1 | As promised, another pullreq... This one's mostly RTH's patches. | 1 | target-arm queue for softfreeze: this is quite big as I |
---|---|---|---|
2 | was on holiday last week, so this is all just sneaking in | ||
3 | under the wire. I particularly wanted to get Philippe's | ||
4 | patches in before freeze as that sort of code-movement | ||
5 | patchset is painful to have to rebase. | ||
2 | 6 | ||
3 | thanks | 7 | thanks |
4 | -- PMM | 8 | -- PMM |
5 | 9 | ||
6 | The following changes since commit 784c2e4f232adf5ef47a84a262ec72a07d068d6a: | 10 | The following changes since commit ae9108f8f0746ce64d02afb1a216153a50926132: |
7 | 11 | ||
8 | Merge remote-tracking branch 'remotes/jasowang/tags/net-pull-request' into staging (2018-10-19 15:30:40 +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) |
9 | 13 | ||
10 | are available in the Git repository at: | 14 | are available in the Git repository at: |
11 | 15 | ||
12 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20181019 | 16 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20190701 |
13 | 17 | ||
14 | for you to fetch changes up to 88c9add25e7120e8622796c81ad3f3fb7f8d40e7: | 18 | for you to fetch changes up to 787a7e76c2e93a48c47b324fea592c9910a70483: |
15 | 19 | ||
16 | target/arm: Only flush tlb if ASID changes (2018-10-19 17:38:48 +0100) | 20 | target/arm: Declare some M-profile functions publicly (2019-07-01 17:29:01 +0100) |
17 | 21 | ||
18 | ---------------------------------------------------------------- | 22 | ---------------------------------------------------------------- |
19 | target-arm queue: | 23 | target-arm queue: |
20 | * ssi-sd: Make devices picking up backends unavailable with -device | 24 | * hw/arm/boot: fix direct kernel boot with initrd |
21 | * Add support for VCPU event states | 25 | * hw/arm/msf2-som: Exit when the cpu is not the expected one |
22 | * Move towards making ID registers the source of truth for | 26 | * i.mx7: fix bugs in PCI controller needed to boot recent kernels |
23 | whether a guest CPU implements a feature, rather than having | 27 | * aspeed: add RTC device |
24 | parallel ID registers and feature bit flags | 28 | * aspeed: fix some timer device bugs |
25 | * Implement various HCR hypervisor trap/config bits | 29 | * aspeed: add swift-bmc board |
26 | * Get IL bit correct for v7 syndrome values | 30 | * aspeed: vic: Add support for legacy register interface |
27 | * Report correct syndrome for FP/SIMD traps to Hyp mode | 31 | * aspeed: add aspeed-xdma device |
28 | * hw/arm/boot: Increase compliance with kernel arm64 boot protocol | 32 | * Add new sbsa-ref board for aarch64 |
29 | * Refactor A32 Neon to use generic vector infrastructure | 33 | * target/arm: code refactoring in preparation for support of |
30 | * Fix a bug in A32 VLD2 "(multiple 2-element structures)" insn | 34 | compilation with TCG disabled |
31 | * net: cadence_gem: Report features correctly in ID register | ||
32 | * Avoid some unnecessary TLB flushes on TTBR register writes | ||
33 | 35 | ||
34 | ---------------------------------------------------------------- | 36 | ---------------------------------------------------------------- |
35 | Dongjiu Geng (1): | 37 | Adriana Kobylak (1): |
36 | target/arm: Add support for VCPU event states | 38 | aspeed: Add support for the swift-bmc board |
37 | 39 | ||
38 | Edgar E. Iglesias (2): | 40 | Andrew Jeffery (3): |
39 | net: cadence_gem: Announce availability of priority queues | 41 | aspeed/timer: Status register contains reload for stopped timer |
40 | net: cadence_gem: Announce 64bit addressing support | 42 | aspeed/timer: Fix match calculations |
43 | aspeed: vic: Add support for legacy register interface | ||
41 | 44 | ||
42 | Markus Armbruster (1): | 45 | Andrew Jones (1): |
43 | ssi-sd: Make devices picking up backends unavailable with -device | 46 | hw/arm/boot: fix direct kernel boot with initrd |
44 | 47 | ||
45 | Peter Maydell (10): | 48 | Andrey Smirnov (5): |
46 | target/arm: Improve debug logging of AArch32 exception return | 49 | i.mx7d: Add no-op/unimplemented APBH DMA module |
47 | target/arm: Make switch_mode() file-local | 50 | i.mx7d: Add no-op/unimplemented PCIE PHY IP block |
48 | target/arm: Implement HCR.FB | 51 | pci: designware: Update MSI mapping unconditionally |
49 | target/arm: Implement HCR.DC | 52 | pci: designware: Update MSI mapping when MSI address changes |
50 | target/arm: ISR_EL1 bits track virtual interrupts if IMO/FMO set | 53 | i.mx7d: pci: Update PCI IRQ mapping to match HW |
51 | target/arm: Implement HCR.VI and VF | ||
52 | target/arm: Implement HCR.PTW | ||
53 | target/arm: New utility function to extract EC from syndrome | ||
54 | target/arm: Get IL bit correct for v7 syndrome values | ||
55 | target/arm: Report correct syndrome for FP/SIMD traps to Hyp mode | ||
56 | 54 | ||
57 | Richard Henderson (30): | 55 | Christian Svensson (1): |
58 | target/arm: Move some system registers into a substructure | 56 | aspeed/timer: Ensure positive muldiv delta |
59 | target/arm: V8M should not imply V7VE | ||
60 | target/arm: Convert v8 extensions from feature bits to isar tests | ||
61 | target/arm: Convert division from feature bits to isar0 tests | ||
62 | target/arm: Convert jazelle from feature bit to isar1 test | ||
63 | target/arm: Convert t32ee from feature bit to isar3 test | ||
64 | target/arm: Convert sve from feature bit to aa64pfr0 test | ||
65 | target/arm: Convert v8.2-fp16 from feature bit to aa64pfr0 test | ||
66 | target/arm: Hoist address increment for vector memory ops | ||
67 | target/arm: Don't call tcg_clear_temp_count | ||
68 | target/arm: Use tcg_gen_gvec_dup_i64 for LD[1-4]R | ||
69 | target/arm: Promote consecutive memory ops for aa64 | ||
70 | target/arm: Mark some arrays const | ||
71 | target/arm: Use gvec for NEON VDUP | ||
72 | target/arm: Use gvec for NEON VMOV, VMVN, VBIC & VORR (immediate) | ||
73 | target/arm: Use gvec for NEON_3R_LOGIC insns | ||
74 | target/arm: Use gvec for NEON_3R_VADD_VSUB insns | ||
75 | target/arm: Use gvec for NEON_2RM_VMN, NEON_2RM_VNEG | ||
76 | target/arm: Use gvec for NEON_3R_VMUL | ||
77 | target/arm: Use gvec for VSHR, VSHL | ||
78 | target/arm: Use gvec for VSRA | ||
79 | target/arm: Use gvec for VSRI, VSLI | ||
80 | target/arm: Use gvec for NEON_3R_VML | ||
81 | target/arm: Use gvec for NEON_3R_VTST_VCEQ, NEON_3R_VCGT, NEON_3R_VCGE | ||
82 | target/arm: Use gvec for NEON VLD all lanes | ||
83 | target/arm: Reorg NEON VLD/VST all elements | ||
84 | target/arm: Promote consecutive memory ops for aa32 | ||
85 | target/arm: Reorg NEON VLD/VST single element to one lane | ||
86 | target/arm: Remove writefn from TTBR0_EL3 | ||
87 | target/arm: Only flush tlb if ASID changes | ||
88 | 57 | ||
89 | Stewart Hildebrand (1): | 58 | Cédric Le Goater (7): |
90 | hw/arm/boot: Increase compliance with kernel arm64 boot protocol | 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 | ||
91 | 66 | ||
92 | target/arm/cpu.h | 227 ++++++- | 67 | Eddie James (1): |
93 | target/arm/internals.h | 45 +- | 68 | hw/misc/aspeed_xdma: New device |
94 | target/arm/kvm_arm.h | 24 + | ||
95 | target/arm/translate.h | 21 + | ||
96 | hw/arm/boot.c | 18 + | ||
97 | hw/intc/armv7m_nvic.c | 12 +- | ||
98 | hw/net/cadence_gem.c | 9 +- | ||
99 | hw/sd/ssi-sd.c | 2 + | ||
100 | linux-user/aarch64/signal.c | 4 +- | ||
101 | linux-user/elfload.c | 60 +- | ||
102 | linux-user/syscall.c | 10 +- | ||
103 | target/arm/cpu.c | 242 ++++---- | ||
104 | target/arm/cpu64.c | 148 +++-- | ||
105 | target/arm/helper.c | 397 ++++++++---- | ||
106 | target/arm/kvm.c | 60 ++ | ||
107 | target/arm/kvm32.c | 13 + | ||
108 | target/arm/kvm64.c | 15 +- | ||
109 | target/arm/machine.c | 28 +- | ||
110 | target/arm/op_helper.c | 2 +- | ||
111 | target/arm/translate-a64.c | 715 ++++----------------- | ||
112 | target/arm/translate.c | 1451 ++++++++++++++++++++++++++++--------------- | ||
113 | 21 files changed, 2021 insertions(+), 1482 deletions(-) | ||
114 | 69 | ||
70 | Hongbo Zhang (2): | ||
71 | hw/arm: Add arm SBSA reference machine, skeleton part | ||
72 | hw/arm: Add arm SBSA reference machine, devices part | ||
73 | |||
74 | Jan Kiszka (1): | ||
75 | hw/arm/virt: Add support for Cortex-A7 | ||
76 | |||
77 | Joel Stanley (4): | ||
78 | hw: timer: Add ASPEED RTC device | ||
79 | hw/arm/aspeed: Add RTC to SoC | ||
80 | aspeed/timer: Fix behaviour running Linux | ||
81 | aspeed: Link SCU to the watchdog | ||
82 | |||
83 | Philippe Mathieu-Daudé (19): | ||
84 | hw/arm/msf2-som: Exit when the cpu is not the expected one | ||
85 | target/arm: Makefile cleanup (Aarch64) | ||
86 | target/arm: Makefile cleanup (ARM) | ||
87 | target/arm: Makefile cleanup (KVM) | ||
88 | target/arm: Makefile cleanup (softmmu) | ||
89 | target/arm: Add copyright boilerplate | ||
90 | target/arm/helper: Remove unused include | ||
91 | target/arm: Fix multiline comment syntax | ||
92 | target/arm: Fix coding style issues | ||
93 | target/arm: Move CPU state dumping routines to cpu.c | ||
94 | target/arm: Declare get_phys_addr() function publicly | ||
95 | target/arm: Move TLB related routines to tlb_helper.c | ||
96 | target/arm/vfp_helper: Move code around | ||
97 | target/arm/vfp_helper: Extract vfp_set_fpscr_to_host() | ||
98 | target/arm/vfp_helper: Extract vfp_set_fpscr_from_host() | ||
99 | target/arm/vfp_helper: Restrict the SoftFloat use to TCG | ||
100 | target/arm: Restrict PSCI to TCG | ||
101 | target/arm: Declare arm_log_exception() function publicly | ||
102 | target/arm: Declare some M-profile functions publicly | ||
103 | |||
104 | Samuel Ortiz (1): | ||
105 | target/arm: Move the DC ZVA helper into op_helper | ||
106 | |||
107 | hw/arm/Makefile.objs | 1 + | ||
108 | hw/misc/Makefile.objs | 1 + | ||
109 | hw/timer/Makefile.objs | 2 +- | ||
110 | target/arm/Makefile.objs | 24 +- | ||
111 | include/hw/arm/aspeed_soc.h | 53 ++- | ||
112 | include/hw/arm/fsl-imx7.h | 14 +- | ||
113 | include/hw/misc/aspeed_xdma.h | 30 ++ | ||
114 | include/hw/ssi/aspeed_smc.h | 3 + | ||
115 | include/hw/timer/aspeed_rtc.h | 31 ++ | ||
116 | include/hw/watchdog/wdt_aspeed.h | 1 + | ||
117 | target/arm/cpu.h | 2 - | ||
118 | target/arm/internals.h | 69 ++- | ||
119 | target/arm/translate.h | 5 - | ||
120 | hw/arm/aspeed.c | 76 +++- | ||
121 | hw/arm/aspeed_soc.c | 262 +++++++++--- | ||
122 | hw/arm/boot.c | 3 +- | ||
123 | hw/arm/fsl-imx7.c | 11 + | ||
124 | hw/arm/msf2-som.c | 1 + | ||
125 | hw/arm/sbsa-ref.c | 806 ++++++++++++++++++++++++++++++++++++ | ||
126 | hw/arm/virt.c | 1 + | ||
127 | hw/intc/aspeed_vic.c | 105 +++-- | ||
128 | hw/misc/aspeed_xdma.c | 165 ++++++++ | ||
129 | hw/pci-host/designware.c | 18 +- | ||
130 | hw/ssi/aspeed_smc.c | 1 + | ||
131 | hw/timer/aspeed_rtc.c | 180 ++++++++ | ||
132 | hw/timer/aspeed_timer.c | 76 ++-- | ||
133 | hw/watchdog/wdt_aspeed.c | 20 + | ||
134 | target/arm/cpu.c | 232 ++++++++++- | ||
135 | target/arm/helper.c | 498 +++++++++------------- | ||
136 | target/arm/op_helper.c | 262 ++++++------ | ||
137 | target/arm/tlb_helper.c | 200 +++++++++ | ||
138 | target/arm/translate-a64.c | 128 ------ | ||
139 | target/arm/translate.c | 91 +--- | ||
140 | target/arm/vfp_helper.c | 199 +++++---- | ||
141 | MAINTAINERS | 8 + | ||
142 | default-configs/aarch64-softmmu.mak | 1 + | ||
143 | hw/arm/Kconfig | 14 + | ||
144 | hw/misc/trace-events | 3 + | ||
145 | hw/timer/trace-events | 4 + | ||
146 | 39 files changed, 2675 insertions(+), 926 deletions(-) | ||
147 | create mode 100644 include/hw/misc/aspeed_xdma.h | ||
148 | create mode 100644 include/hw/timer/aspeed_rtc.h | ||
149 | create mode 100644 hw/arm/sbsa-ref.c | ||
150 | create mode 100644 hw/misc/aspeed_xdma.c | ||
151 | create mode 100644 hw/timer/aspeed_rtc.c | ||
152 | create mode 100644 target/arm/tlb_helper.c | ||
153 | diff view generated by jsdifflib |
1 | From: Stewart Hildebrand <Stewart.Hildebrand@dornerworks.com> | 1 | From: Andrew Jones <drjones@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | "The Image must be placed text_offset bytes from a 2MB aligned base | 3 | Fix the condition used to check whether the initrd fits |
4 | address anywhere in usable system RAM and called there." | 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. | ||
5 | 9 | ||
6 | For the virt board, we write our startup bootloader at the very | 10 | Fixes: 852dc64d665f ("hw/arm/boot: Diagnose layouts that put initrd or |
7 | bottom of RAM, so that bit can't be used for the image. To avoid | 11 | DTB off the end of RAM") |
8 | overlap in case the image requests to be loaded at an offset | 12 | Signed-off-by: Andrew Jones <drjones@redhat.com> |
9 | smaller than our bootloader, we increment the load offset to the | 13 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> |
10 | next 2MB. | 14 | Message-id: 20190618125844.4863-1-drjones@redhat.com |
11 | |||
12 | This fixes a boot failure for Xen AArch64. | ||
13 | |||
14 | Signed-off-by: Stewart Hildebrand <stewart.hildebrand@dornerworks.com> | ||
15 | Tested-by: Andre Przywara <andre.przywara@arm.com> | ||
16 | Message-id: b8a89518794b4436af0c151ed10de4fa@dornerworks.com | ||
17 | [PMM: Rephrased a comment a bit] | ||
18 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
19 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
20 | --- | 16 | --- |
21 | hw/arm/boot.c | 18 ++++++++++++++++++ | 17 | hw/arm/boot.c | 3 ++- |
22 | 1 file changed, 18 insertions(+) | 18 | 1 file changed, 2 insertions(+), 1 deletion(-) |
23 | 19 | ||
24 | diff --git a/hw/arm/boot.c b/hw/arm/boot.c | 20 | diff --git a/hw/arm/boot.c b/hw/arm/boot.c |
25 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
26 | --- a/hw/arm/boot.c | 22 | --- a/hw/arm/boot.c |
27 | +++ b/hw/arm/boot.c | 23 | +++ b/hw/arm/boot.c |
28 | @@ -XXX,XX +XXX,XX @@ | 24 | @@ -XXX,XX +XXX,XX @@ static void arm_setup_direct_kernel_boot(ARMCPU *cpu, |
29 | #include "qemu/config-file.h" | 25 | info->initrd_filename); |
30 | #include "qemu/option.h" | 26 | exit(1); |
31 | #include "exec/address-spaces.h" | 27 | } |
32 | +#include "qemu/units.h" | 28 | - if (info->initrd_start + initrd_size > info->ram_size) { |
33 | 29 | + if (info->initrd_start + initrd_size > ram_end) { | |
34 | /* Kernel boot protocol is specified in the kernel docs | 30 | error_report("could not load initrd '%s': " |
35 | * Documentation/arm/Booting and Documentation/arm64/booting.txt | 31 | "too big to fit into RAM after the kernel", |
36 | @@ -XXX,XX +XXX,XX @@ | 32 | info->initrd_filename); |
37 | #define ARM64_TEXT_OFFSET_OFFSET 8 | 33 | + exit(1); |
38 | #define ARM64_MAGIC_OFFSET 56 | 34 | } |
39 | 35 | } else { | |
40 | +#define BOOTLOADER_MAX_SIZE (4 * KiB) | 36 | initrd_size = 0; |
41 | + | ||
42 | AddressSpace *arm_boot_address_space(ARMCPU *cpu, | ||
43 | const struct arm_boot_info *info) | ||
44 | { | ||
45 | @@ -XXX,XX +XXX,XX @@ static void write_bootloader(const char *name, hwaddr addr, | ||
46 | code[i] = tswap32(insn); | ||
47 | } | ||
48 | |||
49 | + assert((len * sizeof(uint32_t)) < BOOTLOADER_MAX_SIZE); | ||
50 | + | ||
51 | rom_add_blob_fixed_as(name, code, len * sizeof(uint32_t), addr, as); | ||
52 | |||
53 | g_free(code); | ||
54 | @@ -XXX,XX +XXX,XX @@ static uint64_t load_aarch64_image(const char *filename, hwaddr mem_base, | ||
55 | memcpy(&hdrvals, buffer + ARM64_TEXT_OFFSET_OFFSET, sizeof(hdrvals)); | ||
56 | if (hdrvals[1] != 0) { | ||
57 | kernel_load_offset = le64_to_cpu(hdrvals[0]); | ||
58 | + | ||
59 | + /* | ||
60 | + * We write our startup "bootloader" at the very bottom of RAM, | ||
61 | + * so that bit can't be used for the image. Luckily the Image | ||
62 | + * format specification is that the image requests only an offset | ||
63 | + * from a 2MB boundary, not an absolute load address. So if the | ||
64 | + * image requests an offset that might mean it overlaps with the | ||
65 | + * bootloader, we can just load it starting at 2MB+offset rather | ||
66 | + * than 0MB + offset. | ||
67 | + */ | ||
68 | + if (kernel_load_offset < BOOTLOADER_MAX_SIZE) { | ||
69 | + kernel_load_offset += 2 * MiB; | ||
70 | + } | ||
71 | } | ||
72 | } | ||
73 | |||
74 | -- | 37 | -- |
75 | 2.19.1 | 38 | 2.20.1 |
76 | 39 | ||
77 | 40 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | Since QEMU does not implement ASIDs, changes to the ASID must flush the | 3 | This machine correctly defines its default_cpu_type to cortex-m3 |
4 | tlb. However, if the ASID does not change there is no reason to flush. | 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: | ||
5 | 7 | ||
6 | In testing a boot of the Ubuntu installer to the first menu, this reduces | 8 | $ qemu-system-arm -M emcraft-sf2 -cpu cortex-m4 -kernel test-m4.elf |
7 | the number of flushes by 30%, or nearly 600k instances. | 9 | qemu-system-arm: This board can only be used with CPU cortex-m3-arm-cpu |
10 | [output related to M3 core ...] | ||
8 | 11 | ||
9 | Reviewed-by: Aaron Lindsay <aaron@os.amperecomputing.com> | 12 | The CPU is indeed a M3 core: |
10 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 13 | |
11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 14 | (qemu) info qom-tree |
12 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 15 | /machine (emcraft-sf2-machine) |
13 | Message-id: 20181019015617.22583-3-richard.henderson@linaro.org | 16 | /unattached (container) |
17 | /device[0] (msf2-soc) | ||
18 | /armv7m (armv7m) | ||
19 | /cpu (cortex-m3-arm-cpu) | ||
20 | |||
21 | Add the missing exit() call to return to the shell. | ||
22 | |||
23 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
24 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
25 | Reviewed-by: Eduardo Habkost <ehabkost@redhat.com> | ||
26 | Message-id: 20190617160136.29930-1-philmd@redhat.com | ||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 27 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
15 | --- | 28 | --- |
16 | target/arm/helper.c | 8 +++----- | 29 | hw/arm/msf2-som.c | 1 + |
17 | 1 file changed, 3 insertions(+), 5 deletions(-) | 30 | 1 file changed, 1 insertion(+) |
18 | 31 | ||
19 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 32 | diff --git a/hw/arm/msf2-som.c b/hw/arm/msf2-som.c |
20 | index XXXXXXX..XXXXXXX 100644 | 33 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/target/arm/helper.c | 34 | --- a/hw/arm/msf2-som.c |
22 | +++ b/target/arm/helper.c | 35 | +++ b/hw/arm/msf2-som.c |
23 | @@ -XXX,XX +XXX,XX @@ static void vmsa_tcr_el1_write(CPUARMState *env, const ARMCPRegInfo *ri, | 36 | @@ -XXX,XX +XXX,XX @@ static void emcraft_sf2_s2s010_init(MachineState *machine) |
24 | static void vmsa_ttbr_write(CPUARMState *env, const ARMCPRegInfo *ri, | 37 | if (strcmp(machine->cpu_type, mc->default_cpu_type) != 0) { |
25 | uint64_t value) | 38 | error_report("This board can only be used with CPU %s", |
26 | { | 39 | mc->default_cpu_type); |
27 | - /* 64 bit accesses to the TTBRs can change the ASID and so we | 40 | + exit(1); |
28 | - * must flush the TLB. | ||
29 | - */ | ||
30 | - if (cpreg_field_is_64bit(ri)) { | ||
31 | + /* If the ASID changes (with a 64-bit write), we must flush the TLB. */ | ||
32 | + if (cpreg_field_is_64bit(ri) && | ||
33 | + extract64(raw_read(env, ri) ^ value, 48, 16) != 0) { | ||
34 | ARMCPU *cpu = arm_env_get_cpu(env); | ||
35 | - | ||
36 | tlb_flush(CPU(cpu)); | ||
37 | } | 41 | } |
38 | raw_write(env, ri, value); | 42 | |
43 | memory_region_init_ram(ddr, NULL, "ddr-ram", DDR_SIZE, | ||
39 | -- | 44 | -- |
40 | 2.19.1 | 45 | 2.20.1 |
41 | 46 | ||
42 | 47 | diff view generated by jsdifflib |
1 | From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com> | 1 | From: Jan Kiszka <jan.kiszka@siemens.com> |
---|---|---|---|
2 | 2 | ||
3 | Announce 64bit addressing support. | 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. | ||
4 | 5 | ||
5 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | 6 | Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> |
6 | Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> | 7 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> |
7 | Message-id: 20181017213932.19973-3-edgar.iglesias@gmail.com | 8 | Message-id: fc5404f7-4d1d-c28f-6e48-d8799c82acc0@web.de |
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 11 | --- |
11 | hw/net/cadence_gem.c | 3 ++- | 12 | hw/arm/virt.c | 1 + |
12 | 1 file changed, 2 insertions(+), 1 deletion(-) | 13 | 1 file changed, 1 insertion(+) |
13 | 14 | ||
14 | diff --git a/hw/net/cadence_gem.c b/hw/net/cadence_gem.c | 15 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c |
15 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/hw/net/cadence_gem.c | 17 | --- a/hw/arm/virt.c |
17 | +++ b/hw/net/cadence_gem.c | 18 | +++ b/hw/arm/virt.c |
18 | @@ -XXX,XX +XXX,XX @@ | 19 | @@ -XXX,XX +XXX,XX @@ static const int a15irqmap[] = { |
19 | #define GEM_DESCONF4 (0x0000028C/4) | 20 | }; |
20 | #define GEM_DESCONF5 (0x00000290/4) | 21 | |
21 | #define GEM_DESCONF6 (0x00000294/4) | 22 | static const char *valid_cpus[] = { |
22 | +#define GEM_DESCONF6_64B_MASK (1U << 23) | 23 | + ARM_CPU_TYPE_NAME("cortex-a7"), |
23 | #define GEM_DESCONF7 (0x00000298/4) | 24 | ARM_CPU_TYPE_NAME("cortex-a15"), |
24 | 25 | ARM_CPU_TYPE_NAME("cortex-a53"), | |
25 | #define GEM_INT_Q1_STATUS (0x00000400 / 4) | 26 | ARM_CPU_TYPE_NAME("cortex-a57"), |
26 | @@ -XXX,XX +XXX,XX @@ static void gem_reset(DeviceState *d) | ||
27 | s->regs[GEM_DESCONF] = 0x02500111; | ||
28 | s->regs[GEM_DESCONF2] = 0x2ab13fff; | ||
29 | s->regs[GEM_DESCONF5] = 0x002f2045; | ||
30 | - s->regs[GEM_DESCONF6] = 0x0; | ||
31 | + s->regs[GEM_DESCONF6] = GEM_DESCONF6_64B_MASK; | ||
32 | |||
33 | if (s->num_priority_queues > 1) { | ||
34 | queues_mask = MAKE_64BIT_MASK(1, s->num_priority_queues - 1); | ||
35 | -- | 27 | -- |
36 | 2.19.1 | 28 | 2.20.1 |
37 | 29 | ||
38 | 30 | diff view generated by jsdifflib |
1 | The HCR_EL2 VI and VF bits are supposed to track whether there is | 1 | From: Andrey Smirnov <andrew.smirnov@gmail.com> |
---|---|---|---|
2 | a pending virtual IRQ or virtual FIQ. For QEMU we store the | ||
3 | pending VIRQ/VFIQ status in cs->interrupt_request, so this means: | ||
4 | * if the register is read we must get these bit values from | ||
5 | cs->interrupt_request | ||
6 | * if the register is written then we must write the bit | ||
7 | values back into cs->interrupt_request | ||
8 | 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 | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
11 | Message-id: 20181012144235.19646-7-peter.maydell@linaro.org | ||
12 | --- | 12 | --- |
13 | target/arm/helper.c | 47 +++++++++++++++++++++++++++++++++++++++++---- | 13 | include/hw/arm/fsl-imx7.h | 3 +++ |
14 | 1 file changed, 43 insertions(+), 4 deletions(-) | 14 | hw/arm/fsl-imx7.c | 6 ++++++ |
15 | 2 files changed, 9 insertions(+) | ||
15 | 16 | ||
16 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 17 | diff --git a/include/hw/arm/fsl-imx7.h b/include/hw/arm/fsl-imx7.h |
17 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/target/arm/helper.c | 19 | --- a/include/hw/arm/fsl-imx7.h |
19 | +++ b/target/arm/helper.c | 20 | +++ b/include/hw/arm/fsl-imx7.h |
20 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo el3_no_el2_v8_cp_reginfo[] = { | 21 | @@ -XXX,XX +XXX,XX @@ enum FslIMX7MemoryMap { |
21 | static void hcr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) | 22 | FSL_IMX7_PCIE_REG_SIZE = 16 * 1024, |
22 | { | 23 | |
23 | ARMCPU *cpu = arm_env_get_cpu(env); | 24 | FSL_IMX7_GPR_ADDR = 0x30340000, |
24 | + CPUState *cs = ENV_GET_CPU(env); | 25 | + |
25 | uint64_t valid_mask = HCR_MASK; | 26 | + FSL_IMX7_DMA_APBH_ADDR = 0x33000000, |
26 | 27 | + FSL_IMX7_DMA_APBH_SIZE = 0x2000, | |
27 | if (arm_feature(env, ARM_FEATURE_EL3)) { | 28 | }; |
28 | @@ -XXX,XX +XXX,XX @@ static void hcr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) | 29 | |
29 | /* Clear RES0 bits. */ | 30 | enum FslIMX7IRQs { |
30 | value &= valid_mask; | 31 | diff --git a/hw/arm/fsl-imx7.c b/hw/arm/fsl-imx7.c |
31 | 32 | index XXXXXXX..XXXXXXX 100644 | |
33 | --- a/hw/arm/fsl-imx7.c | ||
34 | +++ b/hw/arm/fsl-imx7.c | ||
35 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) | ||
36 | */ | ||
37 | create_unimplemented_device("lcdif", FSL_IMX7_LCDIF_ADDR, | ||
38 | FSL_IMX7_LCDIF_SIZE); | ||
39 | + | ||
32 | + /* | 40 | + /* |
33 | + * VI and VF are kept in cs->interrupt_request. Modifying that | 41 | + * DMA APBH |
34 | + * requires that we have the iothread lock, which is done by | ||
35 | + * marking the reginfo structs as ARM_CP_IO. | ||
36 | + * Note that if a write to HCR pends a VIRQ or VFIQ it is never | ||
37 | + * possible for it to be taken immediately, because VIRQ and | ||
38 | + * VFIQ are masked unless running at EL0 or EL1, and HCR | ||
39 | + * can only be written at EL2. | ||
40 | + */ | 42 | + */ |
41 | + g_assert(qemu_mutex_iothread_locked()); | 43 | + create_unimplemented_device("dma-apbh", FSL_IMX7_DMA_APBH_ADDR, |
42 | + if (value & HCR_VI) { | 44 | + FSL_IMX7_DMA_APBH_SIZE); |
43 | + cs->interrupt_request |= CPU_INTERRUPT_VIRQ; | ||
44 | + } else { | ||
45 | + cs->interrupt_request &= ~CPU_INTERRUPT_VIRQ; | ||
46 | + } | ||
47 | + if (value & HCR_VF) { | ||
48 | + cs->interrupt_request |= CPU_INTERRUPT_VFIQ; | ||
49 | + } else { | ||
50 | + cs->interrupt_request &= ~CPU_INTERRUPT_VFIQ; | ||
51 | + } | ||
52 | + value &= ~(HCR_VI | HCR_VF); | ||
53 | + | ||
54 | /* These bits change the MMU setup: | ||
55 | * HCR_VM enables stage 2 translation | ||
56 | * HCR_PTW forbids certain page-table setups | ||
57 | @@ -XXX,XX +XXX,XX @@ static void hcr_writelow(CPUARMState *env, const ARMCPRegInfo *ri, | ||
58 | hcr_write(env, NULL, value); | ||
59 | } | 45 | } |
60 | 46 | ||
61 | +static uint64_t hcr_read(CPUARMState *env, const ARMCPRegInfo *ri) | 47 | static void fsl_imx7_class_init(ObjectClass *oc, void *data) |
62 | +{ | ||
63 | + /* The VI and VF bits live in cs->interrupt_request */ | ||
64 | + uint64_t ret = env->cp15.hcr_el2 & ~(HCR_VI | HCR_VF); | ||
65 | + CPUState *cs = ENV_GET_CPU(env); | ||
66 | + | ||
67 | + if (cs->interrupt_request & CPU_INTERRUPT_VIRQ) { | ||
68 | + ret |= HCR_VI; | ||
69 | + } | ||
70 | + if (cs->interrupt_request & CPU_INTERRUPT_VFIQ) { | ||
71 | + ret |= HCR_VF; | ||
72 | + } | ||
73 | + return ret; | ||
74 | +} | ||
75 | + | ||
76 | static const ARMCPRegInfo el2_cp_reginfo[] = { | ||
77 | { .name = "HCR_EL2", .state = ARM_CP_STATE_AA64, | ||
78 | + .type = ARM_CP_IO, | ||
79 | .opc0 = 3, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 0, | ||
80 | .access = PL2_RW, .fieldoffset = offsetof(CPUARMState, cp15.hcr_el2), | ||
81 | - .writefn = hcr_write }, | ||
82 | + .writefn = hcr_write, .readfn = hcr_read }, | ||
83 | { .name = "HCR", .state = ARM_CP_STATE_AA32, | ||
84 | - .type = ARM_CP_ALIAS, | ||
85 | + .type = ARM_CP_ALIAS | ARM_CP_IO, | ||
86 | .cp = 15, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 0, | ||
87 | .access = PL2_RW, .fieldoffset = offsetof(CPUARMState, cp15.hcr_el2), | ||
88 | - .writefn = hcr_writelow }, | ||
89 | + .writefn = hcr_writelow, .readfn = hcr_read }, | ||
90 | { .name = "ELR_EL2", .state = ARM_CP_STATE_AA64, | ||
91 | .type = ARM_CP_ALIAS, | ||
92 | .opc0 = 3, .opc1 = 4, .crn = 4, .crm = 0, .opc2 = 1, | ||
93 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo el2_cp_reginfo[] = { | ||
94 | |||
95 | static const ARMCPRegInfo el2_v8_cp_reginfo[] = { | ||
96 | { .name = "HCR2", .state = ARM_CP_STATE_AA32, | ||
97 | - .type = ARM_CP_ALIAS, | ||
98 | + .type = ARM_CP_ALIAS | ARM_CP_IO, | ||
99 | .cp = 15, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 4, | ||
100 | .access = PL2_RW, | ||
101 | .fieldoffset = offsetofhigh32(CPUARMState, cp15.hcr_el2), | ||
102 | -- | 48 | -- |
103 | 2.19.1 | 49 | 2.20.1 |
104 | 50 | ||
105 | 51 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Andrey Smirnov <andrew.smirnov@gmail.com> |
---|---|---|---|
2 | 2 | ||
3 | This is done generically in translator_loop. | 3 | Add no-op/unimplemented PCIE PHY IP block. Needed by new kernels to |
4 | use PCIE. | ||
4 | 5 | ||
5 | Reported-by: Laurent Desnogues <laurent.desnogues@gmail.com> | 6 | Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> |
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 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 | ||
7 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 11 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> |
8 | Message-id: 20181011205206.3552-3-richard.henderson@linaro.org | ||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 13 | --- |
12 | target/arm/translate-a64.c | 1 - | 14 | include/hw/arm/fsl-imx7.h | 3 +++ |
13 | target/arm/translate.c | 1 - | 15 | hw/arm/fsl-imx7.c | 5 +++++ |
14 | 2 files changed, 2 deletions(-) | 16 | 2 files changed, 8 insertions(+) |
15 | 17 | ||
16 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 18 | diff --git a/include/hw/arm/fsl-imx7.h b/include/hw/arm/fsl-imx7.h |
17 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/target/arm/translate-a64.c | 20 | --- a/include/hw/arm/fsl-imx7.h |
19 | +++ b/target/arm/translate-a64.c | 21 | +++ b/include/hw/arm/fsl-imx7.h |
20 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_init_disas_context(DisasContextBase *dcbase, | 22 | @@ -XXX,XX +XXX,XX @@ enum FslIMX7MemoryMap { |
21 | 23 | FSL_IMX7_ADC2_ADDR = 0x30620000, | |
22 | static void aarch64_tr_tb_start(DisasContextBase *db, CPUState *cpu) | 24 | FSL_IMX7_ADCn_SIZE = 0x1000, |
23 | { | 25 | |
24 | - tcg_clear_temp_count(); | 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); | ||
25 | } | 45 | } |
26 | 46 | ||
27 | static void aarch64_tr_insn_start(DisasContextBase *dcbase, CPUState *cpu) | 47 | static void fsl_imx7_class_init(ObjectClass *oc, void *data) |
28 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
29 | index XXXXXXX..XXXXXXX 100644 | ||
30 | --- a/target/arm/translate.c | ||
31 | +++ b/target/arm/translate.c | ||
32 | @@ -XXX,XX +XXX,XX @@ static void arm_tr_tb_start(DisasContextBase *dcbase, CPUState *cpu) | ||
33 | tcg_gen_movi_i32(tmp, 0); | ||
34 | store_cpu_field(tmp, condexec_bits); | ||
35 | } | ||
36 | - tcg_clear_temp_count(); | ||
37 | } | ||
38 | |||
39 | static void arm_tr_insn_start(DisasContextBase *dcbase, CPUState *cpu) | ||
40 | -- | 48 | -- |
41 | 2.19.1 | 49 | 2.20.1 |
42 | 50 | ||
43 | 51 | diff view generated by jsdifflib |
1 | From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com> | 1 | From: Andrey Smirnov <andrew.smirnov@gmail.com> |
---|---|---|---|
2 | 2 | ||
3 | Announce the availability of the various priority queues. | 3 | Expression to calculate update_msi_mapping in code handling writes to |
4 | This fixes an issue where guest kernels would miss to | 4 | DESIGNWARE_PCIE_MSI_INTR0_ENABLE is missing an ! operator and should |
5 | configure secondary queues due to inproper feature bits. | 5 | be: |
6 | 6 | ||
7 | Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> | 7 | !!root->msi.intr[0].enable ^ !!val; |
8 | Message-id: 20181017213932.19973-2-edgar.iglesias@gmail.com | 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> | ||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 20 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 21 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 22 | --- |
12 | hw/net/cadence_gem.c | 8 +++++++- | 23 | hw/pci-host/designware.c | 10 ++-------- |
13 | 1 file changed, 7 insertions(+), 1 deletion(-) | 24 | 1 file changed, 2 insertions(+), 8 deletions(-) |
14 | 25 | ||
15 | diff --git a/hw/net/cadence_gem.c b/hw/net/cadence_gem.c | 26 | diff --git a/hw/pci-host/designware.c b/hw/pci-host/designware.c |
16 | index XXXXXXX..XXXXXXX 100644 | 27 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/hw/net/cadence_gem.c | 28 | --- a/hw/pci-host/designware.c |
18 | +++ b/hw/net/cadence_gem.c | 29 | +++ b/hw/pci-host/designware.c |
19 | @@ -XXX,XX +XXX,XX @@ static void gem_reset(DeviceState *d) | 30 | @@ -XXX,XX +XXX,XX @@ static void designware_pcie_root_config_write(PCIDevice *d, uint32_t address, |
20 | int i; | 31 | root->msi.base |= (uint64_t)val << 32; |
21 | CadenceGEMState *s = CADENCE_GEM(d); | 32 | break; |
22 | const uint8_t *a; | 33 | |
23 | + uint32_t queues_mask = 0; | 34 | - case DESIGNWARE_PCIE_MSI_INTR0_ENABLE: { |
24 | 35 | - const bool update_msi_mapping = !root->msi.intr[0].enable ^ !!val; | |
25 | DB_PRINT("\n"); | 36 | - |
26 | 37 | + case DESIGNWARE_PCIE_MSI_INTR0_ENABLE: | |
27 | @@ -XXX,XX +XXX,XX @@ static void gem_reset(DeviceState *d) | 38 | root->msi.intr[0].enable = val; |
28 | s->regs[GEM_DESCONF] = 0x02500111; | 39 | - |
29 | s->regs[GEM_DESCONF2] = 0x2ab13fff; | 40 | - if (update_msi_mapping) { |
30 | s->regs[GEM_DESCONF5] = 0x002f2045; | 41 | - designware_pcie_root_update_msi_mapping(root); |
31 | - s->regs[GEM_DESCONF6] = 0x00000200; | 42 | - } |
32 | + s->regs[GEM_DESCONF6] = 0x0; | 43 | + designware_pcie_root_update_msi_mapping(root); |
33 | + | 44 | break; |
34 | + if (s->num_priority_queues > 1) { | 45 | - } |
35 | + queues_mask = MAKE_64BIT_MASK(1, s->num_priority_queues - 1); | 46 | |
36 | + s->regs[GEM_DESCONF6] |= queues_mask; | 47 | case DESIGNWARE_PCIE_MSI_INTR0_MASK: |
37 | + } | 48 | root->msi.intr[0].mask = val; |
38 | |||
39 | /* Set MAC address */ | ||
40 | a = &s->conf.macaddr.a[0]; | ||
41 | -- | 49 | -- |
42 | 2.19.1 | 50 | 2.20.1 |
43 | 51 | ||
44 | 52 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Andrey Smirnov <andrew.smirnov@gmail.com> |
---|---|---|---|
2 | 2 | ||
3 | For a sequence of loads or stores from a single register, | 3 | MSI mapping needs to be update when MSI address changes, so add the |
4 | little-endian operations can be promoted to an 8-byte op. | 4 | code to do so. |
5 | This can reduce the number of operations by a factor of 8. | ||
6 | 5 | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 6 | Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> |
8 | Message-id: 20181011205206.3552-20-richard.henderson@linaro.org | 7 | Cc: Peter Maydell <peter.maydell@linaro.org> |
9 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 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> | ||
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | --- | 14 | --- |
13 | target/arm/translate.c | 10 ++++++++++ | 15 | hw/pci-host/designware.c | 2 ++ |
14 | 1 file changed, 10 insertions(+) | 16 | 1 file changed, 2 insertions(+) |
15 | 17 | ||
16 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 18 | diff --git a/hw/pci-host/designware.c b/hw/pci-host/designware.c |
17 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/target/arm/translate.c | 20 | --- a/hw/pci-host/designware.c |
19 | +++ b/target/arm/translate.c | 21 | +++ b/hw/pci-host/designware.c |
20 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_ls_insn(DisasContext *s, uint32_t insn) | 22 | @@ -XXX,XX +XXX,XX @@ static void designware_pcie_root_config_write(PCIDevice *d, uint32_t address, |
21 | if (size == 3 && (interleave | spacing) != 1) { | 23 | case DESIGNWARE_PCIE_MSI_ADDR_LO: |
22 | return 1; | 24 | root->msi.base &= 0xFFFFFFFF00000000ULL; |
23 | } | 25 | root->msi.base |= val; |
24 | + /* For our purposes, bytes are always little-endian. */ | 26 | + designware_pcie_root_update_msi_mapping(root); |
25 | + if (size == 0) { | 27 | break; |
26 | + endian = MO_LE; | 28 | |
27 | + } | 29 | case DESIGNWARE_PCIE_MSI_ADDR_HI: |
28 | + /* Consecutive little-endian elements from a single register | 30 | root->msi.base &= 0x00000000FFFFFFFFULL; |
29 | + * can be promoted to a larger little-endian operation. | 31 | root->msi.base |= (uint64_t)val << 32; |
30 | + */ | 32 | + designware_pcie_root_update_msi_mapping(root); |
31 | + if (interleave == 1 && endian == MO_LE) { | 33 | break; |
32 | + size = 3; | 34 | |
33 | + } | 35 | case DESIGNWARE_PCIE_MSI_INTR0_ENABLE: |
34 | tmp64 = tcg_temp_new_i64(); | ||
35 | addr = tcg_temp_new_i32(); | ||
36 | tmp2 = tcg_const_i32(1 << size); | ||
37 | -- | 36 | -- |
38 | 2.19.1 | 37 | 2.20.1 |
39 | 38 | ||
40 | 39 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Andrey Smirnov <andrew.smirnov@gmail.com> |
---|---|---|---|
2 | 2 | ||
3 | Move cmtst_op expanders from translate-a64.c. | 3 | Datasheet for i.MX7 is incorrect and i.MX7's PCI IRQ mapping matches |
4 | that of i.MX6: | ||
4 | 5 | ||
5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 6 | * INTD/MSI 122 |
6 | Message-id: 20181011205206.3552-17-richard.henderson@linaro.org | 7 | * INTC 123 |
8 | * INTB 124 | ||
9 | * INTA 125 | ||
10 | |||
11 | Fix all of the relevant code to reflect that fact. Needed by latest | ||
12 | Linux kernels. | ||
13 | |||
14 | (Reference: Linux kernel commit 538d6e9d597584e80 from an | ||
15 | NXP employee confirming that the datasheet is incorrect and | ||
16 | with a report of a test against hardware.) | ||
17 | |||
18 | Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> | ||
19 | Cc: Peter Maydell <peter.maydell@linaro.org> | ||
20 | Cc: Michael S. Tsirkin <mst@redhat.com> | ||
21 | Cc: qemu-devel@nongnu.org | ||
22 | Cc: qemu-arm@nongnu.org | ||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 23 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
24 | [PMM: added ref to kernel commit confirming the datasheet error] | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 25 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | --- | 26 | --- |
10 | target/arm/translate.h | 2 + | 27 | include/hw/arm/fsl-imx7.h | 8 ++++---- |
11 | target/arm/translate-a64.c | 38 ------------------ | 28 | hw/pci-host/designware.c | 6 ++++-- |
12 | target/arm/translate.c | 81 +++++++++++++++++++++++++++----------- | 29 | 2 files changed, 8 insertions(+), 6 deletions(-) |
13 | 3 files changed, 60 insertions(+), 61 deletions(-) | ||
14 | 30 | ||
15 | diff --git a/target/arm/translate.h b/target/arm/translate.h | 31 | diff --git a/include/hw/arm/fsl-imx7.h b/include/hw/arm/fsl-imx7.h |
16 | index XXXXXXX..XXXXXXX 100644 | 32 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/translate.h | 33 | --- a/include/hw/arm/fsl-imx7.h |
18 | +++ b/target/arm/translate.h | 34 | +++ b/include/hw/arm/fsl-imx7.h |
19 | @@ -XXX,XX +XXX,XX @@ extern const GVecGen3 bit_op; | 35 | @@ -XXX,XX +XXX,XX @@ enum FslIMX7IRQs { |
20 | extern const GVecGen3 bif_op; | 36 | FSL_IMX7_USB2_IRQ = 42, |
21 | extern const GVecGen3 mla_op[4]; | 37 | FSL_IMX7_USB3_IRQ = 40, |
22 | extern const GVecGen3 mls_op[4]; | 38 | |
23 | +extern const GVecGen3 cmtst_op[4]; | 39 | - FSL_IMX7_PCI_INTA_IRQ = 122, |
24 | extern const GVecGen2i ssra_op[4]; | 40 | - FSL_IMX7_PCI_INTB_IRQ = 123, |
25 | extern const GVecGen2i usra_op[4]; | 41 | - FSL_IMX7_PCI_INTC_IRQ = 124, |
26 | extern const GVecGen2i sri_op[4]; | 42 | - FSL_IMX7_PCI_INTD_IRQ = 125, |
27 | extern const GVecGen2i sli_op[4]; | 43 | + FSL_IMX7_PCI_INTA_IRQ = 125, |
28 | +void gen_cmtst_i64(TCGv_i64 d, TCGv_i64 a, TCGv_i64 b); | 44 | + FSL_IMX7_PCI_INTB_IRQ = 124, |
29 | 45 | + FSL_IMX7_PCI_INTC_IRQ = 123, | |
30 | /* | 46 | + FSL_IMX7_PCI_INTD_IRQ = 122, |
31 | * Forward to the isar_feature_* tests given a DisasContext pointer. | 47 | |
32 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 48 | FSL_IMX7_UART7_IRQ = 126, |
49 | |||
50 | diff --git a/hw/pci-host/designware.c b/hw/pci-host/designware.c | ||
33 | index XXXXXXX..XXXXXXX 100644 | 51 | index XXXXXXX..XXXXXXX 100644 |
34 | --- a/target/arm/translate-a64.c | 52 | --- a/hw/pci-host/designware.c |
35 | +++ b/target/arm/translate-a64.c | 53 | +++ b/hw/pci-host/designware.c |
36 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_scalar_three_reg_diff(DisasContext *s, uint32_t insn) | 54 | @@ -XXX,XX +XXX,XX @@ |
55 | #define DESIGNWARE_PCIE_ATU_DEVFN(x) (((x) >> 16) & 0xff) | ||
56 | #define DESIGNWARE_PCIE_ATU_UPPER_TARGET 0x91C | ||
57 | |||
58 | +#define DESIGNWARE_PCIE_IRQ_MSI 3 | ||
59 | + | ||
60 | static DesignwarePCIEHost * | ||
61 | designware_pcie_root_to_host(DesignwarePCIERoot *root) | ||
62 | { | ||
63 | @@ -XXX,XX +XXX,XX @@ static void designware_pcie_root_msi_write(void *opaque, hwaddr addr, | ||
64 | root->msi.intr[0].status |= BIT(val) & root->msi.intr[0].enable; | ||
65 | |||
66 | if (root->msi.intr[0].status & ~root->msi.intr[0].mask) { | ||
67 | - qemu_set_irq(host->pci.irqs[0], 1); | ||
68 | + qemu_set_irq(host->pci.irqs[DESIGNWARE_PCIE_IRQ_MSI], 1); | ||
37 | } | 69 | } |
38 | } | 70 | } |
39 | 71 | ||
40 | -/* CMTST : test is "if (X & Y != 0)". */ | 72 | @@ -XXX,XX +XXX,XX @@ static void designware_pcie_root_config_write(PCIDevice *d, uint32_t address, |
41 | -static void gen_cmtst_i32(TCGv_i32 d, TCGv_i32 a, TCGv_i32 b) | 73 | case DESIGNWARE_PCIE_MSI_INTR0_STATUS: |
42 | -{ | 74 | root->msi.intr[0].status ^= val; |
43 | - tcg_gen_and_i32(d, a, b); | 75 | if (!root->msi.intr[0].status) { |
44 | - tcg_gen_setcondi_i32(TCG_COND_NE, d, d, 0); | 76 | - qemu_set_irq(host->pci.irqs[0], 0); |
45 | - tcg_gen_neg_i32(d, d); | 77 | + qemu_set_irq(host->pci.irqs[DESIGNWARE_PCIE_IRQ_MSI], 0); |
46 | -} | ||
47 | - | ||
48 | -static void gen_cmtst_i64(TCGv_i64 d, TCGv_i64 a, TCGv_i64 b) | ||
49 | -{ | ||
50 | - tcg_gen_and_i64(d, a, b); | ||
51 | - tcg_gen_setcondi_i64(TCG_COND_NE, d, d, 0); | ||
52 | - tcg_gen_neg_i64(d, d); | ||
53 | -} | ||
54 | - | ||
55 | -static void gen_cmtst_vec(unsigned vece, TCGv_vec d, TCGv_vec a, TCGv_vec b) | ||
56 | -{ | ||
57 | - tcg_gen_and_vec(vece, d, a, b); | ||
58 | - tcg_gen_dupi_vec(vece, a, 0); | ||
59 | - tcg_gen_cmp_vec(TCG_COND_NE, vece, d, d, a); | ||
60 | -} | ||
61 | - | ||
62 | static void handle_3same_64(DisasContext *s, int opcode, bool u, | ||
63 | TCGv_i64 tcg_rd, TCGv_i64 tcg_rn, TCGv_i64 tcg_rm) | ||
64 | { | ||
65 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_3same_float(DisasContext *s, uint32_t insn) | ||
66 | /* Integer op subgroup of C3.6.16. */ | ||
67 | static void disas_simd_3same_int(DisasContext *s, uint32_t insn) | ||
68 | { | ||
69 | - static const GVecGen3 cmtst_op[4] = { | ||
70 | - { .fni4 = gen_helper_neon_tst_u8, | ||
71 | - .fniv = gen_cmtst_vec, | ||
72 | - .vece = MO_8 }, | ||
73 | - { .fni4 = gen_helper_neon_tst_u16, | ||
74 | - .fniv = gen_cmtst_vec, | ||
75 | - .vece = MO_16 }, | ||
76 | - { .fni4 = gen_cmtst_i32, | ||
77 | - .fniv = gen_cmtst_vec, | ||
78 | - .vece = MO_32 }, | ||
79 | - { .fni8 = gen_cmtst_i64, | ||
80 | - .fniv = gen_cmtst_vec, | ||
81 | - .prefer_i64 = TCG_TARGET_REG_BITS == 64, | ||
82 | - .vece = MO_64 }, | ||
83 | - }; | ||
84 | - | ||
85 | int is_q = extract32(insn, 30, 1); | ||
86 | int u = extract32(insn, 29, 1); | ||
87 | int size = extract32(insn, 22, 2); | ||
88 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
89 | index XXXXXXX..XXXXXXX 100644 | ||
90 | --- a/target/arm/translate.c | ||
91 | +++ b/target/arm/translate.c | ||
92 | @@ -XXX,XX +XXX,XX @@ const GVecGen3 mls_op[4] = { | ||
93 | .vece = MO_64 }, | ||
94 | }; | ||
95 | |||
96 | +/* CMTST : test is "if (X & Y != 0)". */ | ||
97 | +static void gen_cmtst_i32(TCGv_i32 d, TCGv_i32 a, TCGv_i32 b) | ||
98 | +{ | ||
99 | + tcg_gen_and_i32(d, a, b); | ||
100 | + tcg_gen_setcondi_i32(TCG_COND_NE, d, d, 0); | ||
101 | + tcg_gen_neg_i32(d, d); | ||
102 | +} | ||
103 | + | ||
104 | +void gen_cmtst_i64(TCGv_i64 d, TCGv_i64 a, TCGv_i64 b) | ||
105 | +{ | ||
106 | + tcg_gen_and_i64(d, a, b); | ||
107 | + tcg_gen_setcondi_i64(TCG_COND_NE, d, d, 0); | ||
108 | + tcg_gen_neg_i64(d, d); | ||
109 | +} | ||
110 | + | ||
111 | +static void gen_cmtst_vec(unsigned vece, TCGv_vec d, TCGv_vec a, TCGv_vec b) | ||
112 | +{ | ||
113 | + tcg_gen_and_vec(vece, d, a, b); | ||
114 | + tcg_gen_dupi_vec(vece, a, 0); | ||
115 | + tcg_gen_cmp_vec(TCG_COND_NE, vece, d, d, a); | ||
116 | +} | ||
117 | + | ||
118 | +const GVecGen3 cmtst_op[4] = { | ||
119 | + { .fni4 = gen_helper_neon_tst_u8, | ||
120 | + .fniv = gen_cmtst_vec, | ||
121 | + .vece = MO_8 }, | ||
122 | + { .fni4 = gen_helper_neon_tst_u16, | ||
123 | + .fniv = gen_cmtst_vec, | ||
124 | + .vece = MO_16 }, | ||
125 | + { .fni4 = gen_cmtst_i32, | ||
126 | + .fniv = gen_cmtst_vec, | ||
127 | + .vece = MO_32 }, | ||
128 | + { .fni8 = gen_cmtst_i64, | ||
129 | + .fniv = gen_cmtst_vec, | ||
130 | + .prefer_i64 = TCG_TARGET_REG_BITS == 64, | ||
131 | + .vece = MO_64 }, | ||
132 | +}; | ||
133 | + | ||
134 | /* Translate a NEON data processing instruction. Return nonzero if the | ||
135 | instruction is invalid. | ||
136 | We process data in a mixture of 32-bit and 64-bit chunks. | ||
137 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
138 | tcg_gen_gvec_3(rd_ofs, rn_ofs, rm_ofs, vec_size, vec_size, | ||
139 | u ? &mls_op[size] : &mla_op[size]); | ||
140 | return 0; | ||
141 | + | ||
142 | + case NEON_3R_VTST_VCEQ: | ||
143 | + if (u) { /* VCEQ */ | ||
144 | + tcg_gen_gvec_cmp(TCG_COND_EQ, size, rd_ofs, rn_ofs, rm_ofs, | ||
145 | + vec_size, vec_size); | ||
146 | + } else { /* VTST */ | ||
147 | + tcg_gen_gvec_3(rd_ofs, rn_ofs, rm_ofs, | ||
148 | + vec_size, vec_size, &cmtst_op[size]); | ||
149 | + } | ||
150 | + return 0; | ||
151 | + | ||
152 | + case NEON_3R_VCGT: | ||
153 | + tcg_gen_gvec_cmp(u ? TCG_COND_GTU : TCG_COND_GT, size, | ||
154 | + rd_ofs, rn_ofs, rm_ofs, vec_size, vec_size); | ||
155 | + return 0; | ||
156 | + | ||
157 | + case NEON_3R_VCGE: | ||
158 | + tcg_gen_gvec_cmp(u ? TCG_COND_GEU : TCG_COND_GE, size, | ||
159 | + rd_ofs, rn_ofs, rm_ofs, vec_size, vec_size); | ||
160 | + return 0; | ||
161 | } | 78 | } |
162 | 79 | break; | |
163 | if (size == 3) { | 80 | |
164 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
165 | case NEON_3R_VQSUB: | ||
166 | GEN_NEON_INTEGER_OP_ENV(qsub); | ||
167 | break; | ||
168 | - case NEON_3R_VCGT: | ||
169 | - GEN_NEON_INTEGER_OP(cgt); | ||
170 | - break; | ||
171 | - case NEON_3R_VCGE: | ||
172 | - GEN_NEON_INTEGER_OP(cge); | ||
173 | - break; | ||
174 | case NEON_3R_VSHL: | ||
175 | GEN_NEON_INTEGER_OP(shl); | ||
176 | break; | ||
177 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
178 | tmp2 = neon_load_reg(rd, pass); | ||
179 | gen_neon_add(size, tmp, tmp2); | ||
180 | break; | ||
181 | - case NEON_3R_VTST_VCEQ: | ||
182 | - if (!u) { /* VTST */ | ||
183 | - switch (size) { | ||
184 | - case 0: gen_helper_neon_tst_u8(tmp, tmp, tmp2); break; | ||
185 | - case 1: gen_helper_neon_tst_u16(tmp, tmp, tmp2); break; | ||
186 | - case 2: gen_helper_neon_tst_u32(tmp, tmp, tmp2); break; | ||
187 | - default: abort(); | ||
188 | - } | ||
189 | - } else { /* VCEQ */ | ||
190 | - switch (size) { | ||
191 | - case 0: gen_helper_neon_ceq_u8(tmp, tmp, tmp2); break; | ||
192 | - case 1: gen_helper_neon_ceq_u16(tmp, tmp, tmp2); break; | ||
193 | - case 2: gen_helper_neon_ceq_u32(tmp, tmp, tmp2); break; | ||
194 | - default: abort(); | ||
195 | - } | ||
196 | - } | ||
197 | - break; | ||
198 | case NEON_3R_VMUL: | ||
199 | /* VMUL.P8; other cases already eliminated. */ | ||
200 | gen_helper_neon_mul_p8(tmp, tmp, tmp2); | ||
201 | -- | 81 | -- |
202 | 2.19.1 | 82 | 2.20.1 |
203 | 83 | ||
204 | 84 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Cédric Le Goater <clg@kaod.org> |
---|---|---|---|
2 | 2 | ||
3 | Both arm and thumb2 division are controlled by the same ISAR field, | 3 | This will simplify the definition of new SoCs, like the AST2600 which |
4 | which takes care of the arm implies thumb case. Having M imply | 4 | should use a different CPU and a different IRQ number layout. |
5 | thumb2 division was wrong for cortex-m0, which is v6m and does not | 5 | |
6 | have thumb2 at all, much less thumb2 division. | 6 | Signed-off-by: Cédric Le Goater <clg@kaod.org> |
7 | |||
8 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 7 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> |
9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 8 | Reviewed-by: Joel Stanley <joel@jms.id.au> |
10 | Message-id: 20181016223115.24100-5-richard.henderson@linaro.org | 9 | Message-id: 20190618165311.27066-2-clg@kaod.org |
11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | --- | 11 | --- |
14 | target/arm/cpu.h | 12 ++++++++++-- | 12 | include/hw/arm/aspeed_soc.h | 36 +++++++++++++++++++++++ |
15 | linux-user/elfload.c | 4 ++-- | 13 | hw/arm/aspeed_soc.c | 57 +++++++++++++++++++++++++++++++------ |
16 | target/arm/cpu.c | 10 +--------- | 14 | 2 files changed, 85 insertions(+), 8 deletions(-) |
17 | target/arm/translate.c | 4 ++-- | 15 | |
18 | 4 files changed, 15 insertions(+), 15 deletions(-) | 16 | diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h |
19 | |||
20 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
21 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/target/arm/cpu.h | 18 | --- a/include/hw/arm/aspeed_soc.h |
23 | +++ b/target/arm/cpu.h | 19 | +++ b/include/hw/arm/aspeed_soc.h |
24 | @@ -XXX,XX +XXX,XX @@ enum arm_features { | 20 | @@ -XXX,XX +XXX,XX @@ typedef struct AspeedSoCInfo { |
25 | ARM_FEATURE_VFP3, | 21 | const char *fmc_typename; |
26 | ARM_FEATURE_VFP_FP16, | 22 | const char **spi_typename; |
27 | ARM_FEATURE_NEON, | 23 | int wdts_num; |
28 | - ARM_FEATURE_THUMB_DIV, /* divide supported in Thumb encoding */ | 24 | + const int *irqmap; |
29 | ARM_FEATURE_M, /* Microcontroller profile. */ | 25 | } AspeedSoCInfo; |
30 | ARM_FEATURE_OMAPCP, /* OMAP specific CP15 ops handling. */ | 26 | |
31 | ARM_FEATURE_THUMB2EE, | 27 | typedef struct AspeedSoCClass { |
32 | @@ -XXX,XX +XXX,XX @@ enum arm_features { | 28 | @@ -XXX,XX +XXX,XX @@ typedef struct AspeedSoCClass { |
33 | ARM_FEATURE_V5, | 29 | #define ASPEED_SOC_GET_CLASS(obj) \ |
34 | ARM_FEATURE_STRONGARM, | 30 | OBJECT_GET_CLASS(AspeedSoCClass, (obj), TYPE_ASPEED_SOC) |
35 | ARM_FEATURE_VAPA, /* cp15 VA to PA lookups */ | 31 | |
36 | - ARM_FEATURE_ARM_DIV, /* divide supported in ARM encoding */ | 32 | +enum { |
37 | ARM_FEATURE_VFP4, /* VFPv4 (implies that NEON is v2) */ | 33 | + ASPEED_IOMEM, |
38 | ARM_FEATURE_GENERIC_TIMER, | 34 | + ASPEED_UART1, |
39 | ARM_FEATURE_MVFR, /* Media and VFP Feature Registers 0 and 1 */ | 35 | + ASPEED_UART2, |
40 | @@ -XXX,XX +XXX,XX @@ extern const uint64_t pred_esz_masks[4]; | 36 | + ASPEED_UART3, |
41 | /* | 37 | + ASPEED_UART4, |
42 | * 32-bit feature tests via id registers. | 38 | + ASPEED_UART5, |
43 | */ | 39 | + ASPEED_VUART, |
44 | +static inline bool isar_feature_thumb_div(const ARMISARegisters *id) | 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) | ||
45 | +{ | 150 | +{ |
46 | + return FIELD_EX32(id->id_isar0, ID_ISAR0, DIVIDE) != 0; | 151 | + AspeedSoCClass *sc = ASPEED_SOC_GET_CLASS(s); |
152 | + | ||
153 | + return qdev_get_gpio_in(DEVICE(&s->vic), sc->info->irqmap[ctrl]); | ||
47 | +} | 154 | +} |
48 | + | 155 | + |
49 | +static inline bool isar_feature_arm_div(const ARMISARegisters *id) | 156 | static void aspeed_soc_init(Object *obj) |
50 | +{ | ||
51 | + return FIELD_EX32(id->id_isar0, ID_ISAR0, DIVIDE) > 1; | ||
52 | +} | ||
53 | + | ||
54 | static inline bool isar_feature_aa32_aes(const ARMISARegisters *id) | ||
55 | { | 157 | { |
56 | return FIELD_EX32(id->id_isar5, ID_ISAR5, AES) != 0; | 158 | AspeedSoCState *s = ASPEED_SOC(obj); |
57 | diff --git a/linux-user/elfload.c b/linux-user/elfload.c | 159 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) |
58 | index XXXXXXX..XXXXXXX 100644 | 160 | return; |
59 | --- a/linux-user/elfload.c | 161 | } |
60 | +++ b/linux-user/elfload.c | 162 | sysbus_mmio_map(SYS_BUS_DEVICE(&s->timerctrl), 0, ASPEED_SOC_TIMER_BASE); |
61 | @@ -XXX,XX +XXX,XX @@ static uint32_t get_elf_hwcap(void) | 163 | - for (i = 0; i < ARRAY_SIZE(timer_irqs); i++) { |
62 | GET_FEATURE(ARM_FEATURE_VFP3, ARM_HWCAP_ARM_VFPv3); | 164 | - qemu_irq irq = qdev_get_gpio_in(DEVICE(&s->vic), timer_irqs[i]); |
63 | GET_FEATURE(ARM_FEATURE_V6K, ARM_HWCAP_ARM_TLS); | 165 | + for (i = 0; i < ASPEED_TIMER_NR_TIMERS; i++) { |
64 | GET_FEATURE(ARM_FEATURE_VFP4, ARM_HWCAP_ARM_VFPv4); | 166 | + qemu_irq irq = aspeed_soc_get_irq(s, ASPEED_TIMER1 + i); |
65 | - GET_FEATURE(ARM_FEATURE_ARM_DIV, ARM_HWCAP_ARM_IDIVA); | 167 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->timerctrl), i, irq); |
66 | - GET_FEATURE(ARM_FEATURE_THUMB_DIV, ARM_HWCAP_ARM_IDIVT); | 168 | } |
67 | + GET_FEATURE_ID(arm_div, ARM_HWCAP_ARM_IDIVA); | 169 | |
68 | + GET_FEATURE_ID(thumb_div, ARM_HWCAP_ARM_IDIVT); | 170 | /* UART - attach an 8250 to the IO space as our UART5 */ |
69 | /* All QEMU's VFPv3 CPUs have 32 registers, see VFP_DREG in translate.c. | 171 | if (serial_hd(0)) { |
70 | * Note that the ARM_HWCAP_ARM_VFPv3D16 bit is always the inverse of | 172 | - qemu_irq uart5 = qdev_get_gpio_in(DEVICE(&s->vic), uart_irqs[4]); |
71 | * ARM_HWCAP_ARM_VFPD32 (and so always clear for QEMU); it is unrelated | 173 | + qemu_irq uart5 = aspeed_soc_get_irq(s, ASPEED_UART5); |
72 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | 174 | serial_mm_init(get_system_memory(), |
73 | index XXXXXXX..XXXXXXX 100644 | 175 | ASPEED_SOC_IOMEM_BASE + ASPEED_SOC_UART_5_BASE, 2, |
74 | --- a/target/arm/cpu.c | 176 | uart5, 38400, serial_hd(0), DEVICE_LITTLE_ENDIAN); |
75 | +++ b/target/arm/cpu.c | 177 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) |
76 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) | 178 | } |
77 | * Presence of EL2 itself is ARM_FEATURE_EL2, and of the | 179 | sysbus_mmio_map(SYS_BUS_DEVICE(&s->i2c), 0, ASPEED_SOC_I2C_BASE); |
78 | * Security Extensions is ARM_FEATURE_EL3. | 180 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->i2c), 0, |
79 | */ | 181 | - qdev_get_gpio_in(DEVICE(&s->vic), 12)); |
80 | - set_feature(env, ARM_FEATURE_ARM_DIV); | 182 | + aspeed_soc_get_irq(s, ASPEED_I2C)); |
81 | + assert(cpu_isar_feature(arm_div, cpu)); | 183 | |
82 | set_feature(env, ARM_FEATURE_LPAE); | 184 | /* FMC, The number of CS is set at the board level */ |
83 | set_feature(env, ARM_FEATURE_V7); | 185 | object_property_set_bool(OBJECT(&s->fmc), true, "realized", &err); |
84 | } | 186 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) |
85 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) | 187 | sysbus_mmio_map(SYS_BUS_DEVICE(&s->fmc), 1, |
86 | if (arm_feature(env, ARM_FEATURE_V5)) { | 188 | s->fmc.ctrl->flash_window_base); |
87 | set_feature(env, ARM_FEATURE_V4T); | 189 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->fmc), 0, |
88 | } | 190 | - qdev_get_gpio_in(DEVICE(&s->vic), 19)); |
89 | - if (arm_feature(env, ARM_FEATURE_M)) { | 191 | + aspeed_soc_get_irq(s, ASPEED_FMC)); |
90 | - set_feature(env, ARM_FEATURE_THUMB_DIV); | 192 | |
91 | - } | 193 | /* SPI */ |
92 | - if (arm_feature(env, ARM_FEATURE_ARM_DIV)) { | 194 | for (i = 0; i < sc->info->spis_num; i++) { |
93 | - set_feature(env, ARM_FEATURE_THUMB_DIV); | 195 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) |
94 | - } | 196 | } |
95 | if (arm_feature(env, ARM_FEATURE_VFP4)) { | 197 | sysbus_mmio_map(SYS_BUS_DEVICE(&s->ftgmac100), 0, ASPEED_SOC_ETH1_BASE); |
96 | set_feature(env, ARM_FEATURE_VFP3); | 198 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->ftgmac100), 0, |
97 | set_feature(env, ARM_FEATURE_VFP_FP16); | 199 | - qdev_get_gpio_in(DEVICE(&s->vic), 2)); |
98 | @@ -XXX,XX +XXX,XX @@ static void cortex_r5_initfn(Object *obj) | 200 | + aspeed_soc_get_irq(s, ASPEED_ETH1)); |
99 | ARMCPU *cpu = ARM_CPU(obj); | 201 | } |
100 | 202 | ||
101 | set_feature(&cpu->env, ARM_FEATURE_V7); | 203 | static void aspeed_soc_class_init(ObjectClass *oc, void *data) |
102 | - set_feature(&cpu->env, ARM_FEATURE_THUMB_DIV); | ||
103 | - set_feature(&cpu->env, ARM_FEATURE_ARM_DIV); | ||
104 | set_feature(&cpu->env, ARM_FEATURE_V7MP); | ||
105 | set_feature(&cpu->env, ARM_FEATURE_PMSA); | ||
106 | cpu->midr = 0x411fc153; /* r1p3 */ | ||
107 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
108 | index XXXXXXX..XXXXXXX 100644 | ||
109 | --- a/target/arm/translate.c | ||
110 | +++ b/target/arm/translate.c | ||
111 | @@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) | ||
112 | case 1: | ||
113 | case 3: | ||
114 | /* SDIV, UDIV */ | ||
115 | - if (!arm_dc_feature(s, ARM_FEATURE_ARM_DIV)) { | ||
116 | + if (!dc_isar_feature(arm_div, s)) { | ||
117 | goto illegal_op; | ||
118 | } | ||
119 | if (((insn >> 5) & 7) || (rd != 15)) { | ||
120 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) | ||
121 | tmp2 = load_reg(s, rm); | ||
122 | if ((op & 0x50) == 0x10) { | ||
123 | /* sdiv, udiv */ | ||
124 | - if (!arm_dc_feature(s, ARM_FEATURE_THUMB_DIV)) { | ||
125 | + if (!dc_isar_feature(thumb_div, s)) { | ||
126 | goto illegal_op; | ||
127 | } | ||
128 | if (op & 0x20) | ||
129 | -- | 204 | -- |
130 | 2.19.1 | 205 | 2.20.1 |
131 | 206 | ||
132 | 207 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Cédric Le Goater <clg@kaod.org> |
---|---|---|---|
2 | 2 | ||
3 | This will simplify the definition of new SoCs, like the AST2600 which | ||
4 | should use a slightly different address space and have a different set | ||
5 | of controllers. | ||
6 | |||
7 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
3 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 8 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> |
4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 9 | Reviewed-by: Joel Stanley <joel@jms.id.au> |
5 | Message-id: 20181016223115.24100-9-richard.henderson@linaro.org | 10 | Message-id: 20190618165311.27066-3-clg@kaod.org |
6 | 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 | --- | 12 | --- |
9 | target/arm/cpu.h | 17 +++++++++++++++- | 13 | include/hw/arm/aspeed_soc.h | 4 +- |
10 | linux-user/elfload.c | 6 +----- | 14 | hw/arm/aspeed.c | 8 +-- |
11 | target/arm/cpu64.c | 16 ++++++++------- | 15 | hw/arm/aspeed_soc.c | 117 ++++++++++++++++++++++-------------- |
12 | target/arm/helper.c | 2 +- | 16 | 3 files changed, 78 insertions(+), 51 deletions(-) |
13 | target/arm/translate-a64.c | 40 +++++++++++++++++++------------------- | 17 | |
14 | target/arm/translate.c | 6 +++--- | 18 | diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h |
15 | 6 files changed, 50 insertions(+), 37 deletions(-) | ||
16 | |||
17 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
18 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/target/arm/cpu.h | 20 | --- a/include/hw/arm/aspeed_soc.h |
20 | +++ b/target/arm/cpu.h | 21 | +++ b/include/hw/arm/aspeed_soc.h |
21 | @@ -XXX,XX +XXX,XX @@ enum arm_features { | 22 | @@ -XXX,XX +XXX,XX @@ typedef struct AspeedSoCInfo { |
22 | ARM_FEATURE_PMU, /* has PMU support */ | 23 | const char *name; |
23 | ARM_FEATURE_VBAR, /* has cp15 VBAR */ | 24 | const char *cpu_type; |
24 | ARM_FEATURE_M_SECURITY, /* M profile Security Extension */ | 25 | uint32_t silicon_rev; |
25 | - ARM_FEATURE_V8_FP16, /* implements v8.2 half-precision float */ | 26 | - hwaddr sdram_base; |
26 | ARM_FEATURE_M_MAIN, /* M profile Main Extension */ | 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, | ||
27 | }; | 43 | }; |
28 | 44 | ||
29 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa32_dp(const ARMISARegisters *id) | 45 | #endif /* ASPEED_SOC_H */ |
30 | return FIELD_EX32(id->id_isar6, ID_ISAR6, DP) != 0; | 46 | diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c |
31 | } | 47 | index XXXXXXX..XXXXXXX 100644 |
32 | 48 | --- a/hw/arm/aspeed.c | |
33 | +static inline bool isar_feature_aa32_fp16_arith(const ARMISARegisters *id) | 49 | +++ b/hw/arm/aspeed.c |
34 | +{ | 50 | @@ -XXX,XX +XXX,XX @@ static void aspeed_board_init(MachineState *machine, |
35 | + /* | 51 | &error_abort); |
36 | + * This is a placeholder for use by VCMA until the rest of | 52 | |
37 | + * the ARMv8.2-FP16 extension is implemented for aa32 mode. | 53 | memory_region_allocate_system_memory(&bmc->ram, NULL, "ram", ram_size); |
38 | + * At which point we can properly set and check MVFR1.FPHP. | 54 | - memory_region_add_subregion(get_system_memory(), sc->info->sdram_base, |
39 | + */ | 55 | - &bmc->ram); |
40 | + return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, FP) == 1; | 56 | + memory_region_add_subregion(get_system_memory(), |
41 | +} | 57 | + sc->info->memmap[ASPEED_SDRAM], &bmc->ram); |
58 | object_property_add_const_link(OBJECT(&bmc->soc), "ram", OBJECT(&bmc->ram), | ||
59 | &error_abort); | ||
60 | |||
61 | @@ -XXX,XX +XXX,XX @@ static void aspeed_board_init(MachineState *machine, | ||
62 | memory_region_init_io(&bmc->max_ram, NULL, &max_ram_ops, NULL, | ||
63 | "max_ram", max_ram_size - ram_size); | ||
64 | memory_region_add_subregion(get_system_memory(), | ||
65 | - sc->info->sdram_base + ram_size, | ||
66 | + sc->info->memmap[ASPEED_SDRAM] + ram_size, | ||
67 | &bmc->max_ram); | ||
68 | |||
69 | aspeed_board_init_flashes(&bmc->soc.fmc, cfg->fmc_model, &error_abort); | ||
70 | @@ -XXX,XX +XXX,XX @@ static void aspeed_board_init(MachineState *machine, | ||
71 | aspeed_board_binfo.initrd_filename = machine->initrd_filename; | ||
72 | aspeed_board_binfo.kernel_cmdline = machine->kernel_cmdline; | ||
73 | aspeed_board_binfo.ram_size = ram_size; | ||
74 | - aspeed_board_binfo.loader_start = sc->info->sdram_base; | ||
75 | + aspeed_board_binfo.loader_start = sc->info->memmap[ASPEED_SDRAM]; | ||
76 | |||
77 | if (cfg->i2c_init) { | ||
78 | cfg->i2c_init(bmc); | ||
79 | diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c | ||
80 | index XXXXXXX..XXXXXXX 100644 | ||
81 | --- a/hw/arm/aspeed_soc.c | ||
82 | +++ b/hw/arm/aspeed_soc.c | ||
83 | @@ -XXX,XX +XXX,XX @@ | ||
84 | #include "hw/i2c/aspeed_i2c.h" | ||
85 | #include "net/net.h" | ||
86 | |||
87 | -#define ASPEED_SOC_UART_5_BASE 0x00184000 | ||
88 | #define ASPEED_SOC_IOMEM_SIZE 0x00200000 | ||
89 | -#define ASPEED_SOC_IOMEM_BASE 0x1E600000 | ||
90 | -#define ASPEED_SOC_FMC_BASE 0x1E620000 | ||
91 | -#define ASPEED_SOC_SPI_BASE 0x1E630000 | ||
92 | -#define ASPEED_SOC_SPI2_BASE 0x1E631000 | ||
93 | -#define ASPEED_SOC_VIC_BASE 0x1E6C0000 | ||
94 | -#define ASPEED_SOC_SDMC_BASE 0x1E6E0000 | ||
95 | -#define ASPEED_SOC_SCU_BASE 0x1E6E2000 | ||
96 | -#define ASPEED_SOC_SRAM_BASE 0x1E720000 | ||
97 | -#define ASPEED_SOC_TIMER_BASE 0x1E782000 | ||
98 | -#define ASPEED_SOC_WDT_BASE 0x1E785000 | ||
99 | -#define ASPEED_SOC_I2C_BASE 0x1E78A000 | ||
100 | -#define ASPEED_SOC_ETH1_BASE 0x1E660000 | ||
101 | -#define ASPEED_SOC_ETH2_BASE 0x1E680000 | ||
42 | + | 102 | + |
43 | /* | 103 | +static const hwaddr aspeed_soc_ast2400_memmap[] = { |
44 | * 64-bit feature tests via id registers. | 104 | + [ASPEED_IOMEM] = 0x1E600000, |
45 | */ | 105 | + [ASPEED_FMC] = 0x1E620000, |
46 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa64_fcma(const ARMISARegisters *id) | 106 | + [ASPEED_SPI1] = 0x1E630000, |
47 | return FIELD_EX64(id->id_aa64isar1, ID_AA64ISAR1, FCMA) != 0; | 107 | + [ASPEED_VIC] = 0x1E6C0000, |
48 | } | 108 | + [ASPEED_SDMC] = 0x1E6E0000, |
49 | 109 | + [ASPEED_SCU] = 0x1E6E2000, | |
50 | +static inline bool isar_feature_aa64_fp16(const ARMISARegisters *id) | 110 | + [ASPEED_ADC] = 0x1E6E9000, |
51 | +{ | 111 | + [ASPEED_SRAM] = 0x1E720000, |
52 | + /* We always set the AdvSIMD and FP fields identically wrt FP16. */ | 112 | + [ASPEED_GPIO] = 0x1E780000, |
53 | + return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, FP) == 1; | 113 | + [ASPEED_RTC] = 0x1E781000, |
54 | +} | 114 | + [ASPEED_TIMER1] = 0x1E782000, |
115 | + [ASPEED_WDT] = 0x1E785000, | ||
116 | + [ASPEED_PWM] = 0x1E786000, | ||
117 | + [ASPEED_LPC] = 0x1E789000, | ||
118 | + [ASPEED_IBT] = 0x1E789140, | ||
119 | + [ASPEED_I2C] = 0x1E78A000, | ||
120 | + [ASPEED_ETH1] = 0x1E660000, | ||
121 | + [ASPEED_ETH2] = 0x1E680000, | ||
122 | + [ASPEED_UART1] = 0x1E783000, | ||
123 | + [ASPEED_UART5] = 0x1E784000, | ||
124 | + [ASPEED_VUART] = 0x1E787000, | ||
125 | + [ASPEED_SDRAM] = 0x40000000, | ||
126 | +}; | ||
55 | + | 127 | + |
56 | static inline bool isar_feature_aa64_sve(const ARMISARegisters *id) | 128 | +static const hwaddr aspeed_soc_ast2500_memmap[] = { |
57 | { | 129 | + [ASPEED_IOMEM] = 0x1E600000, |
58 | return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, SVE) != 0; | 130 | + [ASPEED_FMC] = 0x1E620000, |
59 | diff --git a/linux-user/elfload.c b/linux-user/elfload.c | 131 | + [ASPEED_SPI1] = 0x1E630000, |
60 | index XXXXXXX..XXXXXXX 100644 | 132 | + [ASPEED_SPI2] = 0x1E631000, |
61 | --- a/linux-user/elfload.c | 133 | + [ASPEED_VIC] = 0x1E6C0000, |
62 | +++ b/linux-user/elfload.c | 134 | + [ASPEED_SDMC] = 0x1E6E0000, |
63 | @@ -XXX,XX +XXX,XX @@ static uint32_t get_elf_hwcap(void) | 135 | + [ASPEED_SCU] = 0x1E6E2000, |
64 | hwcaps |= ARM_HWCAP_A64_ASIMD; | 136 | + [ASPEED_ADC] = 0x1E6E9000, |
65 | 137 | + [ASPEED_SRAM] = 0x1E720000, | |
66 | /* probe for the extra features */ | 138 | + [ASPEED_GPIO] = 0x1E780000, |
67 | -#define GET_FEATURE(feat, hwcap) \ | 139 | + [ASPEED_RTC] = 0x1E781000, |
68 | - do { if (arm_feature(&cpu->env, feat)) { hwcaps |= hwcap; } } while (0) | 140 | + [ASPEED_TIMER1] = 0x1E782000, |
69 | #define GET_FEATURE_ID(feat, hwcap) \ | 141 | + [ASPEED_WDT] = 0x1E785000, |
70 | do { if (cpu_isar_feature(feat, cpu)) { hwcaps |= hwcap; } } while (0) | 142 | + [ASPEED_PWM] = 0x1E786000, |
71 | 143 | + [ASPEED_LPC] = 0x1E789000, | |
72 | @@ -XXX,XX +XXX,XX @@ static uint32_t get_elf_hwcap(void) | 144 | + [ASPEED_IBT] = 0x1E789140, |
73 | GET_FEATURE_ID(aa64_sha3, ARM_HWCAP_A64_SHA3); | 145 | + [ASPEED_I2C] = 0x1E78A000, |
74 | GET_FEATURE_ID(aa64_sm3, ARM_HWCAP_A64_SM3); | 146 | + [ASPEED_ETH1] = 0x1E660000, |
75 | GET_FEATURE_ID(aa64_sm4, ARM_HWCAP_A64_SM4); | 147 | + [ASPEED_ETH2] = 0x1E680000, |
76 | - GET_FEATURE(ARM_FEATURE_V8_FP16, | 148 | + [ASPEED_UART1] = 0x1E783000, |
77 | - ARM_HWCAP_A64_FPHP | ARM_HWCAP_A64_ASIMDHP); | 149 | + [ASPEED_UART5] = 0x1E784000, |
78 | + GET_FEATURE_ID(aa64_fp16, ARM_HWCAP_A64_FPHP | ARM_HWCAP_A64_ASIMDHP); | 150 | + [ASPEED_VUART] = 0x1E787000, |
79 | GET_FEATURE_ID(aa64_atomics, ARM_HWCAP_A64_ATOMICS); | 151 | + [ASPEED_SDRAM] = 0x80000000, |
80 | GET_FEATURE_ID(aa64_rdm, ARM_HWCAP_A64_ASIMDRDM); | 152 | +}; |
81 | GET_FEATURE_ID(aa64_dp, ARM_HWCAP_A64_ASIMDDP); | 153 | |
82 | GET_FEATURE_ID(aa64_fcma, ARM_HWCAP_A64_FCMA); | 154 | static const int aspeed_soc_ast2400_irqmap[] = { |
83 | GET_FEATURE_ID(aa64_sve, ARM_HWCAP_A64_SVE); | 155 | [ASPEED_UART1] = 9, |
84 | 156 | @@ -XXX,XX +XXX,XX @@ static const int aspeed_soc_ast2400_irqmap[] = { | |
85 | -#undef GET_FEATURE | 157 | [ASPEED_ETH2] = 3, |
86 | #undef GET_FEATURE_ID | 158 | }; |
87 | 159 | ||
88 | return hwcaps; | 160 | -#define AST2400_SDRAM_BASE 0x40000000 |
89 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | 161 | -#define AST2500_SDRAM_BASE 0x80000000 |
90 | index XXXXXXX..XXXXXXX 100644 | 162 | - |
91 | --- a/target/arm/cpu64.c | 163 | -/* AST2500 uses the same IRQs as the AST2400 */ |
92 | +++ b/target/arm/cpu64.c | 164 | #define aspeed_soc_ast2500_irqmap aspeed_soc_ast2400_irqmap |
93 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) | 165 | |
94 | 166 | -static const hwaddr aspeed_soc_ast2400_spi_bases[] = { ASPEED_SOC_SPI_BASE }; | |
95 | t = cpu->isar.id_aa64pfr0; | 167 | static const char *aspeed_soc_ast2400_typenames[] = { "aspeed.smc.spi" }; |
96 | t = FIELD_DP64(t, ID_AA64PFR0, SVE, 1); | 168 | - |
97 | + t = FIELD_DP64(t, ID_AA64PFR0, FP, 1); | 169 | -static const hwaddr aspeed_soc_ast2500_spi_bases[] = { ASPEED_SOC_SPI_BASE, |
98 | + t = FIELD_DP64(t, ID_AA64PFR0, ADVSIMD, 1); | 170 | - ASPEED_SOC_SPI2_BASE}; |
99 | cpu->isar.id_aa64pfr0 = t; | 171 | static const char *aspeed_soc_ast2500_typenames[] = { |
100 | 172 | "aspeed.smc.ast2500-spi1", "aspeed.smc.ast2500-spi2" }; | |
101 | /* Replicate the same data to the 32-bit id registers. */ | 173 | |
102 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) | 174 | @@ -XXX,XX +XXX,XX @@ static const AspeedSoCInfo aspeed_socs[] = { |
103 | u = FIELD_DP32(u, ID_ISAR6, DP, 1); | 175 | .name = "ast2400-a0", |
104 | cpu->isar.id_isar6 = u; | 176 | .cpu_type = ARM_CPU_TYPE_NAME("arm926"), |
105 | 177 | .silicon_rev = AST2400_A0_SILICON_REV, | |
106 | -#ifdef CONFIG_USER_ONLY | 178 | - .sdram_base = AST2400_SDRAM_BASE, |
107 | - /* We don't set these in system emulation mode for the moment, | 179 | .sram_size = 0x8000, |
108 | - * since we don't correctly set the ID registers to advertise them, | 180 | .spis_num = 1, |
109 | - * and in some cases they're only available in AArch64 and not AArch32, | 181 | - .spi_bases = aspeed_soc_ast2400_spi_bases, |
110 | - * whereas the architecture requires them to be present in both if | 182 | .fmc_typename = "aspeed.smc.fmc", |
111 | - * present in either. | 183 | .spi_typename = aspeed_soc_ast2400_typenames, |
112 | + /* | 184 | .wdts_num = 2, |
113 | + * FIXME: We do not yet support ARMv8.2-fp16 for AArch32 yet, | 185 | .irqmap = aspeed_soc_ast2400_irqmap, |
114 | + * so do not set MVFR1.FPHP. Strictly speaking this is not legal, | 186 | + .memmap = aspeed_soc_ast2400_memmap, |
115 | + * but it is also not legal to enable SVE without support for FP16, | 187 | }, { |
116 | + * and enabling SVE in system mode is more useful in the short term. | 188 | .name = "ast2400-a1", |
117 | */ | 189 | .cpu_type = ARM_CPU_TYPE_NAME("arm926"), |
118 | - set_feature(&cpu->env, ARM_FEATURE_V8_FP16); | 190 | .silicon_rev = AST2400_A1_SILICON_REV, |
119 | + | 191 | - .sdram_base = AST2400_SDRAM_BASE, |
120 | +#ifdef CONFIG_USER_ONLY | 192 | .sram_size = 0x8000, |
121 | /* For usermode -cpu max we can use a larger and more efficient DCZ | 193 | .spis_num = 1, |
122 | * blocksize since we don't have to follow what the hardware does. | 194 | - .spi_bases = aspeed_soc_ast2400_spi_bases, |
123 | */ | 195 | .fmc_typename = "aspeed.smc.fmc", |
124 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 196 | .spi_typename = aspeed_soc_ast2400_typenames, |
125 | index XXXXXXX..XXXXXXX 100644 | 197 | .wdts_num = 2, |
126 | --- a/target/arm/helper.c | 198 | .irqmap = aspeed_soc_ast2400_irqmap, |
127 | +++ b/target/arm/helper.c | 199 | + .memmap = aspeed_soc_ast2400_memmap, |
128 | @@ -XXX,XX +XXX,XX @@ void HELPER(vfp_set_fpscr)(CPUARMState *env, uint32_t val) | 200 | }, { |
129 | uint32_t changed; | 201 | .name = "ast2400", |
130 | 202 | .cpu_type = ARM_CPU_TYPE_NAME("arm926"), | |
131 | /* When ARMv8.2-FP16 is not supported, FZ16 is RES0. */ | 203 | .silicon_rev = AST2400_A0_SILICON_REV, |
132 | - if (!arm_feature(env, ARM_FEATURE_V8_FP16)) { | 204 | - .sdram_base = AST2400_SDRAM_BASE, |
133 | + if (!cpu_isar_feature(aa64_fp16, arm_env_get_cpu(env))) { | 205 | .sram_size = 0x8000, |
134 | val &= ~FPCR_FZ16; | 206 | .spis_num = 1, |
135 | } | 207 | - .spi_bases = aspeed_soc_ast2400_spi_bases, |
136 | 208 | .fmc_typename = "aspeed.smc.fmc", | |
137 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 209 | .spi_typename = aspeed_soc_ast2400_typenames, |
138 | index XXXXXXX..XXXXXXX 100644 | 210 | .wdts_num = 2, |
139 | --- a/target/arm/translate-a64.c | 211 | .irqmap = aspeed_soc_ast2400_irqmap, |
140 | +++ b/target/arm/translate-a64.c | 212 | + .memmap = aspeed_soc_ast2400_memmap, |
141 | @@ -XXX,XX +XXX,XX @@ static void disas_fp_compare(DisasContext *s, uint32_t insn) | 213 | }, { |
142 | break; | 214 | .name = "ast2500-a1", |
143 | case 3: | 215 | .cpu_type = ARM_CPU_TYPE_NAME("arm1176"), |
144 | size = MO_16; | 216 | .silicon_rev = AST2500_A1_SILICON_REV, |
145 | - if (arm_dc_feature(s, ARM_FEATURE_V8_FP16)) { | 217 | - .sdram_base = AST2500_SDRAM_BASE, |
146 | + if (dc_isar_feature(aa64_fp16, s)) { | 218 | .sram_size = 0x9000, |
147 | break; | 219 | .spis_num = 2, |
148 | } | 220 | - .spi_bases = aspeed_soc_ast2500_spi_bases, |
149 | /* fallthru */ | 221 | .fmc_typename = "aspeed.smc.ast2500-fmc", |
150 | @@ -XXX,XX +XXX,XX @@ static void disas_fp_ccomp(DisasContext *s, uint32_t insn) | 222 | .spi_typename = aspeed_soc_ast2500_typenames, |
151 | break; | 223 | .wdts_num = 3, |
152 | case 3: | 224 | .irqmap = aspeed_soc_ast2500_irqmap, |
153 | size = MO_16; | 225 | + .memmap = aspeed_soc_ast2500_memmap, |
154 | - if (arm_dc_feature(s, ARM_FEATURE_V8_FP16)) { | 226 | }, |
155 | + if (dc_isar_feature(aa64_fp16, s)) { | 227 | }; |
156 | break; | 228 | |
157 | } | 229 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) |
158 | /* fallthru */ | 230 | Error *err = NULL, *local_err = NULL; |
159 | @@ -XXX,XX +XXX,XX @@ static void disas_fp_csel(DisasContext *s, uint32_t insn) | 231 | |
160 | break; | 232 | /* IO space */ |
161 | case 3: | 233 | - create_unimplemented_device("aspeed_soc.io", |
162 | sz = MO_16; | 234 | - ASPEED_SOC_IOMEM_BASE, ASPEED_SOC_IOMEM_SIZE); |
163 | - if (arm_dc_feature(s, ARM_FEATURE_V8_FP16)) { | 235 | + create_unimplemented_device("aspeed_soc.io", sc->info->memmap[ASPEED_IOMEM], |
164 | + if (dc_isar_feature(aa64_fp16, s)) { | 236 | + ASPEED_SOC_IOMEM_SIZE); |
165 | break; | 237 | |
166 | } | 238 | /* CPU */ |
167 | /* fallthru */ | 239 | object_property_set_bool(OBJECT(&s->cpu), true, "realized", &err); |
168 | @@ -XXX,XX +XXX,XX @@ static void disas_fp_1src(DisasContext *s, uint32_t insn) | 240 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) |
169 | handle_fp_1src_double(s, opcode, rd, rn); | 241 | error_propagate(errp, err); |
170 | break; | 242 | return; |
171 | case 3: | 243 | } |
172 | - if (!arm_dc_feature(s, ARM_FEATURE_V8_FP16)) { | 244 | - memory_region_add_subregion(get_system_memory(), ASPEED_SOC_SRAM_BASE, |
173 | + if (!dc_isar_feature(aa64_fp16, s)) { | 245 | - &s->sram); |
174 | unallocated_encoding(s); | 246 | + memory_region_add_subregion(get_system_memory(), |
175 | return; | 247 | + sc->info->memmap[ASPEED_SRAM], &s->sram); |
176 | } | 248 | |
177 | @@ -XXX,XX +XXX,XX @@ static void disas_fp_2src(DisasContext *s, uint32_t insn) | 249 | /* SCU */ |
178 | handle_fp_2src_double(s, opcode, rd, rn, rm); | 250 | object_property_set_bool(OBJECT(&s->scu), true, "realized", &err); |
179 | break; | 251 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) |
180 | case 3: | 252 | error_propagate(errp, err); |
181 | - if (!arm_dc_feature(s, ARM_FEATURE_V8_FP16)) { | 253 | return; |
182 | + if (!dc_isar_feature(aa64_fp16, s)) { | 254 | } |
183 | unallocated_encoding(s); | 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); | ||
184 | return; | 309 | return; |
185 | } | 310 | } |
186 | @@ -XXX,XX +XXX,XX @@ static void disas_fp_3src(DisasContext *s, uint32_t insn) | 311 | - sysbus_mmio_map(SYS_BUS_DEVICE(&s->spi[i]), 0, sc->info->spi_bases[i]); |
187 | handle_fp_3src_double(s, o0, o1, rd, rn, rm, ra); | 312 | + sysbus_mmio_map(SYS_BUS_DEVICE(&s->spi[i]), 0, |
188 | break; | 313 | + sc->info->memmap[ASPEED_SPI1 + i]); |
189 | case 3: | 314 | sysbus_mmio_map(SYS_BUS_DEVICE(&s->spi[i]), 1, |
190 | - if (!arm_dc_feature(s, ARM_FEATURE_V8_FP16)) { | 315 | s->spi[i].ctrl->flash_window_base); |
191 | + if (!dc_isar_feature(aa64_fp16, s)) { | 316 | } |
192 | unallocated_encoding(s); | 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) | ||
193 | return; | 327 | return; |
194 | } | 328 | } |
195 | @@ -XXX,XX +XXX,XX @@ static void disas_fp_imm(DisasContext *s, uint32_t insn) | 329 | sysbus_mmio_map(SYS_BUS_DEVICE(&s->wdt[i]), 0, |
196 | break; | 330 | - ASPEED_SOC_WDT_BASE + i * 0x20); |
197 | case 3: | 331 | + sc->info->memmap[ASPEED_WDT] + i * 0x20); |
198 | sz = MO_16; | 332 | } |
199 | - if (arm_dc_feature(s, ARM_FEATURE_V8_FP16)) { | 333 | |
200 | + if (dc_isar_feature(aa64_fp16, s)) { | 334 | /* Net */ |
201 | break; | 335 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) |
202 | } | 336 | error_propagate(errp, err); |
203 | /* fallthru */ | 337 | return; |
204 | @@ -XXX,XX +XXX,XX @@ static void disas_fp_fixed_conv(DisasContext *s, uint32_t insn) | 338 | } |
205 | case 1: /* float64 */ | 339 | - sysbus_mmio_map(SYS_BUS_DEVICE(&s->ftgmac100), 0, ASPEED_SOC_ETH1_BASE); |
206 | break; | 340 | + sysbus_mmio_map(SYS_BUS_DEVICE(&s->ftgmac100), 0, |
207 | case 3: /* float16 */ | 341 | + sc->info->memmap[ASPEED_ETH1]); |
208 | - if (arm_dc_feature(s, ARM_FEATURE_V8_FP16)) { | 342 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->ftgmac100), 0, |
209 | + if (dc_isar_feature(aa64_fp16, s)) { | 343 | aspeed_soc_get_irq(s, ASPEED_ETH1)); |
210 | break; | 344 | } |
211 | } | ||
212 | /* fallthru */ | ||
213 | @@ -XXX,XX +XXX,XX @@ static void disas_fp_int_conv(DisasContext *s, uint32_t insn) | ||
214 | break; | ||
215 | case 0x6: /* 16-bit float, 32-bit int */ | ||
216 | case 0xe: /* 16-bit float, 64-bit int */ | ||
217 | - if (arm_dc_feature(s, ARM_FEATURE_V8_FP16)) { | ||
218 | + if (dc_isar_feature(aa64_fp16, s)) { | ||
219 | break; | ||
220 | } | ||
221 | /* fallthru */ | ||
222 | @@ -XXX,XX +XXX,XX @@ static void disas_fp_int_conv(DisasContext *s, uint32_t insn) | ||
223 | case 1: /* float64 */ | ||
224 | break; | ||
225 | case 3: /* float16 */ | ||
226 | - if (arm_dc_feature(s, ARM_FEATURE_V8_FP16)) { | ||
227 | + if (dc_isar_feature(aa64_fp16, s)) { | ||
228 | break; | ||
229 | } | ||
230 | /* fallthru */ | ||
231 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_across_lanes(DisasContext *s, uint32_t insn) | ||
232 | */ | ||
233 | is_min = extract32(size, 1, 1); | ||
234 | is_fp = true; | ||
235 | - if (!is_u && arm_dc_feature(s, ARM_FEATURE_V8_FP16)) { | ||
236 | + if (!is_u && dc_isar_feature(aa64_fp16, s)) { | ||
237 | size = 1; | ||
238 | } else if (!is_u || !is_q || extract32(size, 0, 1)) { | ||
239 | unallocated_encoding(s); | ||
240 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_mod_imm(DisasContext *s, uint32_t insn) | ||
241 | |||
242 | if (o2 != 0 || ((cmode == 0xf) && is_neg && !is_q)) { | ||
243 | /* Check for FMOV (vector, immediate) - half-precision */ | ||
244 | - if (!(arm_dc_feature(s, ARM_FEATURE_V8_FP16) && o2 && cmode == 0xf)) { | ||
245 | + if (!(dc_isar_feature(aa64_fp16, s) && o2 && cmode == 0xf)) { | ||
246 | unallocated_encoding(s); | ||
247 | return; | ||
248 | } | ||
249 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_scalar_pairwise(DisasContext *s, uint32_t insn) | ||
250 | case 0x2f: /* FMINP */ | ||
251 | /* FP op, size[0] is 32 or 64 bit*/ | ||
252 | if (!u) { | ||
253 | - if (!arm_dc_feature(s, ARM_FEATURE_V8_FP16)) { | ||
254 | + if (!dc_isar_feature(aa64_fp16, s)) { | ||
255 | unallocated_encoding(s); | ||
256 | return; | ||
257 | } else { | ||
258 | @@ -XXX,XX +XXX,XX @@ static void handle_simd_shift_intfp_conv(DisasContext *s, bool is_scalar, | ||
259 | size = MO_32; | ||
260 | } else if (immh & 2) { | ||
261 | size = MO_16; | ||
262 | - if (!arm_dc_feature(s, ARM_FEATURE_V8_FP16)) { | ||
263 | + if (!dc_isar_feature(aa64_fp16, s)) { | ||
264 | unallocated_encoding(s); | ||
265 | return; | ||
266 | } | ||
267 | @@ -XXX,XX +XXX,XX @@ static void handle_simd_shift_fpint_conv(DisasContext *s, bool is_scalar, | ||
268 | size = MO_32; | ||
269 | } else if (immh & 0x2) { | ||
270 | size = MO_16; | ||
271 | - if (!arm_dc_feature(s, ARM_FEATURE_V8_FP16)) { | ||
272 | + if (!dc_isar_feature(aa64_fp16, s)) { | ||
273 | unallocated_encoding(s); | ||
274 | return; | ||
275 | } | ||
276 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_scalar_three_reg_same_fp16(DisasContext *s, | ||
277 | return; | ||
278 | } | ||
279 | |||
280 | - if (!arm_dc_feature(s, ARM_FEATURE_V8_FP16)) { | ||
281 | + if (!dc_isar_feature(aa64_fp16, s)) { | ||
282 | unallocated_encoding(s); | ||
283 | } | ||
284 | |||
285 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_three_reg_same_fp16(DisasContext *s, uint32_t insn) | ||
286 | TCGv_ptr fpst; | ||
287 | bool pairwise = false; | ||
288 | |||
289 | - if (!arm_dc_feature(s, ARM_FEATURE_V8_FP16)) { | ||
290 | + if (!dc_isar_feature(aa64_fp16, s)) { | ||
291 | unallocated_encoding(s); | ||
292 | return; | ||
293 | } | ||
294 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_three_reg_same_extra(DisasContext *s, uint32_t insn) | ||
295 | case 0x1c: /* FCADD, #90 */ | ||
296 | case 0x1e: /* FCADD, #270 */ | ||
297 | if (size == 0 | ||
298 | - || (size == 1 && !arm_dc_feature(s, ARM_FEATURE_V8_FP16)) | ||
299 | + || (size == 1 && !dc_isar_feature(aa64_fp16, s)) | ||
300 | || (size == 3 && !is_q)) { | ||
301 | unallocated_encoding(s); | ||
302 | return; | ||
303 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_two_reg_misc_fp16(DisasContext *s, uint32_t insn) | ||
304 | bool need_fpst = true; | ||
305 | int rmode; | ||
306 | |||
307 | - if (!arm_dc_feature(s, ARM_FEATURE_V8_FP16)) { | ||
308 | + if (!dc_isar_feature(aa64_fp16, s)) { | ||
309 | unallocated_encoding(s); | ||
310 | return; | ||
311 | } | ||
312 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_indexed(DisasContext *s, uint32_t insn) | ||
313 | } | ||
314 | break; | ||
315 | } | ||
316 | - if (is_fp16 && !arm_dc_feature(s, ARM_FEATURE_V8_FP16)) { | ||
317 | + if (is_fp16 && !dc_isar_feature(aa64_fp16, s)) { | ||
318 | unallocated_encoding(s); | ||
319 | return; | ||
320 | } | ||
321 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
322 | index XXXXXXX..XXXXXXX 100644 | ||
323 | --- a/target/arm/translate.c | ||
324 | +++ b/target/arm/translate.c | ||
325 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_insn_3same_ext(DisasContext *s, uint32_t insn) | ||
326 | int size = extract32(insn, 20, 1); | ||
327 | data = extract32(insn, 23, 2); /* rot */ | ||
328 | if (!dc_isar_feature(aa32_vcma, s) | ||
329 | - || (!size && !arm_dc_feature(s, ARM_FEATURE_V8_FP16))) { | ||
330 | + || (!size && !dc_isar_feature(aa32_fp16_arith, s))) { | ||
331 | return 1; | ||
332 | } | ||
333 | fn_gvec_ptr = size ? gen_helper_gvec_fcmlas : gen_helper_gvec_fcmlah; | ||
334 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_insn_3same_ext(DisasContext *s, uint32_t insn) | ||
335 | int size = extract32(insn, 20, 1); | ||
336 | data = extract32(insn, 24, 1); /* rot */ | ||
337 | if (!dc_isar_feature(aa32_vcma, s) | ||
338 | - || (!size && !arm_dc_feature(s, ARM_FEATURE_V8_FP16))) { | ||
339 | + || (!size && !dc_isar_feature(aa32_fp16_arith, s))) { | ||
340 | return 1; | ||
341 | } | ||
342 | fn_gvec_ptr = size ? gen_helper_gvec_fcadds : gen_helper_gvec_fcaddh; | ||
343 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_insn_2reg_scalar_ext(DisasContext *s, uint32_t insn) | ||
344 | return 1; | ||
345 | } | ||
346 | if (size == 0) { | ||
347 | - if (!arm_dc_feature(s, ARM_FEATURE_V8_FP16)) { | ||
348 | + if (!dc_isar_feature(aa32_fp16_arith, s)) { | ||
349 | return 1; | ||
350 | } | ||
351 | /* For fp16, rm is just Vm, and index is M. */ | ||
352 | -- | 345 | -- |
353 | 2.19.1 | 346 | 2.20.1 |
354 | 347 | ||
355 | 348 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Joel Stanley <joel@jms.id.au> |
---|---|---|---|
2 | 2 | ||
3 | Instead of shifts and masks, use direct loads and stores from | 3 | The RTC is modeled to provide time and date functionality. It is |
4 | the neon register file. | 4 | initialised at zero to match the hardware. |
5 | 5 | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 6 | There is no modelling of the alarm functionality, which includes the IRQ |
7 | Message-id: 20181011205206.3552-21-richard.henderson@linaro.org | 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> | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
12 | Message-id: 20190618165311.27066-4-clg@kaod.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 14 | --- |
11 | target/arm/translate.c | 92 +++++++++++++++++++++++------------------- | 15 | hw/timer/Makefile.objs | 2 +- |
12 | 1 file changed, 50 insertions(+), 42 deletions(-) | 16 | include/hw/timer/aspeed_rtc.h | 31 ++++++ |
13 | 17 | hw/timer/aspeed_rtc.c | 180 ++++++++++++++++++++++++++++++++++ | |
14 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 18 | hw/timer/trace-events | 4 + |
19 | 4 files changed, 216 insertions(+), 1 deletion(-) | ||
20 | create mode 100644 include/hw/timer/aspeed_rtc.h | ||
21 | create mode 100644 hw/timer/aspeed_rtc.c | ||
22 | |||
23 | diff --git a/hw/timer/Makefile.objs b/hw/timer/Makefile.objs | ||
15 | index XXXXXXX..XXXXXXX 100644 | 24 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/translate.c | 25 | --- a/hw/timer/Makefile.objs |
17 | +++ b/target/arm/translate.c | 26 | +++ b/hw/timer/Makefile.objs |
18 | @@ -XXX,XX +XXX,XX @@ static TCGv_i32 neon_load_reg(int reg, int pass) | 27 | @@ -XXX,XX +XXX,XX @@ obj-$(CONFIG_MC146818RTC) += mc146818rtc.o |
19 | return tmp; | 28 | obj-$(CONFIG_ALLWINNER_A10_PIT) += allwinner-a10-pit.o |
20 | } | 29 | |
21 | 30 | common-obj-$(CONFIG_STM32F2XX_TIMER) += stm32f2xx_timer.o | |
22 | +static void neon_load_element(TCGv_i32 var, int reg, int ele, TCGMemOp mop) | 31 | -common-obj-$(CONFIG_ASPEED_SOC) += aspeed_timer.o |
23 | +{ | 32 | +common-obj-$(CONFIG_ASPEED_SOC) += aspeed_timer.o aspeed_rtc.o |
24 | + long offset = neon_element_offset(reg, ele, mop & MO_SIZE); | 33 | |
25 | + | 34 | common-obj-$(CONFIG_SUN4V_RTC) += sun4v-rtc.o |
26 | + switch (mop) { | 35 | common-obj-$(CONFIG_CMSDK_APB_TIMER) += cmsdk-apb-timer.o |
27 | + case MO_UB: | 36 | diff --git a/include/hw/timer/aspeed_rtc.h b/include/hw/timer/aspeed_rtc.h |
28 | + tcg_gen_ld8u_i32(var, cpu_env, offset); | 37 | new file mode 100644 |
29 | + break; | 38 | index XXXXXXX..XXXXXXX |
30 | + case MO_UW: | 39 | --- /dev/null |
31 | + tcg_gen_ld16u_i32(var, cpu_env, offset); | 40 | +++ b/include/hw/timer/aspeed_rtc.h |
32 | + break; | 41 | @@ -XXX,XX +XXX,XX @@ |
33 | + case MO_UL: | 42 | +/* |
34 | + tcg_gen_ld_i32(var, cpu_env, offset); | 43 | + * ASPEED Real Time Clock |
35 | + break; | 44 | + * Joel Stanley <joel@jms.id.au> |
45 | + * | ||
46 | + * Copyright 2019 IBM Corp | ||
47 | + * SPDX-License-Identifier: GPL-2.0-or-later | ||
48 | + */ | ||
49 | +#ifndef ASPEED_RTC_H | ||
50 | +#define ASPEED_RTC_H | ||
51 | + | ||
52 | +#include <stdint.h> | ||
53 | + | ||
54 | +#include "hw/hw.h" | ||
55 | +#include "hw/irq.h" | ||
56 | +#include "hw/sysbus.h" | ||
57 | + | ||
58 | +typedef struct AspeedRtcState { | ||
59 | + SysBusDevice parent_obj; | ||
60 | + | ||
61 | + MemoryRegion iomem; | ||
62 | + qemu_irq irq; | ||
63 | + | ||
64 | + uint32_t reg[0x18]; | ||
65 | + int offset; | ||
66 | + | ||
67 | +} AspeedRtcState; | ||
68 | + | ||
69 | +#define TYPE_ASPEED_RTC "aspeed.rtc" | ||
70 | +#define ASPEED_RTC(obj) OBJECT_CHECK(AspeedRtcState, (obj), TYPE_ASPEED_RTC) | ||
71 | + | ||
72 | +#endif /* ASPEED_RTC_H */ | ||
73 | diff --git a/hw/timer/aspeed_rtc.c b/hw/timer/aspeed_rtc.c | ||
74 | new file mode 100644 | ||
75 | index XXXXXXX..XXXXXXX | ||
76 | --- /dev/null | ||
77 | +++ b/hw/timer/aspeed_rtc.c | ||
78 | @@ -XXX,XX +XXX,XX @@ | ||
79 | +/* | ||
80 | + * ASPEED Real Time Clock | ||
81 | + * Joel Stanley <joel@jms.id.au> | ||
82 | + * | ||
83 | + * Copyright 2019 IBM Corp | ||
84 | + * SPDX-License-Identifier: GPL-2.0-or-later | ||
85 | + */ | ||
86 | + | ||
87 | +#include "qemu/osdep.h" | ||
88 | +#include "qemu-common.h" | ||
89 | +#include "hw/timer/aspeed_rtc.h" | ||
90 | +#include "qemu/log.h" | ||
91 | +#include "qemu/timer.h" | ||
92 | + | ||
93 | +#include "trace.h" | ||
94 | + | ||
95 | +#define COUNTER1 (0x00 / 4) | ||
96 | +#define COUNTER2 (0x04 / 4) | ||
97 | +#define ALARM (0x08 / 4) | ||
98 | +#define CONTROL (0x10 / 4) | ||
99 | +#define ALARM_STATUS (0x14 / 4) | ||
100 | + | ||
101 | +#define RTC_UNLOCKED BIT(1) | ||
102 | +#define RTC_ENABLED BIT(0) | ||
103 | + | ||
104 | +static void aspeed_rtc_calc_offset(AspeedRtcState *rtc) | ||
105 | +{ | ||
106 | + struct tm tm; | ||
107 | + uint32_t year, cent; | ||
108 | + uint32_t reg1 = rtc->reg[COUNTER1]; | ||
109 | + uint32_t reg2 = rtc->reg[COUNTER2]; | ||
110 | + | ||
111 | + tm.tm_mday = (reg1 >> 24) & 0x1f; | ||
112 | + tm.tm_hour = (reg1 >> 16) & 0x1f; | ||
113 | + tm.tm_min = (reg1 >> 8) & 0x3f; | ||
114 | + tm.tm_sec = (reg1 >> 0) & 0x3f; | ||
115 | + | ||
116 | + cent = (reg2 >> 16) & 0x1f; | ||
117 | + year = (reg2 >> 8) & 0x7f; | ||
118 | + tm.tm_mon = ((reg2 >> 0) & 0x0f) - 1; | ||
119 | + tm.tm_year = year + (cent * 100) - 1900; | ||
120 | + | ||
121 | + rtc->offset = qemu_timedate_diff(&tm); | ||
122 | +} | ||
123 | + | ||
124 | +static uint32_t aspeed_rtc_get_counter(AspeedRtcState *rtc, int r) | ||
125 | +{ | ||
126 | + uint32_t year, cent; | ||
127 | + struct tm now; | ||
128 | + | ||
129 | + qemu_get_timedate(&now, rtc->offset); | ||
130 | + | ||
131 | + switch (r) { | ||
132 | + case COUNTER1: | ||
133 | + return (now.tm_mday << 24) | (now.tm_hour << 16) | | ||
134 | + (now.tm_min << 8) | now.tm_sec; | ||
135 | + case COUNTER2: | ||
136 | + cent = (now.tm_year + 1900) / 100; | ||
137 | + year = now.tm_year % 100; | ||
138 | + return ((cent & 0x1f) << 16) | ((year & 0x7f) << 8) | | ||
139 | + ((now.tm_mon + 1) & 0xf); | ||
36 | + default: | 140 | + default: |
37 | + g_assert_not_reached(); | 141 | + g_assert_not_reached(); |
38 | + } | 142 | + } |
39 | +} | 143 | +} |
40 | + | 144 | + |
41 | static void neon_load_element64(TCGv_i64 var, int reg, int ele, TCGMemOp mop) | 145 | +static uint64_t aspeed_rtc_read(void *opaque, hwaddr addr, |
42 | { | 146 | + unsigned size) |
43 | long offset = neon_element_offset(reg, ele, mop & MO_SIZE); | 147 | +{ |
44 | @@ -XXX,XX +XXX,XX @@ static void neon_store_reg(int reg, int pass, TCGv_i32 var) | 148 | + AspeedRtcState *rtc = opaque; |
45 | tcg_temp_free_i32(var); | 149 | + uint64_t val; |
46 | } | 150 | + uint32_t r = addr >> 2; |
47 | 151 | + | |
48 | +static void neon_store_element(int reg, int ele, TCGMemOp size, TCGv_i32 var) | 152 | + switch (r) { |
49 | +{ | 153 | + case COUNTER1: |
50 | + long offset = neon_element_offset(reg, ele, size); | 154 | + case COUNTER2: |
51 | + | 155 | + if (rtc->reg[CONTROL] & RTC_ENABLED) { |
52 | + switch (size) { | 156 | + rtc->reg[r] = aspeed_rtc_get_counter(rtc, r); |
53 | + case MO_8: | 157 | + } |
54 | + tcg_gen_st8_i32(var, cpu_env, offset); | 158 | + /* fall through */ |
159 | + case CONTROL: | ||
160 | + val = rtc->reg[r]; | ||
55 | + break; | 161 | + break; |
56 | + case MO_16: | 162 | + case ALARM: |
57 | + tcg_gen_st16_i32(var, cpu_env, offset); | 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); | ||
58 | + break; | 190 | + break; |
59 | + case MO_32: | 191 | + case ALARM: |
60 | + tcg_gen_st_i32(var, cpu_env, offset); | 192 | + case ALARM_STATUS: |
193 | + default: | ||
194 | + qemu_log_mask(LOG_UNIMP, "%s: 0x%" HWADDR_PRIx "\n", __func__, addr); | ||
61 | + break; | 195 | + break; |
62 | + default: | 196 | + } |
63 | + g_assert_not_reached(); | 197 | + trace_aspeed_rtc_write(addr, val); |
64 | + } | 198 | +} |
65 | +} | 199 | + |
66 | + | 200 | +static void aspeed_rtc_reset(DeviceState *d) |
67 | static void neon_store_element64(int reg, int ele, TCGMemOp size, TCGv_i64 var) | 201 | +{ |
68 | { | 202 | + AspeedRtcState *rtc = ASPEED_RTC(d); |
69 | long offset = neon_element_offset(reg, ele, size); | 203 | + |
70 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_ls_insn(DisasContext *s, uint32_t insn) | 204 | + rtc->offset = 0; |
71 | int stride; | 205 | + memset(rtc->reg, 0, sizeof(rtc->reg)); |
72 | int size; | 206 | +} |
73 | int reg; | 207 | + |
74 | - int pass; | 208 | +static const MemoryRegionOps aspeed_rtc_ops = { |
75 | int load; | 209 | + .read = aspeed_rtc_read, |
76 | - int shift; | 210 | + .write = aspeed_rtc_write, |
77 | int n; | 211 | + .endianness = DEVICE_NATIVE_ENDIAN, |
78 | int vec_size; | 212 | +}; |
79 | int mmu_idx; | 213 | + |
80 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_ls_insn(DisasContext *s, uint32_t insn) | 214 | +static const VMStateDescription vmstate_aspeed_rtc = { |
81 | } else { | 215 | + .name = TYPE_ASPEED_RTC, |
82 | /* Single element. */ | 216 | + .version_id = 1, |
83 | int idx = (insn >> 4) & 0xf; | 217 | + .fields = (VMStateField[]) { |
84 | - pass = (insn >> 7) & 1; | 218 | + VMSTATE_UINT32_ARRAY(reg, AspeedRtcState, 0x18), |
85 | + int reg_idx; | 219 | + VMSTATE_INT32(offset, AspeedRtcState), |
86 | switch (size) { | 220 | + VMSTATE_INT32(offset, AspeedRtcState), |
87 | case 0: | 221 | + VMSTATE_END_OF_LIST() |
88 | - shift = ((insn >> 5) & 3) * 8; | 222 | + } |
89 | + reg_idx = (insn >> 5) & 7; | 223 | +}; |
90 | stride = 1; | 224 | + |
91 | break; | 225 | +static void aspeed_rtc_realize(DeviceState *dev, Error **errp) |
92 | case 1: | 226 | +{ |
93 | - shift = ((insn >> 6) & 1) * 16; | 227 | + SysBusDevice *sbd = SYS_BUS_DEVICE(dev); |
94 | + reg_idx = (insn >> 6) & 3; | 228 | + AspeedRtcState *s = ASPEED_RTC(dev); |
95 | stride = (insn & (1 << 5)) ? 2 : 1; | 229 | + |
96 | break; | 230 | + sysbus_init_irq(sbd, &s->irq); |
97 | case 2: | 231 | + |
98 | - shift = 0; | 232 | + memory_region_init_io(&s->iomem, OBJECT(s), &aspeed_rtc_ops, s, |
99 | + reg_idx = (insn >> 7) & 1; | 233 | + "aspeed-rtc", 0x18ULL); |
100 | stride = (insn & (1 << 6)) ? 2 : 1; | 234 | + sysbus_init_mmio(sbd, &s->iomem); |
101 | break; | 235 | +} |
102 | default: | 236 | + |
103 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_ls_insn(DisasContext *s, uint32_t insn) | 237 | +static void aspeed_rtc_class_init(ObjectClass *klass, void *data) |
104 | */ | 238 | +{ |
105 | return 1; | 239 | + DeviceClass *dc = DEVICE_CLASS(klass); |
106 | } | 240 | + |
107 | + tmp = tcg_temp_new_i32(); | 241 | + dc->realize = aspeed_rtc_realize; |
108 | addr = tcg_temp_new_i32(); | 242 | + dc->vmsd = &vmstate_aspeed_rtc; |
109 | load_reg_var(s, addr, rn); | 243 | + dc->reset = aspeed_rtc_reset; |
110 | for (reg = 0; reg < nregs; reg++) { | 244 | +} |
111 | if (load) { | 245 | + |
112 | - tmp = tcg_temp_new_i32(); | 246 | +static const TypeInfo aspeed_rtc_info = { |
113 | - switch (size) { | 247 | + .name = TYPE_ASPEED_RTC, |
114 | - case 0: | 248 | + .parent = TYPE_SYS_BUS_DEVICE, |
115 | - gen_aa32_ld8u(s, tmp, addr, get_mem_index(s)); | 249 | + .instance_size = sizeof(AspeedRtcState), |
116 | - break; | 250 | + .class_init = aspeed_rtc_class_init, |
117 | - case 1: | 251 | +}; |
118 | - gen_aa32_ld16u(s, tmp, addr, get_mem_index(s)); | 252 | + |
119 | - break; | 253 | +static void aspeed_rtc_register_types(void) |
120 | - case 2: | 254 | +{ |
121 | - gen_aa32_ld32u(s, tmp, addr, get_mem_index(s)); | 255 | + type_register_static(&aspeed_rtc_info); |
122 | - break; | 256 | +} |
123 | - default: /* Avoid compiler warnings. */ | 257 | + |
124 | - abort(); | 258 | +type_init(aspeed_rtc_register_types) |
125 | - } | 259 | diff --git a/hw/timer/trace-events b/hw/timer/trace-events |
126 | - if (size != 2) { | 260 | index XXXXXXX..XXXXXXX 100644 |
127 | - tmp2 = neon_load_reg(rd, pass); | 261 | --- a/hw/timer/trace-events |
128 | - tcg_gen_deposit_i32(tmp, tmp2, tmp, | 262 | +++ b/hw/timer/trace-events |
129 | - shift, size ? 16 : 8); | 263 | @@ -XXX,XX +XXX,XX @@ cmsdk_apb_dualtimer_read(uint64_t offset, uint64_t data, unsigned size) "CMSDK A |
130 | - tcg_temp_free_i32(tmp2); | 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" |
131 | - } | 265 | cmsdk_apb_dualtimer_reset(void) "CMSDK APB dualtimer: reset" |
132 | - neon_store_reg(rd, pass, tmp); | 266 | |
133 | + gen_aa32_ld_i32(s, tmp, addr, get_mem_index(s), | 267 | +# hw/timer/aspeed-rtc.c |
134 | + s->be_data | size); | 268 | +aspeed_rtc_read(uint64_t addr, uint64_t value) "addr 0x%02" PRIx64 " value 0x%08" PRIx64 |
135 | + neon_store_element(rd, reg_idx, size, tmp); | 269 | +aspeed_rtc_write(uint64_t addr, uint64_t value) "addr 0x%02" PRIx64 " value 0x%08" PRIx64 |
136 | } else { /* Store */ | 270 | + |
137 | - tmp = neon_load_reg(rd, pass); | 271 | # sun4v-rtc.c |
138 | - if (shift) | 272 | sun4v_rtc_read(uint64_t addr, uint64_t value) "read: addr 0x%" PRIx64 " value 0x%" PRIx64 |
139 | - tcg_gen_shri_i32(tmp, tmp, shift); | 273 | sun4v_rtc_write(uint64_t addr, uint64_t value) "write: addr 0x%" PRIx64 " value 0x%" PRIx64 |
140 | - switch (size) { | ||
141 | - case 0: | ||
142 | - gen_aa32_st8(s, tmp, addr, get_mem_index(s)); | ||
143 | - break; | ||
144 | - case 1: | ||
145 | - gen_aa32_st16(s, tmp, addr, get_mem_index(s)); | ||
146 | - break; | ||
147 | - case 2: | ||
148 | - gen_aa32_st32(s, tmp, addr, get_mem_index(s)); | ||
149 | - break; | ||
150 | - } | ||
151 | - tcg_temp_free_i32(tmp); | ||
152 | + neon_load_element(tmp, rd, reg_idx, size); | ||
153 | + gen_aa32_st_i32(s, tmp, addr, get_mem_index(s), | ||
154 | + s->be_data | size); | ||
155 | } | ||
156 | rd += stride; | ||
157 | tcg_gen_addi_i32(addr, addr, 1 << size); | ||
158 | } | ||
159 | tcg_temp_free_i32(addr); | ||
160 | + tcg_temp_free_i32(tmp); | ||
161 | stride = nregs * (1 << size); | ||
162 | } | ||
163 | } | ||
164 | -- | 274 | -- |
165 | 2.19.1 | 275 | 2.20.1 |
166 | 276 | ||
167 | 277 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Joel Stanley <joel@jms.id.au> |
---|---|---|---|
2 | 2 | ||
3 | The EL3 version of this register does not include an ASID, | 3 | All systems have an RTC. |
4 | and so the tlb_flush performed by vmsa_ttbr_write is not needed. | ||
5 | 4 | ||
6 | Reviewed-by: Aaron Lindsay <aaron@os.amperecomputing.com> | 5 | The IRQ is hooked up but the model does not use it at this stage. There |
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 6 | is no guest code that uses it, so this limitation is acceptable. |
7 | |||
8 | Signed-off-by: Joel Stanley <joel@jms.id.au> | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Message-id: 20181019015617.22583-2-richard.henderson@linaro.org | 10 | Message-id: 20190618165311.27066-5-clg@kaod.org |
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 12 | --- |
12 | target/arm/helper.c | 2 +- | 13 | include/hw/arm/aspeed_soc.h | 2 ++ |
13 | 1 file changed, 1 insertion(+), 1 deletion(-) | 14 | hw/arm/aspeed_soc.c | 13 +++++++++++++ |
15 | 2 files changed, 15 insertions(+) | ||
14 | 16 | ||
15 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 17 | diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h |
16 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/helper.c | 19 | --- a/include/hw/arm/aspeed_soc.h |
18 | +++ b/target/arm/helper.c | 20 | +++ b/include/hw/arm/aspeed_soc.h |
19 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo el3_cp_reginfo[] = { | 21 | @@ -XXX,XX +XXX,XX @@ |
20 | .fieldoffset = offsetof(CPUARMState, cp15.mvbar) }, | 22 | #include "hw/misc/aspeed_scu.h" |
21 | { .name = "TTBR0_EL3", .state = ARM_CP_STATE_AA64, | 23 | #include "hw/misc/aspeed_sdmc.h" |
22 | .opc0 = 3, .opc1 = 6, .crn = 2, .crm = 0, .opc2 = 0, | 24 | #include "hw/timer/aspeed_timer.h" |
23 | - .access = PL3_RW, .writefn = vmsa_ttbr_write, .resetvalue = 0, | 25 | +#include "hw/timer/aspeed_rtc.h" |
24 | + .access = PL3_RW, .resetvalue = 0, | 26 | #include "hw/i2c/aspeed_i2c.h" |
25 | .fieldoffset = offsetof(CPUARMState, cp15.ttbr0_el[3]) }, | 27 | #include "hw/ssi/aspeed_smc.h" |
26 | { .name = "TCR_EL3", .state = ARM_CP_STATE_AA64, | 28 | #include "hw/watchdog/wdt_aspeed.h" |
27 | .opc0 = 3, .opc1 = 6, .crn = 2, .crm = 0, .opc2 = 2, | 29 | @@ -XXX,XX +XXX,XX @@ typedef struct AspeedSoCState { |
30 | ARMCPU cpu; | ||
31 | MemoryRegion sram; | ||
32 | AspeedVICState vic; | ||
33 | + AspeedRtcState rtc; | ||
34 | AspeedTimerCtrlState timerctrl; | ||
35 | AspeedI2CState i2c; | ||
36 | AspeedSCUState scu; | ||
37 | diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c | ||
38 | index XXXXXXX..XXXXXXX 100644 | ||
39 | --- a/hw/arm/aspeed_soc.c | ||
40 | +++ b/hw/arm/aspeed_soc.c | ||
41 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_init(Object *obj) | ||
42 | sysbus_init_child_obj(obj, "vic", OBJECT(&s->vic), sizeof(s->vic), | ||
43 | TYPE_ASPEED_VIC); | ||
44 | |||
45 | + sysbus_init_child_obj(obj, "rtc", OBJECT(&s->rtc), sizeof(s->rtc), | ||
46 | + TYPE_ASPEED_RTC); | ||
47 | + | ||
48 | sysbus_init_child_obj(obj, "timerctrl", OBJECT(&s->timerctrl), | ||
49 | sizeof(s->timerctrl), TYPE_ASPEED_TIMER); | ||
50 | object_property_add_const_link(OBJECT(&s->timerctrl), "scu", | ||
51 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) | ||
52 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->vic), 1, | ||
53 | qdev_get_gpio_in(DEVICE(&s->cpu), ARM_CPU_FIQ)); | ||
54 | |||
55 | + /* RTC */ | ||
56 | + object_property_set_bool(OBJECT(&s->rtc), true, "realized", &err); | ||
57 | + if (err) { | ||
58 | + error_propagate(errp, err); | ||
59 | + return; | ||
60 | + } | ||
61 | + sysbus_mmio_map(SYS_BUS_DEVICE(&s->rtc), 0, sc->info->memmap[ASPEED_RTC]); | ||
62 | + sysbus_connect_irq(SYS_BUS_DEVICE(&s->rtc), 0, | ||
63 | + aspeed_soc_get_irq(s, ASPEED_RTC)); | ||
64 | + | ||
65 | /* Timer */ | ||
66 | object_property_set_bool(OBJECT(&s->timerctrl), true, "realized", &err); | ||
67 | if (err) { | ||
28 | -- | 68 | -- |
29 | 2.19.1 | 69 | 2.20.1 |
30 | 70 | ||
31 | 71 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Cédric Le Goater <clg@kaod.org> |
---|---|---|---|
2 | 2 | ||
3 | For a sequence of loads or stores from a single register, | 3 | The current models of the Aspeed SoCs only have one CPU but future |
4 | little-endian operations can be promoted to an 8-byte op. | 4 | ones will support SMP. Introduce a new num_cpus field at the SoC class |
5 | This can reduce the number of operations by a factor of 8. | 5 | level to define the number of available CPUs per SoC and also |
6 | 6 | introduce a 'num-cpus' property to activate the CPUs configured for | |
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 7 | the machine. |
8 | Message-id: 20181011205206.3552-5-richard.henderson@linaro.org | 8 | |
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 9 | The max_cpus limit of the machine should depend on the SoC definition |
10 | but, unfortunately, these values are not available when the machine | ||
11 | class is initialized. This is the reason why we add a check on | ||
12 | num_cpus in the AspeedSoC realize handler. | ||
13 | |||
14 | SMP support will be activated when models for such SoCs are implemented. | ||
15 | |||
16 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
17 | Reviewed-by: Joel Stanley <joel@jms.id.au> | ||
18 | Message-id: 20190618165311.27066-6-clg@kaod.org | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 19 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 20 | --- |
12 | target/arm/translate-a64.c | 66 +++++++++++++++++++++++--------------- | 21 | include/hw/arm/aspeed_soc.h | 5 ++++- |
13 | 1 file changed, 40 insertions(+), 26 deletions(-) | 22 | hw/arm/aspeed.c | 7 +++++-- |
14 | 23 | hw/arm/aspeed_soc.c | 33 +++++++++++++++++++++++++++------ | |
15 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 24 | 3 files changed, 36 insertions(+), 9 deletions(-) |
25 | |||
26 | diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | 27 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/translate-a64.c | 28 | --- a/include/hw/arm/aspeed_soc.h |
18 | +++ b/target/arm/translate-a64.c | 29 | +++ b/include/hw/arm/aspeed_soc.h |
19 | @@ -XXX,XX +XXX,XX @@ static void write_vec_element_i32(DisasContext *s, TCGv_i32 tcg_src, | 30 | @@ -XXX,XX +XXX,XX @@ |
20 | 31 | ||
21 | /* Store from vector register to memory */ | 32 | #define ASPEED_SPIS_NUM 2 |
22 | static void do_vec_st(DisasContext *s, int srcidx, int element, | 33 | #define ASPEED_WDTS_NUM 3 |
23 | - TCGv_i64 tcg_addr, int size) | 34 | +#define ASPEED_CPUS_NUM 2 |
24 | + TCGv_i64 tcg_addr, int size, TCGMemOp endian) | 35 | |
25 | { | 36 | typedef struct AspeedSoCState { |
26 | - TCGMemOp memop = s->be_data + size; | 37 | /*< private >*/ |
27 | TCGv_i64 tcg_tmp = tcg_temp_new_i64(); | 38 | DeviceState parent; |
28 | 39 | ||
29 | read_vec_element(s, tcg_tmp, srcidx, element, size); | 40 | /*< public >*/ |
30 | - tcg_gen_qemu_st_i64(tcg_tmp, tcg_addr, get_mem_index(s), memop); | 41 | - ARMCPU cpu; |
31 | + tcg_gen_qemu_st_i64(tcg_tmp, tcg_addr, get_mem_index(s), endian | size); | 42 | + ARMCPU cpu[ASPEED_CPUS_NUM]; |
32 | 43 | + uint32_t num_cpus; | |
33 | tcg_temp_free_i64(tcg_tmp); | 44 | MemoryRegion sram; |
34 | } | 45 | AspeedVICState vic; |
35 | 46 | AspeedRtcState rtc; | |
36 | /* Load from memory to vector register */ | 47 | @@ -XXX,XX +XXX,XX @@ typedef struct AspeedSoCInfo { |
37 | static void do_vec_ld(DisasContext *s, int destidx, int element, | 48 | int wdts_num; |
38 | - TCGv_i64 tcg_addr, int size) | 49 | const int *irqmap; |
39 | + TCGv_i64 tcg_addr, int size, TCGMemOp endian) | 50 | const hwaddr *memmap; |
40 | { | 51 | + uint32_t num_cpus; |
41 | - TCGMemOp memop = s->be_data + size; | 52 | } AspeedSoCInfo; |
42 | TCGv_i64 tcg_tmp = tcg_temp_new_i64(); | 53 | |
43 | 54 | typedef struct AspeedSoCClass { | |
44 | - tcg_gen_qemu_ld_i64(tcg_tmp, tcg_addr, get_mem_index(s), memop); | 55 | diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c |
45 | + tcg_gen_qemu_ld_i64(tcg_tmp, tcg_addr, get_mem_index(s), endian | size); | 56 | index XXXXXXX..XXXXXXX 100644 |
46 | write_vec_element(s, tcg_tmp, destidx, element, size); | 57 | --- a/hw/arm/aspeed.c |
47 | 58 | +++ b/hw/arm/aspeed.c | |
48 | tcg_temp_free_i64(tcg_tmp); | 59 | @@ -XXX,XX +XXX,XX @@ |
49 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_multiple_struct(DisasContext *s, uint32_t insn) | 60 | #include "hw/misc/tmp105.h" |
50 | bool is_postidx = extract32(insn, 23, 1); | 61 | #include "qemu/log.h" |
51 | bool is_q = extract32(insn, 30, 1); | 62 | #include "sysemu/block-backend.h" |
52 | TCGv_i64 tcg_addr, tcg_rn, tcg_ebytes; | 63 | +#include "sysemu/sysemu.h" |
53 | + TCGMemOp endian = s->be_data; | 64 | #include "hw/loader.h" |
54 | 65 | #include "qemu/error-report.h" | |
55 | - int ebytes = 1 << size; | 66 | #include "qemu/units.h" |
56 | - int elements = (is_q ? 128 : 64) / (8 << size); | 67 | |
57 | + int ebytes; /* bytes per element */ | 68 | static struct arm_boot_info aspeed_board_binfo = { |
58 | + int elements; /* elements per vector */ | 69 | .board_id = -1, /* device-tree-only board */ |
59 | int rpt; /* num iterations */ | 70 | - .nb_cpus = 1, |
60 | int selem; /* structure elements */ | 71 | }; |
61 | int r; | 72 | |
62 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_multiple_struct(DisasContext *s, uint32_t insn) | 73 | struct AspeedBoardState { |
63 | gen_check_sp_alignment(s); | 74 | @@ -XXX,XX +XXX,XX @@ static void aspeed_board_init(MachineState *machine, |
64 | } | 75 | &error_abort); |
65 | 76 | object_property_set_int(OBJECT(&bmc->soc), cfg->num_cs, "num-cs", | |
66 | + /* For our purposes, bytes are always little-endian. */ | 77 | &error_abort); |
67 | + if (size == 0) { | 78 | + object_property_set_int(OBJECT(&bmc->soc), smp_cpus, "num-cpus", |
68 | + endian = MO_LE; | 79 | + &error_abort); |
80 | if (machine->kernel_filename) { | ||
81 | /* | ||
82 | * When booting with a -kernel command line there is no u-boot | ||
83 | @@ -XXX,XX +XXX,XX @@ static void aspeed_board_init(MachineState *machine, | ||
84 | aspeed_board_binfo.kernel_cmdline = machine->kernel_cmdline; | ||
85 | aspeed_board_binfo.ram_size = ram_size; | ||
86 | aspeed_board_binfo.loader_start = sc->info->memmap[ASPEED_SDRAM]; | ||
87 | + aspeed_board_binfo.nb_cpus = bmc->soc.num_cpus; | ||
88 | |||
89 | if (cfg->i2c_init) { | ||
90 | cfg->i2c_init(bmc); | ||
91 | @@ -XXX,XX +XXX,XX @@ static void aspeed_machine_class_init(ObjectClass *oc, void *data) | ||
92 | |||
93 | mc->desc = board->desc; | ||
94 | mc->init = aspeed_machine_init; | ||
95 | - mc->max_cpus = 1; | ||
96 | + mc->max_cpus = ASPEED_CPUS_NUM; | ||
97 | mc->no_sdcard = 1; | ||
98 | mc->no_floppy = 1; | ||
99 | mc->no_cdrom = 1; | ||
100 | diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c | ||
101 | index XXXXXXX..XXXXXXX 100644 | ||
102 | --- a/hw/arm/aspeed_soc.c | ||
103 | +++ b/hw/arm/aspeed_soc.c | ||
104 | @@ -XXX,XX +XXX,XX @@ | ||
105 | #include "hw/char/serial.h" | ||
106 | #include "qemu/log.h" | ||
107 | #include "qemu/module.h" | ||
108 | +#include "qemu/error-report.h" | ||
109 | #include "hw/i2c/aspeed_i2c.h" | ||
110 | #include "net/net.h" | ||
111 | |||
112 | @@ -XXX,XX +XXX,XX @@ static const AspeedSoCInfo aspeed_socs[] = { | ||
113 | .wdts_num = 2, | ||
114 | .irqmap = aspeed_soc_ast2400_irqmap, | ||
115 | .memmap = aspeed_soc_ast2400_memmap, | ||
116 | + .num_cpus = 1, | ||
117 | }, { | ||
118 | .name = "ast2400-a1", | ||
119 | .cpu_type = ARM_CPU_TYPE_NAME("arm926"), | ||
120 | @@ -XXX,XX +XXX,XX @@ static const AspeedSoCInfo aspeed_socs[] = { | ||
121 | .wdts_num = 2, | ||
122 | .irqmap = aspeed_soc_ast2400_irqmap, | ||
123 | .memmap = aspeed_soc_ast2400_memmap, | ||
124 | + .num_cpus = 1, | ||
125 | }, { | ||
126 | .name = "ast2400", | ||
127 | .cpu_type = ARM_CPU_TYPE_NAME("arm926"), | ||
128 | @@ -XXX,XX +XXX,XX @@ static const AspeedSoCInfo aspeed_socs[] = { | ||
129 | .wdts_num = 2, | ||
130 | .irqmap = aspeed_soc_ast2400_irqmap, | ||
131 | .memmap = aspeed_soc_ast2400_memmap, | ||
132 | + .num_cpus = 1, | ||
133 | }, { | ||
134 | .name = "ast2500-a1", | ||
135 | .cpu_type = ARM_CPU_TYPE_NAME("arm1176"), | ||
136 | @@ -XXX,XX +XXX,XX @@ static const AspeedSoCInfo aspeed_socs[] = { | ||
137 | .wdts_num = 3, | ||
138 | .irqmap = aspeed_soc_ast2500_irqmap, | ||
139 | .memmap = aspeed_soc_ast2500_memmap, | ||
140 | + .num_cpus = 1, | ||
141 | }, | ||
142 | }; | ||
143 | |||
144 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_init(Object *obj) | ||
145 | AspeedSoCClass *sc = ASPEED_SOC_GET_CLASS(s); | ||
146 | int i; | ||
147 | |||
148 | - object_initialize_child(obj, "cpu", OBJECT(&s->cpu), sizeof(s->cpu), | ||
149 | - sc->info->cpu_type, &error_abort, NULL); | ||
150 | + for (i = 0; i < sc->info->num_cpus; i++) { | ||
151 | + object_initialize_child(obj, "cpu[*]", OBJECT(&s->cpu[i]), | ||
152 | + sizeof(s->cpu[i]), sc->info->cpu_type, | ||
153 | + &error_abort, NULL); | ||
154 | + } | ||
155 | |||
156 | sysbus_init_child_obj(obj, "scu", OBJECT(&s->scu), sizeof(s->scu), | ||
157 | TYPE_ASPEED_SCU); | ||
158 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) | ||
159 | create_unimplemented_device("aspeed_soc.io", sc->info->memmap[ASPEED_IOMEM], | ||
160 | ASPEED_SOC_IOMEM_SIZE); | ||
161 | |||
162 | + if (s->num_cpus > sc->info->num_cpus) { | ||
163 | + warn_report("%s: invalid number of CPUs %d, using default %d", | ||
164 | + sc->info->name, s->num_cpus, sc->info->num_cpus); | ||
165 | + s->num_cpus = sc->info->num_cpus; | ||
69 | + } | 166 | + } |
70 | + | 167 | + |
71 | + /* Consecutive little-endian elements from a single register | 168 | /* CPU */ |
72 | + * can be promoted to a larger little-endian operation. | 169 | - object_property_set_bool(OBJECT(&s->cpu), true, "realized", &err); |
73 | + */ | 170 | - if (err) { |
74 | + if (selem == 1 && endian == MO_LE) { | 171 | - error_propagate(errp, err); |
75 | + size = 3; | 172 | - return; |
76 | + } | 173 | + for (i = 0; i < s->num_cpus; i++) { |
77 | + ebytes = 1 << size; | 174 | + object_property_set_bool(OBJECT(&s->cpu[i]), true, "realized", &err); |
78 | + elements = (is_q ? 16 : 8) / ebytes; | 175 | + if (err) { |
79 | + | 176 | + error_propagate(errp, err); |
80 | tcg_rn = cpu_reg_sp(s, rn); | 177 | + return; |
81 | tcg_addr = tcg_temp_new_i64(); | 178 | + } |
82 | tcg_gen_mov_i64(tcg_addr, tcg_rn); | ||
83 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_multiple_struct(DisasContext *s, uint32_t insn) | ||
84 | for (r = 0; r < rpt; r++) { | ||
85 | int e; | ||
86 | for (e = 0; e < elements; e++) { | ||
87 | - int tt = (rt + r) % 32; | ||
88 | int xs; | ||
89 | for (xs = 0; xs < selem; xs++) { | ||
90 | + int tt = (rt + r + xs) % 32; | ||
91 | if (is_store) { | ||
92 | - do_vec_st(s, tt, e, tcg_addr, size); | ||
93 | + do_vec_st(s, tt, e, tcg_addr, size, endian); | ||
94 | } else { | ||
95 | - do_vec_ld(s, tt, e, tcg_addr, size); | ||
96 | - | ||
97 | - /* For non-quad operations, setting a slice of the low | ||
98 | - * 64 bits of the register clears the high 64 bits (in | ||
99 | - * the ARM ARM pseudocode this is implicit in the fact | ||
100 | - * that 'rval' is a 64 bit wide variable). | ||
101 | - * For quad operations, we might still need to zero the | ||
102 | - * high bits of SVE. We optimize by noticing that we only | ||
103 | - * need to do this the first time we touch a register. | ||
104 | - */ | ||
105 | - if (e == 0 && (r == 0 || xs == selem - 1)) { | ||
106 | - clear_vec_high(s, is_q, tt); | ||
107 | - } | ||
108 | + do_vec_ld(s, tt, e, tcg_addr, size, endian); | ||
109 | } | ||
110 | tcg_gen_add_i64(tcg_addr, tcg_addr, tcg_ebytes); | ||
111 | - tt = (tt + 1) % 32; | ||
112 | } | ||
113 | } | ||
114 | } | 179 | } |
115 | 180 | ||
116 | + if (!is_store) { | 181 | /* SRAM */ |
117 | + /* For non-quad operations, setting a slice of the low | 182 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) |
118 | + * 64 bits of the register clears the high 64 bits (in | 183 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->ftgmac100), 0, |
119 | + * the ARM ARM pseudocode this is implicit in the fact | 184 | aspeed_soc_get_irq(s, ASPEED_ETH1)); |
120 | + * that 'rval' is a 64 bit wide variable). | 185 | } |
121 | + * For quad operations, we might still need to zero the | 186 | +static Property aspeed_soc_properties[] = { |
122 | + * high bits of SVE. | 187 | + DEFINE_PROP_UINT32("num-cpus", AspeedSoCState, num_cpus, 0), |
123 | + */ | 188 | + DEFINE_PROP_END_OF_LIST(), |
124 | + for (r = 0; r < rpt * selem; r++) { | 189 | +}; |
125 | + int tt = (rt + r) % 32; | 190 | |
126 | + clear_vec_high(s, is_q, tt); | 191 | static void aspeed_soc_class_init(ObjectClass *oc, void *data) |
127 | + } | 192 | { |
128 | + } | 193 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_class_init(ObjectClass *oc, void *data) |
129 | + | 194 | dc->realize = aspeed_soc_realize; |
130 | if (is_postidx) { | 195 | /* Reason: Uses serial_hds and nd_table in realize() directly */ |
131 | int rm = extract32(insn, 16, 5); | 196 | dc->user_creatable = false; |
132 | if (rm == 31) { | 197 | + dc->props = aspeed_soc_properties; |
133 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_single_struct(DisasContext *s, uint32_t insn) | 198 | } |
134 | } else { | 199 | |
135 | /* Load/store one element per register */ | 200 | static const TypeInfo aspeed_soc_type_info = { |
136 | if (is_load) { | ||
137 | - do_vec_ld(s, rt, index, tcg_addr, scale); | ||
138 | + do_vec_ld(s, rt, index, tcg_addr, scale, s->be_data); | ||
139 | } else { | ||
140 | - do_vec_st(s, rt, index, tcg_addr, scale); | ||
141 | + do_vec_st(s, rt, index, tcg_addr, scale, s->be_data); | ||
142 | } | ||
143 | } | ||
144 | tcg_gen_add_i64(tcg_addr, tcg_addr, tcg_ebytes); | ||
145 | -- | 201 | -- |
146 | 2.19.1 | 202 | 2.20.1 |
147 | 203 | ||
148 | 204 | diff view generated by jsdifflib |
1 | From: Richard Henderson <rth@twiddle.net> | 1 | From: Cédric Le Goater <clg@kaod.org> |
---|---|---|---|
2 | 2 | ||
3 | This can reduce the number of opcodes required for certain | 3 | The Aspeed SoCs have two MACs. Extend the Aspeed model to support a |
4 | complex forms of load-multiple (e.g. ld4.16b). | 4 | second NIC. |
5 | 5 | ||
6 | Signed-off-by: Richard Henderson <rth@twiddle.net> | 6 | Signed-off-by: Cédric Le Goater <clg@kaod.org> |
7 | Message-id: 20181011205206.3552-2-richard.henderson@linaro.org | 7 | Reviewed-by: Joel Stanley <joel@jms.id.au> |
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Message-id: 20190618165311.27066-7-clg@kaod.org |
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 10 | --- |
11 | target/arm/translate-a64.c | 12 ++++++++---- | 11 | include/hw/arm/aspeed_soc.h | 3 ++- |
12 | 1 file changed, 8 insertions(+), 4 deletions(-) | 12 | hw/arm/aspeed_soc.c | 33 +++++++++++++++++++-------------- |
13 | 2 files changed, 21 insertions(+), 15 deletions(-) | ||
13 | 14 | ||
14 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 15 | diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h |
15 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/translate-a64.c | 17 | --- a/include/hw/arm/aspeed_soc.h |
17 | +++ b/target/arm/translate-a64.c | 18 | +++ b/include/hw/arm/aspeed_soc.h |
18 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_multiple_struct(DisasContext *s, uint32_t insn) | 19 | @@ -XXX,XX +XXX,XX @@ |
19 | bool is_store = !extract32(insn, 22, 1); | 20 | #define ASPEED_SPIS_NUM 2 |
20 | bool is_postidx = extract32(insn, 23, 1); | 21 | #define ASPEED_WDTS_NUM 3 |
21 | bool is_q = extract32(insn, 30, 1); | 22 | #define ASPEED_CPUS_NUM 2 |
22 | - TCGv_i64 tcg_addr, tcg_rn; | 23 | +#define ASPEED_MACS_NUM 2 |
23 | + TCGv_i64 tcg_addr, tcg_rn, tcg_ebytes; | 24 | |
24 | 25 | typedef struct AspeedSoCState { | |
25 | int ebytes = 1 << size; | 26 | /*< private >*/ |
26 | int elements = (is_q ? 128 : 64) / (8 << size); | 27 | @@ -XXX,XX +XXX,XX @@ typedef struct AspeedSoCState { |
27 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_multiple_struct(DisasContext *s, uint32_t insn) | 28 | AspeedSMCState spi[ASPEED_SPIS_NUM]; |
28 | tcg_rn = cpu_reg_sp(s, rn); | 29 | AspeedSDMCState sdmc; |
29 | tcg_addr = tcg_temp_new_i64(); | 30 | AspeedWDTState wdt[ASPEED_WDTS_NUM]; |
30 | tcg_gen_mov_i64(tcg_addr, tcg_rn); | 31 | - FTGMAC100State ftgmac100; |
31 | + tcg_ebytes = tcg_const_i64(ebytes); | 32 | + FTGMAC100State ftgmac100[ASPEED_MACS_NUM]; |
32 | 33 | } AspeedSoCState; | |
33 | for (r = 0; r < rpt; r++) { | 34 | |
34 | int e; | 35 | #define TYPE_ASPEED_SOC "aspeed-soc" |
35 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_multiple_struct(DisasContext *s, uint32_t insn) | 36 | diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c |
36 | clear_vec_high(s, is_q, tt); | 37 | index XXXXXXX..XXXXXXX 100644 |
37 | } | 38 | --- a/hw/arm/aspeed_soc.c |
38 | } | 39 | +++ b/hw/arm/aspeed_soc.c |
39 | - tcg_gen_addi_i64(tcg_addr, tcg_addr, ebytes); | 40 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_init(Object *obj) |
40 | + tcg_gen_add_i64(tcg_addr, tcg_addr, tcg_ebytes); | 41 | sc->info->silicon_rev); |
41 | tt = (tt + 1) % 32; | ||
42 | } | ||
43 | } | ||
44 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_multiple_struct(DisasContext *s, uint32_t insn) | ||
45 | tcg_gen_add_i64(tcg_rn, tcg_rn, cpu_reg(s, rm)); | ||
46 | } | ||
47 | } | 42 | } |
48 | + tcg_temp_free_i64(tcg_ebytes); | 43 | |
49 | tcg_temp_free_i64(tcg_addr); | 44 | - sysbus_init_child_obj(obj, "ftgmac100", OBJECT(&s->ftgmac100), |
45 | - sizeof(s->ftgmac100), TYPE_FTGMAC100); | ||
46 | + for (i = 0; i < ASPEED_MACS_NUM; i++) { | ||
47 | + sysbus_init_child_obj(obj, "ftgmac100[*]", OBJECT(&s->ftgmac100[i]), | ||
48 | + sizeof(s->ftgmac100[i]), TYPE_FTGMAC100); | ||
49 | + } | ||
50 | } | 50 | } |
51 | 51 | ||
52 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_single_struct(DisasContext *s, uint32_t insn) | 52 | static void aspeed_soc_realize(DeviceState *dev, Error **errp) |
53 | bool replicate = false; | 53 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) |
54 | int index = is_q << 3 | S << 2 | size; | ||
55 | int ebytes, xs; | ||
56 | - TCGv_i64 tcg_addr, tcg_rn; | ||
57 | + TCGv_i64 tcg_addr, tcg_rn, tcg_ebytes; | ||
58 | |||
59 | switch (scale) { | ||
60 | case 3: | ||
61 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_single_struct(DisasContext *s, uint32_t insn) | ||
62 | tcg_rn = cpu_reg_sp(s, rn); | ||
63 | tcg_addr = tcg_temp_new_i64(); | ||
64 | tcg_gen_mov_i64(tcg_addr, tcg_rn); | ||
65 | + tcg_ebytes = tcg_const_i64(ebytes); | ||
66 | |||
67 | for (xs = 0; xs < selem; xs++) { | ||
68 | if (replicate) { | ||
69 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_single_struct(DisasContext *s, uint32_t insn) | ||
70 | do_vec_st(s, rt, index, tcg_addr, scale); | ||
71 | } | ||
72 | } | ||
73 | - tcg_gen_addi_i64(tcg_addr, tcg_addr, ebytes); | ||
74 | + tcg_gen_add_i64(tcg_addr, tcg_addr, tcg_ebytes); | ||
75 | rt = (rt + 1) % 32; | ||
76 | } | 54 | } |
77 | 55 | ||
78 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_single_struct(DisasContext *s, uint32_t insn) | 56 | /* Net */ |
79 | tcg_gen_add_i64(tcg_rn, tcg_rn, cpu_reg(s, rm)); | 57 | - qdev_set_nic_properties(DEVICE(&s->ftgmac100), &nd_table[0]); |
80 | } | 58 | - object_property_set_bool(OBJECT(&s->ftgmac100), true, "aspeed", &err); |
59 | - object_property_set_bool(OBJECT(&s->ftgmac100), true, "realized", | ||
60 | - &local_err); | ||
61 | - error_propagate(&err, local_err); | ||
62 | - if (err) { | ||
63 | - error_propagate(errp, err); | ||
64 | - return; | ||
65 | + for (i = 0; i < nb_nics; i++) { | ||
66 | + qdev_set_nic_properties(DEVICE(&s->ftgmac100[i]), &nd_table[i]); | ||
67 | + object_property_set_bool(OBJECT(&s->ftgmac100[i]), true, "aspeed", | ||
68 | + &err); | ||
69 | + object_property_set_bool(OBJECT(&s->ftgmac100[i]), true, "realized", | ||
70 | + &local_err); | ||
71 | + error_propagate(&err, local_err); | ||
72 | + if (err) { | ||
73 | + error_propagate(errp, err); | ||
74 | + return; | ||
75 | + } | ||
76 | + sysbus_mmio_map(SYS_BUS_DEVICE(&s->ftgmac100[i]), 0, | ||
77 | + sc->info->memmap[ASPEED_ETH1 + i]); | ||
78 | + sysbus_connect_irq(SYS_BUS_DEVICE(&s->ftgmac100[i]), 0, | ||
79 | + aspeed_soc_get_irq(s, ASPEED_ETH1 + i)); | ||
81 | } | 80 | } |
82 | + tcg_temp_free_i64(tcg_ebytes); | 81 | - sysbus_mmio_map(SYS_BUS_DEVICE(&s->ftgmac100), 0, |
83 | tcg_temp_free_i64(tcg_addr); | 82 | - sc->info->memmap[ASPEED_ETH1]); |
83 | - sysbus_connect_irq(SYS_BUS_DEVICE(&s->ftgmac100), 0, | ||
84 | - aspeed_soc_get_irq(s, ASPEED_ETH1)); | ||
84 | } | 85 | } |
85 | 86 | static Property aspeed_soc_properties[] = { | |
87 | DEFINE_PROP_UINT32("num-cpus", AspeedSoCState, num_cpus, 0), | ||
86 | -- | 88 | -- |
87 | 2.19.1 | 89 | 2.20.1 |
88 | 90 | ||
89 | 91 | diff view generated by jsdifflib |
1 | From: Dongjiu Geng <gengdongjiu@huawei.com> | 1 | From: Joel Stanley <joel@jms.id.au> |
---|---|---|---|
2 | 2 | ||
3 | This patch extends the qemu-kvm state sync logic with support for | 3 | The Linux kernel driver was updated in commit 4451d3f59f2a |
4 | KVM_GET/SET_VCPU_EVENTS, giving access to yet missing SError exception. | 4 | ("clocksource/drivers/fttmr010: Fix set_next_event handler) to fix an |
5 | And also it can support the exception state migration. | 5 | issue observed on hardware: |
6 | 6 | ||
7 | The SError exception states include SError pending state and ESR value, | 7 | > RELOAD register is loaded into COUNT register when the aspeed timer |
8 | the kvm_put/get_vcpu_events() will be called when set or get system | 8 | > is enabled, which means the next event may be delayed because timer |
9 | registers. When do migration, if source machine has SError pending, | 9 | > interrupt won't be generated until <0xFFFFFFFF - current_count + |
10 | QEMU will do this migration regardless whether the target machine supports | 10 | > cycles>. |
11 | to specify guest ESR value, because if target machine does not support that, | ||
12 | it can also inject the SError with zero ESR value. | ||
13 | 11 | ||
14 | Signed-off-by: Dongjiu Geng <gengdongjiu@huawei.com> | 12 | When running under Qemu, the system appeared "laggy". The guest is now |
15 | Reviewed-by: Andrew Jones <drjones@redhat.com> | 13 | scheduling timer events too regularly, starving the host of CPU time. |
16 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 14 | |
17 | Message-id: 1538067351-23931-3-git-send-email-gengdongjiu@huawei.com | 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> | ||
18 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 31 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
19 | --- | 32 | --- |
20 | target/arm/cpu.h | 7 ++++++ | 33 | hw/timer/aspeed_timer.c | 57 ++++++++++++++++++++++------------------- |
21 | target/arm/kvm_arm.h | 24 ++++++++++++++++++ | 34 | 1 file changed, 30 insertions(+), 27 deletions(-) |
22 | target/arm/kvm.c | 60 ++++++++++++++++++++++++++++++++++++++++++++ | ||
23 | target/arm/kvm32.c | 13 ++++++++++ | ||
24 | target/arm/kvm64.c | 13 ++++++++++ | ||
25 | target/arm/machine.c | 22 ++++++++++++++++ | ||
26 | 6 files changed, 139 insertions(+) | ||
27 | 35 | ||
28 | 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 |
29 | index XXXXXXX..XXXXXXX 100644 | 37 | index XXXXXXX..XXXXXXX 100644 |
30 | --- a/target/arm/cpu.h | 38 | --- a/hw/timer/aspeed_timer.c |
31 | +++ b/target/arm/cpu.h | 39 | +++ b/hw/timer/aspeed_timer.c |
32 | @@ -XXX,XX +XXX,XX @@ typedef struct CPUARMState { | 40 | @@ -XXX,XX +XXX,XX @@ static inline uint64_t calculate_time(struct AspeedTimer *t, uint32_t ticks) |
33 | */ | 41 | |
34 | } exception; | 42 | static uint64_t calculate_next(struct AspeedTimer *t) |
35 | 43 | { | |
36 | + /* Information associated with an SError */ | 44 | - uint64_t next = 0; |
37 | + struct { | 45 | - uint32_t rate = calculate_rate(t); |
38 | + uint8_t pending; | 46 | + uint64_t now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); |
39 | + uint8_t has_esr; | 47 | + uint64_t next; |
40 | + uint64_t esr; | 48 | |
41 | + } serror; | 49 | - while (!next) { |
42 | + | 50 | - /* We don't know the relationship between the values in the match |
43 | /* Thumb-2 EE state. */ | 51 | - * registers, so sort using MAX/MIN/zero. We sort in that order as the |
44 | uint32_t teecr; | 52 | - * timer counts down to zero. */ |
45 | uint32_t teehbr; | 53 | - uint64_t seq[] = { |
46 | diff --git a/target/arm/kvm_arm.h b/target/arm/kvm_arm.h | 54 | - calculate_time(t, MAX(t->match[0], t->match[1])), |
47 | index XXXXXXX..XXXXXXX 100644 | 55 | - calculate_time(t, MIN(t->match[0], t->match[1])), |
48 | --- a/target/arm/kvm_arm.h | 56 | - calculate_time(t, 0), |
49 | +++ b/target/arm/kvm_arm.h | 57 | - }; |
50 | @@ -XXX,XX +XXX,XX @@ bool write_kvmstate_to_list(ARMCPU *cpu); | 58 | - uint64_t reload_ns; |
51 | */ | 59 | - uint64_t now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); |
52 | void kvm_arm_reset_vcpu(ARMCPU *cpu); | 60 | + /* |
53 | 61 | + * We don't know the relationship between the values in the match | |
54 | +/** | 62 | + * registers, so sort using MAX/MIN/zero. We sort in that order as |
55 | + * kvm_arm_init_serror_injection: | 63 | + * the timer counts down to zero. |
56 | + * @cs: CPUState | 64 | + */ |
57 | + * | 65 | |
58 | + * Check whether KVM can set guest SError syndrome. | 66 | - if (now < seq[0]) { |
59 | + */ | 67 | - next = seq[0]; |
60 | +void kvm_arm_init_serror_injection(CPUState *cs); | 68 | - } else if (now < seq[1]) { |
61 | + | 69 | - next = seq[1]; |
62 | +/** | 70 | - } else if (now < seq[2]) { |
63 | + * kvm_get_vcpu_events: | 71 | - next = seq[2]; |
64 | + * @cpu: ARMCPU | 72 | - } else if (t->reload) { |
65 | + * | 73 | - reload_ns = muldiv64(t->reload, NANOSECONDS_PER_SECOND, rate); |
66 | + * Get VCPU related state from kvm. | 74 | - t->start = now - ((now - t->start) % reload_ns); |
67 | + */ | 75 | - } else { |
68 | +int kvm_get_vcpu_events(ARMCPU *cpu); | 76 | - /* no reload value, return 0 */ |
69 | + | 77 | - break; |
70 | +/** | 78 | - } |
71 | + * kvm_put_vcpu_events: | 79 | + next = calculate_time(t, MAX(t->match[0], t->match[1])); |
72 | + * @cpu: ARMCPU | 80 | + if (now < next) { |
73 | + * | 81 | + return next; |
74 | + * Put VCPU related state to kvm. | 82 | } |
75 | + */ | 83 | |
76 | +int kvm_put_vcpu_events(ARMCPU *cpu); | 84 | - return next; |
77 | + | 85 | + next = calculate_time(t, MIN(t->match[0], t->match[1])); |
78 | #ifdef CONFIG_KVM | 86 | + if (now < next) { |
79 | /** | 87 | + return next; |
80 | * kvm_arm_create_scratch_host_vcpu: | ||
81 | diff --git a/target/arm/kvm.c b/target/arm/kvm.c | ||
82 | index XXXXXXX..XXXXXXX 100644 | ||
83 | --- a/target/arm/kvm.c | ||
84 | +++ b/target/arm/kvm.c | ||
85 | @@ -XXX,XX +XXX,XX @@ const KVMCapabilityInfo kvm_arch_required_capabilities[] = { | ||
86 | }; | ||
87 | |||
88 | static bool cap_has_mp_state; | ||
89 | +static bool cap_has_inject_serror_esr; | ||
90 | |||
91 | static ARMHostCPUFeatures arm_host_cpu_features; | ||
92 | |||
93 | @@ -XXX,XX +XXX,XX @@ int kvm_arm_vcpu_init(CPUState *cs) | ||
94 | return kvm_vcpu_ioctl(cs, KVM_ARM_VCPU_INIT, &init); | ||
95 | } | ||
96 | |||
97 | +void kvm_arm_init_serror_injection(CPUState *cs) | ||
98 | +{ | ||
99 | + cap_has_inject_serror_esr = kvm_check_extension(cs->kvm_state, | ||
100 | + KVM_CAP_ARM_INJECT_SERROR_ESR); | ||
101 | +} | ||
102 | + | ||
103 | bool kvm_arm_create_scratch_host_vcpu(const uint32_t *cpus_to_try, | ||
104 | int *fdarray, | ||
105 | struct kvm_vcpu_init *init) | ||
106 | @@ -XXX,XX +XXX,XX @@ int kvm_arm_sync_mpstate_to_qemu(ARMCPU *cpu) | ||
107 | return 0; | ||
108 | } | ||
109 | |||
110 | +int kvm_put_vcpu_events(ARMCPU *cpu) | ||
111 | +{ | ||
112 | + CPUARMState *env = &cpu->env; | ||
113 | + struct kvm_vcpu_events events; | ||
114 | + int ret; | ||
115 | + | ||
116 | + if (!kvm_has_vcpu_events()) { | ||
117 | + return 0; | ||
118 | + } | 88 | + } |
119 | + | 89 | + |
120 | + memset(&events, 0, sizeof(events)); | 90 | + next = calculate_time(t, 0); |
121 | + events.exception.serror_pending = env->serror.pending; | 91 | + if (now < next) { |
122 | + | 92 | + return next; |
123 | + /* Inject SError to guest with specified syndrome if host kernel | ||
124 | + * supports it, otherwise inject SError without syndrome. | ||
125 | + */ | ||
126 | + if (cap_has_inject_serror_esr) { | ||
127 | + events.exception.serror_has_esr = env->serror.has_esr; | ||
128 | + events.exception.serror_esr = env->serror.esr; | ||
129 | + } | 93 | + } |
130 | + | 94 | + |
131 | + ret = kvm_vcpu_ioctl(CPU(cpu), KVM_SET_VCPU_EVENTS, &events); | 95 | + /* We've missed all deadlines, fire interrupt and try again */ |
132 | + if (ret) { | 96 | + timer_del(&t->timer); |
133 | + error_report("failed to put vcpu events"); | 97 | + |
98 | + if (timer_overflow_interrupt(t)) { | ||
99 | + t->level = !t->level; | ||
100 | + qemu_set_irq(t->irq, t->level); | ||
134 | + } | 101 | + } |
135 | + | 102 | + |
136 | + return ret; | 103 | + t->start = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); |
137 | +} | 104 | + return calculate_time(t, MAX(MAX(t->match[0], t->match[1]), 0)); |
138 | + | ||
139 | +int kvm_get_vcpu_events(ARMCPU *cpu) | ||
140 | +{ | ||
141 | + CPUARMState *env = &cpu->env; | ||
142 | + struct kvm_vcpu_events events; | ||
143 | + int ret; | ||
144 | + | ||
145 | + if (!kvm_has_vcpu_events()) { | ||
146 | + return 0; | ||
147 | + } | ||
148 | + | ||
149 | + memset(&events, 0, sizeof(events)); | ||
150 | + ret = kvm_vcpu_ioctl(CPU(cpu), KVM_GET_VCPU_EVENTS, &events); | ||
151 | + if (ret) { | ||
152 | + error_report("failed to get vcpu events"); | ||
153 | + return ret; | ||
154 | + } | ||
155 | + | ||
156 | + env->serror.pending = events.exception.serror_pending; | ||
157 | + env->serror.has_esr = events.exception.serror_has_esr; | ||
158 | + env->serror.esr = events.exception.serror_esr; | ||
159 | + | ||
160 | + return 0; | ||
161 | +} | ||
162 | + | ||
163 | void kvm_arch_pre_run(CPUState *cs, struct kvm_run *run) | ||
164 | { | ||
165 | } | 105 | } |
166 | diff --git a/target/arm/kvm32.c b/target/arm/kvm32.c | 106 | |
167 | index XXXXXXX..XXXXXXX 100644 | 107 | static void aspeed_timer_mod(AspeedTimer *t) |
168 | --- a/target/arm/kvm32.c | ||
169 | +++ b/target/arm/kvm32.c | ||
170 | @@ -XXX,XX +XXX,XX @@ int kvm_arch_init_vcpu(CPUState *cs) | ||
171 | } | ||
172 | cpu->mp_affinity = mpidr & ARM32_AFFINITY_MASK; | ||
173 | |||
174 | + /* Check whether userspace can specify guest syndrome value */ | ||
175 | + kvm_arm_init_serror_injection(cs); | ||
176 | + | ||
177 | return kvm_arm_init_cpreg_list(cpu); | ||
178 | } | ||
179 | |||
180 | @@ -XXX,XX +XXX,XX @@ int kvm_arch_put_registers(CPUState *cs, int level) | ||
181 | return ret; | ||
182 | } | ||
183 | |||
184 | + ret = kvm_put_vcpu_events(cpu); | ||
185 | + if (ret) { | ||
186 | + return ret; | ||
187 | + } | ||
188 | + | ||
189 | /* Note that we do not call write_cpustate_to_list() | ||
190 | * here, so we are only writing the tuple list back to | ||
191 | * KVM. This is safe because nothing can change the | ||
192 | @@ -XXX,XX +XXX,XX @@ int kvm_arch_get_registers(CPUState *cs) | ||
193 | } | ||
194 | vfp_set_fpscr(env, fpscr); | ||
195 | |||
196 | + ret = kvm_get_vcpu_events(cpu); | ||
197 | + if (ret) { | ||
198 | + return ret; | ||
199 | + } | ||
200 | + | ||
201 | if (!write_kvmstate_to_list(cpu)) { | ||
202 | return EINVAL; | ||
203 | } | ||
204 | diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c | ||
205 | index XXXXXXX..XXXXXXX 100644 | ||
206 | --- a/target/arm/kvm64.c | ||
207 | +++ b/target/arm/kvm64.c | ||
208 | @@ -XXX,XX +XXX,XX @@ int kvm_arch_init_vcpu(CPUState *cs) | ||
209 | |||
210 | kvm_arm_init_debug(cs); | ||
211 | |||
212 | + /* Check whether user space can specify guest syndrome value */ | ||
213 | + kvm_arm_init_serror_injection(cs); | ||
214 | + | ||
215 | return kvm_arm_init_cpreg_list(cpu); | ||
216 | } | ||
217 | |||
218 | @@ -XXX,XX +XXX,XX @@ int kvm_arch_put_registers(CPUState *cs, int level) | ||
219 | return ret; | ||
220 | } | ||
221 | |||
222 | + ret = kvm_put_vcpu_events(cpu); | ||
223 | + if (ret) { | ||
224 | + return ret; | ||
225 | + } | ||
226 | + | ||
227 | if (!write_list_to_kvmstate(cpu, level)) { | ||
228 | return EINVAL; | ||
229 | } | ||
230 | @@ -XXX,XX +XXX,XX @@ int kvm_arch_get_registers(CPUState *cs) | ||
231 | } | ||
232 | vfp_set_fpcr(env, fpr); | ||
233 | |||
234 | + ret = kvm_get_vcpu_events(cpu); | ||
235 | + if (ret) { | ||
236 | + return ret; | ||
237 | + } | ||
238 | + | ||
239 | if (!write_kvmstate_to_list(cpu)) { | ||
240 | return EINVAL; | ||
241 | } | ||
242 | diff --git a/target/arm/machine.c b/target/arm/machine.c | ||
243 | index XXXXXXX..XXXXXXX 100644 | ||
244 | --- a/target/arm/machine.c | ||
245 | +++ b/target/arm/machine.c | ||
246 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_sve = { | ||
247 | }; | ||
248 | #endif /* AARCH64 */ | ||
249 | |||
250 | +static bool serror_needed(void *opaque) | ||
251 | +{ | ||
252 | + ARMCPU *cpu = opaque; | ||
253 | + CPUARMState *env = &cpu->env; | ||
254 | + | ||
255 | + return env->serror.pending != 0; | ||
256 | +} | ||
257 | + | ||
258 | +static const VMStateDescription vmstate_serror = { | ||
259 | + .name = "cpu/serror", | ||
260 | + .version_id = 1, | ||
261 | + .minimum_version_id = 1, | ||
262 | + .needed = serror_needed, | ||
263 | + .fields = (VMStateField[]) { | ||
264 | + VMSTATE_UINT8(env.serror.pending, ARMCPU), | ||
265 | + VMSTATE_UINT8(env.serror.has_esr, ARMCPU), | ||
266 | + VMSTATE_UINT64(env.serror.esr, ARMCPU), | ||
267 | + VMSTATE_END_OF_LIST() | ||
268 | + } | ||
269 | +}; | ||
270 | + | ||
271 | static bool m_needed(void *opaque) | ||
272 | { | ||
273 | ARMCPU *cpu = opaque; | ||
274 | @@ -XXX,XX +XXX,XX @@ const VMStateDescription vmstate_arm_cpu = { | ||
275 | #ifdef TARGET_AARCH64 | ||
276 | &vmstate_sve, | ||
277 | #endif | ||
278 | + &vmstate_serror, | ||
279 | NULL | ||
280 | } | ||
281 | }; | ||
282 | -- | 108 | -- |
283 | 2.19.1 | 109 | 2.20.1 |
284 | 110 | ||
285 | 111 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Andrew Jeffery <andrew@aj.id.au> |
---|---|---|---|
2 | 2 | ||
3 | Instantiating mps2-an505 (cortex-m33) will fail make check when | 3 | From the datasheet: |
4 | V7VE asserts that ID_ISAR0.Divide includes ARM division. It is | ||
5 | also wrong to include ARM_FEATURE_LPAE. | ||
6 | 4 | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 5 | This register stores the current status of counter #N. When timer |
8 | Message-id: 20181016223115.24100-3-richard.henderson@linaro.org | 6 | enable bit TMC30[N * b] is disabled, the reload register will be |
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 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 | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 16 | --- |
12 | target/arm/cpu.c | 6 +++++- | 17 | hw/timer/aspeed_timer.c | 6 +++++- |
13 | 1 file changed, 5 insertions(+), 1 deletion(-) | 18 | 1 file changed, 5 insertions(+), 1 deletion(-) |
14 | 19 | ||
15 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | 20 | diff --git a/hw/timer/aspeed_timer.c b/hw/timer/aspeed_timer.c |
16 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/cpu.c | 22 | --- a/hw/timer/aspeed_timer.c |
18 | +++ b/target/arm/cpu.c | 23 | +++ b/hw/timer/aspeed_timer.c |
19 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) | 24 | @@ -XXX,XX +XXX,XX @@ static uint64_t aspeed_timer_get_value(AspeedTimer *t, int reg) |
20 | 25 | ||
21 | /* Some features automatically imply others: */ | 26 | switch (reg) { |
22 | if (arm_feature(env, ARM_FEATURE_V8)) { | 27 | case TIMER_REG_STATUS: |
23 | - set_feature(env, ARM_FEATURE_V7VE); | 28 | - value = calculate_ticks(t, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL)); |
24 | + if (arm_feature(env, ARM_FEATURE_M)) { | 29 | + if (timer_enabled(t)) { |
25 | + set_feature(env, ARM_FEATURE_V7); | 30 | + value = calculate_ticks(t, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL)); |
26 | + } else { | 31 | + } else { |
27 | + set_feature(env, ARM_FEATURE_V7VE); | 32 | + value = t->reload; |
28 | + } | 33 | + } |
29 | } | 34 | break; |
30 | if (arm_feature(env, ARM_FEATURE_V7VE)) { | 35 | case TIMER_REG_RELOAD: |
31 | /* v7 Virtualization Extensions. In real hardware this implies | 36 | value = t->reload; |
32 | -- | 37 | -- |
33 | 2.19.1 | 38 | 2.20.1 |
34 | 39 | ||
35 | 40 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Andrew Jeffery <andrew@aj.id.au> |
---|---|---|---|
2 | 2 | ||
3 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 3 | If the match value exceeds reload then we don't want to include it in |
4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 4 | calculations for the next event. |
5 | Message-id: 20181016223115.24100-7-richard.henderson@linaro.org | 5 | |
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 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 | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | --- | 10 | --- |
9 | target/arm/cpu.h | 6 +++++- | 11 | hw/timer/aspeed_timer.c | 13 ++++++++++--- |
10 | linux-user/elfload.c | 2 +- | 12 | 1 file changed, 10 insertions(+), 3 deletions(-) |
11 | target/arm/cpu.c | 4 ---- | ||
12 | target/arm/helper.c | 2 +- | ||
13 | target/arm/machine.c | 3 +-- | ||
14 | 5 files changed, 8 insertions(+), 9 deletions(-) | ||
15 | 13 | ||
16 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 14 | diff --git a/hw/timer/aspeed_timer.c b/hw/timer/aspeed_timer.c |
17 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/target/arm/cpu.h | 16 | --- a/hw/timer/aspeed_timer.c |
19 | +++ b/target/arm/cpu.h | 17 | +++ b/hw/timer/aspeed_timer.c |
20 | @@ -XXX,XX +XXX,XX @@ enum arm_features { | 18 | @@ -XXX,XX +XXX,XX @@ static inline uint64_t calculate_time(struct AspeedTimer *t, uint32_t ticks) |
21 | ARM_FEATURE_NEON, | 19 | return t->start + delta_ns; |
22 | ARM_FEATURE_M, /* Microcontroller profile. */ | ||
23 | ARM_FEATURE_OMAPCP, /* OMAP specific CP15 ops handling. */ | ||
24 | - ARM_FEATURE_THUMB2EE, | ||
25 | ARM_FEATURE_V7MP, /* v7 Multiprocessing Extensions */ | ||
26 | ARM_FEATURE_V7VE, /* v7 Virtualization Extensions (non-EL2 parts) */ | ||
27 | ARM_FEATURE_V4T, | ||
28 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_jazelle(const ARMISARegisters *id) | ||
29 | return FIELD_EX32(id->id_isar1, ID_ISAR1, JAZELLE) != 0; | ||
30 | } | 20 | } |
31 | 21 | ||
32 | +static inline bool isar_feature_t32ee(const ARMISARegisters *id) | 22 | +static inline uint32_t calculate_match(struct AspeedTimer *t, int i) |
33 | +{ | 23 | +{ |
34 | + return FIELD_EX32(id->id_isar3, ID_ISAR3, T32EE) != 0; | 24 | + return t->match[i] < t->reload ? t->match[i] : 0; |
35 | +} | 25 | +} |
36 | + | 26 | + |
37 | static inline bool isar_feature_aa32_aes(const ARMISARegisters *id) | 27 | static uint64_t calculate_next(struct AspeedTimer *t) |
38 | { | 28 | { |
39 | return FIELD_EX32(id->id_isar5, ID_ISAR5, AES) != 0; | 29 | uint64_t now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); |
40 | diff --git a/linux-user/elfload.c b/linux-user/elfload.c | 30 | @@ -XXX,XX +XXX,XX @@ static uint64_t calculate_next(struct AspeedTimer *t) |
41 | index XXXXXXX..XXXXXXX 100644 | 31 | * the timer counts down to zero. |
42 | --- a/linux-user/elfload.c | 32 | */ |
43 | +++ b/linux-user/elfload.c | 33 | |
44 | @@ -XXX,XX +XXX,XX @@ static uint32_t get_elf_hwcap(void) | 34 | - next = calculate_time(t, MAX(t->match[0], t->match[1])); |
45 | GET_FEATURE(ARM_FEATURE_V5, ARM_HWCAP_ARM_EDSP); | 35 | + next = calculate_time(t, MAX(calculate_match(t, 0), calculate_match(t, 1))); |
46 | GET_FEATURE(ARM_FEATURE_VFP, ARM_HWCAP_ARM_VFP); | 36 | if (now < next) { |
47 | GET_FEATURE(ARM_FEATURE_IWMMXT, ARM_HWCAP_ARM_IWMMXT); | 37 | return next; |
48 | - GET_FEATURE(ARM_FEATURE_THUMB2EE, ARM_HWCAP_ARM_THUMBEE); | ||
49 | + GET_FEATURE_ID(t32ee, ARM_HWCAP_ARM_THUMBEE); | ||
50 | GET_FEATURE(ARM_FEATURE_NEON, ARM_HWCAP_ARM_NEON); | ||
51 | GET_FEATURE(ARM_FEATURE_VFP3, ARM_HWCAP_ARM_VFPv3); | ||
52 | GET_FEATURE(ARM_FEATURE_V6K, ARM_HWCAP_ARM_TLS); | ||
53 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | ||
54 | index XXXXXXX..XXXXXXX 100644 | ||
55 | --- a/target/arm/cpu.c | ||
56 | +++ b/target/arm/cpu.c | ||
57 | @@ -XXX,XX +XXX,XX @@ static void cortex_a8_initfn(Object *obj) | ||
58 | set_feature(&cpu->env, ARM_FEATURE_V7); | ||
59 | set_feature(&cpu->env, ARM_FEATURE_VFP3); | ||
60 | set_feature(&cpu->env, ARM_FEATURE_NEON); | ||
61 | - set_feature(&cpu->env, ARM_FEATURE_THUMB2EE); | ||
62 | set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS); | ||
63 | set_feature(&cpu->env, ARM_FEATURE_EL3); | ||
64 | cpu->midr = 0x410fc080; | ||
65 | @@ -XXX,XX +XXX,XX @@ static void cortex_a9_initfn(Object *obj) | ||
66 | set_feature(&cpu->env, ARM_FEATURE_VFP3); | ||
67 | set_feature(&cpu->env, ARM_FEATURE_VFP_FP16); | ||
68 | set_feature(&cpu->env, ARM_FEATURE_NEON); | ||
69 | - set_feature(&cpu->env, ARM_FEATURE_THUMB2EE); | ||
70 | set_feature(&cpu->env, ARM_FEATURE_EL3); | ||
71 | /* Note that A9 supports the MP extensions even for | ||
72 | * A9UP and single-core A9MP (which are both different | ||
73 | @@ -XXX,XX +XXX,XX @@ static void cortex_a7_initfn(Object *obj) | ||
74 | set_feature(&cpu->env, ARM_FEATURE_V7VE); | ||
75 | set_feature(&cpu->env, ARM_FEATURE_VFP4); | ||
76 | set_feature(&cpu->env, ARM_FEATURE_NEON); | ||
77 | - set_feature(&cpu->env, ARM_FEATURE_THUMB2EE); | ||
78 | set_feature(&cpu->env, ARM_FEATURE_GENERIC_TIMER); | ||
79 | set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS); | ||
80 | set_feature(&cpu->env, ARM_FEATURE_CBAR_RO); | ||
81 | @@ -XXX,XX +XXX,XX @@ static void cortex_a15_initfn(Object *obj) | ||
82 | set_feature(&cpu->env, ARM_FEATURE_V7VE); | ||
83 | set_feature(&cpu->env, ARM_FEATURE_VFP4); | ||
84 | set_feature(&cpu->env, ARM_FEATURE_NEON); | ||
85 | - set_feature(&cpu->env, ARM_FEATURE_THUMB2EE); | ||
86 | set_feature(&cpu->env, ARM_FEATURE_GENERIC_TIMER); | ||
87 | set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS); | ||
88 | set_feature(&cpu->env, ARM_FEATURE_CBAR_RO); | ||
89 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
90 | index XXXXXXX..XXXXXXX 100644 | ||
91 | --- a/target/arm/helper.c | ||
92 | +++ b/target/arm/helper.c | ||
93 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
94 | define_arm_cp_regs(cpu, vmsa_pmsa_cp_reginfo); | ||
95 | define_arm_cp_regs(cpu, vmsa_cp_reginfo); | ||
96 | } | 38 | } |
97 | - if (arm_feature(env, ARM_FEATURE_THUMB2EE)) { | 39 | |
98 | + if (cpu_isar_feature(t32ee, cpu)) { | 40 | - next = calculate_time(t, MIN(t->match[0], t->match[1])); |
99 | define_arm_cp_regs(cpu, t2ee_cp_reginfo); | 41 | + next = calculate_time(t, MIN(calculate_match(t, 0), calculate_match(t, 1))); |
42 | if (now < next) { | ||
43 | return next; | ||
100 | } | 44 | } |
101 | if (arm_feature(env, ARM_FEATURE_GENERIC_TIMER)) { | 45 | @@ -XXX,XX +XXX,XX @@ static uint64_t calculate_next(struct AspeedTimer *t) |
102 | diff --git a/target/arm/machine.c b/target/arm/machine.c | 46 | qemu_set_irq(t->irq, t->level); |
103 | index XXXXXXX..XXXXXXX 100644 | 47 | } |
104 | --- a/target/arm/machine.c | 48 | |
105 | +++ b/target/arm/machine.c | 49 | + next = MAX(MAX(calculate_match(t, 0), calculate_match(t, 1)), 0); |
106 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_m = { | 50 | t->start = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); |
107 | static bool thumb2ee_needed(void *opaque) | 51 | - return calculate_time(t, MAX(MAX(t->match[0], t->match[1]), 0)); |
108 | { | 52 | + |
109 | ARMCPU *cpu = opaque; | 53 | + return calculate_time(t, next); |
110 | - CPUARMState *env = &cpu->env; | ||
111 | |||
112 | - return arm_feature(env, ARM_FEATURE_THUMB2EE); | ||
113 | + return cpu_isar_feature(t32ee, cpu); | ||
114 | } | 54 | } |
115 | 55 | ||
116 | static const VMStateDescription vmstate_thumb2ee = { | 56 | static void aspeed_timer_mod(AspeedTimer *t) |
117 | -- | 57 | -- |
118 | 2.19.1 | 58 | 2.20.1 |
119 | 59 | ||
120 | 60 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Christian Svensson <bluecmd@google.com> |
---|---|---|---|
2 | 2 | ||
3 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 3 | If the host decrements the counter register that results in a negative |
4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 4 | delta. This is then passed to muldiv64 which only handles unsigned |
5 | Message-id: 20181016223115.24100-8-richard.henderson@linaro.org | 5 | numbers resulting in bogus results. |
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 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 | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 18 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | --- | 19 | --- |
9 | target/arm/cpu.h | 16 +++++++++++++++- | 20 | hw/timer/aspeed_timer.c | 6 +++++- |
10 | linux-user/aarch64/signal.c | 4 ++-- | 21 | 1 file changed, 5 insertions(+), 1 deletion(-) |
11 | linux-user/elfload.c | 2 +- | ||
12 | linux-user/syscall.c | 10 ++++++---- | ||
13 | target/arm/cpu64.c | 5 ++++- | ||
14 | target/arm/helper.c | 9 ++++++--- | ||
15 | target/arm/machine.c | 3 +-- | ||
16 | target/arm/translate-a64.c | 4 ++-- | ||
17 | 8 files changed, 37 insertions(+), 16 deletions(-) | ||
18 | 22 | ||
19 | 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 |
20 | index XXXXXXX..XXXXXXX 100644 | 24 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/target/arm/cpu.h | 25 | --- a/hw/timer/aspeed_timer.c |
22 | +++ b/target/arm/cpu.h | 26 | +++ b/hw/timer/aspeed_timer.c |
23 | @@ -XXX,XX +XXX,XX @@ FIELD(ID_AA64ISAR1, FRINTTS, 32, 4) | 27 | @@ -XXX,XX +XXX,XX @@ static void aspeed_timer_set_value(AspeedTimerCtrlState *s, int timer, int reg, |
24 | FIELD(ID_AA64ISAR1, SB, 36, 4) | 28 | int64_t delta = (int64_t) value - (int64_t) calculate_ticks(t, now); |
25 | FIELD(ID_AA64ISAR1, SPECRES, 40, 4) | 29 | uint32_t rate = calculate_rate(t); |
26 | 30 | ||
27 | +FIELD(ID_AA64PFR0, EL0, 0, 4) | 31 | - t->start += muldiv64(delta, NANOSECONDS_PER_SECOND, rate); |
28 | +FIELD(ID_AA64PFR0, EL1, 4, 4) | 32 | + if (delta >= 0) { |
29 | +FIELD(ID_AA64PFR0, EL2, 8, 4) | 33 | + t->start += muldiv64(delta, NANOSECONDS_PER_SECOND, rate); |
30 | +FIELD(ID_AA64PFR0, EL3, 12, 4) | 34 | + } else { |
31 | +FIELD(ID_AA64PFR0, FP, 16, 4) | 35 | + t->start -= muldiv64(-delta, NANOSECONDS_PER_SECOND, rate); |
32 | +FIELD(ID_AA64PFR0, ADVSIMD, 20, 4) | 36 | + } |
33 | +FIELD(ID_AA64PFR0, GIC, 24, 4) | 37 | aspeed_timer_mod(t); |
34 | +FIELD(ID_AA64PFR0, RAS, 28, 4) | ||
35 | +FIELD(ID_AA64PFR0, SVE, 32, 4) | ||
36 | + | ||
37 | QEMU_BUILD_BUG_ON(ARRAY_SIZE(((ARMCPU *)0)->ccsidr) <= R_V7M_CSSELR_INDEX_MASK); | ||
38 | |||
39 | /* If adding a feature bit which corresponds to a Linux ELF | ||
40 | @@ -XXX,XX +XXX,XX @@ enum arm_features { | ||
41 | ARM_FEATURE_PMU, /* has PMU support */ | ||
42 | ARM_FEATURE_VBAR, /* has cp15 VBAR */ | ||
43 | ARM_FEATURE_M_SECURITY, /* M profile Security Extension */ | ||
44 | - ARM_FEATURE_SVE, /* has Scalable Vector Extension */ | ||
45 | ARM_FEATURE_V8_FP16, /* implements v8.2 half-precision float */ | ||
46 | ARM_FEATURE_M_MAIN, /* M profile Main Extension */ | ||
47 | }; | ||
48 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa64_fcma(const ARMISARegisters *id) | ||
49 | return FIELD_EX64(id->id_aa64isar1, ID_AA64ISAR1, FCMA) != 0; | ||
50 | } | ||
51 | |||
52 | +static inline bool isar_feature_aa64_sve(const ARMISARegisters *id) | ||
53 | +{ | ||
54 | + return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, SVE) != 0; | ||
55 | +} | ||
56 | + | ||
57 | /* | ||
58 | * Forward to the above feature tests given an ARMCPU pointer. | ||
59 | */ | ||
60 | diff --git a/linux-user/aarch64/signal.c b/linux-user/aarch64/signal.c | ||
61 | index XXXXXXX..XXXXXXX 100644 | ||
62 | --- a/linux-user/aarch64/signal.c | ||
63 | +++ b/linux-user/aarch64/signal.c | ||
64 | @@ -XXX,XX +XXX,XX @@ static int target_restore_sigframe(CPUARMState *env, | ||
65 | break; | ||
66 | |||
67 | case TARGET_SVE_MAGIC: | ||
68 | - if (arm_feature(env, ARM_FEATURE_SVE)) { | ||
69 | + if (cpu_isar_feature(aa64_sve, arm_env_get_cpu(env))) { | ||
70 | vq = (env->vfp.zcr_el[1] & 0xf) + 1; | ||
71 | sve_size = QEMU_ALIGN_UP(TARGET_SVE_SIG_CONTEXT_SIZE(vq), 16); | ||
72 | if (!sve && size == sve_size) { | ||
73 | @@ -XXX,XX +XXX,XX @@ static void target_setup_frame(int usig, struct target_sigaction *ka, | ||
74 | &layout); | ||
75 | |||
76 | /* SVE state needs saving only if it exists. */ | ||
77 | - if (arm_feature(env, ARM_FEATURE_SVE)) { | ||
78 | + if (cpu_isar_feature(aa64_sve, arm_env_get_cpu(env))) { | ||
79 | vq = (env->vfp.zcr_el[1] & 0xf) + 1; | ||
80 | sve_size = QEMU_ALIGN_UP(TARGET_SVE_SIG_CONTEXT_SIZE(vq), 16); | ||
81 | sve_ofs = alloc_sigframe_space(sve_size, &layout); | ||
82 | diff --git a/linux-user/elfload.c b/linux-user/elfload.c | ||
83 | index XXXXXXX..XXXXXXX 100644 | ||
84 | --- a/linux-user/elfload.c | ||
85 | +++ b/linux-user/elfload.c | ||
86 | @@ -XXX,XX +XXX,XX @@ static uint32_t get_elf_hwcap(void) | ||
87 | GET_FEATURE_ID(aa64_rdm, ARM_HWCAP_A64_ASIMDRDM); | ||
88 | GET_FEATURE_ID(aa64_dp, ARM_HWCAP_A64_ASIMDDP); | ||
89 | GET_FEATURE_ID(aa64_fcma, ARM_HWCAP_A64_FCMA); | ||
90 | - GET_FEATURE(ARM_FEATURE_SVE, ARM_HWCAP_A64_SVE); | ||
91 | + GET_FEATURE_ID(aa64_sve, ARM_HWCAP_A64_SVE); | ||
92 | |||
93 | #undef GET_FEATURE | ||
94 | #undef GET_FEATURE_ID | ||
95 | diff --git a/linux-user/syscall.c b/linux-user/syscall.c | ||
96 | index XXXXXXX..XXXXXXX 100644 | ||
97 | --- a/linux-user/syscall.c | ||
98 | +++ b/linux-user/syscall.c | ||
99 | @@ -XXX,XX +XXX,XX @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, | ||
100 | * even though the current architectural maximum is VQ=16. | ||
101 | */ | ||
102 | ret = -TARGET_EINVAL; | ||
103 | - if (arm_feature(cpu_env, ARM_FEATURE_SVE) | ||
104 | + if (cpu_isar_feature(aa64_sve, arm_env_get_cpu(cpu_env)) | ||
105 | && arg2 >= 0 && arg2 <= 512 * 16 && !(arg2 & 15)) { | ||
106 | CPUARMState *env = cpu_env; | ||
107 | ARMCPU *cpu = arm_env_get_cpu(env); | ||
108 | @@ -XXX,XX +XXX,XX @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, | ||
109 | return ret; | ||
110 | case TARGET_PR_SVE_GET_VL: | ||
111 | ret = -TARGET_EINVAL; | ||
112 | - if (arm_feature(cpu_env, ARM_FEATURE_SVE)) { | ||
113 | - CPUARMState *env = cpu_env; | ||
114 | - ret = ((env->vfp.zcr_el[1] & 0xf) + 1) * 16; | ||
115 | + { | ||
116 | + ARMCPU *cpu = arm_env_get_cpu(cpu_env); | ||
117 | + if (cpu_isar_feature(aa64_sve, cpu)) { | ||
118 | + ret = ((cpu->env.vfp.zcr_el[1] & 0xf) + 1) * 16; | ||
119 | + } | ||
120 | } | ||
121 | return ret; | ||
122 | #endif /* AARCH64 */ | ||
123 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | ||
124 | index XXXXXXX..XXXXXXX 100644 | ||
125 | --- a/target/arm/cpu64.c | ||
126 | +++ b/target/arm/cpu64.c | ||
127 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) | ||
128 | t = FIELD_DP64(t, ID_AA64ISAR1, FCMA, 1); | ||
129 | cpu->isar.id_aa64isar1 = t; | ||
130 | |||
131 | + t = cpu->isar.id_aa64pfr0; | ||
132 | + t = FIELD_DP64(t, ID_AA64PFR0, SVE, 1); | ||
133 | + cpu->isar.id_aa64pfr0 = t; | ||
134 | + | ||
135 | /* Replicate the same data to the 32-bit id registers. */ | ||
136 | u = cpu->isar.id_isar5; | ||
137 | u = FIELD_DP32(u, ID_ISAR5, AES, 2); /* AES + PMULL */ | ||
138 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) | ||
139 | * present in either. | ||
140 | */ | ||
141 | set_feature(&cpu->env, ARM_FEATURE_V8_FP16); | ||
142 | - set_feature(&cpu->env, ARM_FEATURE_SVE); | ||
143 | /* For usermode -cpu max we can use a larger and more efficient DCZ | ||
144 | * blocksize since we don't have to follow what the hardware does. | ||
145 | */ | ||
146 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
147 | index XXXXXXX..XXXXXXX 100644 | ||
148 | --- a/target/arm/helper.c | ||
149 | +++ b/target/arm/helper.c | ||
150 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
151 | define_one_arm_cp_reg(cpu, &sctlr); | ||
152 | } | ||
153 | |||
154 | - if (arm_feature(env, ARM_FEATURE_SVE)) { | ||
155 | + if (cpu_isar_feature(aa64_sve, cpu)) { | ||
156 | define_one_arm_cp_reg(cpu, &zcr_el1_reginfo); | ||
157 | if (arm_feature(env, ARM_FEATURE_EL2)) { | ||
158 | define_one_arm_cp_reg(cpu, &zcr_el2_reginfo); | ||
159 | @@ -XXX,XX +XXX,XX @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, | ||
160 | uint32_t flags; | ||
161 | |||
162 | if (is_a64(env)) { | ||
163 | + ARMCPU *cpu = arm_env_get_cpu(env); | ||
164 | + | ||
165 | *pc = env->pc; | ||
166 | flags = ARM_TBFLAG_AARCH64_STATE_MASK; | ||
167 | /* Get control bits for tagged addresses */ | ||
168 | flags |= (arm_regime_tbi0(env, mmu_idx) << ARM_TBFLAG_TBI0_SHIFT); | ||
169 | flags |= (arm_regime_tbi1(env, mmu_idx) << ARM_TBFLAG_TBI1_SHIFT); | ||
170 | |||
171 | - if (arm_feature(env, ARM_FEATURE_SVE)) { | ||
172 | + if (cpu_isar_feature(aa64_sve, cpu)) { | ||
173 | int sve_el = sve_exception_el(env, current_el); | ||
174 | uint32_t zcr_len; | ||
175 | |||
176 | @@ -XXX,XX +XXX,XX @@ void aarch64_sve_narrow_vq(CPUARMState *env, unsigned vq) | ||
177 | void aarch64_sve_change_el(CPUARMState *env, int old_el, | ||
178 | int new_el, bool el0_a64) | ||
179 | { | ||
180 | + ARMCPU *cpu = arm_env_get_cpu(env); | ||
181 | int old_len, new_len; | ||
182 | bool old_a64, new_a64; | ||
183 | |||
184 | /* Nothing to do if no SVE. */ | ||
185 | - if (!arm_feature(env, ARM_FEATURE_SVE)) { | ||
186 | + if (!cpu_isar_feature(aa64_sve, cpu)) { | ||
187 | return; | ||
188 | } | ||
189 | |||
190 | diff --git a/target/arm/machine.c b/target/arm/machine.c | ||
191 | index XXXXXXX..XXXXXXX 100644 | ||
192 | --- a/target/arm/machine.c | ||
193 | +++ b/target/arm/machine.c | ||
194 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_iwmmxt = { | ||
195 | static bool sve_needed(void *opaque) | ||
196 | { | ||
197 | ARMCPU *cpu = opaque; | ||
198 | - CPUARMState *env = &cpu->env; | ||
199 | |||
200 | - return arm_feature(env, ARM_FEATURE_SVE); | ||
201 | + return cpu_isar_feature(aa64_sve, cpu); | ||
202 | } | ||
203 | |||
204 | /* The first two words of each Zreg is stored in VFP state. */ | ||
205 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
206 | index XXXXXXX..XXXXXXX 100644 | ||
207 | --- a/target/arm/translate-a64.c | ||
208 | +++ b/target/arm/translate-a64.c | ||
209 | @@ -XXX,XX +XXX,XX @@ void aarch64_cpu_dump_state(CPUState *cs, FILE *f, | ||
210 | cpu_fprintf(f, " FPCR=%08x FPSR=%08x\n", | ||
211 | vfp_get_fpcr(env), vfp_get_fpsr(env)); | ||
212 | |||
213 | - if (arm_feature(env, ARM_FEATURE_SVE) && sve_exception_el(env, el) == 0) { | ||
214 | + if (cpu_isar_feature(aa64_sve, cpu) && sve_exception_el(env, el) == 0) { | ||
215 | int j, zcr_len = sve_zcr_len_for_el(env, el); | ||
216 | |||
217 | for (i = 0; i <= FFR_PRED_NUM; i++) { | ||
218 | @@ -XXX,XX +XXX,XX @@ static void disas_a64_insn(CPUARMState *env, DisasContext *s) | ||
219 | unallocated_encoding(s); | ||
220 | break; | ||
221 | case 0x2: | ||
222 | - if (!arm_dc_feature(s, ARM_FEATURE_SVE) || !disas_sve(s, insn)) { | ||
223 | + if (!dc_isar_feature(aa64_sve, s) || !disas_sve(s, insn)) { | ||
224 | unallocated_encoding(s); | ||
225 | } | 38 | } |
226 | break; | 39 | break; |
227 | -- | 40 | -- |
228 | 2.19.1 | 41 | 2.20.1 |
229 | 42 | ||
230 | 43 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Cédric Le Goater <clg@kaod.org> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 3 | It has never been used as far as I can tell from the git history. |
4 | Message-id: 20181011205206.3552-12-richard.henderson@linaro.org | 4 | |
5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 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 | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | --- | 9 | --- |
8 | target/arm/translate.c | 31 +++++++++++++++---------------- | 10 | hw/arm/aspeed.c | 2 -- |
9 | 1 file changed, 15 insertions(+), 16 deletions(-) | 11 | 1 file changed, 2 deletions(-) |
10 | 12 | ||
11 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 13 | diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c |
12 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/target/arm/translate.c | 15 | --- a/hw/arm/aspeed.c |
14 | +++ b/target/arm/translate.c | 16 | +++ b/hw/arm/aspeed.c |
15 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | 17 | @@ -XXX,XX +XXX,XX @@ static void aspeed_board_init(MachineState *machine, |
16 | vec_size, vec_size); | 18 | memory_region_allocate_system_memory(&bmc->ram, NULL, "ram", ram_size); |
17 | } | 19 | memory_region_add_subregion(get_system_memory(), |
18 | return 0; | 20 | sc->info->memmap[ASPEED_SDRAM], &bmc->ram); |
19 | + | 21 | - object_property_add_const_link(OBJECT(&bmc->soc), "ram", OBJECT(&bmc->ram), |
20 | + case NEON_3R_VMUL: /* VMUL */ | 22 | - &error_abort); |
21 | + if (u) { | 23 | |
22 | + /* Polynomial case allows only P8 and is handled below. */ | 24 | max_ram_size = object_property_get_uint(OBJECT(&bmc->soc), "max-ram-size", |
23 | + if (size != 0) { | 25 | &error_abort); |
24 | + return 1; | ||
25 | + } | ||
26 | + } else { | ||
27 | + tcg_gen_gvec_mul(size, rd_ofs, rn_ofs, rm_ofs, | ||
28 | + vec_size, vec_size); | ||
29 | + return 0; | ||
30 | + } | ||
31 | + break; | ||
32 | } | ||
33 | if (size == 3) { | ||
34 | /* 64-bit element instructions. */ | ||
35 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
36 | return 1; | ||
37 | } | ||
38 | break; | ||
39 | - case NEON_3R_VMUL: | ||
40 | - if (u && (size != 0)) { | ||
41 | - /* UNDEF on invalid size for polynomial subcase */ | ||
42 | - return 1; | ||
43 | - } | ||
44 | - break; | ||
45 | case NEON_3R_VFM_VQRDMLSH: | ||
46 | if (!arm_dc_feature(s, ARM_FEATURE_VFP4)) { | ||
47 | return 1; | ||
48 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
49 | } | ||
50 | break; | ||
51 | case NEON_3R_VMUL: | ||
52 | - if (u) { /* polynomial */ | ||
53 | - gen_helper_neon_mul_p8(tmp, tmp, tmp2); | ||
54 | - } else { /* Integer */ | ||
55 | - switch (size) { | ||
56 | - case 0: gen_helper_neon_mul_u8(tmp, tmp, tmp2); break; | ||
57 | - case 1: gen_helper_neon_mul_u16(tmp, tmp, tmp2); break; | ||
58 | - case 2: tcg_gen_mul_i32(tmp, tmp, tmp2); break; | ||
59 | - default: abort(); | ||
60 | - } | ||
61 | - } | ||
62 | + /* VMUL.P8; other cases already eliminated. */ | ||
63 | + gen_helper_neon_mul_p8(tmp, tmp, tmp2); | ||
64 | break; | ||
65 | case NEON_3R_VPMAX: | ||
66 | GEN_NEON_INTEGER_OP(pmax); | ||
67 | -- | 26 | -- |
68 | 2.19.1 | 27 | 2.20.1 |
69 | 28 | ||
70 | 29 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Cédric Le Goater <clg@kaod.org> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 3 | The RAM memory region is defined after the SoC is realized when the |
4 | Message-id: 20181011205206.3552-11-richard.henderson@linaro.org | 4 | SDMC controller has checked that the defined RAM size for the machine |
5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 5 | is correct. This is problematic for controller models requiring a link |
6 | on the RAM region, for DMA support in the SMC controller for instance. | ||
7 | |||
8 | Introduce a container memory region for the RAM that we can link into | ||
9 | the controllers early, before the SoC is realized. It will be | ||
10 | populated with the RAM region after the checks have be done. | ||
11 | |||
12 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
13 | Reviewed-by: Joel Stanley <joel@jms.id.au> | ||
14 | Message-id: 20190618165311.27066-14-clg@kaod.org | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | --- | 16 | --- |
8 | target/arm/translate.c | 16 ++++++++-------- | 17 | hw/arm/aspeed.c | 13 +++++++++---- |
9 | 1 file changed, 8 insertions(+), 8 deletions(-) | 18 | 1 file changed, 9 insertions(+), 4 deletions(-) |
10 | 19 | ||
11 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 20 | diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c |
12 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/target/arm/translate.c | 22 | --- a/hw/arm/aspeed.c |
14 | +++ b/target/arm/translate.c | 23 | +++ b/hw/arm/aspeed.c |
15 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | 24 | @@ -XXX,XX +XXX,XX @@ static struct arm_boot_info aspeed_board_binfo = { |
16 | tcg_temp_free_ptr(ptr1); | 25 | |
17 | tcg_temp_free_ptr(ptr2); | 26 | struct AspeedBoardState { |
18 | break; | 27 | AspeedSoCState soc; |
28 | + MemoryRegion ram_container; | ||
29 | MemoryRegion ram; | ||
30 | MemoryRegion max_ram; | ||
31 | }; | ||
32 | @@ -XXX,XX +XXX,XX @@ static void aspeed_board_init(MachineState *machine, | ||
33 | ram_addr_t max_ram_size; | ||
34 | |||
35 | bmc = g_new0(AspeedBoardState, 1); | ||
19 | + | 36 | + |
20 | + case NEON_2RM_VMVN: | 37 | + memory_region_init(&bmc->ram_container, NULL, "aspeed-ram-container", |
21 | + tcg_gen_gvec_not(0, rd_ofs, rm_ofs, vec_size, vec_size); | 38 | + UINT32_MAX); |
22 | + break; | ||
23 | + case NEON_2RM_VNEG: | ||
24 | + tcg_gen_gvec_neg(size, rd_ofs, rm_ofs, vec_size, vec_size); | ||
25 | + break; | ||
26 | + | 39 | + |
27 | default: | 40 | object_initialize_child(OBJECT(machine), "soc", &bmc->soc, |
28 | elementwise: | 41 | (sizeof(bmc->soc)), cfg->soc_name, &error_abort, |
29 | for (pass = 0; pass < (q ? 4 : 2); pass++) { | 42 | NULL); |
30 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | 43 | @@ -XXX,XX +XXX,XX @@ static void aspeed_board_init(MachineState *machine, |
31 | case NEON_2RM_VCNT: | 44 | &error_abort); |
32 | gen_helper_neon_cnt_u8(tmp, tmp); | 45 | |
33 | break; | 46 | memory_region_allocate_system_memory(&bmc->ram, NULL, "ram", ram_size); |
34 | - case NEON_2RM_VMVN: | 47 | + memory_region_add_subregion(&bmc->ram_container, 0, &bmc->ram); |
35 | - tcg_gen_not_i32(tmp, tmp); | 48 | memory_region_add_subregion(get_system_memory(), |
36 | - break; | 49 | - sc->info->memmap[ASPEED_SDRAM], &bmc->ram); |
37 | case NEON_2RM_VQABS: | 50 | + sc->info->memmap[ASPEED_SDRAM], |
38 | switch (size) { | 51 | + &bmc->ram_container); |
39 | case 0: | 52 | |
40 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | 53 | max_ram_size = object_property_get_uint(OBJECT(&bmc->soc), "max-ram-size", |
41 | default: abort(); | 54 | &error_abort); |
42 | } | 55 | memory_region_init_io(&bmc->max_ram, NULL, &max_ram_ops, NULL, |
43 | break; | 56 | "max_ram", max_ram_size - ram_size); |
44 | - case NEON_2RM_VNEG: | 57 | - memory_region_add_subregion(get_system_memory(), |
45 | - tmp2 = tcg_const_i32(0); | 58 | - sc->info->memmap[ASPEED_SDRAM] + ram_size, |
46 | - gen_neon_rsb(size, tmp, tmp2); | 59 | - &bmc->max_ram); |
47 | - tcg_temp_free_i32(tmp2); | 60 | + memory_region_add_subregion(&bmc->ram_container, ram_size, &bmc->max_ram); |
48 | - break; | 61 | |
49 | case NEON_2RM_VCGT0_F: | 62 | aspeed_board_init_flashes(&bmc->soc.fmc, cfg->fmc_model, &error_abort); |
50 | { | 63 | aspeed_board_init_flashes(&bmc->soc.spi[0], cfg->spi_model, &error_abort); |
51 | TCGv_ptr fpstatus = get_fpstatus_ptr(1); | ||
52 | -- | 64 | -- |
53 | 2.19.1 | 65 | 2.20.1 |
54 | 66 | ||
55 | 67 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Cédric Le Goater <clg@kaod.org> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 3 | The DRAM address of a DMA transaction depends on the DRAM base address |
4 | Message-id: 20181011205206.3552-13-richard.henderson@linaro.org | 4 | of the SoC. Inform the SMC controller model with this value. |
5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 5 | |
6 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
7 | Reviewed-by: Joel Stanley <joel@jms.id.au> | ||
8 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
9 | Message-id: 20190618165311.27066-15-clg@kaod.org | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | --- | 11 | --- |
8 | target/arm/translate.c | 70 +++++++++++++++++++++++++++++------------- | 12 | include/hw/ssi/aspeed_smc.h | 3 +++ |
9 | 1 file changed, 48 insertions(+), 22 deletions(-) | 13 | hw/arm/aspeed_soc.c | 6 ++++++ |
14 | hw/ssi/aspeed_smc.c | 1 + | ||
15 | 3 files changed, 10 insertions(+) | ||
10 | 16 | ||
11 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 17 | diff --git a/include/hw/ssi/aspeed_smc.h b/include/hw/ssi/aspeed_smc.h |
12 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/target/arm/translate.c | 19 | --- a/include/hw/ssi/aspeed_smc.h |
14 | +++ b/target/arm/translate.c | 20 | +++ b/include/hw/ssi/aspeed_smc.h |
15 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | 21 | @@ -XXX,XX +XXX,XX @@ typedef struct AspeedSMCState { |
16 | size--; | 22 | uint8_t r_timings; |
17 | } | 23 | uint8_t conf_enable_w0; |
18 | shift = (insn >> 16) & ((1 << (3 + size)) - 1); | 24 | |
19 | - /* To avoid excessive duplication of ops we implement shift | 25 | + /* for DMA support */ |
20 | - by immediate using the variable shift operations. */ | 26 | + uint64_t sdram_base; |
21 | if (op < 8) { | ||
22 | /* Shift by immediate: | ||
23 | VSHR, VSRA, VRSHR, VRSRA, VSRI, VSHL, VQSHL, VQSHLU. */ | ||
24 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
25 | } | ||
26 | /* Right shifts are encoded as N - shift, where N is the | ||
27 | element size in bits. */ | ||
28 | - if (op <= 4) | ||
29 | + if (op <= 4) { | ||
30 | shift = shift - (1 << (size + 3)); | ||
31 | + } | ||
32 | + | 27 | + |
33 | + switch (op) { | 28 | AspeedSMCFlash *flashes; |
34 | + case 0: /* VSHR */ | 29 | |
35 | + /* Right shift comes here negative. */ | 30 | uint8_t snoop_index; |
36 | + shift = -shift; | 31 | diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c |
37 | + /* Shifts larger than the element size are architecturally | 32 | index XXXXXXX..XXXXXXX 100644 |
38 | + * valid. Unsigned results in all zeros; signed results | 33 | --- a/hw/arm/aspeed_soc.c |
39 | + * in all sign bits. | 34 | +++ b/hw/arm/aspeed_soc.c |
40 | + */ | 35 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) |
41 | + if (!u) { | 36 | aspeed_soc_get_irq(s, ASPEED_I2C)); |
42 | + tcg_gen_gvec_sari(size, rd_ofs, rm_ofs, | 37 | |
43 | + MIN(shift, (8 << size) - 1), | 38 | /* FMC, The number of CS is set at the board level */ |
44 | + vec_size, vec_size); | 39 | + object_property_set_int(OBJECT(&s->fmc), sc->info->memmap[ASPEED_SDRAM], |
45 | + } else if (shift >= 8 << size) { | 40 | + "sdram-base", &err); |
46 | + tcg_gen_gvec_dup8i(rd_ofs, vec_size, vec_size, 0); | 41 | + if (err) { |
47 | + } else { | 42 | + error_propagate(errp, err); |
48 | + tcg_gen_gvec_shri(size, rd_ofs, rm_ofs, shift, | 43 | + return; |
49 | + vec_size, vec_size); | 44 | + } |
50 | + } | 45 | object_property_set_bool(OBJECT(&s->fmc), true, "realized", &err); |
51 | + return 0; | 46 | if (err) { |
52 | + | 47 | error_propagate(errp, err); |
53 | + case 5: /* VSHL, VSLI */ | 48 | diff --git a/hw/ssi/aspeed_smc.c b/hw/ssi/aspeed_smc.c |
54 | + if (!u) { /* VSHL */ | 49 | index XXXXXXX..XXXXXXX 100644 |
55 | + /* Shifts larger than the element size are | 50 | --- a/hw/ssi/aspeed_smc.c |
56 | + * architecturally valid and results in zero. | 51 | +++ b/hw/ssi/aspeed_smc.c |
57 | + */ | 52 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_aspeed_smc = { |
58 | + if (shift >= 8 << size) { | 53 | |
59 | + tcg_gen_gvec_dup8i(rd_ofs, vec_size, vec_size, 0); | 54 | static Property aspeed_smc_properties[] = { |
60 | + } else { | 55 | DEFINE_PROP_UINT32("num-cs", AspeedSMCState, num_cs, 1), |
61 | + tcg_gen_gvec_shli(size, rd_ofs, rm_ofs, shift, | 56 | + DEFINE_PROP_UINT64("sdram-base", AspeedSMCState, sdram_base, 0), |
62 | + vec_size, vec_size); | 57 | DEFINE_PROP_END_OF_LIST(), |
63 | + } | 58 | }; |
64 | + return 0; | ||
65 | + } | ||
66 | + break; | ||
67 | + } | ||
68 | + | ||
69 | if (size == 3) { | ||
70 | count = q + 1; | ||
71 | } else { | ||
72 | count = q ? 4: 2; | ||
73 | } | ||
74 | - switch (size) { | ||
75 | - case 0: | ||
76 | - imm = (uint8_t) shift; | ||
77 | - imm |= imm << 8; | ||
78 | - imm |= imm << 16; | ||
79 | - break; | ||
80 | - case 1: | ||
81 | - imm = (uint16_t) shift; | ||
82 | - imm |= imm << 16; | ||
83 | - break; | ||
84 | - case 2: | ||
85 | - case 3: | ||
86 | - imm = shift; | ||
87 | - break; | ||
88 | - default: | ||
89 | - abort(); | ||
90 | - } | ||
91 | + | ||
92 | + /* To avoid excessive duplication of ops we implement shift | ||
93 | + * by immediate using the variable shift operations. | ||
94 | + */ | ||
95 | + imm = dup_const(size, shift); | ||
96 | |||
97 | for (pass = 0; pass < count; pass++) { | ||
98 | if (size == 3) { | ||
99 | neon_load_reg64(cpu_V0, rm + pass); | ||
100 | tcg_gen_movi_i64(cpu_V1, imm); | ||
101 | switch (op) { | ||
102 | - case 0: /* VSHR */ | ||
103 | case 1: /* VSRA */ | ||
104 | if (u) | ||
105 | gen_helper_neon_shl_u64(cpu_V0, cpu_V0, cpu_V1); | ||
106 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
107 | cpu_V0, cpu_V1); | ||
108 | } | ||
109 | break; | ||
110 | + default: | ||
111 | + g_assert_not_reached(); | ||
112 | } | ||
113 | if (op == 1 || op == 3) { | ||
114 | /* Accumulate. */ | ||
115 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
116 | tmp2 = tcg_temp_new_i32(); | ||
117 | tcg_gen_movi_i32(tmp2, imm); | ||
118 | switch (op) { | ||
119 | - case 0: /* VSHR */ | ||
120 | case 1: /* VSRA */ | ||
121 | GEN_NEON_INTEGER_OP(shl); | ||
122 | break; | ||
123 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
124 | case 7: /* VQSHL */ | ||
125 | GEN_NEON_INTEGER_OP_ENV(qshl); | ||
126 | break; | ||
127 | + default: | ||
128 | + g_assert_not_reached(); | ||
129 | } | ||
130 | tcg_temp_free_i32(tmp2); | ||
131 | 59 | ||
132 | -- | 60 | -- |
133 | 2.19.1 | 61 | 2.20.1 |
134 | 62 | ||
135 | 63 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Adriana Kobylak <anoo@us.ibm.com> |
---|---|---|---|
2 | 2 | ||
3 | Having V6 alone imply jazelle was wrong for cortex-m0. | 3 | The Swift board is an OpenPOWER system hosting POWER processors. |
4 | Change to an assertion for V6 & !M. | 4 | Add support for their BMC including the I2C devices as found on HW. |
5 | 5 | ||
6 | This was harmless, because the only place we tested ARM_FEATURE_JAZELLE | 6 | Signed-off-by: Adriana Kobylak <anoo@us.ibm.com> |
7 | was for 'bxj' in disas_arm(), which is unreachable for M-profile cores. | 7 | Reviewed-by: Cédric Le Goater <clg@kaod.org> |
8 | 8 | Reviewed-by: Joel Stanley <joel@jms.id.au> | |
9 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 9 | Message-id: 20190618165311.27066-20-clg@kaod.org |
10 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
11 | Message-id: 20181016223115.24100-6-richard.henderson@linaro.org | ||
12 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | --- | 11 | --- |
15 | target/arm/cpu.h | 6 +++++- | 12 | hw/arm/aspeed.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++++ |
16 | target/arm/cpu.c | 17 ++++++++++++++--- | 13 | 1 file changed, 50 insertions(+) |
17 | target/arm/translate.c | 2 +- | ||
18 | 3 files changed, 20 insertions(+), 5 deletions(-) | ||
19 | 14 | ||
20 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 15 | diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c |
21 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/target/arm/cpu.h | 17 | --- a/hw/arm/aspeed.c |
23 | +++ b/target/arm/cpu.h | 18 | +++ b/hw/arm/aspeed.c |
24 | @@ -XXX,XX +XXX,XX @@ enum arm_features { | 19 | @@ -XXX,XX +XXX,XX @@ struct AspeedBoardState { |
25 | ARM_FEATURE_PMU, /* has PMU support */ | 20 | SCU_AST2500_HW_STRAP_ACPI_ENABLE | \ |
26 | ARM_FEATURE_VBAR, /* has cp15 VBAR */ | 21 | SCU_HW_STRAP_SPI_MODE(SCU_HW_STRAP_SPI_MASTER)) |
27 | ARM_FEATURE_M_SECURITY, /* M profile Security Extension */ | 22 | |
28 | - ARM_FEATURE_JAZELLE, /* has (trivial) Jazelle implementation */ | 23 | +/* Swift hardware value: 0xF11AD206 */ |
29 | ARM_FEATURE_SVE, /* has Scalable Vector Extension */ | 24 | +#define SWIFT_BMC_HW_STRAP1 ( \ |
30 | ARM_FEATURE_V8_FP16, /* implements v8.2 half-precision float */ | 25 | + AST2500_HW_STRAP1_DEFAULTS | \ |
31 | ARM_FEATURE_M_MAIN, /* M profile Main Extension */ | 26 | + SCU_AST2500_HW_STRAP_SPI_AUTOFETCH_ENABLE | \ |
32 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_arm_div(const ARMISARegisters *id) | 27 | + SCU_AST2500_HW_STRAP_GPIO_STRAP_ENABLE | \ |
33 | return FIELD_EX32(id->id_isar0, ID_ISAR0, DIVIDE) > 1; | 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); | ||
34 | } | 39 | } |
35 | 40 | ||
36 | +static inline bool isar_feature_jazelle(const ARMISARegisters *id) | 41 | +static void swift_bmc_i2c_init(AspeedBoardState *bmc) |
37 | +{ | 42 | +{ |
38 | + return FIELD_EX32(id->id_isar1, ID_ISAR1, JAZELLE) != 0; | 43 | + AspeedSoCState *soc = &bmc->soc; |
44 | + | ||
45 | + i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 3), "pca9552", 0x60); | ||
46 | + | ||
47 | + /* The swift board expects a TMP275 but a TMP105 is compatible */ | ||
48 | + i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 7), "tmp105", 0x48); | ||
49 | + /* The swift board expects a pca9551 but a pca9552 is compatible */ | ||
50 | + i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 7), "pca9552", 0x60); | ||
51 | + | ||
52 | + /* The swift board expects an Epson RX8900 RTC but a ds1338 is compatible */ | ||
53 | + i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 8), "ds1338", 0x32); | ||
54 | + i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 8), "pca9552", 0x60); | ||
55 | + | ||
56 | + i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 9), "tmp423", 0x4c); | ||
57 | + /* The swift board expects a pca9539 but a pca9552 is compatible */ | ||
58 | + i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 9), "pca9552", 0x74); | ||
59 | + | ||
60 | + i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 10), "tmp423", 0x4c); | ||
61 | + /* The swift board expects a pca9539 but a pca9552 is compatible */ | ||
62 | + i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 10), "pca9552", | ||
63 | + 0x74); | ||
64 | + | ||
65 | + /* The swift board expects a TMP275 but a TMP105 is compatible */ | ||
66 | + i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 12), "tmp105", 0x48); | ||
67 | + i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 12), "tmp105", 0x4a); | ||
39 | +} | 68 | +} |
40 | + | 69 | + |
41 | static inline bool isar_feature_aa32_aes(const ARMISARegisters *id) | 70 | static void witherspoon_bmc_i2c_init(AspeedBoardState *bmc) |
42 | { | 71 | { |
43 | return FIELD_EX32(id->id_isar5, ID_ISAR5, AES) != 0; | 72 | AspeedSoCState *soc = &bmc->soc; |
44 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | 73 | @@ -XXX,XX +XXX,XX @@ static const AspeedBoardConfig aspeed_boards[] = { |
45 | index XXXXXXX..XXXXXXX 100644 | 74 | .num_cs = 2, |
46 | --- a/target/arm/cpu.c | 75 | .i2c_init = romulus_bmc_i2c_init, |
47 | +++ b/target/arm/cpu.c | 76 | .ram = 512 * MiB, |
48 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) | 77 | + }, { |
49 | } | 78 | + .name = MACHINE_TYPE_NAME("swift-bmc"), |
50 | if (arm_feature(env, ARM_FEATURE_V6)) { | 79 | + .desc = "OpenPOWER Swift BMC (ARM1176)", |
51 | set_feature(env, ARM_FEATURE_V5); | 80 | + .soc_name = "ast2500-a1", |
52 | - set_feature(env, ARM_FEATURE_JAZELLE); | 81 | + .hw_strap1 = SWIFT_BMC_HW_STRAP1, |
53 | if (!arm_feature(env, ARM_FEATURE_M)) { | 82 | + .fmc_model = "mx66l1g45g", |
54 | + assert(cpu_isar_feature(jazelle, cpu)); | 83 | + .spi_model = "mx66l1g45g", |
55 | set_feature(env, ARM_FEATURE_AUXCR); | 84 | + .num_cs = 2, |
56 | } | 85 | + .i2c_init = swift_bmc_i2c_init, |
57 | } | 86 | + .ram = 512 * MiB, |
58 | @@ -XXX,XX +XXX,XX @@ static void arm926_initfn(Object *obj) | 87 | }, { |
59 | set_feature(&cpu->env, ARM_FEATURE_VFP); | 88 | .name = MACHINE_TYPE_NAME("witherspoon-bmc"), |
60 | set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS); | 89 | .desc = "OpenPOWER Witherspoon BMC (ARM1176)", |
61 | set_feature(&cpu->env, ARM_FEATURE_CACHE_TEST_CLEAN); | ||
62 | - set_feature(&cpu->env, ARM_FEATURE_JAZELLE); | ||
63 | cpu->midr = 0x41069265; | ||
64 | cpu->reset_fpsid = 0x41011090; | ||
65 | cpu->ctr = 0x1dd20d2; | ||
66 | cpu->reset_sctlr = 0x00090078; | ||
67 | + | ||
68 | + /* | ||
69 | + * ARMv5 does not have the ID_ISAR registers, but we can still | ||
70 | + * set the field to indicate Jazelle support within QEMU. | ||
71 | + */ | ||
72 | + cpu->isar.id_isar1 = FIELD_DP32(cpu->isar.id_isar1, ID_ISAR1, JAZELLE, 1); | ||
73 | } | ||
74 | |||
75 | static void arm946_initfn(Object *obj) | ||
76 | @@ -XXX,XX +XXX,XX @@ static void arm1026_initfn(Object *obj) | ||
77 | set_feature(&cpu->env, ARM_FEATURE_AUXCR); | ||
78 | set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS); | ||
79 | set_feature(&cpu->env, ARM_FEATURE_CACHE_TEST_CLEAN); | ||
80 | - set_feature(&cpu->env, ARM_FEATURE_JAZELLE); | ||
81 | cpu->midr = 0x4106a262; | ||
82 | cpu->reset_fpsid = 0x410110a0; | ||
83 | cpu->ctr = 0x1dd20d2; | ||
84 | cpu->reset_sctlr = 0x00090078; | ||
85 | cpu->reset_auxcr = 1; | ||
86 | + | ||
87 | + /* | ||
88 | + * ARMv5 does not have the ID_ISAR registers, but we can still | ||
89 | + * set the field to indicate Jazelle support within QEMU. | ||
90 | + */ | ||
91 | + cpu->isar.id_isar1 = FIELD_DP32(cpu->isar.id_isar1, ID_ISAR1, JAZELLE, 1); | ||
92 | + | ||
93 | { | ||
94 | /* The 1026 had an IFAR at c6,c0,0,1 rather than the ARMv6 c6,c0,0,2 */ | ||
95 | ARMCPRegInfo ifar = { | ||
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 @@ | ||
101 | #define ENABLE_ARCH_5 arm_dc_feature(s, ARM_FEATURE_V5) | ||
102 | /* currently all emulated v5 cores are also v5TE, so don't bother */ | ||
103 | #define ENABLE_ARCH_5TE arm_dc_feature(s, ARM_FEATURE_V5) | ||
104 | -#define ENABLE_ARCH_5J arm_dc_feature(s, ARM_FEATURE_JAZELLE) | ||
105 | +#define ENABLE_ARCH_5J dc_isar_feature(jazelle, s) | ||
106 | #define ENABLE_ARCH_6 arm_dc_feature(s, ARM_FEATURE_V6) | ||
107 | #define ENABLE_ARCH_6K arm_dc_feature(s, ARM_FEATURE_V6K) | ||
108 | #define ENABLE_ARCH_6T2 arm_dc_feature(s, ARM_FEATURE_THUMB2) | ||
109 | -- | 90 | -- |
110 | 2.19.1 | 91 | 2.20.1 |
111 | 92 | ||
112 | 93 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Eddie James <eajames@linux.ibm.com> |
---|---|---|---|
2 | 2 | ||
3 | Instead of shifts and masks, use direct loads and stores from the neon | 3 | The XDMA engine embedded in the Aspeed SOCs performs PCI DMA operations |
4 | register file. Mirror the iteration structure of the ARM pseudocode | 4 | between the SOC (acting as a BMC) and a host processor in a server. |
5 | more closely. Correct the parameters of the VLD2 A2 insn. | 5 | |
6 | 6 | The XDMA engine exists on the AST2400, AST2500, and AST2600 SOCs, so | |
7 | Note that this includes a bugfix for handling of the insn | 7 | enable it for all of those. Add trace events on the important register |
8 | "VLD2 (multiple 2-element structures)" -- we were using an | 8 | writes in the XDMA engine. |
9 | incorrect stride value. | 9 | |
10 | 10 | Signed-off-by: Eddie James <eajames@linux.ibm.com> | |
11 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 11 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> |
12 | Message-id: 20181011205206.3552-19-richard.henderson@linaro.org | 12 | Signed-off-by: Cédric Le Goater <clg@kaod.org> |
13 | Reviewed-by: Peter Maydell <peter.maydell@linaro.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> | ||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
15 | --- | 17 | --- |
16 | target/arm/translate.c | 170 ++++++++++++++++++----------------------- | 18 | hw/misc/Makefile.objs | 1 + |
17 | 1 file changed, 74 insertions(+), 96 deletions(-) | 19 | include/hw/arm/aspeed_soc.h | 3 + |
18 | 20 | include/hw/misc/aspeed_xdma.h | 30 +++++++ | |
19 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 21 | hw/arm/aspeed_soc.c | 17 ++++ |
22 | hw/misc/aspeed_xdma.c | 165 ++++++++++++++++++++++++++++++++++ | ||
23 | hw/misc/trace-events | 3 + | ||
24 | 6 files changed, 219 insertions(+) | ||
25 | create mode 100644 include/hw/misc/aspeed_xdma.h | ||
26 | create mode 100644 hw/misc/aspeed_xdma.c | ||
27 | |||
28 | diff --git a/hw/misc/Makefile.objs b/hw/misc/Makefile.objs | ||
20 | index XXXXXXX..XXXXXXX 100644 | 29 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/target/arm/translate.c | 30 | --- a/hw/misc/Makefile.objs |
22 | +++ b/target/arm/translate.c | 31 | +++ b/hw/misc/Makefile.objs |
23 | @@ -XXX,XX +XXX,XX @@ static TCGv_i32 neon_load_reg(int reg, int pass) | 32 | @@ -XXX,XX +XXX,XX @@ obj-$(CONFIG_ARMSSE_MHU) += armsse-mhu.o |
24 | return tmp; | 33 | |
34 | obj-$(CONFIG_PVPANIC) += pvpanic.o | ||
35 | obj-$(CONFIG_AUX) += auxbus.o | ||
36 | +obj-$(CONFIG_ASPEED_SOC) += aspeed_xdma.o | ||
37 | obj-$(CONFIG_ASPEED_SOC) += aspeed_scu.o aspeed_sdmc.o | ||
38 | obj-$(CONFIG_MSF2) += msf2-sysreg.o | ||
39 | obj-$(CONFIG_NRF51_SOC) += nrf51_rng.o | ||
40 | diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h | ||
41 | index XXXXXXX..XXXXXXX 100644 | ||
42 | --- a/include/hw/arm/aspeed_soc.h | ||
43 | +++ b/include/hw/arm/aspeed_soc.h | ||
44 | @@ -XXX,XX +XXX,XX @@ | ||
45 | #include "hw/intc/aspeed_vic.h" | ||
46 | #include "hw/misc/aspeed_scu.h" | ||
47 | #include "hw/misc/aspeed_sdmc.h" | ||
48 | +#include "hw/misc/aspeed_xdma.h" | ||
49 | #include "hw/timer/aspeed_timer.h" | ||
50 | #include "hw/timer/aspeed_rtc.h" | ||
51 | #include "hw/i2c/aspeed_i2c.h" | ||
52 | @@ -XXX,XX +XXX,XX @@ typedef struct AspeedSoCState { | ||
53 | AspeedTimerCtrlState timerctrl; | ||
54 | AspeedI2CState i2c; | ||
55 | AspeedSCUState scu; | ||
56 | + AspeedXDMAState xdma; | ||
57 | AspeedSMCState fmc; | ||
58 | AspeedSMCState spi[ASPEED_SPIS_NUM]; | ||
59 | AspeedSDMCState sdmc; | ||
60 | @@ -XXX,XX +XXX,XX @@ enum { | ||
61 | ASPEED_ETH1, | ||
62 | ASPEED_ETH2, | ||
63 | ASPEED_SDRAM, | ||
64 | + ASPEED_XDMA, | ||
65 | }; | ||
66 | |||
67 | #endif /* ASPEED_SOC_H */ | ||
68 | diff --git a/include/hw/misc/aspeed_xdma.h b/include/hw/misc/aspeed_xdma.h | ||
69 | new file mode 100644 | ||
70 | index XXXXXXX..XXXXXXX | ||
71 | --- /dev/null | ||
72 | +++ b/include/hw/misc/aspeed_xdma.h | ||
73 | @@ -XXX,XX +XXX,XX @@ | ||
74 | +/* | ||
75 | + * ASPEED XDMA Controller | ||
76 | + * Eddie James <eajames@linux.ibm.com> | ||
77 | + * | ||
78 | + * Copyright (C) 2019 IBM Corp. | ||
79 | + * SPDX-License-Identifer: GPL-2.0-or-later | ||
80 | + */ | ||
81 | + | ||
82 | +#ifndef ASPEED_XDMA_H | ||
83 | +#define ASPEED_XDMA_H | ||
84 | + | ||
85 | +#include "hw/sysbus.h" | ||
86 | + | ||
87 | +#define TYPE_ASPEED_XDMA "aspeed.xdma" | ||
88 | +#define ASPEED_XDMA(obj) OBJECT_CHECK(AspeedXDMAState, (obj), TYPE_ASPEED_XDMA) | ||
89 | + | ||
90 | +#define ASPEED_XDMA_NUM_REGS (ASPEED_XDMA_REG_SIZE / sizeof(uint32_t)) | ||
91 | +#define ASPEED_XDMA_REG_SIZE 0x7C | ||
92 | + | ||
93 | +typedef struct AspeedXDMAState { | ||
94 | + SysBusDevice parent; | ||
95 | + | ||
96 | + MemoryRegion iomem; | ||
97 | + qemu_irq irq; | ||
98 | + | ||
99 | + char bmc_cmdq_readp_set; | ||
100 | + uint32_t regs[ASPEED_XDMA_NUM_REGS]; | ||
101 | +} AspeedXDMAState; | ||
102 | + | ||
103 | +#endif /* ASPEED_XDMA_H */ | ||
104 | diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c | ||
105 | index XXXXXXX..XXXXXXX 100644 | ||
106 | --- a/hw/arm/aspeed_soc.c | ||
107 | +++ b/hw/arm/aspeed_soc.c | ||
108 | @@ -XXX,XX +XXX,XX @@ static const hwaddr aspeed_soc_ast2400_memmap[] = { | ||
109 | [ASPEED_VIC] = 0x1E6C0000, | ||
110 | [ASPEED_SDMC] = 0x1E6E0000, | ||
111 | [ASPEED_SCU] = 0x1E6E2000, | ||
112 | + [ASPEED_XDMA] = 0x1E6E7000, | ||
113 | [ASPEED_ADC] = 0x1E6E9000, | ||
114 | [ASPEED_SRAM] = 0x1E720000, | ||
115 | [ASPEED_GPIO] = 0x1E780000, | ||
116 | @@ -XXX,XX +XXX,XX @@ static const hwaddr aspeed_soc_ast2500_memmap[] = { | ||
117 | [ASPEED_VIC] = 0x1E6C0000, | ||
118 | [ASPEED_SDMC] = 0x1E6E0000, | ||
119 | [ASPEED_SCU] = 0x1E6E2000, | ||
120 | + [ASPEED_XDMA] = 0x1E6E7000, | ||
121 | [ASPEED_ADC] = 0x1E6E9000, | ||
122 | [ASPEED_SRAM] = 0x1E720000, | ||
123 | [ASPEED_GPIO] = 0x1E780000, | ||
124 | @@ -XXX,XX +XXX,XX @@ static const int aspeed_soc_ast2400_irqmap[] = { | ||
125 | [ASPEED_I2C] = 12, | ||
126 | [ASPEED_ETH1] = 2, | ||
127 | [ASPEED_ETH2] = 3, | ||
128 | + [ASPEED_XDMA] = 6, | ||
129 | }; | ||
130 | |||
131 | #define aspeed_soc_ast2500_irqmap aspeed_soc_ast2400_irqmap | ||
132 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_init(Object *obj) | ||
133 | sysbus_init_child_obj(obj, "ftgmac100[*]", OBJECT(&s->ftgmac100[i]), | ||
134 | sizeof(s->ftgmac100[i]), TYPE_FTGMAC100); | ||
135 | } | ||
136 | + | ||
137 | + sysbus_init_child_obj(obj, "xdma", OBJECT(&s->xdma), sizeof(s->xdma), | ||
138 | + TYPE_ASPEED_XDMA); | ||
25 | } | 139 | } |
26 | 140 | ||
27 | +static void neon_load_element64(TCGv_i64 var, int reg, int ele, TCGMemOp mop) | 141 | static void aspeed_soc_realize(DeviceState *dev, Error **errp) |
28 | +{ | 142 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) |
29 | + long offset = neon_element_offset(reg, ele, mop & MO_SIZE); | 143 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->ftgmac100[i]), 0, |
30 | + | 144 | aspeed_soc_get_irq(s, ASPEED_ETH1 + i)); |
31 | + switch (mop) { | 145 | } |
32 | + case MO_UB: | 146 | + |
33 | + tcg_gen_ld8u_i64(var, cpu_env, offset); | 147 | + /* XDMA */ |
34 | + break; | 148 | + object_property_set_bool(OBJECT(&s->xdma), true, "realized", &err); |
35 | + case MO_UW: | 149 | + if (err) { |
36 | + tcg_gen_ld16u_i64(var, cpu_env, offset); | 150 | + error_propagate(errp, err); |
37 | + break; | 151 | + return; |
38 | + case MO_UL: | 152 | + } |
39 | + tcg_gen_ld32u_i64(var, cpu_env, offset); | 153 | + sysbus_mmio_map(SYS_BUS_DEVICE(&s->xdma), 0, |
40 | + break; | 154 | + sc->info->memmap[ASPEED_XDMA]); |
41 | + case MO_Q: | 155 | + sysbus_connect_irq(SYS_BUS_DEVICE(&s->xdma), 0, |
42 | + tcg_gen_ld_i64(var, cpu_env, offset); | 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)]; | ||
207 | + } | ||
208 | + | ||
209 | + return (uint64_t)val; | ||
210 | +} | ||
211 | + | ||
212 | +static void aspeed_xdma_write(void *opaque, hwaddr addr, uint64_t val, | ||
213 | + unsigned int size) | ||
214 | +{ | ||
215 | + unsigned int idx; | ||
216 | + uint32_t val32 = (uint32_t)val; | ||
217 | + AspeedXDMAState *xdma = opaque; | ||
218 | + | ||
219 | + if (addr >= ASPEED_XDMA_REG_SIZE) { | ||
220 | + return; | ||
221 | + } | ||
222 | + | ||
223 | + switch (addr) { | ||
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 | + } | ||
43 | + break; | 264 | + break; |
44 | + default: | 265 | + default: |
45 | + g_assert_not_reached(); | 266 | + xdma->regs[TO_REG(addr)] = val32; |
267 | + break; | ||
46 | + } | 268 | + } |
47 | +} | 269 | +} |
48 | + | 270 | + |
49 | static void neon_store_reg(int reg, int pass, TCGv_i32 var) | 271 | +static const MemoryRegionOps aspeed_xdma_ops = { |
50 | { | 272 | + .read = aspeed_xdma_read, |
51 | tcg_gen_st_i32(var, cpu_env, neon_reg_offset(reg, pass)); | 273 | + .write = aspeed_xdma_write, |
52 | tcg_temp_free_i32(var); | 274 | + .endianness = DEVICE_NATIVE_ENDIAN, |
53 | } | 275 | + .valid.min_access_size = 4, |
54 | 276 | + .valid.max_access_size = 4, | |
55 | +static void neon_store_element64(int reg, int ele, TCGMemOp size, TCGv_i64 var) | 277 | +}; |
56 | +{ | 278 | + |
57 | + long offset = neon_element_offset(reg, ele, size); | 279 | +static void aspeed_xdma_realize(DeviceState *dev, Error **errp) |
58 | + | 280 | +{ |
59 | + switch (size) { | 281 | + SysBusDevice *sbd = SYS_BUS_DEVICE(dev); |
60 | + case MO_8: | 282 | + AspeedXDMAState *xdma = ASPEED_XDMA(dev); |
61 | + tcg_gen_st8_i64(var, cpu_env, offset); | 283 | + |
62 | + break; | 284 | + sysbus_init_irq(sbd, &xdma->irq); |
63 | + case MO_16: | 285 | + memory_region_init_io(&xdma->iomem, OBJECT(xdma), &aspeed_xdma_ops, xdma, |
64 | + tcg_gen_st16_i64(var, cpu_env, offset); | 286 | + TYPE_ASPEED_XDMA, XDMA_MEM_SIZE); |
65 | + break; | 287 | + sysbus_init_mmio(sbd, &xdma->iomem); |
66 | + case MO_32: | 288 | +} |
67 | + tcg_gen_st32_i64(var, cpu_env, offset); | 289 | + |
68 | + break; | 290 | +static void aspeed_xdma_reset(DeviceState *dev) |
69 | + case MO_64: | 291 | +{ |
70 | + tcg_gen_st_i64(var, cpu_env, offset); | 292 | + AspeedXDMAState *xdma = ASPEED_XDMA(dev); |
71 | + break; | 293 | + |
72 | + default: | 294 | + xdma->bmc_cmdq_readp_set = 0; |
73 | + g_assert_not_reached(); | 295 | + memset(xdma->regs, 0, ASPEED_XDMA_REG_SIZE); |
74 | + } | 296 | + xdma->regs[TO_REG(XDMA_IRQ_ENG_STAT)] = XDMA_IRQ_ENG_STAT_RESET; |
75 | +} | 297 | + |
76 | + | 298 | + qemu_irq_lower(xdma->irq); |
77 | static inline void neon_load_reg64(TCGv_i64 var, int reg) | 299 | +} |
78 | { | 300 | + |
79 | tcg_gen_ld_i64(var, cpu_env, vfp_reg_offset(1, reg)); | 301 | +static const VMStateDescription aspeed_xdma_vmstate = { |
80 | @@ -XXX,XX +XXX,XX @@ static struct { | 302 | + .name = TYPE_ASPEED_XDMA, |
81 | int interleave; | 303 | + .version_id = 1, |
82 | int spacing; | 304 | + .fields = (VMStateField[]) { |
83 | } const neon_ls_element_type[11] = { | 305 | + VMSTATE_UINT32_ARRAY(regs, AspeedXDMAState, ASPEED_XDMA_NUM_REGS), |
84 | - {4, 4, 1}, | 306 | + VMSTATE_END_OF_LIST(), |
85 | - {4, 4, 2}, | 307 | + }, |
86 | + {1, 4, 1}, | 308 | +}; |
87 | + {1, 4, 2}, | 309 | + |
88 | {4, 1, 1}, | 310 | +static void aspeed_xdma_class_init(ObjectClass *classp, void *data) |
89 | - {4, 2, 1}, | 311 | +{ |
90 | - {3, 3, 1}, | 312 | + DeviceClass *dc = DEVICE_CLASS(classp); |
91 | - {3, 3, 2}, | 313 | + |
92 | + {2, 2, 2}, | 314 | + dc->realize = aspeed_xdma_realize; |
93 | + {1, 3, 1}, | 315 | + dc->reset = aspeed_xdma_reset; |
94 | + {1, 3, 2}, | 316 | + dc->vmsd = &aspeed_xdma_vmstate; |
95 | {3, 1, 1}, | 317 | +} |
96 | {1, 1, 1}, | 318 | + |
97 | - {2, 2, 1}, | 319 | +static const TypeInfo aspeed_xdma_info = { |
98 | - {2, 2, 2}, | 320 | + .name = TYPE_ASPEED_XDMA, |
99 | + {1, 2, 1}, | 321 | + .parent = TYPE_SYS_BUS_DEVICE, |
100 | + {1, 2, 2}, | 322 | + .instance_size = sizeof(AspeedXDMAState), |
101 | {2, 1, 1} | 323 | + .class_init = aspeed_xdma_class_init, |
102 | }; | 324 | +}; |
103 | 325 | + | |
104 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_ls_insn(DisasContext *s, uint32_t insn) | 326 | +static void aspeed_xdma_register_type(void) |
105 | int shift; | 327 | +{ |
106 | int n; | 328 | + type_register_static(&aspeed_xdma_info); |
107 | int vec_size; | 329 | +} |
108 | + int mmu_idx; | 330 | +type_init(aspeed_xdma_register_type); |
109 | + TCGMemOp endian; | 331 | diff --git a/hw/misc/trace-events b/hw/misc/trace-events |
110 | TCGv_i32 addr; | 332 | index XXXXXXX..XXXXXXX 100644 |
111 | TCGv_i32 tmp; | 333 | --- a/hw/misc/trace-events |
112 | TCGv_i32 tmp2; | 334 | +++ b/hw/misc/trace-events |
113 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_ls_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 |
114 | rn = (insn >> 16) & 0xf; | 336 | # armsse-mhu.c |
115 | rm = insn & 0xf; | 337 | armsse_mhu_read(uint64_t offset, uint64_t data, unsigned size) "SSE-200 MHU read: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u" |
116 | load = (insn & (1 << 21)) != 0; | 338 | armsse_mhu_write(uint64_t offset, uint64_t data, unsigned size) "SSE-200 MHU write: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u" |
117 | + endian = s->be_data; | 339 | + |
118 | + mmu_idx = get_mem_index(s); | 340 | +# aspeed_xdma.c |
119 | if ((insn & (1 << 23)) == 0) { | 341 | +aspeed_xdma_write(uint64_t offset, uint64_t data) "XDMA write: offset 0x%" PRIx64 " data 0x%" PRIx64 |
120 | /* Load store all elements. */ | ||
121 | op = (insn >> 8) & 0xf; | ||
122 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_ls_insn(DisasContext *s, uint32_t insn) | ||
123 | nregs = neon_ls_element_type[op].nregs; | ||
124 | interleave = neon_ls_element_type[op].interleave; | ||
125 | spacing = neon_ls_element_type[op].spacing; | ||
126 | - if (size == 3 && (interleave | spacing) != 1) | ||
127 | + if (size == 3 && (interleave | spacing) != 1) { | ||
128 | return 1; | ||
129 | + } | ||
130 | + tmp64 = tcg_temp_new_i64(); | ||
131 | addr = tcg_temp_new_i32(); | ||
132 | + tmp2 = tcg_const_i32(1 << size); | ||
133 | load_reg_var(s, addr, rn); | ||
134 | - stride = (1 << size) * interleave; | ||
135 | for (reg = 0; reg < nregs; reg++) { | ||
136 | - if (interleave > 2 || (interleave == 2 && nregs == 2)) { | ||
137 | - load_reg_var(s, addr, rn); | ||
138 | - tcg_gen_addi_i32(addr, addr, (1 << size) * reg); | ||
139 | - } else if (interleave == 2 && nregs == 4 && reg == 2) { | ||
140 | - load_reg_var(s, addr, rn); | ||
141 | - tcg_gen_addi_i32(addr, addr, 1 << size); | ||
142 | - } | ||
143 | - if (size == 3) { | ||
144 | - tmp64 = tcg_temp_new_i64(); | ||
145 | - if (load) { | ||
146 | - gen_aa32_ld64(s, tmp64, addr, get_mem_index(s)); | ||
147 | - neon_store_reg64(tmp64, rd); | ||
148 | - } else { | ||
149 | - neon_load_reg64(tmp64, rd); | ||
150 | - gen_aa32_st64(s, tmp64, addr, get_mem_index(s)); | ||
151 | - } | ||
152 | - tcg_temp_free_i64(tmp64); | ||
153 | - tcg_gen_addi_i32(addr, addr, stride); | ||
154 | - } else { | ||
155 | - for (pass = 0; pass < 2; pass++) { | ||
156 | - if (size == 2) { | ||
157 | - if (load) { | ||
158 | - tmp = tcg_temp_new_i32(); | ||
159 | - gen_aa32_ld32u(s, tmp, addr, get_mem_index(s)); | ||
160 | - neon_store_reg(rd, pass, tmp); | ||
161 | - } else { | ||
162 | - tmp = neon_load_reg(rd, pass); | ||
163 | - gen_aa32_st32(s, tmp, addr, get_mem_index(s)); | ||
164 | - tcg_temp_free_i32(tmp); | ||
165 | - } | ||
166 | - tcg_gen_addi_i32(addr, addr, stride); | ||
167 | - } else if (size == 1) { | ||
168 | - if (load) { | ||
169 | - tmp = tcg_temp_new_i32(); | ||
170 | - gen_aa32_ld16u(s, tmp, addr, get_mem_index(s)); | ||
171 | - tcg_gen_addi_i32(addr, addr, stride); | ||
172 | - tmp2 = tcg_temp_new_i32(); | ||
173 | - gen_aa32_ld16u(s, tmp2, addr, get_mem_index(s)); | ||
174 | - tcg_gen_addi_i32(addr, addr, stride); | ||
175 | - tcg_gen_shli_i32(tmp2, tmp2, 16); | ||
176 | - tcg_gen_or_i32(tmp, tmp, tmp2); | ||
177 | - tcg_temp_free_i32(tmp2); | ||
178 | - neon_store_reg(rd, pass, tmp); | ||
179 | - } else { | ||
180 | - tmp = neon_load_reg(rd, pass); | ||
181 | - tmp2 = tcg_temp_new_i32(); | ||
182 | - tcg_gen_shri_i32(tmp2, tmp, 16); | ||
183 | - gen_aa32_st16(s, tmp, addr, get_mem_index(s)); | ||
184 | - tcg_temp_free_i32(tmp); | ||
185 | - tcg_gen_addi_i32(addr, addr, stride); | ||
186 | - gen_aa32_st16(s, tmp2, addr, get_mem_index(s)); | ||
187 | - tcg_temp_free_i32(tmp2); | ||
188 | - tcg_gen_addi_i32(addr, addr, stride); | ||
189 | - } | ||
190 | - } else /* size == 0 */ { | ||
191 | - if (load) { | ||
192 | - tmp2 = NULL; | ||
193 | - for (n = 0; n < 4; n++) { | ||
194 | - tmp = tcg_temp_new_i32(); | ||
195 | - gen_aa32_ld8u(s, tmp, addr, get_mem_index(s)); | ||
196 | - tcg_gen_addi_i32(addr, addr, stride); | ||
197 | - if (n == 0) { | ||
198 | - tmp2 = tmp; | ||
199 | - } else { | ||
200 | - tcg_gen_shli_i32(tmp, tmp, n * 8); | ||
201 | - tcg_gen_or_i32(tmp2, tmp2, tmp); | ||
202 | - tcg_temp_free_i32(tmp); | ||
203 | - } | ||
204 | - } | ||
205 | - neon_store_reg(rd, pass, tmp2); | ||
206 | - } else { | ||
207 | - tmp2 = neon_load_reg(rd, pass); | ||
208 | - for (n = 0; n < 4; n++) { | ||
209 | - tmp = tcg_temp_new_i32(); | ||
210 | - if (n == 0) { | ||
211 | - tcg_gen_mov_i32(tmp, tmp2); | ||
212 | - } else { | ||
213 | - tcg_gen_shri_i32(tmp, tmp2, n * 8); | ||
214 | - } | ||
215 | - gen_aa32_st8(s, tmp, addr, get_mem_index(s)); | ||
216 | - tcg_temp_free_i32(tmp); | ||
217 | - tcg_gen_addi_i32(addr, addr, stride); | ||
218 | - } | ||
219 | - tcg_temp_free_i32(tmp2); | ||
220 | - } | ||
221 | + for (n = 0; n < 8 >> size; n++) { | ||
222 | + int xs; | ||
223 | + for (xs = 0; xs < interleave; xs++) { | ||
224 | + int tt = rd + reg + spacing * xs; | ||
225 | + | ||
226 | + if (load) { | ||
227 | + gen_aa32_ld_i64(s, tmp64, addr, mmu_idx, endian | size); | ||
228 | + neon_store_element64(tt, n, size, tmp64); | ||
229 | + } else { | ||
230 | + neon_load_element64(tmp64, tt, n, size); | ||
231 | + gen_aa32_st_i64(s, tmp64, addr, mmu_idx, endian | size); | ||
232 | } | ||
233 | + tcg_gen_add_i32(addr, addr, tmp2); | ||
234 | } | ||
235 | } | ||
236 | - rd += spacing; | ||
237 | } | ||
238 | tcg_temp_free_i32(addr); | ||
239 | - stride = nregs * 8; | ||
240 | + tcg_temp_free_i32(tmp2); | ||
241 | + tcg_temp_free_i64(tmp64); | ||
242 | + stride = nregs * interleave * 8; | ||
243 | } else { | ||
244 | size = (insn >> 10) & 3; | ||
245 | if (size == 3) { | ||
246 | -- | 342 | -- |
247 | 2.19.1 | 343 | 2.20.1 |
248 | 344 | ||
249 | 345 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | 1 | From: Andrew Jeffery <andrew@aj.id.au> | |
2 | |||
3 | The legacy interface only supported up to 32 IRQs, which became | ||
4 | restrictive around the AST2400 generation. QEMU support for the SoCs | ||
5 | started with the AST2400 along with an effort to reimplement and | ||
6 | upstream drivers for Linux, so up until this point the consumers of the | ||
7 | QEMU ASPEED support only required the 64 IRQ register interface. | ||
8 | |||
9 | In an effort to support older BMC firmware, add support for the 32 IRQ | ||
10 | interface. | ||
11 | |||
12 | Signed-off-by: Andrew Jeffery <andrew@aj.id.au> | ||
13 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
14 | Reviewed-by: Joel Stanley <joel@jms.id.au> | ||
15 | Message-id: 20190618165311.27066-22-clg@kaod.org | ||
16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
17 | --- | ||
18 | hw/intc/aspeed_vic.c | 105 ++++++++++++++++++++++++++----------------- | ||
19 | 1 file changed, 63 insertions(+), 42 deletions(-) | ||
20 | |||
21 | diff --git a/hw/intc/aspeed_vic.c b/hw/intc/aspeed_vic.c | ||
22 | index XXXXXXX..XXXXXXX 100644 | ||
23 | --- a/hw/intc/aspeed_vic.c | ||
24 | +++ b/hw/intc/aspeed_vic.c | ||
25 | @@ -XXX,XX +XXX,XX @@ static void aspeed_vic_set_irq(void *opaque, int irq, int level) | ||
26 | |||
27 | static uint64_t aspeed_vic_read(void *opaque, hwaddr offset, unsigned size) | ||
28 | { | ||
29 | - uint64_t val; | ||
30 | - const bool high = !!(offset & 0x4); | ||
31 | - hwaddr n_offset = (offset & ~0x4); | ||
32 | AspeedVICState *s = (AspeedVICState *)opaque; | ||
33 | + hwaddr n_offset; | ||
34 | + uint64_t val; | ||
35 | + bool high; | ||
36 | |||
37 | if (offset < AVIC_NEW_BASE_OFFSET) { | ||
38 | - qemu_log_mask(LOG_UNIMP, "%s: Ignoring read from legacy registers " | ||
39 | - "at 0x%" HWADDR_PRIx "[%u]\n", __func__, offset, size); | ||
40 | - return 0; | ||
41 | + high = false; | ||
42 | + n_offset = offset; | ||
43 | + } else { | ||
44 | + high = !!(offset & 0x4); | ||
45 | + n_offset = (offset & ~0x4); | ||
46 | } | ||
47 | |||
48 | - n_offset -= AVIC_NEW_BASE_OFFSET; | ||
49 | - | ||
50 | switch (n_offset) { | ||
51 | - case 0x0: /* IRQ Status */ | ||
52 | + case 0x80: /* IRQ Status */ | ||
53 | + case 0x00: | ||
54 | val = s->raw & ~s->select & s->enable; | ||
55 | break; | ||
56 | - case 0x08: /* FIQ Status */ | ||
57 | + case 0x88: /* FIQ Status */ | ||
58 | + case 0x04: | ||
59 | val = s->raw & s->select & s->enable; | ||
60 | break; | ||
61 | - case 0x10: /* Raw Interrupt Status */ | ||
62 | + case 0x90: /* Raw Interrupt Status */ | ||
63 | + case 0x08: | ||
64 | val = s->raw; | ||
65 | break; | ||
66 | - case 0x18: /* Interrupt Selection */ | ||
67 | + case 0x98: /* Interrupt Selection */ | ||
68 | + case 0x0c: | ||
69 | val = s->select; | ||
70 | break; | ||
71 | - case 0x20: /* Interrupt Enable */ | ||
72 | + case 0xa0: /* Interrupt Enable */ | ||
73 | + case 0x10: | ||
74 | val = s->enable; | ||
75 | break; | ||
76 | - case 0x30: /* Software Interrupt */ | ||
77 | + case 0xb0: /* Software Interrupt */ | ||
78 | + case 0x18: | ||
79 | val = s->trigger; | ||
80 | break; | ||
81 | - case 0x40: /* Interrupt Sensitivity */ | ||
82 | + case 0xc0: /* Interrupt Sensitivity */ | ||
83 | + case 0x24: | ||
84 | val = s->sense; | ||
85 | break; | ||
86 | - case 0x48: /* Interrupt Both Edge Trigger Control */ | ||
87 | + case 0xc8: /* Interrupt Both Edge Trigger Control */ | ||
88 | + case 0x28: | ||
89 | val = s->dual_edge; | ||
90 | break; | ||
91 | - case 0x50: /* Interrupt Event */ | ||
92 | + case 0xd0: /* Interrupt Event */ | ||
93 | + case 0x2c: | ||
94 | val = s->event; | ||
95 | break; | ||
96 | - case 0x60: /* Edge Triggered Interrupt Status */ | ||
97 | + case 0xe0: /* Edge Triggered Interrupt Status */ | ||
98 | val = s->raw & ~s->sense; | ||
99 | break; | ||
100 | /* Illegal */ | ||
101 | - case 0x28: /* Interrupt Enable Clear */ | ||
102 | - case 0x38: /* Software Interrupt Clear */ | ||
103 | - case 0x58: /* Edge Triggered Interrupt Clear */ | ||
104 | + case 0xa8: /* Interrupt Enable Clear */ | ||
105 | + case 0xb8: /* Software Interrupt Clear */ | ||
106 | + case 0xd8: /* Edge Triggered Interrupt Clear */ | ||
107 | qemu_log_mask(LOG_GUEST_ERROR, | ||
108 | "%s: Read of write-only register with offset 0x%" | ||
109 | HWADDR_PRIx "\n", __func__, offset); | ||
110 | @@ -XXX,XX +XXX,XX @@ static uint64_t aspeed_vic_read(void *opaque, hwaddr offset, unsigned size) | ||
111 | } | ||
112 | if (high) { | ||
113 | val = extract64(val, 32, 19); | ||
114 | + } else { | ||
115 | + val = extract64(val, 0, 32); | ||
116 | } | ||
117 | trace_aspeed_vic_read(offset, size, val); | ||
118 | return val; | ||
119 | @@ -XXX,XX +XXX,XX @@ static uint64_t aspeed_vic_read(void *opaque, hwaddr offset, unsigned size) | ||
120 | static void aspeed_vic_write(void *opaque, hwaddr offset, uint64_t data, | ||
121 | unsigned size) | ||
122 | { | ||
123 | - const bool high = !!(offset & 0x4); | ||
124 | - hwaddr n_offset = (offset & ~0x4); | ||
125 | AspeedVICState *s = (AspeedVICState *)opaque; | ||
126 | + hwaddr n_offset; | ||
127 | + bool high; | ||
128 | |||
129 | if (offset < AVIC_NEW_BASE_OFFSET) { | ||
130 | - qemu_log_mask(LOG_UNIMP, | ||
131 | - "%s: Ignoring write to legacy registers at 0x%" | ||
132 | - HWADDR_PRIx "[%u] <- 0x%" PRIx64 "\n", __func__, offset, | ||
133 | - size, data); | ||
134 | - return; | ||
135 | + high = false; | ||
136 | + n_offset = offset; | ||
137 | + } else { | ||
138 | + high = !!(offset & 0x4); | ||
139 | + n_offset = (offset & ~0x4); | ||
140 | } | ||
141 | |||
142 | - n_offset -= AVIC_NEW_BASE_OFFSET; | ||
143 | trace_aspeed_vic_write(offset, size, data); | ||
144 | |||
145 | /* Given we have members using separate enable/clear registers, deposit64() | ||
146 | @@ -XXX,XX +XXX,XX @@ static void aspeed_vic_write(void *opaque, hwaddr offset, uint64_t data, | ||
147 | } | ||
148 | |||
149 | switch (n_offset) { | ||
150 | - case 0x18: /* Interrupt Selection */ | ||
151 | + case 0x98: /* Interrupt Selection */ | ||
152 | + case 0x0c: | ||
153 | /* Register has deposit64() semantics - overwrite requested 32 bits */ | ||
154 | if (high) { | ||
155 | s->select &= AVIC_L_MASK; | ||
156 | @@ -XXX,XX +XXX,XX @@ static void aspeed_vic_write(void *opaque, hwaddr offset, uint64_t data, | ||
157 | } | ||
158 | s->select |= data; | ||
159 | break; | ||
160 | - case 0x20: /* Interrupt Enable */ | ||
161 | + case 0xa0: /* Interrupt Enable */ | ||
162 | + case 0x10: | ||
163 | s->enable |= data; | ||
164 | break; | ||
165 | - case 0x28: /* Interrupt Enable Clear */ | ||
166 | + case 0xa8: /* Interrupt Enable Clear */ | ||
167 | + case 0x14: | ||
168 | s->enable &= ~data; | ||
169 | break; | ||
170 | - case 0x30: /* Software Interrupt */ | ||
171 | + case 0xb0: /* Software Interrupt */ | ||
172 | + case 0x18: | ||
173 | qemu_log_mask(LOG_UNIMP, "%s: Software interrupts unavailable. " | ||
174 | "IRQs requested: 0x%016" PRIx64 "\n", __func__, data); | ||
175 | break; | ||
176 | - case 0x38: /* Software Interrupt Clear */ | ||
177 | + case 0xb8: /* Software Interrupt Clear */ | ||
178 | + case 0x1c: | ||
179 | qemu_log_mask(LOG_UNIMP, "%s: Software interrupts unavailable. " | ||
180 | "IRQs to be cleared: 0x%016" PRIx64 "\n", __func__, data); | ||
181 | break; | ||
182 | - case 0x50: /* Interrupt Event */ | ||
183 | + case 0xd0: /* Interrupt Event */ | ||
184 | /* Register has deposit64() semantics - overwrite the top four valid | ||
185 | * IRQ bits, as only the top four IRQs (GPIOs) can change their event | ||
186 | * type */ | ||
187 | @@ -XXX,XX +XXX,XX @@ static void aspeed_vic_write(void *opaque, hwaddr offset, uint64_t data, | ||
188 | "Ignoring invalid write to interrupt event register"); | ||
189 | } | ||
190 | break; | ||
191 | - case 0x58: /* Edge Triggered Interrupt Clear */ | ||
192 | + case 0xd8: /* Edge Triggered Interrupt Clear */ | ||
193 | + case 0x38: | ||
194 | s->raw &= ~(data & ~s->sense); | ||
195 | break; | ||
196 | - case 0x00: /* IRQ Status */ | ||
197 | - case 0x08: /* FIQ Status */ | ||
198 | - case 0x10: /* Raw Interrupt Status */ | ||
199 | - case 0x40: /* Interrupt Sensitivity */ | ||
200 | - case 0x48: /* Interrupt Both Edge Trigger Control */ | ||
201 | - case 0x60: /* Edge Triggered Interrupt Status */ | ||
202 | + case 0x80: /* IRQ Status */ | ||
203 | + case 0x00: | ||
204 | + case 0x88: /* FIQ Status */ | ||
205 | + case 0x04: | ||
206 | + case 0x90: /* Raw Interrupt Status */ | ||
207 | + case 0x08: | ||
208 | + case 0xc0: /* Interrupt Sensitivity */ | ||
209 | + case 0x24: | ||
210 | + case 0xc8: /* Interrupt Both Edge Trigger Control */ | ||
211 | + case 0x28: | ||
212 | + case 0xe0: /* Edge Triggered Interrupt Status */ | ||
213 | qemu_log_mask(LOG_GUEST_ERROR, | ||
214 | "%s: Write of read-only register with offset 0x%" | ||
215 | HWADDR_PRIx "\n", __func__, offset); | ||
216 | -- | ||
217 | 2.20.1 | ||
218 | |||
219 | diff view generated by jsdifflib |
1 | The HCR.DC virtualization configuration register bit has the | 1 | From: Joel Stanley <joel@jms.id.au> |
---|---|---|---|
2 | following effects: | ||
3 | * SCTLR.M behaves as if it is 0 for all purposes except | ||
4 | direct reads of the bit | ||
5 | * HCR.VM behaves as if it is 1 for all purposes except | ||
6 | direct reads of the bit | ||
7 | * the memory type produced by the first stage of the EL1&EL0 | ||
8 | translation regime is Normal Non-Shareable, | ||
9 | Inner Write-Back Read-Allocate Write-Allocate, | ||
10 | Outer Write-Back Read-Allocate Write-Allocate. | ||
11 | 2 | ||
12 | Implement this behaviour. | 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. | ||
13 | 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 | ||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
15 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
16 | Message-id: 20181012144235.19646-5-peter.maydell@linaro.org | ||
17 | --- | 18 | --- |
18 | target/arm/helper.c | 23 +++++++++++++++++++++-- | 19 | include/hw/watchdog/wdt_aspeed.h | 1 + |
19 | 1 file changed, 21 insertions(+), 2 deletions(-) | 20 | hw/arm/aspeed_soc.c | 2 ++ |
21 | hw/watchdog/wdt_aspeed.c | 20 ++++++++++++++++++++ | ||
22 | 3 files changed, 23 insertions(+) | ||
20 | 23 | ||
21 | 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 |
22 | index XXXXXXX..XXXXXXX 100644 | 25 | index XXXXXXX..XXXXXXX 100644 |
23 | --- a/target/arm/helper.c | 26 | --- a/include/hw/watchdog/wdt_aspeed.h |
24 | +++ b/target/arm/helper.c | 27 | +++ b/include/hw/watchdog/wdt_aspeed.h |
25 | @@ -XXX,XX +XXX,XX @@ static uint64_t do_ats_write(CPUARMState *env, uint64_t value, | 28 | @@ -XXX,XX +XXX,XX @@ typedef struct AspeedWDTState { |
26 | * * The Non-secure TTBCR.EAE bit is set to 1 | 29 | MemoryRegion iomem; |
27 | * * The implementation includes EL2, and the value of HCR.VM is 1 | 30 | uint32_t regs[ASPEED_WDT_REGS_MAX]; |
28 | * | 31 | |
29 | + * (Note that HCR.DC makes HCR.VM behave as if it is 1.) | 32 | + AspeedSCUState *scu; |
30 | + * | 33 | uint32_t pclk_freq; |
31 | * ATS1Hx always uses the 64bit format (not supported yet). | 34 | uint32_t silicon_rev; |
32 | */ | 35 | uint32_t ext_pulse_width_mask; |
33 | format64 = arm_s1_regime_using_lpae_format(env, mmu_idx); | 36 | diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c |
34 | 37 | index XXXXXXX..XXXXXXX 100644 | |
35 | if (arm_feature(env, ARM_FEATURE_EL2)) { | 38 | --- a/hw/arm/aspeed_soc.c |
36 | if (mmu_idx == ARMMMUIdx_S12NSE0 || mmu_idx == ARMMMUIdx_S12NSE1) { | 39 | +++ b/hw/arm/aspeed_soc.c |
37 | - format64 |= env->cp15.hcr_el2 & HCR_VM; | 40 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_init(Object *obj) |
38 | + format64 |= env->cp15.hcr_el2 & (HCR_VM | HCR_DC); | 41 | sizeof(s->wdt[i]), TYPE_ASPEED_WDT); |
39 | } else { | 42 | qdev_prop_set_uint32(DEVICE(&s->wdt[i]), "silicon-rev", |
40 | format64 |= arm_current_el(env) == 2; | 43 | sc->info->silicon_rev); |
41 | } | 44 | + object_property_add_const_link(OBJECT(&s->wdt[i]), "scu", |
42 | @@ -XXX,XX +XXX,XX @@ static inline bool regime_translation_disabled(CPUARMState *env, | 45 | + OBJECT(&s->scu), &error_abort); |
43 | } | 46 | } |
44 | 47 | ||
45 | if (mmu_idx == ARMMMUIdx_S2NS) { | 48 | for (i = 0; i < ASPEED_MACS_NUM; i++) { |
46 | - return (env->cp15.hcr_el2 & HCR_VM) == 0; | 49 | diff --git a/hw/watchdog/wdt_aspeed.c b/hw/watchdog/wdt_aspeed.c |
47 | + /* HCR.DC means HCR.VM behaves as 1 */ | 50 | index XXXXXXX..XXXXXXX 100644 |
48 | + return (env->cp15.hcr_el2 & (HCR_DC | HCR_VM)) == 0; | 51 | --- a/hw/watchdog/wdt_aspeed.c |
49 | } | 52 | +++ b/hw/watchdog/wdt_aspeed.c |
50 | 53 | @@ -XXX,XX +XXX,XX @@ | |
51 | if (env->cp15.hcr_el2 & HCR_TGE) { | 54 | |
52 | @@ -XXX,XX +XXX,XX @@ static inline bool regime_translation_disabled(CPUARMState *env, | 55 | #define WDT_RESTART_MAGIC 0x4755 |
53 | } | 56 | |
54 | } | 57 | +#define SCU_RESET_CONTROL1 (0x04 / 4) |
55 | 58 | +#define SCU_RESET_SDRAM BIT(0) | |
56 | + if ((env->cp15.hcr_el2 & HCR_DC) && | 59 | + |
57 | + (mmu_idx == ARMMMUIdx_S1NSE0 || mmu_idx == ARMMMUIdx_S1NSE1)) { | 60 | static bool aspeed_wdt_is_enabled(const AspeedWDTState *s) |
58 | + /* HCR.DC means SCTLR_EL1.M behaves as 0 */ | 61 | { |
59 | + return true; | 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; | ||
60 | + } | 72 | + } |
61 | + | 73 | + |
62 | return (regime_sctlr(env, mmu_idx) & SCTLR_M) == 0; | 74 | qemu_log_mask(CPU_LOG_RESET, "Watchdog timer expired.\n"); |
63 | } | 75 | watchdog_perform_action(); |
64 | 76 | timer_del(s->timer); | |
65 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr(CPUARMState *env, target_ulong address, | 77 | @@ -XXX,XX +XXX,XX @@ static void aspeed_wdt_realize(DeviceState *dev, Error **errp) |
66 | 78 | { | |
67 | /* Combine the S1 and S2 cache attributes, if needed */ | 79 | SysBusDevice *sbd = SYS_BUS_DEVICE(dev); |
68 | if (!ret && cacheattrs != NULL) { | 80 | AspeedWDTState *s = ASPEED_WDT(dev); |
69 | + if (env->cp15.hcr_el2 & HCR_DC) { | 81 | + Error *err = NULL; |
70 | + /* | 82 | + Object *obj; |
71 | + * HCR.DC forces the first stage attributes to | 83 | + |
72 | + * Normal Non-Shareable, | 84 | + obj = object_property_get_link(OBJECT(dev), "scu", &err); |
73 | + * Inner Write-Back Read-Allocate Write-Allocate, | 85 | + if (!obj) { |
74 | + * Outer Write-Back Read-Allocate Write-Allocate. | 86 | + error_propagate(errp, err); |
75 | + */ | 87 | + error_prepend(errp, "required link 'scu' not found: "); |
76 | + cacheattrs->attrs = 0xff; | 88 | + return; |
77 | + cacheattrs->shareability = 0; | 89 | + } |
78 | + } | 90 | + s->scu = ASPEED_SCU(obj); |
79 | *cacheattrs = combine_cacheattrs(*cacheattrs, cacheattrs2); | 91 | |
80 | } | 92 | if (!is_supported_silicon_rev(s->silicon_rev)) { |
81 | 93 | error_setg(errp, "Unknown silicon revision: 0x%" PRIx32, | |
82 | -- | 94 | -- |
83 | 2.19.1 | 95 | 2.20.1 |
84 | 96 | ||
85 | 97 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Hongbo Zhang <hongbo.zhang@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 3 | For AArch64, the existing "virt" machine is primarily meant to |
4 | Message-id: 20181011205206.3552-10-richard.henderson@linaro.org | 4 | run on KVM and execute virtualization workloads, but we need an |
5 | environment as faithful as possible to physical hardware, for supporting | ||
6 | firmware and OS development for physical Aarch64 machines. | ||
7 | |||
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] | ||
5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 40 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 41 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | --- | 42 | --- |
8 | target/arm/translate.c | 29 ++++++++++------------------- | 43 | hw/arm/Makefile.objs | 1 + |
9 | 1 file changed, 10 insertions(+), 19 deletions(-) | 44 | hw/arm/sbsa-ref.c | 271 ++++++++++++++++++++++++++++ |
10 | 45 | MAINTAINERS | 8 + | |
11 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 46 | default-configs/aarch64-softmmu.mak | 1 + |
47 | hw/arm/Kconfig | 14 ++ | ||
48 | 5 files changed, 295 insertions(+) | ||
49 | create mode 100644 hw/arm/sbsa-ref.c | ||
50 | |||
51 | diff --git a/hw/arm/Makefile.objs b/hw/arm/Makefile.objs | ||
12 | index XXXXXXX..XXXXXXX 100644 | 52 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/target/arm/translate.c | 53 | --- a/hw/arm/Makefile.objs |
14 | +++ b/target/arm/translate.c | 54 | +++ b/hw/arm/Makefile.objs |
15 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | 55 | @@ -XXX,XX +XXX,XX @@ obj-$(CONFIG_SPITZ) += spitz.o |
16 | break; | 56 | obj-$(CONFIG_TOSA) += tosa.o |
17 | } | 57 | obj-$(CONFIG_Z2) += z2.o |
18 | return 0; | 58 | obj-$(CONFIG_REALVIEW) += realview.o |
19 | + | 59 | +obj-$(CONFIG_SBSA_REF) += sbsa-ref.o |
20 | + case NEON_3R_VADD_VSUB: | 60 | obj-$(CONFIG_STELLARIS) += stellaris.o |
21 | + if (u) { | 61 | obj-$(CONFIG_COLLIE) += collie.o |
22 | + tcg_gen_gvec_sub(size, rd_ofs, rn_ofs, rm_ofs, | 62 | obj-$(CONFIG_VERSATILE) += versatilepb.o |
23 | + vec_size, vec_size); | 63 | diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c |
24 | + } else { | 64 | new file mode 100644 |
25 | + tcg_gen_gvec_add(size, rd_ofs, rn_ofs, rm_ofs, | 65 | index XXXXXXX..XXXXXXX |
26 | + vec_size, vec_size); | 66 | --- /dev/null |
27 | + } | 67 | +++ b/hw/arm/sbsa-ref.c |
28 | + return 0; | 68 | @@ -XXX,XX +XXX,XX @@ |
29 | } | 69 | +/* |
30 | if (size == 3) { | 70 | + * ARM SBSA Reference Platform emulation |
31 | /* 64-bit element instructions. */ | 71 | + * |
32 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | 72 | + * Copyright (c) 2018 Linaro Limited |
33 | cpu_V1, cpu_V0); | 73 | + * Written by Hongbo Zhang <hongbo.zhang@linaro.org> |
34 | } | 74 | + * |
35 | break; | 75 | + * This program is free software; you can redistribute it and/or modify it |
36 | - case NEON_3R_VADD_VSUB: | 76 | + * under the terms and conditions of the GNU General Public License, |
37 | - if (u) { | 77 | + * version 2 or later, as published by the Free Software Foundation. |
38 | - tcg_gen_sub_i64(CPU_V001); | 78 | + * |
39 | - } else { | 79 | + * This program is distributed in the hope it will be useful, but WITHOUT |
40 | - tcg_gen_add_i64(CPU_V001); | 80 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
41 | - } | 81 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
42 | - break; | 82 | + * more details. |
43 | default: | 83 | + * |
44 | abort(); | 84 | + * You should have received a copy of the GNU General Public License along with |
45 | } | 85 | + * this program. If not, see <http://www.gnu.org/licenses/>. |
46 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | 86 | + */ |
47 | tmp2 = neon_load_reg(rd, pass); | 87 | + |
48 | gen_neon_add(size, tmp, tmp2); | 88 | +#include "qemu/osdep.h" |
49 | break; | 89 | +#include "qapi/error.h" |
50 | - case NEON_3R_VADD_VSUB: | 90 | +#include "qemu/error-report.h" |
51 | - if (!u) { /* VADD */ | 91 | +#include "qemu/units.h" |
52 | - gen_neon_add(size, tmp, tmp2); | 92 | +#include "sysemu/numa.h" |
53 | - } else { /* VSUB */ | 93 | +#include "sysemu/sysemu.h" |
54 | - switch (size) { | 94 | +#include "exec/address-spaces.h" |
55 | - case 0: gen_helper_neon_sub_u8(tmp, tmp, tmp2); break; | 95 | +#include "exec/hwaddr.h" |
56 | - case 1: gen_helper_neon_sub_u16(tmp, tmp, tmp2); break; | 96 | +#include "kvm_arm.h" |
57 | - case 2: tcg_gen_sub_i32(tmp, tmp, tmp2); break; | 97 | +#include "hw/arm/boot.h" |
58 | - default: abort(); | 98 | +#include "hw/boards.h" |
59 | - } | 99 | +#include "hw/intc/arm_gicv3_common.h" |
60 | - } | 100 | + |
61 | - break; | 101 | +#define RAMLIMIT_GB 8192 |
62 | case NEON_3R_VTST_VCEQ: | 102 | +#define RAMLIMIT_BYTES (RAMLIMIT_GB * GiB) |
63 | if (!u) { /* VTST */ | 103 | + |
64 | switch (size) { | 104 | +enum { |
105 | + SBSA_FLASH, | ||
106 | + SBSA_MEM, | ||
107 | + SBSA_CPUPERIPHS, | ||
108 | + SBSA_GIC_DIST, | ||
109 | + SBSA_GIC_REDIST, | ||
110 | + SBSA_SMMU, | ||
111 | + SBSA_UART, | ||
112 | + SBSA_RTC, | ||
113 | + SBSA_PCIE, | ||
114 | + SBSA_PCIE_MMIO, | ||
115 | + SBSA_PCIE_MMIO_HIGH, | ||
116 | + SBSA_PCIE_PIO, | ||
117 | + SBSA_PCIE_ECAM, | ||
118 | + SBSA_GPIO, | ||
119 | + SBSA_SECURE_UART, | ||
120 | + SBSA_SECURE_UART_MM, | ||
121 | + SBSA_SECURE_MEM, | ||
122 | + SBSA_AHCI, | ||
123 | + SBSA_EHCI, | ||
124 | +}; | ||
125 | + | ||
126 | +typedef struct MemMapEntry { | ||
127 | + hwaddr base; | ||
128 | + hwaddr size; | ||
129 | +} MemMapEntry; | ||
130 | + | ||
131 | +typedef struct { | ||
132 | + MachineState parent; | ||
133 | + struct arm_boot_info bootinfo; | ||
134 | + int smp_cpus; | ||
135 | + void *fdt; | ||
136 | + int fdt_size; | ||
137 | + int psci_conduit; | ||
138 | +} SBSAMachineState; | ||
139 | + | ||
140 | +#define TYPE_SBSA_MACHINE MACHINE_TYPE_NAME("sbsa-ref") | ||
141 | +#define SBSA_MACHINE(obj) \ | ||
142 | + OBJECT_CHECK(SBSAMachineState, (obj), TYPE_SBSA_MACHINE) | ||
143 | + | ||
144 | +static const MemMapEntry sbsa_ref_memmap[] = { | ||
145 | + /* 512M boot ROM */ | ||
146 | + [SBSA_FLASH] = { 0, 0x20000000 }, | ||
147 | + /* 512M secure memory */ | ||
148 | + [SBSA_SECURE_MEM] = { 0x20000000, 0x20000000 }, | ||
149 | + /* Space reserved for CPU peripheral devices */ | ||
150 | + [SBSA_CPUPERIPHS] = { 0x40000000, 0x00040000 }, | ||
151 | + [SBSA_GIC_DIST] = { 0x40060000, 0x00010000 }, | ||
152 | + [SBSA_GIC_REDIST] = { 0x40080000, 0x04000000 }, | ||
153 | + [SBSA_UART] = { 0x60000000, 0x00001000 }, | ||
154 | + [SBSA_RTC] = { 0x60010000, 0x00001000 }, | ||
155 | + [SBSA_GPIO] = { 0x60020000, 0x00001000 }, | ||
156 | + [SBSA_SECURE_UART] = { 0x60030000, 0x00001000 }, | ||
157 | + [SBSA_SECURE_UART_MM] = { 0x60040000, 0x00001000 }, | ||
158 | + [SBSA_SMMU] = { 0x60050000, 0x00020000 }, | ||
159 | + /* Space here reserved for more SMMUs */ | ||
160 | + [SBSA_AHCI] = { 0x60100000, 0x00010000 }, | ||
161 | + [SBSA_EHCI] = { 0x60110000, 0x00010000 }, | ||
162 | + /* Space here reserved for other devices */ | ||
163 | + [SBSA_PCIE_PIO] = { 0x7fff0000, 0x00010000 }, | ||
164 | + /* 32-bit address PCIE MMIO space */ | ||
165 | + [SBSA_PCIE_MMIO] = { 0x80000000, 0x70000000 }, | ||
166 | + /* 256M PCIE ECAM space */ | ||
167 | + [SBSA_PCIE_ECAM] = { 0xf0000000, 0x10000000 }, | ||
168 | + /* ~1TB PCIE MMIO space (4GB to 1024GB boundary) */ | ||
169 | + [SBSA_PCIE_MMIO_HIGH] = { 0x100000000ULL, 0xFF00000000ULL }, | ||
170 | + [SBSA_MEM] = { 0x10000000000ULL, RAMLIMIT_BYTES }, | ||
171 | +}; | ||
172 | + | ||
173 | +static void sbsa_ref_init(MachineState *machine) | ||
174 | +{ | ||
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); | ||
340 | diff --git a/MAINTAINERS b/MAINTAINERS | ||
341 | index XXXXXXX..XXXXXXX 100644 | ||
342 | --- a/MAINTAINERS | ||
343 | +++ b/MAINTAINERS | ||
344 | @@ -XXX,XX +XXX,XX @@ F: include/hw/arm/fsl-imx6.h | ||
345 | F: include/hw/misc/imx6_*.h | ||
346 | F: include/hw/ssi/imx_spi.h | ||
347 | |||
348 | +SBSA-REF | ||
349 | +M: Radoslaw Biernacki <radoslaw.biernacki@linaro.org> | ||
350 | +M: Peter Maydell <peter.maydell@linaro.org> | ||
351 | +R: Leif Lindholm <leif.lindholm@linaro.org> | ||
352 | +L: qemu-arm@nongnu.org | ||
353 | +S: Maintained | ||
354 | +F: hw/arm/sbsa-ref.c | ||
355 | + | ||
356 | Sharp SL-5500 (Collie) PDA | ||
357 | M: Peter Maydell <peter.maydell@linaro.org> | ||
358 | L: qemu-arm@nongnu.org | ||
359 | diff --git a/default-configs/aarch64-softmmu.mak b/default-configs/aarch64-softmmu.mak | ||
360 | index XXXXXXX..XXXXXXX 100644 | ||
361 | --- a/default-configs/aarch64-softmmu.mak | ||
362 | +++ b/default-configs/aarch64-softmmu.mak | ||
363 | @@ -XXX,XX +XXX,XX @@ include arm-softmmu.mak | ||
364 | |||
365 | CONFIG_XLNX_ZYNQMP_ARM=y | ||
366 | CONFIG_XLNX_VERSAL=y | ||
367 | +CONFIG_SBSA_REF=y | ||
368 | diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig | ||
369 | index XXXXXXX..XXXXXXX 100644 | ||
370 | --- a/hw/arm/Kconfig | ||
371 | +++ b/hw/arm/Kconfig | ||
372 | @@ -XXX,XX +XXX,XX @@ config REALVIEW | ||
373 | select DS1338 # I2C RTC+NVRAM | ||
374 | select USB_OHCI | ||
375 | |||
376 | +config SBSA_REF | ||
377 | + bool | ||
378 | + imply PCI_DEVICES | ||
379 | + select AHCI | ||
380 | + select ARM_SMMUV3 | ||
381 | + select GPIO_KEY | ||
382 | + select PCI_EXPRESS | ||
383 | + select PCI_EXPRESS_GENERIC_BRIDGE | ||
384 | + select PFLASH_CFI01 | ||
385 | + select PL011 # UART | ||
386 | + select PL031 # RTC | ||
387 | + select PL061 # GPIO | ||
388 | + select USB_EHCI_SYSBUS | ||
389 | + | ||
390 | config SABRELITE | ||
391 | bool | ||
392 | select FSL_IMX6 | ||
65 | -- | 393 | -- |
66 | 2.19.1 | 394 | 2.20.1 |
67 | 395 | ||
68 | 396 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Hongbo Zhang <hongbo.zhang@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Create struct ARMISARegisters, to be accessed during translation. | 3 | Following the previous patch, this patch adds peripheral devices to the |
4 | newly introduced SBSA-ref machine. | ||
4 | 5 | ||
5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 6 | Signed-off-by: Hongbo Zhang <hongbo.zhang@linaro.org> |
6 | Message-id: 20181016223115.24100-2-richard.henderson@linaro.org | 7 | Message-id: 1561890034-15921-3-git-send-email-hongbo.zhang@linaro.org |
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | --- | 10 | --- |
10 | target/arm/cpu.h | 32 ++++---- | 11 | hw/arm/sbsa-ref.c | 535 ++++++++++++++++++++++++++++++++++++++++++++++ |
11 | hw/intc/armv7m_nvic.c | 12 +-- | 12 | 1 file changed, 535 insertions(+) |
12 | target/arm/cpu.c | 178 +++++++++++++++++++++--------------------- | ||
13 | target/arm/cpu64.c | 70 ++++++++--------- | ||
14 | target/arm/helper.c | 28 +++---- | ||
15 | 5 files changed, 162 insertions(+), 158 deletions(-) | ||
16 | 13 | ||
17 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 14 | diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c |
18 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/target/arm/cpu.h | 16 | --- a/hw/arm/sbsa-ref.c |
20 | +++ b/target/arm/cpu.h | 17 | +++ b/hw/arm/sbsa-ref.c |
21 | @@ -XXX,XX +XXX,XX @@ struct ARMCPU { | 18 | @@ -XXX,XX +XXX,XX @@ |
22 | * ARMv7AR ARM Architecture Reference Manual. A reset_ prefix | 19 | */ |
23 | * is used for reset values of non-constant registers; no reset_ | 20 | |
24 | * prefix means a constant register. | 21 | #include "qemu/osdep.h" |
25 | + * Some of these registers are split out into a substructure that | 22 | +#include "qemu-common.h" |
26 | + * is shared with the translators to control the ISA. | 23 | #include "qapi/error.h" |
27 | */ | 24 | #include "qemu/error-report.h" |
28 | + struct ARMISARegisters { | 25 | #include "qemu/units.h" |
29 | + uint32_t id_isar0; | 26 | +#include "sysemu/device_tree.h" |
30 | + uint32_t id_isar1; | 27 | #include "sysemu/numa.h" |
31 | + uint32_t id_isar2; | 28 | #include "sysemu/sysemu.h" |
32 | + uint32_t id_isar3; | 29 | #include "exec/address-spaces.h" |
33 | + uint32_t id_isar4; | 30 | #include "exec/hwaddr.h" |
34 | + uint32_t id_isar5; | 31 | #include "kvm_arm.h" |
35 | + uint32_t id_isar6; | 32 | #include "hw/arm/boot.h" |
36 | + uint32_t mvfr0; | 33 | +#include "hw/block/flash.h" |
37 | + uint32_t mvfr1; | 34 | #include "hw/boards.h" |
38 | + uint32_t mvfr2; | 35 | +#include "hw/ide/internal.h" |
39 | + uint64_t id_aa64isar0; | 36 | +#include "hw/ide/ahci_internal.h" |
40 | + uint64_t id_aa64isar1; | 37 | #include "hw/intc/arm_gicv3_common.h" |
41 | + uint64_t id_aa64pfr0; | 38 | +#include "hw/loader.h" |
42 | + uint64_t id_aa64pfr1; | 39 | +#include "hw/pci-host/gpex.h" |
43 | + } isar; | 40 | +#include "hw/usb.h" |
44 | uint32_t midr; | 41 | +#include "net/net.h" |
45 | uint32_t revidr; | 42 | |
46 | uint32_t reset_fpsid; | 43 | #define RAMLIMIT_GB 8192 |
47 | - uint32_t mvfr0; | 44 | #define RAMLIMIT_BYTES (RAMLIMIT_GB * GiB) |
48 | - uint32_t mvfr1; | 45 | |
49 | - uint32_t mvfr2; | 46 | +#define NUM_IRQS 256 |
50 | uint32_t ctr; | 47 | +#define NUM_SMMU_IRQS 4 |
51 | uint32_t reset_sctlr; | 48 | +#define NUM_SATA_PORTS 6 |
52 | uint32_t id_pfr0; | 49 | + |
53 | @@ -XXX,XX +XXX,XX @@ struct ARMCPU { | 50 | +#define VIRTUAL_PMU_IRQ 7 |
54 | uint32_t id_mmfr2; | 51 | +#define ARCH_GIC_MAINT_IRQ 9 |
55 | uint32_t id_mmfr3; | 52 | +#define ARCH_TIMER_VIRT_IRQ 11 |
56 | uint32_t id_mmfr4; | 53 | +#define ARCH_TIMER_S_EL1_IRQ 13 |
57 | - uint32_t id_isar0; | 54 | +#define ARCH_TIMER_NS_EL1_IRQ 14 |
58 | - uint32_t id_isar1; | 55 | +#define ARCH_TIMER_NS_EL2_IRQ 10 |
59 | - uint32_t id_isar2; | 56 | + |
60 | - uint32_t id_isar3; | 57 | enum { |
61 | - uint32_t id_isar4; | 58 | SBSA_FLASH, |
62 | - uint32_t id_isar5; | 59 | SBSA_MEM, |
63 | - uint32_t id_isar6; | 60 | @@ -XXX,XX +XXX,XX @@ typedef struct { |
64 | - uint64_t id_aa64pfr0; | 61 | void *fdt; |
65 | - uint64_t id_aa64pfr1; | 62 | int fdt_size; |
66 | uint64_t id_aa64dfr0; | 63 | int psci_conduit; |
67 | uint64_t id_aa64dfr1; | 64 | + PFlashCFI01 *flash[2]; |
68 | uint64_t id_aa64afr0; | 65 | } SBSAMachineState; |
69 | uint64_t id_aa64afr1; | 66 | |
70 | - uint64_t id_aa64isar0; | 67 | #define TYPE_SBSA_MACHINE MACHINE_TYPE_NAME("sbsa-ref") |
71 | - uint64_t id_aa64isar1; | 68 | @@ -XXX,XX +XXX,XX @@ static const MemMapEntry sbsa_ref_memmap[] = { |
72 | uint64_t id_aa64mmfr0; | 69 | [SBSA_MEM] = { 0x10000000000ULL, RAMLIMIT_BYTES }, |
73 | uint64_t id_aa64mmfr1; | 70 | }; |
74 | uint32_t dbgdidr; | 71 | |
75 | diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c | 72 | +static const int sbsa_ref_irqmap[] = { |
76 | index XXXXXXX..XXXXXXX 100644 | 73 | + [SBSA_UART] = 1, |
77 | --- a/hw/intc/armv7m_nvic.c | 74 | + [SBSA_RTC] = 2, |
78 | +++ b/hw/intc/armv7m_nvic.c | 75 | + [SBSA_PCIE] = 3, /* ... to 6 */ |
79 | @@ -XXX,XX +XXX,XX @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs) | 76 | + [SBSA_GPIO] = 7, |
80 | case 0xd5c: /* MMFR3. */ | 77 | + [SBSA_SECURE_UART] = 8, |
81 | return cpu->id_mmfr3; | 78 | + [SBSA_SECURE_UART_MM] = 9, |
82 | case 0xd60: /* ISAR0. */ | 79 | + [SBSA_AHCI] = 10, |
83 | - return cpu->id_isar0; | 80 | + [SBSA_EHCI] = 11, |
84 | + return cpu->isar.id_isar0; | 81 | +}; |
85 | case 0xd64: /* ISAR1. */ | 82 | + |
86 | - return cpu->id_isar1; | 83 | +/* |
87 | + return cpu->isar.id_isar1; | 84 | + * Firmware on this machine only uses ACPI table to load OS, these limited |
88 | case 0xd68: /* ISAR2. */ | 85 | + * device tree nodes are just to let firmware know the info which varies from |
89 | - return cpu->id_isar2; | 86 | + * command line parameters, so it is not necessary to be fully compatible |
90 | + return cpu->isar.id_isar2; | 87 | + * with the kernel CPU and NUMA binding rules. |
91 | case 0xd6c: /* ISAR3. */ | 88 | + */ |
92 | - return cpu->id_isar3; | 89 | +static void create_fdt(SBSAMachineState *sms) |
93 | + return cpu->isar.id_isar3; | 90 | +{ |
94 | case 0xd70: /* ISAR4. */ | 91 | + void *fdt = create_device_tree(&sms->fdt_size); |
95 | - return cpu->id_isar4; | 92 | + const MachineState *ms = MACHINE(sms); |
96 | + return cpu->isar.id_isar4; | 93 | + int cpu; |
97 | case 0xd74: /* ISAR5. */ | 94 | + |
98 | - return cpu->id_isar5; | 95 | + if (!fdt) { |
99 | + return cpu->isar.id_isar5; | 96 | + error_report("create_device_tree() failed"); |
100 | case 0xd78: /* CLIDR */ | 97 | + exit(1); |
101 | return cpu->clidr; | 98 | + } |
102 | case 0xd7c: /* CTR */ | 99 | + |
103 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | 100 | + sms->fdt = fdt; |
104 | index XXXXXXX..XXXXXXX 100644 | 101 | + |
105 | --- a/target/arm/cpu.c | 102 | + qemu_fdt_setprop_string(fdt, "/", "compatible", "linux,sbsa-ref"); |
106 | +++ b/target/arm/cpu.c | 103 | + qemu_fdt_setprop_cell(fdt, "/", "#address-cells", 0x2); |
107 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_reset(CPUState *s) | 104 | + qemu_fdt_setprop_cell(fdt, "/", "#size-cells", 0x2); |
108 | g_hash_table_foreach(cpu->cp_regs, cp_reg_check_reset, cpu); | 105 | + |
109 | 106 | + if (have_numa_distance) { | |
110 | env->vfp.xregs[ARM_VFP_FPSID] = cpu->reset_fpsid; | 107 | + int size = nb_numa_nodes * nb_numa_nodes * 3 * sizeof(uint32_t); |
111 | - env->vfp.xregs[ARM_VFP_MVFR0] = cpu->mvfr0; | 108 | + uint32_t *matrix = g_malloc0(size); |
112 | - env->vfp.xregs[ARM_VFP_MVFR1] = cpu->mvfr1; | 109 | + int idx, i, j; |
113 | - env->vfp.xregs[ARM_VFP_MVFR2] = cpu->mvfr2; | 110 | + |
114 | + env->vfp.xregs[ARM_VFP_MVFR0] = cpu->isar.mvfr0; | 111 | + for (i = 0; i < nb_numa_nodes; i++) { |
115 | + env->vfp.xregs[ARM_VFP_MVFR1] = cpu->isar.mvfr1; | 112 | + for (j = 0; j < nb_numa_nodes; j++) { |
116 | + env->vfp.xregs[ARM_VFP_MVFR2] = cpu->isar.mvfr2; | 113 | + idx = (i * nb_numa_nodes + j) * 3; |
117 | 114 | + matrix[idx + 0] = cpu_to_be32(i); | |
118 | cpu->power_state = cpu->start_powered_off ? PSCI_OFF : PSCI_ON; | 115 | + matrix[idx + 1] = cpu_to_be32(j); |
119 | s->halted = cpu->start_powered_off; | 116 | + matrix[idx + 2] = cpu_to_be32(numa_info[i].distance[j]); |
120 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) | 117 | + } |
121 | * registers as well. These are id_pfr1[7:4] and id_aa64pfr0[15:12]. | 118 | + } |
122 | */ | 119 | + |
123 | cpu->id_pfr1 &= ~0xf0; | 120 | + qemu_fdt_add_subnode(fdt, "/distance-map"); |
124 | - cpu->id_aa64pfr0 &= ~0xf000; | 121 | + qemu_fdt_setprop(fdt, "/distance-map", "distance-matrix", |
125 | + cpu->isar.id_aa64pfr0 &= ~0xf000; | 122 | + matrix, size); |
123 | + g_free(matrix); | ||
124 | + } | ||
125 | + | ||
126 | + qemu_fdt_add_subnode(sms->fdt, "/cpus"); | ||
127 | + | ||
128 | + for (cpu = sms->smp_cpus - 1; cpu >= 0; cpu--) { | ||
129 | + char *nodename = g_strdup_printf("/cpus/cpu@%d", cpu); | ||
130 | + ARMCPU *armcpu = ARM_CPU(qemu_get_cpu(cpu)); | ||
131 | + CPUState *cs = CPU(armcpu); | ||
132 | + | ||
133 | + qemu_fdt_add_subnode(sms->fdt, nodename); | ||
134 | + | ||
135 | + if (ms->possible_cpus->cpus[cs->cpu_index].props.has_node_id) { | ||
136 | + qemu_fdt_setprop_cell(sms->fdt, nodename, "numa-node-id", | ||
137 | + ms->possible_cpus->cpus[cs->cpu_index].props.node_id); | ||
138 | + } | ||
139 | + | ||
140 | + g_free(nodename); | ||
141 | + } | ||
142 | +} | ||
143 | + | ||
144 | +#define SBSA_FLASH_SECTOR_SIZE (256 * KiB) | ||
145 | + | ||
146 | +static PFlashCFI01 *sbsa_flash_create1(SBSAMachineState *sms, | ||
147 | + const char *name, | ||
148 | + const char *alias_prop_name) | ||
149 | +{ | ||
150 | + /* | ||
151 | + * Create a single flash device. We use the same parameters as | ||
152 | + * the flash devices on the Versatile Express board. | ||
153 | + */ | ||
154 | + DeviceState *dev = qdev_create(NULL, TYPE_PFLASH_CFI01); | ||
155 | + | ||
156 | + qdev_prop_set_uint64(dev, "sector-length", SBSA_FLASH_SECTOR_SIZE); | ||
157 | + qdev_prop_set_uint8(dev, "width", 4); | ||
158 | + qdev_prop_set_uint8(dev, "device-width", 2); | ||
159 | + qdev_prop_set_bit(dev, "big-endian", false); | ||
160 | + qdev_prop_set_uint16(dev, "id0", 0x89); | ||
161 | + qdev_prop_set_uint16(dev, "id1", 0x18); | ||
162 | + qdev_prop_set_uint16(dev, "id2", 0x00); | ||
163 | + qdev_prop_set_uint16(dev, "id3", 0x00); | ||
164 | + qdev_prop_set_string(dev, "name", name); | ||
165 | + object_property_add_child(OBJECT(sms), name, OBJECT(dev), | ||
166 | + &error_abort); | ||
167 | + object_property_add_alias(OBJECT(sms), alias_prop_name, | ||
168 | + OBJECT(dev), "drive", &error_abort); | ||
169 | + return PFLASH_CFI01(dev); | ||
170 | +} | ||
171 | + | ||
172 | +static void sbsa_flash_create(SBSAMachineState *sms) | ||
173 | +{ | ||
174 | + sms->flash[0] = sbsa_flash_create1(sms, "sbsa.flash0", "pflash0"); | ||
175 | + sms->flash[1] = sbsa_flash_create1(sms, "sbsa.flash1", "pflash1"); | ||
176 | +} | ||
177 | + | ||
178 | +static void sbsa_flash_map1(PFlashCFI01 *flash, | ||
179 | + hwaddr base, hwaddr size, | ||
180 | + MemoryRegion *sysmem) | ||
181 | +{ | ||
182 | + DeviceState *dev = DEVICE(flash); | ||
183 | + | ||
184 | + assert(size % SBSA_FLASH_SECTOR_SIZE == 0); | ||
185 | + assert(size / SBSA_FLASH_SECTOR_SIZE <= UINT32_MAX); | ||
186 | + qdev_prop_set_uint32(dev, "num-blocks", size / SBSA_FLASH_SECTOR_SIZE); | ||
187 | + qdev_init_nofail(dev); | ||
188 | + | ||
189 | + memory_region_add_subregion(sysmem, base, | ||
190 | + sysbus_mmio_get_region(SYS_BUS_DEVICE(dev), | ||
191 | + 0)); | ||
192 | +} | ||
193 | + | ||
194 | +static void sbsa_flash_map(SBSAMachineState *sms, | ||
195 | + MemoryRegion *sysmem, | ||
196 | + MemoryRegion *secure_sysmem) | ||
197 | +{ | ||
198 | + /* | ||
199 | + * Map two flash devices to fill the SBSA_FLASH space in the memmap. | ||
200 | + * sysmem is the system memory space. secure_sysmem is the secure view | ||
201 | + * of the system, and the first flash device should be made visible only | ||
202 | + * there. The second flash device is visible to both secure and nonsecure. | ||
203 | + * If sysmem == secure_sysmem this means there is no separate Secure | ||
204 | + * address space and both flash devices are generally visible. | ||
205 | + */ | ||
206 | + hwaddr flashsize = sbsa_ref_memmap[SBSA_FLASH].size / 2; | ||
207 | + hwaddr flashbase = sbsa_ref_memmap[SBSA_FLASH].base; | ||
208 | + | ||
209 | + sbsa_flash_map1(sms->flash[0], flashbase, flashsize, | ||
210 | + secure_sysmem); | ||
211 | + sbsa_flash_map1(sms->flash[1], flashbase + flashsize, flashsize, | ||
212 | + sysmem); | ||
213 | +} | ||
214 | + | ||
215 | +static bool sbsa_firmware_init(SBSAMachineState *sms, | ||
216 | + MemoryRegion *sysmem, | ||
217 | + MemoryRegion *secure_sysmem) | ||
218 | +{ | ||
219 | + int i; | ||
220 | + BlockBackend *pflash_blk0; | ||
221 | + | ||
222 | + /* Map legacy -drive if=pflash to machine properties */ | ||
223 | + for (i = 0; i < ARRAY_SIZE(sms->flash); i++) { | ||
224 | + pflash_cfi01_legacy_drive(sms->flash[i], | ||
225 | + drive_get(IF_PFLASH, 0, i)); | ||
226 | + } | ||
227 | + | ||
228 | + sbsa_flash_map(sms, sysmem, secure_sysmem); | ||
229 | + | ||
230 | + pflash_blk0 = pflash_cfi01_get_blk(sms->flash[0]); | ||
231 | + | ||
232 | + if (bios_name) { | ||
233 | + char *fname; | ||
234 | + MemoryRegion *mr; | ||
235 | + int image_size; | ||
236 | + | ||
237 | + if (pflash_blk0) { | ||
238 | + error_report("The contents of the first flash device may be " | ||
239 | + "specified with -bios or with -drive if=pflash... " | ||
240 | + "but you cannot use both options at once"); | ||
241 | + exit(1); | ||
242 | + } | ||
243 | + | ||
244 | + /* Fall back to -bios */ | ||
245 | + | ||
246 | + fname = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); | ||
247 | + if (!fname) { | ||
248 | + error_report("Could not find ROM image '%s'", bios_name); | ||
249 | + exit(1); | ||
250 | + } | ||
251 | + mr = sysbus_mmio_get_region(SYS_BUS_DEVICE(sms->flash[0]), 0); | ||
252 | + image_size = load_image_mr(fname, mr); | ||
253 | + g_free(fname); | ||
254 | + if (image_size < 0) { | ||
255 | + error_report("Could not load ROM image '%s'", bios_name); | ||
256 | + exit(1); | ||
257 | + } | ||
258 | + } | ||
259 | + | ||
260 | + return pflash_blk0 || bios_name; | ||
261 | +} | ||
262 | + | ||
263 | +static void create_secure_ram(SBSAMachineState *sms, | ||
264 | + MemoryRegion *secure_sysmem) | ||
265 | +{ | ||
266 | + MemoryRegion *secram = g_new(MemoryRegion, 1); | ||
267 | + hwaddr base = sbsa_ref_memmap[SBSA_SECURE_MEM].base; | ||
268 | + hwaddr size = sbsa_ref_memmap[SBSA_SECURE_MEM].size; | ||
269 | + | ||
270 | + memory_region_init_ram(secram, NULL, "sbsa-ref.secure-ram", size, | ||
271 | + &error_fatal); | ||
272 | + memory_region_add_subregion(secure_sysmem, base, secram); | ||
273 | +} | ||
274 | + | ||
275 | +static void create_gic(SBSAMachineState *sms, qemu_irq *pic) | ||
276 | +{ | ||
277 | + DeviceState *gicdev; | ||
278 | + SysBusDevice *gicbusdev; | ||
279 | + const char *gictype; | ||
280 | + uint32_t redist0_capacity, redist0_count; | ||
281 | + int i; | ||
282 | + | ||
283 | + gictype = gicv3_class_name(); | ||
284 | + | ||
285 | + gicdev = qdev_create(NULL, gictype); | ||
286 | + qdev_prop_set_uint32(gicdev, "revision", 3); | ||
287 | + qdev_prop_set_uint32(gicdev, "num-cpu", smp_cpus); | ||
288 | + /* | ||
289 | + * Note that the num-irq property counts both internal and external | ||
290 | + * interrupts; there are always 32 of the former (mandated by GIC spec). | ||
291 | + */ | ||
292 | + qdev_prop_set_uint32(gicdev, "num-irq", NUM_IRQS + 32); | ||
293 | + qdev_prop_set_bit(gicdev, "has-security-extensions", true); | ||
294 | + | ||
295 | + redist0_capacity = | ||
296 | + sbsa_ref_memmap[SBSA_GIC_REDIST].size / GICV3_REDIST_SIZE; | ||
297 | + redist0_count = MIN(smp_cpus, redist0_capacity); | ||
298 | + | ||
299 | + qdev_prop_set_uint32(gicdev, "len-redist-region-count", 1); | ||
300 | + qdev_prop_set_uint32(gicdev, "redist-region-count[0]", redist0_count); | ||
301 | + | ||
302 | + qdev_init_nofail(gicdev); | ||
303 | + gicbusdev = SYS_BUS_DEVICE(gicdev); | ||
304 | + sysbus_mmio_map(gicbusdev, 0, sbsa_ref_memmap[SBSA_GIC_DIST].base); | ||
305 | + sysbus_mmio_map(gicbusdev, 1, sbsa_ref_memmap[SBSA_GIC_REDIST].base); | ||
306 | + | ||
307 | + /* | ||
308 | + * Wire the outputs from each CPU's generic timer and the GICv3 | ||
309 | + * maintenance interrupt signal to the appropriate GIC PPI inputs, | ||
310 | + * and the GIC's IRQ/FIQ/VIRQ/VFIQ interrupt outputs to the CPU's inputs. | ||
311 | + */ | ||
312 | + for (i = 0; i < smp_cpus; i++) { | ||
313 | + DeviceState *cpudev = DEVICE(qemu_get_cpu(i)); | ||
314 | + int ppibase = NUM_IRQS + i * GIC_INTERNAL + GIC_NR_SGIS; | ||
315 | + int irq; | ||
316 | + /* | ||
317 | + * Mapping from the output timer irq lines from the CPU to the | ||
318 | + * GIC PPI inputs used for this board. | ||
319 | + */ | ||
320 | + const int timer_irq[] = { | ||
321 | + [GTIMER_PHYS] = ARCH_TIMER_NS_EL1_IRQ, | ||
322 | + [GTIMER_VIRT] = ARCH_TIMER_VIRT_IRQ, | ||
323 | + [GTIMER_HYP] = ARCH_TIMER_NS_EL2_IRQ, | ||
324 | + [GTIMER_SEC] = ARCH_TIMER_S_EL1_IRQ, | ||
325 | + }; | ||
326 | + | ||
327 | + for (irq = 0; irq < ARRAY_SIZE(timer_irq); irq++) { | ||
328 | + qdev_connect_gpio_out(cpudev, irq, | ||
329 | + qdev_get_gpio_in(gicdev, | ||
330 | + ppibase + timer_irq[irq])); | ||
331 | + } | ||
332 | + | ||
333 | + qdev_connect_gpio_out_named(cpudev, "gicv3-maintenance-interrupt", 0, | ||
334 | + qdev_get_gpio_in(gicdev, ppibase | ||
335 | + + ARCH_GIC_MAINT_IRQ)); | ||
336 | + qdev_connect_gpio_out_named(cpudev, "pmu-interrupt", 0, | ||
337 | + qdev_get_gpio_in(gicdev, ppibase | ||
338 | + + VIRTUAL_PMU_IRQ)); | ||
339 | + | ||
340 | + sysbus_connect_irq(gicbusdev, i, qdev_get_gpio_in(cpudev, ARM_CPU_IRQ)); | ||
341 | + sysbus_connect_irq(gicbusdev, i + smp_cpus, | ||
342 | + qdev_get_gpio_in(cpudev, ARM_CPU_FIQ)); | ||
343 | + sysbus_connect_irq(gicbusdev, i + 2 * smp_cpus, | ||
344 | + qdev_get_gpio_in(cpudev, ARM_CPU_VIRQ)); | ||
345 | + sysbus_connect_irq(gicbusdev, i + 3 * smp_cpus, | ||
346 | + qdev_get_gpio_in(cpudev, ARM_CPU_VFIQ)); | ||
347 | + } | ||
348 | + | ||
349 | + for (i = 0; i < NUM_IRQS; i++) { | ||
350 | + pic[i] = qdev_get_gpio_in(gicdev, i); | ||
351 | + } | ||
352 | +} | ||
353 | + | ||
354 | +static void create_uart(const SBSAMachineState *sms, qemu_irq *pic, int uart, | ||
355 | + MemoryRegion *mem, Chardev *chr) | ||
356 | +{ | ||
357 | + hwaddr base = sbsa_ref_memmap[uart].base; | ||
358 | + int irq = sbsa_ref_irqmap[uart]; | ||
359 | + DeviceState *dev = qdev_create(NULL, "pl011"); | ||
360 | + SysBusDevice *s = SYS_BUS_DEVICE(dev); | ||
361 | + | ||
362 | + qdev_prop_set_chr(dev, "chardev", chr); | ||
363 | + qdev_init_nofail(dev); | ||
364 | + memory_region_add_subregion(mem, base, | ||
365 | + sysbus_mmio_get_region(s, 0)); | ||
366 | + sysbus_connect_irq(s, 0, pic[irq]); | ||
367 | +} | ||
368 | + | ||
369 | +static void create_rtc(const SBSAMachineState *sms, qemu_irq *pic) | ||
370 | +{ | ||
371 | + hwaddr base = sbsa_ref_memmap[SBSA_RTC].base; | ||
372 | + int irq = sbsa_ref_irqmap[SBSA_RTC]; | ||
373 | + | ||
374 | + sysbus_create_simple("pl031", base, pic[irq]); | ||
375 | +} | ||
376 | + | ||
377 | +static DeviceState *gpio_key_dev; | ||
378 | +static void sbsa_ref_powerdown_req(Notifier *n, void *opaque) | ||
379 | +{ | ||
380 | + /* use gpio Pin 3 for power button event */ | ||
381 | + qemu_set_irq(qdev_get_gpio_in(gpio_key_dev, 0), 1); | ||
382 | +} | ||
383 | + | ||
384 | +static Notifier sbsa_ref_powerdown_notifier = { | ||
385 | + .notify = sbsa_ref_powerdown_req | ||
386 | +}; | ||
387 | + | ||
388 | +static void create_gpio(const SBSAMachineState *sms, qemu_irq *pic) | ||
389 | +{ | ||
390 | + DeviceState *pl061_dev; | ||
391 | + hwaddr base = sbsa_ref_memmap[SBSA_GPIO].base; | ||
392 | + int irq = sbsa_ref_irqmap[SBSA_GPIO]; | ||
393 | + | ||
394 | + pl061_dev = sysbus_create_simple("pl061", base, pic[irq]); | ||
395 | + | ||
396 | + gpio_key_dev = sysbus_create_simple("gpio-key", -1, | ||
397 | + qdev_get_gpio_in(pl061_dev, 3)); | ||
398 | + | ||
399 | + /* connect powerdown request */ | ||
400 | + qemu_register_powerdown_notifier(&sbsa_ref_powerdown_notifier); | ||
401 | +} | ||
402 | + | ||
403 | +static void create_ahci(const SBSAMachineState *sms, qemu_irq *pic) | ||
404 | +{ | ||
405 | + hwaddr base = sbsa_ref_memmap[SBSA_AHCI].base; | ||
406 | + int irq = sbsa_ref_irqmap[SBSA_AHCI]; | ||
407 | + DeviceState *dev; | ||
408 | + DriveInfo *hd[NUM_SATA_PORTS]; | ||
409 | + SysbusAHCIState *sysahci; | ||
410 | + AHCIState *ahci; | ||
411 | + int i; | ||
412 | + | ||
413 | + dev = qdev_create(NULL, "sysbus-ahci"); | ||
414 | + qdev_prop_set_uint32(dev, "num-ports", NUM_SATA_PORTS); | ||
415 | + qdev_init_nofail(dev); | ||
416 | + sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, base); | ||
417 | + sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, pic[irq]); | ||
418 | + | ||
419 | + sysahci = SYSBUS_AHCI(dev); | ||
420 | + ahci = &sysahci->ahci; | ||
421 | + ide_drive_get(hd, ARRAY_SIZE(hd)); | ||
422 | + for (i = 0; i < ahci->ports; i++) { | ||
423 | + if (hd[i] == NULL) { | ||
424 | + continue; | ||
425 | + } | ||
426 | + ide_create_drive(&ahci->dev[i].port, 0, hd[i]); | ||
427 | + } | ||
428 | +} | ||
429 | + | ||
430 | +static void create_ehci(const SBSAMachineState *sms, qemu_irq *pic) | ||
431 | +{ | ||
432 | + hwaddr base = sbsa_ref_memmap[SBSA_EHCI].base; | ||
433 | + int irq = sbsa_ref_irqmap[SBSA_EHCI]; | ||
434 | + | ||
435 | + sysbus_create_simple("platform-ehci-usb", base, pic[irq]); | ||
436 | +} | ||
437 | + | ||
438 | +static void create_smmu(const SBSAMachineState *sms, qemu_irq *pic, | ||
439 | + PCIBus *bus) | ||
440 | +{ | ||
441 | + hwaddr base = sbsa_ref_memmap[SBSA_SMMU].base; | ||
442 | + int irq = sbsa_ref_irqmap[SBSA_SMMU]; | ||
443 | + DeviceState *dev; | ||
444 | + int i; | ||
445 | + | ||
446 | + dev = qdev_create(NULL, "arm-smmuv3"); | ||
447 | + | ||
448 | + object_property_set_link(OBJECT(dev), OBJECT(bus), "primary-bus", | ||
449 | + &error_abort); | ||
450 | + qdev_init_nofail(dev); | ||
451 | + sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, base); | ||
452 | + for (i = 0; i < NUM_SMMU_IRQS; i++) { | ||
453 | + sysbus_connect_irq(SYS_BUS_DEVICE(dev), i, pic[irq + i]); | ||
454 | + } | ||
455 | +} | ||
456 | + | ||
457 | +static void create_pcie(SBSAMachineState *sms, qemu_irq *pic) | ||
458 | +{ | ||
459 | + hwaddr base_ecam = sbsa_ref_memmap[SBSA_PCIE_ECAM].base; | ||
460 | + hwaddr size_ecam = sbsa_ref_memmap[SBSA_PCIE_ECAM].size; | ||
461 | + hwaddr base_mmio = sbsa_ref_memmap[SBSA_PCIE_MMIO].base; | ||
462 | + hwaddr size_mmio = sbsa_ref_memmap[SBSA_PCIE_MMIO].size; | ||
463 | + hwaddr base_mmio_high = sbsa_ref_memmap[SBSA_PCIE_MMIO_HIGH].base; | ||
464 | + hwaddr size_mmio_high = sbsa_ref_memmap[SBSA_PCIE_MMIO_HIGH].size; | ||
465 | + hwaddr base_pio = sbsa_ref_memmap[SBSA_PCIE_PIO].base; | ||
466 | + int irq = sbsa_ref_irqmap[SBSA_PCIE]; | ||
467 | + MemoryRegion *mmio_alias, *mmio_alias_high, *mmio_reg; | ||
468 | + MemoryRegion *ecam_alias, *ecam_reg; | ||
469 | + DeviceState *dev; | ||
470 | + PCIHostState *pci; | ||
471 | + int i; | ||
472 | + | ||
473 | + dev = qdev_create(NULL, TYPE_GPEX_HOST); | ||
474 | + qdev_init_nofail(dev); | ||
475 | + | ||
476 | + /* Map ECAM space */ | ||
477 | + ecam_alias = g_new0(MemoryRegion, 1); | ||
478 | + ecam_reg = sysbus_mmio_get_region(SYS_BUS_DEVICE(dev), 0); | ||
479 | + memory_region_init_alias(ecam_alias, OBJECT(dev), "pcie-ecam", | ||
480 | + ecam_reg, 0, size_ecam); | ||
481 | + memory_region_add_subregion(get_system_memory(), base_ecam, ecam_alias); | ||
482 | + | ||
483 | + /* Map the MMIO space */ | ||
484 | + mmio_alias = g_new0(MemoryRegion, 1); | ||
485 | + mmio_reg = sysbus_mmio_get_region(SYS_BUS_DEVICE(dev), 1); | ||
486 | + memory_region_init_alias(mmio_alias, OBJECT(dev), "pcie-mmio", | ||
487 | + mmio_reg, base_mmio, size_mmio); | ||
488 | + memory_region_add_subregion(get_system_memory(), base_mmio, mmio_alias); | ||
489 | + | ||
490 | + /* Map the MMIO_HIGH space */ | ||
491 | + mmio_alias_high = g_new0(MemoryRegion, 1); | ||
492 | + memory_region_init_alias(mmio_alias_high, OBJECT(dev), "pcie-mmio-high", | ||
493 | + mmio_reg, base_mmio_high, size_mmio_high); | ||
494 | + memory_region_add_subregion(get_system_memory(), base_mmio_high, | ||
495 | + mmio_alias_high); | ||
496 | + | ||
497 | + /* Map IO port space */ | ||
498 | + sysbus_mmio_map(SYS_BUS_DEVICE(dev), 2, base_pio); | ||
499 | + | ||
500 | + for (i = 0; i < GPEX_NUM_IRQS; i++) { | ||
501 | + sysbus_connect_irq(SYS_BUS_DEVICE(dev), i, pic[irq + i]); | ||
502 | + gpex_set_irq_num(GPEX_HOST(dev), i, irq + i); | ||
503 | + } | ||
504 | + | ||
505 | + pci = PCI_HOST_BRIDGE(dev); | ||
506 | + if (pci->bus) { | ||
507 | + for (i = 0; i < nb_nics; i++) { | ||
508 | + NICInfo *nd = &nd_table[i]; | ||
509 | + | ||
510 | + if (!nd->model) { | ||
511 | + nd->model = g_strdup("e1000e"); | ||
512 | + } | ||
513 | + | ||
514 | + pci_nic_init_nofail(nd, pci->bus, nd->model, NULL); | ||
515 | + } | ||
516 | + } | ||
517 | + | ||
518 | + pci_create_simple(pci->bus, -1, "VGA"); | ||
519 | + | ||
520 | + create_smmu(sms, pic, pci->bus); | ||
521 | +} | ||
522 | + | ||
523 | +static void *sbsa_ref_dtb(const struct arm_boot_info *binfo, int *fdt_size) | ||
524 | +{ | ||
525 | + const SBSAMachineState *board = container_of(binfo, SBSAMachineState, | ||
526 | + bootinfo); | ||
527 | + | ||
528 | + *fdt_size = board->fdt_size; | ||
529 | + return board->fdt; | ||
530 | +} | ||
531 | + | ||
532 | static void sbsa_ref_init(MachineState *machine) | ||
533 | { | ||
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); | ||
126 | } | 548 | } |
127 | 549 | ||
128 | if (!cpu->has_el2) { | 550 | + /* |
129 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) | 551 | + * The Secure view of the world is the same as the NonSecure, |
130 | * registers if we don't have EL2. These are id_pfr1[15:12] and | 552 | + * but with a few extra devices. Create it as a container region |
131 | * id_aa64pfr0_el1[11:8]. | 553 | + * containing the system memory at low priority; any secure-only |
132 | */ | 554 | + * devices go in at higher priority and take precedence. |
133 | - cpu->id_aa64pfr0 &= ~0xf00; | 555 | + */ |
134 | + cpu->isar.id_aa64pfr0 &= ~0xf00; | 556 | + secure_sysmem = g_new(MemoryRegion, 1); |
135 | cpu->id_pfr1 &= ~0xf000; | 557 | + memory_region_init(secure_sysmem, OBJECT(machine), "secure-memory", |
136 | } | 558 | + UINT64_MAX); |
137 | 559 | + memory_region_add_subregion_overlap(secure_sysmem, 0, sysmem, -1); | |
138 | @@ -XXX,XX +XXX,XX @@ static void arm1136_r2_initfn(Object *obj) | 560 | + |
139 | set_feature(&cpu->env, ARM_FEATURE_CACHE_BLOCK_OPS); | 561 | + firmware_loaded = sbsa_firmware_init(sms, sysmem, |
140 | cpu->midr = 0x4107b362; | 562 | + secure_sysmem ?: sysmem); |
141 | cpu->reset_fpsid = 0x410120b4; | 563 | + |
142 | - cpu->mvfr0 = 0x11111111; | 564 | + if (machine->kernel_filename && firmware_loaded) { |
143 | - cpu->mvfr1 = 0x00000000; | 565 | + error_report("sbsa-ref: No fw_cfg device on this machine, " |
144 | + cpu->isar.mvfr0 = 0x11111111; | 566 | + "so -kernel option is not supported when firmware loaded, " |
145 | + cpu->isar.mvfr1 = 0x00000000; | 567 | + "please load OS from hard disk instead"); |
146 | cpu->ctr = 0x1dd20d2; | 568 | + exit(1); |
147 | cpu->reset_sctlr = 0x00050078; | 569 | + } |
148 | cpu->id_pfr0 = 0x111; | 570 | + |
149 | @@ -XXX,XX +XXX,XX @@ static void arm1136_r2_initfn(Object *obj) | 571 | /* |
150 | cpu->id_mmfr0 = 0x01130003; | 572 | * This machine has EL3 enabled, external firmware should supply PSCI |
151 | cpu->id_mmfr1 = 0x10030302; | 573 | * implementation, so the QEMU's internal PSCI is disabled. |
152 | cpu->id_mmfr2 = 0x01222110; | 574 | @@ -XXX,XX +XXX,XX @@ static void sbsa_ref_init(MachineState *machine) |
153 | - cpu->id_isar0 = 0x00140011; | 575 | machine->ram_size); |
154 | - cpu->id_isar1 = 0x12002111; | 576 | memory_region_add_subregion(sysmem, sbsa_ref_memmap[SBSA_MEM].base, ram); |
155 | - cpu->id_isar2 = 0x11231111; | 577 | |
156 | - cpu->id_isar3 = 0x01102131; | 578 | + create_fdt(sms); |
157 | - cpu->id_isar4 = 0x141; | 579 | + |
158 | + cpu->isar.id_isar0 = 0x00140011; | 580 | + create_secure_ram(sms, secure_sysmem); |
159 | + cpu->isar.id_isar1 = 0x12002111; | 581 | + |
160 | + cpu->isar.id_isar2 = 0x11231111; | 582 | + create_gic(sms, pic); |
161 | + cpu->isar.id_isar3 = 0x01102131; | 583 | + |
162 | + cpu->isar.id_isar4 = 0x141; | 584 | + create_uart(sms, pic, SBSA_UART, sysmem, serial_hd(0)); |
163 | cpu->reset_auxcr = 7; | 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); | ||
164 | } | 607 | } |
165 | 608 | ||
166 | @@ -XXX,XX +XXX,XX @@ static void arm1136_initfn(Object *obj) | 609 | @@ -XXX,XX +XXX,XX @@ sbsa_ref_get_default_cpu_node_id(const MachineState *ms, int idx) |
167 | set_feature(&cpu->env, ARM_FEATURE_CACHE_BLOCK_OPS); | 610 | return idx % nb_numa_nodes; |
168 | cpu->midr = 0x4117b363; | ||
169 | cpu->reset_fpsid = 0x410120b4; | ||
170 | - cpu->mvfr0 = 0x11111111; | ||
171 | - cpu->mvfr1 = 0x00000000; | ||
172 | + cpu->isar.mvfr0 = 0x11111111; | ||
173 | + cpu->isar.mvfr1 = 0x00000000; | ||
174 | cpu->ctr = 0x1dd20d2; | ||
175 | cpu->reset_sctlr = 0x00050078; | ||
176 | cpu->id_pfr0 = 0x111; | ||
177 | @@ -XXX,XX +XXX,XX @@ static void arm1136_initfn(Object *obj) | ||
178 | cpu->id_mmfr0 = 0x01130003; | ||
179 | cpu->id_mmfr1 = 0x10030302; | ||
180 | cpu->id_mmfr2 = 0x01222110; | ||
181 | - cpu->id_isar0 = 0x00140011; | ||
182 | - cpu->id_isar1 = 0x12002111; | ||
183 | - cpu->id_isar2 = 0x11231111; | ||
184 | - cpu->id_isar3 = 0x01102131; | ||
185 | - cpu->id_isar4 = 0x141; | ||
186 | + cpu->isar.id_isar0 = 0x00140011; | ||
187 | + cpu->isar.id_isar1 = 0x12002111; | ||
188 | + cpu->isar.id_isar2 = 0x11231111; | ||
189 | + cpu->isar.id_isar3 = 0x01102131; | ||
190 | + cpu->isar.id_isar4 = 0x141; | ||
191 | cpu->reset_auxcr = 7; | ||
192 | } | 611 | } |
193 | 612 | ||
194 | @@ -XXX,XX +XXX,XX @@ static void arm1176_initfn(Object *obj) | 613 | +static void sbsa_ref_instance_init(Object *obj) |
195 | set_feature(&cpu->env, ARM_FEATURE_EL3); | 614 | +{ |
196 | cpu->midr = 0x410fb767; | 615 | + SBSAMachineState *sms = SBSA_MACHINE(obj); |
197 | cpu->reset_fpsid = 0x410120b5; | 616 | + |
198 | - cpu->mvfr0 = 0x11111111; | 617 | + sbsa_flash_create(sms); |
199 | - cpu->mvfr1 = 0x00000000; | 618 | +} |
200 | + cpu->isar.mvfr0 = 0x11111111; | 619 | + |
201 | + cpu->isar.mvfr1 = 0x00000000; | 620 | static void sbsa_ref_class_init(ObjectClass *oc, void *data) |
202 | cpu->ctr = 0x1dd20d2; | ||
203 | cpu->reset_sctlr = 0x00050078; | ||
204 | cpu->id_pfr0 = 0x111; | ||
205 | @@ -XXX,XX +XXX,XX @@ static void arm1176_initfn(Object *obj) | ||
206 | cpu->id_mmfr0 = 0x01130003; | ||
207 | cpu->id_mmfr1 = 0x10030302; | ||
208 | cpu->id_mmfr2 = 0x01222100; | ||
209 | - cpu->id_isar0 = 0x0140011; | ||
210 | - cpu->id_isar1 = 0x12002111; | ||
211 | - cpu->id_isar2 = 0x11231121; | ||
212 | - cpu->id_isar3 = 0x01102131; | ||
213 | - cpu->id_isar4 = 0x01141; | ||
214 | + cpu->isar.id_isar0 = 0x0140011; | ||
215 | + cpu->isar.id_isar1 = 0x12002111; | ||
216 | + cpu->isar.id_isar2 = 0x11231121; | ||
217 | + cpu->isar.id_isar3 = 0x01102131; | ||
218 | + cpu->isar.id_isar4 = 0x01141; | ||
219 | cpu->reset_auxcr = 7; | ||
220 | } | ||
221 | |||
222 | @@ -XXX,XX +XXX,XX @@ static void arm11mpcore_initfn(Object *obj) | ||
223 | set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS); | ||
224 | cpu->midr = 0x410fb022; | ||
225 | cpu->reset_fpsid = 0x410120b4; | ||
226 | - cpu->mvfr0 = 0x11111111; | ||
227 | - cpu->mvfr1 = 0x00000000; | ||
228 | + cpu->isar.mvfr0 = 0x11111111; | ||
229 | + cpu->isar.mvfr1 = 0x00000000; | ||
230 | cpu->ctr = 0x1d192992; /* 32K icache 32K dcache */ | ||
231 | cpu->id_pfr0 = 0x111; | ||
232 | cpu->id_pfr1 = 0x1; | ||
233 | @@ -XXX,XX +XXX,XX @@ static void arm11mpcore_initfn(Object *obj) | ||
234 | cpu->id_mmfr0 = 0x01100103; | ||
235 | cpu->id_mmfr1 = 0x10020302; | ||
236 | cpu->id_mmfr2 = 0x01222000; | ||
237 | - cpu->id_isar0 = 0x00100011; | ||
238 | - cpu->id_isar1 = 0x12002111; | ||
239 | - cpu->id_isar2 = 0x11221011; | ||
240 | - cpu->id_isar3 = 0x01102131; | ||
241 | - cpu->id_isar4 = 0x141; | ||
242 | + cpu->isar.id_isar0 = 0x00100011; | ||
243 | + cpu->isar.id_isar1 = 0x12002111; | ||
244 | + cpu->isar.id_isar2 = 0x11221011; | ||
245 | + cpu->isar.id_isar3 = 0x01102131; | ||
246 | + cpu->isar.id_isar4 = 0x141; | ||
247 | cpu->reset_auxcr = 1; | ||
248 | } | ||
249 | |||
250 | @@ -XXX,XX +XXX,XX @@ static void cortex_m3_initfn(Object *obj) | ||
251 | cpu->id_mmfr1 = 0x00000000; | ||
252 | cpu->id_mmfr2 = 0x00000000; | ||
253 | cpu->id_mmfr3 = 0x00000000; | ||
254 | - cpu->id_isar0 = 0x01141110; | ||
255 | - cpu->id_isar1 = 0x02111000; | ||
256 | - cpu->id_isar2 = 0x21112231; | ||
257 | - cpu->id_isar3 = 0x01111110; | ||
258 | - cpu->id_isar4 = 0x01310102; | ||
259 | - cpu->id_isar5 = 0x00000000; | ||
260 | - cpu->id_isar6 = 0x00000000; | ||
261 | + cpu->isar.id_isar0 = 0x01141110; | ||
262 | + cpu->isar.id_isar1 = 0x02111000; | ||
263 | + cpu->isar.id_isar2 = 0x21112231; | ||
264 | + cpu->isar.id_isar3 = 0x01111110; | ||
265 | + cpu->isar.id_isar4 = 0x01310102; | ||
266 | + cpu->isar.id_isar5 = 0x00000000; | ||
267 | + cpu->isar.id_isar6 = 0x00000000; | ||
268 | } | ||
269 | |||
270 | static void cortex_m4_initfn(Object *obj) | ||
271 | @@ -XXX,XX +XXX,XX @@ static void cortex_m4_initfn(Object *obj) | ||
272 | cpu->id_mmfr1 = 0x00000000; | ||
273 | cpu->id_mmfr2 = 0x00000000; | ||
274 | cpu->id_mmfr3 = 0x00000000; | ||
275 | - cpu->id_isar0 = 0x01141110; | ||
276 | - cpu->id_isar1 = 0x02111000; | ||
277 | - cpu->id_isar2 = 0x21112231; | ||
278 | - cpu->id_isar3 = 0x01111110; | ||
279 | - cpu->id_isar4 = 0x01310102; | ||
280 | - cpu->id_isar5 = 0x00000000; | ||
281 | - cpu->id_isar6 = 0x00000000; | ||
282 | + cpu->isar.id_isar0 = 0x01141110; | ||
283 | + cpu->isar.id_isar1 = 0x02111000; | ||
284 | + cpu->isar.id_isar2 = 0x21112231; | ||
285 | + cpu->isar.id_isar3 = 0x01111110; | ||
286 | + cpu->isar.id_isar4 = 0x01310102; | ||
287 | + cpu->isar.id_isar5 = 0x00000000; | ||
288 | + cpu->isar.id_isar6 = 0x00000000; | ||
289 | } | ||
290 | |||
291 | static void cortex_m33_initfn(Object *obj) | ||
292 | @@ -XXX,XX +XXX,XX @@ static void cortex_m33_initfn(Object *obj) | ||
293 | cpu->id_mmfr1 = 0x00000000; | ||
294 | cpu->id_mmfr2 = 0x01000000; | ||
295 | cpu->id_mmfr3 = 0x00000000; | ||
296 | - cpu->id_isar0 = 0x01101110; | ||
297 | - cpu->id_isar1 = 0x02212000; | ||
298 | - cpu->id_isar2 = 0x20232232; | ||
299 | - cpu->id_isar3 = 0x01111131; | ||
300 | - cpu->id_isar4 = 0x01310132; | ||
301 | - cpu->id_isar5 = 0x00000000; | ||
302 | - cpu->id_isar6 = 0x00000000; | ||
303 | + cpu->isar.id_isar0 = 0x01101110; | ||
304 | + cpu->isar.id_isar1 = 0x02212000; | ||
305 | + cpu->isar.id_isar2 = 0x20232232; | ||
306 | + cpu->isar.id_isar3 = 0x01111131; | ||
307 | + cpu->isar.id_isar4 = 0x01310132; | ||
308 | + cpu->isar.id_isar5 = 0x00000000; | ||
309 | + cpu->isar.id_isar6 = 0x00000000; | ||
310 | cpu->clidr = 0x00000000; | ||
311 | cpu->ctr = 0x8000c000; | ||
312 | } | ||
313 | @@ -XXX,XX +XXX,XX @@ static void cortex_r5_initfn(Object *obj) | ||
314 | cpu->id_mmfr1 = 0x00000000; | ||
315 | cpu->id_mmfr2 = 0x01200000; | ||
316 | cpu->id_mmfr3 = 0x0211; | ||
317 | - cpu->id_isar0 = 0x02101111; | ||
318 | - cpu->id_isar1 = 0x13112111; | ||
319 | - cpu->id_isar2 = 0x21232141; | ||
320 | - cpu->id_isar3 = 0x01112131; | ||
321 | - cpu->id_isar4 = 0x0010142; | ||
322 | - cpu->id_isar5 = 0x0; | ||
323 | - cpu->id_isar6 = 0x0; | ||
324 | + cpu->isar.id_isar0 = 0x02101111; | ||
325 | + cpu->isar.id_isar1 = 0x13112111; | ||
326 | + cpu->isar.id_isar2 = 0x21232141; | ||
327 | + cpu->isar.id_isar3 = 0x01112131; | ||
328 | + cpu->isar.id_isar4 = 0x0010142; | ||
329 | + cpu->isar.id_isar5 = 0x0; | ||
330 | + cpu->isar.id_isar6 = 0x0; | ||
331 | cpu->mp_is_up = true; | ||
332 | cpu->pmsav7_dregion = 16; | ||
333 | define_arm_cp_regs(cpu, cortexr5_cp_reginfo); | ||
334 | @@ -XXX,XX +XXX,XX @@ static void cortex_a8_initfn(Object *obj) | ||
335 | set_feature(&cpu->env, ARM_FEATURE_EL3); | ||
336 | cpu->midr = 0x410fc080; | ||
337 | cpu->reset_fpsid = 0x410330c0; | ||
338 | - cpu->mvfr0 = 0x11110222; | ||
339 | - cpu->mvfr1 = 0x00011111; | ||
340 | + cpu->isar.mvfr0 = 0x11110222; | ||
341 | + cpu->isar.mvfr1 = 0x00011111; | ||
342 | cpu->ctr = 0x82048004; | ||
343 | cpu->reset_sctlr = 0x00c50078; | ||
344 | cpu->id_pfr0 = 0x1031; | ||
345 | @@ -XXX,XX +XXX,XX @@ static void cortex_a8_initfn(Object *obj) | ||
346 | cpu->id_mmfr1 = 0x20000000; | ||
347 | cpu->id_mmfr2 = 0x01202000; | ||
348 | cpu->id_mmfr3 = 0x11; | ||
349 | - cpu->id_isar0 = 0x00101111; | ||
350 | - cpu->id_isar1 = 0x12112111; | ||
351 | - cpu->id_isar2 = 0x21232031; | ||
352 | - cpu->id_isar3 = 0x11112131; | ||
353 | - cpu->id_isar4 = 0x00111142; | ||
354 | + cpu->isar.id_isar0 = 0x00101111; | ||
355 | + cpu->isar.id_isar1 = 0x12112111; | ||
356 | + cpu->isar.id_isar2 = 0x21232031; | ||
357 | + cpu->isar.id_isar3 = 0x11112131; | ||
358 | + cpu->isar.id_isar4 = 0x00111142; | ||
359 | cpu->dbgdidr = 0x15141000; | ||
360 | cpu->clidr = (1 << 27) | (2 << 24) | 3; | ||
361 | cpu->ccsidr[0] = 0xe007e01a; /* 16k L1 dcache. */ | ||
362 | @@ -XXX,XX +XXX,XX @@ static void cortex_a9_initfn(Object *obj) | ||
363 | set_feature(&cpu->env, ARM_FEATURE_CBAR); | ||
364 | cpu->midr = 0x410fc090; | ||
365 | cpu->reset_fpsid = 0x41033090; | ||
366 | - cpu->mvfr0 = 0x11110222; | ||
367 | - cpu->mvfr1 = 0x01111111; | ||
368 | + cpu->isar.mvfr0 = 0x11110222; | ||
369 | + cpu->isar.mvfr1 = 0x01111111; | ||
370 | cpu->ctr = 0x80038003; | ||
371 | cpu->reset_sctlr = 0x00c50078; | ||
372 | cpu->id_pfr0 = 0x1031; | ||
373 | @@ -XXX,XX +XXX,XX @@ static void cortex_a9_initfn(Object *obj) | ||
374 | cpu->id_mmfr1 = 0x20000000; | ||
375 | cpu->id_mmfr2 = 0x01230000; | ||
376 | cpu->id_mmfr3 = 0x00002111; | ||
377 | - cpu->id_isar0 = 0x00101111; | ||
378 | - cpu->id_isar1 = 0x13112111; | ||
379 | - cpu->id_isar2 = 0x21232041; | ||
380 | - cpu->id_isar3 = 0x11112131; | ||
381 | - cpu->id_isar4 = 0x00111142; | ||
382 | + cpu->isar.id_isar0 = 0x00101111; | ||
383 | + cpu->isar.id_isar1 = 0x13112111; | ||
384 | + cpu->isar.id_isar2 = 0x21232041; | ||
385 | + cpu->isar.id_isar3 = 0x11112131; | ||
386 | + cpu->isar.id_isar4 = 0x00111142; | ||
387 | cpu->dbgdidr = 0x35141000; | ||
388 | cpu->clidr = (1 << 27) | (1 << 24) | 3; | ||
389 | cpu->ccsidr[0] = 0xe00fe019; /* 16k L1 dcache. */ | ||
390 | @@ -XXX,XX +XXX,XX @@ static void cortex_a7_initfn(Object *obj) | ||
391 | cpu->kvm_target = QEMU_KVM_ARM_TARGET_CORTEX_A7; | ||
392 | cpu->midr = 0x410fc075; | ||
393 | cpu->reset_fpsid = 0x41023075; | ||
394 | - cpu->mvfr0 = 0x10110222; | ||
395 | - cpu->mvfr1 = 0x11111111; | ||
396 | + cpu->isar.mvfr0 = 0x10110222; | ||
397 | + cpu->isar.mvfr1 = 0x11111111; | ||
398 | cpu->ctr = 0x84448003; | ||
399 | cpu->reset_sctlr = 0x00c50078; | ||
400 | cpu->id_pfr0 = 0x00001131; | ||
401 | @@ -XXX,XX +XXX,XX @@ static void cortex_a7_initfn(Object *obj) | ||
402 | /* a7_mpcore_r0p5_trm, page 4-4 gives 0x01101110; but | ||
403 | * table 4-41 gives 0x02101110, which includes the arm div insns. | ||
404 | */ | ||
405 | - cpu->id_isar0 = 0x02101110; | ||
406 | - cpu->id_isar1 = 0x13112111; | ||
407 | - cpu->id_isar2 = 0x21232041; | ||
408 | - cpu->id_isar3 = 0x11112131; | ||
409 | - cpu->id_isar4 = 0x10011142; | ||
410 | + cpu->isar.id_isar0 = 0x02101110; | ||
411 | + cpu->isar.id_isar1 = 0x13112111; | ||
412 | + cpu->isar.id_isar2 = 0x21232041; | ||
413 | + cpu->isar.id_isar3 = 0x11112131; | ||
414 | + cpu->isar.id_isar4 = 0x10011142; | ||
415 | cpu->dbgdidr = 0x3515f005; | ||
416 | cpu->clidr = 0x0a200023; | ||
417 | cpu->ccsidr[0] = 0x701fe00a; /* 32K L1 dcache */ | ||
418 | @@ -XXX,XX +XXX,XX @@ static void cortex_a15_initfn(Object *obj) | ||
419 | cpu->kvm_target = QEMU_KVM_ARM_TARGET_CORTEX_A15; | ||
420 | cpu->midr = 0x412fc0f1; | ||
421 | cpu->reset_fpsid = 0x410430f0; | ||
422 | - cpu->mvfr0 = 0x10110222; | ||
423 | - cpu->mvfr1 = 0x11111111; | ||
424 | + cpu->isar.mvfr0 = 0x10110222; | ||
425 | + cpu->isar.mvfr1 = 0x11111111; | ||
426 | cpu->ctr = 0x8444c004; | ||
427 | cpu->reset_sctlr = 0x00c50078; | ||
428 | cpu->id_pfr0 = 0x00001131; | ||
429 | @@ -XXX,XX +XXX,XX @@ static void cortex_a15_initfn(Object *obj) | ||
430 | cpu->id_mmfr1 = 0x20000000; | ||
431 | cpu->id_mmfr2 = 0x01240000; | ||
432 | cpu->id_mmfr3 = 0x02102211; | ||
433 | - cpu->id_isar0 = 0x02101110; | ||
434 | - cpu->id_isar1 = 0x13112111; | ||
435 | - cpu->id_isar2 = 0x21232041; | ||
436 | - cpu->id_isar3 = 0x11112131; | ||
437 | - cpu->id_isar4 = 0x10011142; | ||
438 | + cpu->isar.id_isar0 = 0x02101110; | ||
439 | + cpu->isar.id_isar1 = 0x13112111; | ||
440 | + cpu->isar.id_isar2 = 0x21232041; | ||
441 | + cpu->isar.id_isar3 = 0x11112131; | ||
442 | + cpu->isar.id_isar4 = 0x10011142; | ||
443 | cpu->dbgdidr = 0x3515f021; | ||
444 | cpu->clidr = 0x0a200023; | ||
445 | cpu->ccsidr[0] = 0x701fe00a; /* 32K L1 dcache */ | ||
446 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | ||
447 | index XXXXXXX..XXXXXXX 100644 | ||
448 | --- a/target/arm/cpu64.c | ||
449 | +++ b/target/arm/cpu64.c | ||
450 | @@ -XXX,XX +XXX,XX @@ static void aarch64_a57_initfn(Object *obj) | ||
451 | cpu->midr = 0x411fd070; | ||
452 | cpu->revidr = 0x00000000; | ||
453 | cpu->reset_fpsid = 0x41034070; | ||
454 | - cpu->mvfr0 = 0x10110222; | ||
455 | - cpu->mvfr1 = 0x12111111; | ||
456 | - cpu->mvfr2 = 0x00000043; | ||
457 | + cpu->isar.mvfr0 = 0x10110222; | ||
458 | + cpu->isar.mvfr1 = 0x12111111; | ||
459 | + cpu->isar.mvfr2 = 0x00000043; | ||
460 | cpu->ctr = 0x8444c004; | ||
461 | cpu->reset_sctlr = 0x00c50838; | ||
462 | cpu->id_pfr0 = 0x00000131; | ||
463 | @@ -XXX,XX +XXX,XX @@ static void aarch64_a57_initfn(Object *obj) | ||
464 | cpu->id_mmfr1 = 0x40000000; | ||
465 | cpu->id_mmfr2 = 0x01260000; | ||
466 | cpu->id_mmfr3 = 0x02102211; | ||
467 | - cpu->id_isar0 = 0x02101110; | ||
468 | - cpu->id_isar1 = 0x13112111; | ||
469 | - cpu->id_isar2 = 0x21232042; | ||
470 | - cpu->id_isar3 = 0x01112131; | ||
471 | - cpu->id_isar4 = 0x00011142; | ||
472 | - cpu->id_isar5 = 0x00011121; | ||
473 | - cpu->id_isar6 = 0; | ||
474 | - cpu->id_aa64pfr0 = 0x00002222; | ||
475 | + cpu->isar.id_isar0 = 0x02101110; | ||
476 | + cpu->isar.id_isar1 = 0x13112111; | ||
477 | + cpu->isar.id_isar2 = 0x21232042; | ||
478 | + cpu->isar.id_isar3 = 0x01112131; | ||
479 | + cpu->isar.id_isar4 = 0x00011142; | ||
480 | + cpu->isar.id_isar5 = 0x00011121; | ||
481 | + cpu->isar.id_isar6 = 0; | ||
482 | + cpu->isar.id_aa64pfr0 = 0x00002222; | ||
483 | cpu->id_aa64dfr0 = 0x10305106; | ||
484 | cpu->pmceid0 = 0x00000000; | ||
485 | cpu->pmceid1 = 0x00000000; | ||
486 | - cpu->id_aa64isar0 = 0x00011120; | ||
487 | + cpu->isar.id_aa64isar0 = 0x00011120; | ||
488 | cpu->id_aa64mmfr0 = 0x00001124; | ||
489 | cpu->dbgdidr = 0x3516d000; | ||
490 | cpu->clidr = 0x0a200023; | ||
491 | @@ -XXX,XX +XXX,XX @@ static void aarch64_a53_initfn(Object *obj) | ||
492 | cpu->midr = 0x410fd034; | ||
493 | cpu->revidr = 0x00000000; | ||
494 | cpu->reset_fpsid = 0x41034070; | ||
495 | - cpu->mvfr0 = 0x10110222; | ||
496 | - cpu->mvfr1 = 0x12111111; | ||
497 | - cpu->mvfr2 = 0x00000043; | ||
498 | + cpu->isar.mvfr0 = 0x10110222; | ||
499 | + cpu->isar.mvfr1 = 0x12111111; | ||
500 | + cpu->isar.mvfr2 = 0x00000043; | ||
501 | cpu->ctr = 0x84448004; /* L1Ip = VIPT */ | ||
502 | cpu->reset_sctlr = 0x00c50838; | ||
503 | cpu->id_pfr0 = 0x00000131; | ||
504 | @@ -XXX,XX +XXX,XX @@ static void aarch64_a53_initfn(Object *obj) | ||
505 | cpu->id_mmfr1 = 0x40000000; | ||
506 | cpu->id_mmfr2 = 0x01260000; | ||
507 | cpu->id_mmfr3 = 0x02102211; | ||
508 | - cpu->id_isar0 = 0x02101110; | ||
509 | - cpu->id_isar1 = 0x13112111; | ||
510 | - cpu->id_isar2 = 0x21232042; | ||
511 | - cpu->id_isar3 = 0x01112131; | ||
512 | - cpu->id_isar4 = 0x00011142; | ||
513 | - cpu->id_isar5 = 0x00011121; | ||
514 | - cpu->id_isar6 = 0; | ||
515 | - cpu->id_aa64pfr0 = 0x00002222; | ||
516 | + cpu->isar.id_isar0 = 0x02101110; | ||
517 | + cpu->isar.id_isar1 = 0x13112111; | ||
518 | + cpu->isar.id_isar2 = 0x21232042; | ||
519 | + cpu->isar.id_isar3 = 0x01112131; | ||
520 | + cpu->isar.id_isar4 = 0x00011142; | ||
521 | + cpu->isar.id_isar5 = 0x00011121; | ||
522 | + cpu->isar.id_isar6 = 0; | ||
523 | + cpu->isar.id_aa64pfr0 = 0x00002222; | ||
524 | cpu->id_aa64dfr0 = 0x10305106; | ||
525 | - cpu->id_aa64isar0 = 0x00011120; | ||
526 | + cpu->isar.id_aa64isar0 = 0x00011120; | ||
527 | cpu->id_aa64mmfr0 = 0x00001122; /* 40 bit physical addr */ | ||
528 | cpu->dbgdidr = 0x3516d000; | ||
529 | cpu->clidr = 0x0a200023; | ||
530 | @@ -XXX,XX +XXX,XX @@ static void aarch64_a72_initfn(Object *obj) | ||
531 | cpu->midr = 0x410fd083; | ||
532 | cpu->revidr = 0x00000000; | ||
533 | cpu->reset_fpsid = 0x41034080; | ||
534 | - cpu->mvfr0 = 0x10110222; | ||
535 | - cpu->mvfr1 = 0x12111111; | ||
536 | - cpu->mvfr2 = 0x00000043; | ||
537 | + cpu->isar.mvfr0 = 0x10110222; | ||
538 | + cpu->isar.mvfr1 = 0x12111111; | ||
539 | + cpu->isar.mvfr2 = 0x00000043; | ||
540 | cpu->ctr = 0x8444c004; | ||
541 | cpu->reset_sctlr = 0x00c50838; | ||
542 | cpu->id_pfr0 = 0x00000131; | ||
543 | @@ -XXX,XX +XXX,XX @@ static void aarch64_a72_initfn(Object *obj) | ||
544 | cpu->id_mmfr1 = 0x40000000; | ||
545 | cpu->id_mmfr2 = 0x01260000; | ||
546 | cpu->id_mmfr3 = 0x02102211; | ||
547 | - cpu->id_isar0 = 0x02101110; | ||
548 | - cpu->id_isar1 = 0x13112111; | ||
549 | - cpu->id_isar2 = 0x21232042; | ||
550 | - cpu->id_isar3 = 0x01112131; | ||
551 | - cpu->id_isar4 = 0x00011142; | ||
552 | - cpu->id_isar5 = 0x00011121; | ||
553 | - cpu->id_aa64pfr0 = 0x00002222; | ||
554 | + cpu->isar.id_isar0 = 0x02101110; | ||
555 | + cpu->isar.id_isar1 = 0x13112111; | ||
556 | + cpu->isar.id_isar2 = 0x21232042; | ||
557 | + cpu->isar.id_isar3 = 0x01112131; | ||
558 | + cpu->isar.id_isar4 = 0x00011142; | ||
559 | + cpu->isar.id_isar5 = 0x00011121; | ||
560 | + cpu->isar.id_aa64pfr0 = 0x00002222; | ||
561 | cpu->id_aa64dfr0 = 0x10305106; | ||
562 | cpu->pmceid0 = 0x00000000; | ||
563 | cpu->pmceid1 = 0x00000000; | ||
564 | - cpu->id_aa64isar0 = 0x00011120; | ||
565 | + cpu->isar.id_aa64isar0 = 0x00011120; | ||
566 | cpu->id_aa64mmfr0 = 0x00001124; | ||
567 | cpu->dbgdidr = 0x3516d000; | ||
568 | cpu->clidr = 0x0a200023; | ||
569 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
570 | index XXXXXXX..XXXXXXX 100644 | ||
571 | --- a/target/arm/helper.c | ||
572 | +++ b/target/arm/helper.c | ||
573 | @@ -XXX,XX +XXX,XX @@ static uint64_t id_pfr1_read(CPUARMState *env, const ARMCPRegInfo *ri) | ||
574 | static uint64_t id_aa64pfr0_read(CPUARMState *env, const ARMCPRegInfo *ri) | ||
575 | { | 621 | { |
576 | ARMCPU *cpu = arm_env_get_cpu(env); | 622 | MachineClass *mc = MACHINE_CLASS(oc); |
577 | - uint64_t pfr0 = cpu->id_aa64pfr0; | 623 | @@ -XXX,XX +XXX,XX @@ static void sbsa_ref_class_init(ObjectClass *oc, void *data) |
578 | + uint64_t pfr0 = cpu->isar.id_aa64pfr0; | 624 | static const TypeInfo sbsa_ref_info = { |
579 | 625 | .name = TYPE_SBSA_MACHINE, | |
580 | if (env->gicv3state) { | 626 | .parent = TYPE_MACHINE, |
581 | pfr0 |= 1 << 24; | 627 | + .instance_init = sbsa_ref_instance_init, |
582 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | 628 | .class_init = sbsa_ref_class_init, |
583 | { .name = "ID_ISAR0", .state = ARM_CP_STATE_BOTH, | 629 | .instance_size = sizeof(SBSAMachineState), |
584 | .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 2, .opc2 = 0, | 630 | }; |
585 | .access = PL1_R, .type = ARM_CP_CONST, | ||
586 | - .resetvalue = cpu->id_isar0 }, | ||
587 | + .resetvalue = cpu->isar.id_isar0 }, | ||
588 | { .name = "ID_ISAR1", .state = ARM_CP_STATE_BOTH, | ||
589 | .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 2, .opc2 = 1, | ||
590 | .access = PL1_R, .type = ARM_CP_CONST, | ||
591 | - .resetvalue = cpu->id_isar1 }, | ||
592 | + .resetvalue = cpu->isar.id_isar1 }, | ||
593 | { .name = "ID_ISAR2", .state = ARM_CP_STATE_BOTH, | ||
594 | .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 2, .opc2 = 2, | ||
595 | .access = PL1_R, .type = ARM_CP_CONST, | ||
596 | - .resetvalue = cpu->id_isar2 }, | ||
597 | + .resetvalue = cpu->isar.id_isar2 }, | ||
598 | { .name = "ID_ISAR3", .state = ARM_CP_STATE_BOTH, | ||
599 | .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 2, .opc2 = 3, | ||
600 | .access = PL1_R, .type = ARM_CP_CONST, | ||
601 | - .resetvalue = cpu->id_isar3 }, | ||
602 | + .resetvalue = cpu->isar.id_isar3 }, | ||
603 | { .name = "ID_ISAR4", .state = ARM_CP_STATE_BOTH, | ||
604 | .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 2, .opc2 = 4, | ||
605 | .access = PL1_R, .type = ARM_CP_CONST, | ||
606 | - .resetvalue = cpu->id_isar4 }, | ||
607 | + .resetvalue = cpu->isar.id_isar4 }, | ||
608 | { .name = "ID_ISAR5", .state = ARM_CP_STATE_BOTH, | ||
609 | .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 2, .opc2 = 5, | ||
610 | .access = PL1_R, .type = ARM_CP_CONST, | ||
611 | - .resetvalue = cpu->id_isar5 }, | ||
612 | + .resetvalue = cpu->isar.id_isar5 }, | ||
613 | { .name = "ID_MMFR4", .state = ARM_CP_STATE_BOTH, | ||
614 | .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 2, .opc2 = 6, | ||
615 | .access = PL1_R, .type = ARM_CP_CONST, | ||
616 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
617 | { .name = "ID_ISAR6", .state = ARM_CP_STATE_BOTH, | ||
618 | .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 2, .opc2 = 7, | ||
619 | .access = PL1_R, .type = ARM_CP_CONST, | ||
620 | - .resetvalue = cpu->id_isar6 }, | ||
621 | + .resetvalue = cpu->isar.id_isar6 }, | ||
622 | REGINFO_SENTINEL | ||
623 | }; | ||
624 | define_arm_cp_regs(cpu, v6_idregs); | ||
625 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
626 | { .name = "ID_AA64PFR1_EL1", .state = ARM_CP_STATE_AA64, | ||
627 | .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 4, .opc2 = 1, | ||
628 | .access = PL1_R, .type = ARM_CP_CONST, | ||
629 | - .resetvalue = cpu->id_aa64pfr1}, | ||
630 | + .resetvalue = cpu->isar.id_aa64pfr1}, | ||
631 | { .name = "ID_AA64PFR2_EL1_RESERVED", .state = ARM_CP_STATE_AA64, | ||
632 | .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 4, .opc2 = 2, | ||
633 | .access = PL1_R, .type = ARM_CP_CONST, | ||
634 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
635 | { .name = "ID_AA64ISAR0_EL1", .state = ARM_CP_STATE_AA64, | ||
636 | .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 6, .opc2 = 0, | ||
637 | .access = PL1_R, .type = ARM_CP_CONST, | ||
638 | - .resetvalue = cpu->id_aa64isar0 }, | ||
639 | + .resetvalue = cpu->isar.id_aa64isar0 }, | ||
640 | { .name = "ID_AA64ISAR1_EL1", .state = ARM_CP_STATE_AA64, | ||
641 | .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 6, .opc2 = 1, | ||
642 | .access = PL1_R, .type = ARM_CP_CONST, | ||
643 | - .resetvalue = cpu->id_aa64isar1 }, | ||
644 | + .resetvalue = cpu->isar.id_aa64isar1 }, | ||
645 | { .name = "ID_AA64ISAR2_EL1_RESERVED", .state = ARM_CP_STATE_AA64, | ||
646 | .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 6, .opc2 = 2, | ||
647 | .access = PL1_R, .type = ARM_CP_CONST, | ||
648 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
649 | { .name = "MVFR0_EL1", .state = ARM_CP_STATE_AA64, | ||
650 | .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 3, .opc2 = 0, | ||
651 | .access = PL1_R, .type = ARM_CP_CONST, | ||
652 | - .resetvalue = cpu->mvfr0 }, | ||
653 | + .resetvalue = cpu->isar.mvfr0 }, | ||
654 | { .name = "MVFR1_EL1", .state = ARM_CP_STATE_AA64, | ||
655 | .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 3, .opc2 = 1, | ||
656 | .access = PL1_R, .type = ARM_CP_CONST, | ||
657 | - .resetvalue = cpu->mvfr1 }, | ||
658 | + .resetvalue = cpu->isar.mvfr1 }, | ||
659 | { .name = "MVFR2_EL1", .state = ARM_CP_STATE_AA64, | ||
660 | .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 3, .opc2 = 2, | ||
661 | .access = PL1_R, .type = ARM_CP_CONST, | ||
662 | - .resetvalue = cpu->mvfr2 }, | ||
663 | + .resetvalue = cpu->isar.mvfr2 }, | ||
664 | { .name = "MVFR3_EL1_RESERVED", .state = ARM_CP_STATE_AA64, | ||
665 | .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 3, .opc2 = 3, | ||
666 | .access = PL1_R, .type = ARM_CP_CONST, | ||
667 | -- | 631 | -- |
668 | 2.19.1 | 632 | 2.20.1 |
669 | 633 | ||
670 | 634 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 3 | Group Aarch64 rules together, TCG related ones at the bottom. |
4 | Message-id: 20181011205206.3552-8-richard.henderson@linaro.org | 4 | This will help when restricting TCG-only objects. |
5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 5 | |
6 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
7 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
8 | Message-id: 20190701132516.26392-2-philmd@redhat.com | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | --- | 10 | --- |
8 | target/arm/translate.c | 67 ++++++++++++++++++++++++------------------ | 11 | target/arm/Makefile.objs | 5 +++-- |
9 | 1 file changed, 39 insertions(+), 28 deletions(-) | 12 | 1 file changed, 3 insertions(+), 2 deletions(-) |
10 | 13 | ||
11 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 14 | diff --git a/target/arm/Makefile.objs b/target/arm/Makefile.objs |
12 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/target/arm/translate.c | 16 | --- a/target/arm/Makefile.objs |
14 | +++ b/target/arm/translate.c | 17 | +++ b/target/arm/Makefile.objs |
15 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | 18 | @@ -XXX,XX +XXX,XX @@ obj-$(call lnot,$(CONFIG_KVM)) += kvm-stub.o |
16 | return 1; | 19 | obj-y += translate.o op_helper.o helper.o cpu.o |
17 | } | 20 | obj-y += neon_helper.o iwmmxt_helper.o vec_helper.o vfp_helper.o |
18 | } else { /* (insn & 0x00380080) == 0 */ | 21 | obj-y += gdbstub.o |
19 | - int invert; | 22 | -obj-$(TARGET_AARCH64) += cpu64.o translate-a64.o helper-a64.o gdbstub64.o |
20 | + int invert, reg_ofs, vec_size; | 23 | -obj-$(TARGET_AARCH64) += pauth_helper.o |
21 | + | 24 | +obj-$(TARGET_AARCH64) += cpu64.o gdbstub64.o |
22 | if (q && (rd & 1)) { | 25 | obj-y += crypto_helper.o |
23 | return 1; | 26 | obj-$(CONFIG_SOFTMMU) += arm-powerctl.o |
24 | } | 27 | |
25 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | 28 | @@ -XXX,XX +XXX,XX @@ target/arm/translate-sve.o: target/arm/decode-sve.inc.c |
26 | break; | 29 | target/arm/translate.o: target/arm/decode-vfp.inc.c |
27 | case 14: | 30 | target/arm/translate.o: target/arm/decode-vfp-uncond.inc.c |
28 | imm |= (imm << 8) | (imm << 16) | (imm << 24); | 31 | |
29 | - if (invert) | 32 | +obj-$(TARGET_AARCH64) += translate-a64.o helper-a64.o |
30 | + if (invert) { | 33 | obj-$(TARGET_AARCH64) += translate-sve.o sve_helper.o |
31 | imm = ~imm; | 34 | +obj-$(TARGET_AARCH64) += pauth_helper.o |
32 | + } | ||
33 | break; | ||
34 | case 15: | ||
35 | if (invert) { | ||
36 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
37 | | ((imm & 0x40) ? (0x1f << 25) : (1 << 30)); | ||
38 | break; | ||
39 | } | ||
40 | - if (invert) | ||
41 | + if (invert) { | ||
42 | imm = ~imm; | ||
43 | + } | ||
44 | |||
45 | - for (pass = 0; pass < (q ? 4 : 2); pass++) { | ||
46 | - if (op & 1 && op < 12) { | ||
47 | - tmp = neon_load_reg(rd, pass); | ||
48 | - if (invert) { | ||
49 | - /* The immediate value has already been inverted, so | ||
50 | - BIC becomes AND. */ | ||
51 | - tcg_gen_andi_i32(tmp, tmp, imm); | ||
52 | - } else { | ||
53 | - tcg_gen_ori_i32(tmp, tmp, imm); | ||
54 | - } | ||
55 | + reg_ofs = neon_reg_offset(rd, 0); | ||
56 | + vec_size = q ? 16 : 8; | ||
57 | + | ||
58 | + if (op & 1 && op < 12) { | ||
59 | + if (invert) { | ||
60 | + /* The immediate value has already been inverted, | ||
61 | + * so BIC becomes AND. | ||
62 | + */ | ||
63 | + tcg_gen_gvec_andi(MO_32, reg_ofs, reg_ofs, imm, | ||
64 | + vec_size, vec_size); | ||
65 | } else { | ||
66 | - /* VMOV, VMVN. */ | ||
67 | - tmp = tcg_temp_new_i32(); | ||
68 | - if (op == 14 && invert) { | ||
69 | - int n; | ||
70 | - uint32_t val; | ||
71 | - val = 0; | ||
72 | - for (n = 0; n < 4; n++) { | ||
73 | - if (imm & (1 << (n + (pass & 1) * 4))) | ||
74 | - val |= 0xff << (n * 8); | ||
75 | - } | ||
76 | - tcg_gen_movi_i32(tmp, val); | ||
77 | - } else { | ||
78 | - tcg_gen_movi_i32(tmp, imm); | ||
79 | - } | ||
80 | + tcg_gen_gvec_ori(MO_32, reg_ofs, reg_ofs, imm, | ||
81 | + vec_size, vec_size); | ||
82 | + } | ||
83 | + } else { | ||
84 | + /* VMOV, VMVN. */ | ||
85 | + if (op == 14 && invert) { | ||
86 | + TCGv_i64 t64 = tcg_temp_new_i64(); | ||
87 | + | ||
88 | + for (pass = 0; pass <= q; ++pass) { | ||
89 | + uint64_t val = 0; | ||
90 | + int n; | ||
91 | + | ||
92 | + for (n = 0; n < 8; n++) { | ||
93 | + if (imm & (1 << (n + pass * 8))) { | ||
94 | + val |= 0xffull << (n * 8); | ||
95 | + } | ||
96 | + } | ||
97 | + tcg_gen_movi_i64(t64, val); | ||
98 | + neon_store_reg64(t64, rd + pass); | ||
99 | + } | ||
100 | + tcg_temp_free_i64(t64); | ||
101 | + } else { | ||
102 | + tcg_gen_gvec_dup32i(reg_ofs, vec_size, vec_size, imm); | ||
103 | } | ||
104 | - neon_store_reg(rd, pass, tmp); | ||
105 | } | ||
106 | } | ||
107 | } else { /* (insn & 0x00800010 == 0x00800000) */ | ||
108 | -- | 35 | -- |
109 | 2.19.1 | 36 | 2.20.1 |
110 | 37 | ||
111 | 38 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 3 | Group ARM objects together, TCG related ones at the bottom. |
4 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 4 | This will help when restricting TCG-only objects. |
5 | Message-id: 20181011205206.3552-6-richard.henderson@linaro.org | 5 | |
6 | [PMM: drop change to now-deleted cpu_mode_names array] | 6 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> |
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> |
8 | Message-id: 20190701132516.26392-3-philmd@redhat.com | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | --- | 10 | --- |
10 | target/arm/translate.c | 4 ++-- | 11 | target/arm/Makefile.objs | 10 ++++++---- |
11 | 1 file changed, 2 insertions(+), 2 deletions(-) | 12 | 1 file changed, 6 insertions(+), 4 deletions(-) |
12 | 13 | ||
13 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 14 | diff --git a/target/arm/Makefile.objs b/target/arm/Makefile.objs |
14 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/translate.c | 16 | --- a/target/arm/Makefile.objs |
16 | +++ b/target/arm/translate.c | 17 | +++ b/target/arm/Makefile.objs |
17 | @@ -XXX,XX +XXX,XX @@ static TCGv_i64 cpu_F0d, cpu_F1d; | 18 | @@ -XXX,XX +XXX,XX @@ obj-$(CONFIG_KVM) += kvm.o |
18 | 19 | obj-$(call land,$(CONFIG_KVM),$(call lnot,$(TARGET_AARCH64))) += kvm32.o | |
19 | #include "exec/gen-icount.h" | 20 | obj-$(call land,$(CONFIG_KVM),$(TARGET_AARCH64)) += kvm64.o |
20 | 21 | obj-$(call lnot,$(CONFIG_KVM)) += kvm-stub.o | |
21 | -static const char *regnames[] = | 22 | -obj-y += translate.o op_helper.o helper.o cpu.o |
22 | +static const char * const regnames[] = | 23 | -obj-y += neon_helper.o iwmmxt_helper.o vec_helper.o vfp_helper.o |
23 | { "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", | 24 | -obj-y += gdbstub.o |
24 | "r8", "r9", "r10", "r11", "r12", "r13", "r14", "pc" }; | 25 | +obj-y += helper.o vfp_helper.o |
25 | 26 | +obj-y += cpu.o gdbstub.o | |
26 | @@ -XXX,XX +XXX,XX @@ static struct { | 27 | obj-$(TARGET_AARCH64) += cpu64.o gdbstub64.o |
27 | int nregs; | 28 | -obj-y += crypto_helper.o |
28 | int interleave; | 29 | obj-$(CONFIG_SOFTMMU) += arm-powerctl.o |
29 | int spacing; | 30 | |
30 | -} neon_ls_element_type[11] = { | 31 | DECODETREE = $(SRC_PATH)/scripts/decodetree.py |
31 | +} const neon_ls_element_type[11] = { | 32 | @@ -XXX,XX +XXX,XX @@ target/arm/translate-sve.o: target/arm/decode-sve.inc.c |
32 | {4, 4, 1}, | 33 | target/arm/translate.o: target/arm/decode-vfp.inc.c |
33 | {4, 4, 2}, | 34 | target/arm/translate.o: target/arm/decode-vfp-uncond.inc.c |
34 | {4, 1, 1}, | 35 | |
36 | +obj-y += translate.o op_helper.o | ||
37 | +obj-y += crypto_helper.o | ||
38 | +obj-y += iwmmxt_helper.o vec_helper.o neon_helper.o | ||
39 | + | ||
40 | obj-$(TARGET_AARCH64) += translate-a64.o helper-a64.o | ||
41 | obj-$(TARGET_AARCH64) += translate-sve.o sve_helper.o | ||
42 | obj-$(TARGET_AARCH64) += pauth_helper.o | ||
35 | -- | 43 | -- |
36 | 2.19.1 | 44 | 2.20.1 |
37 | 45 | ||
38 | 46 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 3 | Group KVM rules together. |
4 | Message-id: 20181011205206.3552-4-richard.henderson@linaro.org | 4 | |
5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 5 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> |
6 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
7 | Message-id: 20190701132516.26392-4-philmd@redhat.com | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | --- | 9 | --- |
8 | target/arm/translate-a64.c | 28 +++------------------------- | 10 | target/arm/Makefile.objs | 9 +++++---- |
9 | 1 file changed, 3 insertions(+), 25 deletions(-) | 11 | 1 file changed, 5 insertions(+), 4 deletions(-) |
10 | 12 | ||
11 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 13 | diff --git a/target/arm/Makefile.objs b/target/arm/Makefile.objs |
12 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/target/arm/translate-a64.c | 15 | --- a/target/arm/Makefile.objs |
14 | +++ b/target/arm/translate-a64.c | 16 | +++ b/target/arm/Makefile.objs |
15 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_single_struct(DisasContext *s, uint32_t insn) | 17 | @@ -XXX,XX +XXX,XX @@ |
16 | for (xs = 0; xs < selem; xs++) { | 18 | obj-y += arm-semi.o |
17 | if (replicate) { | 19 | obj-$(CONFIG_SOFTMMU) += machine.o psci.o arch_dump.o monitor.o |
18 | /* Load and replicate to all elements */ | 20 | -obj-$(CONFIG_KVM) += kvm.o |
19 | - uint64_t mulconst; | 21 | -obj-$(call land,$(CONFIG_KVM),$(call lnot,$(TARGET_AARCH64))) += kvm32.o |
20 | TCGv_i64 tcg_tmp = tcg_temp_new_i64(); | 22 | -obj-$(call land,$(CONFIG_KVM),$(TARGET_AARCH64)) += kvm64.o |
21 | 23 | -obj-$(call lnot,$(CONFIG_KVM)) += kvm-stub.o | |
22 | tcg_gen_qemu_ld_i64(tcg_tmp, tcg_addr, | 24 | obj-y += helper.o vfp_helper.o |
23 | get_mem_index(s), s->be_data + scale); | 25 | obj-y += cpu.o gdbstub.o |
24 | - switch (scale) { | 26 | obj-$(TARGET_AARCH64) += cpu64.o gdbstub64.o |
25 | - case 0: | 27 | obj-$(CONFIG_SOFTMMU) += arm-powerctl.o |
26 | - mulconst = 0x0101010101010101ULL; | 28 | |
27 | - break; | 29 | +obj-$(CONFIG_KVM) += kvm.o |
28 | - case 1: | 30 | +obj-$(call land,$(CONFIG_KVM),$(call lnot,$(TARGET_AARCH64))) += kvm32.o |
29 | - mulconst = 0x0001000100010001ULL; | 31 | +obj-$(call land,$(CONFIG_KVM),$(TARGET_AARCH64)) += kvm64.o |
30 | - break; | 32 | +obj-$(call lnot,$(CONFIG_KVM)) += kvm-stub.o |
31 | - case 2: | 33 | + |
32 | - mulconst = 0x0000000100000001ULL; | 34 | DECODETREE = $(SRC_PATH)/scripts/decodetree.py |
33 | - break; | 35 | |
34 | - case 3: | 36 | target/arm/decode-sve.inc.c: $(SRC_PATH)/target/arm/sve.decode $(DECODETREE) |
35 | - mulconst = 0; | ||
36 | - break; | ||
37 | - default: | ||
38 | - g_assert_not_reached(); | ||
39 | - } | ||
40 | - if (mulconst) { | ||
41 | - tcg_gen_muli_i64(tcg_tmp, tcg_tmp, mulconst); | ||
42 | - } | ||
43 | - write_vec_element(s, tcg_tmp, rt, 0, MO_64); | ||
44 | - if (is_q) { | ||
45 | - write_vec_element(s, tcg_tmp, rt, 1, MO_64); | ||
46 | - } | ||
47 | + tcg_gen_gvec_dup_i64(scale, vec_full_reg_offset(s, rt), | ||
48 | + (is_q + 1) * 8, vec_full_reg_size(s), | ||
49 | + tcg_tmp); | ||
50 | tcg_temp_free_i64(tcg_tmp); | ||
51 | - clear_vec_high(s, is_q, rt); | ||
52 | } else { | ||
53 | /* Load/store one element per register */ | ||
54 | if (is_load) { | ||
55 | -- | 37 | -- |
56 | 2.19.1 | 38 | 2.20.1 |
57 | 39 | ||
58 | 40 | diff view generated by jsdifflib |
1 | From: Markus Armbruster <armbru@redhat.com> | 1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | Device models aren't supposed to go on fishing expeditions for | 3 | Group SOFTMMU objects together. |
4 | backends. They should expose suitable properties for the user to set. | 4 | Since PSCI is TCG specific, keep it separate. |
5 | For onboard devices, board code sets them. | ||
6 | 5 | ||
7 | Device ssi-sd picks up its block backend in its init() method with | 6 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> |
8 | drive_get_next() instead. This mistake is already marked FIXME since | 7 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> |
9 | commit af9e40a. | 8 | Message-id: 20190701132516.26392-5-philmd@redhat.com |
10 | |||
11 | Unset user_creatable to remove the mistake from our external | ||
12 | interface. Since the SSI bus doesn't support hotplug, only -device | ||
13 | can be affected. Only certain ARM machines have ssi-sd and provide an | ||
14 | SSI bus for it; this patch breaks -device ssi-sd for these machines. | ||
15 | No actual use of -device ssi-sd is known. | ||
16 | |||
17 | Signed-off-by: Markus Armbruster <armbru@redhat.com> | ||
18 | Acked-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
19 | Acked-by: Thomas Huth <thuth@redhat.com> | ||
20 | Message-id: 20181009060835.4608-1-armbru@redhat.com | ||
21 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
22 | --- | 10 | --- |
23 | hw/sd/ssi-sd.c | 2 ++ | 11 | target/arm/Makefile.objs | 5 ++++- |
24 | 1 file changed, 2 insertions(+) | 12 | 1 file changed, 4 insertions(+), 1 deletion(-) |
25 | 13 | ||
26 | diff --git a/hw/sd/ssi-sd.c b/hw/sd/ssi-sd.c | 14 | diff --git a/target/arm/Makefile.objs b/target/arm/Makefile.objs |
27 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
28 | --- a/hw/sd/ssi-sd.c | 16 | --- a/target/arm/Makefile.objs |
29 | +++ b/hw/sd/ssi-sd.c | 17 | +++ b/target/arm/Makefile.objs |
30 | @@ -XXX,XX +XXX,XX @@ static void ssi_sd_class_init(ObjectClass *klass, void *data) | 18 | @@ -XXX,XX +XXX,XX @@ |
31 | k->cs_polarity = SSI_CS_LOW; | 19 | obj-y += arm-semi.o |
32 | dc->vmsd = &vmstate_ssi_sd; | 20 | -obj-$(CONFIG_SOFTMMU) += machine.o psci.o arch_dump.o monitor.o |
33 | dc->reset = ssi_sd_reset; | 21 | obj-y += helper.o vfp_helper.o |
34 | + /* Reason: init() method uses drive_get_next() */ | 22 | obj-y += cpu.o gdbstub.o |
35 | + dc->user_creatable = false; | 23 | obj-$(TARGET_AARCH64) += cpu64.o gdbstub64.o |
36 | } | 24 | + |
37 | 25 | +obj-$(CONFIG_SOFTMMU) += machine.o arch_dump.o monitor.o | |
38 | static const TypeInfo ssi_sd_info = { | 26 | obj-$(CONFIG_SOFTMMU) += arm-powerctl.o |
27 | |||
28 | obj-$(CONFIG_KVM) += kvm.o | ||
29 | @@ -XXX,XX +XXX,XX @@ obj-y += translate.o op_helper.o | ||
30 | obj-y += crypto_helper.o | ||
31 | obj-y += iwmmxt_helper.o vec_helper.o neon_helper.o | ||
32 | |||
33 | +obj-$(CONFIG_SOFTMMU) += psci.o | ||
34 | + | ||
35 | obj-$(TARGET_AARCH64) += translate-a64.o helper-a64.o | ||
36 | obj-$(TARGET_AARCH64) += translate-sve.o sve_helper.o | ||
37 | obj-$(TARGET_AARCH64) += pauth_helper.o | ||
39 | -- | 38 | -- |
40 | 2.19.1 | 39 | 2.20.1 |
41 | 40 | ||
42 | 41 | diff view generated by jsdifflib |
1 | If the HCR_EL2 PTW virtualizaiton configuration register bit | 1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> |
---|---|---|---|
2 | is set, then this means that a stage 2 Permission fault must | ||
3 | be generated if a stage 1 translation table access is made | ||
4 | to an address that is mapped as Device memory in stage 2. | ||
5 | Implement this. | ||
6 | 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 | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20181012144235.19646-8-peter.maydell@linaro.org | ||
10 | --- | 9 | --- |
11 | target/arm/helper.c | 21 ++++++++++++++++++++- | 10 | target/arm/helper.c | 7 +++++++ |
12 | 1 file changed, 20 insertions(+), 1 deletion(-) | 11 | 1 file changed, 7 insertions(+) |
13 | 12 | ||
14 | 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 |
15 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/helper.c | 15 | --- a/target/arm/helper.c |
17 | +++ b/target/arm/helper.c | 16 | +++ b/target/arm/helper.c |
18 | @@ -XXX,XX +XXX,XX @@ static hwaddr S1_ptw_translate(CPUARMState *env, ARMMMUIdx mmu_idx, | 17 | @@ -XXX,XX +XXX,XX @@ |
19 | hwaddr s2pa; | 18 | +/* |
20 | int s2prot; | 19 | + * ARM generic helpers. |
21 | int ret; | 20 | + * |
22 | + ARMCacheAttrs cacheattrs = {}; | 21 | + * This code is licensed under the GNU GPL v2 or later. |
23 | + ARMCacheAttrs *pcacheattrs = NULL; | 22 | + * |
24 | + | 23 | + * SPDX-License-Identifier: GPL-2.0-or-later |
25 | + if (env->cp15.hcr_el2 & HCR_PTW) { | 24 | + */ |
26 | + /* | 25 | #include "qemu/osdep.h" |
27 | + * PTW means we must fault if this S1 walk touches S2 Device | 26 | #include "qemu/units.h" |
28 | + * memory; otherwise we don't care about the attributes and can | 27 | #include "target/arm/idau.h" |
29 | + * save the S2 translation the effort of computing them. | ||
30 | + */ | ||
31 | + pcacheattrs = &cacheattrs; | ||
32 | + } | ||
33 | |||
34 | ret = get_phys_addr_lpae(env, addr, 0, ARMMMUIdx_S2NS, &s2pa, | ||
35 | - &txattrs, &s2prot, &s2size, fi, NULL); | ||
36 | + &txattrs, &s2prot, &s2size, fi, pcacheattrs); | ||
37 | if (ret) { | ||
38 | assert(fi->type != ARMFault_None); | ||
39 | fi->s2addr = addr; | ||
40 | @@ -XXX,XX +XXX,XX @@ static hwaddr S1_ptw_translate(CPUARMState *env, ARMMMUIdx mmu_idx, | ||
41 | fi->s1ptw = true; | ||
42 | return ~0; | ||
43 | } | ||
44 | + if (pcacheattrs && (pcacheattrs->attrs & 0xf0) == 0) { | ||
45 | + /* Access was to Device memory: generate Permission fault */ | ||
46 | + fi->type = ARMFault_Permission; | ||
47 | + fi->s2addr = addr; | ||
48 | + fi->stage2 = true; | ||
49 | + fi->s1ptw = true; | ||
50 | + return ~0; | ||
51 | + } | ||
52 | addr = s2pa; | ||
53 | } | ||
54 | return addr; | ||
55 | -- | 28 | -- |
56 | 2.19.1 | 29 | 2.20.1 |
57 | 30 | ||
58 | 31 | diff view generated by jsdifflib |
1 | The A/I/F bits in ISR_EL1 should track the virtual interrupt | 1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> |
---|---|---|---|
2 | status, not the physical interrupt status, if the associated | ||
3 | HCR_EL2.AMO/IMO/FMO bit is set. Implement this, rather than | ||
4 | always showing the physical interrupt status. | ||
5 | 2 | ||
6 | We don't currently implement anything to do with external | 3 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> |
7 | aborts, so this applies only to the I and F bits (though it | 4 | Message-id: 20190701132516.26392-7-philmd@redhat.com |
8 | ought to be possible for the outer guest to present a virtual | 5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
9 | external abort to the inner guest, even if QEMU doesn't | ||
10 | emulate physical external aborts, so there is missing | ||
11 | functionality in this area). | ||
12 | |||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
15 | Message-id: 20181012144235.19646-6-peter.maydell@linaro.org | ||
16 | --- | 7 | --- |
17 | target/arm/helper.c | 22 ++++++++++++++++++---- | 8 | target/arm/helper.c | 2 -- |
18 | 1 file changed, 18 insertions(+), 4 deletions(-) | 9 | 1 file changed, 2 deletions(-) |
19 | 10 | ||
20 | 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 |
21 | index XXXXXXX..XXXXXXX 100644 | 12 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/target/arm/helper.c | 13 | --- a/target/arm/helper.c |
23 | +++ b/target/arm/helper.c | 14 | +++ b/target/arm/helper.c |
24 | @@ -XXX,XX +XXX,XX @@ static uint64_t isr_read(CPUARMState *env, const ARMCPRegInfo *ri) | 15 | @@ -XXX,XX +XXX,XX @@ |
25 | CPUState *cs = ENV_GET_CPU(env); | 16 | #include "exec/gdbstub.h" |
26 | uint64_t ret = 0; | 17 | #include "exec/helper-proto.h" |
27 | 18 | #include "qemu/host-utils.h" | |
28 | - if (cs->interrupt_request & CPU_INTERRUPT_HARD) { | 19 | -#include "sysemu/arch_init.h" |
29 | - ret |= CPSR_I; | 20 | #include "sysemu/sysemu.h" |
30 | + if (arm_hcr_el2_imo(env)) { | 21 | #include "qemu/bitops.h" |
31 | + if (cs->interrupt_request & CPU_INTERRUPT_VIRQ) { | 22 | #include "qemu/crc32c.h" |
32 | + ret |= CPSR_I; | 23 | @@ -XXX,XX +XXX,XX @@ |
33 | + } | 24 | #include "hw/semihosting/semihost.h" |
34 | + } else { | 25 | #include "sysemu/cpus.h" |
35 | + if (cs->interrupt_request & CPU_INTERRUPT_HARD) { | 26 | #include "sysemu/kvm.h" |
36 | + ret |= CPSR_I; | 27 | -#include "fpu/softfloat.h" |
37 | + } | 28 | #include "qemu/range.h" |
38 | } | 29 | #include "qapi/qapi-commands-target.h" |
39 | - if (cs->interrupt_request & CPU_INTERRUPT_FIQ) { | 30 | #include "qapi/error.h" |
40 | - ret |= CPSR_F; | ||
41 | + | ||
42 | + if (arm_hcr_el2_fmo(env)) { | ||
43 | + if (cs->interrupt_request & CPU_INTERRUPT_VFIQ) { | ||
44 | + ret |= CPSR_F; | ||
45 | + } | ||
46 | + } else { | ||
47 | + if (cs->interrupt_request & CPU_INTERRUPT_FIQ) { | ||
48 | + ret |= CPSR_F; | ||
49 | + } | ||
50 | } | ||
51 | + | ||
52 | /* External aborts are not possible in QEMU so A bit is always clear */ | ||
53 | return ret; | ||
54 | } | ||
55 | -- | 31 | -- |
56 | 2.19.1 | 32 | 2.20.1 |
57 | 33 | ||
58 | 34 | diff view generated by jsdifflib |
1 | The HCR.FB virtualization configuration register bit requests that | 1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> |
---|---|---|---|
2 | TLB maintenance, branch predictor invalidate-all and icache | ||
3 | invalidate-all operations performed in NS EL1 should be upgraded | ||
4 | from "local CPU only to "broadcast within Inner Shareable domain". | ||
5 | For QEMU we NOP the branch predictor and icache operations, so | ||
6 | we only need to upgrade the TLB invalidates: | ||
7 | AArch32 TLBIALL, TLBIMVA, TLBIASID, DTLBIALL, DTLBIMVA, DTLBIASID, | ||
8 | ITLBIALL, ITLBIMVA, ITLBIASID, TLBIMVAA, TLBIMVAL, TLBIMVAAL | ||
9 | AArch64 TLBI VMALLE1, TLBI VAE1, TLBI ASIDE1, TLBI VAAE1, | ||
10 | TLBI VALE1, TLBI VAALE1 | ||
11 | 2 | ||
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 | |||
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 | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
14 | Message-id: 20181012144235.19646-4-peter.maydell@linaro.org | ||
15 | --- | 11 | --- |
16 | target/arm/helper.c | 191 +++++++++++++++++++++++++++----------------- | 12 | target/arm/helper.c | 237 ++++++++++++++++++++++++++-------------- |
17 | 1 file changed, 116 insertions(+), 75 deletions(-) | 13 | target/arm/op_helper.c | 54 ++++++--- |
14 | target/arm/vfp_helper.c | 3 +- | ||
15 | 3 files changed, 196 insertions(+), 98 deletions(-) | ||
18 | 16 | ||
19 | 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 |
20 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/target/arm/helper.c | 19 | --- a/target/arm/helper.c |
22 | +++ b/target/arm/helper.c | 20 | +++ b/target/arm/helper.c |
23 | @@ -XXX,XX +XXX,XX @@ static void contextidr_write(CPUARMState *env, const ARMCPRegInfo *ri, | 21 | @@ -XXX,XX +XXX,XX @@ void HELPER(v7m_vlldm)(CPUARMState *env, uint32_t fptr) |
24 | raw_write(env, ri, value); | 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 | */ | ||
25 | } | 53 | } |
26 | 54 | ||
27 | -static void tlbiall_write(CPUARMState *env, const ARMCPRegInfo *ri, | 55 | -/* Write to v7M CONTROL.SPSEL bit for the specified security bank. |
28 | - uint64_t value) | 56 | +/* |
29 | -{ | 57 | + * Write to v7M CONTROL.SPSEL bit for the specified security bank. |
30 | - /* Invalidate all (TLBIALL) */ | 58 | * This may change the current stack pointer between Main and Process |
31 | - ARMCPU *cpu = arm_env_get_cpu(env); | 59 | * stack pointers if it is done for the CONTROL register for the current |
32 | - | 60 | * security state. |
33 | - tlb_flush(CPU(cpu)); | 61 | @@ -XXX,XX +XXX,XX @@ static void write_v7m_control_spsel_for_secstate(CPUARMState *env, |
34 | -} | 62 | } |
35 | - | ||
36 | -static void tlbimva_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
37 | - uint64_t value) | ||
38 | -{ | ||
39 | - /* Invalidate single TLB entry by MVA and ASID (TLBIMVA) */ | ||
40 | - ARMCPU *cpu = arm_env_get_cpu(env); | ||
41 | - | ||
42 | - tlb_flush_page(CPU(cpu), value & TARGET_PAGE_MASK); | ||
43 | -} | ||
44 | - | ||
45 | -static void tlbiasid_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
46 | - uint64_t value) | ||
47 | -{ | ||
48 | - /* Invalidate by ASID (TLBIASID) */ | ||
49 | - ARMCPU *cpu = arm_env_get_cpu(env); | ||
50 | - | ||
51 | - tlb_flush(CPU(cpu)); | ||
52 | -} | ||
53 | - | ||
54 | -static void tlbimvaa_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
55 | - uint64_t value) | ||
56 | -{ | ||
57 | - /* Invalidate single entry by MVA, all ASIDs (TLBIMVAA) */ | ||
58 | - ARMCPU *cpu = arm_env_get_cpu(env); | ||
59 | - | ||
60 | - tlb_flush_page(CPU(cpu), value & TARGET_PAGE_MASK); | ||
61 | -} | ||
62 | - | ||
63 | /* IS variants of TLB operations must affect all cores */ | ||
64 | static void tlbiall_is_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
65 | uint64_t value) | ||
66 | @@ -XXX,XX +XXX,XX @@ static void tlbimvaa_is_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
67 | tlb_flush_page_all_cpus_synced(cs, value & TARGET_PAGE_MASK); | ||
68 | } | 63 | } |
69 | 64 | ||
65 | -/* Write to v7M CONTROL.SPSEL bit. This may change the current | ||
70 | +/* | 66 | +/* |
71 | + * Non-IS variants of TLB operations are upgraded to | 67 | + * Write to v7M CONTROL.SPSEL bit. This may change the current |
72 | + * IS versions if we are at NS EL1 and HCR_EL2.FB is set to | 68 | * stack pointer between Main and Process stack pointers. |
73 | + * force broadcast of these operations. | ||
74 | + */ | ||
75 | +static bool tlb_force_broadcast(CPUARMState *env) | ||
76 | +{ | ||
77 | + return (env->cp15.hcr_el2 & HCR_FB) && | ||
78 | + arm_current_el(env) == 1 && arm_is_secure_below_el3(env); | ||
79 | +} | ||
80 | + | ||
81 | +static void tlbiall_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
82 | + uint64_t value) | ||
83 | +{ | ||
84 | + /* Invalidate all (TLBIALL) */ | ||
85 | + ARMCPU *cpu = arm_env_get_cpu(env); | ||
86 | + | ||
87 | + if (tlb_force_broadcast(env)) { | ||
88 | + tlbiall_is_write(env, NULL, value); | ||
89 | + return; | ||
90 | + } | ||
91 | + | ||
92 | + tlb_flush(CPU(cpu)); | ||
93 | +} | ||
94 | + | ||
95 | +static void tlbimva_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
96 | + uint64_t value) | ||
97 | +{ | ||
98 | + /* Invalidate single TLB entry by MVA and ASID (TLBIMVA) */ | ||
99 | + ARMCPU *cpu = arm_env_get_cpu(env); | ||
100 | + | ||
101 | + if (tlb_force_broadcast(env)) { | ||
102 | + tlbimva_is_write(env, NULL, value); | ||
103 | + return; | ||
104 | + } | ||
105 | + | ||
106 | + tlb_flush_page(CPU(cpu), value & TARGET_PAGE_MASK); | ||
107 | +} | ||
108 | + | ||
109 | +static void tlbiasid_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
110 | + uint64_t value) | ||
111 | +{ | ||
112 | + /* Invalidate by ASID (TLBIASID) */ | ||
113 | + ARMCPU *cpu = arm_env_get_cpu(env); | ||
114 | + | ||
115 | + if (tlb_force_broadcast(env)) { | ||
116 | + tlbiasid_is_write(env, NULL, value); | ||
117 | + return; | ||
118 | + } | ||
119 | + | ||
120 | + tlb_flush(CPU(cpu)); | ||
121 | +} | ||
122 | + | ||
123 | +static void tlbimvaa_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
124 | + uint64_t value) | ||
125 | +{ | ||
126 | + /* Invalidate single entry by MVA, all ASIDs (TLBIMVAA) */ | ||
127 | + ARMCPU *cpu = arm_env_get_cpu(env); | ||
128 | + | ||
129 | + if (tlb_force_broadcast(env)) { | ||
130 | + tlbimvaa_is_write(env, NULL, value); | ||
131 | + return; | ||
132 | + } | ||
133 | + | ||
134 | + tlb_flush_page(CPU(cpu), value & TARGET_PAGE_MASK); | ||
135 | +} | ||
136 | + | ||
137 | static void tlbiall_nsnh_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
138 | uint64_t value) | ||
139 | { | ||
140 | @@ -XXX,XX +XXX,XX @@ static CPAccessResult aa64_cacheop_access(CPUARMState *env, | ||
141 | * Page D4-1736 (DDI0487A.b) | ||
142 | */ | 69 | */ |
143 | 70 | static void write_v7m_control_spsel(CPUARMState *env, bool new_spsel) | |
144 | -static void tlbi_aa64_vmalle1_write(CPUARMState *env, const ARMCPRegInfo *ri, | 71 | @@ -XXX,XX +XXX,XX @@ static void write_v7m_control_spsel(CPUARMState *env, bool new_spsel) |
145 | - uint64_t value) | 72 | |
146 | -{ | 73 | void write_v7m_exception(CPUARMState *env, uint32_t new_exc) |
147 | - CPUState *cs = ENV_GET_CPU(env); | 74 | { |
148 | - | 75 | - /* Write a new value to v7m.exception, thus transitioning into or out |
149 | - if (arm_is_secure_below_el3(env)) { | 76 | + /* |
150 | - tlb_flush_by_mmuidx(cs, | 77 | + * Write a new value to v7m.exception, thus transitioning into or out |
151 | - ARMMMUIdxBit_S1SE1 | | 78 | * of Handler mode; this may result in a change of active stack pointer. |
152 | - ARMMMUIdxBit_S1SE0); | 79 | */ |
153 | - } else { | 80 | bool new_is_psp, old_is_psp = v7m_using_psp(env); |
154 | - tlb_flush_by_mmuidx(cs, | 81 | @@ -XXX,XX +XXX,XX @@ static void switch_v7m_security_state(CPUARMState *env, bool new_secstate) |
155 | - ARMMMUIdxBit_S12NSE1 | | 82 | return; |
156 | - ARMMMUIdxBit_S12NSE0); | 83 | } |
157 | - } | 84 | |
158 | -} | 85 | - /* All the banked state is accessed by looking at env->v7m.secure |
159 | - | 86 | + /* |
160 | static void tlbi_aa64_vmalle1is_write(CPUARMState *env, const ARMCPRegInfo *ri, | 87 | + * All the banked state is accessed by looking at env->v7m.secure |
161 | uint64_t value) | 88 | * except for the stack pointer; rearrange the SP appropriately. |
162 | { | 89 | */ |
163 | @@ -XXX,XX +XXX,XX @@ static void tlbi_aa64_vmalle1is_write(CPUARMState *env, const ARMCPRegInfo *ri, | 90 | new_ss_msp = env->v7m.other_ss_msp; |
164 | } | 91 | @@ -XXX,XX +XXX,XX @@ static void switch_v7m_security_state(CPUARMState *env, bool new_secstate) |
92 | |||
93 | void HELPER(v7m_bxns)(CPUARMState *env, uint32_t dest) | ||
94 | { | ||
95 | - /* Handle v7M BXNS: | ||
96 | + /* | ||
97 | + * Handle v7M BXNS: | ||
98 | * - if the return value is a magic value, do exception return (like BX) | ||
99 | * - otherwise bit 0 of the return value is the target security state | ||
100 | */ | ||
101 | @@ -XXX,XX +XXX,XX @@ void HELPER(v7m_bxns)(CPUARMState *env, uint32_t dest) | ||
102 | } | ||
103 | |||
104 | if (dest >= min_magic) { | ||
105 | - /* This is an exception return magic value; put it where | ||
106 | + /* | ||
107 | + * This is an exception return magic value; put it where | ||
108 | * do_v7m_exception_exit() expects and raise EXCEPTION_EXIT. | ||
109 | * Note that if we ever add gen_ss_advance() singlestep support to | ||
110 | * M profile this should count as an "instruction execution complete" | ||
111 | @@ -XXX,XX +XXX,XX @@ void HELPER(v7m_bxns)(CPUARMState *env, uint32_t dest) | ||
112 | |||
113 | void HELPER(v7m_blxns)(CPUARMState *env, uint32_t dest) | ||
114 | { | ||
115 | - /* Handle v7M BLXNS: | ||
116 | + /* | ||
117 | + * Handle v7M BLXNS: | ||
118 | * - bit 0 of the destination address is the target security state | ||
119 | */ | ||
120 | |||
121 | @@ -XXX,XX +XXX,XX @@ void HELPER(v7m_blxns)(CPUARMState *env, uint32_t dest) | ||
122 | assert(env->v7m.secure); | ||
123 | |||
124 | if (dest & 1) { | ||
125 | - /* target is Secure, so this is just a normal BLX, | ||
126 | + /* | ||
127 | + * Target is Secure, so this is just a normal BLX, | ||
128 | * except that the low bit doesn't indicate Thumb/not. | ||
129 | */ | ||
130 | env->regs[14] = nextinst; | ||
131 | @@ -XXX,XX +XXX,XX @@ void HELPER(v7m_blxns)(CPUARMState *env, uint32_t dest) | ||
132 | env->regs[13] = sp; | ||
133 | env->regs[14] = 0xfeffffff; | ||
134 | if (arm_v7m_is_handler_mode(env)) { | ||
135 | - /* Write a dummy value to IPSR, to avoid leaking the current secure | ||
136 | + /* | ||
137 | + * Write a dummy value to IPSR, to avoid leaking the current secure | ||
138 | * exception number to non-secure code. This is guaranteed not | ||
139 | * to cause write_v7m_exception() to actually change stacks. | ||
140 | */ | ||
141 | @@ -XXX,XX +XXX,XX @@ void HELPER(v7m_blxns)(CPUARMState *env, uint32_t dest) | ||
142 | static uint32_t *get_v7m_sp_ptr(CPUARMState *env, bool secure, bool threadmode, | ||
143 | bool spsel) | ||
144 | { | ||
145 | - /* Return a pointer to the location where we currently store the | ||
146 | + /* | ||
147 | + * Return a pointer to the location where we currently store the | ||
148 | * stack pointer for the requested security state and thread mode. | ||
149 | * This pointer will become invalid if the CPU state is updated | ||
150 | * such that the stack pointers are switched around (eg changing | ||
151 | @@ -XXX,XX +XXX,XX @@ static bool arm_v7m_load_vector(ARMCPU *cpu, int exc, bool targets_secure, | ||
152 | |||
153 | mmu_idx = arm_v7m_mmu_idx_for_secstate_and_priv(env, targets_secure, true); | ||
154 | |||
155 | - /* We don't do a get_phys_addr() here because the rules for vector | ||
156 | + /* | ||
157 | + * We don't do a get_phys_addr() here because the rules for vector | ||
158 | * loads are special: they always use the default memory map, and | ||
159 | * the default memory map permits reads from all addresses. | ||
160 | * Since there's no easy way to pass through to pmsav8_mpu_lookup() | ||
161 | @@ -XXX,XX +XXX,XX @@ static bool arm_v7m_load_vector(ARMCPU *cpu, int exc, bool targets_secure, | ||
162 | return true; | ||
163 | |||
164 | load_fail: | ||
165 | - /* All vector table fetch fails are reported as HardFault, with | ||
166 | + /* | ||
167 | + * All vector table fetch fails are reported as HardFault, with | ||
168 | * HFSR.VECTTBL and .FORCED set. (FORCED is set because | ||
169 | * technically the underlying exception is a MemManage or BusFault | ||
170 | * that is escalated to HardFault.) This is a terminal exception, | ||
171 | @@ -XXX,XX +XXX,XX @@ static uint32_t v7m_integrity_sig(CPUARMState *env, uint32_t lr) | ||
172 | static bool v7m_push_callee_stack(ARMCPU *cpu, uint32_t lr, bool dotailchain, | ||
173 | bool ignore_faults) | ||
174 | { | ||
175 | - /* For v8M, push the callee-saves register part of the stack frame. | ||
176 | + /* | ||
177 | + * For v8M, push the callee-saves register part of the stack frame. | ||
178 | * Compare the v8M pseudocode PushCalleeStack(). | ||
179 | * In the tailchaining case this may not be the current stack. | ||
180 | */ | ||
181 | @@ -XXX,XX +XXX,XX @@ static bool v7m_push_callee_stack(ARMCPU *cpu, uint32_t lr, bool dotailchain, | ||
182 | return true; | ||
183 | } | ||
184 | |||
185 | - /* Write as much of the stack frame as we can. A write failure may | ||
186 | + /* | ||
187 | + * Write as much of the stack frame as we can. A write failure may | ||
188 | * cause us to pend a derived exception. | ||
189 | */ | ||
190 | sig = v7m_integrity_sig(env, lr); | ||
191 | @@ -XXX,XX +XXX,XX @@ static bool v7m_push_callee_stack(ARMCPU *cpu, uint32_t lr, bool dotailchain, | ||
192 | static void v7m_exception_taken(ARMCPU *cpu, uint32_t lr, bool dotailchain, | ||
193 | bool ignore_stackfaults) | ||
194 | { | ||
195 | - /* Do the "take the exception" parts of exception entry, | ||
196 | + /* | ||
197 | + * Do the "take the exception" parts of exception entry, | ||
198 | * but not the pushing of state to the stack. This is | ||
199 | * similar to the pseudocode ExceptionTaken() function. | ||
200 | */ | ||
201 | @@ -XXX,XX +XXX,XX @@ static void v7m_exception_taken(ARMCPU *cpu, uint32_t lr, bool dotailchain, | ||
202 | if (arm_feature(env, ARM_FEATURE_V8)) { | ||
203 | if (arm_feature(env, ARM_FEATURE_M_SECURITY) && | ||
204 | (lr & R_V7M_EXCRET_S_MASK)) { | ||
205 | - /* The background code (the owner of the registers in the | ||
206 | + /* | ||
207 | + * The background code (the owner of the registers in the | ||
208 | * exception frame) is Secure. This means it may either already | ||
209 | * have or now needs to push callee-saves registers. | ||
210 | */ | ||
211 | if (targets_secure) { | ||
212 | if (dotailchain && !(lr & R_V7M_EXCRET_ES_MASK)) { | ||
213 | - /* We took an exception from Secure to NonSecure | ||
214 | + /* | ||
215 | + * We took an exception from Secure to NonSecure | ||
216 | * (which means the callee-saved registers got stacked) | ||
217 | * and are now tailchaining to a Secure exception. | ||
218 | * Clear DCRS so eventual return from this Secure | ||
219 | @@ -XXX,XX +XXX,XX @@ static void v7m_exception_taken(ARMCPU *cpu, uint32_t lr, bool dotailchain, | ||
220 | lr &= ~R_V7M_EXCRET_DCRS_MASK; | ||
221 | } | ||
222 | } else { | ||
223 | - /* We're going to a non-secure exception; push the | ||
224 | + /* | ||
225 | + * We're going to a non-secure exception; push the | ||
226 | * callee-saves registers to the stack now, if they're | ||
227 | * not already saved. | ||
228 | */ | ||
229 | @@ -XXX,XX +XXX,XX @@ static void v7m_exception_taken(ARMCPU *cpu, uint32_t lr, bool dotailchain, | ||
230 | lr |= R_V7M_EXCRET_SPSEL_MASK; | ||
231 | } | ||
232 | |||
233 | - /* Clear registers if necessary to prevent non-secure exception | ||
234 | + /* | ||
235 | + * Clear registers if necessary to prevent non-secure exception | ||
236 | * code being able to see register values from secure code. | ||
237 | * Where register values become architecturally UNKNOWN we leave | ||
238 | * them with their previous values. | ||
239 | */ | ||
240 | if (arm_feature(env, ARM_FEATURE_M_SECURITY)) { | ||
241 | if (!targets_secure) { | ||
242 | - /* Always clear the caller-saved registers (they have been | ||
243 | + /* | ||
244 | + * Always clear the caller-saved registers (they have been | ||
245 | * pushed to the stack earlier in v7m_push_stack()). | ||
246 | * Clear callee-saved registers if the background code is | ||
247 | * Secure (in which case these regs were saved in | ||
248 | @@ -XXX,XX +XXX,XX @@ static void v7m_exception_taken(ARMCPU *cpu, uint32_t lr, bool dotailchain, | ||
249 | } | ||
250 | |||
251 | if (push_failed && !ignore_stackfaults) { | ||
252 | - /* Derived exception on callee-saves register stacking: | ||
253 | + /* | ||
254 | + * Derived exception on callee-saves register stacking: | ||
255 | * we might now want to take a different exception which | ||
256 | * targets a different security state, so try again from the top. | ||
257 | */ | ||
258 | @@ -XXX,XX +XXX,XX @@ static void v7m_exception_taken(ARMCPU *cpu, uint32_t lr, bool dotailchain, | ||
259 | return; | ||
260 | } | ||
261 | |||
262 | - /* Now we've done everything that might cause a derived exception | ||
263 | + /* | ||
264 | + * Now we've done everything that might cause a derived exception | ||
265 | * we can go ahead and activate whichever exception we're going to | ||
266 | * take (which might now be the derived exception). | ||
267 | */ | ||
268 | @@ -XXX,XX +XXX,XX @@ void HELPER(v7m_vlldm)(CPUARMState *env, uint32_t fptr) | ||
269 | |||
270 | static bool v7m_push_stack(ARMCPU *cpu) | ||
271 | { | ||
272 | - /* Do the "set up stack frame" part of exception entry, | ||
273 | + /* | ||
274 | + * Do the "set up stack frame" part of exception entry, | ||
275 | * similar to pseudocode PushStack(). | ||
276 | * Return true if we generate a derived exception (and so | ||
277 | * should ignore further stack faults trying to process | ||
278 | @@ -XXX,XX +XXX,XX @@ static bool v7m_push_stack(ARMCPU *cpu) | ||
279 | } | ||
280 | } | ||
281 | |||
282 | - /* Write as much of the stack frame as we can. If we fail a stack | ||
283 | + /* | ||
284 | + * Write as much of the stack frame as we can. If we fail a stack | ||
285 | * write this will result in a derived exception being pended | ||
286 | * (which may be taken in preference to the one we started with | ||
287 | * if it has higher priority). | ||
288 | @@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu) | ||
289 | bool ftype; | ||
290 | bool restore_s16_s31; | ||
291 | |||
292 | - /* If we're not in Handler mode then jumps to magic exception-exit | ||
293 | + /* | ||
294 | + * If we're not in Handler mode then jumps to magic exception-exit | ||
295 | * addresses don't have magic behaviour. However for the v8M | ||
296 | * security extensions the magic secure-function-return has to | ||
297 | * work in thread mode too, so to avoid doing an extra check in | ||
298 | @@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu) | ||
299 | return; | ||
300 | } | ||
301 | |||
302 | - /* In the spec pseudocode ExceptionReturn() is called directly | ||
303 | + /* | ||
304 | + * In the spec pseudocode ExceptionReturn() is called directly | ||
305 | * from BXWritePC() and gets the full target PC value including | ||
306 | * bit zero. In QEMU's implementation we treat it as a normal | ||
307 | * jump-to-register (which is then caught later on), and so split | ||
308 | @@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu) | ||
309 | } | ||
310 | |||
311 | if (arm_feature(env, ARM_FEATURE_M_SECURITY)) { | ||
312 | - /* EXC_RETURN.ES validation check (R_SMFL). We must do this before | ||
313 | + /* | ||
314 | + * EXC_RETURN.ES validation check (R_SMFL). We must do this before | ||
315 | * we pick which FAULTMASK to clear. | ||
316 | */ | ||
317 | if (!env->v7m.secure && | ||
318 | @@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu) | ||
319 | } | ||
320 | |||
321 | if (env->v7m.exception != ARMV7M_EXCP_NMI) { | ||
322 | - /* Auto-clear FAULTMASK on return from other than NMI. | ||
323 | + /* | ||
324 | + * Auto-clear FAULTMASK on return from other than NMI. | ||
325 | * If the security extension is implemented then this only | ||
326 | * happens if the raw execution priority is >= 0; the | ||
327 | * value of the ES bit in the exception return value indicates | ||
328 | @@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu) | ||
329 | /* still an irq active now */ | ||
330 | break; | ||
331 | case 1: | ||
332 | - /* we returned to base exception level, no nesting. | ||
333 | + /* | ||
334 | + * We returned to base exception level, no nesting. | ||
335 | * (In the pseudocode this is written using "NestedActivation != 1" | ||
336 | * where we have 'rettobase == false'.) | ||
337 | */ | ||
338 | @@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu) | ||
339 | |||
340 | if (arm_feature(env, ARM_FEATURE_V8)) { | ||
341 | if (!arm_feature(env, ARM_FEATURE_M_SECURITY)) { | ||
342 | - /* UNPREDICTABLE if S == 1 or DCRS == 0 or ES == 1 (R_XLCP); | ||
343 | + /* | ||
344 | + * UNPREDICTABLE if S == 1 or DCRS == 0 or ES == 1 (R_XLCP); | ||
345 | * we choose to take the UsageFault. | ||
346 | */ | ||
347 | if ((excret & R_V7M_EXCRET_S_MASK) || | ||
348 | @@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu) | ||
349 | break; | ||
350 | case 13: /* Return to Thread using Process stack */ | ||
351 | case 9: /* Return to Thread using Main stack */ | ||
352 | - /* We only need to check NONBASETHRDENA for v7M, because in | ||
353 | + /* | ||
354 | + * We only need to check NONBASETHRDENA for v7M, because in | ||
355 | * v8M this bit does not exist (it is RES1). | ||
356 | */ | ||
357 | if (!rettobase && | ||
358 | @@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu) | ||
359 | } | ||
360 | |||
361 | if (ufault) { | ||
362 | - /* Bad exception return: instead of popping the exception | ||
363 | + /* | ||
364 | + * Bad exception return: instead of popping the exception | ||
365 | * stack, directly take a usage fault on the current stack. | ||
366 | */ | ||
367 | env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_INVPC_MASK; | ||
368 | @@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu) | ||
369 | switch_v7m_security_state(env, return_to_secure); | ||
370 | |||
371 | { | ||
372 | - /* The stack pointer we should be reading the exception frame from | ||
373 | + /* | ||
374 | + * The stack pointer we should be reading the exception frame from | ||
375 | * depends on bits in the magic exception return type value (and | ||
376 | * for v8M isn't necessarily the stack pointer we will eventually | ||
377 | * end up resuming execution with). Get a pointer to the location | ||
378 | @@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu) | ||
379 | v7m_stack_read(cpu, &xpsr, frameptr + 0x1c, mmu_idx); | ||
380 | |||
381 | if (!pop_ok) { | ||
382 | - /* v7m_stack_read() pended a fault, so take it (as a tail | ||
383 | + /* | ||
384 | + * v7m_stack_read() pended a fault, so take it (as a tail | ||
385 | * chained exception on the same stack frame) | ||
386 | */ | ||
387 | qemu_log_mask(CPU_LOG_INT, "...derived exception on unstacking\n"); | ||
388 | @@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu) | ||
389 | return; | ||
390 | } | ||
391 | |||
392 | - /* Returning from an exception with a PC with bit 0 set is defined | ||
393 | + /* | ||
394 | + * Returning from an exception with a PC with bit 0 set is defined | ||
395 | * behaviour on v8M (bit 0 is ignored), but for v7M it was specified | ||
396 | * to be UNPREDICTABLE. In practice actual v7M hardware seems to ignore | ||
397 | * the lsbit, and there are several RTOSes out there which incorrectly | ||
398 | @@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu) | ||
399 | } | ||
400 | |||
401 | if (arm_feature(env, ARM_FEATURE_V8)) { | ||
402 | - /* For v8M we have to check whether the xPSR exception field | ||
403 | + /* | ||
404 | + * For v8M we have to check whether the xPSR exception field | ||
405 | * matches the EXCRET value for return to handler/thread | ||
406 | * before we commit to changing the SP and xPSR. | ||
407 | */ | ||
408 | bool will_be_handler = (xpsr & XPSR_EXCP) != 0; | ||
409 | if (return_to_handler != will_be_handler) { | ||
410 | - /* Take an INVPC UsageFault on the current stack. | ||
411 | + /* | ||
412 | + * Take an INVPC UsageFault on the current stack. | ||
413 | * By this point we will have switched to the security state | ||
414 | * for the background state, so this UsageFault will target | ||
415 | * that state. | ||
416 | @@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu) | ||
417 | frameptr += 0x40; | ||
418 | } | ||
419 | } | ||
420 | - /* Undo stack alignment (the SPREALIGN bit indicates that the original | ||
421 | + /* | ||
422 | + * Undo stack alignment (the SPREALIGN bit indicates that the original | ||
423 | * pre-exception SP was not 8-aligned and we added a padding word to | ||
424 | * align it, so we undo this by ORing in the bit that increases it | ||
425 | * from the current 8-aligned value to the 8-unaligned value. (Adding 4 | ||
426 | @@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu) | ||
427 | V7M_CONTROL, SFPA, sfpa); | ||
428 | } | ||
429 | |||
430 | - /* The restored xPSR exception field will be zero if we're | ||
431 | + /* | ||
432 | + * The restored xPSR exception field will be zero if we're | ||
433 | * resuming in Thread mode. If that doesn't match what the | ||
434 | * exception return excret specified then this is a UsageFault. | ||
435 | * v7M requires we make this check here; v8M did it earlier. | ||
436 | */ | ||
437 | if (return_to_handler != arm_v7m_is_handler_mode(env)) { | ||
438 | - /* Take an INVPC UsageFault by pushing the stack again; | ||
439 | + /* | ||
440 | + * Take an INVPC UsageFault by pushing the stack again; | ||
441 | * we know we're v7M so this is never a Secure UsageFault. | ||
442 | */ | ||
443 | bool ignore_stackfaults; | ||
444 | @@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu) | ||
445 | |||
446 | static bool do_v7m_function_return(ARMCPU *cpu) | ||
447 | { | ||
448 | - /* v8M security extensions magic function return. | ||
449 | + /* | ||
450 | + * v8M security extensions magic function return. | ||
451 | * We may either: | ||
452 | * (1) throw an exception (longjump) | ||
453 | * (2) return true if we successfully handled the function return | ||
454 | @@ -XXX,XX +XXX,XX @@ static bool do_v7m_function_return(ARMCPU *cpu) | ||
455 | frame_sp_p = get_v7m_sp_ptr(env, true, threadmode, spsel); | ||
456 | frameptr = *frame_sp_p; | ||
457 | |||
458 | - /* These loads may throw an exception (for MPU faults). We want to | ||
459 | + /* | ||
460 | + * These loads may throw an exception (for MPU faults). We want to | ||
461 | * do them as secure, so work out what MMU index that is. | ||
462 | */ | ||
463 | mmu_idx = arm_v7m_mmu_idx_for_secstate(env, true); | ||
464 | @@ -XXX,XX +XXX,XX @@ static void arm_log_exception(int idx) | ||
465 | static bool v7m_read_half_insn(ARMCPU *cpu, ARMMMUIdx mmu_idx, | ||
466 | uint32_t addr, uint16_t *insn) | ||
467 | { | ||
468 | - /* Load a 16-bit portion of a v7M instruction, returning true on success, | ||
469 | + /* | ||
470 | + * Load a 16-bit portion of a v7M instruction, returning true on success, | ||
471 | * or false on failure (in which case we will have pended the appropriate | ||
472 | * exception). | ||
473 | * We need to do the instruction fetch's MPU and SAU checks | ||
474 | @@ -XXX,XX +XXX,XX @@ static bool v7m_read_half_insn(ARMCPU *cpu, ARMMMUIdx mmu_idx, | ||
475 | |||
476 | v8m_security_lookup(env, addr, MMU_INST_FETCH, mmu_idx, &sattrs); | ||
477 | if (!sattrs.nsc || sattrs.ns) { | ||
478 | - /* This must be the second half of the insn, and it straddles a | ||
479 | + /* | ||
480 | + * This must be the second half of the insn, and it straddles a | ||
481 | * region boundary with the second half not being S&NSC. | ||
482 | */ | ||
483 | env->v7m.sfsr |= R_V7M_SFSR_INVEP_MASK; | ||
484 | @@ -XXX,XX +XXX,XX @@ static bool v7m_read_half_insn(ARMCPU *cpu, ARMMMUIdx mmu_idx, | ||
485 | |||
486 | static bool v7m_handle_execute_nsc(ARMCPU *cpu) | ||
487 | { | ||
488 | - /* Check whether this attempt to execute code in a Secure & NS-Callable | ||
489 | + /* | ||
490 | + * Check whether this attempt to execute code in a Secure & NS-Callable | ||
491 | * memory region is for an SG instruction; if so, then emulate the | ||
492 | * effect of the SG instruction and return true. Otherwise pend | ||
493 | * the correct kind of exception and return false. | ||
494 | @@ -XXX,XX +XXX,XX @@ static bool v7m_handle_execute_nsc(ARMCPU *cpu) | ||
495 | ARMMMUIdx mmu_idx; | ||
496 | uint16_t insn; | ||
497 | |||
498 | - /* We should never get here unless get_phys_addr_pmsav8() caused | ||
499 | + /* | ||
500 | + * We should never get here unless get_phys_addr_pmsav8() caused | ||
501 | * an exception for NS executing in S&NSC memory. | ||
502 | */ | ||
503 | assert(!env->v7m.secure); | ||
504 | @@ -XXX,XX +XXX,XX @@ static bool v7m_handle_execute_nsc(ARMCPU *cpu) | ||
505 | } | ||
506 | |||
507 | if (insn != 0xe97f) { | ||
508 | - /* Not an SG instruction first half (we choose the IMPDEF | ||
509 | + /* | ||
510 | + * Not an SG instruction first half (we choose the IMPDEF | ||
511 | * early-SG-check option). | ||
512 | */ | ||
513 | goto gen_invep; | ||
514 | @@ -XXX,XX +XXX,XX @@ static bool v7m_handle_execute_nsc(ARMCPU *cpu) | ||
515 | } | ||
516 | |||
517 | if (insn != 0xe97f) { | ||
518 | - /* Not an SG instruction second half (yes, both halves of the SG | ||
519 | + /* | ||
520 | + * Not an SG instruction second half (yes, both halves of the SG | ||
521 | * insn have the same hex value) | ||
522 | */ | ||
523 | goto gen_invep; | ||
524 | } | ||
525 | |||
526 | - /* OK, we have confirmed that we really have an SG instruction. | ||
527 | + /* | ||
528 | + * OK, we have confirmed that we really have an SG instruction. | ||
529 | * We know we're NS in S memory so don't need to repeat those checks. | ||
530 | */ | ||
531 | qemu_log_mask(CPU_LOG_INT, "...really an SG instruction at 0x%08" PRIx32 | ||
532 | @@ -XXX,XX +XXX,XX @@ void arm_v7m_cpu_do_interrupt(CPUState *cs) | ||
533 | |||
534 | arm_log_exception(cs->exception_index); | ||
535 | |||
536 | - /* For exceptions we just mark as pending on the NVIC, and let that | ||
537 | - handle it. */ | ||
538 | + /* | ||
539 | + * For exceptions we just mark as pending on the NVIC, and let that | ||
540 | + * handle it. | ||
541 | + */ | ||
542 | switch (cs->exception_index) { | ||
543 | case EXCP_UDEF: | ||
544 | armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, env->v7m.secure); | ||
545 | @@ -XXX,XX +XXX,XX @@ void arm_v7m_cpu_do_interrupt(CPUState *cs) | ||
546 | break; | ||
547 | case EXCP_PREFETCH_ABORT: | ||
548 | case EXCP_DATA_ABORT: | ||
549 | - /* Note that for M profile we don't have a guest facing FSR, but | ||
550 | + /* | ||
551 | + * Note that for M profile we don't have a guest facing FSR, but | ||
552 | * the env->exception.fsr will be populated by the code that | ||
553 | * raises the fault, in the A profile short-descriptor format. | ||
554 | */ | ||
555 | switch (env->exception.fsr & 0xf) { | ||
556 | case M_FAKE_FSR_NSC_EXEC: | ||
557 | - /* Exception generated when we try to execute code at an address | ||
558 | + /* | ||
559 | + * Exception generated when we try to execute code at an address | ||
560 | * which is marked as Secure & Non-Secure Callable and the CPU | ||
561 | * is in the Non-Secure state. The only instruction which can | ||
562 | * be executed like this is SG (and that only if both halves of | ||
563 | @@ -XXX,XX +XXX,XX @@ void arm_v7m_cpu_do_interrupt(CPUState *cs) | ||
564 | } | ||
565 | break; | ||
566 | case M_FAKE_FSR_SFAULT: | ||
567 | - /* Various flavours of SecureFault for attempts to execute or | ||
568 | + /* | ||
569 | + * Various flavours of SecureFault for attempts to execute or | ||
570 | * access data in the wrong security state. | ||
571 | */ | ||
572 | switch (cs->exception_index) { | ||
573 | @@ -XXX,XX +XXX,XX @@ void arm_v7m_cpu_do_interrupt(CPUState *cs) | ||
574 | armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_BUS, false); | ||
575 | break; | ||
576 | default: | ||
577 | - /* All other FSR values are either MPU faults or "can't happen | ||
578 | + /* | ||
579 | + * All other FSR values are either MPU faults or "can't happen | ||
580 | * for M profile" cases. | ||
581 | */ | ||
582 | switch (cs->exception_index) { | ||
583 | @@ -XXX,XX +XXX,XX @@ void arm_v7m_cpu_do_interrupt(CPUState *cs) | ||
584 | if (arm_feature(env, ARM_FEATURE_V8)) { | ||
585 | lr = R_V7M_EXCRET_RES1_MASK | | ||
586 | R_V7M_EXCRET_DCRS_MASK; | ||
587 | - /* The S bit indicates whether we should return to Secure | ||
588 | + /* | ||
589 | + * The S bit indicates whether we should return to Secure | ||
590 | * or NonSecure (ie our current state). | ||
591 | * The ES bit indicates whether we're taking this exception | ||
592 | * to Secure or NonSecure (ie our target state). We set it | ||
593 | @@ -XXX,XX +XXX,XX @@ void arm_v7m_cpu_do_interrupt(CPUState *cs) | ||
594 | v7m_exception_taken(cpu, lr, false, ignore_stackfaults); | ||
165 | } | 595 | } |
166 | 596 | ||
167 | +static void tlbi_aa64_vmalle1_write(CPUARMState *env, const ARMCPRegInfo *ri, | 597 | -/* Function used to synchronize QEMU's AArch64 register set with AArch32 |
168 | + uint64_t value) | 598 | +/* |
169 | +{ | 599 | + * Function used to synchronize QEMU's AArch64 register set with AArch32 |
170 | + CPUState *cs = ENV_GET_CPU(env); | 600 | * register set. This is necessary when switching between AArch32 and AArch64 |
171 | + | 601 | * execution state. |
172 | + if (tlb_force_broadcast(env)) { | 602 | */ |
173 | + tlbi_aa64_vmalle1_write(env, NULL, value); | 603 | @@ -XXX,XX +XXX,XX @@ void aarch64_sync_32_to_64(CPUARMState *env) |
174 | + return; | 604 | env->xregs[i] = env->regs[i]; |
175 | + } | 605 | } |
176 | + | 606 | |
177 | + if (arm_is_secure_below_el3(env)) { | 607 | - /* Unless we are in FIQ mode, x8-x12 come from the user registers r8-r12. |
178 | + tlb_flush_by_mmuidx(cs, | 608 | + /* |
179 | + ARMMMUIdxBit_S1SE1 | | 609 | + * Unless we are in FIQ mode, x8-x12 come from the user registers r8-r12. |
180 | + ARMMMUIdxBit_S1SE0); | 610 | * Otherwise, they come from the banked user regs. |
181 | + } else { | 611 | */ |
182 | + tlb_flush_by_mmuidx(cs, | 612 | if (mode == ARM_CPU_MODE_FIQ) { |
183 | + ARMMMUIdxBit_S12NSE1 | | 613 | @@ -XXX,XX +XXX,XX @@ void aarch64_sync_32_to_64(CPUARMState *env) |
184 | + ARMMMUIdxBit_S12NSE0); | 614 | } |
185 | + } | 615 | } |
186 | +} | 616 | |
187 | + | 617 | - /* Registers x13-x23 are the various mode SP and FP registers. Registers |
188 | static void tlbi_aa64_alle1_write(CPUARMState *env, const ARMCPRegInfo *ri, | 618 | + /* |
189 | uint64_t value) | 619 | + * Registers x13-x23 are the various mode SP and FP registers. Registers |
190 | { | 620 | * r13 and r14 are only copied if we are in that mode, otherwise we copy |
191 | @@ -XXX,XX +XXX,XX @@ static void tlbi_aa64_alle3is_write(CPUARMState *env, const ARMCPRegInfo *ri, | 621 | * from the mode banked register. |
192 | tlb_flush_by_mmuidx_all_cpus_synced(cs, ARMMMUIdxBit_S1E3); | 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]; | ||
193 | } | 635 | } |
194 | 636 | ||
195 | -static void tlbi_aa64_vae1_write(CPUARMState *env, const ARMCPRegInfo *ri, | 637 | -/* Function used to synchronize QEMU's AArch32 register set with AArch64 |
196 | - uint64_t value) | 638 | +/* |
197 | -{ | 639 | + * Function used to synchronize QEMU's AArch32 register set with AArch64 |
198 | - /* Invalidate by VA, EL1&0 (AArch64 version). | 640 | * register set. This is necessary when switching between AArch32 and AArch64 |
199 | - * Currently handles all of VAE1, VAAE1, VAALE1 and VALE1, | 641 | * execution state. |
200 | - * since we don't support flush-for-specific-ASID-only or | 642 | */ |
201 | - * flush-last-level-only. | 643 | @@ -XXX,XX +XXX,XX @@ void aarch64_sync_64_to_32(CPUARMState *env) |
202 | - */ | 644 | env->regs[i] = env->xregs[i]; |
203 | - ARMCPU *cpu = arm_env_get_cpu(env); | 645 | } |
204 | - CPUState *cs = CPU(cpu); | 646 | |
205 | - uint64_t pageaddr = sextract64(value << 12, 0, 56); | 647 | - /* Unless we are in FIQ mode, r8-r12 come from the user registers x8-x12. |
206 | - | 648 | + /* |
207 | - if (arm_is_secure_below_el3(env)) { | 649 | + * Unless we are in FIQ mode, r8-r12 come from the user registers x8-x12. |
208 | - tlb_flush_page_by_mmuidx(cs, pageaddr, | 650 | * Otherwise, we copy x8-x12 into the banked user regs. |
209 | - ARMMMUIdxBit_S1SE1 | | 651 | */ |
210 | - ARMMMUIdxBit_S1SE0); | 652 | if (mode == ARM_CPU_MODE_FIQ) { |
211 | - } else { | 653 | @@ -XXX,XX +XXX,XX @@ void aarch64_sync_64_to_32(CPUARMState *env) |
212 | - tlb_flush_page_by_mmuidx(cs, pageaddr, | 654 | } |
213 | - ARMMMUIdxBit_S12NSE1 | | 655 | } |
214 | - ARMMMUIdxBit_S12NSE0); | 656 | |
215 | - } | 657 | - /* Registers r13 & r14 depend on the current mode. |
216 | -} | 658 | + /* |
217 | - | 659 | + * Registers r13 & r14 depend on the current mode. |
218 | static void tlbi_aa64_vae2_write(CPUARMState *env, const ARMCPRegInfo *ri, | 660 | * If we are in a given mode, we copy the corresponding x registers to r13 |
219 | uint64_t value) | 661 | * and r14. Otherwise, we copy the x register to the banked r13 and r14 |
220 | { | 662 | * for the mode. |
221 | @@ -XXX,XX +XXX,XX @@ static void tlbi_aa64_vae1is_write(CPUARMState *env, const ARMCPRegInfo *ri, | 663 | @@ -XXX,XX +XXX,XX @@ void aarch64_sync_64_to_32(CPUARMState *env) |
222 | } | 664 | } else { |
665 | env->banked_r13[bank_number(ARM_CPU_MODE_USR)] = env->xregs[13]; | ||
666 | |||
667 | - /* HYP is an exception in that it does not have its own banked r14 but | ||
668 | + /* | ||
669 | + * HYP is an exception in that it does not have its own banked r14 but | ||
670 | * shares the USR r14 | ||
671 | */ | ||
672 | if (mode == ARM_CPU_MODE_HYP) { | ||
673 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(v7m_mrs)(CPUARMState *env, uint32_t reg) | ||
674 | return value; | ||
675 | } | ||
676 | case 0x94: /* CONTROL_NS */ | ||
677 | - /* We have to handle this here because unprivileged Secure code | ||
678 | + /* | ||
679 | + * We have to handle this here because unprivileged Secure code | ||
680 | * can read the NS CONTROL register. | ||
681 | */ | ||
682 | if (!env->v7m.secure) { | ||
683 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(v7m_mrs)(CPUARMState *env, uint32_t reg) | ||
684 | return env->v7m.faultmask[M_REG_NS]; | ||
685 | case 0x98: /* SP_NS */ | ||
686 | { | ||
687 | - /* This gives the non-secure SP selected based on whether we're | ||
688 | + /* | ||
689 | + * This gives the non-secure SP selected based on whether we're | ||
690 | * currently in handler mode or not, using the NS CONTROL.SPSEL. | ||
691 | */ | ||
692 | bool spsel = env->v7m.control[M_REG_NS] & R_V7M_CONTROL_SPSEL_MASK; | ||
693 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(v7m_mrs)(CPUARMState *env, uint32_t reg) | ||
694 | |||
695 | void HELPER(v7m_msr)(CPUARMState *env, uint32_t maskreg, uint32_t val) | ||
696 | { | ||
697 | - /* We're passed bits [11..0] of the instruction; extract | ||
698 | + /* | ||
699 | + * We're passed bits [11..0] of the instruction; extract | ||
700 | * SYSm and the mask bits. | ||
701 | * Invalid combinations of SYSm and mask are UNPREDICTABLE; | ||
702 | * we choose to treat them as if the mask bits were valid. | ||
703 | @@ -XXX,XX +XXX,XX @@ void HELPER(v7m_msr)(CPUARMState *env, uint32_t maskreg, uint32_t val) | ||
704 | return; | ||
705 | case 0x98: /* SP_NS */ | ||
706 | { | ||
707 | - /* This gives the non-secure SP selected based on whether we're | ||
708 | + /* | ||
709 | + * This gives the non-secure SP selected based on whether we're | ||
710 | * currently in handler mode or not, using the NS CONTROL.SPSEL. | ||
711 | */ | ||
712 | bool spsel = env->v7m.control[M_REG_NS] & R_V7M_CONTROL_SPSEL_MASK; | ||
713 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(v7m_tt)(CPUARMState *env, uint32_t addr, uint32_t op) | ||
714 | bool targetsec = env->v7m.secure; | ||
715 | bool is_subpage; | ||
716 | |||
717 | - /* Work out what the security state and privilege level we're | ||
718 | + /* | ||
719 | + * Work out what the security state and privilege level we're | ||
720 | * interested in is... | ||
721 | */ | ||
722 | if (alt) { | ||
723 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(v7m_tt)(CPUARMState *env, uint32_t addr, uint32_t op) | ||
724 | /* ...and then figure out which MMU index this is */ | ||
725 | mmu_idx = arm_v7m_mmu_idx_for_secstate_and_priv(env, targetsec, targetpriv); | ||
726 | |||
727 | - /* We know that the MPU and SAU don't care about the access type | ||
728 | + /* | ||
729 | + * We know that the MPU and SAU don't care about the access type | ||
730 | * for our purposes beyond that we don't want to claim to be | ||
731 | * an insn fetch, so we arbitrarily call this a read. | ||
732 | */ | ||
733 | |||
734 | - /* MPU region info only available for privileged or if | ||
735 | + /* | ||
736 | + * MPU region info only available for privileged or if | ||
737 | * inspecting the other MPU state. | ||
738 | */ | ||
739 | if (arm_current_el(env) != 0 || alt) { | ||
740 | @@ -XXX,XX +XXX,XX @@ bool arm_cpu_tlb_fill(CPUState *cs, vaddr address, int size, | ||
741 | |||
742 | void HELPER(dc_zva)(CPUARMState *env, uint64_t vaddr_in) | ||
743 | { | ||
744 | - /* Implement DC ZVA, which zeroes a fixed-length block of memory. | ||
745 | + /* | ||
746 | + * Implement DC ZVA, which zeroes a fixed-length block of memory. | ||
747 | * Note that we do not implement the (architecturally mandated) | ||
748 | * alignment fault for attempts to use this on Device memory | ||
749 | * (which matches the usual QEMU behaviour of not implementing either | ||
750 | @@ -XXX,XX +XXX,XX @@ void HELPER(dc_zva)(CPUARMState *env, uint64_t vaddr_in) | ||
751 | |||
752 | #ifndef CONFIG_USER_ONLY | ||
753 | { | ||
754 | - /* Slightly awkwardly, QEMU's TARGET_PAGE_SIZE may be less than | ||
755 | + /* | ||
756 | + * Slightly awkwardly, QEMU's TARGET_PAGE_SIZE may be less than | ||
757 | * the block size so we might have to do more than one TLB lookup. | ||
758 | * We know that in fact for any v8 CPU the page size is at least 4K | ||
759 | * and the block size must be 2K or less, but TARGET_PAGE_SIZE is only | ||
760 | @@ -XXX,XX +XXX,XX @@ void HELPER(dc_zva)(CPUARMState *env, uint64_t vaddr_in) | ||
761 | } | ||
762 | } | ||
763 | if (i == maxidx) { | ||
764 | - /* If it's all in the TLB it's fair game for just writing to; | ||
765 | + /* | ||
766 | + * If it's all in the TLB it's fair game for just writing to; | ||
767 | * we know we don't need to update dirty status, etc. | ||
768 | */ | ||
769 | for (i = 0; i < maxidx - 1; i++) { | ||
770 | @@ -XXX,XX +XXX,XX @@ void HELPER(dc_zva)(CPUARMState *env, uint64_t vaddr_in) | ||
771 | memset(hostaddr[i], 0, blocklen - (i * TARGET_PAGE_SIZE)); | ||
772 | return; | ||
773 | } | ||
774 | - /* OK, try a store and see if we can populate the tlb. This | ||
775 | + /* | ||
776 | + * OK, try a store and see if we can populate the tlb. This | ||
777 | * might cause an exception if the memory isn't writable, | ||
778 | * in which case we will longjmp out of here. We must for | ||
779 | * this purpose use the actual register value passed to us | ||
780 | @@ -XXX,XX +XXX,XX @@ void HELPER(dc_zva)(CPUARMState *env, uint64_t vaddr_in) | ||
781 | } | ||
782 | } | ||
783 | |||
784 | - /* Slow path (probably attempt to do this to an I/O device or | ||
785 | + /* | ||
786 | + * Slow path (probably attempt to do this to an I/O device or | ||
787 | * similar, or clearing of a block of code we have translations | ||
788 | * cached for). Just do a series of byte writes as the architecture | ||
789 | * demands. It's not worth trying to use a cpu_physical_memory_map(), | ||
790 | diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c | ||
791 | index XXXXXXX..XXXXXXX 100644 | ||
792 | --- a/target/arm/op_helper.c | ||
793 | +++ b/target/arm/op_helper.c | ||
794 | @@ -XXX,XX +XXX,XX @@ static inline uint32_t merge_syn_data_abort(uint32_t template_syn, | ||
795 | { | ||
796 | uint32_t syn; | ||
797 | |||
798 | - /* ISV is only set for data aborts routed to EL2 and | ||
799 | + /* | ||
800 | + * ISV is only set for data aborts routed to EL2 and | ||
801 | * never for stage-1 page table walks faulting on stage 2. | ||
802 | * | ||
803 | * Furthermore, ISV is only set for certain kinds of load/stores. | ||
804 | @@ -XXX,XX +XXX,XX @@ static inline uint32_t merge_syn_data_abort(uint32_t template_syn, | ||
805 | syn = syn_data_abort_no_iss(same_el, | ||
806 | ea, 0, s1ptw, is_write, fsc); | ||
807 | } else { | ||
808 | - /* Fields: IL, ISV, SAS, SSE, SRT, SF and AR come from the template | ||
809 | + /* | ||
810 | + * Fields: IL, ISV, SAS, SSE, SRT, SF and AR come from the template | ||
811 | * syndrome created at translation time. | ||
812 | * Now we create the runtime syndrome with the remaining fields. | ||
813 | */ | ||
814 | @@ -XXX,XX +XXX,XX @@ void arm_deliver_fault(ARMCPU *cpu, vaddr addr, MMUAccessType access_type, | ||
815 | |||
816 | if (target_el == 2 || arm_el_is_aa64(env, target_el) || | ||
817 | arm_s1_regime_using_lpae_format(env, arm_mmu_idx)) { | ||
818 | - /* LPAE format fault status register : bottom 6 bits are | ||
819 | + /* | ||
820 | + * LPAE format fault status register : bottom 6 bits are | ||
821 | * status code in the same form as needed for syndrome | ||
822 | */ | ||
823 | fsr = arm_fi_to_lfsc(fi); | ||
824 | fsc = extract32(fsr, 0, 6); | ||
825 | } else { | ||
826 | fsr = arm_fi_to_sfsc(fi); | ||
827 | - /* Short format FSR : this fault will never actually be reported | ||
828 | + /* | ||
829 | + * Short format FSR : this fault will never actually be reported | ||
830 | * to an EL that uses a syndrome register. Use a (currently) | ||
831 | * reserved FSR code in case the constructed syndrome does leak | ||
832 | * into the guest somehow. | ||
833 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_do_unaligned_access(CPUState *cs, vaddr vaddr, | ||
834 | arm_deliver_fault(cpu, vaddr, access_type, mmu_idx, &fi); | ||
223 | } | 835 | } |
224 | 836 | ||
225 | +static void tlbi_aa64_vae1_write(CPUARMState *env, const ARMCPRegInfo *ri, | 837 | -/* arm_cpu_do_transaction_failed: handle a memory system error response |
226 | + uint64_t value) | 838 | +/* |
227 | +{ | 839 | + * arm_cpu_do_transaction_failed: handle a memory system error response |
228 | + /* Invalidate by VA, EL1&0 (AArch64 version). | 840 | * (eg "no device/memory present at address") by raising an external abort |
229 | + * Currently handles all of VAE1, VAAE1, VAALE1 and VALE1, | 841 | * exception |
230 | + * since we don't support flush-for-specific-ASID-only or | 842 | */ |
231 | + * flush-last-level-only. | 843 | @@ -XXX,XX +XXX,XX @@ static bool linked_bp_matches(ARMCPU *cpu, int lbn) |
232 | + */ | 844 | int bt; |
233 | + ARMCPU *cpu = arm_env_get_cpu(env); | 845 | uint32_t contextidr; |
234 | + CPUState *cs = CPU(cpu); | 846 | |
235 | + uint64_t pageaddr = sextract64(value << 12, 0, 56); | 847 | - /* Links to unimplemented or non-context aware breakpoints are |
236 | + | 848 | + /* |
237 | + if (tlb_force_broadcast(env)) { | 849 | + * Links to unimplemented or non-context aware breakpoints are |
238 | + tlbi_aa64_vae1is_write(env, NULL, value); | 850 | * CONSTRAINED UNPREDICTABLE: either behave as if disabled, or |
239 | + return; | 851 | * as if linked to an UNKNOWN context-aware breakpoint (in which |
240 | + } | 852 | * case DBGWCR<n>_EL1.LBN must indicate that breakpoint). |
241 | + | 853 | @@ -XXX,XX +XXX,XX @@ static bool linked_bp_matches(ARMCPU *cpu, int lbn) |
242 | + if (arm_is_secure_below_el3(env)) { | 854 | |
243 | + tlb_flush_page_by_mmuidx(cs, pageaddr, | 855 | bt = extract64(bcr, 20, 4); |
244 | + ARMMMUIdxBit_S1SE1 | | 856 | |
245 | + ARMMMUIdxBit_S1SE0); | 857 | - /* We match the whole register even if this is AArch32 using the |
246 | + } else { | 858 | + /* |
247 | + tlb_flush_page_by_mmuidx(cs, pageaddr, | 859 | + * We match the whole register even if this is AArch32 using the |
248 | + ARMMMUIdxBit_S12NSE1 | | 860 | * short descriptor format (in which case it holds both PROCID and ASID), |
249 | + ARMMMUIdxBit_S12NSE0); | 861 | * since we don't implement the optional v7 context ID masking. |
250 | + } | 862 | */ |
251 | +} | 863 | @@ -XXX,XX +XXX,XX @@ static bool linked_bp_matches(ARMCPU *cpu, int lbn) |
252 | + | 864 | case 9: /* linked VMID match (reserved if no EL2) */ |
253 | static void tlbi_aa64_vae2is_write(CPUARMState *env, const ARMCPRegInfo *ri, | 865 | case 11: /* linked context ID and VMID match (reserved if no EL2) */ |
254 | uint64_t value) | 866 | default: |
255 | { | 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 | */ | ||
256 | -- | 987 | -- |
257 | 2.19.1 | 988 | 2.20.1 |
258 | 989 | ||
259 | 990 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 3 | Since we'll move this code around, fix its style first. |
4 | Message-id: 20181011205206.3552-18-richard.henderson@linaro.org | 4 | |
5 | [PMM: added parens in ?: expression] | 5 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> |
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> |
7 | Message-id: 20190701132516.26392-9-philmd@redhat.com | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | --- | 9 | --- |
9 | target/arm/translate.c | 81 ++++++++++++++---------------------------- | 10 | target/arm/translate.c | 11 ++++++----- |
10 | 1 file changed, 26 insertions(+), 55 deletions(-) | 11 | target/arm/vfp_helper.c | 36 ++++++++++++++++++++++++------------ |
12 | 2 files changed, 30 insertions(+), 17 deletions(-) | ||
11 | 13 | ||
12 | 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 |
13 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
14 | --- a/target/arm/translate.c | 16 | --- a/target/arm/translate.c |
15 | +++ b/target/arm/translate.c | 17 | +++ b/target/arm/translate.c |
16 | @@ -XXX,XX +XXX,XX @@ static void gen_vfp_msr(TCGv_i32 tmp) | 18 | @@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) |
17 | tcg_temp_free_i32(tmp); | 19 | loaded_base = 0; |
20 | loaded_var = NULL; | ||
21 | n = 0; | ||
22 | - for(i=0;i<16;i++) { | ||
23 | + for (i = 0; i < 16; i++) { | ||
24 | if (insn & (1 << i)) | ||
25 | n++; | ||
26 | } | ||
27 | @@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) | ||
28 | } | ||
29 | } | ||
30 | j = 0; | ||
31 | - for(i=0;i<16;i++) { | ||
32 | + for (i = 0; i < 16; i++) { | ||
33 | if (insn & (1 << i)) { | ||
34 | if (is_load) { | ||
35 | /* load */ | ||
36 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_dump_state(CPUState *cs, FILE *f, int flags) | ||
37 | return; | ||
38 | } | ||
39 | |||
40 | - for(i=0;i<16;i++) { | ||
41 | + for (i = 0; i < 16; i++) { | ||
42 | qemu_fprintf(f, "R%02d=%08x", i, env->regs[i]); | ||
43 | - if ((i % 4) == 3) | ||
44 | + if ((i % 4) == 3) { | ||
45 | qemu_fprintf(f, "\n"); | ||
46 | - else | ||
47 | + } else { | ||
48 | qemu_fprintf(f, " "); | ||
49 | + } | ||
50 | } | ||
51 | |||
52 | if (arm_feature(env, ARM_FEATURE_M)) { | ||
53 | diff --git a/target/arm/vfp_helper.c b/target/arm/vfp_helper.c | ||
54 | index XXXXXXX..XXXXXXX 100644 | ||
55 | --- a/target/arm/vfp_helper.c | ||
56 | +++ b/target/arm/vfp_helper.c | ||
57 | @@ -XXX,XX +XXX,XX @@ static inline int vfp_exceptbits_from_host(int host_bits) | ||
58 | { | ||
59 | int target_bits = 0; | ||
60 | |||
61 | - if (host_bits & float_flag_invalid) | ||
62 | + if (host_bits & float_flag_invalid) { | ||
63 | target_bits |= 1; | ||
64 | - if (host_bits & float_flag_divbyzero) | ||
65 | + } | ||
66 | + if (host_bits & float_flag_divbyzero) { | ||
67 | target_bits |= 2; | ||
68 | - if (host_bits & float_flag_overflow) | ||
69 | + } | ||
70 | + if (host_bits & float_flag_overflow) { | ||
71 | target_bits |= 4; | ||
72 | - if (host_bits & (float_flag_underflow | float_flag_output_denormal)) | ||
73 | + } | ||
74 | + if (host_bits & (float_flag_underflow | float_flag_output_denormal)) { | ||
75 | target_bits |= 8; | ||
76 | - if (host_bits & float_flag_inexact) | ||
77 | + } | ||
78 | + if (host_bits & float_flag_inexact) { | ||
79 | target_bits |= 0x10; | ||
80 | - if (host_bits & float_flag_input_denormal) | ||
81 | + } | ||
82 | + if (host_bits & float_flag_input_denormal) { | ||
83 | target_bits |= 0x80; | ||
84 | + } | ||
85 | return target_bits; | ||
18 | } | 86 | } |
19 | 87 | ||
20 | -static void gen_neon_dup_u8(TCGv_i32 var, int shift) | 88 | @@ -XXX,XX +XXX,XX @@ static inline int vfp_exceptbits_to_host(int target_bits) |
21 | -{ | ||
22 | - TCGv_i32 tmp = tcg_temp_new_i32(); | ||
23 | - if (shift) | ||
24 | - tcg_gen_shri_i32(var, var, shift); | ||
25 | - tcg_gen_ext8u_i32(var, var); | ||
26 | - tcg_gen_shli_i32(tmp, var, 8); | ||
27 | - tcg_gen_or_i32(var, var, tmp); | ||
28 | - tcg_gen_shli_i32(tmp, var, 16); | ||
29 | - tcg_gen_or_i32(var, var, tmp); | ||
30 | - tcg_temp_free_i32(tmp); | ||
31 | -} | ||
32 | - | ||
33 | static void gen_neon_dup_low16(TCGv_i32 var) | ||
34 | { | 89 | { |
35 | TCGv_i32 tmp = tcg_temp_new_i32(); | 90 | int host_bits = 0; |
36 | @@ -XXX,XX +XXX,XX @@ static void gen_neon_dup_high16(TCGv_i32 var) | 91 | |
37 | tcg_temp_free_i32(tmp); | 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; | ||
38 | } | 117 | } |
39 | 118 | ||
40 | -static TCGv_i32 gen_load_and_replicate(DisasContext *s, TCGv_i32 addr, int size) | ||
41 | -{ | ||
42 | - /* Load a single Neon element and replicate into a 32 bit TCG reg */ | ||
43 | - TCGv_i32 tmp = tcg_temp_new_i32(); | ||
44 | - switch (size) { | ||
45 | - case 0: | ||
46 | - gen_aa32_ld8u(s, tmp, addr, get_mem_index(s)); | ||
47 | - gen_neon_dup_u8(tmp, 0); | ||
48 | - break; | ||
49 | - case 1: | ||
50 | - gen_aa32_ld16u(s, tmp, addr, get_mem_index(s)); | ||
51 | - gen_neon_dup_low16(tmp); | ||
52 | - break; | ||
53 | - case 2: | ||
54 | - gen_aa32_ld32u(s, tmp, addr, get_mem_index(s)); | ||
55 | - break; | ||
56 | - default: /* Avoid compiler warnings. */ | ||
57 | - abort(); | ||
58 | - } | ||
59 | - return tmp; | ||
60 | -} | ||
61 | - | ||
62 | static int handle_vsel(uint32_t insn, uint32_t rd, uint32_t rn, uint32_t rm, | ||
63 | uint32_t dp) | ||
64 | { | ||
65 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_ls_insn(DisasContext *s, uint32_t insn) | ||
66 | int load; | ||
67 | int shift; | ||
68 | int n; | ||
69 | + int vec_size; | ||
70 | TCGv_i32 addr; | ||
71 | TCGv_i32 tmp; | ||
72 | TCGv_i32 tmp2; | ||
73 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_ls_insn(DisasContext *s, uint32_t insn) | ||
74 | } | ||
75 | addr = tcg_temp_new_i32(); | ||
76 | load_reg_var(s, addr, rn); | ||
77 | - if (nregs == 1) { | ||
78 | - /* VLD1 to all lanes: bit 5 indicates how many Dregs to write */ | ||
79 | - tmp = gen_load_and_replicate(s, addr, size); | ||
80 | - tcg_gen_st_i32(tmp, cpu_env, neon_reg_offset(rd, 0)); | ||
81 | - tcg_gen_st_i32(tmp, cpu_env, neon_reg_offset(rd, 1)); | ||
82 | - if (insn & (1 << 5)) { | ||
83 | - tcg_gen_st_i32(tmp, cpu_env, neon_reg_offset(rd + 1, 0)); | ||
84 | - tcg_gen_st_i32(tmp, cpu_env, neon_reg_offset(rd + 1, 1)); | ||
85 | - } | ||
86 | - tcg_temp_free_i32(tmp); | ||
87 | - } else { | ||
88 | - /* VLD2/3/4 to all lanes: bit 5 indicates register stride */ | ||
89 | - stride = (insn & (1 << 5)) ? 2 : 1; | ||
90 | - for (reg = 0; reg < nregs; reg++) { | ||
91 | - tmp = gen_load_and_replicate(s, addr, size); | ||
92 | - tcg_gen_st_i32(tmp, cpu_env, neon_reg_offset(rd, 0)); | ||
93 | - tcg_gen_st_i32(tmp, cpu_env, neon_reg_offset(rd, 1)); | ||
94 | - tcg_temp_free_i32(tmp); | ||
95 | - tcg_gen_addi_i32(addr, addr, 1 << size); | ||
96 | - rd += stride; | ||
97 | + | ||
98 | + /* VLD1 to all lanes: bit 5 indicates how many Dregs to write. | ||
99 | + * VLD2/3/4 to all lanes: bit 5 indicates register stride. | ||
100 | + */ | ||
101 | + stride = (insn & (1 << 5)) ? 2 : 1; | ||
102 | + vec_size = nregs == 1 ? stride * 8 : 8; | ||
103 | + | ||
104 | + tmp = tcg_temp_new_i32(); | ||
105 | + for (reg = 0; reg < nregs; reg++) { | ||
106 | + gen_aa32_ld_i32(s, tmp, addr, get_mem_index(s), | ||
107 | + s->be_data | size); | ||
108 | + if ((rd & 1) && vec_size == 16) { | ||
109 | + /* We cannot write 16 bytes at once because the | ||
110 | + * destination is unaligned. | ||
111 | + */ | ||
112 | + tcg_gen_gvec_dup_i32(size, neon_reg_offset(rd, 0), | ||
113 | + 8, 8, tmp); | ||
114 | + tcg_gen_gvec_mov(0, neon_reg_offset(rd + 1, 0), | ||
115 | + neon_reg_offset(rd, 0), 8, 8); | ||
116 | + } else { | ||
117 | + tcg_gen_gvec_dup_i32(size, neon_reg_offset(rd, 0), | ||
118 | + vec_size, vec_size, tmp); | ||
119 | } | ||
120 | + tcg_gen_addi_i32(addr, addr, 1 << size); | ||
121 | + rd += stride; | ||
122 | } | ||
123 | + tcg_temp_free_i32(tmp); | ||
124 | tcg_temp_free_i32(addr); | ||
125 | stride = (1 << size) * nregs; | ||
126 | } else { | ||
127 | -- | 119 | -- |
128 | 2.19.1 | 120 | 2.20.1 |
129 | 121 | ||
130 | 122 | diff view generated by jsdifflib |
1 | Create and use a utility function to extract the EC field | 1 | From: Samuel Ortiz <sameo@linux.intel.com> |
---|---|---|---|
2 | from a syndrome, rather than open-coding the shift. | 2 | |
3 | 3 | Those helpers are a software implementation of the ARM v8 memory zeroing | |
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> | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20181012144235.19646-9-peter.maydell@linaro.org | ||
7 | --- | 17 | --- |
8 | target/arm/internals.h | 5 +++++ | 18 | target/arm/helper.c | 92 ----------------------------------------- |
9 | target/arm/helper.c | 4 ++-- | 19 | target/arm/op_helper.c | 93 ++++++++++++++++++++++++++++++++++++++++++ |
10 | target/arm/kvm64.c | 2 +- | 20 | 2 files changed, 93 insertions(+), 92 deletions(-) |
11 | target/arm/op_helper.c | 2 +- | 21 | |
12 | 4 files changed, 9 insertions(+), 4 deletions(-) | ||
13 | |||
14 | diff --git a/target/arm/internals.h b/target/arm/internals.h | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/target/arm/internals.h | ||
17 | +++ b/target/arm/internals.h | ||
18 | @@ -XXX,XX +XXX,XX @@ enum arm_exception_class { | ||
19 | #define ARM_EL_IL (1 << ARM_EL_IL_SHIFT) | ||
20 | #define ARM_EL_ISV (1 << ARM_EL_ISV_SHIFT) | ||
21 | |||
22 | +static inline uint32_t syn_get_ec(uint32_t syn) | ||
23 | +{ | ||
24 | + return syn >> ARM_EL_EC_SHIFT; | ||
25 | +} | ||
26 | + | ||
27 | /* Utility functions for constructing various kinds of syndrome value. | ||
28 | * Note that in general we follow the AArch64 syndrome values; in a | ||
29 | * few cases the value in HSR for exceptions taken to AArch32 Hyp | ||
30 | 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 |
31 | index XXXXXXX..XXXXXXX 100644 | 23 | index XXXXXXX..XXXXXXX 100644 |
32 | --- a/target/arm/helper.c | 24 | --- a/target/arm/helper.c |
33 | +++ b/target/arm/helper.c | 25 | +++ b/target/arm/helper.c |
34 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_do_interrupt_aarch32(CPUState *cs) | 26 | @@ -XXX,XX +XXX,XX @@ bool arm_cpu_tlb_fill(CPUState *cs, vaddr address, int size, |
35 | uint32_t moe; | 27 | #endif |
36 | 28 | } | |
37 | /* If this is a debug exception we must update the DBGDSCR.MOE bits */ | 29 | |
38 | - switch (env->exception.syndrome >> ARM_EL_EC_SHIFT) { | 30 | -void HELPER(dc_zva)(CPUARMState *env, uint64_t vaddr_in) |
39 | + switch (syn_get_ec(env->exception.syndrome)) { | 31 | -{ |
40 | case EC_BREAKPOINT: | 32 | - /* |
41 | case EC_BREAKPOINT_SAME_EL: | 33 | - * Implement DC ZVA, which zeroes a fixed-length block of memory. |
42 | moe = 1; | 34 | - * Note that we do not implement the (architecturally mandated) |
43 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_do_interrupt(CPUState *cs) | 35 | - * alignment fault for attempts to use this on Device memory |
44 | if (qemu_loglevel_mask(CPU_LOG_INT) | 36 | - * (which matches the usual QEMU behaviour of not implementing either |
45 | && !excp_is_internal(cs->exception_index)) { | 37 | - * alignment faults or any memory attribute handling). |
46 | qemu_log_mask(CPU_LOG_INT, "...with ESR 0x%x/0x%" PRIx32 "\n", | 38 | - */ |
47 | - env->exception.syndrome >> ARM_EL_EC_SHIFT, | 39 | - |
48 | + syn_get_ec(env->exception.syndrome), | 40 | - ARMCPU *cpu = env_archcpu(env); |
49 | env->exception.syndrome); | 41 | - uint64_t blocklen = 4 << cpu->dcz_blocksize; |
50 | } | 42 | - uint64_t vaddr = vaddr_in & ~(blocklen - 1); |
51 | 43 | - | |
52 | diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c | 44 | -#ifndef CONFIG_USER_ONLY |
53 | index XXXXXXX..XXXXXXX 100644 | 45 | - { |
54 | --- a/target/arm/kvm64.c | 46 | - /* |
55 | +++ b/target/arm/kvm64.c | 47 | - * Slightly awkwardly, QEMU's TARGET_PAGE_SIZE may be less than |
56 | @@ -XXX,XX +XXX,XX @@ int kvm_arch_remove_sw_breakpoint(CPUState *cs, struct kvm_sw_breakpoint *bp) | 48 | - * the block size so we might have to do more than one TLB lookup. |
57 | 49 | - * We know that in fact for any v8 CPU the page size is at least 4K | |
58 | bool kvm_arm_handle_debug(CPUState *cs, struct kvm_debug_exit_arch *debug_exit) | 50 | - * and the block size must be 2K or less, but TARGET_PAGE_SIZE is only |
59 | { | 51 | - * 1K as an artefact of legacy v5 subpage support being present in the |
60 | - int hsr_ec = debug_exit->hsr >> ARM_EL_EC_SHIFT; | 52 | - * same QEMU executable. So in practice the hostaddr[] array has |
61 | + int hsr_ec = syn_get_ec(debug_exit->hsr); | 53 | - * two entries, given the current setting of TARGET_PAGE_BITS_MIN. |
62 | ARMCPU *cpu = ARM_CPU(cs); | 54 | - */ |
63 | CPUClass *cc = CPU_GET_CLASS(cs); | 55 | - int maxidx = DIV_ROUND_UP(blocklen, TARGET_PAGE_SIZE); |
64 | CPUARMState *env = &cpu->env; | 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. */ | ||
65 | diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c | 125 | diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c |
66 | index XXXXXXX..XXXXXXX 100644 | 126 | index XXXXXXX..XXXXXXX 100644 |
67 | --- a/target/arm/op_helper.c | 127 | --- a/target/arm/op_helper.c |
68 | +++ b/target/arm/op_helper.c | 128 | +++ b/target/arm/op_helper.c |
69 | @@ -XXX,XX +XXX,XX @@ void raise_exception(CPUARMState *env, uint32_t excp, | 129 | @@ -XXX,XX +XXX,XX @@ |
70 | * (see DDI0478C.a D1.10.4) | 130 | * License along with this library; if not, see <http://www.gnu.org/licenses/>. |
71 | */ | 131 | */ |
72 | target_el = 2; | 132 | #include "qemu/osdep.h" |
73 | - if (syndrome >> ARM_EL_EC_SHIFT == EC_ADVSIMDFPACCESSTRAP) { | 133 | +#include "qemu/units.h" |
74 | + if (syn_get_ec(syndrome) == EC_ADVSIMDFPACCESSTRAP) { | 134 | #include "qemu/log.h" |
75 | syndrome = syn_uncategorized(); | 135 | #include "qemu/main-loop.h" |
76 | } | 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)); | ||
77 | } | 139 | } |
140 | } | ||
141 | + | ||
142 | +void HELPER(dc_zva)(CPUARMState *env, uint64_t vaddr_in) | ||
143 | +{ | ||
144 | + /* | ||
145 | + * Implement DC ZVA, which zeroes a fixed-length block of memory. | ||
146 | + * Note that we do not implement the (architecturally mandated) | ||
147 | + * alignment fault for attempts to use this on Device memory | ||
148 | + * (which matches the usual QEMU behaviour of not implementing either | ||
149 | + * alignment faults or any memory attribute handling). | ||
150 | + */ | ||
151 | + | ||
152 | + ARMCPU *cpu = env_archcpu(env); | ||
153 | + uint64_t blocklen = 4 << cpu->dcz_blocksize; | ||
154 | + uint64_t vaddr = vaddr_in & ~(blocklen - 1); | ||
155 | + | ||
156 | +#ifndef CONFIG_USER_ONLY | ||
157 | + { | ||
158 | + /* | ||
159 | + * Slightly awkwardly, QEMU's TARGET_PAGE_SIZE may be less than | ||
160 | + * the block size so we might have to do more than one TLB lookup. | ||
161 | + * We know that in fact for any v8 CPU the page size is at least 4K | ||
162 | + * and the block size must be 2K or less, but TARGET_PAGE_SIZE is only | ||
163 | + * 1K as an artefact of legacy v5 subpage support being present in the | ||
164 | + * same QEMU executable. So in practice the hostaddr[] array has | ||
165 | + * two entries, given the current setting of TARGET_PAGE_BITS_MIN. | ||
166 | + */ | ||
167 | + int maxidx = DIV_ROUND_UP(blocklen, TARGET_PAGE_SIZE); | ||
168 | + void *hostaddr[DIV_ROUND_UP(2 * KiB, 1 << TARGET_PAGE_BITS_MIN)]; | ||
169 | + int try, i; | ||
170 | + unsigned mmu_idx = cpu_mmu_index(env, false); | ||
171 | + TCGMemOpIdx oi = make_memop_idx(MO_UB, mmu_idx); | ||
172 | + | ||
173 | + assert(maxidx <= ARRAY_SIZE(hostaddr)); | ||
174 | + | ||
175 | + for (try = 0; try < 2; try++) { | ||
176 | + | ||
177 | + for (i = 0; i < maxidx; i++) { | ||
178 | + hostaddr[i] = tlb_vaddr_to_host(env, | ||
179 | + vaddr + TARGET_PAGE_SIZE * i, | ||
180 | + 1, mmu_idx); | ||
181 | + if (!hostaddr[i]) { | ||
182 | + break; | ||
183 | + } | ||
184 | + } | ||
185 | + if (i == maxidx) { | ||
186 | + /* | ||
187 | + * If it's all in the TLB it's fair game for just writing to; | ||
188 | + * we know we don't need to update dirty status, etc. | ||
189 | + */ | ||
190 | + for (i = 0; i < maxidx - 1; i++) { | ||
191 | + memset(hostaddr[i], 0, TARGET_PAGE_SIZE); | ||
192 | + } | ||
193 | + memset(hostaddr[i], 0, blocklen - (i * TARGET_PAGE_SIZE)); | ||
194 | + return; | ||
195 | + } | ||
196 | + /* | ||
197 | + * OK, try a store and see if we can populate the tlb. This | ||
198 | + * might cause an exception if the memory isn't writable, | ||
199 | + * in which case we will longjmp out of here. We must for | ||
200 | + * this purpose use the actual register value passed to us | ||
201 | + * so that we get the fault address right. | ||
202 | + */ | ||
203 | + helper_ret_stb_mmu(env, vaddr_in, 0, oi, GETPC()); | ||
204 | + /* Now we can populate the other TLB entries, if any */ | ||
205 | + for (i = 0; i < maxidx; i++) { | ||
206 | + uint64_t va = vaddr + TARGET_PAGE_SIZE * i; | ||
207 | + if (va != (vaddr_in & TARGET_PAGE_MASK)) { | ||
208 | + helper_ret_stb_mmu(env, va, 0, oi, GETPC()); | ||
209 | + } | ||
210 | + } | ||
211 | + } | ||
212 | + | ||
213 | + /* | ||
214 | + * Slow path (probably attempt to do this to an I/O device or | ||
215 | + * similar, or clearing of a block of code we have translations | ||
216 | + * cached for). Just do a series of byte writes as the architecture | ||
217 | + * demands. It's not worth trying to use a cpu_physical_memory_map(), | ||
218 | + * memset(), unmap() sequence here because: | ||
219 | + * + we'd need to account for the blocksize being larger than a page | ||
220 | + * + the direct-RAM access case is almost always going to be dealt | ||
221 | + * with in the fastpath code above, so there's no speed benefit | ||
222 | + * + we would have to deal with the map returning NULL because the | ||
223 | + * bounce buffer was in use | ||
224 | + */ | ||
225 | + for (i = 0; i < blocklen; i++) { | ||
226 | + helper_ret_stb_mmu(env, vaddr + i, 0, oi, GETPC()); | ||
227 | + } | ||
228 | + } | ||
229 | +#else | ||
230 | + memset(g2h(vaddr), 0, blocklen); | ||
231 | +#endif | ||
232 | +} | ||
78 | -- | 233 | -- |
79 | 2.19.1 | 234 | 2.20.1 |
80 | 235 | ||
81 | 236 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | Most of the v8 extensions are self-contained within the ISAR | 3 | Suggested-by: Samuel Ortiz <sameo@linux.intel.com> |
4 | registers and are not implied by other feature bits, which | 4 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> |
5 | makes them the easiest to convert. | 5 | Message-id: 20190701132516.26392-11-philmd@redhat.com |
6 | |||
7 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20181016223115.24100-4-richard.henderson@linaro.org | ||
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | --- | 8 | --- |
13 | target/arm/cpu.h | 131 +++++++++++++++++++++++++++++++++---- | 9 | target/arm/cpu.h | 2 - |
14 | target/arm/translate.h | 7 ++ | 10 | target/arm/translate.h | 5 - |
15 | linux-user/elfload.c | 46 ++++++++----- | 11 | target/arm/cpu.c | 226 +++++++++++++++++++++++++++++++++++++ |
16 | target/arm/cpu.c | 27 +++++--- | 12 | target/arm/translate-a64.c | 128 --------------------- |
17 | target/arm/cpu64.c | 57 +++++++++------- | 13 | target/arm/translate.c | 88 --------------- |
18 | target/arm/translate-a64.c | 101 ++++++++++++++-------------- | 14 | 5 files changed, 226 insertions(+), 223 deletions(-) |
19 | target/arm/translate.c | 36 +++++----- | ||
20 | 7 files changed, 273 insertions(+), 132 deletions(-) | ||
21 | 15 | ||
22 | 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 |
23 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
24 | --- a/target/arm/cpu.h | 18 | --- a/target/arm/cpu.h |
25 | +++ b/target/arm/cpu.h | 19 | +++ b/target/arm/cpu.h |
26 | @@ -XXX,XX +XXX,XX @@ typedef enum ARMPSCIState { | 20 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_do_interrupt(CPUState *cpu); |
27 | PSCI_ON_PENDING = 2 | 21 | void arm_v7m_cpu_do_interrupt(CPUState *cpu); |
28 | } ARMPSCIState; | 22 | bool arm_cpu_exec_interrupt(CPUState *cpu, int int_req); |
29 | 23 | ||
30 | +typedef struct ARMISARegisters ARMISARegisters; | 24 | -void arm_cpu_dump_state(CPUState *cs, FILE *f, int flags); |
31 | + | 25 | - |
32 | /** | 26 | hwaddr arm_cpu_get_phys_page_attrs_debug(CPUState *cpu, vaddr addr, |
33 | * ARMCPU: | 27 | MemTxAttrs *attrs); |
34 | * @env: #CPUARMState | 28 | |
35 | @@ -XXX,XX +XXX,XX @@ enum arm_features { | ||
36 | ARM_FEATURE_LPAE, /* has Large Physical Address Extension */ | ||
37 | ARM_FEATURE_V8, | ||
38 | ARM_FEATURE_AARCH64, /* supports 64 bit mode */ | ||
39 | - ARM_FEATURE_V8_AES, /* implements AES part of v8 Crypto Extensions */ | ||
40 | ARM_FEATURE_CBAR, /* has cp15 CBAR */ | ||
41 | ARM_FEATURE_CRC, /* ARMv8 CRC instructions */ | ||
42 | ARM_FEATURE_CBAR_RO, /* has cp15 CBAR and it is read-only */ | ||
43 | ARM_FEATURE_EL2, /* has EL2 Virtualization support */ | ||
44 | ARM_FEATURE_EL3, /* has EL3 Secure monitor support */ | ||
45 | - ARM_FEATURE_V8_SHA1, /* implements SHA1 part of v8 Crypto Extensions */ | ||
46 | - ARM_FEATURE_V8_SHA256, /* implements SHA256 part of v8 Crypto Extensions */ | ||
47 | - ARM_FEATURE_V8_PMULL, /* implements PMULL part of v8 Crypto Extensions */ | ||
48 | ARM_FEATURE_THUMB_DSP, /* DSP insns supported in the Thumb encodings */ | ||
49 | ARM_FEATURE_PMU, /* has PMU support */ | ||
50 | ARM_FEATURE_VBAR, /* has cp15 VBAR */ | ||
51 | ARM_FEATURE_M_SECURITY, /* M profile Security Extension */ | ||
52 | ARM_FEATURE_JAZELLE, /* has (trivial) Jazelle implementation */ | ||
53 | ARM_FEATURE_SVE, /* has Scalable Vector Extension */ | ||
54 | - ARM_FEATURE_V8_SHA512, /* implements SHA512 part of v8 Crypto Extensions */ | ||
55 | - ARM_FEATURE_V8_SHA3, /* implements SHA3 part of v8 Crypto Extensions */ | ||
56 | - ARM_FEATURE_V8_SM3, /* implements SM3 part of v8 Crypto Extensions */ | ||
57 | - ARM_FEATURE_V8_SM4, /* implements SM4 part of v8 Crypto Extensions */ | ||
58 | - ARM_FEATURE_V8_ATOMICS, /* ARMv8.1-Atomics feature */ | ||
59 | - ARM_FEATURE_V8_RDM, /* implements v8.1 simd round multiply */ | ||
60 | - ARM_FEATURE_V8_DOTPROD, /* implements v8.2 simd dot product */ | ||
61 | ARM_FEATURE_V8_FP16, /* implements v8.2 half-precision float */ | ||
62 | - ARM_FEATURE_V8_FCMA, /* has complex number part of v8.3 extensions. */ | ||
63 | ARM_FEATURE_M_MAIN, /* M profile Main Extension */ | ||
64 | }; | ||
65 | |||
66 | @@ -XXX,XX +XXX,XX @@ static inline uint64_t *aa64_vfp_qreg(CPUARMState *env, unsigned regno) | ||
67 | /* Shared between translate-sve.c and sve_helper.c. */ | ||
68 | extern const uint64_t pred_esz_masks[4]; | ||
69 | |||
70 | +/* | ||
71 | + * 32-bit feature tests via id registers. | ||
72 | + */ | ||
73 | +static inline bool isar_feature_aa32_aes(const ARMISARegisters *id) | ||
74 | +{ | ||
75 | + return FIELD_EX32(id->id_isar5, ID_ISAR5, AES) != 0; | ||
76 | +} | ||
77 | + | ||
78 | +static inline bool isar_feature_aa32_pmull(const ARMISARegisters *id) | ||
79 | +{ | ||
80 | + return FIELD_EX32(id->id_isar5, ID_ISAR5, AES) > 1; | ||
81 | +} | ||
82 | + | ||
83 | +static inline bool isar_feature_aa32_sha1(const ARMISARegisters *id) | ||
84 | +{ | ||
85 | + return FIELD_EX32(id->id_isar5, ID_ISAR5, SHA1) != 0; | ||
86 | +} | ||
87 | + | ||
88 | +static inline bool isar_feature_aa32_sha2(const ARMISARegisters *id) | ||
89 | +{ | ||
90 | + return FIELD_EX32(id->id_isar5, ID_ISAR5, SHA2) != 0; | ||
91 | +} | ||
92 | + | ||
93 | +static inline bool isar_feature_aa32_crc32(const ARMISARegisters *id) | ||
94 | +{ | ||
95 | + return FIELD_EX32(id->id_isar5, ID_ISAR5, CRC32) != 0; | ||
96 | +} | ||
97 | + | ||
98 | +static inline bool isar_feature_aa32_rdm(const ARMISARegisters *id) | ||
99 | +{ | ||
100 | + return FIELD_EX32(id->id_isar5, ID_ISAR5, RDM) != 0; | ||
101 | +} | ||
102 | + | ||
103 | +static inline bool isar_feature_aa32_vcma(const ARMISARegisters *id) | ||
104 | +{ | ||
105 | + return FIELD_EX32(id->id_isar5, ID_ISAR5, VCMA) != 0; | ||
106 | +} | ||
107 | + | ||
108 | +static inline bool isar_feature_aa32_dp(const ARMISARegisters *id) | ||
109 | +{ | ||
110 | + return FIELD_EX32(id->id_isar6, ID_ISAR6, DP) != 0; | ||
111 | +} | ||
112 | + | ||
113 | +/* | ||
114 | + * 64-bit feature tests via id registers. | ||
115 | + */ | ||
116 | +static inline bool isar_feature_aa64_aes(const ARMISARegisters *id) | ||
117 | +{ | ||
118 | + return FIELD_EX64(id->id_aa64isar0, ID_AA64ISAR0, AES) != 0; | ||
119 | +} | ||
120 | + | ||
121 | +static inline bool isar_feature_aa64_pmull(const ARMISARegisters *id) | ||
122 | +{ | ||
123 | + return FIELD_EX64(id->id_aa64isar0, ID_AA64ISAR0, AES) > 1; | ||
124 | +} | ||
125 | + | ||
126 | +static inline bool isar_feature_aa64_sha1(const ARMISARegisters *id) | ||
127 | +{ | ||
128 | + return FIELD_EX64(id->id_aa64isar0, ID_AA64ISAR0, SHA1) != 0; | ||
129 | +} | ||
130 | + | ||
131 | +static inline bool isar_feature_aa64_sha256(const ARMISARegisters *id) | ||
132 | +{ | ||
133 | + return FIELD_EX64(id->id_aa64isar0, ID_AA64ISAR0, SHA2) != 0; | ||
134 | +} | ||
135 | + | ||
136 | +static inline bool isar_feature_aa64_sha512(const ARMISARegisters *id) | ||
137 | +{ | ||
138 | + return FIELD_EX64(id->id_aa64isar0, ID_AA64ISAR0, SHA2) > 1; | ||
139 | +} | ||
140 | + | ||
141 | +static inline bool isar_feature_aa64_crc32(const ARMISARegisters *id) | ||
142 | +{ | ||
143 | + return FIELD_EX64(id->id_aa64isar0, ID_AA64ISAR0, CRC32) != 0; | ||
144 | +} | ||
145 | + | ||
146 | +static inline bool isar_feature_aa64_atomics(const ARMISARegisters *id) | ||
147 | +{ | ||
148 | + return FIELD_EX64(id->id_aa64isar0, ID_AA64ISAR0, ATOMIC) != 0; | ||
149 | +} | ||
150 | + | ||
151 | +static inline bool isar_feature_aa64_rdm(const ARMISARegisters *id) | ||
152 | +{ | ||
153 | + return FIELD_EX64(id->id_aa64isar0, ID_AA64ISAR0, RDM) != 0; | ||
154 | +} | ||
155 | + | ||
156 | +static inline bool isar_feature_aa64_sha3(const ARMISARegisters *id) | ||
157 | +{ | ||
158 | + return FIELD_EX64(id->id_aa64isar0, ID_AA64ISAR0, SHA3) != 0; | ||
159 | +} | ||
160 | + | ||
161 | +static inline bool isar_feature_aa64_sm3(const ARMISARegisters *id) | ||
162 | +{ | ||
163 | + return FIELD_EX64(id->id_aa64isar0, ID_AA64ISAR0, SM3) != 0; | ||
164 | +} | ||
165 | + | ||
166 | +static inline bool isar_feature_aa64_sm4(const ARMISARegisters *id) | ||
167 | +{ | ||
168 | + return FIELD_EX64(id->id_aa64isar0, ID_AA64ISAR0, SM4) != 0; | ||
169 | +} | ||
170 | + | ||
171 | +static inline bool isar_feature_aa64_dp(const ARMISARegisters *id) | ||
172 | +{ | ||
173 | + return FIELD_EX64(id->id_aa64isar0, ID_AA64ISAR0, DP) != 0; | ||
174 | +} | ||
175 | + | ||
176 | +static inline bool isar_feature_aa64_fcma(const ARMISARegisters *id) | ||
177 | +{ | ||
178 | + return FIELD_EX64(id->id_aa64isar1, ID_AA64ISAR1, FCMA) != 0; | ||
179 | +} | ||
180 | + | ||
181 | +/* | ||
182 | + * Forward to the above feature tests given an ARMCPU pointer. | ||
183 | + */ | ||
184 | +#define cpu_isar_feature(name, cpu) \ | ||
185 | + ({ ARMCPU *cpu_ = (cpu); isar_feature_##name(&cpu_->isar); }) | ||
186 | + | ||
187 | #endif | ||
188 | 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 |
189 | index XXXXXXX..XXXXXXX 100644 | 30 | index XXXXXXX..XXXXXXX 100644 |
190 | --- a/target/arm/translate.h | 31 | --- a/target/arm/translate.h |
191 | +++ b/target/arm/translate.h | 32 | +++ b/target/arm/translate.h |
192 | @@ -XXX,XX +XXX,XX @@ | 33 | @@ -XXX,XX +XXX,XX @@ static inline void disas_set_insn_syndrome(DisasContext *s, uint32_t syn) |
193 | /* internal defines */ | 34 | #ifdef TARGET_AARCH64 |
194 | typedef struct DisasContext { | 35 | void a64_translate_init(void); |
195 | DisasContextBase base; | 36 | void gen_a64_set_pc_im(uint64_t val); |
196 | + const ARMISARegisters *isar; | 37 | -void aarch64_cpu_dump_state(CPUState *cs, FILE *f, int flags); |
197 | 38 | extern const TranslatorOps aarch64_translator_ops; | |
198 | target_ulong pc; | 39 | #else |
199 | target_ulong page_start; | 40 | static inline void a64_translate_init(void) |
200 | @@ -XXX,XX +XXX,XX @@ static inline TCGv_i32 get_ahp_flag(void) | 41 | @@ -XXX,XX +XXX,XX @@ static inline void a64_translate_init(void) |
201 | return ret; | 42 | static inline void gen_a64_set_pc_im(uint64_t val) |
43 | { | ||
202 | } | 44 | } |
203 | 45 | - | |
204 | +/* | 46 | -static inline void aarch64_cpu_dump_state(CPUState *cs, FILE *f, int flags) |
205 | + * Forward to the isar_feature_* tests given a DisasContext pointer. | 47 | -{ |
206 | + */ | 48 | -} |
207 | +#define dc_isar_feature(name, ctx) \ | 49 | #endif |
208 | + ({ DisasContext *ctx_ = (ctx); isar_feature_##name(ctx_->isar); }) | 50 | |
209 | + | 51 | void arm_test_cc(DisasCompare *cmp, int cc); |
210 | #endif /* TARGET_ARM_TRANSLATE_H */ | ||
211 | diff --git a/linux-user/elfload.c b/linux-user/elfload.c | ||
212 | index XXXXXXX..XXXXXXX 100644 | ||
213 | --- a/linux-user/elfload.c | ||
214 | +++ b/linux-user/elfload.c | ||
215 | @@ -XXX,XX +XXX,XX @@ static uint32_t get_elf_hwcap(void) | ||
216 | /* probe for the extra features */ | ||
217 | #define GET_FEATURE(feat, hwcap) \ | ||
218 | do { if (arm_feature(&cpu->env, feat)) { hwcaps |= hwcap; } } while (0) | ||
219 | + | ||
220 | +#define GET_FEATURE_ID(feat, hwcap) \ | ||
221 | + do { if (cpu_isar_feature(feat, cpu)) { hwcaps |= hwcap; } } while (0) | ||
222 | + | ||
223 | /* EDSP is in v5TE and above, but all our v5 CPUs are v5TE */ | ||
224 | GET_FEATURE(ARM_FEATURE_V5, ARM_HWCAP_ARM_EDSP); | ||
225 | GET_FEATURE(ARM_FEATURE_VFP, ARM_HWCAP_ARM_VFP); | ||
226 | @@ -XXX,XX +XXX,XX @@ static uint32_t get_elf_hwcap2(void) | ||
227 | ARMCPU *cpu = ARM_CPU(thread_cpu); | ||
228 | uint32_t hwcaps = 0; | ||
229 | |||
230 | - GET_FEATURE(ARM_FEATURE_V8_AES, ARM_HWCAP2_ARM_AES); | ||
231 | - GET_FEATURE(ARM_FEATURE_V8_PMULL, ARM_HWCAP2_ARM_PMULL); | ||
232 | - GET_FEATURE(ARM_FEATURE_V8_SHA1, ARM_HWCAP2_ARM_SHA1); | ||
233 | - GET_FEATURE(ARM_FEATURE_V8_SHA256, ARM_HWCAP2_ARM_SHA2); | ||
234 | - GET_FEATURE(ARM_FEATURE_CRC, ARM_HWCAP2_ARM_CRC32); | ||
235 | + GET_FEATURE_ID(aa32_aes, ARM_HWCAP2_ARM_AES); | ||
236 | + GET_FEATURE_ID(aa32_pmull, ARM_HWCAP2_ARM_PMULL); | ||
237 | + GET_FEATURE_ID(aa32_sha1, ARM_HWCAP2_ARM_SHA1); | ||
238 | + GET_FEATURE_ID(aa32_sha2, ARM_HWCAP2_ARM_SHA2); | ||
239 | + GET_FEATURE_ID(aa32_crc32, ARM_HWCAP2_ARM_CRC32); | ||
240 | return hwcaps; | ||
241 | } | ||
242 | |||
243 | #undef GET_FEATURE | ||
244 | +#undef GET_FEATURE_ID | ||
245 | |||
246 | #else | ||
247 | /* 64 bit ARM definitions */ | ||
248 | @@ -XXX,XX +XXX,XX @@ static uint32_t get_elf_hwcap(void) | ||
249 | /* probe for the extra features */ | ||
250 | #define GET_FEATURE(feat, hwcap) \ | ||
251 | do { if (arm_feature(&cpu->env, feat)) { hwcaps |= hwcap; } } while (0) | ||
252 | - GET_FEATURE(ARM_FEATURE_V8_AES, ARM_HWCAP_A64_AES); | ||
253 | - GET_FEATURE(ARM_FEATURE_V8_PMULL, ARM_HWCAP_A64_PMULL); | ||
254 | - GET_FEATURE(ARM_FEATURE_V8_SHA1, ARM_HWCAP_A64_SHA1); | ||
255 | - GET_FEATURE(ARM_FEATURE_V8_SHA256, ARM_HWCAP_A64_SHA2); | ||
256 | - GET_FEATURE(ARM_FEATURE_CRC, ARM_HWCAP_A64_CRC32); | ||
257 | - GET_FEATURE(ARM_FEATURE_V8_SHA3, ARM_HWCAP_A64_SHA3); | ||
258 | - GET_FEATURE(ARM_FEATURE_V8_SM3, ARM_HWCAP_A64_SM3); | ||
259 | - GET_FEATURE(ARM_FEATURE_V8_SM4, ARM_HWCAP_A64_SM4); | ||
260 | - GET_FEATURE(ARM_FEATURE_V8_SHA512, ARM_HWCAP_A64_SHA512); | ||
261 | +#define GET_FEATURE_ID(feat, hwcap) \ | ||
262 | + do { if (cpu_isar_feature(feat, cpu)) { hwcaps |= hwcap; } } while (0) | ||
263 | + | ||
264 | + GET_FEATURE_ID(aa64_aes, ARM_HWCAP_A64_AES); | ||
265 | + GET_FEATURE_ID(aa64_pmull, ARM_HWCAP_A64_PMULL); | ||
266 | + GET_FEATURE_ID(aa64_sha1, ARM_HWCAP_A64_SHA1); | ||
267 | + GET_FEATURE_ID(aa64_sha256, ARM_HWCAP_A64_SHA2); | ||
268 | + GET_FEATURE_ID(aa64_sha512, ARM_HWCAP_A64_SHA512); | ||
269 | + GET_FEATURE_ID(aa64_crc32, ARM_HWCAP_A64_CRC32); | ||
270 | + GET_FEATURE_ID(aa64_sha3, ARM_HWCAP_A64_SHA3); | ||
271 | + GET_FEATURE_ID(aa64_sm3, ARM_HWCAP_A64_SM3); | ||
272 | + GET_FEATURE_ID(aa64_sm4, ARM_HWCAP_A64_SM4); | ||
273 | GET_FEATURE(ARM_FEATURE_V8_FP16, | ||
274 | ARM_HWCAP_A64_FPHP | ARM_HWCAP_A64_ASIMDHP); | ||
275 | - GET_FEATURE(ARM_FEATURE_V8_ATOMICS, ARM_HWCAP_A64_ATOMICS); | ||
276 | - GET_FEATURE(ARM_FEATURE_V8_RDM, ARM_HWCAP_A64_ASIMDRDM); | ||
277 | - GET_FEATURE(ARM_FEATURE_V8_DOTPROD, ARM_HWCAP_A64_ASIMDDP); | ||
278 | - GET_FEATURE(ARM_FEATURE_V8_FCMA, ARM_HWCAP_A64_FCMA); | ||
279 | + GET_FEATURE_ID(aa64_atomics, ARM_HWCAP_A64_ATOMICS); | ||
280 | + GET_FEATURE_ID(aa64_rdm, ARM_HWCAP_A64_ASIMDRDM); | ||
281 | + GET_FEATURE_ID(aa64_dp, ARM_HWCAP_A64_ASIMDDP); | ||
282 | + GET_FEATURE_ID(aa64_fcma, ARM_HWCAP_A64_FCMA); | ||
283 | GET_FEATURE(ARM_FEATURE_SVE, ARM_HWCAP_A64_SVE); | ||
284 | + | ||
285 | #undef GET_FEATURE | ||
286 | +#undef GET_FEATURE_ID | ||
287 | |||
288 | return hwcaps; | ||
289 | } | ||
290 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | 52 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c |
291 | index XXXXXXX..XXXXXXX 100644 | 53 | index XXXXXXX..XXXXXXX 100644 |
292 | --- a/target/arm/cpu.c | 54 | --- a/target/arm/cpu.c |
293 | +++ b/target/arm/cpu.c | 55 | +++ b/target/arm/cpu.c |
294 | @@ -XXX,XX +XXX,XX @@ static void arm_max_initfn(Object *obj) | 56 | @@ -XXX,XX +XXX,XX @@ |
295 | cortex_a15_initfn(obj); | 57 | */ |
296 | #ifdef CONFIG_USER_ONLY | 58 | |
297 | /* We don't set these in system emulation mode for the moment, | 59 | #include "qemu/osdep.h" |
298 | - * since we don't correctly set the ID registers to advertise them, | 60 | +#include "qemu/qemu-print.h" |
299 | + * since we don't correctly set (all of) the ID registers to | 61 | #include "qemu-common.h" |
300 | + * advertise them. | 62 | #include "target/arm/idau.h" |
301 | */ | 63 | #include "qemu/module.h" |
302 | set_feature(&cpu->env, ARM_FEATURE_V8); | 64 | @@ -XXX,XX +XXX,XX @@ static void arm_disas_set_info(CPUState *cpu, disassemble_info *info) |
303 | - set_feature(&cpu->env, ARM_FEATURE_V8_AES); | ||
304 | - set_feature(&cpu->env, ARM_FEATURE_V8_SHA1); | ||
305 | - set_feature(&cpu->env, ARM_FEATURE_V8_SHA256); | ||
306 | - set_feature(&cpu->env, ARM_FEATURE_V8_PMULL); | ||
307 | - set_feature(&cpu->env, ARM_FEATURE_CRC); | ||
308 | - set_feature(&cpu->env, ARM_FEATURE_V8_RDM); | ||
309 | - set_feature(&cpu->env, ARM_FEATURE_V8_DOTPROD); | ||
310 | - set_feature(&cpu->env, ARM_FEATURE_V8_FCMA); | ||
311 | + { | ||
312 | + uint32_t t; | ||
313 | + | ||
314 | + t = cpu->isar.id_isar5; | ||
315 | + t = FIELD_DP32(t, ID_ISAR5, AES, 2); | ||
316 | + t = FIELD_DP32(t, ID_ISAR5, SHA1, 1); | ||
317 | + t = FIELD_DP32(t, ID_ISAR5, SHA2, 1); | ||
318 | + t = FIELD_DP32(t, ID_ISAR5, CRC32, 1); | ||
319 | + t = FIELD_DP32(t, ID_ISAR5, RDM, 1); | ||
320 | + t = FIELD_DP32(t, ID_ISAR5, VCMA, 1); | ||
321 | + cpu->isar.id_isar5 = t; | ||
322 | + | ||
323 | + t = cpu->isar.id_isar6; | ||
324 | + t = FIELD_DP32(t, ID_ISAR6, DP, 1); | ||
325 | + cpu->isar.id_isar6 = t; | ||
326 | + } | ||
327 | #endif | 65 | #endif |
328 | } | ||
329 | } | 66 | } |
330 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | 67 | |
331 | index XXXXXXX..XXXXXXX 100644 | 68 | +#ifdef TARGET_AARCH64 |
332 | --- a/target/arm/cpu64.c | 69 | + |
333 | +++ b/target/arm/cpu64.c | 70 | +static void aarch64_cpu_dump_state(CPUState *cs, FILE *f, int flags) |
334 | @@ -XXX,XX +XXX,XX @@ static void aarch64_a57_initfn(Object *obj) | 71 | +{ |
335 | set_feature(&cpu->env, ARM_FEATURE_GENERIC_TIMER); | 72 | + ARMCPU *cpu = ARM_CPU(cs); |
336 | set_feature(&cpu->env, ARM_FEATURE_AARCH64); | 73 | + CPUARMState *env = &cpu->env; |
337 | set_feature(&cpu->env, ARM_FEATURE_CBAR_RO); | 74 | + uint32_t psr = pstate_read(env); |
338 | - set_feature(&cpu->env, ARM_FEATURE_V8_AES); | 75 | + int i; |
339 | - set_feature(&cpu->env, ARM_FEATURE_V8_SHA1); | 76 | + int el = arm_current_el(env); |
340 | - set_feature(&cpu->env, ARM_FEATURE_V8_SHA256); | 77 | + const char *ns_status; |
341 | - set_feature(&cpu->env, ARM_FEATURE_V8_PMULL); | 78 | + |
342 | - set_feature(&cpu->env, ARM_FEATURE_CRC); | 79 | + qemu_fprintf(f, " PC=%016" PRIx64 " ", env->pc); |
343 | set_feature(&cpu->env, ARM_FEATURE_EL2); | 80 | + for (i = 0; i < 32; i++) { |
344 | set_feature(&cpu->env, ARM_FEATURE_EL3); | 81 | + if (i == 31) { |
345 | set_feature(&cpu->env, ARM_FEATURE_PMU); | 82 | + qemu_fprintf(f, " SP=%016" PRIx64 "\n", env->xregs[i]); |
346 | @@ -XXX,XX +XXX,XX @@ static void aarch64_a53_initfn(Object *obj) | 83 | + } else { |
347 | set_feature(&cpu->env, ARM_FEATURE_GENERIC_TIMER); | 84 | + qemu_fprintf(f, "X%02d=%016" PRIx64 "%s", i, env->xregs[i], |
348 | set_feature(&cpu->env, ARM_FEATURE_AARCH64); | 85 | + (i + 2) % 3 ? " " : "\n"); |
349 | set_feature(&cpu->env, ARM_FEATURE_CBAR_RO); | 86 | + } |
350 | - set_feature(&cpu->env, ARM_FEATURE_V8_AES); | 87 | + } |
351 | - set_feature(&cpu->env, ARM_FEATURE_V8_SHA1); | 88 | + |
352 | - set_feature(&cpu->env, ARM_FEATURE_V8_SHA256); | 89 | + if (arm_feature(env, ARM_FEATURE_EL3) && el != 3) { |
353 | - set_feature(&cpu->env, ARM_FEATURE_V8_PMULL); | 90 | + ns_status = env->cp15.scr_el3 & SCR_NS ? "NS " : "S "; |
354 | - set_feature(&cpu->env, ARM_FEATURE_CRC); | 91 | + } else { |
355 | set_feature(&cpu->env, ARM_FEATURE_EL2); | 92 | + ns_status = ""; |
356 | set_feature(&cpu->env, ARM_FEATURE_EL3); | 93 | + } |
357 | set_feature(&cpu->env, ARM_FEATURE_PMU); | 94 | + qemu_fprintf(f, "PSTATE=%08x %c%c%c%c %sEL%d%c", |
358 | @@ -XXX,XX +XXX,XX @@ static void aarch64_a72_initfn(Object *obj) | 95 | + psr, |
359 | set_feature(&cpu->env, ARM_FEATURE_GENERIC_TIMER); | 96 | + psr & PSTATE_N ? 'N' : '-', |
360 | set_feature(&cpu->env, ARM_FEATURE_AARCH64); | 97 | + psr & PSTATE_Z ? 'Z' : '-', |
361 | set_feature(&cpu->env, ARM_FEATURE_CBAR_RO); | 98 | + psr & PSTATE_C ? 'C' : '-', |
362 | - set_feature(&cpu->env, ARM_FEATURE_V8_AES); | 99 | + psr & PSTATE_V ? 'V' : '-', |
363 | - set_feature(&cpu->env, ARM_FEATURE_V8_SHA1); | 100 | + ns_status, |
364 | - set_feature(&cpu->env, ARM_FEATURE_V8_SHA256); | 101 | + el, |
365 | - set_feature(&cpu->env, ARM_FEATURE_V8_PMULL); | 102 | + psr & PSTATE_SP ? 'h' : 't'); |
366 | - set_feature(&cpu->env, ARM_FEATURE_CRC); | 103 | + |
367 | set_feature(&cpu->env, ARM_FEATURE_EL2); | 104 | + if (cpu_isar_feature(aa64_bti, cpu)) { |
368 | set_feature(&cpu->env, ARM_FEATURE_EL3); | 105 | + qemu_fprintf(f, " BTYPE=%d", (psr & PSTATE_BTYPE) >> 10); |
369 | set_feature(&cpu->env, ARM_FEATURE_PMU); | 106 | + } |
370 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) | 107 | + if (!(flags & CPU_DUMP_FPU)) { |
371 | if (kvm_enabled()) { | 108 | + qemu_fprintf(f, "\n"); |
372 | kvm_arm_set_cpu_features_from_host(cpu); | 109 | + return; |
373 | } else { | 110 | + } |
374 | + uint64_t t; | 111 | + if (fp_exception_el(env, el) != 0) { |
375 | + uint32_t u; | 112 | + qemu_fprintf(f, " FPU disabled\n"); |
376 | aarch64_a57_initfn(obj); | 113 | + return; |
377 | + | 114 | + } |
378 | + t = cpu->isar.id_aa64isar0; | 115 | + qemu_fprintf(f, " FPCR=%08x FPSR=%08x\n", |
379 | + t = FIELD_DP64(t, ID_AA64ISAR0, AES, 2); /* AES + PMULL */ | 116 | + vfp_get_fpcr(env), vfp_get_fpsr(env)); |
380 | + t = FIELD_DP64(t, ID_AA64ISAR0, SHA1, 1); | 117 | + |
381 | + t = FIELD_DP64(t, ID_AA64ISAR0, SHA2, 2); /* SHA512 */ | 118 | + if (cpu_isar_feature(aa64_sve, cpu) && sve_exception_el(env, el) == 0) { |
382 | + t = FIELD_DP64(t, ID_AA64ISAR0, CRC32, 1); | 119 | + int j, zcr_len = sve_zcr_len_for_el(env, el); |
383 | + t = FIELD_DP64(t, ID_AA64ISAR0, ATOMIC, 2); | 120 | + |
384 | + t = FIELD_DP64(t, ID_AA64ISAR0, RDM, 1); | 121 | + for (i = 0; i <= FFR_PRED_NUM; i++) { |
385 | + t = FIELD_DP64(t, ID_AA64ISAR0, SHA3, 1); | 122 | + bool eol; |
386 | + t = FIELD_DP64(t, ID_AA64ISAR0, SM3, 1); | 123 | + if (i == FFR_PRED_NUM) { |
387 | + t = FIELD_DP64(t, ID_AA64ISAR0, SM4, 1); | 124 | + qemu_fprintf(f, "FFR="); |
388 | + t = FIELD_DP64(t, ID_AA64ISAR0, DP, 1); | 125 | + /* It's last, so end the line. */ |
389 | + cpu->isar.id_aa64isar0 = t; | 126 | + eol = true; |
390 | + | 127 | + } else { |
391 | + t = cpu->isar.id_aa64isar1; | 128 | + qemu_fprintf(f, "P%02d=", i); |
392 | + t = FIELD_DP64(t, ID_AA64ISAR1, FCMA, 1); | 129 | + switch (zcr_len) { |
393 | + cpu->isar.id_aa64isar1 = t; | 130 | + case 0: |
394 | + | 131 | + eol = i % 8 == 7; |
395 | + /* Replicate the same data to the 32-bit id registers. */ | 132 | + break; |
396 | + u = cpu->isar.id_isar5; | 133 | + case 1: |
397 | + u = FIELD_DP32(u, ID_ISAR5, AES, 2); /* AES + PMULL */ | 134 | + eol = i % 6 == 5; |
398 | + u = FIELD_DP32(u, ID_ISAR5, SHA1, 1); | 135 | + break; |
399 | + u = FIELD_DP32(u, ID_ISAR5, SHA2, 1); | 136 | + case 2: |
400 | + u = FIELD_DP32(u, ID_ISAR5, CRC32, 1); | 137 | + case 3: |
401 | + u = FIELD_DP32(u, ID_ISAR5, RDM, 1); | 138 | + eol = i % 3 == 2; |
402 | + u = FIELD_DP32(u, ID_ISAR5, VCMA, 1); | 139 | + break; |
403 | + cpu->isar.id_isar5 = u; | 140 | + default: |
404 | + | 141 | + /* More than one quadword per predicate. */ |
405 | + u = cpu->isar.id_isar6; | 142 | + eol = true; |
406 | + u = FIELD_DP32(u, ID_ISAR6, DP, 1); | 143 | + break; |
407 | + cpu->isar.id_isar6 = u; | 144 | + } |
408 | + | 145 | + } |
409 | #ifdef CONFIG_USER_ONLY | 146 | + for (j = zcr_len / 4; j >= 0; j--) { |
410 | /* We don't set these in system emulation mode for the moment, | 147 | + int digits; |
411 | * since we don't correctly set the ID registers to advertise them, | 148 | + if (j * 4 + 4 <= zcr_len + 1) { |
412 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) | 149 | + digits = 16; |
413 | * whereas the architecture requires them to be present in both if | 150 | + } else { |
414 | * present in either. | 151 | + digits = (zcr_len % 4 + 1) * 4; |
415 | */ | 152 | + } |
416 | - set_feature(&cpu->env, ARM_FEATURE_V8_SHA512); | 153 | + qemu_fprintf(f, "%0*" PRIx64 "%s", digits, |
417 | - set_feature(&cpu->env, ARM_FEATURE_V8_SHA3); | 154 | + env->vfp.pregs[i].p[j], |
418 | - set_feature(&cpu->env, ARM_FEATURE_V8_SM3); | 155 | + j ? ":" : eol ? "\n" : " "); |
419 | - set_feature(&cpu->env, ARM_FEATURE_V8_SM4); | 156 | + } |
420 | - set_feature(&cpu->env, ARM_FEATURE_V8_ATOMICS); | 157 | + } |
421 | - set_feature(&cpu->env, ARM_FEATURE_V8_RDM); | 158 | + |
422 | - set_feature(&cpu->env, ARM_FEATURE_V8_DOTPROD); | 159 | + for (i = 0; i < 32; i++) { |
423 | set_feature(&cpu->env, ARM_FEATURE_V8_FP16); | 160 | + if (zcr_len == 0) { |
424 | - set_feature(&cpu->env, ARM_FEATURE_V8_FCMA); | 161 | + qemu_fprintf(f, "Z%02d=%016" PRIx64 ":%016" PRIx64 "%s", |
425 | set_feature(&cpu->env, ARM_FEATURE_SVE); | 162 | + i, env->vfp.zregs[i].d[1], |
426 | /* For usermode -cpu max we can use a larger and more efficient DCZ | 163 | + env->vfp.zregs[i].d[0], i & 1 ? "\n" : " "); |
427 | * blocksize since we don't have to follow what the hardware does. | 164 | + } else if (zcr_len == 1) { |
165 | + qemu_fprintf(f, "Z%02d=%016" PRIx64 ":%016" PRIx64 | ||
166 | + ":%016" PRIx64 ":%016" PRIx64 "\n", | ||
167 | + i, env->vfp.zregs[i].d[3], env->vfp.zregs[i].d[2], | ||
168 | + env->vfp.zregs[i].d[1], env->vfp.zregs[i].d[0]); | ||
169 | + } else { | ||
170 | + for (j = zcr_len; j >= 0; j--) { | ||
171 | + bool odd = (zcr_len - j) % 2 != 0; | ||
172 | + if (j == zcr_len) { | ||
173 | + qemu_fprintf(f, "Z%02d[%x-%x]=", i, j, j - 1); | ||
174 | + } else if (!odd) { | ||
175 | + if (j > 0) { | ||
176 | + qemu_fprintf(f, " [%x-%x]=", j, j - 1); | ||
177 | + } else { | ||
178 | + qemu_fprintf(f, " [%x]=", j); | ||
179 | + } | ||
180 | + } | ||
181 | + qemu_fprintf(f, "%016" PRIx64 ":%016" PRIx64 "%s", | ||
182 | + env->vfp.zregs[i].d[j * 2 + 1], | ||
183 | + env->vfp.zregs[i].d[j * 2], | ||
184 | + odd || j == 0 ? "\n" : ":"); | ||
185 | + } | ||
186 | + } | ||
187 | + } | ||
188 | + } else { | ||
189 | + for (i = 0; i < 32; i++) { | ||
190 | + uint64_t *q = aa64_vfp_qreg(env, i); | ||
191 | + qemu_fprintf(f, "Q%02d=%016" PRIx64 ":%016" PRIx64 "%s", | ||
192 | + i, q[1], q[0], (i & 1 ? "\n" : " ")); | ||
193 | + } | ||
194 | + } | ||
195 | +} | ||
196 | + | ||
197 | +#else | ||
198 | + | ||
199 | +static inline void aarch64_cpu_dump_state(CPUState *cs, FILE *f, int flags) | ||
200 | +{ | ||
201 | + g_assert_not_reached(); | ||
202 | +} | ||
203 | + | ||
204 | +#endif | ||
205 | + | ||
206 | +static void arm_cpu_dump_state(CPUState *cs, FILE *f, int flags) | ||
207 | +{ | ||
208 | + ARMCPU *cpu = ARM_CPU(cs); | ||
209 | + CPUARMState *env = &cpu->env; | ||
210 | + int i; | ||
211 | + | ||
212 | + if (is_a64(env)) { | ||
213 | + aarch64_cpu_dump_state(cs, f, flags); | ||
214 | + return; | ||
215 | + } | ||
216 | + | ||
217 | + for (i = 0; i < 16; i++) { | ||
218 | + qemu_fprintf(f, "R%02d=%08x", i, env->regs[i]); | ||
219 | + if ((i % 4) == 3) { | ||
220 | + qemu_fprintf(f, "\n"); | ||
221 | + } else { | ||
222 | + qemu_fprintf(f, " "); | ||
223 | + } | ||
224 | + } | ||
225 | + | ||
226 | + if (arm_feature(env, ARM_FEATURE_M)) { | ||
227 | + uint32_t xpsr = xpsr_read(env); | ||
228 | + const char *mode; | ||
229 | + const char *ns_status = ""; | ||
230 | + | ||
231 | + if (arm_feature(env, ARM_FEATURE_M_SECURITY)) { | ||
232 | + ns_status = env->v7m.secure ? "S " : "NS "; | ||
233 | + } | ||
234 | + | ||
235 | + if (xpsr & XPSR_EXCP) { | ||
236 | + mode = "handler"; | ||
237 | + } else { | ||
238 | + if (env->v7m.control[env->v7m.secure] & R_V7M_CONTROL_NPRIV_MASK) { | ||
239 | + mode = "unpriv-thread"; | ||
240 | + } else { | ||
241 | + mode = "priv-thread"; | ||
242 | + } | ||
243 | + } | ||
244 | + | ||
245 | + qemu_fprintf(f, "XPSR=%08x %c%c%c%c %c %s%s\n", | ||
246 | + xpsr, | ||
247 | + xpsr & XPSR_N ? 'N' : '-', | ||
248 | + xpsr & XPSR_Z ? 'Z' : '-', | ||
249 | + xpsr & XPSR_C ? 'C' : '-', | ||
250 | + xpsr & XPSR_V ? 'V' : '-', | ||
251 | + xpsr & XPSR_T ? 'T' : 'A', | ||
252 | + ns_status, | ||
253 | + mode); | ||
254 | + } else { | ||
255 | + uint32_t psr = cpsr_read(env); | ||
256 | + const char *ns_status = ""; | ||
257 | + | ||
258 | + if (arm_feature(env, ARM_FEATURE_EL3) && | ||
259 | + (psr & CPSR_M) != ARM_CPU_MODE_MON) { | ||
260 | + ns_status = env->cp15.scr_el3 & SCR_NS ? "NS " : "S "; | ||
261 | + } | ||
262 | + | ||
263 | + qemu_fprintf(f, "PSR=%08x %c%c%c%c %c %s%s%d\n", | ||
264 | + psr, | ||
265 | + psr & CPSR_N ? 'N' : '-', | ||
266 | + psr & CPSR_Z ? 'Z' : '-', | ||
267 | + psr & CPSR_C ? 'C' : '-', | ||
268 | + psr & CPSR_V ? 'V' : '-', | ||
269 | + psr & CPSR_T ? 'T' : 'A', | ||
270 | + ns_status, | ||
271 | + aarch32_mode_name(psr), (psr & 0x10) ? 32 : 26); | ||
272 | + } | ||
273 | + | ||
274 | + if (flags & CPU_DUMP_FPU) { | ||
275 | + int numvfpregs = 0; | ||
276 | + if (arm_feature(env, ARM_FEATURE_VFP)) { | ||
277 | + numvfpregs += 16; | ||
278 | + } | ||
279 | + if (arm_feature(env, ARM_FEATURE_VFP3)) { | ||
280 | + numvfpregs += 16; | ||
281 | + } | ||
282 | + for (i = 0; i < numvfpregs; i++) { | ||
283 | + uint64_t v = *aa32_vfp_dreg(env, i); | ||
284 | + qemu_fprintf(f, "s%02d=%08x s%02d=%08x d%02d=%016" PRIx64 "\n", | ||
285 | + i * 2, (uint32_t)v, | ||
286 | + i * 2 + 1, (uint32_t)(v >> 32), | ||
287 | + i, v); | ||
288 | + } | ||
289 | + qemu_fprintf(f, "FPSCR: %08x\n", vfp_get_fpscr(env)); | ||
290 | + } | ||
291 | +} | ||
292 | + | ||
293 | uint64_t arm_cpu_mp_affinity(int idx, uint8_t clustersz) | ||
294 | { | ||
295 | uint32_t Aff1 = idx / clustersz; | ||
428 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 296 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c |
429 | index XXXXXXX..XXXXXXX 100644 | 297 | index XXXXXXX..XXXXXXX 100644 |
430 | --- a/target/arm/translate-a64.c | 298 | --- a/target/arm/translate-a64.c |
431 | +++ b/target/arm/translate-a64.c | 299 | +++ b/target/arm/translate-a64.c |
432 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_excl(DisasContext *s, uint32_t insn) | 300 | @@ -XXX,XX +XXX,XX @@ |
433 | } | 301 | #include "translate.h" |
434 | if (rt2 == 31 | 302 | #include "internals.h" |
435 | && ((rt | rs) & 1) == 0 | 303 | #include "qemu/host-utils.h" |
436 | - && arm_dc_feature(s, ARM_FEATURE_V8_ATOMICS)) { | 304 | -#include "qemu/qemu-print.h" |
437 | + && dc_isar_feature(aa64_atomics, s)) { | 305 | |
438 | /* CASP / CASPL */ | 306 | #include "hw/semihosting/semihost.h" |
439 | gen_compare_and_swap_pair(s, rs, rt, rn, size | 2); | 307 | #include "exec/gen-icount.h" |
440 | return; | 308 | @@ -XXX,XX +XXX,XX @@ static void set_btype(DisasContext *s, int val) |
441 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_excl(DisasContext *s, uint32_t insn) | 309 | s->btype = -1; |
442 | } | 310 | } |
443 | if (rt2 == 31 | 311 | |
444 | && ((rt | rs) & 1) == 0 | 312 | -void aarch64_cpu_dump_state(CPUState *cs, FILE *f, int flags) |
445 | - && arm_dc_feature(s, ARM_FEATURE_V8_ATOMICS)) { | 313 | -{ |
446 | + && dc_isar_feature(aa64_atomics, s)) { | 314 | - ARMCPU *cpu = ARM_CPU(cs); |
447 | /* CASPA / CASPAL */ | 315 | - CPUARMState *env = &cpu->env; |
448 | gen_compare_and_swap_pair(s, rs, rt, rn, size | 2); | 316 | - uint32_t psr = pstate_read(env); |
449 | return; | 317 | - int i; |
450 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_excl(DisasContext *s, uint32_t insn) | 318 | - int el = arm_current_el(env); |
451 | case 0xb: /* CASL */ | 319 | - const char *ns_status; |
452 | case 0xe: /* CASA */ | 320 | - |
453 | case 0xf: /* CASAL */ | 321 | - qemu_fprintf(f, " PC=%016" PRIx64 " ", env->pc); |
454 | - if (rt2 == 31 && arm_dc_feature(s, ARM_FEATURE_V8_ATOMICS)) { | 322 | - for (i = 0; i < 32; i++) { |
455 | + if (rt2 == 31 && dc_isar_feature(aa64_atomics, s)) { | 323 | - if (i == 31) { |
456 | gen_compare_and_swap(s, rs, rt, rn, size); | 324 | - qemu_fprintf(f, " SP=%016" PRIx64 "\n", env->xregs[i]); |
457 | return; | 325 | - } else { |
458 | } | 326 | - qemu_fprintf(f, "X%02d=%016" PRIx64 "%s", i, env->xregs[i], |
459 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_atomic(DisasContext *s, uint32_t insn, | 327 | - (i + 2) % 3 ? " " : "\n"); |
460 | int rs = extract32(insn, 16, 5); | 328 | - } |
461 | int rn = extract32(insn, 5, 5); | 329 | - } |
462 | int o3_opc = extract32(insn, 12, 4); | 330 | - |
463 | - int feature = ARM_FEATURE_V8_ATOMICS; | 331 | - if (arm_feature(env, ARM_FEATURE_EL3) && el != 3) { |
464 | TCGv_i64 tcg_rn, tcg_rs; | 332 | - ns_status = env->cp15.scr_el3 & SCR_NS ? "NS " : "S "; |
465 | AtomicThreeOpFn *fn; | 333 | - } else { |
466 | 334 | - ns_status = ""; | |
467 | - if (is_vector) { | 335 | - } |
468 | + if (is_vector || !dc_isar_feature(aa64_atomics, s)) { | 336 | - qemu_fprintf(f, "PSTATE=%08x %c%c%c%c %sEL%d%c", |
469 | unallocated_encoding(s); | 337 | - psr, |
470 | return; | 338 | - psr & PSTATE_N ? 'N' : '-', |
471 | } | 339 | - psr & PSTATE_Z ? 'Z' : '-', |
472 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_atomic(DisasContext *s, uint32_t insn, | 340 | - psr & PSTATE_C ? 'C' : '-', |
473 | unallocated_encoding(s); | 341 | - psr & PSTATE_V ? 'V' : '-', |
474 | return; | 342 | - ns_status, |
475 | } | 343 | - el, |
476 | - if (!arm_dc_feature(s, feature)) { | 344 | - psr & PSTATE_SP ? 'h' : 't'); |
477 | - unallocated_encoding(s); | 345 | - |
346 | - if (cpu_isar_feature(aa64_bti, cpu)) { | ||
347 | - qemu_fprintf(f, " BTYPE=%d", (psr & PSTATE_BTYPE) >> 10); | ||
348 | - } | ||
349 | - if (!(flags & CPU_DUMP_FPU)) { | ||
350 | - qemu_fprintf(f, "\n"); | ||
478 | - return; | 351 | - return; |
479 | - } | 352 | - } |
480 | 353 | - if (fp_exception_el(env, el) != 0) { | |
481 | if (rn == 31) { | 354 | - qemu_fprintf(f, " FPU disabled\n"); |
482 | gen_check_sp_alignment(s); | 355 | - return; |
483 | @@ -XXX,XX +XXX,XX @@ static void handle_crc32(DisasContext *s, | 356 | - } |
484 | TCGv_i64 tcg_acc, tcg_val; | 357 | - qemu_fprintf(f, " FPCR=%08x FPSR=%08x\n", |
485 | TCGv_i32 tcg_bytes; | 358 | - vfp_get_fpcr(env), vfp_get_fpsr(env)); |
486 | 359 | - | |
487 | - if (!arm_dc_feature(s, ARM_FEATURE_CRC) | 360 | - if (cpu_isar_feature(aa64_sve, cpu) && sve_exception_el(env, el) == 0) { |
488 | + if (!dc_isar_feature(aa64_crc32, s) | 361 | - int j, zcr_len = sve_zcr_len_for_el(env, el); |
489 | || (sf == 1 && sz != 3) | 362 | - |
490 | || (sf == 0 && sz == 3)) { | 363 | - for (i = 0; i <= FFR_PRED_NUM; i++) { |
491 | unallocated_encoding(s); | 364 | - bool eol; |
492 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_scalar_three_reg_same_extra(DisasContext *s, | 365 | - if (i == FFR_PRED_NUM) { |
493 | bool u = extract32(insn, 29, 1); | 366 | - qemu_fprintf(f, "FFR="); |
494 | TCGv_i32 ele1, ele2, ele3; | 367 | - /* It's last, so end the line. */ |
495 | TCGv_i64 res; | 368 | - eol = true; |
496 | - int feature; | 369 | - } else { |
497 | + bool feature; | 370 | - qemu_fprintf(f, "P%02d=", i); |
498 | 371 | - switch (zcr_len) { | |
499 | switch (u * 16 + opcode) { | 372 | - case 0: |
500 | case 0x10: /* SQRDMLAH (vector) */ | 373 | - eol = i % 8 == 7; |
501 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_scalar_three_reg_same_extra(DisasContext *s, | 374 | - break; |
502 | unallocated_encoding(s); | 375 | - case 1: |
503 | return; | 376 | - eol = i % 6 == 5; |
504 | } | 377 | - break; |
505 | - feature = ARM_FEATURE_V8_RDM; | 378 | - case 2: |
506 | + feature = dc_isar_feature(aa64_rdm, s); | 379 | - case 3: |
507 | break; | 380 | - eol = i % 3 == 2; |
508 | default: | 381 | - break; |
509 | unallocated_encoding(s); | 382 | - default: |
510 | return; | 383 | - /* More than one quadword per predicate. */ |
511 | } | 384 | - eol = true; |
512 | - if (!arm_dc_feature(s, feature)) { | 385 | - break; |
513 | + if (!feature) { | 386 | - } |
514 | unallocated_encoding(s); | 387 | - } |
515 | return; | 388 | - for (j = zcr_len / 4; j >= 0; j--) { |
516 | } | 389 | - int digits; |
517 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_three_reg_diff(DisasContext *s, uint32_t insn) | 390 | - if (j * 4 + 4 <= zcr_len + 1) { |
518 | return; | 391 | - digits = 16; |
519 | } | 392 | - } else { |
520 | if (size == 3) { | 393 | - digits = (zcr_len % 4 + 1) * 4; |
521 | - if (!arm_dc_feature(s, ARM_FEATURE_V8_PMULL)) { | 394 | - } |
522 | + if (!dc_isar_feature(aa64_pmull, s)) { | 395 | - qemu_fprintf(f, "%0*" PRIx64 "%s", digits, |
523 | unallocated_encoding(s); | 396 | - env->vfp.pregs[i].p[j], |
524 | return; | 397 | - j ? ":" : eol ? "\n" : " "); |
525 | } | 398 | - } |
526 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_three_reg_same_extra(DisasContext *s, uint32_t insn) | 399 | - } |
527 | int size = extract32(insn, 22, 2); | 400 | - |
528 | bool u = extract32(insn, 29, 1); | 401 | - for (i = 0; i < 32; i++) { |
529 | bool is_q = extract32(insn, 30, 1); | 402 | - if (zcr_len == 0) { |
530 | - int feature, rot; | 403 | - qemu_fprintf(f, "Z%02d=%016" PRIx64 ":%016" PRIx64 "%s", |
531 | + bool feature; | 404 | - i, env->vfp.zregs[i].d[1], |
532 | + int rot; | 405 | - env->vfp.zregs[i].d[0], i & 1 ? "\n" : " "); |
533 | 406 | - } else if (zcr_len == 1) { | |
534 | switch (u * 16 + opcode) { | 407 | - qemu_fprintf(f, "Z%02d=%016" PRIx64 ":%016" PRIx64 |
535 | case 0x10: /* SQRDMLAH (vector) */ | 408 | - ":%016" PRIx64 ":%016" PRIx64 "\n", |
536 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_three_reg_same_extra(DisasContext *s, uint32_t insn) | 409 | - i, env->vfp.zregs[i].d[3], env->vfp.zregs[i].d[2], |
537 | unallocated_encoding(s); | 410 | - env->vfp.zregs[i].d[1], env->vfp.zregs[i].d[0]); |
538 | return; | 411 | - } else { |
539 | } | 412 | - for (j = zcr_len; j >= 0; j--) { |
540 | - feature = ARM_FEATURE_V8_RDM; | 413 | - bool odd = (zcr_len - j) % 2 != 0; |
541 | + feature = dc_isar_feature(aa64_rdm, s); | 414 | - if (j == zcr_len) { |
542 | break; | 415 | - qemu_fprintf(f, "Z%02d[%x-%x]=", i, j, j - 1); |
543 | case 0x02: /* SDOT (vector) */ | 416 | - } else if (!odd) { |
544 | case 0x12: /* UDOT (vector) */ | 417 | - if (j > 0) { |
545 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_three_reg_same_extra(DisasContext *s, uint32_t insn) | 418 | - qemu_fprintf(f, " [%x-%x]=", j, j - 1); |
546 | unallocated_encoding(s); | 419 | - } else { |
547 | return; | 420 | - qemu_fprintf(f, " [%x]=", j); |
548 | } | 421 | - } |
549 | - feature = ARM_FEATURE_V8_DOTPROD; | 422 | - } |
550 | + feature = dc_isar_feature(aa64_dp, s); | 423 | - qemu_fprintf(f, "%016" PRIx64 ":%016" PRIx64 "%s", |
551 | break; | 424 | - env->vfp.zregs[i].d[j * 2 + 1], |
552 | case 0x18: /* FCMLA, #0 */ | 425 | - env->vfp.zregs[i].d[j * 2], |
553 | case 0x19: /* FCMLA, #90 */ | 426 | - odd || j == 0 ? "\n" : ":"); |
554 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_three_reg_same_extra(DisasContext *s, uint32_t insn) | 427 | - } |
555 | unallocated_encoding(s); | 428 | - } |
556 | return; | 429 | - } |
557 | } | 430 | - } else { |
558 | - feature = ARM_FEATURE_V8_FCMA; | 431 | - for (i = 0; i < 32; i++) { |
559 | + feature = dc_isar_feature(aa64_fcma, s); | 432 | - uint64_t *q = aa64_vfp_qreg(env, i); |
560 | break; | 433 | - qemu_fprintf(f, "Q%02d=%016" PRIx64 ":%016" PRIx64 "%s", |
561 | default: | 434 | - i, q[1], q[0], (i & 1 ? "\n" : " ")); |
562 | unallocated_encoding(s); | 435 | - } |
563 | return; | 436 | - } |
564 | } | 437 | -} |
565 | - if (!arm_dc_feature(s, feature)) { | 438 | - |
566 | + if (!feature) { | 439 | void gen_a64_set_pc_im(uint64_t val) |
567 | unallocated_encoding(s); | 440 | { |
568 | return; | 441 | tcg_gen_movi_i64(cpu_pc, val); |
569 | } | ||
570 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_indexed(DisasContext *s, uint32_t insn) | ||
571 | break; | ||
572 | case 0x1d: /* SQRDMLAH */ | ||
573 | case 0x1f: /* SQRDMLSH */ | ||
574 | - if (!arm_dc_feature(s, ARM_FEATURE_V8_RDM)) { | ||
575 | + if (!dc_isar_feature(aa64_rdm, s)) { | ||
576 | unallocated_encoding(s); | ||
577 | return; | ||
578 | } | ||
579 | break; | ||
580 | case 0x0e: /* SDOT */ | ||
581 | case 0x1e: /* UDOT */ | ||
582 | - if (size != MO_32 || !arm_dc_feature(s, ARM_FEATURE_V8_DOTPROD)) { | ||
583 | + if (size != MO_32 || !dc_isar_feature(aa64_dp, s)) { | ||
584 | unallocated_encoding(s); | ||
585 | return; | ||
586 | } | ||
587 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_indexed(DisasContext *s, uint32_t insn) | ||
588 | case 0x13: /* FCMLA #90 */ | ||
589 | case 0x15: /* FCMLA #180 */ | ||
590 | case 0x17: /* FCMLA #270 */ | ||
591 | - if (!arm_dc_feature(s, ARM_FEATURE_V8_FCMA)) { | ||
592 | + if (!dc_isar_feature(aa64_fcma, s)) { | ||
593 | unallocated_encoding(s); | ||
594 | return; | ||
595 | } | ||
596 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_aes(DisasContext *s, uint32_t insn) | ||
597 | TCGv_i32 tcg_decrypt; | ||
598 | CryptoThreeOpIntFn *genfn; | ||
599 | |||
600 | - if (!arm_dc_feature(s, ARM_FEATURE_V8_AES) | ||
601 | - || size != 0) { | ||
602 | + if (!dc_isar_feature(aa64_aes, s) || size != 0) { | ||
603 | unallocated_encoding(s); | ||
604 | return; | ||
605 | } | ||
606 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_three_reg_sha(DisasContext *s, uint32_t insn) | ||
607 | int rd = extract32(insn, 0, 5); | ||
608 | CryptoThreeOpFn *genfn; | ||
609 | TCGv_ptr tcg_rd_ptr, tcg_rn_ptr, tcg_rm_ptr; | ||
610 | - int feature = ARM_FEATURE_V8_SHA256; | ||
611 | + bool feature; | ||
612 | |||
613 | if (size != 0) { | ||
614 | unallocated_encoding(s); | ||
615 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_three_reg_sha(DisasContext *s, uint32_t insn) | ||
616 | case 2: /* SHA1M */ | ||
617 | case 3: /* SHA1SU0 */ | ||
618 | genfn = NULL; | ||
619 | - feature = ARM_FEATURE_V8_SHA1; | ||
620 | + feature = dc_isar_feature(aa64_sha1, s); | ||
621 | break; | ||
622 | case 4: /* SHA256H */ | ||
623 | genfn = gen_helper_crypto_sha256h; | ||
624 | + feature = dc_isar_feature(aa64_sha256, s); | ||
625 | break; | ||
626 | case 5: /* SHA256H2 */ | ||
627 | genfn = gen_helper_crypto_sha256h2; | ||
628 | + feature = dc_isar_feature(aa64_sha256, s); | ||
629 | break; | ||
630 | case 6: /* SHA256SU1 */ | ||
631 | genfn = gen_helper_crypto_sha256su1; | ||
632 | + feature = dc_isar_feature(aa64_sha256, s); | ||
633 | break; | ||
634 | default: | ||
635 | unallocated_encoding(s); | ||
636 | return; | ||
637 | } | ||
638 | |||
639 | - if (!arm_dc_feature(s, feature)) { | ||
640 | + if (!feature) { | ||
641 | unallocated_encoding(s); | ||
642 | return; | ||
643 | } | ||
644 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_two_reg_sha(DisasContext *s, uint32_t insn) | ||
645 | int rn = extract32(insn, 5, 5); | ||
646 | int rd = extract32(insn, 0, 5); | ||
647 | CryptoTwoOpFn *genfn; | ||
648 | - int feature; | ||
649 | + bool feature; | ||
650 | TCGv_ptr tcg_rd_ptr, tcg_rn_ptr; | ||
651 | |||
652 | if (size != 0) { | ||
653 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_two_reg_sha(DisasContext *s, uint32_t insn) | ||
654 | |||
655 | switch (opcode) { | ||
656 | case 0: /* SHA1H */ | ||
657 | - feature = ARM_FEATURE_V8_SHA1; | ||
658 | + feature = dc_isar_feature(aa64_sha1, s); | ||
659 | genfn = gen_helper_crypto_sha1h; | ||
660 | break; | ||
661 | case 1: /* SHA1SU1 */ | ||
662 | - feature = ARM_FEATURE_V8_SHA1; | ||
663 | + feature = dc_isar_feature(aa64_sha1, s); | ||
664 | genfn = gen_helper_crypto_sha1su1; | ||
665 | break; | ||
666 | case 2: /* SHA256SU0 */ | ||
667 | - feature = ARM_FEATURE_V8_SHA256; | ||
668 | + feature = dc_isar_feature(aa64_sha256, s); | ||
669 | genfn = gen_helper_crypto_sha256su0; | ||
670 | break; | ||
671 | default: | ||
672 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_two_reg_sha(DisasContext *s, uint32_t insn) | ||
673 | return; | ||
674 | } | ||
675 | |||
676 | - if (!arm_dc_feature(s, feature)) { | ||
677 | + if (!feature) { | ||
678 | unallocated_encoding(s); | ||
679 | return; | ||
680 | } | ||
681 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_three_reg_sha512(DisasContext *s, uint32_t insn) | ||
682 | int rm = extract32(insn, 16, 5); | ||
683 | int rn = extract32(insn, 5, 5); | ||
684 | int rd = extract32(insn, 0, 5); | ||
685 | - int feature; | ||
686 | + bool feature; | ||
687 | CryptoThreeOpFn *genfn; | ||
688 | |||
689 | if (o == 0) { | ||
690 | switch (opcode) { | ||
691 | case 0: /* SHA512H */ | ||
692 | - feature = ARM_FEATURE_V8_SHA512; | ||
693 | + feature = dc_isar_feature(aa64_sha512, s); | ||
694 | genfn = gen_helper_crypto_sha512h; | ||
695 | break; | ||
696 | case 1: /* SHA512H2 */ | ||
697 | - feature = ARM_FEATURE_V8_SHA512; | ||
698 | + feature = dc_isar_feature(aa64_sha512, s); | ||
699 | genfn = gen_helper_crypto_sha512h2; | ||
700 | break; | ||
701 | case 2: /* SHA512SU1 */ | ||
702 | - feature = ARM_FEATURE_V8_SHA512; | ||
703 | + feature = dc_isar_feature(aa64_sha512, s); | ||
704 | genfn = gen_helper_crypto_sha512su1; | ||
705 | break; | ||
706 | case 3: /* RAX1 */ | ||
707 | - feature = ARM_FEATURE_V8_SHA3; | ||
708 | + feature = dc_isar_feature(aa64_sha3, s); | ||
709 | genfn = NULL; | ||
710 | break; | ||
711 | } | ||
712 | } else { | ||
713 | switch (opcode) { | ||
714 | case 0: /* SM3PARTW1 */ | ||
715 | - feature = ARM_FEATURE_V8_SM3; | ||
716 | + feature = dc_isar_feature(aa64_sm3, s); | ||
717 | genfn = gen_helper_crypto_sm3partw1; | ||
718 | break; | ||
719 | case 1: /* SM3PARTW2 */ | ||
720 | - feature = ARM_FEATURE_V8_SM3; | ||
721 | + feature = dc_isar_feature(aa64_sm3, s); | ||
722 | genfn = gen_helper_crypto_sm3partw2; | ||
723 | break; | ||
724 | case 2: /* SM4EKEY */ | ||
725 | - feature = ARM_FEATURE_V8_SM4; | ||
726 | + feature = dc_isar_feature(aa64_sm4, s); | ||
727 | genfn = gen_helper_crypto_sm4ekey; | ||
728 | break; | ||
729 | default: | ||
730 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_three_reg_sha512(DisasContext *s, uint32_t insn) | ||
731 | } | ||
732 | } | ||
733 | |||
734 | - if (!arm_dc_feature(s, feature)) { | ||
735 | + if (!feature) { | ||
736 | unallocated_encoding(s); | ||
737 | return; | ||
738 | } | ||
739 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_two_reg_sha512(DisasContext *s, uint32_t insn) | ||
740 | int rn = extract32(insn, 5, 5); | ||
741 | int rd = extract32(insn, 0, 5); | ||
742 | TCGv_ptr tcg_rd_ptr, tcg_rn_ptr; | ||
743 | - int feature; | ||
744 | + bool feature; | ||
745 | CryptoTwoOpFn *genfn; | ||
746 | |||
747 | switch (opcode) { | ||
748 | case 0: /* SHA512SU0 */ | ||
749 | - feature = ARM_FEATURE_V8_SHA512; | ||
750 | + feature = dc_isar_feature(aa64_sha512, s); | ||
751 | genfn = gen_helper_crypto_sha512su0; | ||
752 | break; | ||
753 | case 1: /* SM4E */ | ||
754 | - feature = ARM_FEATURE_V8_SM4; | ||
755 | + feature = dc_isar_feature(aa64_sm4, s); | ||
756 | genfn = gen_helper_crypto_sm4e; | ||
757 | break; | ||
758 | default: | ||
759 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_two_reg_sha512(DisasContext *s, uint32_t insn) | ||
760 | return; | ||
761 | } | ||
762 | |||
763 | - if (!arm_dc_feature(s, feature)) { | ||
764 | + if (!feature) { | ||
765 | unallocated_encoding(s); | ||
766 | return; | ||
767 | } | ||
768 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_four_reg(DisasContext *s, uint32_t insn) | ||
769 | int ra = extract32(insn, 10, 5); | ||
770 | int rn = extract32(insn, 5, 5); | ||
771 | int rd = extract32(insn, 0, 5); | ||
772 | - int feature; | ||
773 | + bool feature; | ||
774 | |||
775 | switch (op0) { | ||
776 | case 0: /* EOR3 */ | ||
777 | case 1: /* BCAX */ | ||
778 | - feature = ARM_FEATURE_V8_SHA3; | ||
779 | + feature = dc_isar_feature(aa64_sha3, s); | ||
780 | break; | ||
781 | case 2: /* SM3SS1 */ | ||
782 | - feature = ARM_FEATURE_V8_SM3; | ||
783 | + feature = dc_isar_feature(aa64_sm3, s); | ||
784 | break; | ||
785 | default: | ||
786 | unallocated_encoding(s); | ||
787 | return; | ||
788 | } | ||
789 | |||
790 | - if (!arm_dc_feature(s, feature)) { | ||
791 | + if (!feature) { | ||
792 | unallocated_encoding(s); | ||
793 | return; | ||
794 | } | ||
795 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_xar(DisasContext *s, uint32_t insn) | ||
796 | TCGv_i64 tcg_op1, tcg_op2, tcg_res[2]; | ||
797 | int pass; | ||
798 | |||
799 | - if (!arm_dc_feature(s, ARM_FEATURE_V8_SHA3)) { | ||
800 | + if (!dc_isar_feature(aa64_sha3, s)) { | ||
801 | unallocated_encoding(s); | ||
802 | return; | ||
803 | } | ||
804 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_three_reg_imm2(DisasContext *s, uint32_t insn) | ||
805 | TCGv_ptr tcg_rd_ptr, tcg_rn_ptr, tcg_rm_ptr; | ||
806 | TCGv_i32 tcg_imm2, tcg_opcode; | ||
807 | |||
808 | - if (!arm_dc_feature(s, ARM_FEATURE_V8_SM3)) { | ||
809 | + if (!dc_isar_feature(aa64_sm3, s)) { | ||
810 | unallocated_encoding(s); | ||
811 | return; | ||
812 | } | ||
813 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_init_disas_context(DisasContextBase *dcbase, | ||
814 | ARMCPU *arm_cpu = arm_env_get_cpu(env); | ||
815 | int bound; | ||
816 | |||
817 | + dc->isar = &arm_cpu->isar; | ||
818 | dc->pc = dc->base.pc_first; | ||
819 | dc->condjmp = 0; | ||
820 | |||
821 | 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 |
822 | index XXXXXXX..XXXXXXX 100644 | 443 | index XXXXXXX..XXXXXXX 100644 |
823 | --- a/target/arm/translate.c | 444 | --- a/target/arm/translate.c |
824 | +++ b/target/arm/translate.c | 445 | +++ b/target/arm/translate.c |
825 | @@ -XXX,XX +XXX,XX @@ static const uint8_t neon_2rm_sizes[] = { | 446 | @@ -XXX,XX +XXX,XX @@ |
826 | static int do_v81_helper(DisasContext *s, gen_helper_gvec_3_ptr *fn, | 447 | #include "tcg-op-gvec.h" |
827 | int q, int rd, int rn, int rm) | 448 | #include "qemu/log.h" |
449 | #include "qemu/bitops.h" | ||
450 | -#include "qemu/qemu-print.h" | ||
451 | #include "arm_ldst.h" | ||
452 | #include "hw/semihosting/semihost.h" | ||
453 | |||
454 | @@ -XXX,XX +XXX,XX @@ void gen_intermediate_code(CPUState *cpu, TranslationBlock *tb, int max_insns) | ||
455 | translator_loop(ops, &dc.base, cpu, tb, max_insns); | ||
456 | } | ||
457 | |||
458 | -void arm_cpu_dump_state(CPUState *cs, FILE *f, int flags) | ||
459 | -{ | ||
460 | - ARMCPU *cpu = ARM_CPU(cs); | ||
461 | - CPUARMState *env = &cpu->env; | ||
462 | - int i; | ||
463 | - | ||
464 | - if (is_a64(env)) { | ||
465 | - aarch64_cpu_dump_state(cs, f, flags); | ||
466 | - return; | ||
467 | - } | ||
468 | - | ||
469 | - for (i = 0; i < 16; i++) { | ||
470 | - qemu_fprintf(f, "R%02d=%08x", i, env->regs[i]); | ||
471 | - if ((i % 4) == 3) { | ||
472 | - qemu_fprintf(f, "\n"); | ||
473 | - } else { | ||
474 | - qemu_fprintf(f, " "); | ||
475 | - } | ||
476 | - } | ||
477 | - | ||
478 | - if (arm_feature(env, ARM_FEATURE_M)) { | ||
479 | - uint32_t xpsr = xpsr_read(env); | ||
480 | - const char *mode; | ||
481 | - const char *ns_status = ""; | ||
482 | - | ||
483 | - if (arm_feature(env, ARM_FEATURE_M_SECURITY)) { | ||
484 | - ns_status = env->v7m.secure ? "S " : "NS "; | ||
485 | - } | ||
486 | - | ||
487 | - if (xpsr & XPSR_EXCP) { | ||
488 | - mode = "handler"; | ||
489 | - } else { | ||
490 | - if (env->v7m.control[env->v7m.secure] & R_V7M_CONTROL_NPRIV_MASK) { | ||
491 | - mode = "unpriv-thread"; | ||
492 | - } else { | ||
493 | - mode = "priv-thread"; | ||
494 | - } | ||
495 | - } | ||
496 | - | ||
497 | - qemu_fprintf(f, "XPSR=%08x %c%c%c%c %c %s%s\n", | ||
498 | - xpsr, | ||
499 | - xpsr & XPSR_N ? 'N' : '-', | ||
500 | - xpsr & XPSR_Z ? 'Z' : '-', | ||
501 | - xpsr & XPSR_C ? 'C' : '-', | ||
502 | - xpsr & XPSR_V ? 'V' : '-', | ||
503 | - xpsr & XPSR_T ? 'T' : 'A', | ||
504 | - ns_status, | ||
505 | - mode); | ||
506 | - } else { | ||
507 | - uint32_t psr = cpsr_read(env); | ||
508 | - const char *ns_status = ""; | ||
509 | - | ||
510 | - if (arm_feature(env, ARM_FEATURE_EL3) && | ||
511 | - (psr & CPSR_M) != ARM_CPU_MODE_MON) { | ||
512 | - ns_status = env->cp15.scr_el3 & SCR_NS ? "NS " : "S "; | ||
513 | - } | ||
514 | - | ||
515 | - qemu_fprintf(f, "PSR=%08x %c%c%c%c %c %s%s%d\n", | ||
516 | - psr, | ||
517 | - psr & CPSR_N ? 'N' : '-', | ||
518 | - psr & CPSR_Z ? 'Z' : '-', | ||
519 | - psr & CPSR_C ? 'C' : '-', | ||
520 | - psr & CPSR_V ? 'V' : '-', | ||
521 | - psr & CPSR_T ? 'T' : 'A', | ||
522 | - ns_status, | ||
523 | - aarch32_mode_name(psr), (psr & 0x10) ? 32 : 26); | ||
524 | - } | ||
525 | - | ||
526 | - if (flags & CPU_DUMP_FPU) { | ||
527 | - int numvfpregs = 0; | ||
528 | - if (arm_feature(env, ARM_FEATURE_VFP)) { | ||
529 | - numvfpregs += 16; | ||
530 | - } | ||
531 | - if (arm_feature(env, ARM_FEATURE_VFP3)) { | ||
532 | - numvfpregs += 16; | ||
533 | - } | ||
534 | - for (i = 0; i < numvfpregs; i++) { | ||
535 | - uint64_t v = *aa32_vfp_dreg(env, i); | ||
536 | - qemu_fprintf(f, "s%02d=%08x s%02d=%08x d%02d=%016" PRIx64 "\n", | ||
537 | - i * 2, (uint32_t)v, | ||
538 | - i * 2 + 1, (uint32_t)(v >> 32), | ||
539 | - i, v); | ||
540 | - } | ||
541 | - qemu_fprintf(f, "FPSCR: %08x\n", vfp_get_fpscr(env)); | ||
542 | - } | ||
543 | -} | ||
544 | - | ||
545 | void restore_state_to_opc(CPUARMState *env, TranslationBlock *tb, | ||
546 | target_ulong *data) | ||
828 | { | 547 | { |
829 | - if (arm_dc_feature(s, ARM_FEATURE_V8_RDM)) { | ||
830 | + if (dc_isar_feature(aa32_rdm, s)) { | ||
831 | int opr_sz = (1 + q) * 8; | ||
832 | tcg_gen_gvec_3_ptr(vfp_reg_offset(1, rd), | ||
833 | vfp_reg_offset(1, rn), | ||
834 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
835 | return 1; | ||
836 | } | ||
837 | if (!u) { /* SHA-1 */ | ||
838 | - if (!arm_dc_feature(s, ARM_FEATURE_V8_SHA1)) { | ||
839 | + if (!dc_isar_feature(aa32_sha1, s)) { | ||
840 | return 1; | ||
841 | } | ||
842 | ptr1 = vfp_reg_ptr(true, rd); | ||
843 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
844 | gen_helper_crypto_sha1_3reg(ptr1, ptr2, ptr3, tmp4); | ||
845 | tcg_temp_free_i32(tmp4); | ||
846 | } else { /* SHA-256 */ | ||
847 | - if (!arm_dc_feature(s, ARM_FEATURE_V8_SHA256) || size == 3) { | ||
848 | + if (!dc_isar_feature(aa32_sha2, s) || size == 3) { | ||
849 | return 1; | ||
850 | } | ||
851 | ptr1 = vfp_reg_ptr(true, rd); | ||
852 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
853 | if (op == 14 && size == 2) { | ||
854 | TCGv_i64 tcg_rn, tcg_rm, tcg_rd; | ||
855 | |||
856 | - if (!arm_dc_feature(s, ARM_FEATURE_V8_PMULL)) { | ||
857 | + if (!dc_isar_feature(aa32_pmull, s)) { | ||
858 | return 1; | ||
859 | } | ||
860 | tcg_rn = tcg_temp_new_i64(); | ||
861 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
862 | { | ||
863 | NeonGenThreeOpEnvFn *fn; | ||
864 | |||
865 | - if (!arm_dc_feature(s, ARM_FEATURE_V8_RDM)) { | ||
866 | + if (!dc_isar_feature(aa32_rdm, s)) { | ||
867 | return 1; | ||
868 | } | ||
869 | if (u && ((rd | rn) & 1)) { | ||
870 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
871 | break; | ||
872 | } | ||
873 | case NEON_2RM_AESE: case NEON_2RM_AESMC: | ||
874 | - if (!arm_dc_feature(s, ARM_FEATURE_V8_AES) | ||
875 | - || ((rm | rd) & 1)) { | ||
876 | + if (!dc_isar_feature(aa32_aes, s) || ((rm | rd) & 1)) { | ||
877 | return 1; | ||
878 | } | ||
879 | ptr1 = vfp_reg_ptr(true, rd); | ||
880 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
881 | tcg_temp_free_i32(tmp3); | ||
882 | break; | ||
883 | case NEON_2RM_SHA1H: | ||
884 | - if (!arm_dc_feature(s, ARM_FEATURE_V8_SHA1) | ||
885 | - || ((rm | rd) & 1)) { | ||
886 | + if (!dc_isar_feature(aa32_sha1, s) || ((rm | rd) & 1)) { | ||
887 | return 1; | ||
888 | } | ||
889 | ptr1 = vfp_reg_ptr(true, rd); | ||
890 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
891 | } | ||
892 | /* bit 6 (q): set -> SHA256SU0, cleared -> SHA1SU1 */ | ||
893 | if (q) { | ||
894 | - if (!arm_dc_feature(s, ARM_FEATURE_V8_SHA256)) { | ||
895 | + if (!dc_isar_feature(aa32_sha2, s)) { | ||
896 | return 1; | ||
897 | } | ||
898 | - } else if (!arm_dc_feature(s, ARM_FEATURE_V8_SHA1)) { | ||
899 | + } else if (!dc_isar_feature(aa32_sha1, s)) { | ||
900 | return 1; | ||
901 | } | ||
902 | ptr1 = vfp_reg_ptr(true, rd); | ||
903 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_insn_3same_ext(DisasContext *s, uint32_t insn) | ||
904 | /* VCMLA -- 1111 110R R.1S .... .... 1000 ...0 .... */ | ||
905 | int size = extract32(insn, 20, 1); | ||
906 | data = extract32(insn, 23, 2); /* rot */ | ||
907 | - if (!arm_dc_feature(s, ARM_FEATURE_V8_FCMA) | ||
908 | + if (!dc_isar_feature(aa32_vcma, s) | ||
909 | || (!size && !arm_dc_feature(s, ARM_FEATURE_V8_FP16))) { | ||
910 | return 1; | ||
911 | } | ||
912 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_insn_3same_ext(DisasContext *s, uint32_t insn) | ||
913 | /* VCADD -- 1111 110R 1.0S .... .... 1000 ...0 .... */ | ||
914 | int size = extract32(insn, 20, 1); | ||
915 | data = extract32(insn, 24, 1); /* rot */ | ||
916 | - if (!arm_dc_feature(s, ARM_FEATURE_V8_FCMA) | ||
917 | + if (!dc_isar_feature(aa32_vcma, s) | ||
918 | || (!size && !arm_dc_feature(s, ARM_FEATURE_V8_FP16))) { | ||
919 | return 1; | ||
920 | } | ||
921 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_insn_3same_ext(DisasContext *s, uint32_t insn) | ||
922 | } else if ((insn & 0xfeb00f00) == 0xfc200d00) { | ||
923 | /* V[US]DOT -- 1111 1100 0.10 .... .... 1101 .Q.U .... */ | ||
924 | bool u = extract32(insn, 4, 1); | ||
925 | - if (!arm_dc_feature(s, ARM_FEATURE_V8_DOTPROD)) { | ||
926 | + if (!dc_isar_feature(aa32_dp, s)) { | ||
927 | return 1; | ||
928 | } | ||
929 | fn_gvec = u ? gen_helper_gvec_udot_b : gen_helper_gvec_sdot_b; | ||
930 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_insn_2reg_scalar_ext(DisasContext *s, uint32_t insn) | ||
931 | int size = extract32(insn, 23, 1); | ||
932 | int index; | ||
933 | |||
934 | - if (!arm_dc_feature(s, ARM_FEATURE_V8_FCMA)) { | ||
935 | + if (!dc_isar_feature(aa32_vcma, s)) { | ||
936 | return 1; | ||
937 | } | ||
938 | if (size == 0) { | ||
939 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_insn_2reg_scalar_ext(DisasContext *s, uint32_t insn) | ||
940 | } else if ((insn & 0xffb00f00) == 0xfe200d00) { | ||
941 | /* V[US]DOT -- 1111 1110 0.10 .... .... 1101 .Q.U .... */ | ||
942 | int u = extract32(insn, 4, 1); | ||
943 | - if (!arm_dc_feature(s, ARM_FEATURE_V8_DOTPROD)) { | ||
944 | + if (!dc_isar_feature(aa32_dp, s)) { | ||
945 | return 1; | ||
946 | } | ||
947 | fn_gvec = u ? gen_helper_gvec_udot_idx_b : gen_helper_gvec_sdot_idx_b; | ||
948 | @@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) | ||
949 | * op1 == 3 is UNPREDICTABLE but handle as UNDEFINED. | ||
950 | * Bits 8, 10 and 11 should be zero. | ||
951 | */ | ||
952 | - if (!arm_dc_feature(s, ARM_FEATURE_CRC) || op1 == 0x3 || | ||
953 | - (c & 0xd) != 0) { | ||
954 | + if (!dc_isar_feature(aa32_crc32, s) || op1 == 0x3 || (c & 0xd) != 0) { | ||
955 | goto illegal_op; | ||
956 | } | ||
957 | |||
958 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) | ||
959 | case 0x28: | ||
960 | case 0x29: | ||
961 | case 0x2a: | ||
962 | - if (!arm_dc_feature(s, ARM_FEATURE_CRC)) { | ||
963 | + if (!dc_isar_feature(aa32_crc32, s)) { | ||
964 | goto illegal_op; | ||
965 | } | ||
966 | break; | ||
967 | @@ -XXX,XX +XXX,XX @@ static void arm_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) | ||
968 | CPUARMState *env = cs->env_ptr; | ||
969 | ARMCPU *cpu = arm_env_get_cpu(env); | ||
970 | |||
971 | + dc->isar = &cpu->isar; | ||
972 | dc->pc = dc->base.pc_first; | ||
973 | dc->condjmp = 0; | ||
974 | |||
975 | -- | 548 | -- |
976 | 2.19.1 | 549 | 2.20.1 |
977 | 550 | ||
978 | 551 | diff view generated by jsdifflib |
1 | The switch_mode() function is defined in target/arm/helper.c and used | 1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> |
---|---|---|---|
2 | only in that file and nowhere else, so we can make it file-local | ||
3 | rather than global. | ||
4 | 2 | ||
3 | In the next commit we will split the TLB related routines of | ||
4 | this file, and this function will also be called in the new | ||
5 | file. Declare it in the "internals.h" header. | ||
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> | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20181012144235.19646-3-peter.maydell@linaro.org | ||
8 | --- | 11 | --- |
9 | target/arm/internals.h | 1 - | 12 | target/arm/internals.h | 16 ++++++++++++++++ |
10 | target/arm/helper.c | 6 ++++-- | 13 | target/arm/helper.c | 21 +++++---------------- |
11 | 2 files changed, 4 insertions(+), 3 deletions(-) | 14 | 2 files changed, 21 insertions(+), 16 deletions(-) |
12 | 15 | ||
13 | diff --git a/target/arm/internals.h b/target/arm/internals.h | 16 | diff --git a/target/arm/internals.h b/target/arm/internals.h |
14 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/internals.h | 18 | --- a/target/arm/internals.h |
16 | +++ b/target/arm/internals.h | 19 | +++ b/target/arm/internals.h |
17 | @@ -XXX,XX +XXX,XX @@ static inline int bank_number(int mode) | 20 | @@ -XXX,XX +XXX,XX @@ static inline int exception_target_el(CPUARMState *env) |
18 | g_assert_not_reached(); | 21 | return target_el; |
19 | } | 22 | } |
20 | 23 | ||
21 | -void switch_mode(CPUARMState *, int); | 24 | +#ifndef CONFIG_USER_ONLY |
22 | void arm_cpu_register_gdb_regs_for_features(ARMCPU *cpu); | 25 | + |
23 | void arm_translate_init(void); | 26 | +/* Cacheability and shareability attributes for a memory access */ |
24 | 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 | ||
25 | 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 |
26 | index XXXXXXX..XXXXXXX 100644 | 42 | index XXXXXXX..XXXXXXX 100644 |
27 | --- a/target/arm/helper.c | 43 | --- a/target/arm/helper.c |
28 | +++ b/target/arm/helper.c | 44 | +++ b/target/arm/helper.c |
29 | @@ -XXX,XX +XXX,XX @@ static void v8m_security_lookup(CPUARMState *env, uint32_t address, | 45 | @@ -XXX,XX +XXX,XX @@ |
30 | V8M_SAttributes *sattrs); | 46 | #define ARM_CPU_FREQ 1000000000 /* FIXME: 1 GHz, should be configurable */ |
31 | #endif | 47 | |
32 | 48 | #ifndef CONFIG_USER_ONLY | |
33 | +static void switch_mode(CPUARMState *env, int mode); | 49 | -/* Cacheability and shareability attributes for a memory access */ |
34 | + | 50 | -typedef struct ARMCacheAttrs { |
35 | static int vfp_gdb_get_reg(CPUARMState *env, uint8_t *buf, int reg) | 51 | - unsigned int attrs:8; /* as in the MAIR register encoding */ |
52 | - unsigned int shareability:2; /* as in the SH field of the VMSAv8-64 PTEs */ | ||
53 | -} ARMCacheAttrs; | ||
54 | - | ||
55 | -static bool get_phys_addr(CPUARMState *env, target_ulong address, | ||
56 | - MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
57 | - hwaddr *phys_ptr, MemTxAttrs *attrs, int *prot, | ||
58 | - target_ulong *page_size, | ||
59 | - ARMMMUFaultInfo *fi, ARMCacheAttrs *cacheattrs); | ||
60 | |||
61 | static bool get_phys_addr_lpae(CPUARMState *env, target_ulong address, | ||
62 | MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
63 | @@ -XXX,XX +XXX,XX @@ static ARMCacheAttrs combine_cacheattrs(ARMCacheAttrs s1, ARMCacheAttrs s2) | ||
64 | * @fi: set to fault info if the translation fails | ||
65 | * @cacheattrs: (if non-NULL) set to the cacheability/shareability attributes | ||
66 | */ | ||
67 | -static bool get_phys_addr(CPUARMState *env, target_ulong address, | ||
68 | - MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
69 | - hwaddr *phys_ptr, MemTxAttrs *attrs, int *prot, | ||
70 | - target_ulong *page_size, | ||
71 | - ARMMMUFaultInfo *fi, ARMCacheAttrs *cacheattrs) | ||
72 | +bool get_phys_addr(CPUARMState *env, target_ulong address, | ||
73 | + MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
74 | + hwaddr *phys_ptr, MemTxAttrs *attrs, int *prot, | ||
75 | + target_ulong *page_size, | ||
76 | + ARMMMUFaultInfo *fi, ARMCacheAttrs *cacheattrs) | ||
36 | { | 77 | { |
37 | int nregs; | 78 | if (mmu_idx == ARMMMUIdx_S12NSE0 || mmu_idx == ARMMMUIdx_S12NSE1) { |
38 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(v7m_tt)(CPUARMState *env, uint32_t addr, uint32_t op) | 79 | /* Call ourselves recursively to do the stage 1 and then stage 2 |
39 | return 0; | ||
40 | } | ||
41 | |||
42 | -void switch_mode(CPUARMState *env, int mode) | ||
43 | +static void switch_mode(CPUARMState *env, int mode) | ||
44 | { | ||
45 | ARMCPU *cpu = arm_env_get_cpu(env); | ||
46 | |||
47 | @@ -XXX,XX +XXX,XX @@ void aarch64_sync_64_to_32(CPUARMState *env) | ||
48 | |||
49 | #else | ||
50 | |||
51 | -void switch_mode(CPUARMState *env, int mode) | ||
52 | +static void switch_mode(CPUARMState *env, int mode) | ||
53 | { | ||
54 | int old_mode; | ||
55 | int i; | ||
56 | -- | 80 | -- |
57 | 2.19.1 | 81 | 2.20.1 |
58 | 82 | ||
59 | 83 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | Move mla_op and mls_op expanders from translate-a64.c. | 3 | These routines are TCG specific. |
4 | The arm_deliver_fault() function is only used within the new | ||
5 | helper. Make it static. | ||
4 | 6 | ||
5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 7 | Suggested-by: Alex Bennée <alex.bennee@linaro.org> |
6 | Message-id: 20181011205206.3552-16-richard.henderson@linaro.org | 8 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> |
9 | Message-id: 20190701132516.26392-13-philmd@redhat.com | ||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | --- | 12 | --- |
10 | target/arm/translate.h | 2 + | 13 | target/arm/Makefile.objs | 1 + |
11 | target/arm/translate-a64.c | 106 ----------------------------- | 14 | target/arm/internals.h | 3 - |
12 | target/arm/translate.c | 134 ++++++++++++++++++++++++++++++++----- | 15 | target/arm/cpu.c | 6 +- |
13 | 3 files changed, 120 insertions(+), 122 deletions(-) | 16 | target/arm/helper.c | 53 ----------- |
17 | target/arm/op_helper.c | 135 -------------------------- | ||
18 | target/arm/tlb_helper.c | 200 +++++++++++++++++++++++++++++++++++++++ | ||
19 | 6 files changed, 205 insertions(+), 193 deletions(-) | ||
20 | create mode 100644 target/arm/tlb_helper.c | ||
14 | 21 | ||
15 | diff --git a/target/arm/translate.h b/target/arm/translate.h | 22 | diff --git a/target/arm/Makefile.objs b/target/arm/Makefile.objs |
16 | index XXXXXXX..XXXXXXX 100644 | 23 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/translate.h | 24 | --- a/target/arm/Makefile.objs |
18 | +++ b/target/arm/translate.h | 25 | +++ b/target/arm/Makefile.objs |
19 | @@ -XXX,XX +XXX,XX @@ static inline TCGv_i32 get_ahp_flag(void) | 26 | @@ -XXX,XX +XXX,XX @@ target/arm/translate-sve.o: target/arm/decode-sve.inc.c |
20 | extern const GVecGen3 bsl_op; | 27 | target/arm/translate.o: target/arm/decode-vfp.inc.c |
21 | extern const GVecGen3 bit_op; | 28 | target/arm/translate.o: target/arm/decode-vfp-uncond.inc.c |
22 | extern const GVecGen3 bif_op; | 29 | |
23 | +extern const GVecGen3 mla_op[4]; | 30 | +obj-y += tlb_helper.o |
24 | +extern const GVecGen3 mls_op[4]; | 31 | obj-y += translate.o op_helper.o |
25 | extern const GVecGen2i ssra_op[4]; | 32 | obj-y += crypto_helper.o |
26 | extern const GVecGen2i usra_op[4]; | 33 | obj-y += iwmmxt_helper.o vec_helper.o neon_helper.o |
27 | extern const GVecGen2i sri_op[4]; | 34 | diff --git a/target/arm/internals.h b/target/arm/internals.h |
28 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
29 | index XXXXXXX..XXXXXXX 100644 | 35 | index XXXXXXX..XXXXXXX 100644 |
30 | --- a/target/arm/translate-a64.c | 36 | --- a/target/arm/internals.h |
31 | +++ b/target/arm/translate-a64.c | 37 | +++ b/target/arm/internals.h |
32 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_3same_float(DisasContext *s, uint32_t insn) | 38 | @@ -XXX,XX +XXX,XX @@ bool arm_cpu_tlb_fill(CPUState *cs, vaddr address, int size, |
33 | } | 39 | MMUAccessType access_type, int mmu_idx, |
40 | bool probe, uintptr_t retaddr); | ||
41 | |||
42 | -void arm_deliver_fault(ARMCPU *cpu, vaddr addr, MMUAccessType access_type, | ||
43 | - int mmu_idx, ARMMMUFaultInfo *fi) QEMU_NORETURN; | ||
44 | - | ||
45 | /* Return true if the stage 1 translation regime is using LPAE format page | ||
46 | * tables */ | ||
47 | bool arm_s1_regime_using_lpae_format(CPUARMState *env, ARMMMUIdx mmu_idx); | ||
48 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | ||
49 | index XXXXXXX..XXXXXXX 100644 | ||
50 | --- a/target/arm/cpu.c | ||
51 | +++ b/target/arm/cpu.c | ||
52 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_class_init(ObjectClass *oc, void *data) | ||
53 | cc->gdb_write_register = arm_cpu_gdb_write_register; | ||
54 | #ifndef CONFIG_USER_ONLY | ||
55 | cc->do_interrupt = arm_cpu_do_interrupt; | ||
56 | - cc->do_unaligned_access = arm_cpu_do_unaligned_access; | ||
57 | - cc->do_transaction_failed = arm_cpu_do_transaction_failed; | ||
58 | cc->get_phys_page_attrs_debug = arm_cpu_get_phys_page_attrs_debug; | ||
59 | cc->asidx_from_attrs = arm_asidx_from_attrs; | ||
60 | cc->vmsd = &vmstate_arm_cpu; | ||
61 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_class_init(ObjectClass *oc, void *data) | ||
62 | #ifdef CONFIG_TCG | ||
63 | cc->tcg_initialize = arm_translate_init; | ||
64 | cc->tlb_fill = arm_cpu_tlb_fill; | ||
65 | +#if !defined(CONFIG_USER_ONLY) | ||
66 | + cc->do_unaligned_access = arm_cpu_do_unaligned_access; | ||
67 | + cc->do_transaction_failed = arm_cpu_do_transaction_failed; | ||
68 | +#endif /* CONFIG_TCG && !CONFIG_USER_ONLY */ | ||
69 | #endif | ||
34 | } | 70 | } |
35 | 71 | ||
36 | -static void gen_mla8_i32(TCGv_i32 d, TCGv_i32 a, TCGv_i32 b) | 72 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
73 | index XXXXXXX..XXXXXXX 100644 | ||
74 | --- a/target/arm/helper.c | ||
75 | +++ b/target/arm/helper.c | ||
76 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(v7m_tt)(CPUARMState *env, uint32_t addr, uint32_t op) | ||
77 | |||
78 | #endif | ||
79 | |||
80 | -bool arm_cpu_tlb_fill(CPUState *cs, vaddr address, int size, | ||
81 | - MMUAccessType access_type, int mmu_idx, | ||
82 | - bool probe, uintptr_t retaddr) | ||
37 | -{ | 83 | -{ |
38 | - gen_helper_neon_mul_u8(a, a, b); | 84 | - ARMCPU *cpu = ARM_CPU(cs); |
39 | - gen_helper_neon_add_u8(d, d, a); | 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 | ||
40 | -} | 131 | -} |
41 | - | 132 | - |
42 | -static void gen_mla16_i32(TCGv_i32 d, TCGv_i32 a, TCGv_i32 b) | 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) | ||
43 | -{ | 151 | -{ |
44 | - gen_helper_neon_mul_u16(a, a, b); | 152 | - uint32_t syn; |
45 | - gen_helper_neon_add_u16(d, d, a); | 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; | ||
46 | -} | 183 | -} |
47 | - | 184 | - |
48 | -static void gen_mla32_i32(TCGv_i32 d, TCGv_i32 a, TCGv_i32 b) | 185 | -void arm_deliver_fault(ARMCPU *cpu, vaddr addr, MMUAccessType access_type, |
186 | - int mmu_idx, ARMMMUFaultInfo *fi) | ||
49 | -{ | 187 | -{ |
50 | - tcg_gen_mul_i32(a, a, b); | 188 | - CPUARMState *env = &cpu->env; |
51 | - tcg_gen_add_i32(d, d, a); | 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); | ||
52 | -} | 238 | -} |
53 | - | 239 | - |
54 | -static void gen_mla64_i64(TCGv_i64 d, TCGv_i64 a, TCGv_i64 b) | 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) | ||
55 | -{ | 244 | -{ |
56 | - tcg_gen_mul_i64(a, a, b); | 245 | - ARMCPU *cpu = ARM_CPU(cs); |
57 | - tcg_gen_add_i64(d, d, a); | 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); | ||
58 | -} | 253 | -} |
59 | - | 254 | - |
60 | -static void gen_mla_vec(unsigned vece, TCGv_vec d, TCGv_vec a, TCGv_vec b) | 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) | ||
61 | -{ | 265 | -{ |
62 | - tcg_gen_mul_vec(vece, a, a, b); | 266 | - ARMCPU *cpu = ARM_CPU(cs); |
63 | - tcg_gen_add_vec(vece, d, d, a); | 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); | ||
64 | -} | 275 | -} |
65 | - | 276 | - |
66 | -static void gen_mls8_i32(TCGv_i32 d, TCGv_i32 a, TCGv_i32 b) | 277 | -#endif /* !defined(CONFIG_USER_ONLY) */ |
67 | -{ | 278 | - |
68 | - gen_helper_neon_mul_u8(a, a, b); | 279 | void HELPER(v8m_stackcheck)(CPUARMState *env, uint32_t newvalue) |
69 | - gen_helper_neon_sub_u8(d, d, a); | ||
70 | -} | ||
71 | - | ||
72 | -static void gen_mls16_i32(TCGv_i32 d, TCGv_i32 a, TCGv_i32 b) | ||
73 | -{ | ||
74 | - gen_helper_neon_mul_u16(a, a, b); | ||
75 | - gen_helper_neon_sub_u16(d, d, a); | ||
76 | -} | ||
77 | - | ||
78 | -static void gen_mls32_i32(TCGv_i32 d, TCGv_i32 a, TCGv_i32 b) | ||
79 | -{ | ||
80 | - tcg_gen_mul_i32(a, a, b); | ||
81 | - tcg_gen_sub_i32(d, d, a); | ||
82 | -} | ||
83 | - | ||
84 | -static void gen_mls64_i64(TCGv_i64 d, TCGv_i64 a, TCGv_i64 b) | ||
85 | -{ | ||
86 | - tcg_gen_mul_i64(a, a, b); | ||
87 | - tcg_gen_sub_i64(d, d, a); | ||
88 | -} | ||
89 | - | ||
90 | -static void gen_mls_vec(unsigned vece, TCGv_vec d, TCGv_vec a, TCGv_vec b) | ||
91 | -{ | ||
92 | - tcg_gen_mul_vec(vece, a, a, b); | ||
93 | - tcg_gen_sub_vec(vece, d, d, a); | ||
94 | -} | ||
95 | - | ||
96 | /* Integer op subgroup of C3.6.16. */ | ||
97 | static void disas_simd_3same_int(DisasContext *s, uint32_t insn) | ||
98 | { | 280 | { |
99 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_3same_int(DisasContext *s, uint32_t insn) | 281 | /* |
100 | .prefer_i64 = TCG_TARGET_REG_BITS == 64, | 282 | diff --git a/target/arm/tlb_helper.c b/target/arm/tlb_helper.c |
101 | .vece = MO_64 }, | 283 | new file mode 100644 |
102 | }; | 284 | index XXXXXXX..XXXXXXX |
103 | - static const GVecGen3 mla_op[4] = { | 285 | --- /dev/null |
104 | - { .fni4 = gen_mla8_i32, | 286 | +++ b/target/arm/tlb_helper.c |
105 | - .fniv = gen_mla_vec, | 287 | @@ -XXX,XX +XXX,XX @@ |
106 | - .opc = INDEX_op_mul_vec, | 288 | +/* |
107 | - .load_dest = true, | 289 | + * ARM TLB (Translation lookaside buffer) helpers. |
108 | - .vece = MO_8 }, | 290 | + * |
109 | - { .fni4 = gen_mla16_i32, | 291 | + * This code is licensed under the GNU GPL v2 or later. |
110 | - .fniv = gen_mla_vec, | 292 | + * |
111 | - .opc = INDEX_op_mul_vec, | 293 | + * SPDX-License-Identifier: GPL-2.0-or-later |
112 | - .load_dest = true, | 294 | + */ |
113 | - .vece = MO_16 }, | 295 | +#include "qemu/osdep.h" |
114 | - { .fni4 = gen_mla32_i32, | 296 | +#include "cpu.h" |
115 | - .fniv = gen_mla_vec, | 297 | +#include "internals.h" |
116 | - .opc = INDEX_op_mul_vec, | 298 | +#include "exec/exec-all.h" |
117 | - .load_dest = true, | 299 | + |
118 | - .vece = MO_32 }, | 300 | +#if !defined(CONFIG_USER_ONLY) |
119 | - { .fni8 = gen_mla64_i64, | 301 | + |
120 | - .fniv = gen_mla_vec, | 302 | +static inline uint32_t merge_syn_data_abort(uint32_t template_syn, |
121 | - .opc = INDEX_op_mul_vec, | 303 | + unsigned int target_el, |
122 | - .prefer_i64 = TCG_TARGET_REG_BITS == 64, | 304 | + bool same_el, bool ea, |
123 | - .load_dest = true, | 305 | + bool s1ptw, bool is_write, |
124 | - .vece = MO_64 }, | 306 | + int fsc) |
125 | - }; | ||
126 | - static const GVecGen3 mls_op[4] = { | ||
127 | - { .fni4 = gen_mls8_i32, | ||
128 | - .fniv = gen_mls_vec, | ||
129 | - .opc = INDEX_op_mul_vec, | ||
130 | - .load_dest = true, | ||
131 | - .vece = MO_8 }, | ||
132 | - { .fni4 = gen_mls16_i32, | ||
133 | - .fniv = gen_mls_vec, | ||
134 | - .opc = INDEX_op_mul_vec, | ||
135 | - .load_dest = true, | ||
136 | - .vece = MO_16 }, | ||
137 | - { .fni4 = gen_mls32_i32, | ||
138 | - .fniv = gen_mls_vec, | ||
139 | - .opc = INDEX_op_mul_vec, | ||
140 | - .load_dest = true, | ||
141 | - .vece = MO_32 }, | ||
142 | - { .fni8 = gen_mls64_i64, | ||
143 | - .fniv = gen_mls_vec, | ||
144 | - .opc = INDEX_op_mul_vec, | ||
145 | - .prefer_i64 = TCG_TARGET_REG_BITS == 64, | ||
146 | - .load_dest = true, | ||
147 | - .vece = MO_64 }, | ||
148 | - }; | ||
149 | |||
150 | int is_q = extract32(insn, 30, 1); | ||
151 | int u = extract32(insn, 29, 1); | ||
152 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
153 | index XXXXXXX..XXXXXXX 100644 | ||
154 | --- a/target/arm/translate.c | ||
155 | +++ b/target/arm/translate.c | ||
156 | @@ -XXX,XX +XXX,XX @@ static void gen_neon_narrow_op(int op, int u, int size, | ||
157 | #define NEON_3R_VABA 15 | ||
158 | #define NEON_3R_VADD_VSUB 16 | ||
159 | #define NEON_3R_VTST_VCEQ 17 | ||
160 | -#define NEON_3R_VML 18 /* VMLA, VMLAL, VMLS, VMLSL */ | ||
161 | +#define NEON_3R_VML 18 /* VMLA, VMLS */ | ||
162 | #define NEON_3R_VMUL 19 | ||
163 | #define NEON_3R_VPMAX 20 | ||
164 | #define NEON_3R_VPMIN 21 | ||
165 | @@ -XXX,XX +XXX,XX @@ const GVecGen2i sli_op[4] = { | ||
166 | .vece = MO_64 }, | ||
167 | }; | ||
168 | |||
169 | +static void gen_mla8_i32(TCGv_i32 d, TCGv_i32 a, TCGv_i32 b) | ||
170 | +{ | 307 | +{ |
171 | + gen_helper_neon_mul_u8(a, a, b); | 308 | + uint32_t syn; |
172 | + gen_helper_neon_add_u8(d, d, a); | 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; | ||
173 | +} | 339 | +} |
174 | + | 340 | + |
175 | +static void gen_mls8_i32(TCGv_i32 d, TCGv_i32 a, TCGv_i32 b) | 341 | +static void QEMU_NORETURN arm_deliver_fault(ARMCPU *cpu, vaddr addr, |
342 | + MMUAccessType access_type, | ||
343 | + int mmu_idx, ARMMMUFaultInfo *fi) | ||
176 | +{ | 344 | +{ |
177 | + gen_helper_neon_mul_u8(a, a, b); | 345 | + CPUARMState *env = &cpu->env; |
178 | + gen_helper_neon_sub_u8(d, d, a); | 346 | + int target_el; |
347 | + bool same_el; | ||
348 | + uint32_t syn, exc, fsr, fsc; | ||
349 | + ARMMMUIdx arm_mmu_idx = core_to_arm_mmu_idx(env, mmu_idx); | ||
350 | + | ||
351 | + target_el = exception_target_el(env); | ||
352 | + if (fi->stage2) { | ||
353 | + target_el = 2; | ||
354 | + env->cp15.hpfar_el2 = extract64(fi->s2addr, 12, 47) << 4; | ||
355 | + } | ||
356 | + same_el = (arm_current_el(env) == target_el); | ||
357 | + | ||
358 | + if (target_el == 2 || arm_el_is_aa64(env, target_el) || | ||
359 | + arm_s1_regime_using_lpae_format(env, arm_mmu_idx)) { | ||
360 | + /* | ||
361 | + * LPAE format fault status register : bottom 6 bits are | ||
362 | + * status code in the same form as needed for syndrome | ||
363 | + */ | ||
364 | + fsr = arm_fi_to_lfsc(fi); | ||
365 | + fsc = extract32(fsr, 0, 6); | ||
366 | + } else { | ||
367 | + fsr = arm_fi_to_sfsc(fi); | ||
368 | + /* | ||
369 | + * Short format FSR : this fault will never actually be reported | ||
370 | + * to an EL that uses a syndrome register. Use a (currently) | ||
371 | + * reserved FSR code in case the constructed syndrome does leak | ||
372 | + * into the guest somehow. | ||
373 | + */ | ||
374 | + fsc = 0x3f; | ||
375 | + } | ||
376 | + | ||
377 | + if (access_type == MMU_INST_FETCH) { | ||
378 | + syn = syn_insn_abort(same_el, fi->ea, fi->s1ptw, fsc); | ||
379 | + exc = EXCP_PREFETCH_ABORT; | ||
380 | + } else { | ||
381 | + syn = merge_syn_data_abort(env->exception.syndrome, target_el, | ||
382 | + same_el, fi->ea, fi->s1ptw, | ||
383 | + access_type == MMU_DATA_STORE, | ||
384 | + fsc); | ||
385 | + if (access_type == MMU_DATA_STORE | ||
386 | + && arm_feature(env, ARM_FEATURE_V6)) { | ||
387 | + fsr |= (1 << 11); | ||
388 | + } | ||
389 | + exc = EXCP_DATA_ABORT; | ||
390 | + } | ||
391 | + | ||
392 | + env->exception.vaddress = addr; | ||
393 | + env->exception.fsr = fsr; | ||
394 | + raise_exception(env, exc, syn, target_el); | ||
179 | +} | 395 | +} |
180 | + | 396 | + |
181 | +static void gen_mla16_i32(TCGv_i32 d, TCGv_i32 a, TCGv_i32 b) | 397 | +/* Raise a data fault alignment exception for the specified virtual address */ |
398 | +void arm_cpu_do_unaligned_access(CPUState *cs, vaddr vaddr, | ||
399 | + MMUAccessType access_type, | ||
400 | + int mmu_idx, uintptr_t retaddr) | ||
182 | +{ | 401 | +{ |
183 | + gen_helper_neon_mul_u16(a, a, b); | 402 | + ARMCPU *cpu = ARM_CPU(cs); |
184 | + gen_helper_neon_add_u16(d, d, a); | 403 | + ARMMMUFaultInfo fi = {}; |
404 | + | ||
405 | + /* now we have a real cpu fault */ | ||
406 | + cpu_restore_state(cs, retaddr, true); | ||
407 | + | ||
408 | + fi.type = ARMFault_Alignment; | ||
409 | + arm_deliver_fault(cpu, vaddr, access_type, mmu_idx, &fi); | ||
185 | +} | 410 | +} |
186 | + | 411 | + |
187 | +static void gen_mls16_i32(TCGv_i32 d, TCGv_i32 a, TCGv_i32 b) | 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) | ||
188 | +{ | 422 | +{ |
189 | + gen_helper_neon_mul_u16(a, a, b); | 423 | + ARMCPU *cpu = ARM_CPU(cs); |
190 | + gen_helper_neon_sub_u16(d, d, a); | 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); | ||
191 | +} | 432 | +} |
192 | + | 433 | + |
193 | +static void gen_mla32_i32(TCGv_i32 d, TCGv_i32 a, TCGv_i32 b) | 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) | ||
194 | +{ | 439 | +{ |
195 | + tcg_gen_mul_i32(a, a, b); | 440 | + ARMCPU *cpu = ARM_CPU(cs); |
196 | + tcg_gen_add_i32(d, d, a); | 441 | + |
442 | +#ifdef CONFIG_USER_ONLY | ||
443 | + cpu->env.exception.vaddress = address; | ||
444 | + if (access_type == MMU_INST_FETCH) { | ||
445 | + cs->exception_index = EXCP_PREFETCH_ABORT; | ||
446 | + } else { | ||
447 | + cs->exception_index = EXCP_DATA_ABORT; | ||
448 | + } | ||
449 | + cpu_loop_exit_restore(cs, retaddr); | ||
450 | +#else | ||
451 | + hwaddr phys_addr; | ||
452 | + target_ulong page_size; | ||
453 | + int prot, ret; | ||
454 | + MemTxAttrs attrs = {}; | ||
455 | + ARMMMUFaultInfo fi = {}; | ||
456 | + | ||
457 | + /* | ||
458 | + * Walk the page table and (if the mapping exists) add the page | ||
459 | + * to the TLB. On success, return true. Otherwise, if probing, | ||
460 | + * return false. Otherwise populate fsr with ARM DFSR/IFSR fault | ||
461 | + * register format, and signal the fault. | ||
462 | + */ | ||
463 | + ret = get_phys_addr(&cpu->env, address, access_type, | ||
464 | + core_to_arm_mmu_idx(&cpu->env, mmu_idx), | ||
465 | + &phys_addr, &attrs, &prot, &page_size, &fi, NULL); | ||
466 | + if (likely(!ret)) { | ||
467 | + /* | ||
468 | + * Map a single [sub]page. Regions smaller than our declared | ||
469 | + * target page size are handled specially, so for those we | ||
470 | + * pass in the exact addresses. | ||
471 | + */ | ||
472 | + if (page_size >= TARGET_PAGE_SIZE) { | ||
473 | + phys_addr &= TARGET_PAGE_MASK; | ||
474 | + address &= TARGET_PAGE_MASK; | ||
475 | + } | ||
476 | + tlb_set_page_with_attrs(cs, address, phys_addr, attrs, | ||
477 | + prot, mmu_idx, page_size); | ||
478 | + return true; | ||
479 | + } else if (probe) { | ||
480 | + return false; | ||
481 | + } else { | ||
482 | + /* now we have a real cpu fault */ | ||
483 | + cpu_restore_state(cs, retaddr, true); | ||
484 | + arm_deliver_fault(cpu, address, access_type, mmu_idx, &fi); | ||
485 | + } | ||
486 | +#endif | ||
197 | +} | 487 | +} |
198 | + | ||
199 | +static void gen_mls32_i32(TCGv_i32 d, TCGv_i32 a, TCGv_i32 b) | ||
200 | +{ | ||
201 | + tcg_gen_mul_i32(a, a, b); | ||
202 | + tcg_gen_sub_i32(d, d, a); | ||
203 | +} | ||
204 | + | ||
205 | +static void gen_mla64_i64(TCGv_i64 d, TCGv_i64 a, TCGv_i64 b) | ||
206 | +{ | ||
207 | + tcg_gen_mul_i64(a, a, b); | ||
208 | + tcg_gen_add_i64(d, d, a); | ||
209 | +} | ||
210 | + | ||
211 | +static void gen_mls64_i64(TCGv_i64 d, TCGv_i64 a, TCGv_i64 b) | ||
212 | +{ | ||
213 | + tcg_gen_mul_i64(a, a, b); | ||
214 | + tcg_gen_sub_i64(d, d, a); | ||
215 | +} | ||
216 | + | ||
217 | +static void gen_mla_vec(unsigned vece, TCGv_vec d, TCGv_vec a, TCGv_vec b) | ||
218 | +{ | ||
219 | + tcg_gen_mul_vec(vece, a, a, b); | ||
220 | + tcg_gen_add_vec(vece, d, d, a); | ||
221 | +} | ||
222 | + | ||
223 | +static void gen_mls_vec(unsigned vece, TCGv_vec d, TCGv_vec a, TCGv_vec b) | ||
224 | +{ | ||
225 | + tcg_gen_mul_vec(vece, a, a, b); | ||
226 | + tcg_gen_sub_vec(vece, d, d, a); | ||
227 | +} | ||
228 | + | ||
229 | +/* Note that while NEON does not support VMLA and VMLS as 64-bit ops, | ||
230 | + * these tables are shared with AArch64 which does support them. | ||
231 | + */ | ||
232 | +const GVecGen3 mla_op[4] = { | ||
233 | + { .fni4 = gen_mla8_i32, | ||
234 | + .fniv = gen_mla_vec, | ||
235 | + .opc = INDEX_op_mul_vec, | ||
236 | + .load_dest = true, | ||
237 | + .vece = MO_8 }, | ||
238 | + { .fni4 = gen_mla16_i32, | ||
239 | + .fniv = gen_mla_vec, | ||
240 | + .opc = INDEX_op_mul_vec, | ||
241 | + .load_dest = true, | ||
242 | + .vece = MO_16 }, | ||
243 | + { .fni4 = gen_mla32_i32, | ||
244 | + .fniv = gen_mla_vec, | ||
245 | + .opc = INDEX_op_mul_vec, | ||
246 | + .load_dest = true, | ||
247 | + .vece = MO_32 }, | ||
248 | + { .fni8 = gen_mla64_i64, | ||
249 | + .fniv = gen_mla_vec, | ||
250 | + .opc = INDEX_op_mul_vec, | ||
251 | + .prefer_i64 = TCG_TARGET_REG_BITS == 64, | ||
252 | + .load_dest = true, | ||
253 | + .vece = MO_64 }, | ||
254 | +}; | ||
255 | + | ||
256 | +const GVecGen3 mls_op[4] = { | ||
257 | + { .fni4 = gen_mls8_i32, | ||
258 | + .fniv = gen_mls_vec, | ||
259 | + .opc = INDEX_op_mul_vec, | ||
260 | + .load_dest = true, | ||
261 | + .vece = MO_8 }, | ||
262 | + { .fni4 = gen_mls16_i32, | ||
263 | + .fniv = gen_mls_vec, | ||
264 | + .opc = INDEX_op_mul_vec, | ||
265 | + .load_dest = true, | ||
266 | + .vece = MO_16 }, | ||
267 | + { .fni4 = gen_mls32_i32, | ||
268 | + .fniv = gen_mls_vec, | ||
269 | + .opc = INDEX_op_mul_vec, | ||
270 | + .load_dest = true, | ||
271 | + .vece = MO_32 }, | ||
272 | + { .fni8 = gen_mls64_i64, | ||
273 | + .fniv = gen_mls_vec, | ||
274 | + .opc = INDEX_op_mul_vec, | ||
275 | + .prefer_i64 = TCG_TARGET_REG_BITS == 64, | ||
276 | + .load_dest = true, | ||
277 | + .vece = MO_64 }, | ||
278 | +}; | ||
279 | + | ||
280 | /* Translate a NEON data processing instruction. Return nonzero if the | ||
281 | instruction is invalid. | ||
282 | We process data in a mixture of 32-bit and 64-bit chunks. | ||
283 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
284 | return 0; | ||
285 | } | ||
286 | break; | ||
287 | + | ||
288 | + case NEON_3R_VML: /* VMLA, VMLS */ | ||
289 | + tcg_gen_gvec_3(rd_ofs, rn_ofs, rm_ofs, vec_size, vec_size, | ||
290 | + u ? &mls_op[size] : &mla_op[size]); | ||
291 | + return 0; | ||
292 | } | ||
293 | + | ||
294 | if (size == 3) { | ||
295 | /* 64-bit element instructions. */ | ||
296 | for (pass = 0; pass < (q ? 2 : 1); pass++) { | ||
297 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
298 | } | ||
299 | } | ||
300 | break; | ||
301 | - case NEON_3R_VML: /* VMLA, VMLAL, VMLS,VMLSL */ | ||
302 | - switch (size) { | ||
303 | - case 0: gen_helper_neon_mul_u8(tmp, tmp, tmp2); break; | ||
304 | - case 1: gen_helper_neon_mul_u16(tmp, tmp, tmp2); break; | ||
305 | - case 2: tcg_gen_mul_i32(tmp, tmp, tmp2); break; | ||
306 | - default: abort(); | ||
307 | - } | ||
308 | - tcg_temp_free_i32(tmp2); | ||
309 | - tmp2 = neon_load_reg(rd, pass); | ||
310 | - if (u) { /* VMLS */ | ||
311 | - gen_neon_rsb(size, tmp, tmp2); | ||
312 | - } else { /* VMLA */ | ||
313 | - gen_neon_add(size, tmp, tmp2); | ||
314 | - } | ||
315 | - break; | ||
316 | case NEON_3R_VMUL: | ||
317 | /* VMUL.P8; other cases already eliminated. */ | ||
318 | gen_helper_neon_mul_p8(tmp, tmp, tmp2); | ||
319 | -- | 488 | -- |
320 | 2.19.1 | 489 | 2.20.1 |
321 | 490 | ||
322 | 491 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | Move shi_op and sli_op expanders from translate-a64.c. | 3 | To ease the review of the next commit, |
4 | move the vfp_exceptbits_to_host() function directly after | ||
5 | vfp_exceptbits_from_host(). Amusingly the diff shows we | ||
6 | are moving vfp_get_fpscr(). | ||
4 | 7 | ||
5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 8 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> |
6 | Message-id: 20181011205206.3552-15-richard.henderson@linaro.org | 9 | Message-id: 20190701132516.26392-15-philmd@redhat.com |
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | --- | 12 | --- |
10 | target/arm/translate.h | 2 + | 13 | target/arm/vfp_helper.c | 52 ++++++++++++++++++++--------------------- |
11 | target/arm/translate-a64.c | 152 +---------------------- | 14 | 1 file changed, 26 insertions(+), 26 deletions(-) |
12 | target/arm/translate.c | 244 ++++++++++++++++++++++++++----------- | ||
13 | 3 files changed, 179 insertions(+), 219 deletions(-) | ||
14 | 15 | ||
15 | diff --git a/target/arm/translate.h b/target/arm/translate.h | 16 | diff --git a/target/arm/vfp_helper.c b/target/arm/vfp_helper.c |
16 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/translate.h | 18 | --- a/target/arm/vfp_helper.c |
18 | +++ b/target/arm/translate.h | 19 | +++ b/target/arm/vfp_helper.c |
19 | @@ -XXX,XX +XXX,XX @@ extern const GVecGen3 bit_op; | 20 | @@ -XXX,XX +XXX,XX @@ static inline int vfp_exceptbits_from_host(int host_bits) |
20 | extern const GVecGen3 bif_op; | 21 | return target_bits; |
21 | extern const GVecGen2i ssra_op[4]; | ||
22 | extern const GVecGen2i usra_op[4]; | ||
23 | +extern const GVecGen2i sri_op[4]; | ||
24 | +extern const GVecGen2i sli_op[4]; | ||
25 | |||
26 | /* | ||
27 | * Forward to the isar_feature_* tests given a DisasContext pointer. | ||
28 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
29 | index XXXXXXX..XXXXXXX 100644 | ||
30 | --- a/target/arm/translate-a64.c | ||
31 | +++ b/target/arm/translate-a64.c | ||
32 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_scalar_two_reg_misc(DisasContext *s, uint32_t insn) | ||
33 | } | ||
34 | } | 22 | } |
35 | 23 | ||
36 | -static void gen_shr8_ins_i64(TCGv_i64 d, TCGv_i64 a, int64_t shift) | 24 | -uint32_t HELPER(vfp_get_fpscr)(CPUARMState *env) |
37 | -{ | 25 | -{ |
38 | - uint64_t mask = dup_const(MO_8, 0xff >> shift); | 26 | - uint32_t i, fpscr; |
39 | - TCGv_i64 t = tcg_temp_new_i64(); | ||
40 | - | 27 | - |
41 | - tcg_gen_shri_i64(t, a, shift); | 28 | - fpscr = env->vfp.xregs[ARM_VFP_FPSCR] |
42 | - tcg_gen_andi_i64(t, t, mask); | 29 | - | (env->vfp.vec_len << 16) |
43 | - tcg_gen_andi_i64(d, d, ~mask); | 30 | - | (env->vfp.vec_stride << 20); |
44 | - tcg_gen_or_i64(d, d, t); | 31 | - |
45 | - tcg_temp_free_i64(t); | 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; | ||
46 | -} | 43 | -} |
47 | - | 44 | - |
48 | -static void gen_shr16_ins_i64(TCGv_i64 d, TCGv_i64 a, int64_t shift) | 45 | -uint32_t vfp_get_fpscr(CPUARMState *env) |
49 | -{ | 46 | -{ |
50 | - uint64_t mask = dup_const(MO_16, 0xffff >> shift); | 47 | - return HELPER(vfp_get_fpscr)(env); |
51 | - TCGv_i64 t = tcg_temp_new_i64(); | ||
52 | - | ||
53 | - tcg_gen_shri_i64(t, a, shift); | ||
54 | - tcg_gen_andi_i64(t, t, mask); | ||
55 | - tcg_gen_andi_i64(d, d, ~mask); | ||
56 | - tcg_gen_or_i64(d, d, t); | ||
57 | - tcg_temp_free_i64(t); | ||
58 | -} | 48 | -} |
59 | - | 49 | - |
60 | -static void gen_shr32_ins_i32(TCGv_i32 d, TCGv_i32 a, int32_t shift) | 50 | /* Convert vfp exception flags to target form. */ |
61 | -{ | 51 | static inline int vfp_exceptbits_to_host(int target_bits) |
62 | - tcg_gen_shri_i32(a, a, shift); | ||
63 | - tcg_gen_deposit_i32(d, d, a, 0, 32 - shift); | ||
64 | -} | ||
65 | - | ||
66 | -static void gen_shr64_ins_i64(TCGv_i64 d, TCGv_i64 a, int64_t shift) | ||
67 | -{ | ||
68 | - tcg_gen_shri_i64(a, a, shift); | ||
69 | - tcg_gen_deposit_i64(d, d, a, 0, 64 - shift); | ||
70 | -} | ||
71 | - | ||
72 | -static void gen_shr_ins_vec(unsigned vece, TCGv_vec d, TCGv_vec a, int64_t sh) | ||
73 | -{ | ||
74 | - uint64_t mask = (2ull << ((8 << vece) - 1)) - 1; | ||
75 | - TCGv_vec t = tcg_temp_new_vec_matching(d); | ||
76 | - TCGv_vec m = tcg_temp_new_vec_matching(d); | ||
77 | - | ||
78 | - tcg_gen_dupi_vec(vece, m, mask ^ (mask >> sh)); | ||
79 | - tcg_gen_shri_vec(vece, t, a, sh); | ||
80 | - tcg_gen_and_vec(vece, d, d, m); | ||
81 | - tcg_gen_or_vec(vece, d, d, t); | ||
82 | - | ||
83 | - tcg_temp_free_vec(t); | ||
84 | - tcg_temp_free_vec(m); | ||
85 | -} | ||
86 | - | ||
87 | /* SSHR[RA]/USHR[RA] - Vector shift right (optional rounding/accumulate) */ | ||
88 | static void handle_vec_simd_shri(DisasContext *s, bool is_q, bool is_u, | ||
89 | int immh, int immb, int opcode, int rn, int rd) | ||
90 | { | 52 | { |
91 | - static const GVecGen2i sri_op[4] = { | 53 | @@ -XXX,XX +XXX,XX @@ static inline int vfp_exceptbits_to_host(int target_bits) |
92 | - { .fni8 = gen_shr8_ins_i64, | 54 | return host_bits; |
93 | - .fniv = gen_shr_ins_vec, | ||
94 | - .load_dest = true, | ||
95 | - .opc = INDEX_op_shri_vec, | ||
96 | - .vece = MO_8 }, | ||
97 | - { .fni8 = gen_shr16_ins_i64, | ||
98 | - .fniv = gen_shr_ins_vec, | ||
99 | - .load_dest = true, | ||
100 | - .opc = INDEX_op_shri_vec, | ||
101 | - .vece = MO_16 }, | ||
102 | - { .fni4 = gen_shr32_ins_i32, | ||
103 | - .fniv = gen_shr_ins_vec, | ||
104 | - .load_dest = true, | ||
105 | - .opc = INDEX_op_shri_vec, | ||
106 | - .vece = MO_32 }, | ||
107 | - { .fni8 = gen_shr64_ins_i64, | ||
108 | - .fniv = gen_shr_ins_vec, | ||
109 | - .prefer_i64 = TCG_TARGET_REG_BITS == 64, | ||
110 | - .load_dest = true, | ||
111 | - .opc = INDEX_op_shri_vec, | ||
112 | - .vece = MO_64 }, | ||
113 | - }; | ||
114 | - | ||
115 | int size = 32 - clz32(immh) - 1; | ||
116 | int immhb = immh << 3 | immb; | ||
117 | int shift = 2 * (8 << size) - immhb; | ||
118 | @@ -XXX,XX +XXX,XX @@ static void handle_vec_simd_shri(DisasContext *s, bool is_q, bool is_u, | ||
119 | clear_vec_high(s, is_q, rd); | ||
120 | } | 55 | } |
121 | 56 | ||
122 | -static void gen_shl8_ins_i64(TCGv_i64 d, TCGv_i64 a, int64_t shift) | 57 | +uint32_t HELPER(vfp_get_fpscr)(CPUARMState *env) |
123 | -{ | ||
124 | - uint64_t mask = dup_const(MO_8, 0xff << shift); | ||
125 | - TCGv_i64 t = tcg_temp_new_i64(); | ||
126 | - | ||
127 | - tcg_gen_shli_i64(t, a, shift); | ||
128 | - tcg_gen_andi_i64(t, t, mask); | ||
129 | - tcg_gen_andi_i64(d, d, ~mask); | ||
130 | - tcg_gen_or_i64(d, d, t); | ||
131 | - tcg_temp_free_i64(t); | ||
132 | -} | ||
133 | - | ||
134 | -static void gen_shl16_ins_i64(TCGv_i64 d, TCGv_i64 a, int64_t shift) | ||
135 | -{ | ||
136 | - uint64_t mask = dup_const(MO_16, 0xffff << shift); | ||
137 | - TCGv_i64 t = tcg_temp_new_i64(); | ||
138 | - | ||
139 | - tcg_gen_shli_i64(t, a, shift); | ||
140 | - tcg_gen_andi_i64(t, t, mask); | ||
141 | - tcg_gen_andi_i64(d, d, ~mask); | ||
142 | - tcg_gen_or_i64(d, d, t); | ||
143 | - tcg_temp_free_i64(t); | ||
144 | -} | ||
145 | - | ||
146 | -static void gen_shl32_ins_i32(TCGv_i32 d, TCGv_i32 a, int32_t shift) | ||
147 | -{ | ||
148 | - tcg_gen_deposit_i32(d, d, a, shift, 32 - shift); | ||
149 | -} | ||
150 | - | ||
151 | -static void gen_shl64_ins_i64(TCGv_i64 d, TCGv_i64 a, int64_t shift) | ||
152 | -{ | ||
153 | - tcg_gen_deposit_i64(d, d, a, shift, 64 - shift); | ||
154 | -} | ||
155 | - | ||
156 | -static void gen_shl_ins_vec(unsigned vece, TCGv_vec d, TCGv_vec a, int64_t sh) | ||
157 | -{ | ||
158 | - uint64_t mask = (1ull << sh) - 1; | ||
159 | - TCGv_vec t = tcg_temp_new_vec_matching(d); | ||
160 | - TCGv_vec m = tcg_temp_new_vec_matching(d); | ||
161 | - | ||
162 | - tcg_gen_dupi_vec(vece, m, mask); | ||
163 | - tcg_gen_shli_vec(vece, t, a, sh); | ||
164 | - tcg_gen_and_vec(vece, d, d, m); | ||
165 | - tcg_gen_or_vec(vece, d, d, t); | ||
166 | - | ||
167 | - tcg_temp_free_vec(t); | ||
168 | - tcg_temp_free_vec(m); | ||
169 | -} | ||
170 | - | ||
171 | /* SHL/SLI - Vector shift left */ | ||
172 | static void handle_vec_simd_shli(DisasContext *s, bool is_q, bool insert, | ||
173 | int immh, int immb, int opcode, int rn, int rd) | ||
174 | { | ||
175 | - static const GVecGen2i shi_op[4] = { | ||
176 | - { .fni8 = gen_shl8_ins_i64, | ||
177 | - .fniv = gen_shl_ins_vec, | ||
178 | - .opc = INDEX_op_shli_vec, | ||
179 | - .prefer_i64 = TCG_TARGET_REG_BITS == 64, | ||
180 | - .load_dest = true, | ||
181 | - .vece = MO_8 }, | ||
182 | - { .fni8 = gen_shl16_ins_i64, | ||
183 | - .fniv = gen_shl_ins_vec, | ||
184 | - .opc = INDEX_op_shli_vec, | ||
185 | - .prefer_i64 = TCG_TARGET_REG_BITS == 64, | ||
186 | - .load_dest = true, | ||
187 | - .vece = MO_16 }, | ||
188 | - { .fni4 = gen_shl32_ins_i32, | ||
189 | - .fniv = gen_shl_ins_vec, | ||
190 | - .opc = INDEX_op_shli_vec, | ||
191 | - .prefer_i64 = TCG_TARGET_REG_BITS == 64, | ||
192 | - .load_dest = true, | ||
193 | - .vece = MO_32 }, | ||
194 | - { .fni8 = gen_shl64_ins_i64, | ||
195 | - .fniv = gen_shl_ins_vec, | ||
196 | - .opc = INDEX_op_shli_vec, | ||
197 | - .prefer_i64 = TCG_TARGET_REG_BITS == 64, | ||
198 | - .load_dest = true, | ||
199 | - .vece = MO_64 }, | ||
200 | - }; | ||
201 | int size = 32 - clz32(immh) - 1; | ||
202 | int immhb = immh << 3 | immb; | ||
203 | int shift = immhb - (8 << size); | ||
204 | @@ -XXX,XX +XXX,XX @@ static void handle_vec_simd_shli(DisasContext *s, bool is_q, bool insert, | ||
205 | } | ||
206 | |||
207 | if (insert) { | ||
208 | - gen_gvec_op2i(s, is_q, rd, rn, shift, &shi_op[size]); | ||
209 | + gen_gvec_op2i(s, is_q, rd, rn, shift, &sli_op[size]); | ||
210 | } else { | ||
211 | gen_gvec_fn2i(s, is_q, rd, rn, shift, tcg_gen_gvec_shli, size); | ||
212 | } | ||
213 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
214 | index XXXXXXX..XXXXXXX 100644 | ||
215 | --- a/target/arm/translate.c | ||
216 | +++ b/target/arm/translate.c | ||
217 | @@ -XXX,XX +XXX,XX @@ const GVecGen2i usra_op[4] = { | ||
218 | .vece = MO_64, }, | ||
219 | }; | ||
220 | |||
221 | +static void gen_shr8_ins_i64(TCGv_i64 d, TCGv_i64 a, int64_t shift) | ||
222 | +{ | 58 | +{ |
223 | + uint64_t mask = dup_const(MO_8, 0xff >> shift); | 59 | + uint32_t i, fpscr; |
224 | + TCGv_i64 t = tcg_temp_new_i64(); | ||
225 | + | 60 | + |
226 | + tcg_gen_shri_i64(t, a, shift); | 61 | + fpscr = env->vfp.xregs[ARM_VFP_FPSCR] |
227 | + tcg_gen_andi_i64(t, t, mask); | 62 | + | (env->vfp.vec_len << 16) |
228 | + tcg_gen_andi_i64(d, d, ~mask); | 63 | + | (env->vfp.vec_stride << 20); |
229 | + tcg_gen_or_i64(d, d, t); | 64 | + |
230 | + tcg_temp_free_i64(t); | 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; | ||
231 | +} | 76 | +} |
232 | + | 77 | + |
233 | +static void gen_shr16_ins_i64(TCGv_i64 d, TCGv_i64 a, int64_t shift) | 78 | +uint32_t vfp_get_fpscr(CPUARMState *env) |
234 | +{ | 79 | +{ |
235 | + uint64_t mask = dup_const(MO_16, 0xffff >> shift); | 80 | + return HELPER(vfp_get_fpscr)(env); |
236 | + TCGv_i64 t = tcg_temp_new_i64(); | ||
237 | + | ||
238 | + tcg_gen_shri_i64(t, a, shift); | ||
239 | + tcg_gen_andi_i64(t, t, mask); | ||
240 | + tcg_gen_andi_i64(d, d, ~mask); | ||
241 | + tcg_gen_or_i64(d, d, t); | ||
242 | + tcg_temp_free_i64(t); | ||
243 | +} | 81 | +} |
244 | + | 82 | + |
245 | +static void gen_shr32_ins_i32(TCGv_i32 d, TCGv_i32 a, int32_t shift) | 83 | void HELPER(vfp_set_fpscr)(CPUARMState *env, uint32_t val) |
246 | +{ | 84 | { |
247 | + tcg_gen_shri_i32(a, a, shift); | 85 | int i; |
248 | + tcg_gen_deposit_i32(d, d, a, 0, 32 - shift); | ||
249 | +} | ||
250 | + | ||
251 | +static void gen_shr64_ins_i64(TCGv_i64 d, TCGv_i64 a, int64_t shift) | ||
252 | +{ | ||
253 | + tcg_gen_shri_i64(a, a, shift); | ||
254 | + tcg_gen_deposit_i64(d, d, a, 0, 64 - shift); | ||
255 | +} | ||
256 | + | ||
257 | +static void gen_shr_ins_vec(unsigned vece, TCGv_vec d, TCGv_vec a, int64_t sh) | ||
258 | +{ | ||
259 | + if (sh == 0) { | ||
260 | + tcg_gen_mov_vec(d, a); | ||
261 | + } else { | ||
262 | + TCGv_vec t = tcg_temp_new_vec_matching(d); | ||
263 | + TCGv_vec m = tcg_temp_new_vec_matching(d); | ||
264 | + | ||
265 | + tcg_gen_dupi_vec(vece, m, MAKE_64BIT_MASK((8 << vece) - sh, sh)); | ||
266 | + tcg_gen_shri_vec(vece, t, a, sh); | ||
267 | + tcg_gen_and_vec(vece, d, d, m); | ||
268 | + tcg_gen_or_vec(vece, d, d, t); | ||
269 | + | ||
270 | + tcg_temp_free_vec(t); | ||
271 | + tcg_temp_free_vec(m); | ||
272 | + } | ||
273 | +} | ||
274 | + | ||
275 | +const GVecGen2i sri_op[4] = { | ||
276 | + { .fni8 = gen_shr8_ins_i64, | ||
277 | + .fniv = gen_shr_ins_vec, | ||
278 | + .load_dest = true, | ||
279 | + .opc = INDEX_op_shri_vec, | ||
280 | + .vece = MO_8 }, | ||
281 | + { .fni8 = gen_shr16_ins_i64, | ||
282 | + .fniv = gen_shr_ins_vec, | ||
283 | + .load_dest = true, | ||
284 | + .opc = INDEX_op_shri_vec, | ||
285 | + .vece = MO_16 }, | ||
286 | + { .fni4 = gen_shr32_ins_i32, | ||
287 | + .fniv = gen_shr_ins_vec, | ||
288 | + .load_dest = true, | ||
289 | + .opc = INDEX_op_shri_vec, | ||
290 | + .vece = MO_32 }, | ||
291 | + { .fni8 = gen_shr64_ins_i64, | ||
292 | + .fniv = gen_shr_ins_vec, | ||
293 | + .prefer_i64 = TCG_TARGET_REG_BITS == 64, | ||
294 | + .load_dest = true, | ||
295 | + .opc = INDEX_op_shri_vec, | ||
296 | + .vece = MO_64 }, | ||
297 | +}; | ||
298 | + | ||
299 | +static void gen_shl8_ins_i64(TCGv_i64 d, TCGv_i64 a, int64_t shift) | ||
300 | +{ | ||
301 | + uint64_t mask = dup_const(MO_8, 0xff << shift); | ||
302 | + TCGv_i64 t = tcg_temp_new_i64(); | ||
303 | + | ||
304 | + tcg_gen_shli_i64(t, a, shift); | ||
305 | + tcg_gen_andi_i64(t, t, mask); | ||
306 | + tcg_gen_andi_i64(d, d, ~mask); | ||
307 | + tcg_gen_or_i64(d, d, t); | ||
308 | + tcg_temp_free_i64(t); | ||
309 | +} | ||
310 | + | ||
311 | +static void gen_shl16_ins_i64(TCGv_i64 d, TCGv_i64 a, int64_t shift) | ||
312 | +{ | ||
313 | + uint64_t mask = dup_const(MO_16, 0xffff << shift); | ||
314 | + TCGv_i64 t = tcg_temp_new_i64(); | ||
315 | + | ||
316 | + tcg_gen_shli_i64(t, a, shift); | ||
317 | + tcg_gen_andi_i64(t, t, mask); | ||
318 | + tcg_gen_andi_i64(d, d, ~mask); | ||
319 | + tcg_gen_or_i64(d, d, t); | ||
320 | + tcg_temp_free_i64(t); | ||
321 | +} | ||
322 | + | ||
323 | +static void gen_shl32_ins_i32(TCGv_i32 d, TCGv_i32 a, int32_t shift) | ||
324 | +{ | ||
325 | + tcg_gen_deposit_i32(d, d, a, shift, 32 - shift); | ||
326 | +} | ||
327 | + | ||
328 | +static void gen_shl64_ins_i64(TCGv_i64 d, TCGv_i64 a, int64_t shift) | ||
329 | +{ | ||
330 | + tcg_gen_deposit_i64(d, d, a, shift, 64 - shift); | ||
331 | +} | ||
332 | + | ||
333 | +static void gen_shl_ins_vec(unsigned vece, TCGv_vec d, TCGv_vec a, int64_t sh) | ||
334 | +{ | ||
335 | + if (sh == 0) { | ||
336 | + tcg_gen_mov_vec(d, a); | ||
337 | + } else { | ||
338 | + TCGv_vec t = tcg_temp_new_vec_matching(d); | ||
339 | + TCGv_vec m = tcg_temp_new_vec_matching(d); | ||
340 | + | ||
341 | + tcg_gen_dupi_vec(vece, m, MAKE_64BIT_MASK(0, sh)); | ||
342 | + tcg_gen_shli_vec(vece, t, a, sh); | ||
343 | + tcg_gen_and_vec(vece, d, d, m); | ||
344 | + tcg_gen_or_vec(vece, d, d, t); | ||
345 | + | ||
346 | + tcg_temp_free_vec(t); | ||
347 | + tcg_temp_free_vec(m); | ||
348 | + } | ||
349 | +} | ||
350 | + | ||
351 | +const GVecGen2i sli_op[4] = { | ||
352 | + { .fni8 = gen_shl8_ins_i64, | ||
353 | + .fniv = gen_shl_ins_vec, | ||
354 | + .load_dest = true, | ||
355 | + .opc = INDEX_op_shli_vec, | ||
356 | + .vece = MO_8 }, | ||
357 | + { .fni8 = gen_shl16_ins_i64, | ||
358 | + .fniv = gen_shl_ins_vec, | ||
359 | + .load_dest = true, | ||
360 | + .opc = INDEX_op_shli_vec, | ||
361 | + .vece = MO_16 }, | ||
362 | + { .fni4 = gen_shl32_ins_i32, | ||
363 | + .fniv = gen_shl_ins_vec, | ||
364 | + .load_dest = true, | ||
365 | + .opc = INDEX_op_shli_vec, | ||
366 | + .vece = MO_32 }, | ||
367 | + { .fni8 = gen_shl64_ins_i64, | ||
368 | + .fniv = gen_shl_ins_vec, | ||
369 | + .prefer_i64 = TCG_TARGET_REG_BITS == 64, | ||
370 | + .load_dest = true, | ||
371 | + .opc = INDEX_op_shli_vec, | ||
372 | + .vece = MO_64 }, | ||
373 | +}; | ||
374 | + | ||
375 | /* Translate a NEON data processing instruction. Return nonzero if the | ||
376 | instruction is invalid. | ||
377 | We process data in a mixture of 32-bit and 64-bit chunks. | ||
378 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
379 | int pairwise; | ||
380 | int u; | ||
381 | int vec_size; | ||
382 | - uint32_t imm, mask; | ||
383 | + uint32_t imm; | ||
384 | TCGv_i32 tmp, tmp2, tmp3, tmp4, tmp5; | ||
385 | TCGv_ptr ptr1, ptr2, ptr3; | ||
386 | TCGv_i64 tmp64; | ||
387 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
388 | } | ||
389 | return 0; | ||
390 | |||
391 | + case 4: /* VSRI */ | ||
392 | + if (!u) { | ||
393 | + return 1; | ||
394 | + } | ||
395 | + /* Right shift comes here negative. */ | ||
396 | + shift = -shift; | ||
397 | + /* Shift out of range leaves destination unchanged. */ | ||
398 | + if (shift < 8 << size) { | ||
399 | + tcg_gen_gvec_2i(rd_ofs, rm_ofs, vec_size, vec_size, | ||
400 | + shift, &sri_op[size]); | ||
401 | + } | ||
402 | + return 0; | ||
403 | + | ||
404 | case 5: /* VSHL, VSLI */ | ||
405 | - if (!u) { /* VSHL */ | ||
406 | + if (u) { /* VSLI */ | ||
407 | + /* Shift out of range leaves destination unchanged. */ | ||
408 | + if (shift < 8 << size) { | ||
409 | + tcg_gen_gvec_2i(rd_ofs, rm_ofs, vec_size, | ||
410 | + vec_size, shift, &sli_op[size]); | ||
411 | + } | ||
412 | + } else { /* VSHL */ | ||
413 | /* Shifts larger than the element size are | ||
414 | * architecturally valid and results in zero. | ||
415 | */ | ||
416 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
417 | tcg_gen_gvec_shli(size, rd_ofs, rm_ofs, shift, | ||
418 | vec_size, vec_size); | ||
419 | } | ||
420 | - return 0; | ||
421 | } | ||
422 | - break; | ||
423 | + return 0; | ||
424 | } | ||
425 | |||
426 | if (size == 3) { | ||
427 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
428 | else | ||
429 | gen_helper_neon_rshl_s64(cpu_V0, cpu_V0, cpu_V1); | ||
430 | break; | ||
431 | - case 4: /* VSRI */ | ||
432 | - case 5: /* VSHL, VSLI */ | ||
433 | - gen_helper_neon_shl_u64(cpu_V0, cpu_V0, cpu_V1); | ||
434 | - break; | ||
435 | case 6: /* VQSHLU */ | ||
436 | gen_helper_neon_qshlu_s64(cpu_V0, cpu_env, | ||
437 | cpu_V0, cpu_V1); | ||
438 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
439 | /* Accumulate. */ | ||
440 | neon_load_reg64(cpu_V1, rd + pass); | ||
441 | tcg_gen_add_i64(cpu_V0, cpu_V0, cpu_V1); | ||
442 | - } else if (op == 4 || (op == 5 && u)) { | ||
443 | - /* Insert */ | ||
444 | - neon_load_reg64(cpu_V1, rd + pass); | ||
445 | - uint64_t mask; | ||
446 | - if (shift < -63 || shift > 63) { | ||
447 | - mask = 0; | ||
448 | - } else { | ||
449 | - if (op == 4) { | ||
450 | - mask = 0xffffffffffffffffull >> -shift; | ||
451 | - } else { | ||
452 | - mask = 0xffffffffffffffffull << shift; | ||
453 | - } | ||
454 | - } | ||
455 | - tcg_gen_andi_i64(cpu_V1, cpu_V1, ~mask); | ||
456 | - tcg_gen_or_i64(cpu_V0, cpu_V0, cpu_V1); | ||
457 | } | ||
458 | neon_store_reg64(cpu_V0, rd + pass); | ||
459 | } else { /* size < 3 */ | ||
460 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
461 | case 3: /* VRSRA */ | ||
462 | GEN_NEON_INTEGER_OP(rshl); | ||
463 | break; | ||
464 | - case 4: /* VSRI */ | ||
465 | - case 5: /* VSHL, VSLI */ | ||
466 | - switch (size) { | ||
467 | - case 0: gen_helper_neon_shl_u8(tmp, tmp, tmp2); break; | ||
468 | - case 1: gen_helper_neon_shl_u16(tmp, tmp, tmp2); break; | ||
469 | - case 2: gen_helper_neon_shl_u32(tmp, tmp, tmp2); break; | ||
470 | - default: abort(); | ||
471 | - } | ||
472 | - break; | ||
473 | case 6: /* VQSHLU */ | ||
474 | switch (size) { | ||
475 | case 0: | ||
476 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
477 | tmp2 = neon_load_reg(rd, pass); | ||
478 | gen_neon_add(size, tmp, tmp2); | ||
479 | tcg_temp_free_i32(tmp2); | ||
480 | - } else if (op == 4 || (op == 5 && u)) { | ||
481 | - /* Insert */ | ||
482 | - switch (size) { | ||
483 | - case 0: | ||
484 | - if (op == 4) | ||
485 | - mask = 0xff >> -shift; | ||
486 | - else | ||
487 | - mask = (uint8_t)(0xff << shift); | ||
488 | - mask |= mask << 8; | ||
489 | - mask |= mask << 16; | ||
490 | - break; | ||
491 | - case 1: | ||
492 | - if (op == 4) | ||
493 | - mask = 0xffff >> -shift; | ||
494 | - else | ||
495 | - mask = (uint16_t)(0xffff << shift); | ||
496 | - mask |= mask << 16; | ||
497 | - break; | ||
498 | - case 2: | ||
499 | - if (shift < -31 || shift > 31) { | ||
500 | - mask = 0; | ||
501 | - } else { | ||
502 | - if (op == 4) | ||
503 | - mask = 0xffffffffu >> -shift; | ||
504 | - else | ||
505 | - mask = 0xffffffffu << shift; | ||
506 | - } | ||
507 | - break; | ||
508 | - default: | ||
509 | - abort(); | ||
510 | - } | ||
511 | - tmp2 = neon_load_reg(rd, pass); | ||
512 | - tcg_gen_andi_i32(tmp, tmp, mask); | ||
513 | - tcg_gen_andi_i32(tmp2, tmp2, ~mask); | ||
514 | - tcg_gen_or_i32(tmp, tmp, tmp2); | ||
515 | - tcg_temp_free_i32(tmp2); | ||
516 | } | ||
517 | neon_store_reg(rd, pass, tmp); | ||
518 | } | ||
519 | -- | 86 | -- |
520 | 2.19.1 | 87 | 2.20.1 |
521 | 88 | ||
522 | 89 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | Move expanders for VBSL, VBIT, and VBIF from translate-a64.c. | 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(). | ||
4 | 6 | ||
5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 7 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> |
6 | Message-id: 20181011205206.3552-9-richard.henderson@linaro.org | 8 | Message-id: 20190701132516.26392-16-philmd@redhat.com |
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | --- | 11 | --- |
10 | target/arm/translate.h | 6 ++ | 12 | target/arm/vfp_helper.c | 127 +++++++++++++++++++++------------------- |
11 | target/arm/translate-a64.c | 61 -------------- | 13 | 1 file changed, 66 insertions(+), 61 deletions(-) |
12 | target/arm/translate.c | 162 +++++++++++++++++++++++++++---------- | ||
13 | 3 files changed, 124 insertions(+), 105 deletions(-) | ||
14 | 14 | ||
15 | diff --git a/target/arm/translate.h b/target/arm/translate.h | 15 | diff --git a/target/arm/vfp_helper.c b/target/arm/vfp_helper.c |
16 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/translate.h | 17 | --- a/target/arm/vfp_helper.c |
18 | +++ b/target/arm/translate.h | 18 | +++ b/target/arm/vfp_helper.c |
19 | @@ -XXX,XX +XXX,XX @@ static inline TCGv_i32 get_ahp_flag(void) | 19 | @@ -XXX,XX +XXX,XX @@ static inline int vfp_exceptbits_to_host(int target_bits) |
20 | return ret; | 20 | return host_bits; |
21 | } | 21 | } |
22 | 22 | ||
23 | + | 23 | -uint32_t HELPER(vfp_get_fpscr)(CPUARMState *env) |
24 | +/* Vector operations shared between ARM and AArch64. */ | ||
25 | +extern const GVecGen3 bsl_op; | ||
26 | +extern const GVecGen3 bit_op; | ||
27 | +extern const GVecGen3 bif_op; | ||
28 | + | ||
29 | /* | ||
30 | * Forward to the isar_feature_* tests given a DisasContext pointer. | ||
31 | */ | ||
32 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
33 | index XXXXXXX..XXXXXXX 100644 | ||
34 | --- a/target/arm/translate-a64.c | ||
35 | +++ b/target/arm/translate-a64.c | ||
36 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_three_reg_diff(DisasContext *s, uint32_t insn) | ||
37 | } | ||
38 | } | ||
39 | |||
40 | -static void gen_bsl_i64(TCGv_i64 rd, TCGv_i64 rn, TCGv_i64 rm) | ||
41 | -{ | 24 | -{ |
42 | - tcg_gen_xor_i64(rn, rn, rm); | 25 | - uint32_t i, fpscr; |
43 | - tcg_gen_and_i64(rn, rn, rd); | 26 | - |
44 | - tcg_gen_xor_i64(rd, rm, rn); | 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; | ||
45 | -} | 42 | -} |
46 | - | 43 | - |
47 | -static void gen_bit_i64(TCGv_i64 rd, TCGv_i64 rn, TCGv_i64 rm) | 44 | -uint32_t vfp_get_fpscr(CPUARMState *env) |
48 | -{ | 45 | -{ |
49 | - tcg_gen_xor_i64(rn, rn, rd); | 46 | - return HELPER(vfp_get_fpscr)(env); |
50 | - tcg_gen_and_i64(rn, rn, rm); | ||
51 | - tcg_gen_xor_i64(rd, rd, rn); | ||
52 | -} | 47 | -} |
53 | - | 48 | - |
54 | -static void gen_bif_i64(TCGv_i64 rd, TCGv_i64 rn, TCGv_i64 rm) | 49 | -void HELPER(vfp_set_fpscr)(CPUARMState *env, uint32_t val) |
55 | -{ | 50 | +static void vfp_set_fpscr_to_host(CPUARMState *env, uint32_t val) |
56 | - tcg_gen_xor_i64(rn, rn, rd); | 51 | { |
57 | - tcg_gen_andc_i64(rn, rn, rm); | 52 | int i; |
58 | - tcg_gen_xor_i64(rd, rd, rn); | 53 | uint32_t changed = env->vfp.xregs[ARM_VFP_FPSCR]; |
59 | -} | 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 | - } | ||
60 | - | 59 | - |
61 | -static void gen_bsl_vec(unsigned vece, TCGv_vec rd, TCGv_vec rn, TCGv_vec rm) | 60 | - if (arm_feature(env, ARM_FEATURE_M)) { |
62 | -{ | 61 | - /* |
63 | - tcg_gen_xor_vec(vece, rn, rn, rm); | 62 | - * M profile FPSCR is RES0 for the QC, STRIDE, FZ16, LEN bits |
64 | - tcg_gen_and_vec(vece, rn, rn, rd); | 63 | - * and also for the trapped-exception-handling bits IxE. |
65 | - tcg_gen_xor_vec(vece, rd, rm, rn); | 64 | - */ |
66 | -} | 65 | - val &= 0xf7c0009f; |
66 | - } | ||
67 | - | 67 | - |
68 | -static void gen_bit_vec(unsigned vece, TCGv_vec rd, TCGv_vec rn, TCGv_vec rm) | 68 | - /* |
69 | -{ | 69 | - * We don't implement trapped exception handling, so the |
70 | - tcg_gen_xor_vec(vece, rn, rn, rd); | 70 | - * trap enable bits, IDE|IXE|UFE|OFE|DZE|IOE are all RAZ/WI (not RES0!) |
71 | - tcg_gen_and_vec(vece, rn, rn, rm); | 71 | - * |
72 | - tcg_gen_xor_vec(vece, rd, rd, rn); | 72 | - * If we exclude the exception flags, IOC|DZC|OFC|UFC|IXC|IDC |
73 | -} | 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; | ||
74 | - | 79 | - |
75 | -static void gen_bif_vec(unsigned vece, TCGv_vec rd, TCGv_vec rn, TCGv_vec rm) | 80 | - /* |
76 | -{ | 81 | - * The bit we set within fpscr_q is arbitrary; the register as a |
77 | - tcg_gen_xor_vec(vece, rn, rn, rd); | 82 | - * whole being zero/non-zero is what counts. |
78 | - tcg_gen_andc_vec(vece, rn, rn, rm); | 83 | - */ |
79 | - tcg_gen_xor_vec(vece, rd, rd, rn); | 84 | - env->vfp.qc[0] = val & FPCR_QC; |
80 | -} | 85 | - env->vfp.qc[1] = 0; |
86 | - env->vfp.qc[2] = 0; | ||
87 | - env->vfp.qc[3] = 0; | ||
81 | - | 88 | - |
82 | /* Logic op (opcode == 3) subgroup of C3.6.16. */ | 89 | changed ^= val; |
83 | static void disas_simd_3same_logic(DisasContext *s, uint32_t insn) | 90 | if (changed & (3 << 22)) { |
84 | { | 91 | i = (val >> 22) & 3; |
85 | - static const GVecGen3 bsl_op = { | 92 | @@ -XXX,XX +XXX,XX @@ void HELPER(vfp_set_fpscr)(CPUARMState *env, uint32_t val) |
86 | - .fni8 = gen_bsl_i64, | 93 | set_float_exception_flags(0, &env->vfp.standard_fp_status); |
87 | - .fniv = gen_bsl_vec, | ||
88 | - .prefer_i64 = TCG_TARGET_REG_BITS == 64, | ||
89 | - .load_dest = true | ||
90 | - }; | ||
91 | - static const GVecGen3 bit_op = { | ||
92 | - .fni8 = gen_bit_i64, | ||
93 | - .fniv = gen_bit_vec, | ||
94 | - .prefer_i64 = TCG_TARGET_REG_BITS == 64, | ||
95 | - .load_dest = true | ||
96 | - }; | ||
97 | - static const GVecGen3 bif_op = { | ||
98 | - .fni8 = gen_bif_i64, | ||
99 | - .fniv = gen_bif_vec, | ||
100 | - .prefer_i64 = TCG_TARGET_REG_BITS == 64, | ||
101 | - .load_dest = true | ||
102 | - }; | ||
103 | - | ||
104 | int rd = extract32(insn, 0, 5); | ||
105 | int rn = extract32(insn, 5, 5); | ||
106 | int rm = extract32(insn, 16, 5); | ||
107 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
108 | index XXXXXXX..XXXXXXX 100644 | ||
109 | --- a/target/arm/translate.c | ||
110 | +++ b/target/arm/translate.c | ||
111 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_ls_insn(DisasContext *s, uint32_t insn) | ||
112 | return 0; | ||
113 | } | 94 | } |
114 | 95 | ||
115 | -/* Bitwise select. dest = c ? t : f. Clobbers T and F. */ | 96 | +uint32_t HELPER(vfp_get_fpscr)(CPUARMState *env) |
116 | -static void gen_neon_bsl(TCGv_i32 dest, TCGv_i32 t, TCGv_i32 f, TCGv_i32 c) | ||
117 | -{ | ||
118 | - tcg_gen_and_i32(t, t, c); | ||
119 | - tcg_gen_andc_i32(f, f, c); | ||
120 | - tcg_gen_or_i32(dest, t, f); | ||
121 | -} | ||
122 | - | ||
123 | static inline void gen_neon_narrow(int size, TCGv_i32 dest, TCGv_i64 src) | ||
124 | { | ||
125 | switch (size) { | ||
126 | @@ -XXX,XX +XXX,XX @@ static int do_v81_helper(DisasContext *s, gen_helper_gvec_3_ptr *fn, | ||
127 | return 1; | ||
128 | } | ||
129 | |||
130 | +/* | ||
131 | + * Expanders for VBitOps_VBIF, VBIT, VBSL. | ||
132 | + */ | ||
133 | +static void gen_bsl_i64(TCGv_i64 rd, TCGv_i64 rn, TCGv_i64 rm) | ||
134 | +{ | 97 | +{ |
135 | + tcg_gen_xor_i64(rn, rn, rm); | 98 | + uint32_t i, fpscr; |
136 | + tcg_gen_and_i64(rn, rn, rd); | 99 | + |
137 | + tcg_gen_xor_i64(rd, rm, rn); | 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; | ||
138 | +} | 115 | +} |
139 | + | 116 | + |
140 | +static void gen_bit_i64(TCGv_i64 rd, TCGv_i64 rn, TCGv_i64 rm) | 117 | +uint32_t vfp_get_fpscr(CPUARMState *env) |
141 | +{ | 118 | +{ |
142 | + tcg_gen_xor_i64(rn, rn, rd); | 119 | + return HELPER(vfp_get_fpscr)(env); |
143 | + tcg_gen_and_i64(rn, rn, rm); | ||
144 | + tcg_gen_xor_i64(rd, rd, rn); | ||
145 | +} | 120 | +} |
146 | + | 121 | + |
147 | +static void gen_bif_i64(TCGv_i64 rd, TCGv_i64 rn, TCGv_i64 rm) | 122 | +void HELPER(vfp_set_fpscr)(CPUARMState *env, uint32_t val) |
148 | +{ | 123 | +{ |
149 | + tcg_gen_xor_i64(rn, rn, rd); | 124 | + /* When ARMv8.2-FP16 is not supported, FZ16 is RES0. */ |
150 | + tcg_gen_andc_i64(rn, rn, rm); | 125 | + if (!cpu_isar_feature(aa64_fp16, env_archcpu(env))) { |
151 | + tcg_gen_xor_i64(rd, rd, rn); | 126 | + val &= ~FPCR_FZ16; |
127 | + } | ||
128 | + | ||
129 | + if (arm_feature(env, ARM_FEATURE_M)) { | ||
130 | + /* | ||
131 | + * M profile FPSCR is RES0 for the QC, STRIDE, FZ16, LEN bits | ||
132 | + * and also for the trapped-exception-handling bits IxE. | ||
133 | + */ | ||
134 | + val &= 0xf7c0009f; | ||
135 | + } | ||
136 | + | ||
137 | + /* | ||
138 | + * We don't implement trapped exception handling, so the | ||
139 | + * trap enable bits, IDE|IXE|UFE|OFE|DZE|IOE are all RAZ/WI (not RES0!) | ||
140 | + * | ||
141 | + * If we exclude the exception flags, IOC|DZC|OFC|UFC|IXC|IDC | ||
142 | + * (which are stored in fp_status), and the other RES0 bits | ||
143 | + * in between, then we clear all of the low 16 bits. | ||
144 | + */ | ||
145 | + env->vfp.xregs[ARM_VFP_FPSCR] = val & 0xf7c80000; | ||
146 | + env->vfp.vec_len = (val >> 16) & 7; | ||
147 | + env->vfp.vec_stride = (val >> 20) & 3; | ||
148 | + | ||
149 | + /* | ||
150 | + * The bit we set within fpscr_q is arbitrary; the register as a | ||
151 | + * whole being zero/non-zero is what counts. | ||
152 | + */ | ||
153 | + env->vfp.qc[0] = val & FPCR_QC; | ||
154 | + env->vfp.qc[1] = 0; | ||
155 | + env->vfp.qc[2] = 0; | ||
156 | + env->vfp.qc[3] = 0; | ||
157 | + | ||
158 | + vfp_set_fpscr_to_host(env, val); | ||
152 | +} | 159 | +} |
153 | + | 160 | + |
154 | +static void gen_bsl_vec(unsigned vece, TCGv_vec rd, TCGv_vec rn, TCGv_vec rm) | 161 | void vfp_set_fpscr(CPUARMState *env, uint32_t val) |
155 | +{ | ||
156 | + tcg_gen_xor_vec(vece, rn, rn, rm); | ||
157 | + tcg_gen_and_vec(vece, rn, rn, rd); | ||
158 | + tcg_gen_xor_vec(vece, rd, rm, rn); | ||
159 | +} | ||
160 | + | ||
161 | +static void gen_bit_vec(unsigned vece, TCGv_vec rd, TCGv_vec rn, TCGv_vec rm) | ||
162 | +{ | ||
163 | + tcg_gen_xor_vec(vece, rn, rn, rd); | ||
164 | + tcg_gen_and_vec(vece, rn, rn, rm); | ||
165 | + tcg_gen_xor_vec(vece, rd, rd, rn); | ||
166 | +} | ||
167 | + | ||
168 | +static void gen_bif_vec(unsigned vece, TCGv_vec rd, TCGv_vec rn, TCGv_vec rm) | ||
169 | +{ | ||
170 | + tcg_gen_xor_vec(vece, rn, rn, rd); | ||
171 | + tcg_gen_andc_vec(vece, rn, rn, rm); | ||
172 | + tcg_gen_xor_vec(vece, rd, rd, rn); | ||
173 | +} | ||
174 | + | ||
175 | +const GVecGen3 bsl_op = { | ||
176 | + .fni8 = gen_bsl_i64, | ||
177 | + .fniv = gen_bsl_vec, | ||
178 | + .prefer_i64 = TCG_TARGET_REG_BITS == 64, | ||
179 | + .load_dest = true | ||
180 | +}; | ||
181 | + | ||
182 | +const GVecGen3 bit_op = { | ||
183 | + .fni8 = gen_bit_i64, | ||
184 | + .fniv = gen_bit_vec, | ||
185 | + .prefer_i64 = TCG_TARGET_REG_BITS == 64, | ||
186 | + .load_dest = true | ||
187 | +}; | ||
188 | + | ||
189 | +const GVecGen3 bif_op = { | ||
190 | + .fni8 = gen_bif_i64, | ||
191 | + .fniv = gen_bif_vec, | ||
192 | + .prefer_i64 = TCG_TARGET_REG_BITS == 64, | ||
193 | + .load_dest = true | ||
194 | +}; | ||
195 | + | ||
196 | + | ||
197 | /* Translate a NEON data processing instruction. Return nonzero if the | ||
198 | instruction is invalid. | ||
199 | We process data in a mixture of 32-bit and 64-bit chunks. | ||
200 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
201 | { | 162 | { |
202 | int op; | 163 | HELPER(vfp_set_fpscr)(env, val); |
203 | int q; | ||
204 | - int rd, rn, rm; | ||
205 | + int rd, rn, rm, rd_ofs, rn_ofs, rm_ofs; | ||
206 | int size; | ||
207 | int shift; | ||
208 | int pass; | ||
209 | int count; | ||
210 | int pairwise; | ||
211 | int u; | ||
212 | + int vec_size; | ||
213 | uint32_t imm, mask; | ||
214 | TCGv_i32 tmp, tmp2, tmp3, tmp4, tmp5; | ||
215 | TCGv_ptr ptr1, ptr2, ptr3; | ||
216 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
217 | VFP_DREG_N(rn, insn); | ||
218 | VFP_DREG_M(rm, insn); | ||
219 | size = (insn >> 20) & 3; | ||
220 | + vec_size = q ? 16 : 8; | ||
221 | + rd_ofs = neon_reg_offset(rd, 0); | ||
222 | + rn_ofs = neon_reg_offset(rn, 0); | ||
223 | + rm_ofs = neon_reg_offset(rm, 0); | ||
224 | + | ||
225 | if ((insn & (1 << 23)) == 0) { | ||
226 | /* Three register same length. */ | ||
227 | op = ((insn >> 7) & 0x1e) | ((insn >> 4) & 1); | ||
228 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
229 | q, rd, rn, rm); | ||
230 | } | ||
231 | return 1; | ||
232 | + | ||
233 | + case NEON_3R_LOGIC: /* Logic ops. */ | ||
234 | + switch ((u << 2) | size) { | ||
235 | + case 0: /* VAND */ | ||
236 | + tcg_gen_gvec_and(0, rd_ofs, rn_ofs, rm_ofs, | ||
237 | + vec_size, vec_size); | ||
238 | + break; | ||
239 | + case 1: /* VBIC */ | ||
240 | + tcg_gen_gvec_andc(0, rd_ofs, rn_ofs, rm_ofs, | ||
241 | + vec_size, vec_size); | ||
242 | + break; | ||
243 | + case 2: | ||
244 | + if (rn == rm) { | ||
245 | + /* VMOV */ | ||
246 | + tcg_gen_gvec_mov(0, rd_ofs, rn_ofs, vec_size, vec_size); | ||
247 | + } else { | ||
248 | + /* VORR */ | ||
249 | + tcg_gen_gvec_or(0, rd_ofs, rn_ofs, rm_ofs, | ||
250 | + vec_size, vec_size); | ||
251 | + } | ||
252 | + break; | ||
253 | + case 3: /* VORN */ | ||
254 | + tcg_gen_gvec_orc(0, rd_ofs, rn_ofs, rm_ofs, | ||
255 | + vec_size, vec_size); | ||
256 | + break; | ||
257 | + case 4: /* VEOR */ | ||
258 | + tcg_gen_gvec_xor(0, rd_ofs, rn_ofs, rm_ofs, | ||
259 | + vec_size, vec_size); | ||
260 | + break; | ||
261 | + case 5: /* VBSL */ | ||
262 | + tcg_gen_gvec_3(rd_ofs, rn_ofs, rm_ofs, | ||
263 | + vec_size, vec_size, &bsl_op); | ||
264 | + break; | ||
265 | + case 6: /* VBIT */ | ||
266 | + tcg_gen_gvec_3(rd_ofs, rn_ofs, rm_ofs, | ||
267 | + vec_size, vec_size, &bit_op); | ||
268 | + break; | ||
269 | + case 7: /* VBIF */ | ||
270 | + tcg_gen_gvec_3(rd_ofs, rn_ofs, rm_ofs, | ||
271 | + vec_size, vec_size, &bif_op); | ||
272 | + break; | ||
273 | + } | ||
274 | + return 0; | ||
275 | } | ||
276 | - if (size == 3 && op != NEON_3R_LOGIC) { | ||
277 | + if (size == 3) { | ||
278 | /* 64-bit element instructions. */ | ||
279 | for (pass = 0; pass < (q ? 2 : 1); pass++) { | ||
280 | neon_load_reg64(cpu_V0, rn + pass); | ||
281 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
282 | case NEON_3R_VRHADD: | ||
283 | GEN_NEON_INTEGER_OP(rhadd); | ||
284 | break; | ||
285 | - case NEON_3R_LOGIC: /* Logic ops. */ | ||
286 | - switch ((u << 2) | size) { | ||
287 | - case 0: /* VAND */ | ||
288 | - tcg_gen_and_i32(tmp, tmp, tmp2); | ||
289 | - break; | ||
290 | - case 1: /* BIC */ | ||
291 | - tcg_gen_andc_i32(tmp, tmp, tmp2); | ||
292 | - break; | ||
293 | - case 2: /* VORR */ | ||
294 | - tcg_gen_or_i32(tmp, tmp, tmp2); | ||
295 | - break; | ||
296 | - case 3: /* VORN */ | ||
297 | - tcg_gen_orc_i32(tmp, tmp, tmp2); | ||
298 | - break; | ||
299 | - case 4: /* VEOR */ | ||
300 | - tcg_gen_xor_i32(tmp, tmp, tmp2); | ||
301 | - break; | ||
302 | - case 5: /* VBSL */ | ||
303 | - tmp3 = neon_load_reg(rd, pass); | ||
304 | - gen_neon_bsl(tmp, tmp, tmp2, tmp3); | ||
305 | - tcg_temp_free_i32(tmp3); | ||
306 | - break; | ||
307 | - case 6: /* VBIT */ | ||
308 | - tmp3 = neon_load_reg(rd, pass); | ||
309 | - gen_neon_bsl(tmp, tmp, tmp3, tmp2); | ||
310 | - tcg_temp_free_i32(tmp3); | ||
311 | - break; | ||
312 | - case 7: /* VBIF */ | ||
313 | - tmp3 = neon_load_reg(rd, pass); | ||
314 | - gen_neon_bsl(tmp, tmp3, tmp, tmp2); | ||
315 | - tcg_temp_free_i32(tmp3); | ||
316 | - break; | ||
317 | - } | ||
318 | - break; | ||
319 | case NEON_3R_VHSUB: | ||
320 | GEN_NEON_INTEGER_OP(hsub); | ||
321 | break; | ||
322 | -- | 164 | -- |
323 | 2.19.1 | 165 | 2.20.1 |
324 | 166 | ||
325 | 167 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | Also introduces neon_element_offset to find the env offset | 3 | The vfp_set_fpscr() helper contains code specific to the host |
4 | of a specific element within a neon register. | 4 | floating point implementation (here the SoftFloat library). |
5 | Extract this code to vfp_set_fpscr_from_host(). | ||
5 | 6 | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 7 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> |
7 | Message-id: 20181011205206.3552-7-richard.henderson@linaro.org | 8 | Message-id: 20190701132516.26392-17-philmd@redhat.com |
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 11 | --- |
11 | target/arm/translate.c | 63 ++++++++++++++++++++++++------------------ | 12 | target/arm/vfp_helper.c | 19 +++++++++++++------ |
12 | 1 file changed, 36 insertions(+), 27 deletions(-) | 13 | 1 file changed, 13 insertions(+), 6 deletions(-) |
13 | 14 | ||
14 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 15 | diff --git a/target/arm/vfp_helper.c b/target/arm/vfp_helper.c |
15 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/translate.c | 17 | --- a/target/arm/vfp_helper.c |
17 | +++ b/target/arm/translate.c | 18 | +++ b/target/arm/vfp_helper.c |
18 | @@ -XXX,XX +XXX,XX @@ neon_reg_offset (int reg, int n) | 19 | @@ -XXX,XX +XXX,XX @@ static inline int vfp_exceptbits_to_host(int target_bits) |
19 | return vfp_reg_offset(0, sreg); | 20 | return host_bits; |
20 | } | 21 | } |
21 | 22 | ||
22 | +/* Return the offset of a 2**SIZE piece of a NEON register, at index ELE, | 23 | +static uint32_t vfp_get_fpscr_from_host(CPUARMState *env) |
23 | + * where 0 is the least significant end of the register. | ||
24 | + */ | ||
25 | +static inline long | ||
26 | +neon_element_offset(int reg, int element, TCGMemOp size) | ||
27 | +{ | 24 | +{ |
28 | + int element_size = 1 << size; | 25 | + uint32_t i; |
29 | + int ofs = element * element_size; | 26 | + |
30 | +#ifdef HOST_WORDS_BIGENDIAN | 27 | + i = get_float_exception_flags(&env->vfp.fp_status); |
31 | + /* Calculate the offset assuming fully little-endian, | 28 | + i |= get_float_exception_flags(&env->vfp.standard_fp_status); |
32 | + * then XOR to account for the order of the 8-byte units. | 29 | + /* FZ16 does not generate an input denormal exception. */ |
33 | + */ | 30 | + i |= (get_float_exception_flags(&env->vfp.fp_status_f16) |
34 | + if (element_size < 8) { | 31 | + & ~float_flag_input_denormal); |
35 | + ofs ^= 8 - element_size; | 32 | + return vfp_exceptbits_from_host(i); |
36 | + } | ||
37 | +#endif | ||
38 | + return neon_reg_offset(reg, 0) + ofs; | ||
39 | +} | 33 | +} |
40 | + | 34 | + |
41 | static TCGv_i32 neon_load_reg(int reg, int pass) | 35 | static void vfp_set_fpscr_to_host(CPUARMState *env, uint32_t val) |
42 | { | 36 | { |
43 | TCGv_i32 tmp = tcg_temp_new_i32(); | 37 | int i; |
44 | @@ -XXX,XX +XXX,XX @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) | 38 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(vfp_get_fpscr)(CPUARMState *env) |
45 | tmp = load_reg(s, rd); | 39 | | (env->vfp.vec_len << 16) |
46 | if (insn & (1 << 23)) { | 40 | | (env->vfp.vec_stride << 20); |
47 | /* VDUP */ | 41 | |
48 | - if (size == 0) { | 42 | - i = get_float_exception_flags(&env->vfp.fp_status); |
49 | - gen_neon_dup_u8(tmp, 0); | 43 | - i |= get_float_exception_flags(&env->vfp.standard_fp_status); |
50 | - } else if (size == 1) { | 44 | - /* FZ16 does not generate an input denormal exception. */ |
51 | - gen_neon_dup_low16(tmp); | 45 | - i |= (get_float_exception_flags(&env->vfp.fp_status_f16) |
52 | - } | 46 | - & ~float_flag_input_denormal); |
53 | - for (n = 0; n <= pass * 2; n++) { | 47 | - fpscr |= vfp_exceptbits_from_host(i); |
54 | - tmp2 = tcg_temp_new_i32(); | 48 | + fpscr |= vfp_get_fpscr_from_host(env); |
55 | - tcg_gen_mov_i32(tmp2, tmp); | 49 | |
56 | - neon_store_reg(rn, n, tmp2); | 50 | i = env->vfp.qc[0] | env->vfp.qc[1] | env->vfp.qc[2] | env->vfp.qc[3]; |
57 | - } | 51 | fpscr |= i ? FPCR_QC : 0; |
58 | - neon_store_reg(rn, n, tmp); | ||
59 | + int vec_size = pass ? 16 : 8; | ||
60 | + tcg_gen_gvec_dup_i32(size, neon_reg_offset(rn, 0), | ||
61 | + vec_size, vec_size, tmp); | ||
62 | + tcg_temp_free_i32(tmp); | ||
63 | } else { | ||
64 | /* VMOV */ | ||
65 | switch (size) { | ||
66 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
67 | tcg_temp_free_i32(tmp); | ||
68 | } else if ((insn & 0x380) == 0) { | ||
69 | /* VDUP */ | ||
70 | + int element; | ||
71 | + TCGMemOp size; | ||
72 | + | ||
73 | if ((insn & (7 << 16)) == 0 || (q && (rd & 1))) { | ||
74 | return 1; | ||
75 | } | ||
76 | - if (insn & (1 << 19)) { | ||
77 | - tmp = neon_load_reg(rm, 1); | ||
78 | - } else { | ||
79 | - tmp = neon_load_reg(rm, 0); | ||
80 | - } | ||
81 | if (insn & (1 << 16)) { | ||
82 | - gen_neon_dup_u8(tmp, ((insn >> 17) & 3) * 8); | ||
83 | + size = MO_8; | ||
84 | + element = (insn >> 17) & 7; | ||
85 | } else if (insn & (1 << 17)) { | ||
86 | - if ((insn >> 18) & 1) | ||
87 | - gen_neon_dup_high16(tmp); | ||
88 | - else | ||
89 | - gen_neon_dup_low16(tmp); | ||
90 | + size = MO_16; | ||
91 | + element = (insn >> 18) & 3; | ||
92 | + } else { | ||
93 | + size = MO_32; | ||
94 | + element = (insn >> 19) & 1; | ||
95 | } | ||
96 | - for (pass = 0; pass < (q ? 4 : 2); pass++) { | ||
97 | - tmp2 = tcg_temp_new_i32(); | ||
98 | - tcg_gen_mov_i32(tmp2, tmp); | ||
99 | - neon_store_reg(rd, pass, tmp2); | ||
100 | - } | ||
101 | - tcg_temp_free_i32(tmp); | ||
102 | + tcg_gen_gvec_dup_mem(size, neon_reg_offset(rd, 0), | ||
103 | + neon_element_offset(rm, element, size), | ||
104 | + q ? 16 : 8, q ? 16 : 8); | ||
105 | } else { | ||
106 | return 1; | ||
107 | } | ||
108 | -- | 52 | -- |
109 | 2.19.1 | 53 | 2.20.1 |
110 | 54 | ||
111 | 55 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | Move ssra_op and usra_op expanders from translate-a64.c. | 3 | This code is specific to the SoftFloat floating-point |
4 | implementation, which is only used by TCG. | ||
4 | 5 | ||
5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 6 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> |
6 | Message-id: 20181011205206.3552-14-richard.henderson@linaro.org | 7 | Message-id: 20190701132516.26392-18-philmd@redhat.com |
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | --- | 10 | --- |
10 | target/arm/translate.h | 2 + | 11 | target/arm/vfp_helper.c | 26 +++++++++++++++++++++++--- |
11 | target/arm/translate-a64.c | 106 ---------------------------- | 12 | 1 file changed, 23 insertions(+), 3 deletions(-) |
12 | target/arm/translate.c | 139 ++++++++++++++++++++++++++++++++++--- | ||
13 | 3 files changed, 130 insertions(+), 117 deletions(-) | ||
14 | 13 | ||
15 | diff --git a/target/arm/translate.h b/target/arm/translate.h | 14 | diff --git a/target/arm/vfp_helper.c b/target/arm/vfp_helper.c |
16 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/translate.h | 16 | --- a/target/arm/vfp_helper.c |
18 | +++ b/target/arm/translate.h | 17 | +++ b/target/arm/vfp_helper.c |
19 | @@ -XXX,XX +XXX,XX @@ static inline TCGv_i32 get_ahp_flag(void) | 18 | @@ -XXX,XX +XXX,XX @@ |
20 | extern const GVecGen3 bsl_op; | 19 | */ |
21 | extern const GVecGen3 bit_op; | 20 | |
22 | extern const GVecGen3 bif_op; | 21 | #include "qemu/osdep.h" |
23 | +extern const GVecGen2i ssra_op[4]; | 22 | -#include "qemu/log.h" |
24 | +extern const GVecGen2i usra_op[4]; | 23 | #include "cpu.h" |
25 | 24 | #include "exec/helper-proto.h" | |
26 | /* | 25 | -#include "fpu/softfloat.h" |
27 | * Forward to the isar_feature_* tests given a DisasContext pointer. | 26 | #include "internals.h" |
28 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 27 | - |
29 | index XXXXXXX..XXXXXXX 100644 | 28 | +#ifdef CONFIG_TCG |
30 | --- a/target/arm/translate-a64.c | 29 | +#include "qemu/log.h" |
31 | +++ b/target/arm/translate-a64.c | 30 | +#include "fpu/softfloat.h" |
32 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_scalar_two_reg_misc(DisasContext *s, uint32_t insn) | 31 | +#endif |
33 | } | 32 | |
33 | /* VFP support. We follow the convention used for VFP instructions: | ||
34 | Single precision routines have a "s" suffix, double precision a | ||
35 | "d" suffix. */ | ||
36 | |||
37 | +#ifdef CONFIG_TCG | ||
38 | + | ||
39 | /* Convert host exception flags to vfp form. */ | ||
40 | static inline int vfp_exceptbits_from_host(int host_bits) | ||
41 | { | ||
42 | @@ -XXX,XX +XXX,XX @@ static void vfp_set_fpscr_to_host(CPUARMState *env, uint32_t val) | ||
43 | set_float_exception_flags(0, &env->vfp.standard_fp_status); | ||
34 | } | 44 | } |
35 | 45 | ||
36 | -static void gen_ssra8_i64(TCGv_i64 d, TCGv_i64 a, int64_t shift) | 46 | +#else |
37 | -{ | 47 | + |
38 | - tcg_gen_vec_sar8i_i64(a, a, shift); | 48 | +static uint32_t vfp_get_fpscr_from_host(CPUARMState *env) |
39 | - tcg_gen_vec_add8_i64(d, d, a); | ||
40 | -} | ||
41 | - | ||
42 | -static void gen_ssra16_i64(TCGv_i64 d, TCGv_i64 a, int64_t shift) | ||
43 | -{ | ||
44 | - tcg_gen_vec_sar16i_i64(a, a, shift); | ||
45 | - tcg_gen_vec_add16_i64(d, d, a); | ||
46 | -} | ||
47 | - | ||
48 | -static void gen_ssra32_i32(TCGv_i32 d, TCGv_i32 a, int32_t shift) | ||
49 | -{ | ||
50 | - tcg_gen_sari_i32(a, a, shift); | ||
51 | - tcg_gen_add_i32(d, d, a); | ||
52 | -} | ||
53 | - | ||
54 | -static void gen_ssra64_i64(TCGv_i64 d, TCGv_i64 a, int64_t shift) | ||
55 | -{ | ||
56 | - tcg_gen_sari_i64(a, a, shift); | ||
57 | - tcg_gen_add_i64(d, d, a); | ||
58 | -} | ||
59 | - | ||
60 | -static void gen_ssra_vec(unsigned vece, TCGv_vec d, TCGv_vec a, int64_t sh) | ||
61 | -{ | ||
62 | - tcg_gen_sari_vec(vece, a, a, sh); | ||
63 | - tcg_gen_add_vec(vece, d, d, a); | ||
64 | -} | ||
65 | - | ||
66 | -static void gen_usra8_i64(TCGv_i64 d, TCGv_i64 a, int64_t shift) | ||
67 | -{ | ||
68 | - tcg_gen_vec_shr8i_i64(a, a, shift); | ||
69 | - tcg_gen_vec_add8_i64(d, d, a); | ||
70 | -} | ||
71 | - | ||
72 | -static void gen_usra16_i64(TCGv_i64 d, TCGv_i64 a, int64_t shift) | ||
73 | -{ | ||
74 | - tcg_gen_vec_shr16i_i64(a, a, shift); | ||
75 | - tcg_gen_vec_add16_i64(d, d, a); | ||
76 | -} | ||
77 | - | ||
78 | -static void gen_usra32_i32(TCGv_i32 d, TCGv_i32 a, int32_t shift) | ||
79 | -{ | ||
80 | - tcg_gen_shri_i32(a, a, shift); | ||
81 | - tcg_gen_add_i32(d, d, a); | ||
82 | -} | ||
83 | - | ||
84 | -static void gen_usra64_i64(TCGv_i64 d, TCGv_i64 a, int64_t shift) | ||
85 | -{ | ||
86 | - tcg_gen_shri_i64(a, a, shift); | ||
87 | - tcg_gen_add_i64(d, d, a); | ||
88 | -} | ||
89 | - | ||
90 | -static void gen_usra_vec(unsigned vece, TCGv_vec d, TCGv_vec a, int64_t sh) | ||
91 | -{ | ||
92 | - tcg_gen_shri_vec(vece, a, a, sh); | ||
93 | - tcg_gen_add_vec(vece, d, d, a); | ||
94 | -} | ||
95 | - | ||
96 | static void gen_shr8_ins_i64(TCGv_i64 d, TCGv_i64 a, int64_t shift) | ||
97 | { | ||
98 | uint64_t mask = dup_const(MO_8, 0xff >> shift); | ||
99 | @@ -XXX,XX +XXX,XX @@ static void gen_shr_ins_vec(unsigned vece, TCGv_vec d, TCGv_vec a, int64_t sh) | ||
100 | static void handle_vec_simd_shri(DisasContext *s, bool is_q, bool is_u, | ||
101 | int immh, int immb, int opcode, int rn, int rd) | ||
102 | { | ||
103 | - static const GVecGen2i ssra_op[4] = { | ||
104 | - { .fni8 = gen_ssra8_i64, | ||
105 | - .fniv = gen_ssra_vec, | ||
106 | - .load_dest = true, | ||
107 | - .opc = INDEX_op_sari_vec, | ||
108 | - .vece = MO_8 }, | ||
109 | - { .fni8 = gen_ssra16_i64, | ||
110 | - .fniv = gen_ssra_vec, | ||
111 | - .load_dest = true, | ||
112 | - .opc = INDEX_op_sari_vec, | ||
113 | - .vece = MO_16 }, | ||
114 | - { .fni4 = gen_ssra32_i32, | ||
115 | - .fniv = gen_ssra_vec, | ||
116 | - .load_dest = true, | ||
117 | - .opc = INDEX_op_sari_vec, | ||
118 | - .vece = MO_32 }, | ||
119 | - { .fni8 = gen_ssra64_i64, | ||
120 | - .fniv = gen_ssra_vec, | ||
121 | - .prefer_i64 = TCG_TARGET_REG_BITS == 64, | ||
122 | - .load_dest = true, | ||
123 | - .opc = INDEX_op_sari_vec, | ||
124 | - .vece = MO_64 }, | ||
125 | - }; | ||
126 | - static const GVecGen2i usra_op[4] = { | ||
127 | - { .fni8 = gen_usra8_i64, | ||
128 | - .fniv = gen_usra_vec, | ||
129 | - .load_dest = true, | ||
130 | - .opc = INDEX_op_shri_vec, | ||
131 | - .vece = MO_8, }, | ||
132 | - { .fni8 = gen_usra16_i64, | ||
133 | - .fniv = gen_usra_vec, | ||
134 | - .load_dest = true, | ||
135 | - .opc = INDEX_op_shri_vec, | ||
136 | - .vece = MO_16, }, | ||
137 | - { .fni4 = gen_usra32_i32, | ||
138 | - .fniv = gen_usra_vec, | ||
139 | - .load_dest = true, | ||
140 | - .opc = INDEX_op_shri_vec, | ||
141 | - .vece = MO_32, }, | ||
142 | - { .fni8 = gen_usra64_i64, | ||
143 | - .fniv = gen_usra_vec, | ||
144 | - .prefer_i64 = TCG_TARGET_REG_BITS == 64, | ||
145 | - .load_dest = true, | ||
146 | - .opc = INDEX_op_shri_vec, | ||
147 | - .vece = MO_64, }, | ||
148 | - }; | ||
149 | static const GVecGen2i sri_op[4] = { | ||
150 | { .fni8 = gen_shr8_ins_i64, | ||
151 | .fniv = gen_shr_ins_vec, | ||
152 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
153 | index XXXXXXX..XXXXXXX 100644 | ||
154 | --- a/target/arm/translate.c | ||
155 | +++ b/target/arm/translate.c | ||
156 | @@ -XXX,XX +XXX,XX @@ const GVecGen3 bif_op = { | ||
157 | .load_dest = true | ||
158 | }; | ||
159 | |||
160 | +static void gen_ssra8_i64(TCGv_i64 d, TCGv_i64 a, int64_t shift) | ||
161 | +{ | 49 | +{ |
162 | + tcg_gen_vec_sar8i_i64(a, a, shift); | 50 | + return 0; |
163 | + tcg_gen_vec_add8_i64(d, d, a); | ||
164 | +} | 51 | +} |
165 | + | 52 | + |
166 | +static void gen_ssra16_i64(TCGv_i64 d, TCGv_i64 a, int64_t shift) | 53 | +static void vfp_set_fpscr_to_host(CPUARMState *env, uint32_t val) |
167 | +{ | 54 | +{ |
168 | + tcg_gen_vec_sar16i_i64(a, a, shift); | ||
169 | + tcg_gen_vec_add16_i64(d, d, a); | ||
170 | +} | 55 | +} |
171 | + | 56 | + |
172 | +static void gen_ssra32_i32(TCGv_i32 d, TCGv_i32 a, int32_t shift) | 57 | +#endif |
173 | +{ | ||
174 | + tcg_gen_sari_i32(a, a, shift); | ||
175 | + tcg_gen_add_i32(d, d, a); | ||
176 | +} | ||
177 | + | 58 | + |
178 | +static void gen_ssra64_i64(TCGv_i64 d, TCGv_i64 a, int64_t shift) | 59 | uint32_t HELPER(vfp_get_fpscr)(CPUARMState *env) |
179 | +{ | 60 | { |
180 | + tcg_gen_sari_i64(a, a, shift); | 61 | uint32_t i, fpscr; |
181 | + tcg_gen_add_i64(d, d, a); | 62 | @@ -XXX,XX +XXX,XX @@ void vfp_set_fpscr(CPUARMState *env, uint32_t val) |
182 | +} | 63 | HELPER(vfp_set_fpscr)(env, val); |
64 | } | ||
65 | |||
66 | +#ifdef CONFIG_TCG | ||
183 | + | 67 | + |
184 | +static void gen_ssra_vec(unsigned vece, TCGv_vec d, TCGv_vec a, int64_t sh) | 68 | #define VFP_HELPER(name, p) HELPER(glue(glue(vfp_,name),p)) |
185 | +{ | 69 | |
186 | + tcg_gen_sari_vec(vece, a, a, sh); | 70 | #define VFP_BINOP(name) \ |
187 | + tcg_gen_add_vec(vece, d, d, a); | 71 | @@ -XXX,XX +XXX,XX @@ float64 HELPER(frint64_d)(float64 f, void *fpst) |
188 | +} | 72 | { |
73 | return frint_d(f, fpst, 64); | ||
74 | } | ||
189 | + | 75 | + |
190 | +const GVecGen2i ssra_op[4] = { | 76 | +#endif |
191 | + { .fni8 = gen_ssra8_i64, | ||
192 | + .fniv = gen_ssra_vec, | ||
193 | + .load_dest = true, | ||
194 | + .opc = INDEX_op_sari_vec, | ||
195 | + .vece = MO_8 }, | ||
196 | + { .fni8 = gen_ssra16_i64, | ||
197 | + .fniv = gen_ssra_vec, | ||
198 | + .load_dest = true, | ||
199 | + .opc = INDEX_op_sari_vec, | ||
200 | + .vece = MO_16 }, | ||
201 | + { .fni4 = gen_ssra32_i32, | ||
202 | + .fniv = gen_ssra_vec, | ||
203 | + .load_dest = true, | ||
204 | + .opc = INDEX_op_sari_vec, | ||
205 | + .vece = MO_32 }, | ||
206 | + { .fni8 = gen_ssra64_i64, | ||
207 | + .fniv = gen_ssra_vec, | ||
208 | + .prefer_i64 = TCG_TARGET_REG_BITS == 64, | ||
209 | + .load_dest = true, | ||
210 | + .opc = INDEX_op_sari_vec, | ||
211 | + .vece = MO_64 }, | ||
212 | +}; | ||
213 | + | ||
214 | +static void gen_usra8_i64(TCGv_i64 d, TCGv_i64 a, int64_t shift) | ||
215 | +{ | ||
216 | + tcg_gen_vec_shr8i_i64(a, a, shift); | ||
217 | + tcg_gen_vec_add8_i64(d, d, a); | ||
218 | +} | ||
219 | + | ||
220 | +static void gen_usra16_i64(TCGv_i64 d, TCGv_i64 a, int64_t shift) | ||
221 | +{ | ||
222 | + tcg_gen_vec_shr16i_i64(a, a, shift); | ||
223 | + tcg_gen_vec_add16_i64(d, d, a); | ||
224 | +} | ||
225 | + | ||
226 | +static void gen_usra32_i32(TCGv_i32 d, TCGv_i32 a, int32_t shift) | ||
227 | +{ | ||
228 | + tcg_gen_shri_i32(a, a, shift); | ||
229 | + tcg_gen_add_i32(d, d, a); | ||
230 | +} | ||
231 | + | ||
232 | +static void gen_usra64_i64(TCGv_i64 d, TCGv_i64 a, int64_t shift) | ||
233 | +{ | ||
234 | + tcg_gen_shri_i64(a, a, shift); | ||
235 | + tcg_gen_add_i64(d, d, a); | ||
236 | +} | ||
237 | + | ||
238 | +static void gen_usra_vec(unsigned vece, TCGv_vec d, TCGv_vec a, int64_t sh) | ||
239 | +{ | ||
240 | + tcg_gen_shri_vec(vece, a, a, sh); | ||
241 | + tcg_gen_add_vec(vece, d, d, a); | ||
242 | +} | ||
243 | + | ||
244 | +const GVecGen2i usra_op[4] = { | ||
245 | + { .fni8 = gen_usra8_i64, | ||
246 | + .fniv = gen_usra_vec, | ||
247 | + .load_dest = true, | ||
248 | + .opc = INDEX_op_shri_vec, | ||
249 | + .vece = MO_8, }, | ||
250 | + { .fni8 = gen_usra16_i64, | ||
251 | + .fniv = gen_usra_vec, | ||
252 | + .load_dest = true, | ||
253 | + .opc = INDEX_op_shri_vec, | ||
254 | + .vece = MO_16, }, | ||
255 | + { .fni4 = gen_usra32_i32, | ||
256 | + .fniv = gen_usra_vec, | ||
257 | + .load_dest = true, | ||
258 | + .opc = INDEX_op_shri_vec, | ||
259 | + .vece = MO_32, }, | ||
260 | + { .fni8 = gen_usra64_i64, | ||
261 | + .fniv = gen_usra_vec, | ||
262 | + .prefer_i64 = TCG_TARGET_REG_BITS == 64, | ||
263 | + .load_dest = true, | ||
264 | + .opc = INDEX_op_shri_vec, | ||
265 | + .vece = MO_64, }, | ||
266 | +}; | ||
267 | |||
268 | /* Translate a NEON data processing instruction. Return nonzero if the | ||
269 | instruction is invalid. | ||
270 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
271 | } | ||
272 | return 0; | ||
273 | |||
274 | + case 1: /* VSRA */ | ||
275 | + /* Right shift comes here negative. */ | ||
276 | + shift = -shift; | ||
277 | + /* Shifts larger than the element size are architecturally | ||
278 | + * valid. Unsigned results in all zeros; signed results | ||
279 | + * in all sign bits. | ||
280 | + */ | ||
281 | + if (!u) { | ||
282 | + tcg_gen_gvec_2i(rd_ofs, rm_ofs, vec_size, vec_size, | ||
283 | + MIN(shift, (8 << size) - 1), | ||
284 | + &ssra_op[size]); | ||
285 | + } else if (shift >= 8 << size) { | ||
286 | + /* rd += 0 */ | ||
287 | + } else { | ||
288 | + tcg_gen_gvec_2i(rd_ofs, rm_ofs, vec_size, vec_size, | ||
289 | + shift, &usra_op[size]); | ||
290 | + } | ||
291 | + return 0; | ||
292 | + | ||
293 | case 5: /* VSHL, VSLI */ | ||
294 | if (!u) { /* VSHL */ | ||
295 | /* Shifts larger than the element size are | ||
296 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
297 | neon_load_reg64(cpu_V0, rm + pass); | ||
298 | tcg_gen_movi_i64(cpu_V1, imm); | ||
299 | switch (op) { | ||
300 | - case 1: /* VSRA */ | ||
301 | - if (u) | ||
302 | - gen_helper_neon_shl_u64(cpu_V0, cpu_V0, cpu_V1); | ||
303 | - else | ||
304 | - gen_helper_neon_shl_s64(cpu_V0, cpu_V0, cpu_V1); | ||
305 | - break; | ||
306 | case 2: /* VRSHR */ | ||
307 | case 3: /* VRSRA */ | ||
308 | if (u) | ||
309 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
310 | default: | ||
311 | g_assert_not_reached(); | ||
312 | } | ||
313 | - if (op == 1 || op == 3) { | ||
314 | + if (op == 3) { | ||
315 | /* Accumulate. */ | ||
316 | neon_load_reg64(cpu_V1, rd + pass); | ||
317 | tcg_gen_add_i64(cpu_V0, cpu_V0, cpu_V1); | ||
318 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
319 | tmp2 = tcg_temp_new_i32(); | ||
320 | tcg_gen_movi_i32(tmp2, imm); | ||
321 | switch (op) { | ||
322 | - case 1: /* VSRA */ | ||
323 | - GEN_NEON_INTEGER_OP(shl); | ||
324 | - break; | ||
325 | case 2: /* VRSHR */ | ||
326 | case 3: /* VRSRA */ | ||
327 | GEN_NEON_INTEGER_OP(rshl); | ||
328 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
329 | } | ||
330 | tcg_temp_free_i32(tmp2); | ||
331 | |||
332 | - if (op == 1 || op == 3) { | ||
333 | + if (op == 3) { | ||
334 | /* Accumulate. */ | ||
335 | tmp2 = neon_load_reg(rd, pass); | ||
336 | gen_neon_add(size, tmp, tmp2); | ||
337 | -- | 77 | -- |
338 | 2.19.1 | 78 | 2.20.1 |
339 | 79 | ||
340 | 80 | diff view generated by jsdifflib |
1 | For traps of FP/SIMD instructions to AArch32 Hyp mode, the syndrome | 1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> |
---|---|---|---|
2 | provided in HSR has more information than is reported to AArch64. | ||
3 | Specifically, there are extra fields TA and coproc which indicate | ||
4 | whether the trapped instruction was FP or SIMD. Add this extra | ||
5 | information to the syndromes we construct, and mask it out when | ||
6 | taking the exception to AArch64. | ||
7 | 2 | ||
3 | Under KVM, the kernel gets the HVC call and handle the PSCI requests. | ||
4 | |||
5 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
6 | Message-id: 20190701132516.26392-20-philmd@redhat.com | ||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
10 | Message-id: 20181012144235.19646-11-peter.maydell@linaro.org | ||
11 | --- | 9 | --- |
12 | target/arm/internals.h | 14 +++++++++++++- | 10 | target/arm/internals.h | 6 +++++- |
13 | target/arm/helper.c | 9 +++++++++ | 11 | 1 file changed, 5 insertions(+), 1 deletion(-) |
14 | target/arm/translate.c | 8 ++++---- | ||
15 | 3 files changed, 26 insertions(+), 5 deletions(-) | ||
16 | 12 | ||
17 | diff --git a/target/arm/internals.h b/target/arm/internals.h | 13 | diff --git a/target/arm/internals.h b/target/arm/internals.h |
18 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/target/arm/internals.h | 15 | --- a/target/arm/internals.h |
20 | +++ b/target/arm/internals.h | 16 | +++ b/target/arm/internals.h |
21 | @@ -XXX,XX +XXX,XX @@ static inline uint32_t syn_get_ec(uint32_t syn) | 17 | @@ -XXX,XX +XXX,XX @@ vaddr arm_adjust_watchpoint_address(CPUState *cs, vaddr addr, int len); |
22 | * few cases the value in HSR for exceptions taken to AArch32 Hyp | 18 | /* Callback function for when a watchpoint or breakpoint triggers. */ |
23 | * mode differs slightly, and we fix this up when populating HSR in | 19 | void arm_debug_excp_handler(CPUState *cs); |
24 | * arm_cpu_do_interrupt_aarch32_hyp(). | 20 | |
25 | + * The exception is FP/SIMD access traps -- these report extra information | 21 | -#ifdef CONFIG_USER_ONLY |
26 | + * when taking an exception to AArch32. For those we include the extra coproc | 22 | +#if defined(CONFIG_USER_ONLY) || !defined(CONFIG_TCG) |
27 | + * and TA fields, and mask them out when taking the exception to AArch64. | 23 | static inline bool arm_is_psci_call(ARMCPU *cpu, int excp_type) |
28 | */ | ||
29 | static inline uint32_t syn_uncategorized(void) | ||
30 | { | 24 | { |
31 | @@ -XXX,XX +XXX,XX @@ static inline uint32_t syn_cp15_rrt_trap(int cv, int cond, int opc1, int crm, | 25 | return false; |
32 | 26 | } | |
33 | static inline uint32_t syn_fp_access_trap(int cv, int cond, bool is_16bit) | 27 | +static inline void arm_handle_psci_call(ARMCPU *cpu) |
34 | { | 28 | +{ |
35 | + /* AArch32 FP trap or any AArch64 FP/SIMD trap: TA == 0 coproc == 0xa */ | 29 | + g_assert_not_reached(); |
36 | return (EC_ADVSIMDFPACCESSTRAP << ARM_EL_EC_SHIFT) | ||
37 | | (is_16bit ? 0 : ARM_EL_IL) | ||
38 | - | (cv << 24) | (cond << 20); | ||
39 | + | (cv << 24) | (cond << 20) | 0xa; | ||
40 | +} | 30 | +} |
41 | + | 31 | #else |
42 | +static inline uint32_t syn_simd_access_trap(int cv, int cond, bool is_16bit) | 32 | /* Return true if the r0/x0 value indicates that this SMC/HVC is a PSCI call. */ |
43 | +{ | 33 | bool arm_is_psci_call(ARMCPU *cpu, int excp_type); |
44 | + /* AArch32 SIMD trap: TA == 1 coproc == 0 */ | ||
45 | + return (EC_ADVSIMDFPACCESSTRAP << ARM_EL_EC_SHIFT) | ||
46 | + | (is_16bit ? 0 : ARM_EL_IL) | ||
47 | + | (cv << 24) | (cond << 20) | (1 << 5); | ||
48 | } | ||
49 | |||
50 | static inline uint32_t syn_sve_access_trap(void) | ||
51 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
52 | index XXXXXXX..XXXXXXX 100644 | ||
53 | --- a/target/arm/helper.c | ||
54 | +++ b/target/arm/helper.c | ||
55 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_do_interrupt_aarch64(CPUState *cs) | ||
56 | case EXCP_HVC: | ||
57 | case EXCP_HYP_TRAP: | ||
58 | case EXCP_SMC: | ||
59 | + if (syn_get_ec(env->exception.syndrome) == EC_ADVSIMDFPACCESSTRAP) { | ||
60 | + /* | ||
61 | + * QEMU internal FP/SIMD syndromes from AArch32 include the | ||
62 | + * TA and coproc fields which are only exposed if the exception | ||
63 | + * is taken to AArch32 Hyp mode. Mask them out to get a valid | ||
64 | + * AArch64 format syndrome. | ||
65 | + */ | ||
66 | + env->exception.syndrome &= ~MAKE_64BIT_MASK(0, 20); | ||
67 | + } | ||
68 | env->cp15.esr_el[new_el] = env->exception.syndrome; | ||
69 | break; | ||
70 | case EXCP_IRQ: | ||
71 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
72 | index XXXXXXX..XXXXXXX 100644 | ||
73 | --- a/target/arm/translate.c | ||
74 | +++ b/target/arm/translate.c | ||
75 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_ls_insn(DisasContext *s, uint32_t insn) | ||
76 | */ | ||
77 | if (s->fp_excp_el) { | ||
78 | gen_exception_insn(s, 4, EXCP_UDEF, | ||
79 | - syn_fp_access_trap(1, 0xe, false), s->fp_excp_el); | ||
80 | + syn_simd_access_trap(1, 0xe, false), s->fp_excp_el); | ||
81 | return 0; | ||
82 | } | ||
83 | |||
84 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
85 | */ | ||
86 | if (s->fp_excp_el) { | ||
87 | gen_exception_insn(s, 4, EXCP_UDEF, | ||
88 | - syn_fp_access_trap(1, 0xe, false), s->fp_excp_el); | ||
89 | + syn_simd_access_trap(1, 0xe, false), s->fp_excp_el); | ||
90 | return 0; | ||
91 | } | ||
92 | |||
93 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_insn_3same_ext(DisasContext *s, uint32_t insn) | ||
94 | |||
95 | if (s->fp_excp_el) { | ||
96 | gen_exception_insn(s, 4, EXCP_UDEF, | ||
97 | - syn_fp_access_trap(1, 0xe, false), s->fp_excp_el); | ||
98 | + syn_simd_access_trap(1, 0xe, false), s->fp_excp_el); | ||
99 | return 0; | ||
100 | } | ||
101 | if (!s->vfp_enabled) { | ||
102 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_insn_2reg_scalar_ext(DisasContext *s, uint32_t insn) | ||
103 | |||
104 | if (s->fp_excp_el) { | ||
105 | gen_exception_insn(s, 4, EXCP_UDEF, | ||
106 | - syn_fp_access_trap(1, 0xe, false), s->fp_excp_el); | ||
107 | + syn_simd_access_trap(1, 0xe, false), s->fp_excp_el); | ||
108 | return 0; | ||
109 | } | ||
110 | if (!s->vfp_enabled) { | ||
111 | -- | 34 | -- |
112 | 2.19.1 | 35 | 2.20.1 |
113 | 36 | ||
114 | 37 | diff view generated by jsdifflib |
1 | For the v7 version of the Arm architecture, the IL bit in | 1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> |
---|---|---|---|
2 | syndrome register values where the field is not valid was | ||
3 | defined to be UNK/SBZP. In v8 this is RES1, which is what | ||
4 | QEMU currently implements. Handle the desired v7 behaviour | ||
5 | by squashing the IL bit for the affected cases: | ||
6 | * EC == EC_UNCATEGORIZED | ||
7 | * prefetch aborts | ||
8 | * data aborts where ISV is 0 | ||
9 | 2 | ||
10 | (The fourth case listed in the v8 Arm ARM DDI 0487C.a in | 3 | In few commits we will split the M-profile functions from this |
11 | section G7.2.70, "illegal state exception", can't happen | 4 | file, and this function will also be called in the new file. |
12 | on a v7 CPU.) | 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. | ||
13 | 8 | ||
14 | This deals with a corner case noted in a comment. | 9 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> |
15 | 10 | Message-id: 20190701132516.26392-21-philmd@redhat.com | |
11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
17 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
18 | Message-id: 20181012144235.19646-10-peter.maydell@linaro.org | ||
19 | --- | 13 | --- |
20 | target/arm/internals.h | 7 ++----- | 14 | target/arm/internals.h | 2 ++ |
21 | target/arm/helper.c | 13 +++++++++++++ | 15 | target/arm/helper.c | 76 +++++++++++++++++++++--------------------- |
22 | 2 files changed, 15 insertions(+), 5 deletions(-) | 16 | 2 files changed, 40 insertions(+), 38 deletions(-) |
23 | 17 | ||
24 | diff --git a/target/arm/internals.h b/target/arm/internals.h | 18 | diff --git a/target/arm/internals.h b/target/arm/internals.h |
25 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
26 | --- a/target/arm/internals.h | 20 | --- a/target/arm/internals.h |
27 | +++ b/target/arm/internals.h | 21 | +++ b/target/arm/internals.h |
28 | @@ -XXX,XX +XXX,XX @@ static inline uint32_t syn_get_ec(uint32_t syn) | 22 | @@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address, |
29 | /* Utility functions for constructing various kinds of syndrome value. | 23 | target_ulong *page_size, |
30 | * Note that in general we follow the AArch64 syndrome values; in a | 24 | ARMMMUFaultInfo *fi, ARMCacheAttrs *cacheattrs); |
31 | * few cases the value in HSR for exceptions taken to AArch32 Hyp | 25 | |
32 | - * mode differs slightly, so if we ever implemented Hyp mode then the | 26 | +void arm_log_exception(int idx); |
33 | - * syndrome value would need some massaging on exception entry. | 27 | + |
34 | - * (One example of this is that AArch64 defaults to IL bit set for | 28 | #endif /* !CONFIG_USER_ONLY */ |
35 | - * exceptions which don't specifically indicate information about the | 29 | |
36 | - * trapping instruction, whereas AArch32 defaults to IL bit clear.) | 30 | #endif |
37 | + * mode differs slightly, and we fix this up when populating HSR in | ||
38 | + * arm_cpu_do_interrupt_aarch32_hyp(). | ||
39 | */ | ||
40 | static inline uint32_t syn_uncategorized(void) | ||
41 | { | ||
42 | 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 |
43 | index XXXXXXX..XXXXXXX 100644 | 32 | index XXXXXXX..XXXXXXX 100644 |
44 | --- a/target/arm/helper.c | 33 | --- a/target/arm/helper.c |
45 | +++ b/target/arm/helper.c | 34 | +++ b/target/arm/helper.c |
46 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_do_interrupt_aarch32_hyp(CPUState *cs) | 35 | @@ -XXX,XX +XXX,XX @@ uint32_t arm_phys_excp_target_el(CPUState *cs, uint32_t excp_idx, |
47 | } | 36 | return target_el; |
48 | 37 | } | |
49 | if (cs->exception_index != EXCP_IRQ && cs->exception_index != EXCP_FIQ) { | 38 | |
50 | + if (!arm_feature(env, ARM_FEATURE_V8)) { | 39 | +void arm_log_exception(int idx) |
51 | + /* | 40 | +{ |
52 | + * QEMU syndrome values are v8-style. v7 has the IL bit | 41 | + if (qemu_loglevel_mask(CPU_LOG_INT)) { |
53 | + * UNK/SBZP for "field not valid" cases, where v8 uses RES1. | 42 | + const char *exc = NULL; |
54 | + * If this is a v7 CPU, squash the IL bit in those cases. | 43 | + static const char * const excnames[] = { |
55 | + */ | 44 | + [EXCP_UDEF] = "Undefined Instruction", |
56 | + if (cs->exception_index == EXCP_PREFETCH_ABORT || | 45 | + [EXCP_SWI] = "SVC", |
57 | + (cs->exception_index == EXCP_DATA_ABORT && | 46 | + [EXCP_PREFETCH_ABORT] = "Prefetch Abort", |
58 | + !(env->exception.syndrome & ARM_EL_ISV)) || | 47 | + [EXCP_DATA_ABORT] = "Data Abort", |
59 | + syn_get_ec(env->exception.syndrome) == EC_UNCATEGORIZED) { | 48 | + [EXCP_IRQ] = "IRQ", |
60 | + env->exception.syndrome &= ~ARM_EL_IL; | 49 | + [EXCP_FIQ] = "FIQ", |
61 | + } | 50 | + [EXCP_BKPT] = "Breakpoint", |
51 | + [EXCP_EXCEPTION_EXIT] = "QEMU v7M exception exit", | ||
52 | + [EXCP_KERNEL_TRAP] = "QEMU intercept of kernel commpage", | ||
53 | + [EXCP_HVC] = "Hypervisor Call", | ||
54 | + [EXCP_HYP_TRAP] = "Hypervisor Trap", | ||
55 | + [EXCP_SMC] = "Secure Monitor Call", | ||
56 | + [EXCP_VIRQ] = "Virtual IRQ", | ||
57 | + [EXCP_VFIQ] = "Virtual FIQ", | ||
58 | + [EXCP_SEMIHOST] = "Semihosting call", | ||
59 | + [EXCP_NOCP] = "v7M NOCP UsageFault", | ||
60 | + [EXCP_INVSTATE] = "v7M INVSTATE UsageFault", | ||
61 | + [EXCP_STKOF] = "v8M STKOF UsageFault", | ||
62 | + [EXCP_LAZYFP] = "v7M exception during lazy FP stacking", | ||
63 | + [EXCP_LSERR] = "v8M LSERR UsageFault", | ||
64 | + [EXCP_UNALIGNED] = "v7M UNALIGNED UsageFault", | ||
65 | + }; | ||
66 | + | ||
67 | + if (idx >= 0 && idx < ARRAY_SIZE(excnames)) { | ||
68 | + exc = excnames[idx]; | ||
62 | + } | 69 | + } |
63 | env->cp15.esr_el[2] = env->exception.syndrome; | 70 | + if (!exc) { |
64 | } | 71 | + exc = "unknown"; |
65 | 72 | + } | |
73 | + qemu_log_mask(CPU_LOG_INT, "Taking exception %d [%s]\n", idx, exc); | ||
74 | + } | ||
75 | +} | ||
76 | + | ||
77 | /* | ||
78 | * Return true if the v7M CPACR permits access to the FPU for the specified | ||
79 | * security state and privilege level. | ||
80 | @@ -XXX,XX +XXX,XX @@ static bool do_v7m_function_return(ARMCPU *cpu) | ||
81 | return true; | ||
82 | } | ||
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) | ||
124 | { | ||
66 | -- | 125 | -- |
67 | 2.19.1 | 126 | 2.20.1 |
68 | 127 | ||
69 | 128 | diff view generated by jsdifflib |
1 | For AArch32, exception return happens through certain kinds | 1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> |
---|---|---|---|
2 | of CPSR write. We don't currently have any CPU_LOG_INT logging | ||
3 | of these events (unlike AArch64, where we log in the ERET | ||
4 | instruction). Add some suitable logging. | ||
5 | 2 | ||
6 | This will log exception returns like this: | 3 | In the next commit we will split the M-profile functions from this |
7 | Exception return from AArch32 hyp to usr PC 0x80100374 | 4 | file. Some function will be called out of helper.c. Declare them in |
5 | the "internals.h" header. | ||
8 | 6 | ||
9 | paralleling the existing logging in the exception_return | 7 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> |
10 | helper for AArch64 exception returns: | 8 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> |
11 | Exception return from AArch64 EL2 to AArch64 EL0 PC 0x8003045c | 9 | Message-id: 20190701132516.26392-22-philmd@redhat.com |
12 | Exception return from AArch64 EL2 to AArch32 EL0 PC 0x8003045c | ||
13 | |||
14 | (Note that an AArch32 exception return can only be | ||
15 | AArch32->AArch32, never to AArch64.) | ||
16 | |||
17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
18 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
19 | Message-id: 20181012144235.19646-2-peter.maydell@linaro.org | ||
20 | --- | 11 | --- |
21 | target/arm/internals.h | 18 ++++++++++++++++++ | 12 | target/arm/internals.h | 42 ++++++++++++++++++++++++++++++++++++++++++ |
22 | target/arm/helper.c | 10 ++++++++++ | 13 | target/arm/helper.c | 38 ++------------------------------------ |
23 | target/arm/translate.c | 7 +------ | 14 | 2 files changed, 44 insertions(+), 36 deletions(-) |
24 | 3 files changed, 29 insertions(+), 6 deletions(-) | ||
25 | 15 | ||
26 | diff --git a/target/arm/internals.h b/target/arm/internals.h | 16 | diff --git a/target/arm/internals.h b/target/arm/internals.h |
27 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
28 | --- a/target/arm/internals.h | 18 | --- a/target/arm/internals.h |
29 | +++ b/target/arm/internals.h | 19 | +++ b/target/arm/internals.h |
30 | @@ -XXX,XX +XXX,XX @@ static inline uint32_t v7m_sp_limit(CPUARMState *env) | 20 | @@ -XXX,XX +XXX,XX @@ static inline uint32_t v7m_sp_limit(CPUARMState *env) |
31 | } | 21 | } |
32 | } | 22 | } |
33 | 23 | ||
34 | +/** | 24 | +/** |
35 | + * aarch32_mode_name(): Return name of the AArch32 CPU mode | 25 | + * v7m_cpacr_pass: |
36 | + * @psr: Program Status Register indicating CPU mode | 26 | + * Return true if the v7M CPACR permits access to the FPU for the specified |
37 | + * | 27 | + * security state and privilege level. |
38 | + * Returns, for debug logging purposes, a printable representation | ||
39 | + * of the AArch32 CPU mode ("svc", "usr", etc) as indicated by | ||
40 | + * the low bits of the specified PSR. | ||
41 | + */ | 28 | + */ |
42 | +static inline const char *aarch32_mode_name(uint32_t psr) | 29 | +static inline bool v7m_cpacr_pass(CPUARMState *env, |
30 | + bool is_secure, bool is_priv) | ||
43 | +{ | 31 | +{ |
44 | + static const char cpu_mode_names[16][4] = { | 32 | + switch (extract32(env->v7m.cpacr[is_secure], 20, 2)) { |
45 | + "usr", "fiq", "irq", "svc", "???", "???", "mon", "abt", | 33 | + case 0: |
46 | + "???", "???", "hyp", "und", "???", "???", "???", "sys" | 34 | + case 2: /* UNPREDICTABLE: we treat like 0 */ |
47 | + }; | 35 | + return false; |
48 | + | 36 | + case 1: |
49 | + return cpu_mode_names[psr & 0xf]; | 37 | + return is_priv; |
38 | + case 3: | ||
39 | + return true; | ||
40 | + default: | ||
41 | + g_assert_not_reached(); | ||
42 | + } | ||
50 | +} | 43 | +} |
51 | + | 44 | + |
52 | #endif | 45 | /** |
46 | * aarch32_mode_name(): Return name of the AArch32 CPU mode | ||
47 | * @psr: Program Status Register indicating CPU mode | ||
48 | @@ -XXX,XX +XXX,XX @@ static inline int exception_target_el(CPUARMState *env) | ||
49 | |||
50 | #ifndef CONFIG_USER_ONLY | ||
51 | |||
52 | +/* Security attributes for an address, as returned by v8m_security_lookup. */ | ||
53 | +typedef struct V8M_SAttributes { | ||
54 | + bool subpage; /* true if these attrs don't cover the whole TARGET_PAGE */ | ||
55 | + bool ns; | ||
56 | + bool nsc; | ||
57 | + uint8_t sregion; | ||
58 | + bool srvalid; | ||
59 | + uint8_t iregion; | ||
60 | + bool irvalid; | ||
61 | +} V8M_SAttributes; | ||
62 | + | ||
63 | +void v8m_security_lookup(CPUARMState *env, uint32_t address, | ||
64 | + MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
65 | + V8M_SAttributes *sattrs); | ||
66 | + | ||
67 | +bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address, | ||
68 | + MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
69 | + hwaddr *phys_ptr, MemTxAttrs *txattrs, | ||
70 | + int *prot, bool *is_subpage, | ||
71 | + ARMMMUFaultInfo *fi, uint32_t *mregion); | ||
72 | + | ||
73 | /* Cacheability and shareability attributes for a memory access */ | ||
74 | typedef struct ARMCacheAttrs { | ||
75 | unsigned int attrs:8; /* as in the MAIR register encoding */ | ||
53 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 76 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
54 | index XXXXXXX..XXXXXXX 100644 | 77 | index XXXXXXX..XXXXXXX 100644 |
55 | --- a/target/arm/helper.c | 78 | --- a/target/arm/helper.c |
56 | +++ b/target/arm/helper.c | 79 | +++ b/target/arm/helper.c |
57 | @@ -XXX,XX +XXX,XX @@ void cpsr_write(CPUARMState *env, uint32_t val, uint32_t mask, | 80 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, target_ulong address, |
58 | mask |= CPSR_IL; | 81 | hwaddr *phys_ptr, MemTxAttrs *txattrs, int *prot, |
59 | val |= CPSR_IL; | 82 | target_ulong *page_size_ptr, |
60 | } | 83 | ARMMMUFaultInfo *fi, ARMCacheAttrs *cacheattrs); |
61 | + qemu_log_mask(LOG_GUEST_ERROR, | 84 | - |
62 | + "Illegal AArch32 mode switch attempt from %s to %s\n", | 85 | -/* Security attributes for an address, as returned by v8m_security_lookup. */ |
63 | + aarch32_mode_name(env->uncached_cpsr), | 86 | -typedef struct V8M_SAttributes { |
64 | + aarch32_mode_name(val)); | 87 | - bool subpage; /* true if these attrs don't cover the whole TARGET_PAGE */ |
65 | } else { | 88 | - bool ns; |
66 | + qemu_log_mask(CPU_LOG_INT, "%s %s to %s PC 0x%" PRIx32 "\n", | 89 | - bool nsc; |
67 | + write_type == CPSRWriteExceptionReturn ? | 90 | - uint8_t sregion; |
68 | + "Exception return from AArch32" : | 91 | - bool srvalid; |
69 | + "AArch32 mode switch from", | 92 | - uint8_t iregion; |
70 | + aarch32_mode_name(env->uncached_cpsr), | 93 | - bool irvalid; |
71 | + aarch32_mode_name(val), env->regs[15]); | 94 | -} V8M_SAttributes; |
72 | switch_mode(env, val & CPSR_M); | 95 | - |
73 | } | 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) | ||
74 | } | 103 | } |
75 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
76 | index XXXXXXX..XXXXXXX 100644 | ||
77 | --- a/target/arm/translate.c | ||
78 | +++ b/target/arm/translate.c | ||
79 | @@ -XXX,XX +XXX,XX @@ void gen_intermediate_code(CPUState *cpu, TranslationBlock *tb) | ||
80 | translator_loop(ops, &dc.base, cpu, tb); | ||
81 | } | 104 | } |
82 | 105 | ||
83 | -static const char *cpu_mode_names[16] = { | 106 | -/* |
84 | - "usr", "fiq", "irq", "svc", "???", "???", "mon", "abt", | 107 | - * Return true if the v7M CPACR permits access to the FPU for the specified |
85 | - "???", "???", "hyp", "und", "???", "???", "???", "sys" | 108 | - * security state and privilege level. |
86 | -}; | 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 | -} | ||
87 | - | 124 | - |
88 | void arm_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprintf, | 125 | /* |
89 | int flags) | 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) | ||
90 | { | 136 | { |
91 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprintf, | 137 | @@ -XXX,XX +XXX,XX @@ static void v8m_security_lookup(CPUARMState *env, uint32_t address, |
92 | psr & CPSR_V ? 'V' : '-', | ||
93 | psr & CPSR_T ? 'T' : 'A', | ||
94 | ns_status, | ||
95 | - cpu_mode_names[psr & 0xf], (psr & 0x10) ? 32 : 26); | ||
96 | + aarch32_mode_name(psr), (psr & 0x10) ? 32 : 26); | ||
97 | } | 138 | } |
98 | 139 | } | |
99 | if (flags & CPU_DUMP_FPU) { | 140 | |
141 | -static bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address, | ||
142 | +bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address, | ||
143 | MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
144 | hwaddr *phys_ptr, MemTxAttrs *txattrs, | ||
145 | int *prot, bool *is_subpage, | ||
100 | -- | 146 | -- |
101 | 2.19.1 | 147 | 2.20.1 |
102 | 148 | ||
103 | 149 | diff view generated by jsdifflib |