1 | As promised, another pullreq... This one's mostly RTH's patches. | 1 | The following changes since commit 7e7eb9f852a46b51a71ae9d82590b2e4d28827ee: |
---|---|---|---|
2 | 2 | ||
3 | thanks | 3 | Merge remote-tracking branch 'remotes/armbru/tags/pull-qapi-2021-01-28' into staging (2021-01-28 22:43:18 +0000) |
4 | -- PMM | ||
5 | |||
6 | The following changes since commit 784c2e4f232adf5ef47a84a262ec72a07d068d6a: | ||
7 | |||
8 | Merge remote-tracking branch 'remotes/jasowang/tags/net-pull-request' into staging (2018-10-19 15:30:40 +0100) | ||
9 | 4 | ||
10 | are available in the Git repository at: | 5 | are available in the Git repository at: |
11 | 6 | ||
12 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20181019 | 7 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20210129 |
13 | 8 | ||
14 | for you to fetch changes up to 88c9add25e7120e8622796c81ad3f3fb7f8d40e7: | 9 | for you to fetch changes up to 11749122e1a86866591306d43603d2795a3dea1a: |
15 | 10 | ||
16 | target/arm: Only flush tlb if ASID changes (2018-10-19 17:38:48 +0100) | 11 | hw/arm/stellaris: Remove board-creation reset of STELLARIS_SYS (2021-01-29 10:47:29 +0000) |
17 | 12 | ||
18 | ---------------------------------------------------------------- | 13 | ---------------------------------------------------------------- |
19 | target-arm queue: | 14 | target-arm queue: |
20 | * ssi-sd: Make devices picking up backends unavailable with -device | 15 | * Implement ID_PFR2 |
21 | * Add support for VCPU event states | 16 | * Conditionalize DBGDIDR |
22 | * Move towards making ID registers the source of truth for | 17 | * rename xlnx-zcu102.canbusN properties |
23 | whether a guest CPU implements a feature, rather than having | 18 | * provide powerdown/reset mechanism for secure firmware on 'virt' board |
24 | parallel ID registers and feature bit flags | 19 | * hw/misc: Fix arith overflow in NPCM7XX PWM module |
25 | * Implement various HCR hypervisor trap/config bits | 20 | * target/arm: Replace magic value by MMU_DATA_LOAD definition |
26 | * Get IL bit correct for v7 syndrome values | 21 | * configure: fix preadv errors on Catalina macOS with new XCode |
27 | * Report correct syndrome for FP/SIMD traps to Hyp mode | 22 | * Various configure and other cleanups in preparation for iOS support |
28 | * hw/arm/boot: Increase compliance with kernel arm64 boot protocol | 23 | * hvf: Add hypervisor entitlement to output binaries (needed for Big Sur) |
29 | * Refactor A32 Neon to use generic vector infrastructure | 24 | * Implement pvpanic-pci device |
30 | * Fix a bug in A32 VLD2 "(multiple 2-element structures)" insn | 25 | * Convert the CMSDK timer devices to the Clock framework |
31 | * net: cadence_gem: Report features correctly in ID register | ||
32 | * Avoid some unnecessary TLB flushes on TTBR register writes | ||
33 | 26 | ||
34 | ---------------------------------------------------------------- | 27 | ---------------------------------------------------------------- |
35 | Dongjiu Geng (1): | 28 | Alexander Graf (1): |
36 | target/arm: Add support for VCPU event states | 29 | hvf: Add hypervisor entitlement to output binaries |
37 | 30 | ||
38 | Edgar E. Iglesias (2): | 31 | Hao Wu (1): |
39 | net: cadence_gem: Announce availability of priority queues | 32 | hw/misc: Fix arith overflow in NPCM7XX PWM module |
40 | net: cadence_gem: Announce 64bit addressing support | ||
41 | 33 | ||
42 | Markus Armbruster (1): | 34 | Joelle van Dyne (7): |
43 | ssi-sd: Make devices picking up backends unavailable with -device | 35 | configure: cross-compiling with empty cross_prefix |
36 | osdep: build with non-working system() function | ||
37 | darwin: remove redundant dependency declaration | ||
38 | darwin: fix cross-compiling for Darwin | ||
39 | configure: cross compile should use x86_64 cpu_family | ||
40 | darwin: detect CoreAudio for build | ||
41 | darwin: remove 64-bit build detection on 32-bit OS | ||
44 | 42 | ||
45 | Peter Maydell (10): | 43 | Maxim Uvarov (3): |
46 | target/arm: Improve debug logging of AArch32 exception return | 44 | hw: gpio: implement gpio-pwr driver for qemu reset/poweroff |
47 | target/arm: Make switch_mode() file-local | 45 | arm-virt: refactor gpios creation |
48 | target/arm: Implement HCR.FB | 46 | arm-virt: add secure pl061 for reset/power down |
49 | target/arm: Implement HCR.DC | ||
50 | target/arm: ISR_EL1 bits track virtual interrupts if IMO/FMO set | ||
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 | 47 | ||
57 | Richard Henderson (30): | 48 | Mihai Carabas (4): |
58 | target/arm: Move some system registers into a substructure | 49 | hw/misc/pvpanic: split-out generic and bus dependent code |
59 | target/arm: V8M should not imply V7VE | 50 | hw/misc/pvpanic: add PCI interface support |
60 | target/arm: Convert v8 extensions from feature bits to isar tests | 51 | pvpanic : update pvpanic spec document |
61 | target/arm: Convert division from feature bits to isar0 tests | 52 | tests/qtest: add a test case for pvpanic-pci |
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 | 53 | ||
89 | Stewart Hildebrand (1): | 54 | Paolo Bonzini (1): |
90 | hw/arm/boot: Increase compliance with kernel arm64 boot protocol | 55 | arm: rename xlnx-zcu102.canbusN properties |
91 | 56 | ||
92 | target/arm/cpu.h | 227 ++++++- | 57 | Peter Maydell (26): |
93 | target/arm/internals.h | 45 +- | 58 | configure: Move preadv check to meson.build |
94 | target/arm/kvm_arm.h | 24 + | 59 | ptimer: Add new ptimer_set_period_from_clock() function |
95 | target/arm/translate.h | 21 + | 60 | clock: Add new clock_has_source() function |
96 | hw/arm/boot.c | 18 + | 61 | tests: Add a simple test of the CMSDK APB timer |
97 | hw/intc/armv7m_nvic.c | 12 +- | 62 | tests: Add a simple test of the CMSDK APB watchdog |
98 | hw/net/cadence_gem.c | 9 +- | 63 | tests: Add a simple test of the CMSDK APB dual timer |
99 | hw/sd/ssi-sd.c | 2 + | 64 | hw/timer/cmsdk-apb-timer: Rename CMSDKAPBTIMER struct to CMSDKAPBTimer |
100 | linux-user/aarch64/signal.c | 4 +- | 65 | hw/timer/cmsdk-apb-timer: Add Clock input |
101 | linux-user/elfload.c | 60 +- | 66 | hw/timer/cmsdk-apb-dualtimer: Add Clock input |
102 | linux-user/syscall.c | 10 +- | 67 | hw/watchdog/cmsdk-apb-watchdog: Add Clock input |
103 | target/arm/cpu.c | 242 ++++---- | 68 | hw/arm/armsse: Rename "MAINCLK" property to "MAINCLK_FRQ" |
104 | target/arm/cpu64.c | 148 +++-- | 69 | hw/arm/armsse: Wire up clocks |
105 | target/arm/helper.c | 397 ++++++++---- | 70 | hw/arm/mps2: Inline CMSDK_APB_TIMER creation |
106 | target/arm/kvm.c | 60 ++ | 71 | hw/arm/mps2: Create and connect SYSCLK Clock |
107 | target/arm/kvm32.c | 13 + | 72 | hw/arm/mps2-tz: Create and connect ARMSSE Clocks |
108 | target/arm/kvm64.c | 15 +- | 73 | hw/arm/musca: Create and connect ARMSSE Clocks |
109 | target/arm/machine.c | 28 +- | 74 | hw/arm/stellaris: Convert SSYS to QOM device |
110 | target/arm/op_helper.c | 2 +- | 75 | hw/arm/stellaris: Create Clock input for watchdog |
111 | target/arm/translate-a64.c | 715 ++++----------------- | 76 | hw/timer/cmsdk-apb-timer: Convert to use Clock input |
112 | target/arm/translate.c | 1451 ++++++++++++++++++++++++++++--------------- | 77 | hw/timer/cmsdk-apb-dualtimer: Convert to use Clock input |
113 | 21 files changed, 2021 insertions(+), 1482 deletions(-) | 78 | hw/watchdog/cmsdk-apb-watchdog: Convert to use Clock input |
79 | tests/qtest/cmsdk-apb-watchdog-test: Test clock changes | ||
80 | hw/arm/armsse: Use Clock to set system_clock_scale | ||
81 | arm: Don't set freq properties on CMSDK timer, dualtimer, watchdog, ARMSSE | ||
82 | arm: Remove frq properties on CMSDK timer, dualtimer, watchdog, ARMSSE | ||
83 | hw/arm/stellaris: Remove board-creation reset of STELLARIS_SYS | ||
114 | 84 | ||
85 | Philippe Mathieu-Daudé (1): | ||
86 | target/arm: Replace magic value by MMU_DATA_LOAD definition | ||
87 | |||
88 | Richard Henderson (2): | ||
89 | target/arm: Implement ID_PFR2 | ||
90 | target/arm: Conditionalize DBGDIDR | ||
91 | |||
92 | docs/devel/clocks.rst | 16 +++ | ||
93 | docs/specs/pci-ids.txt | 1 + | ||
94 | docs/specs/pvpanic.txt | 13 ++- | ||
95 | docs/system/arm/virt.rst | 2 + | ||
96 | configure | 78 ++++++++------ | ||
97 | meson.build | 34 ++++++- | ||
98 | include/hw/arm/armsse.h | 14 ++- | ||
99 | include/hw/arm/virt.h | 2 + | ||
100 | include/hw/clock.h | 15 +++ | ||
101 | include/hw/misc/pvpanic.h | 24 ++++- | ||
102 | include/hw/pci/pci.h | 1 + | ||
103 | include/hw/ptimer.h | 22 ++++ | ||
104 | include/hw/timer/cmsdk-apb-dualtimer.h | 5 +- | ||
105 | include/hw/timer/cmsdk-apb-timer.h | 34 ++----- | ||
106 | include/hw/watchdog/cmsdk-apb-watchdog.h | 5 +- | ||
107 | include/qemu/osdep.h | 12 +++ | ||
108 | include/qemu/typedefs.h | 1 + | ||
109 | target/arm/cpu.h | 1 + | ||
110 | hw/arm/armsse.c | 48 ++++++--- | ||
111 | hw/arm/mps2-tz.c | 14 ++- | ||
112 | hw/arm/mps2.c | 28 ++++- | ||
113 | hw/arm/musca.c | 13 ++- | ||
114 | hw/arm/stellaris.c | 170 +++++++++++++++++++++++-------- | ||
115 | hw/arm/virt.c | 111 ++++++++++++++++---- | ||
116 | hw/arm/xlnx-zcu102.c | 4 +- | ||
117 | hw/core/ptimer.c | 34 +++++++ | ||
118 | hw/gpio/gpio_pwr.c | 70 +++++++++++++ | ||
119 | hw/misc/npcm7xx_pwm.c | 23 ++++- | ||
120 | hw/misc/pvpanic-isa.c | 94 +++++++++++++++++ | ||
121 | hw/misc/pvpanic-pci.c | 94 +++++++++++++++++ | ||
122 | hw/misc/pvpanic.c | 85 ++-------------- | ||
123 | hw/timer/cmsdk-apb-dualtimer.c | 53 +++++++--- | ||
124 | hw/timer/cmsdk-apb-timer.c | 55 +++++----- | ||
125 | hw/watchdog/cmsdk-apb-watchdog.c | 29 ++++-- | ||
126 | target/arm/helper.c | 27 +++-- | ||
127 | target/arm/kvm64.c | 2 + | ||
128 | tests/qtest/cmsdk-apb-dualtimer-test.c | 130 +++++++++++++++++++++++ | ||
129 | tests/qtest/cmsdk-apb-timer-test.c | 75 ++++++++++++++ | ||
130 | tests/qtest/cmsdk-apb-watchdog-test.c | 131 ++++++++++++++++++++++++ | ||
131 | tests/qtest/npcm7xx_pwm-test.c | 4 +- | ||
132 | tests/qtest/pvpanic-pci-test.c | 94 +++++++++++++++++ | ||
133 | tests/qtest/xlnx-can-test.c | 30 +++--- | ||
134 | MAINTAINERS | 3 + | ||
135 | accel/hvf/entitlements.plist | 8 ++ | ||
136 | hw/arm/Kconfig | 1 + | ||
137 | hw/gpio/Kconfig | 3 + | ||
138 | hw/gpio/meson.build | 1 + | ||
139 | hw/i386/Kconfig | 2 +- | ||
140 | hw/misc/Kconfig | 12 ++- | ||
141 | hw/misc/meson.build | 4 +- | ||
142 | scripts/entitlement.sh | 13 +++ | ||
143 | tests/qtest/meson.build | 6 +- | ||
144 | 52 files changed, 1432 insertions(+), 319 deletions(-) | ||
145 | create mode 100644 hw/gpio/gpio_pwr.c | ||
146 | create mode 100644 hw/misc/pvpanic-isa.c | ||
147 | create mode 100644 hw/misc/pvpanic-pci.c | ||
148 | create mode 100644 tests/qtest/cmsdk-apb-dualtimer-test.c | ||
149 | create mode 100644 tests/qtest/cmsdk-apb-timer-test.c | ||
150 | create mode 100644 tests/qtest/cmsdk-apb-watchdog-test.c | ||
151 | create mode 100644 tests/qtest/pvpanic-pci-test.c | ||
152 | create mode 100644 accel/hvf/entitlements.plist | ||
153 | create mode 100755 scripts/entitlement.sh | ||
154 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 3 | This was defined at some point before ARMv8.4, and will |
4 | shortly be used by new processor descriptions. | ||
5 | |||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
5 | Message-id: 20181016223115.24100-7-richard.henderson@linaro.org | 8 | Message-id: 20210120204400.1056582-1-richard.henderson@linaro.org |
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | --- | 10 | --- |
9 | target/arm/cpu.h | 6 +++++- | 11 | target/arm/cpu.h | 1 + |
10 | linux-user/elfload.c | 2 +- | 12 | target/arm/helper.c | 4 ++-- |
11 | target/arm/cpu.c | 4 ---- | 13 | target/arm/kvm64.c | 2 ++ |
12 | target/arm/helper.c | 2 +- | 14 | 3 files changed, 5 insertions(+), 2 deletions(-) |
13 | target/arm/machine.c | 3 +-- | ||
14 | 5 files changed, 8 insertions(+), 9 deletions(-) | ||
15 | 15 | ||
16 | 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 |
17 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/target/arm/cpu.h | 18 | --- a/target/arm/cpu.h |
19 | +++ b/target/arm/cpu.h | 19 | +++ b/target/arm/cpu.h |
20 | @@ -XXX,XX +XXX,XX @@ enum arm_features { | 20 | @@ -XXX,XX +XXX,XX @@ struct ARMCPU { |
21 | ARM_FEATURE_NEON, | 21 | uint32_t id_mmfr4; |
22 | ARM_FEATURE_M, /* Microcontroller profile. */ | 22 | uint32_t id_pfr0; |
23 | ARM_FEATURE_OMAPCP, /* OMAP specific CP15 ops handling. */ | 23 | uint32_t id_pfr1; |
24 | - ARM_FEATURE_THUMB2EE, | 24 | + uint32_t id_pfr2; |
25 | ARM_FEATURE_V7MP, /* v7 Multiprocessing Extensions */ | 25 | uint32_t mvfr0; |
26 | ARM_FEATURE_V7VE, /* v7 Virtualization Extensions (non-EL2 parts) */ | 26 | uint32_t mvfr1; |
27 | ARM_FEATURE_V4T, | 27 | uint32_t mvfr2; |
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 | } | ||
31 | |||
32 | +static inline bool isar_feature_t32ee(const ARMISARegisters *id) | ||
33 | +{ | ||
34 | + return FIELD_EX32(id->id_isar3, ID_ISAR3, T32EE) != 0; | ||
35 | +} | ||
36 | + | ||
37 | static inline bool isar_feature_aa32_aes(const ARMISARegisters *id) | ||
38 | { | ||
39 | return FIELD_EX32(id->id_isar5, ID_ISAR5, AES) != 0; | ||
40 | diff --git a/linux-user/elfload.c b/linux-user/elfload.c | ||
41 | index XXXXXXX..XXXXXXX 100644 | ||
42 | --- a/linux-user/elfload.c | ||
43 | +++ b/linux-user/elfload.c | ||
44 | @@ -XXX,XX +XXX,XX @@ static uint32_t get_elf_hwcap(void) | ||
45 | GET_FEATURE(ARM_FEATURE_V5, ARM_HWCAP_ARM_EDSP); | ||
46 | GET_FEATURE(ARM_FEATURE_VFP, ARM_HWCAP_ARM_VFP); | ||
47 | GET_FEATURE(ARM_FEATURE_IWMMXT, ARM_HWCAP_ARM_IWMMXT); | ||
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 | 28 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
90 | index XXXXXXX..XXXXXXX 100644 | 29 | index XXXXXXX..XXXXXXX 100644 |
91 | --- a/target/arm/helper.c | 30 | --- a/target/arm/helper.c |
92 | +++ b/target/arm/helper.c | 31 | +++ b/target/arm/helper.c |
93 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | 32 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) |
94 | define_arm_cp_regs(cpu, vmsa_pmsa_cp_reginfo); | 33 | .access = PL1_R, .type = ARM_CP_CONST, |
95 | define_arm_cp_regs(cpu, vmsa_cp_reginfo); | 34 | .accessfn = access_aa64_tid3, |
96 | } | 35 | .resetvalue = 0 }, |
97 | - if (arm_feature(env, ARM_FEATURE_THUMB2EE)) { | 36 | - { .name = "MVFR4_EL1_RESERVED", .state = ARM_CP_STATE_AA64, |
98 | + if (cpu_isar_feature(t32ee, cpu)) { | 37 | + { .name = "ID_PFR2", .state = ARM_CP_STATE_BOTH, |
99 | define_arm_cp_regs(cpu, t2ee_cp_reginfo); | 38 | .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 3, .opc2 = 4, |
100 | } | 39 | .access = PL1_R, .type = ARM_CP_CONST, |
101 | if (arm_feature(env, ARM_FEATURE_GENERIC_TIMER)) { | 40 | .accessfn = access_aa64_tid3, |
102 | diff --git a/target/arm/machine.c b/target/arm/machine.c | 41 | - .resetvalue = 0 }, |
42 | + .resetvalue = cpu->isar.id_pfr2 }, | ||
43 | { .name = "MVFR5_EL1_RESERVED", .state = ARM_CP_STATE_AA64, | ||
44 | .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 3, .opc2 = 5, | ||
45 | .access = PL1_R, .type = ARM_CP_CONST, | ||
46 | diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c | ||
103 | index XXXXXXX..XXXXXXX 100644 | 47 | index XXXXXXX..XXXXXXX 100644 |
104 | --- a/target/arm/machine.c | 48 | --- a/target/arm/kvm64.c |
105 | +++ b/target/arm/machine.c | 49 | +++ b/target/arm/kvm64.c |
106 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_m = { | 50 | @@ -XXX,XX +XXX,XX @@ bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf) |
107 | static bool thumb2ee_needed(void *opaque) | 51 | ARM64_SYS_REG(3, 0, 0, 1, 0)); |
108 | { | 52 | err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_pfr1, |
109 | ARMCPU *cpu = opaque; | 53 | ARM64_SYS_REG(3, 0, 0, 1, 1)); |
110 | - CPUARMState *env = &cpu->env; | 54 | + err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_pfr2, |
111 | 55 | + ARM64_SYS_REG(3, 0, 0, 3, 4)); | |
112 | - return arm_feature(env, ARM_FEATURE_THUMB2EE); | 56 | err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_dfr0, |
113 | + return cpu_isar_feature(t32ee, cpu); | 57 | ARM64_SYS_REG(3, 0, 0, 1, 2)); |
114 | } | 58 | err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_mmfr0, |
115 | |||
116 | static const VMStateDescription vmstate_thumb2ee = { | ||
117 | -- | 59 | -- |
118 | 2.19.1 | 60 | 2.20.1 |
119 | 61 | ||
120 | 62 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Since QEMU does not implement ASIDs, changes to the ASID must flush the | 3 | Only define the register if it exists for the cpu. |
4 | tlb. However, if the ASID does not change there is no reason to flush. | ||
5 | 4 | ||
6 | In testing a boot of the Ubuntu installer to the first menu, this reduces | ||
7 | the number of flushes by 30%, or nearly 600k instances. | ||
8 | |||
9 | Reviewed-by: Aaron Lindsay <aaron@os.amperecomputing.com> | ||
10 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
6 | Message-id: 20210120031656.737646-1-richard.henderson@linaro.org | ||
11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
12 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
13 | Message-id: 20181019015617.22583-3-richard.henderson@linaro.org | ||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
15 | --- | 9 | --- |
16 | target/arm/helper.c | 8 +++----- | 10 | target/arm/helper.c | 21 +++++++++++++++------ |
17 | 1 file changed, 3 insertions(+), 5 deletions(-) | 11 | 1 file changed, 15 insertions(+), 6 deletions(-) |
18 | 12 | ||
19 | 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 |
20 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/target/arm/helper.c | 15 | --- a/target/arm/helper.c |
22 | +++ b/target/arm/helper.c | 16 | +++ b/target/arm/helper.c |
23 | @@ -XXX,XX +XXX,XX @@ static void vmsa_tcr_el1_write(CPUARMState *env, const ARMCPRegInfo *ri, | 17 | @@ -XXX,XX +XXX,XX @@ static void define_debug_regs(ARMCPU *cpu) |
24 | static void vmsa_ttbr_write(CPUARMState *env, const ARMCPRegInfo *ri, | 18 | */ |
25 | uint64_t value) | 19 | int i; |
26 | { | 20 | int wrps, brps, ctx_cmps; |
27 | - /* 64 bit accesses to the TTBRs can change the ASID and so we | 21 | - ARMCPRegInfo dbgdidr = { |
28 | - * must flush the TLB. | 22 | - .name = "DBGDIDR", .cp = 14, .crn = 0, .crm = 0, .opc1 = 0, .opc2 = 0, |
29 | - */ | 23 | - .access = PL0_R, .accessfn = access_tda, |
30 | - if (cpreg_field_is_64bit(ri)) { | 24 | - .type = ARM_CP_CONST, .resetvalue = cpu->isar.dbgdidr, |
31 | + /* If the ASID changes (with a 64-bit write), we must flush the TLB. */ | 25 | - }; |
32 | + if (cpreg_field_is_64bit(ri) && | 26 | + |
33 | + extract64(raw_read(env, ri) ^ value, 48, 16) != 0) { | 27 | + /* |
34 | ARMCPU *cpu = arm_env_get_cpu(env); | 28 | + * The Arm ARM says DBGDIDR is optional and deprecated if EL1 cannot |
35 | - | 29 | + * use AArch32. Given that bit 15 is RES1, if the value is 0 then |
36 | tlb_flush(CPU(cpu)); | 30 | + * the register must not exist for this cpu. |
37 | } | 31 | + */ |
38 | raw_write(env, ri, value); | 32 | + if (cpu->isar.dbgdidr != 0) { |
33 | + ARMCPRegInfo dbgdidr = { | ||
34 | + .name = "DBGDIDR", .cp = 14, .crn = 0, .crm = 0, | ||
35 | + .opc1 = 0, .opc2 = 0, | ||
36 | + .access = PL0_R, .accessfn = access_tda, | ||
37 | + .type = ARM_CP_CONST, .resetvalue = cpu->isar.dbgdidr, | ||
38 | + }; | ||
39 | + define_one_arm_cp_reg(cpu, &dbgdidr); | ||
40 | + } | ||
41 | |||
42 | /* Note that all these register fields hold "number of Xs minus 1". */ | ||
43 | brps = arm_num_brps(cpu); | ||
44 | @@ -XXX,XX +XXX,XX @@ static void define_debug_regs(ARMCPU *cpu) | ||
45 | |||
46 | assert(ctx_cmps <= brps); | ||
47 | |||
48 | - define_one_arm_cp_reg(cpu, &dbgdidr); | ||
49 | define_arm_cp_regs(cpu, debug_cp_reginfo); | ||
50 | |||
51 | if (arm_feature(&cpu->env, ARM_FEATURE_LPAE)) { | ||
39 | -- | 52 | -- |
40 | 2.19.1 | 53 | 2.20.1 |
41 | 54 | ||
42 | 55 | diff view generated by jsdifflib |
1 | From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com> | 1 | From: Paolo Bonzini <pbonzini@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | Announce 64bit addressing support. | 3 | The properties to attach a CANBUS object to the xlnx-zcu102 machine have |
4 | a period in them. We want to use periods in properties for compound QAPI types, | ||
5 | and besides the "xlnx-zcu102." prefix is both unnecessary and different | ||
6 | from any other machine property name. Remove it. | ||
4 | 7 | ||
5 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | 8 | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> |
6 | Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> | 9 | Message-id: 20210118162537.779542-1-pbonzini@redhat.com |
7 | Message-id: 20181017213932.19973-3-edgar.iglesias@gmail.com | 10 | Reviewed-by: Vikram Garhwal <fnu.vikram@xilinx.com> |
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 12 | --- |
11 | hw/net/cadence_gem.c | 3 ++- | 13 | hw/arm/xlnx-zcu102.c | 4 ++-- |
12 | 1 file changed, 2 insertions(+), 1 deletion(-) | 14 | tests/qtest/xlnx-can-test.c | 30 +++++++++++++++--------------- |
15 | 2 files changed, 17 insertions(+), 17 deletions(-) | ||
13 | 16 | ||
14 | diff --git a/hw/net/cadence_gem.c b/hw/net/cadence_gem.c | 17 | diff --git a/hw/arm/xlnx-zcu102.c b/hw/arm/xlnx-zcu102.c |
15 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/hw/net/cadence_gem.c | 19 | --- a/hw/arm/xlnx-zcu102.c |
17 | +++ b/hw/net/cadence_gem.c | 20 | +++ b/hw/arm/xlnx-zcu102.c |
18 | @@ -XXX,XX +XXX,XX @@ | 21 | @@ -XXX,XX +XXX,XX @@ static void xlnx_zcu102_machine_instance_init(Object *obj) |
19 | #define GEM_DESCONF4 (0x0000028C/4) | 22 | s->secure = false; |
20 | #define GEM_DESCONF5 (0x00000290/4) | 23 | /* Default to virt (EL2) being disabled */ |
21 | #define GEM_DESCONF6 (0x00000294/4) | 24 | s->virt = false; |
22 | +#define GEM_DESCONF6_64B_MASK (1U << 23) | 25 | - object_property_add_link(obj, "xlnx-zcu102.canbus0", TYPE_CAN_BUS, |
23 | #define GEM_DESCONF7 (0x00000298/4) | 26 | + object_property_add_link(obj, "canbus0", TYPE_CAN_BUS, |
24 | 27 | (Object **)&s->canbus[0], | |
25 | #define GEM_INT_Q1_STATUS (0x00000400 / 4) | 28 | object_property_allow_set_link, |
26 | @@ -XXX,XX +XXX,XX @@ static void gem_reset(DeviceState *d) | 29 | 0); |
27 | s->regs[GEM_DESCONF] = 0x02500111; | 30 | |
28 | s->regs[GEM_DESCONF2] = 0x2ab13fff; | 31 | - object_property_add_link(obj, "xlnx-zcu102.canbus1", TYPE_CAN_BUS, |
29 | s->regs[GEM_DESCONF5] = 0x002f2045; | 32 | + object_property_add_link(obj, "canbus1", TYPE_CAN_BUS, |
30 | - s->regs[GEM_DESCONF6] = 0x0; | 33 | (Object **)&s->canbus[1], |
31 | + s->regs[GEM_DESCONF6] = GEM_DESCONF6_64B_MASK; | 34 | object_property_allow_set_link, |
32 | 35 | 0); | |
33 | if (s->num_priority_queues > 1) { | 36 | diff --git a/tests/qtest/xlnx-can-test.c b/tests/qtest/xlnx-can-test.c |
34 | queues_mask = MAKE_64BIT_MASK(1, s->num_priority_queues - 1); | 37 | index XXXXXXX..XXXXXXX 100644 |
38 | --- a/tests/qtest/xlnx-can-test.c | ||
39 | +++ b/tests/qtest/xlnx-can-test.c | ||
40 | @@ -XXX,XX +XXX,XX @@ static void test_can_bus(void) | ||
41 | uint8_t can_timestamp = 1; | ||
42 | |||
43 | QTestState *qts = qtest_init("-machine xlnx-zcu102" | ||
44 | - " -object can-bus,id=canbus0" | ||
45 | - " -machine xlnx-zcu102.canbus0=canbus0" | ||
46 | - " -machine xlnx-zcu102.canbus1=canbus0" | ||
47 | + " -object can-bus,id=canbus" | ||
48 | + " -machine canbus0=canbus" | ||
49 | + " -machine canbus1=canbus" | ||
50 | ); | ||
51 | |||
52 | /* Configure the CAN0 and CAN1. */ | ||
53 | @@ -XXX,XX +XXX,XX @@ static void test_can_loopback(void) | ||
54 | uint32_t status = 0; | ||
55 | |||
56 | QTestState *qts = qtest_init("-machine xlnx-zcu102" | ||
57 | - " -object can-bus,id=canbus0" | ||
58 | - " -machine xlnx-zcu102.canbus0=canbus0" | ||
59 | - " -machine xlnx-zcu102.canbus1=canbus0" | ||
60 | + " -object can-bus,id=canbus" | ||
61 | + " -machine canbus0=canbus" | ||
62 | + " -machine canbus1=canbus" | ||
63 | ); | ||
64 | |||
65 | /* Configure the CAN0 in loopback mode. */ | ||
66 | @@ -XXX,XX +XXX,XX @@ static void test_can_filter(void) | ||
67 | uint8_t can_timestamp = 1; | ||
68 | |||
69 | QTestState *qts = qtest_init("-machine xlnx-zcu102" | ||
70 | - " -object can-bus,id=canbus0" | ||
71 | - " -machine xlnx-zcu102.canbus0=canbus0" | ||
72 | - " -machine xlnx-zcu102.canbus1=canbus0" | ||
73 | + " -object can-bus,id=canbus" | ||
74 | + " -machine canbus0=canbus" | ||
75 | + " -machine canbus1=canbus" | ||
76 | ); | ||
77 | |||
78 | /* Configure the CAN0 and CAN1. */ | ||
79 | @@ -XXX,XX +XXX,XX @@ static void test_can_sleepmode(void) | ||
80 | uint8_t can_timestamp = 1; | ||
81 | |||
82 | QTestState *qts = qtest_init("-machine xlnx-zcu102" | ||
83 | - " -object can-bus,id=canbus0" | ||
84 | - " -machine xlnx-zcu102.canbus0=canbus0" | ||
85 | - " -machine xlnx-zcu102.canbus1=canbus0" | ||
86 | + " -object can-bus,id=canbus" | ||
87 | + " -machine canbus0=canbus" | ||
88 | + " -machine canbus1=canbus" | ||
89 | ); | ||
90 | |||
91 | /* Configure the CAN0. */ | ||
92 | @@ -XXX,XX +XXX,XX @@ static void test_can_snoopmode(void) | ||
93 | uint8_t can_timestamp = 1; | ||
94 | |||
95 | QTestState *qts = qtest_init("-machine xlnx-zcu102" | ||
96 | - " -object can-bus,id=canbus0" | ||
97 | - " -machine xlnx-zcu102.canbus0=canbus0" | ||
98 | - " -machine xlnx-zcu102.canbus1=canbus0" | ||
99 | + " -object can-bus,id=canbus" | ||
100 | + " -machine canbus0=canbus" | ||
101 | + " -machine canbus1=canbus" | ||
102 | ); | ||
103 | |||
104 | /* Configure the CAN0. */ | ||
35 | -- | 105 | -- |
36 | 2.19.1 | 106 | 2.20.1 |
37 | 107 | ||
38 | 108 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Maxim Uvarov <maxim.uvarov@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Move cmtst_op expanders from translate-a64.c. | 3 | Implement gpio-pwr driver to allow reboot and poweroff machine. |
4 | This is simple driver with just 2 gpios lines. Current use case | ||
5 | is to reboot and poweroff virt machine in secure mode. Secure | ||
6 | pl066 gpio chip is needed for that. | ||
4 | 7 | ||
5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 8 | Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org> |
6 | Message-id: 20181011205206.3552-17-richard.henderson@linaro.org | 9 | Reviewed-by: Hao Wu <wuhaotsh@google.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 | hw/gpio/gpio_pwr.c | 70 +++++++++++++++++++++++++++++++++++++++++++++ |
11 | target/arm/translate-a64.c | 38 ------------------ | 14 | hw/gpio/Kconfig | 3 ++ |
12 | target/arm/translate.c | 81 +++++++++++++++++++++++++++----------- | 15 | hw/gpio/meson.build | 1 + |
13 | 3 files changed, 60 insertions(+), 61 deletions(-) | 16 | 3 files changed, 74 insertions(+) |
17 | create mode 100644 hw/gpio/gpio_pwr.c | ||
14 | 18 | ||
15 | diff --git a/target/arm/translate.h b/target/arm/translate.h | 19 | diff --git a/hw/gpio/gpio_pwr.c b/hw/gpio/gpio_pwr.c |
16 | index XXXXXXX..XXXXXXX 100644 | 20 | new file mode 100644 |
17 | --- a/target/arm/translate.h | 21 | index XXXXXXX..XXXXXXX |
18 | +++ b/target/arm/translate.h | 22 | --- /dev/null |
19 | @@ -XXX,XX +XXX,XX @@ extern const GVecGen3 bit_op; | 23 | +++ b/hw/gpio/gpio_pwr.c |
20 | extern const GVecGen3 bif_op; | 24 | @@ -XXX,XX +XXX,XX @@ |
21 | extern const GVecGen3 mla_op[4]; | 25 | +/* |
22 | extern const GVecGen3 mls_op[4]; | 26 | + * GPIO qemu power controller |
23 | +extern const GVecGen3 cmtst_op[4]; | 27 | + * |
24 | extern const GVecGen2i ssra_op[4]; | 28 | + * Copyright (c) 2020 Linaro Limited |
25 | extern const GVecGen2i usra_op[4]; | 29 | + * |
26 | extern const GVecGen2i sri_op[4]; | 30 | + * Author: Maxim Uvarov <maxim.uvarov@linaro.org> |
27 | extern const GVecGen2i sli_op[4]; | 31 | + * |
28 | +void gen_cmtst_i64(TCGv_i64 d, TCGv_i64 a, TCGv_i64 b); | 32 | + * Virtual gpio driver which can be used on top of pl061 |
29 | 33 | + * to reboot and shutdown qemu virtual machine. One of use | |
30 | /* | 34 | + * case is gpio driver for secure world application (ARM |
31 | * Forward to the isar_feature_* tests given a DisasContext pointer. | 35 | + * Trusted Firmware.). |
32 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 36 | + * |
33 | index XXXXXXX..XXXXXXX 100644 | 37 | + * This work is licensed under the terms of the GNU GPL, version 2 or later. |
34 | --- a/target/arm/translate-a64.c | 38 | + * See the COPYING file in the top-level directory. |
35 | +++ b/target/arm/translate-a64.c | 39 | + * SPDX-License-Identifier: GPL-2.0-or-later |
36 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_scalar_three_reg_diff(DisasContext *s, uint32_t insn) | 40 | + */ |
37 | } | 41 | + |
38 | } | 42 | +/* |
39 | 43 | + * QEMU interface: | |
40 | -/* CMTST : test is "if (X & Y != 0)". */ | 44 | + * two named input GPIO lines: |
41 | -static void gen_cmtst_i32(TCGv_i32 d, TCGv_i32 a, TCGv_i32 b) | 45 | + * 'reset' : when asserted, trigger system reset |
42 | -{ | 46 | + * 'shutdown' : when asserted, trigger system shutdown |
43 | - tcg_gen_and_i32(d, a, b); | 47 | + */ |
44 | - tcg_gen_setcondi_i32(TCG_COND_NE, d, d, 0); | 48 | + |
45 | - tcg_gen_neg_i32(d, d); | 49 | +#include "qemu/osdep.h" |
46 | -} | 50 | +#include "hw/sysbus.h" |
47 | - | 51 | +#include "sysemu/runstate.h" |
48 | -static void gen_cmtst_i64(TCGv_i64 d, TCGv_i64 a, TCGv_i64 b) | 52 | + |
49 | -{ | 53 | +#define TYPE_GPIOPWR "gpio-pwr" |
50 | - tcg_gen_and_i64(d, a, b); | 54 | +OBJECT_DECLARE_SIMPLE_TYPE(GPIO_PWR_State, GPIOPWR) |
51 | - tcg_gen_setcondi_i64(TCG_COND_NE, d, d, 0); | 55 | + |
52 | - tcg_gen_neg_i64(d, d); | 56 | +struct GPIO_PWR_State { |
53 | -} | 57 | + SysBusDevice parent_obj; |
54 | - | 58 | +}; |
55 | -static void gen_cmtst_vec(unsigned vece, TCGv_vec d, TCGv_vec a, TCGv_vec b) | 59 | + |
56 | -{ | 60 | +static void gpio_pwr_reset(void *opaque, int n, int level) |
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 | +{ | 61 | +{ |
99 | + tcg_gen_and_i32(d, a, b); | 62 | + if (level) { |
100 | + tcg_gen_setcondi_i32(TCG_COND_NE, d, d, 0); | 63 | + qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET); |
101 | + tcg_gen_neg_i32(d, d); | 64 | + } |
102 | +} | 65 | +} |
103 | + | 66 | + |
104 | +void gen_cmtst_i64(TCGv_i64 d, TCGv_i64 a, TCGv_i64 b) | 67 | +static void gpio_pwr_shutdown(void *opaque, int n, int level) |
105 | +{ | 68 | +{ |
106 | + tcg_gen_and_i64(d, a, b); | 69 | + if (level) { |
107 | + tcg_gen_setcondi_i64(TCG_COND_NE, d, d, 0); | 70 | + qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN); |
108 | + tcg_gen_neg_i64(d, d); | 71 | + } |
109 | +} | 72 | +} |
110 | + | 73 | + |
111 | +static void gen_cmtst_vec(unsigned vece, TCGv_vec d, TCGv_vec a, TCGv_vec b) | 74 | +static void gpio_pwr_init(Object *obj) |
112 | +{ | 75 | +{ |
113 | + tcg_gen_and_vec(vece, d, a, b); | 76 | + DeviceState *dev = DEVICE(obj); |
114 | + tcg_gen_dupi_vec(vece, a, 0); | 77 | + |
115 | + tcg_gen_cmp_vec(TCG_COND_NE, vece, d, d, a); | 78 | + qdev_init_gpio_in_named(dev, gpio_pwr_reset, "reset", 1); |
79 | + qdev_init_gpio_in_named(dev, gpio_pwr_shutdown, "shutdown", 1); | ||
116 | +} | 80 | +} |
117 | + | 81 | + |
118 | +const GVecGen3 cmtst_op[4] = { | 82 | +static const TypeInfo gpio_pwr_info = { |
119 | + { .fni4 = gen_helper_neon_tst_u8, | 83 | + .name = TYPE_GPIOPWR, |
120 | + .fniv = gen_cmtst_vec, | 84 | + .parent = TYPE_SYS_BUS_DEVICE, |
121 | + .vece = MO_8 }, | 85 | + .instance_size = sizeof(GPIO_PWR_State), |
122 | + { .fni4 = gen_helper_neon_tst_u16, | 86 | + .instance_init = gpio_pwr_init, |
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 | +}; | 87 | +}; |
133 | + | 88 | + |
134 | /* Translate a NEON data processing instruction. Return nonzero if the | 89 | +static void gpio_pwr_register_types(void) |
135 | instruction is invalid. | 90 | +{ |
136 | We process data in a mixture of 32-bit and 64-bit chunks. | 91 | + type_register_static(&gpio_pwr_info); |
137 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | 92 | +} |
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 | + | 93 | + |
142 | + case NEON_3R_VTST_VCEQ: | 94 | +type_init(gpio_pwr_register_types) |
143 | + if (u) { /* VCEQ */ | 95 | diff --git a/hw/gpio/Kconfig b/hw/gpio/Kconfig |
144 | + tcg_gen_gvec_cmp(TCG_COND_EQ, size, rd_ofs, rn_ofs, rm_ofs, | 96 | index XXXXXXX..XXXXXXX 100644 |
145 | + vec_size, vec_size); | 97 | --- a/hw/gpio/Kconfig |
146 | + } else { /* VTST */ | 98 | +++ b/hw/gpio/Kconfig |
147 | + tcg_gen_gvec_3(rd_ofs, rn_ofs, rm_ofs, | 99 | @@ -XXX,XX +XXX,XX @@ config PL061 |
148 | + vec_size, vec_size, &cmtst_op[size]); | 100 | config GPIO_KEY |
149 | + } | 101 | bool |
150 | + return 0; | 102 | |
103 | +config GPIO_PWR | ||
104 | + bool | ||
151 | + | 105 | + |
152 | + case NEON_3R_VCGT: | 106 | config SIFIVE_GPIO |
153 | + tcg_gen_gvec_cmp(u ? TCG_COND_GTU : TCG_COND_GT, size, | 107 | bool |
154 | + rd_ofs, rn_ofs, rm_ofs, vec_size, vec_size); | 108 | diff --git a/hw/gpio/meson.build b/hw/gpio/meson.build |
155 | + return 0; | 109 | index XXXXXXX..XXXXXXX 100644 |
156 | + | 110 | --- a/hw/gpio/meson.build |
157 | + case NEON_3R_VCGE: | 111 | +++ b/hw/gpio/meson.build |
158 | + tcg_gen_gvec_cmp(u ? TCG_COND_GEU : TCG_COND_GE, size, | 112 | @@ -XXX,XX +XXX,XX @@ |
159 | + rd_ofs, rn_ofs, rm_ofs, vec_size, vec_size); | 113 | softmmu_ss.add(when: 'CONFIG_E500', if_true: files('mpc8xxx.c')) |
160 | + return 0; | 114 | softmmu_ss.add(when: 'CONFIG_GPIO_KEY', if_true: files('gpio_key.c')) |
161 | } | 115 | +softmmu_ss.add(when: 'CONFIG_GPIO_PWR', if_true: files('gpio_pwr.c')) |
162 | 116 | softmmu_ss.add(when: 'CONFIG_MAX7310', if_true: files('max7310.c')) | |
163 | if (size == 3) { | 117 | softmmu_ss.add(when: 'CONFIG_PL061', if_true: files('pl061.c')) |
164 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | 118 | softmmu_ss.add(when: 'CONFIG_PUV3', if_true: files('puv3_gpio.c')) |
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 | -- | 119 | -- |
202 | 2.19.1 | 120 | 2.20.1 |
203 | 121 | ||
204 | 122 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Maxim Uvarov <maxim.uvarov@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 3 | No functional change. Just refactor code to better |
4 | Message-id: 20181011205206.3552-18-richard.henderson@linaro.org | 4 | support secure and normal world gpios. |
5 | [PMM: added parens in ?: expression] | 5 | |
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org> |
7 | Reviewed-by: Andrew Jones <drjones@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 | hw/arm/virt.c | 57 ++++++++++++++++++++++++++++++++------------------- |
10 | 1 file changed, 26 insertions(+), 55 deletions(-) | 11 | 1 file changed, 36 insertions(+), 21 deletions(-) |
11 | 12 | ||
12 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 13 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c |
13 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
14 | --- a/target/arm/translate.c | 15 | --- a/hw/arm/virt.c |
15 | +++ b/target/arm/translate.c | 16 | +++ b/hw/arm/virt.c |
16 | @@ -XXX,XX +XXX,XX @@ static void gen_vfp_msr(TCGv_i32 tmp) | 17 | @@ -XXX,XX +XXX,XX @@ static void virt_powerdown_req(Notifier *n, void *opaque) |
17 | tcg_temp_free_i32(tmp); | 18 | } |
18 | } | 19 | } |
19 | 20 | ||
20 | -static void gen_neon_dup_u8(TCGv_i32 var, int shift) | 21 | -static void create_gpio(const VirtMachineState *vms) |
21 | -{ | 22 | +static void create_gpio_keys(const VirtMachineState *vms, |
22 | - TCGv_i32 tmp = tcg_temp_new_i32(); | 23 | + DeviceState *pl061_dev, |
23 | - if (shift) | 24 | + uint32_t phandle) |
24 | - tcg_gen_shri_i32(var, var, shift); | 25 | +{ |
25 | - tcg_gen_ext8u_i32(var, var); | 26 | + gpio_key_dev = sysbus_create_simple("gpio-key", -1, |
26 | - tcg_gen_shli_i32(tmp, var, 8); | 27 | + qdev_get_gpio_in(pl061_dev, 3)); |
27 | - tcg_gen_or_i32(var, var, tmp); | 28 | + |
28 | - tcg_gen_shli_i32(tmp, var, 16); | 29 | + qemu_fdt_add_subnode(vms->fdt, "/gpio-keys"); |
29 | - tcg_gen_or_i32(var, var, tmp); | 30 | + qemu_fdt_setprop_string(vms->fdt, "/gpio-keys", "compatible", "gpio-keys"); |
30 | - tcg_temp_free_i32(tmp); | 31 | + qemu_fdt_setprop_cell(vms->fdt, "/gpio-keys", "#size-cells", 0); |
31 | -} | 32 | + qemu_fdt_setprop_cell(vms->fdt, "/gpio-keys", "#address-cells", 1); |
33 | + | ||
34 | + qemu_fdt_add_subnode(vms->fdt, "/gpio-keys/poweroff"); | ||
35 | + qemu_fdt_setprop_string(vms->fdt, "/gpio-keys/poweroff", | ||
36 | + "label", "GPIO Key Poweroff"); | ||
37 | + qemu_fdt_setprop_cell(vms->fdt, "/gpio-keys/poweroff", "linux,code", | ||
38 | + KEY_POWER); | ||
39 | + qemu_fdt_setprop_cells(vms->fdt, "/gpio-keys/poweroff", | ||
40 | + "gpios", phandle, 3, 0); | ||
41 | +} | ||
42 | + | ||
43 | +static void create_gpio_devices(const VirtMachineState *vms, int gpio, | ||
44 | + MemoryRegion *mem) | ||
45 | { | ||
46 | char *nodename; | ||
47 | DeviceState *pl061_dev; | ||
48 | - hwaddr base = vms->memmap[VIRT_GPIO].base; | ||
49 | - hwaddr size = vms->memmap[VIRT_GPIO].size; | ||
50 | - int irq = vms->irqmap[VIRT_GPIO]; | ||
51 | + hwaddr base = vms->memmap[gpio].base; | ||
52 | + hwaddr size = vms->memmap[gpio].size; | ||
53 | + int irq = vms->irqmap[gpio]; | ||
54 | const char compat[] = "arm,pl061\0arm,primecell"; | ||
55 | + SysBusDevice *s; | ||
56 | |||
57 | - pl061_dev = sysbus_create_simple("pl061", base, | ||
58 | - qdev_get_gpio_in(vms->gic, irq)); | ||
59 | + pl061_dev = qdev_new("pl061"); | ||
60 | + s = SYS_BUS_DEVICE(pl061_dev); | ||
61 | + sysbus_realize_and_unref(s, &error_fatal); | ||
62 | + memory_region_add_subregion(mem, base, sysbus_mmio_get_region(s, 0)); | ||
63 | + sysbus_connect_irq(s, 0, qdev_get_gpio_in(vms->gic, irq)); | ||
64 | |||
65 | uint32_t phandle = qemu_fdt_alloc_phandle(vms->fdt); | ||
66 | nodename = g_strdup_printf("/pl061@%" PRIx64, base); | ||
67 | @@ -XXX,XX +XXX,XX @@ static void create_gpio(const VirtMachineState *vms) | ||
68 | qemu_fdt_setprop_string(vms->fdt, nodename, "clock-names", "apb_pclk"); | ||
69 | qemu_fdt_setprop_cell(vms->fdt, nodename, "phandle", phandle); | ||
70 | |||
71 | - gpio_key_dev = sysbus_create_simple("gpio-key", -1, | ||
72 | - qdev_get_gpio_in(pl061_dev, 3)); | ||
73 | - qemu_fdt_add_subnode(vms->fdt, "/gpio-keys"); | ||
74 | - qemu_fdt_setprop_string(vms->fdt, "/gpio-keys", "compatible", "gpio-keys"); | ||
75 | - qemu_fdt_setprop_cell(vms->fdt, "/gpio-keys", "#size-cells", 0); | ||
76 | - qemu_fdt_setprop_cell(vms->fdt, "/gpio-keys", "#address-cells", 1); | ||
32 | - | 77 | - |
33 | static void gen_neon_dup_low16(TCGv_i32 var) | 78 | - qemu_fdt_add_subnode(vms->fdt, "/gpio-keys/poweroff"); |
34 | { | 79 | - qemu_fdt_setprop_string(vms->fdt, "/gpio-keys/poweroff", |
35 | TCGv_i32 tmp = tcg_temp_new_i32(); | 80 | - "label", "GPIO Key Poweroff"); |
36 | @@ -XXX,XX +XXX,XX @@ static void gen_neon_dup_high16(TCGv_i32 var) | 81 | - qemu_fdt_setprop_cell(vms->fdt, "/gpio-keys/poweroff", "linux,code", |
37 | tcg_temp_free_i32(tmp); | 82 | - KEY_POWER); |
83 | - qemu_fdt_setprop_cells(vms->fdt, "/gpio-keys/poweroff", | ||
84 | - "gpios", phandle, 3, 0); | ||
85 | g_free(nodename); | ||
86 | + | ||
87 | + /* Child gpio devices */ | ||
88 | + create_gpio_keys(vms, pl061_dev, phandle); | ||
38 | } | 89 | } |
39 | 90 | ||
40 | -static TCGv_i32 gen_load_and_replicate(DisasContext *s, TCGv_i32 addr, int size) | 91 | static void create_virtio_devices(const VirtMachineState *vms) |
41 | -{ | 92 | @@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine) |
42 | - /* Load a single Neon element and replicate into a 32 bit TCG reg */ | 93 | if (has_ged && aarch64 && firmware_loaded && virt_is_acpi_enabled(vms)) { |
43 | - TCGv_i32 tmp = tcg_temp_new_i32(); | 94 | vms->acpi_dev = create_acpi_ged(vms); |
44 | - switch (size) { | 95 | } else { |
45 | - case 0: | 96 | - create_gpio(vms); |
46 | - gen_aa32_ld8u(s, tmp, addr, get_mem_index(s)); | 97 | + create_gpio_devices(vms, VIRT_GPIO, sysmem); |
47 | - gen_neon_dup_u8(tmp, 0); | 98 | } |
48 | - break; | 99 | |
49 | - case 1: | 100 | /* connect powerdown request */ |
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 | -- | 101 | -- |
128 | 2.19.1 | 102 | 2.20.1 |
129 | 103 | ||
130 | 104 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Maxim Uvarov <maxim.uvarov@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | For a sequence of loads or stores from a single register, | 3 | Add secure pl061 for reset/power down machine from |
4 | little-endian operations can be promoted to an 8-byte op. | 4 | the secure world (Arm Trusted Firmware). Connect it |
5 | This can reduce the number of operations by a factor of 8. | 5 | with gpio-pwr driver. |
6 | 6 | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 7 | Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org> |
8 | Message-id: 20181011205206.3552-5-richard.henderson@linaro.org | 8 | Reviewed-by: Andrew Jones <drjones@redhat.com> |
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 9 | [PMM: Added mention of the new device to the documentation] |
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 11 | --- |
12 | target/arm/translate-a64.c | 66 +++++++++++++++++++++++--------------- | 12 | docs/system/arm/virt.rst | 2 ++ |
13 | 1 file changed, 40 insertions(+), 26 deletions(-) | 13 | include/hw/arm/virt.h | 2 ++ |
14 | hw/arm/virt.c | 56 +++++++++++++++++++++++++++++++++++++++- | ||
15 | hw/arm/Kconfig | 1 + | ||
16 | 4 files changed, 60 insertions(+), 1 deletion(-) | ||
14 | 17 | ||
15 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 18 | diff --git a/docs/system/arm/virt.rst b/docs/system/arm/virt.rst |
16 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/translate-a64.c | 20 | --- a/docs/system/arm/virt.rst |
18 | +++ b/target/arm/translate-a64.c | 21 | +++ b/docs/system/arm/virt.rst |
19 | @@ -XXX,XX +XXX,XX @@ static void write_vec_element_i32(DisasContext *s, TCGv_i32 tcg_src, | 22 | @@ -XXX,XX +XXX,XX @@ The virt board supports: |
20 | 23 | - Secure-World-only devices if the CPU has TrustZone: | |
21 | /* Store from vector register to memory */ | 24 | |
22 | static void do_vec_st(DisasContext *s, int srcidx, int element, | 25 | - A second PL011 UART |
23 | - TCGv_i64 tcg_addr, int size) | 26 | + - A second PL061 GPIO controller, with GPIO lines for triggering |
24 | + TCGv_i64 tcg_addr, int size, TCGMemOp endian) | 27 | + a system reset or system poweroff |
28 | - A secure flash memory | ||
29 | - 16MB of secure RAM | ||
30 | |||
31 | diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h | ||
32 | index XXXXXXX..XXXXXXX 100644 | ||
33 | --- a/include/hw/arm/virt.h | ||
34 | +++ b/include/hw/arm/virt.h | ||
35 | @@ -XXX,XX +XXX,XX @@ enum { | ||
36 | VIRT_GPIO, | ||
37 | VIRT_SECURE_UART, | ||
38 | VIRT_SECURE_MEM, | ||
39 | + VIRT_SECURE_GPIO, | ||
40 | VIRT_PCDIMM_ACPI, | ||
41 | VIRT_ACPI_GED, | ||
42 | VIRT_NVDIMM_ACPI, | ||
43 | @@ -XXX,XX +XXX,XX @@ struct VirtMachineClass { | ||
44 | bool kvm_no_adjvtime; | ||
45 | bool no_kvm_steal_time; | ||
46 | bool acpi_expose_flash; | ||
47 | + bool no_secure_gpio; | ||
48 | }; | ||
49 | |||
50 | struct VirtMachineState { | ||
51 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c | ||
52 | index XXXXXXX..XXXXXXX 100644 | ||
53 | --- a/hw/arm/virt.c | ||
54 | +++ b/hw/arm/virt.c | ||
55 | @@ -XXX,XX +XXX,XX @@ static const MemMapEntry base_memmap[] = { | ||
56 | [VIRT_ACPI_GED] = { 0x09080000, ACPI_GED_EVT_SEL_LEN }, | ||
57 | [VIRT_NVDIMM_ACPI] = { 0x09090000, NVDIMM_ACPI_IO_LEN}, | ||
58 | [VIRT_PVTIME] = { 0x090a0000, 0x00010000 }, | ||
59 | + [VIRT_SECURE_GPIO] = { 0x090b0000, 0x00001000 }, | ||
60 | [VIRT_MMIO] = { 0x0a000000, 0x00000200 }, | ||
61 | /* ...repeating for a total of NUM_VIRTIO_TRANSPORTS, each of that size */ | ||
62 | [VIRT_PLATFORM_BUS] = { 0x0c000000, 0x02000000 }, | ||
63 | @@ -XXX,XX +XXX,XX @@ static void create_gpio_keys(const VirtMachineState *vms, | ||
64 | "gpios", phandle, 3, 0); | ||
65 | } | ||
66 | |||
67 | +#define SECURE_GPIO_POWEROFF 0 | ||
68 | +#define SECURE_GPIO_RESET 1 | ||
69 | + | ||
70 | +static void create_secure_gpio_pwr(const VirtMachineState *vms, | ||
71 | + DeviceState *pl061_dev, | ||
72 | + uint32_t phandle) | ||
73 | +{ | ||
74 | + DeviceState *gpio_pwr_dev; | ||
75 | + | ||
76 | + /* gpio-pwr */ | ||
77 | + gpio_pwr_dev = sysbus_create_simple("gpio-pwr", -1, NULL); | ||
78 | + | ||
79 | + /* connect secure pl061 to gpio-pwr */ | ||
80 | + qdev_connect_gpio_out(pl061_dev, SECURE_GPIO_RESET, | ||
81 | + qdev_get_gpio_in_named(gpio_pwr_dev, "reset", 0)); | ||
82 | + qdev_connect_gpio_out(pl061_dev, SECURE_GPIO_POWEROFF, | ||
83 | + qdev_get_gpio_in_named(gpio_pwr_dev, "shutdown", 0)); | ||
84 | + | ||
85 | + qemu_fdt_add_subnode(vms->fdt, "/gpio-poweroff"); | ||
86 | + qemu_fdt_setprop_string(vms->fdt, "/gpio-poweroff", "compatible", | ||
87 | + "gpio-poweroff"); | ||
88 | + qemu_fdt_setprop_cells(vms->fdt, "/gpio-poweroff", | ||
89 | + "gpios", phandle, SECURE_GPIO_POWEROFF, 0); | ||
90 | + qemu_fdt_setprop_string(vms->fdt, "/gpio-poweroff", "status", "disabled"); | ||
91 | + qemu_fdt_setprop_string(vms->fdt, "/gpio-poweroff", "secure-status", | ||
92 | + "okay"); | ||
93 | + | ||
94 | + qemu_fdt_add_subnode(vms->fdt, "/gpio-restart"); | ||
95 | + qemu_fdt_setprop_string(vms->fdt, "/gpio-restart", "compatible", | ||
96 | + "gpio-restart"); | ||
97 | + qemu_fdt_setprop_cells(vms->fdt, "/gpio-restart", | ||
98 | + "gpios", phandle, SECURE_GPIO_RESET, 0); | ||
99 | + qemu_fdt_setprop_string(vms->fdt, "/gpio-restart", "status", "disabled"); | ||
100 | + qemu_fdt_setprop_string(vms->fdt, "/gpio-restart", "secure-status", | ||
101 | + "okay"); | ||
102 | +} | ||
103 | + | ||
104 | static void create_gpio_devices(const VirtMachineState *vms, int gpio, | ||
105 | MemoryRegion *mem) | ||
25 | { | 106 | { |
26 | - TCGMemOp memop = s->be_data + size; | 107 | @@ -XXX,XX +XXX,XX @@ static void create_gpio_devices(const VirtMachineState *vms, int gpio, |
27 | TCGv_i64 tcg_tmp = tcg_temp_new_i64(); | 108 | qemu_fdt_setprop_string(vms->fdt, nodename, "clock-names", "apb_pclk"); |
28 | 109 | qemu_fdt_setprop_cell(vms->fdt, nodename, "phandle", phandle); | |
29 | read_vec_element(s, tcg_tmp, srcidx, element, size); | 110 | |
30 | - tcg_gen_qemu_st_i64(tcg_tmp, tcg_addr, get_mem_index(s), memop); | 111 | + if (gpio != VIRT_GPIO) { |
31 | + tcg_gen_qemu_st_i64(tcg_tmp, tcg_addr, get_mem_index(s), endian | size); | 112 | + /* Mark as not usable by the normal world */ |
32 | 113 | + qemu_fdt_setprop_string(vms->fdt, nodename, "status", "disabled"); | |
33 | tcg_temp_free_i64(tcg_tmp); | 114 | + qemu_fdt_setprop_string(vms->fdt, nodename, "secure-status", "okay"); |
115 | + } | ||
116 | g_free(nodename); | ||
117 | |||
118 | /* Child gpio devices */ | ||
119 | - create_gpio_keys(vms, pl061_dev, phandle); | ||
120 | + if (gpio == VIRT_GPIO) { | ||
121 | + create_gpio_keys(vms, pl061_dev, phandle); | ||
122 | + } else { | ||
123 | + create_secure_gpio_pwr(vms, pl061_dev, phandle); | ||
124 | + } | ||
34 | } | 125 | } |
35 | 126 | ||
36 | /* Load from memory to vector register */ | 127 | static void create_virtio_devices(const VirtMachineState *vms) |
37 | static void do_vec_ld(DisasContext *s, int destidx, int element, | 128 | @@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine) |
38 | - TCGv_i64 tcg_addr, int size) | 129 | create_gpio_devices(vms, VIRT_GPIO, sysmem); |
39 | + TCGv_i64 tcg_addr, int size, TCGMemOp endian) | ||
40 | { | ||
41 | - TCGMemOp memop = s->be_data + size; | ||
42 | TCGv_i64 tcg_tmp = tcg_temp_new_i64(); | ||
43 | |||
44 | - tcg_gen_qemu_ld_i64(tcg_tmp, tcg_addr, get_mem_index(s), memop); | ||
45 | + tcg_gen_qemu_ld_i64(tcg_tmp, tcg_addr, get_mem_index(s), endian | size); | ||
46 | write_vec_element(s, tcg_tmp, destidx, element, size); | ||
47 | |||
48 | tcg_temp_free_i64(tcg_tmp); | ||
49 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_multiple_struct(DisasContext *s, uint32_t insn) | ||
50 | bool is_postidx = extract32(insn, 23, 1); | ||
51 | bool is_q = extract32(insn, 30, 1); | ||
52 | TCGv_i64 tcg_addr, tcg_rn, tcg_ebytes; | ||
53 | + TCGMemOp endian = s->be_data; | ||
54 | |||
55 | - int ebytes = 1 << size; | ||
56 | - int elements = (is_q ? 128 : 64) / (8 << size); | ||
57 | + int ebytes; /* bytes per element */ | ||
58 | + int elements; /* elements per vector */ | ||
59 | int rpt; /* num iterations */ | ||
60 | int selem; /* structure elements */ | ||
61 | int r; | ||
62 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_multiple_struct(DisasContext *s, uint32_t insn) | ||
63 | gen_check_sp_alignment(s); | ||
64 | } | 130 | } |
65 | 131 | ||
66 | + /* For our purposes, bytes are always little-endian. */ | 132 | + if (vms->secure && !vmc->no_secure_gpio) { |
67 | + if (size == 0) { | 133 | + create_gpio_devices(vms, VIRT_SECURE_GPIO, secure_sysmem); |
68 | + endian = MO_LE; | ||
69 | + } | 134 | + } |
70 | + | 135 | + |
71 | + /* Consecutive little-endian elements from a single register | 136 | /* connect powerdown request */ |
72 | + * can be promoted to a larger little-endian operation. | 137 | vms->powerdown_notifier.notify = virt_powerdown_req; |
73 | + */ | 138 | qemu_register_powerdown_notifier(&vms->powerdown_notifier); |
74 | + if (selem == 1 && endian == MO_LE) { | 139 | @@ -XXX,XX +XXX,XX @@ DEFINE_VIRT_MACHINE_AS_LATEST(6, 0) |
75 | + size = 3; | 140 | |
76 | + } | 141 | static void virt_machine_5_2_options(MachineClass *mc) |
77 | + ebytes = 1 << size; | 142 | { |
78 | + elements = (is_q ? 16 : 8) / ebytes; | 143 | + VirtMachineClass *vmc = VIRT_MACHINE_CLASS(OBJECT_CLASS(mc)); |
79 | + | 144 | + |
80 | tcg_rn = cpu_reg_sp(s, rn); | 145 | virt_machine_6_0_options(mc); |
81 | tcg_addr = tcg_temp_new_i64(); | 146 | compat_props_add(mc->compat_props, hw_compat_5_2, hw_compat_5_2_len); |
82 | tcg_gen_mov_i64(tcg_addr, tcg_rn); | 147 | + vmc->no_secure_gpio = true; |
83 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_multiple_struct(DisasContext *s, uint32_t insn) | 148 | } |
84 | for (r = 0; r < rpt; r++) { | 149 | DEFINE_VIRT_MACHINE(5, 2) |
85 | int e; | 150 | |
86 | for (e = 0; e < elements; e++) { | 151 | diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig |
87 | - int tt = (rt + r) % 32; | 152 | index XXXXXXX..XXXXXXX 100644 |
88 | int xs; | 153 | --- a/hw/arm/Kconfig |
89 | for (xs = 0; xs < selem; xs++) { | 154 | +++ b/hw/arm/Kconfig |
90 | + int tt = (rt + r + xs) % 32; | 155 | @@ -XXX,XX +XXX,XX @@ config ARM_VIRT |
91 | if (is_store) { | 156 | select PL011 # UART |
92 | - do_vec_st(s, tt, e, tcg_addr, size); | 157 | select PL031 # RTC |
93 | + do_vec_st(s, tt, e, tcg_addr, size, endian); | 158 | select PL061 # GPIO |
94 | } else { | 159 | + select GPIO_PWR |
95 | - do_vec_ld(s, tt, e, tcg_addr, size); | 160 | select PLATFORM_BUS |
96 | - | 161 | select SMBIOS |
97 | - /* For non-quad operations, setting a slice of the low | 162 | select VIRTIO_MMIO |
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 | } | ||
115 | |||
116 | + if (!is_store) { | ||
117 | + /* For non-quad operations, setting a slice of the low | ||
118 | + * 64 bits of the register clears the high 64 bits (in | ||
119 | + * the ARM ARM pseudocode this is implicit in the fact | ||
120 | + * that 'rval' is a 64 bit wide variable). | ||
121 | + * For quad operations, we might still need to zero the | ||
122 | + * high bits of SVE. | ||
123 | + */ | ||
124 | + for (r = 0; r < rpt * selem; r++) { | ||
125 | + int tt = (rt + r) % 32; | ||
126 | + clear_vec_high(s, is_q, tt); | ||
127 | + } | ||
128 | + } | ||
129 | + | ||
130 | if (is_postidx) { | ||
131 | int rm = extract32(insn, 16, 5); | ||
132 | if (rm == 31) { | ||
133 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_single_struct(DisasContext *s, uint32_t insn) | ||
134 | } else { | ||
135 | /* Load/store one element per register */ | ||
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 | -- | 163 | -- |
146 | 2.19.1 | 164 | 2.20.1 |
147 | 165 | ||
148 | 166 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Hao Wu <wuhaotsh@google.com> |
---|---|---|---|
2 | 2 | ||
3 | Create struct ARMISARegisters, to be accessed during translation. | 3 | Fix potential overflow problem when calculating pwm_duty. |
4 | 1. Ensure p->cmr and p->cnr to be from [0,65535], according to the | ||
5 | hardware specification. | ||
6 | 2. Changed duty to uint32_t. However, since MAX_DUTY * (p->cmr+1) | ||
7 | can excceed UINT32_MAX, we convert them to uint64_t in computation | ||
8 | and converted them back to uint32_t. | ||
9 | (duty is guaranteed to be <= MAX_DUTY so it won't overflow.) | ||
4 | 10 | ||
5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 11 | Fixes: CID 1442342 |
6 | Message-id: 20181016223115.24100-2-richard.henderson@linaro.org | 12 | Suggested-by: Peter Maydell <peter.maydell@linaro.org> |
13 | Reviewed-by: Doug Evans <dje@google.com> | ||
14 | Signed-off-by: Hao Wu <wuhaotsh@google.com> | ||
15 | Message-id: 20210127011142.2122790-1-wuhaotsh@google.com | ||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 16 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | --- | 18 | --- |
10 | target/arm/cpu.h | 32 ++++---- | 19 | hw/misc/npcm7xx_pwm.c | 23 +++++++++++++++++++---- |
11 | hw/intc/armv7m_nvic.c | 12 +-- | 20 | tests/qtest/npcm7xx_pwm-test.c | 4 ++-- |
12 | target/arm/cpu.c | 178 +++++++++++++++++++++--------------------- | 21 | 2 files changed, 21 insertions(+), 6 deletions(-) |
13 | target/arm/cpu64.c | 70 ++++++++--------- | ||
14 | target/arm/helper.c | 28 +++---- | ||
15 | 5 files changed, 162 insertions(+), 158 deletions(-) | ||
16 | 22 | ||
17 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 23 | diff --git a/hw/misc/npcm7xx_pwm.c b/hw/misc/npcm7xx_pwm.c |
18 | index XXXXXXX..XXXXXXX 100644 | 24 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/target/arm/cpu.h | 25 | --- a/hw/misc/npcm7xx_pwm.c |
20 | +++ b/target/arm/cpu.h | 26 | +++ b/hw/misc/npcm7xx_pwm.c |
21 | @@ -XXX,XX +XXX,XX @@ struct ARMCPU { | 27 | @@ -XXX,XX +XXX,XX @@ REG32(NPCM7XX_PWM_PWDR3, 0x50); |
22 | * ARMv7AR ARM Architecture Reference Manual. A reset_ prefix | 28 | #define NPCM7XX_CH_INV BIT(2) |
23 | * is used for reset values of non-constant registers; no reset_ | 29 | #define NPCM7XX_CH_MOD BIT(3) |
24 | * prefix means a constant register. | 30 | |
25 | + * Some of these registers are split out into a substructure that | 31 | +#define NPCM7XX_MAX_CMR 65535 |
26 | + * is shared with the translators to control the ISA. | 32 | +#define NPCM7XX_MAX_CNR 65535 |
27 | */ | 33 | + |
28 | + struct ARMISARegisters { | 34 | /* Offset of each PWM channel's prescaler in the PPR register. */ |
29 | + uint32_t id_isar0; | 35 | static const int npcm7xx_ppr_base[] = { 0, 0, 8, 8 }; |
30 | + uint32_t id_isar1; | 36 | /* Offset of each PWM channel's clock selector in the CSR register. */ |
31 | + uint32_t id_isar2; | 37 | @@ -XXX,XX +XXX,XX @@ static uint32_t npcm7xx_pwm_calculate_freq(NPCM7xxPWM *p) |
32 | + uint32_t id_isar3; | 38 | |
33 | + uint32_t id_isar4; | 39 | static uint32_t npcm7xx_pwm_calculate_duty(NPCM7xxPWM *p) |
34 | + uint32_t id_isar5; | 40 | { |
35 | + uint32_t id_isar6; | 41 | - uint64_t duty; |
36 | + uint32_t mvfr0; | 42 | + uint32_t duty; |
37 | + uint32_t mvfr1; | 43 | |
38 | + uint32_t mvfr2; | 44 | if (p->running) { |
39 | + uint64_t id_aa64isar0; | 45 | if (p->cnr == 0) { |
40 | + uint64_t id_aa64isar1; | 46 | @@ -XXX,XX +XXX,XX @@ static uint32_t npcm7xx_pwm_calculate_duty(NPCM7xxPWM *p) |
41 | + uint64_t id_aa64pfr0; | 47 | } else if (p->cmr >= p->cnr) { |
42 | + uint64_t id_aa64pfr1; | 48 | duty = NPCM7XX_PWM_MAX_DUTY; |
43 | + } isar; | 49 | } else { |
44 | uint32_t midr; | 50 | - duty = NPCM7XX_PWM_MAX_DUTY * (p->cmr + 1) / (p->cnr + 1); |
45 | uint32_t revidr; | 51 | + duty = (uint64_t)NPCM7XX_PWM_MAX_DUTY * (p->cmr + 1) / (p->cnr + 1); |
46 | uint32_t reset_fpsid; | 52 | } |
47 | - uint32_t mvfr0; | 53 | } else { |
48 | - uint32_t mvfr1; | 54 | duty = 0; |
49 | - uint32_t mvfr2; | 55 | @@ -XXX,XX +XXX,XX @@ static void npcm7xx_pwm_write(void *opaque, hwaddr offset, |
50 | uint32_t ctr; | 56 | case A_NPCM7XX_PWM_CNR2: |
51 | uint32_t reset_sctlr; | 57 | case A_NPCM7XX_PWM_CNR3: |
52 | uint32_t id_pfr0; | 58 | p = &s->pwm[npcm7xx_cnr_index(offset)]; |
53 | @@ -XXX,XX +XXX,XX @@ struct ARMCPU { | 59 | - p->cnr = value; |
54 | uint32_t id_mmfr2; | 60 | + if (value > NPCM7XX_MAX_CNR) { |
55 | uint32_t id_mmfr3; | 61 | + qemu_log_mask(LOG_GUEST_ERROR, |
56 | uint32_t id_mmfr4; | 62 | + "%s: invalid cnr value: %u", __func__, value); |
57 | - uint32_t id_isar0; | 63 | + p->cnr = NPCM7XX_MAX_CNR; |
58 | - uint32_t id_isar1; | 64 | + } else { |
59 | - uint32_t id_isar2; | 65 | + p->cnr = value; |
60 | - uint32_t id_isar3; | 66 | + } |
61 | - uint32_t id_isar4; | 67 | npcm7xx_pwm_update_output(p); |
62 | - uint32_t id_isar5; | 68 | break; |
63 | - uint32_t id_isar6; | 69 | |
64 | - uint64_t id_aa64pfr0; | 70 | @@ -XXX,XX +XXX,XX @@ static void npcm7xx_pwm_write(void *opaque, hwaddr offset, |
65 | - uint64_t id_aa64pfr1; | 71 | case A_NPCM7XX_PWM_CMR2: |
66 | uint64_t id_aa64dfr0; | 72 | case A_NPCM7XX_PWM_CMR3: |
67 | uint64_t id_aa64dfr1; | 73 | p = &s->pwm[npcm7xx_cmr_index(offset)]; |
68 | uint64_t id_aa64afr0; | 74 | - p->cmr = value; |
69 | uint64_t id_aa64afr1; | 75 | + if (value > NPCM7XX_MAX_CMR) { |
70 | - uint64_t id_aa64isar0; | 76 | + qemu_log_mask(LOG_GUEST_ERROR, |
71 | - uint64_t id_aa64isar1; | 77 | + "%s: invalid cmr value: %u", __func__, value); |
72 | uint64_t id_aa64mmfr0; | 78 | + p->cmr = NPCM7XX_MAX_CMR; |
73 | uint64_t id_aa64mmfr1; | 79 | + } else { |
74 | uint32_t dbgdidr; | 80 | + p->cmr = value; |
75 | diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c | 81 | + } |
82 | npcm7xx_pwm_update_output(p); | ||
83 | break; | ||
84 | |||
85 | diff --git a/tests/qtest/npcm7xx_pwm-test.c b/tests/qtest/npcm7xx_pwm-test.c | ||
76 | index XXXXXXX..XXXXXXX 100644 | 86 | index XXXXXXX..XXXXXXX 100644 |
77 | --- a/hw/intc/armv7m_nvic.c | 87 | --- a/tests/qtest/npcm7xx_pwm-test.c |
78 | +++ b/hw/intc/armv7m_nvic.c | 88 | +++ b/tests/qtest/npcm7xx_pwm-test.c |
79 | @@ -XXX,XX +XXX,XX @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs) | 89 | @@ -XXX,XX +XXX,XX @@ static uint64_t pwm_compute_freq(QTestState *qts, uint32_t ppr, uint32_t csr, |
80 | case 0xd5c: /* MMFR3. */ | 90 | |
81 | return cpu->id_mmfr3; | 91 | static uint64_t pwm_compute_duty(uint32_t cnr, uint32_t cmr, bool inverted) |
82 | case 0xd60: /* ISAR0. */ | 92 | { |
83 | - return cpu->id_isar0; | 93 | - uint64_t duty; |
84 | + return cpu->isar.id_isar0; | 94 | + uint32_t duty; |
85 | case 0xd64: /* ISAR1. */ | 95 | |
86 | - return cpu->id_isar1; | 96 | if (cnr == 0) { |
87 | + return cpu->isar.id_isar1; | 97 | /* PWM is stopped. */ |
88 | case 0xd68: /* ISAR2. */ | 98 | @@ -XXX,XX +XXX,XX @@ static uint64_t pwm_compute_duty(uint32_t cnr, uint32_t cmr, bool inverted) |
89 | - return cpu->id_isar2; | 99 | } else if (cmr >= cnr) { |
90 | + return cpu->isar.id_isar2; | 100 | duty = MAX_DUTY; |
91 | case 0xd6c: /* ISAR3. */ | 101 | } else { |
92 | - return cpu->id_isar3; | 102 | - duty = MAX_DUTY * (cmr + 1) / (cnr + 1); |
93 | + return cpu->isar.id_isar3; | 103 | + duty = (uint64_t)MAX_DUTY * (cmr + 1) / (cnr + 1); |
94 | case 0xd70: /* ISAR4. */ | ||
95 | - return cpu->id_isar4; | ||
96 | + return cpu->isar.id_isar4; | ||
97 | case 0xd74: /* ISAR5. */ | ||
98 | - return cpu->id_isar5; | ||
99 | + return cpu->isar.id_isar5; | ||
100 | case 0xd78: /* CLIDR */ | ||
101 | return cpu->clidr; | ||
102 | case 0xd7c: /* CTR */ | ||
103 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | ||
104 | index XXXXXXX..XXXXXXX 100644 | ||
105 | --- a/target/arm/cpu.c | ||
106 | +++ b/target/arm/cpu.c | ||
107 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_reset(CPUState *s) | ||
108 | g_hash_table_foreach(cpu->cp_regs, cp_reg_check_reset, cpu); | ||
109 | |||
110 | env->vfp.xregs[ARM_VFP_FPSID] = cpu->reset_fpsid; | ||
111 | - env->vfp.xregs[ARM_VFP_MVFR0] = cpu->mvfr0; | ||
112 | - env->vfp.xregs[ARM_VFP_MVFR1] = cpu->mvfr1; | ||
113 | - env->vfp.xregs[ARM_VFP_MVFR2] = cpu->mvfr2; | ||
114 | + env->vfp.xregs[ARM_VFP_MVFR0] = cpu->isar.mvfr0; | ||
115 | + env->vfp.xregs[ARM_VFP_MVFR1] = cpu->isar.mvfr1; | ||
116 | + env->vfp.xregs[ARM_VFP_MVFR2] = cpu->isar.mvfr2; | ||
117 | |||
118 | cpu->power_state = cpu->start_powered_off ? PSCI_OFF : PSCI_ON; | ||
119 | s->halted = cpu->start_powered_off; | ||
120 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) | ||
121 | * registers as well. These are id_pfr1[7:4] and id_aa64pfr0[15:12]. | ||
122 | */ | ||
123 | cpu->id_pfr1 &= ~0xf0; | ||
124 | - cpu->id_aa64pfr0 &= ~0xf000; | ||
125 | + cpu->isar.id_aa64pfr0 &= ~0xf000; | ||
126 | } | 104 | } |
127 | 105 | ||
128 | if (!cpu->has_el2) { | 106 | if (inverted) { |
129 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) | ||
130 | * registers if we don't have EL2. These are id_pfr1[15:12] and | ||
131 | * id_aa64pfr0_el1[11:8]. | ||
132 | */ | ||
133 | - cpu->id_aa64pfr0 &= ~0xf00; | ||
134 | + cpu->isar.id_aa64pfr0 &= ~0xf00; | ||
135 | cpu->id_pfr1 &= ~0xf000; | ||
136 | } | ||
137 | |||
138 | @@ -XXX,XX +XXX,XX @@ static void arm1136_r2_initfn(Object *obj) | ||
139 | set_feature(&cpu->env, ARM_FEATURE_CACHE_BLOCK_OPS); | ||
140 | cpu->midr = 0x4107b362; | ||
141 | cpu->reset_fpsid = 0x410120b4; | ||
142 | - cpu->mvfr0 = 0x11111111; | ||
143 | - cpu->mvfr1 = 0x00000000; | ||
144 | + cpu->isar.mvfr0 = 0x11111111; | ||
145 | + cpu->isar.mvfr1 = 0x00000000; | ||
146 | cpu->ctr = 0x1dd20d2; | ||
147 | cpu->reset_sctlr = 0x00050078; | ||
148 | cpu->id_pfr0 = 0x111; | ||
149 | @@ -XXX,XX +XXX,XX @@ static void arm1136_r2_initfn(Object *obj) | ||
150 | cpu->id_mmfr0 = 0x01130003; | ||
151 | cpu->id_mmfr1 = 0x10030302; | ||
152 | cpu->id_mmfr2 = 0x01222110; | ||
153 | - cpu->id_isar0 = 0x00140011; | ||
154 | - cpu->id_isar1 = 0x12002111; | ||
155 | - cpu->id_isar2 = 0x11231111; | ||
156 | - cpu->id_isar3 = 0x01102131; | ||
157 | - cpu->id_isar4 = 0x141; | ||
158 | + cpu->isar.id_isar0 = 0x00140011; | ||
159 | + cpu->isar.id_isar1 = 0x12002111; | ||
160 | + cpu->isar.id_isar2 = 0x11231111; | ||
161 | + cpu->isar.id_isar3 = 0x01102131; | ||
162 | + cpu->isar.id_isar4 = 0x141; | ||
163 | cpu->reset_auxcr = 7; | ||
164 | } | ||
165 | |||
166 | @@ -XXX,XX +XXX,XX @@ static void arm1136_initfn(Object *obj) | ||
167 | set_feature(&cpu->env, ARM_FEATURE_CACHE_BLOCK_OPS); | ||
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 | } | ||
193 | |||
194 | @@ -XXX,XX +XXX,XX @@ static void arm1176_initfn(Object *obj) | ||
195 | set_feature(&cpu->env, ARM_FEATURE_EL3); | ||
196 | cpu->midr = 0x410fb767; | ||
197 | cpu->reset_fpsid = 0x410120b5; | ||
198 | - cpu->mvfr0 = 0x11111111; | ||
199 | - cpu->mvfr1 = 0x00000000; | ||
200 | + cpu->isar.mvfr0 = 0x11111111; | ||
201 | + cpu->isar.mvfr1 = 0x00000000; | ||
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 | { | ||
576 | ARMCPU *cpu = arm_env_get_cpu(env); | ||
577 | - uint64_t pfr0 = cpu->id_aa64pfr0; | ||
578 | + uint64_t pfr0 = cpu->isar.id_aa64pfr0; | ||
579 | |||
580 | if (env->gicv3state) { | ||
581 | pfr0 |= 1 << 24; | ||
582 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
583 | { .name = "ID_ISAR0", .state = ARM_CP_STATE_BOTH, | ||
584 | .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 2, .opc2 = 0, | ||
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 | -- | 107 | -- |
668 | 2.19.1 | 108 | 2.20.1 |
669 | 109 | ||
670 | 110 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> |
---|---|---|---|
2 | 2 | ||
3 | The EL3 version of this register does not include an ASID, | 3 | cpu_get_phys_page_debug() uses 'DATA LOAD' MMU access type. |
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 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 6 | Message-id: 20210127232822.3530782-1-f4bug@amsat.org |
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Message-id: 20181019015617.22583-2-richard.henderson@linaro.org | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 9 | --- |
12 | target/arm/helper.c | 2 +- | 10 | target/arm/helper.c | 2 +- |
13 | 1 file changed, 1 insertion(+), 1 deletion(-) | 11 | 1 file changed, 1 insertion(+), 1 deletion(-) |
14 | 12 | ||
15 | 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 |
16 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/helper.c | 15 | --- a/target/arm/helper.c |
18 | +++ b/target/arm/helper.c | 16 | +++ b/target/arm/helper.c |
19 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo el3_cp_reginfo[] = { | 17 | @@ -XXX,XX +XXX,XX @@ hwaddr arm_cpu_get_phys_page_attrs_debug(CPUState *cs, vaddr addr, |
20 | .fieldoffset = offsetof(CPUARMState, cp15.mvbar) }, | 18 | |
21 | { .name = "TTBR0_EL3", .state = ARM_CP_STATE_AA64, | 19 | *attrs = (MemTxAttrs) {}; |
22 | .opc0 = 3, .opc1 = 6, .crn = 2, .crm = 0, .opc2 = 0, | 20 | |
23 | - .access = PL3_RW, .writefn = vmsa_ttbr_write, .resetvalue = 0, | 21 | - ret = get_phys_addr(env, addr, 0, mmu_idx, &phys_addr, |
24 | + .access = PL3_RW, .resetvalue = 0, | 22 | + ret = get_phys_addr(env, addr, MMU_DATA_LOAD, mmu_idx, &phys_addr, |
25 | .fieldoffset = offsetof(CPUARMState, cp15.ttbr0_el[3]) }, | 23 | attrs, &prot, &page_size, &fi, &cacheattrs); |
26 | { .name = "TCR_EL3", .state = ARM_CP_STATE_AA64, | 24 | |
27 | .opc0 = 3, .opc1 = 6, .crn = 2, .crm = 0, .opc2 = 2, | 25 | if (ret) { |
28 | -- | 26 | -- |
29 | 2.19.1 | 27 | 2.20.1 |
30 | 28 | ||
31 | 29 | diff view generated by jsdifflib |
1 | From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com> | 1 | Move the preadv availability check to meson.build. This is what we |
---|---|---|---|
2 | want to be doing for host-OS-feature-checks anyway, but it also fixes | ||
3 | a problem with building for macOS with the most recent XCode SDK on a | ||
4 | Catalina host. | ||
2 | 5 | ||
3 | Announce the availability of the various priority queues. | 6 | On that configuration, 'preadv()' is provided as a weak symbol, so |
4 | This fixes an issue where guest kernels would miss to | 7 | that programs can be built with optional support for it and make a |
5 | configure secondary queues due to inproper feature bits. | 8 | runtime availability check to see whether the preadv() they have is a |
9 | working one or one which they must not call because it will | ||
10 | runtime-assert. QEMU's configure test passes (unless you're building | ||
11 | with --enable-werror) because the test program using preadv() | ||
12 | compiles, but then QEMU crashes at runtime when preadv() is called, | ||
13 | with errors like: | ||
6 | 14 | ||
7 | Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> | 15 | dyld: lazy symbol binding failed: Symbol not found: _preadv |
8 | Message-id: 20181017213932.19973-2-edgar.iglesias@gmail.com | 16 | Referenced from: /Users/pm215/src/qemu/./build/x86/tests/test-replication |
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 17 | Expected in: /usr/lib/libSystem.B.dylib |
18 | |||
19 | dyld: Symbol not found: _preadv | ||
20 | Referenced from: /Users/pm215/src/qemu/./build/x86/tests/test-replication | ||
21 | Expected in: /usr/lib/libSystem.B.dylib | ||
22 | |||
23 | Meson's own function availability check has a special case for macOS | ||
24 | which adds '-Wl,-no_weak_imports' to the compiler flags, which forces | ||
25 | the test to require the real function, not the macOS-version-too-old | ||
26 | stub. | ||
27 | |||
28 | So this commit fixes the bug where macOS builds on Catalina currently | ||
29 | require --disable-werror. | ||
30 | |||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 31 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
32 | Acked-by: Paolo Bonzini <pbonzini@redhat.com> | ||
33 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
34 | Message-id: 20210126155846.17109-1-peter.maydell@linaro.org | ||
11 | --- | 35 | --- |
12 | hw/net/cadence_gem.c | 8 +++++++- | 36 | configure | 16 ---------------- |
13 | 1 file changed, 7 insertions(+), 1 deletion(-) | 37 | meson.build | 4 +++- |
38 | 2 files changed, 3 insertions(+), 17 deletions(-) | ||
14 | 39 | ||
15 | diff --git a/hw/net/cadence_gem.c b/hw/net/cadence_gem.c | 40 | diff --git a/configure b/configure |
41 | index XXXXXXX..XXXXXXX 100755 | ||
42 | --- a/configure | ||
43 | +++ b/configure | ||
44 | @@ -XXX,XX +XXX,XX @@ if compile_prog "" "" ; then | ||
45 | iovec=yes | ||
46 | fi | ||
47 | |||
48 | -########################################## | ||
49 | -# preadv probe | ||
50 | -cat > $TMPC <<EOF | ||
51 | -#include <sys/types.h> | ||
52 | -#include <sys/uio.h> | ||
53 | -#include <unistd.h> | ||
54 | -int main(void) { return preadv(0, 0, 0, 0); } | ||
55 | -EOF | ||
56 | -preadv=no | ||
57 | -if compile_prog "" "" ; then | ||
58 | - preadv=yes | ||
59 | -fi | ||
60 | - | ||
61 | ########################################## | ||
62 | # fdt probe | ||
63 | |||
64 | @@ -XXX,XX +XXX,XX @@ fi | ||
65 | if test "$iovec" = "yes" ; then | ||
66 | echo "CONFIG_IOVEC=y" >> $config_host_mak | ||
67 | fi | ||
68 | -if test "$preadv" = "yes" ; then | ||
69 | - echo "CONFIG_PREADV=y" >> $config_host_mak | ||
70 | -fi | ||
71 | if test "$membarrier" = "yes" ; then | ||
72 | echo "CONFIG_MEMBARRIER=y" >> $config_host_mak | ||
73 | fi | ||
74 | diff --git a/meson.build b/meson.build | ||
16 | index XXXXXXX..XXXXXXX 100644 | 75 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/hw/net/cadence_gem.c | 76 | --- a/meson.build |
18 | +++ b/hw/net/cadence_gem.c | 77 | +++ b/meson.build |
19 | @@ -XXX,XX +XXX,XX @@ static void gem_reset(DeviceState *d) | 78 | @@ -XXX,XX +XXX,XX @@ config_host_data.set('HAVE_PTY_H', cc.has_header('pty.h')) |
20 | int i; | 79 | config_host_data.set('HAVE_SYS_IOCCOM_H', cc.has_header('sys/ioccom.h')) |
21 | CadenceGEMState *s = CADENCE_GEM(d); | 80 | config_host_data.set('HAVE_SYS_KCOV_H', cc.has_header('sys/kcov.h')) |
22 | const uint8_t *a; | 81 | |
23 | + uint32_t queues_mask = 0; | 82 | +config_host_data.set('CONFIG_PREADV', cc.has_function('preadv', prefix: '#include <sys/uio.h>')) |
24 | |||
25 | DB_PRINT("\n"); | ||
26 | |||
27 | @@ -XXX,XX +XXX,XX @@ static void gem_reset(DeviceState *d) | ||
28 | s->regs[GEM_DESCONF] = 0x02500111; | ||
29 | s->regs[GEM_DESCONF2] = 0x2ab13fff; | ||
30 | s->regs[GEM_DESCONF5] = 0x002f2045; | ||
31 | - s->regs[GEM_DESCONF6] = 0x00000200; | ||
32 | + s->regs[GEM_DESCONF6] = 0x0; | ||
33 | + | 83 | + |
34 | + if (s->num_priority_queues > 1) { | 84 | ignored = ['CONFIG_QEMU_INTERP_PREFIX'] # actually per-target |
35 | + queues_mask = MAKE_64BIT_MASK(1, s->num_priority_queues - 1); | 85 | arrays = ['CONFIG_AUDIO_DRIVERS', 'CONFIG_BDRV_RW_WHITELIST', 'CONFIG_BDRV_RO_WHITELIST'] |
36 | + s->regs[GEM_DESCONF6] |= queues_mask; | 86 | strings = ['HOST_DSOSUF', 'CONFIG_IASL'] |
37 | + } | 87 | @@ -XXX,XX +XXX,XX @@ summary_info += {'PIE': get_option('b_pie')} |
38 | 88 | summary_info += {'static build': config_host.has_key('CONFIG_STATIC')} | |
39 | /* Set MAC address */ | 89 | summary_info += {'malloc trim support': has_malloc_trim} |
40 | a = &s->conf.macaddr.a[0]; | 90 | summary_info += {'membarrier': config_host.has_key('CONFIG_MEMBARRIER')} |
91 | -summary_info += {'preadv support': config_host.has_key('CONFIG_PREADV')} | ||
92 | +summary_info += {'preadv support': config_host_data.get('CONFIG_PREADV')} | ||
93 | summary_info += {'fdatasync': config_host.has_key('CONFIG_FDATASYNC')} | ||
94 | summary_info += {'madvise': config_host.has_key('CONFIG_MADVISE')} | ||
95 | summary_info += {'posix_madvise': config_host.has_key('CONFIG_POSIX_MADVISE')} | ||
41 | -- | 96 | -- |
42 | 2.19.1 | 97 | 2.20.1 |
43 | 98 | ||
44 | 99 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Joelle van Dyne <j@getutm.app> |
---|---|---|---|
2 | 2 | ||
3 | For a sequence of loads or stores from a single register, | 3 | The iOS toolchain does not use the host prefix naming convention. So we |
4 | little-endian operations can be promoted to an 8-byte op. | 4 | need to enable cross-compile options while allowing the PREFIX to be |
5 | This can reduce the number of operations by a factor of 8. | 5 | blank. |
6 | 6 | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 7 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
8 | Message-id: 20181011205206.3552-20-richard.henderson@linaro.org | 8 | Signed-off-by: Joelle van Dyne <j@getutm.app> |
9 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 9 | Message-id: 20210126012457.39046-3-j@getutm.app |
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | --- | 11 | --- |
13 | target/arm/translate.c | 10 ++++++++++ | 12 | configure | 6 ++++-- |
14 | 1 file changed, 10 insertions(+) | 13 | 1 file changed, 4 insertions(+), 2 deletions(-) |
15 | 14 | ||
16 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 15 | diff --git a/configure b/configure |
17 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100755 |
18 | --- a/target/arm/translate.c | 17 | --- a/configure |
19 | +++ b/target/arm/translate.c | 18 | +++ b/configure |
20 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_ls_insn(DisasContext *s, uint32_t insn) | 19 | @@ -XXX,XX +XXX,XX @@ cpu="" |
21 | if (size == 3 && (interleave | spacing) != 1) { | 20 | iasl="iasl" |
22 | return 1; | 21 | interp_prefix="/usr/gnemul/qemu-%M" |
23 | } | 22 | static="no" |
24 | + /* For our purposes, bytes are always little-endian. */ | 23 | +cross_compile="no" |
25 | + if (size == 0) { | 24 | cross_prefix="" |
26 | + endian = MO_LE; | 25 | audio_drv_list="" |
27 | + } | 26 | block_drv_rw_whitelist="" |
28 | + /* Consecutive little-endian elements from a single register | 27 | @@ -XXX,XX +XXX,XX @@ for opt do |
29 | + * can be promoted to a larger little-endian operation. | 28 | optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)') |
30 | + */ | 29 | case "$opt" in |
31 | + if (interleave == 1 && endian == MO_LE) { | 30 | --cross-prefix=*) cross_prefix="$optarg" |
32 | + size = 3; | 31 | + cross_compile="yes" |
33 | + } | 32 | ;; |
34 | tmp64 = tcg_temp_new_i64(); | 33 | --cc=*) CC="$optarg" |
35 | addr = tcg_temp_new_i32(); | 34 | ;; |
36 | tmp2 = tcg_const_i32(1 << size); | 35 | @@ -XXX,XX +XXX,XX @@ $(echo Deprecated targets: $deprecated_targets_list | \ |
36 | --target-list-exclude=LIST exclude a set of targets from the default target-list | ||
37 | |||
38 | Advanced options (experts only): | ||
39 | - --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix] | ||
40 | + --cross-prefix=PREFIX use PREFIX for compile tools, PREFIX can be blank [$cross_prefix] | ||
41 | --cc=CC use C compiler CC [$cc] | ||
42 | --iasl=IASL use ACPI compiler IASL [$iasl] | ||
43 | --host-cc=CC use C compiler CC [$host_cc] for code run at | ||
44 | @@ -XXX,XX +XXX,XX @@ if has $sdl2_config; then | ||
45 | fi | ||
46 | echo "strip = [$(meson_quote $strip)]" >> $cross | ||
47 | echo "windres = [$(meson_quote $windres)]" >> $cross | ||
48 | -if test -n "$cross_prefix"; then | ||
49 | +if test "$cross_compile" = "yes"; then | ||
50 | cross_arg="--cross-file config-meson.cross" | ||
51 | echo "[host_machine]" >> $cross | ||
52 | if test "$mingw32" = "yes" ; then | ||
37 | -- | 53 | -- |
38 | 2.19.1 | 54 | 2.20.1 |
39 | 55 | ||
40 | 56 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Joelle van Dyne <j@getutm.app> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 3 | Build without error on hosts without a working system(). If system() |
4 | Message-id: 20181011205206.3552-12-richard.henderson@linaro.org | 4 | is called, return -1 with ENOSYS. |
5 | |||
6 | Signed-off-by: Joelle van Dyne <j@getutm.app> | ||
7 | Message-id: 20210126012457.39046-6-j@getutm.app | ||
5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
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 | 31 +++++++++++++++---------------- | 11 | meson.build | 1 + |
9 | 1 file changed, 15 insertions(+), 16 deletions(-) | 12 | include/qemu/osdep.h | 12 ++++++++++++ |
13 | 2 files changed, 13 insertions(+) | ||
10 | 14 | ||
11 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 15 | diff --git a/meson.build b/meson.build |
12 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/target/arm/translate.c | 17 | --- a/meson.build |
14 | +++ b/target/arm/translate.c | 18 | +++ b/meson.build |
15 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | 19 | @@ -XXX,XX +XXX,XX @@ config_host_data.set('HAVE_DRM_H', cc.has_header('libdrm/drm.h')) |
16 | vec_size, vec_size); | 20 | config_host_data.set('HAVE_PTY_H', cc.has_header('pty.h')) |
17 | } | 21 | config_host_data.set('HAVE_SYS_IOCCOM_H', cc.has_header('sys/ioccom.h')) |
18 | return 0; | 22 | config_host_data.set('HAVE_SYS_KCOV_H', cc.has_header('sys/kcov.h')) |
23 | +config_host_data.set('HAVE_SYSTEM_FUNCTION', cc.has_function('system', prefix: '#include <stdlib.h>')) | ||
24 | |||
25 | config_host_data.set('CONFIG_PREADV', cc.has_function('preadv', prefix: '#include <sys/uio.h>')) | ||
26 | |||
27 | diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h | ||
28 | index XXXXXXX..XXXXXXX 100644 | ||
29 | --- a/include/qemu/osdep.h | ||
30 | +++ b/include/qemu/osdep.h | ||
31 | @@ -XXX,XX +XXX,XX @@ static inline void qemu_thread_jit_write(void) {} | ||
32 | static inline void qemu_thread_jit_execute(void) {} | ||
33 | #endif | ||
34 | |||
35 | +/** | ||
36 | + * Platforms which do not support system() return ENOSYS | ||
37 | + */ | ||
38 | +#ifndef HAVE_SYSTEM_FUNCTION | ||
39 | +#define system platform_does_not_support_system | ||
40 | +static inline int platform_does_not_support_system(const char *command) | ||
41 | +{ | ||
42 | + errno = ENOSYS; | ||
43 | + return -1; | ||
44 | +} | ||
45 | +#endif /* !HAVE_SYSTEM_FUNCTION */ | ||
19 | + | 46 | + |
20 | + case NEON_3R_VMUL: /* VMUL */ | 47 | #endif |
21 | + if (u) { | ||
22 | + /* Polynomial case allows only P8 and is handled below. */ | ||
23 | + if (size != 0) { | ||
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 | -- | 48 | -- |
68 | 2.19.1 | 49 | 2.20.1 |
69 | 50 | ||
70 | 51 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Joelle van Dyne <j@getutm.app> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 3 | Meson will find CoreFoundation, IOKit, and Cocoa as needed. |
4 | Message-id: 20181011205206.3552-11-richard.henderson@linaro.org | 4 | |
5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Signed-off-by: Joelle van Dyne <j@getutm.app> | ||
7 | Message-id: 20210126012457.39046-7-j@getutm.app | ||
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 | 16 ++++++++-------- | 10 | configure | 1 - |
9 | 1 file changed, 8 insertions(+), 8 deletions(-) | 11 | 1 file changed, 1 deletion(-) |
10 | 12 | ||
11 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 13 | diff --git a/configure b/configure |
12 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100755 |
13 | --- a/target/arm/translate.c | 15 | --- a/configure |
14 | +++ b/target/arm/translate.c | 16 | +++ b/configure |
15 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | 17 | @@ -XXX,XX +XXX,XX @@ Darwin) |
16 | tcg_temp_free_ptr(ptr1); | 18 | fi |
17 | tcg_temp_free_ptr(ptr2); | 19 | audio_drv_list="coreaudio try-sdl" |
18 | break; | 20 | audio_possible_drivers="coreaudio sdl" |
19 | + | 21 | - QEMU_LDFLAGS="-framework CoreFoundation -framework IOKit $QEMU_LDFLAGS" |
20 | + case NEON_2RM_VMVN: | 22 | # Disable attempts to use ObjectiveC features in os/object.h since they |
21 | + tcg_gen_gvec_not(0, rd_ofs, rm_ofs, vec_size, vec_size); | 23 | # won't work when we're compiling with gcc as a C compiler. |
22 | + break; | 24 | QEMU_CFLAGS="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS" |
23 | + case NEON_2RM_VNEG: | ||
24 | + tcg_gen_gvec_neg(size, rd_ofs, rm_ofs, vec_size, vec_size); | ||
25 | + break; | ||
26 | + | ||
27 | default: | ||
28 | elementwise: | ||
29 | for (pass = 0; pass < (q ? 4 : 2); pass++) { | ||
30 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
31 | case NEON_2RM_VCNT: | ||
32 | gen_helper_neon_cnt_u8(tmp, tmp); | ||
33 | break; | ||
34 | - case NEON_2RM_VMVN: | ||
35 | - tcg_gen_not_i32(tmp, tmp); | ||
36 | - break; | ||
37 | case NEON_2RM_VQABS: | ||
38 | switch (size) { | ||
39 | case 0: | ||
40 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
41 | default: abort(); | ||
42 | } | ||
43 | break; | ||
44 | - case NEON_2RM_VNEG: | ||
45 | - tmp2 = tcg_const_i32(0); | ||
46 | - gen_neon_rsb(size, tmp, tmp2); | ||
47 | - tcg_temp_free_i32(tmp2); | ||
48 | - break; | ||
49 | case NEON_2RM_VCGT0_F: | ||
50 | { | ||
51 | TCGv_ptr fpstatus = get_fpstatus_ptr(1); | ||
52 | -- | 25 | -- |
53 | 2.19.1 | 26 | 2.20.1 |
54 | 27 | ||
55 | 28 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Joelle van Dyne <j@getutm.app> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 3 | Add objc to the Meson cross file as well as detection of Darwin. |
4 | Message-id: 20181011205206.3552-10-richard.henderson@linaro.org | 4 | |
5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Signed-off-by: Joelle van Dyne <j@getutm.app> | ||
7 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
8 | Message-id: 20210126012457.39046-8-j@getutm.app | ||
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 | 29 ++++++++++------------------- | 11 | configure | 4 ++++ |
9 | 1 file changed, 10 insertions(+), 19 deletions(-) | 12 | 1 file changed, 4 insertions(+) |
10 | 13 | ||
11 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 14 | diff --git a/configure b/configure |
12 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100755 |
13 | --- a/target/arm/translate.c | 16 | --- a/configure |
14 | +++ b/target/arm/translate.c | 17 | +++ b/configure |
15 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | 18 | @@ -XXX,XX +XXX,XX @@ echo "cpp_link_args = [${LDFLAGS:+$(meson_quote $LDFLAGS)}]" >> $cross |
16 | break; | 19 | echo "[binaries]" >> $cross |
17 | } | 20 | echo "c = [$(meson_quote $cc)]" >> $cross |
18 | return 0; | 21 | test -n "$cxx" && echo "cpp = [$(meson_quote $cxx)]" >> $cross |
19 | + | 22 | +test -n "$objcc" && echo "objc = [$(meson_quote $objcc)]" >> $cross |
20 | + case NEON_3R_VADD_VSUB: | 23 | echo "ar = [$(meson_quote $ar)]" >> $cross |
21 | + if (u) { | 24 | echo "nm = [$(meson_quote $nm)]" >> $cross |
22 | + tcg_gen_gvec_sub(size, rd_ofs, rn_ofs, rm_ofs, | 25 | echo "pkgconfig = [$(meson_quote $pkg_config_exe)]" >> $cross |
23 | + vec_size, vec_size); | 26 | @@ -XXX,XX +XXX,XX @@ if test "$cross_compile" = "yes"; then |
24 | + } else { | 27 | if test "$linux" = "yes" ; then |
25 | + tcg_gen_gvec_add(size, rd_ofs, rn_ofs, rm_ofs, | 28 | echo "system = 'linux'" >> $cross |
26 | + vec_size, vec_size); | 29 | fi |
27 | + } | 30 | + if test "$darwin" = "yes" ; then |
28 | + return 0; | 31 | + echo "system = 'darwin'" >> $cross |
29 | } | 32 | + fi |
30 | if (size == 3) { | 33 | case "$ARCH" in |
31 | /* 64-bit element instructions. */ | 34 | i386|x86_64) |
32 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | 35 | echo "cpu_family = 'x86'" >> $cross |
33 | cpu_V1, cpu_V0); | ||
34 | } | ||
35 | break; | ||
36 | - case NEON_3R_VADD_VSUB: | ||
37 | - if (u) { | ||
38 | - tcg_gen_sub_i64(CPU_V001); | ||
39 | - } else { | ||
40 | - tcg_gen_add_i64(CPU_V001); | ||
41 | - } | ||
42 | - break; | ||
43 | default: | ||
44 | abort(); | ||
45 | } | ||
46 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
47 | tmp2 = neon_load_reg(rd, pass); | ||
48 | gen_neon_add(size, tmp, tmp2); | ||
49 | break; | ||
50 | - case NEON_3R_VADD_VSUB: | ||
51 | - if (!u) { /* VADD */ | ||
52 | - gen_neon_add(size, tmp, tmp2); | ||
53 | - } else { /* VSUB */ | ||
54 | - switch (size) { | ||
55 | - case 0: gen_helper_neon_sub_u8(tmp, tmp, tmp2); break; | ||
56 | - case 1: gen_helper_neon_sub_u16(tmp, tmp, tmp2); break; | ||
57 | - case 2: tcg_gen_sub_i32(tmp, tmp, tmp2); break; | ||
58 | - default: abort(); | ||
59 | - } | ||
60 | - } | ||
61 | - break; | ||
62 | case NEON_3R_VTST_VCEQ: | ||
63 | if (!u) { /* VTST */ | ||
64 | switch (size) { | ||
65 | -- | 36 | -- |
66 | 2.19.1 | 37 | 2.20.1 |
67 | 38 | ||
68 | 39 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Joelle van Dyne <j@getutm.app> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 3 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> |
4 | Message-id: 20181011205206.3552-8-richard.henderson@linaro.org | 4 | Signed-off-by: Joelle van Dyne <j@getutm.app> |
5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 5 | Message-id: 20210126012457.39046-9-j@getutm.app |
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | --- | 7 | --- |
8 | target/arm/translate.c | 67 ++++++++++++++++++++++++------------------ | 8 | configure | 5 ++++- |
9 | 1 file changed, 39 insertions(+), 28 deletions(-) | 9 | 1 file changed, 4 insertions(+), 1 deletion(-) |
10 | 10 | ||
11 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 11 | diff --git a/configure b/configure |
12 | index XXXXXXX..XXXXXXX 100644 | 12 | index XXXXXXX..XXXXXXX 100755 |
13 | --- a/target/arm/translate.c | 13 | --- a/configure |
14 | +++ b/target/arm/translate.c | 14 | +++ b/configure |
15 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | 15 | @@ -XXX,XX +XXX,XX @@ if test "$cross_compile" = "yes"; then |
16 | return 1; | 16 | echo "system = 'darwin'" >> $cross |
17 | } | 17 | fi |
18 | } else { /* (insn & 0x00380080) == 0 */ | 18 | case "$ARCH" in |
19 | - int invert; | 19 | - i386|x86_64) |
20 | + int invert, reg_ofs, vec_size; | 20 | + i386) |
21 | + | 21 | echo "cpu_family = 'x86'" >> $cross |
22 | if (q && (rd & 1)) { | 22 | ;; |
23 | return 1; | 23 | + x86_64) |
24 | } | 24 | + echo "cpu_family = 'x86_64'" >> $cross |
25 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | 25 | + ;; |
26 | break; | 26 | ppc64le) |
27 | case 14: | 27 | echo "cpu_family = 'ppc64'" >> $cross |
28 | imm |= (imm << 8) | (imm << 16) | (imm << 24); | 28 | ;; |
29 | - if (invert) | ||
30 | + if (invert) { | ||
31 | imm = ~imm; | ||
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 | -- | 29 | -- |
109 | 2.19.1 | 30 | 2.20.1 |
110 | 31 | ||
111 | 32 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Joelle van Dyne <j@getutm.app> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 3 | On iOS there is no CoreAudio, so we should not assume Darwin always |
4 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 4 | has it. |
5 | Message-id: 20181011205206.3552-6-richard.henderson@linaro.org | 5 | |
6 | [PMM: drop change to now-deleted cpu_mode_names array] | 6 | Signed-off-by: Joelle van Dyne <j@getutm.app> |
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
8 | Message-id: 20210126012457.39046-11-j@getutm.app | ||
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 | configure | 35 +++++++++++++++++++++++++++++++++-- |
11 | 1 file changed, 2 insertions(+), 2 deletions(-) | 12 | 1 file changed, 33 insertions(+), 2 deletions(-) |
12 | 13 | ||
13 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 14 | diff --git a/configure b/configure |
14 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100755 |
15 | --- a/target/arm/translate.c | 16 | --- a/configure |
16 | +++ b/target/arm/translate.c | 17 | +++ b/configure |
17 | @@ -XXX,XX +XXX,XX @@ static TCGv_i64 cpu_F0d, cpu_F1d; | 18 | @@ -XXX,XX +XXX,XX @@ fdt="auto" |
18 | 19 | netmap="no" | |
19 | #include "exec/gen-icount.h" | 20 | sdl="auto" |
20 | 21 | sdl_image="auto" | |
21 | -static const char *regnames[] = | 22 | +coreaudio="auto" |
22 | +static const char * const regnames[] = | 23 | virtiofsd="auto" |
23 | { "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", | 24 | virtfs="auto" |
24 | "r8", "r9", "r10", "r11", "r12", "r13", "r14", "pc" }; | 25 | libudev="auto" |
25 | 26 | @@ -XXX,XX +XXX,XX @@ Darwin) | |
26 | @@ -XXX,XX +XXX,XX @@ static struct { | 27 | QEMU_CFLAGS="-arch x86_64 $QEMU_CFLAGS" |
27 | int nregs; | 28 | QEMU_LDFLAGS="-arch x86_64 $QEMU_LDFLAGS" |
28 | int interleave; | 29 | fi |
29 | int spacing; | 30 | - audio_drv_list="coreaudio try-sdl" |
30 | -} neon_ls_element_type[11] = { | 31 | + audio_drv_list="try-coreaudio try-sdl" |
31 | +} const neon_ls_element_type[11] = { | 32 | audio_possible_drivers="coreaudio sdl" |
32 | {4, 4, 1}, | 33 | # Disable attempts to use ObjectiveC features in os/object.h since they |
33 | {4, 4, 2}, | 34 | # won't work when we're compiling with gcc as a C compiler. |
34 | {4, 1, 1}, | 35 | @@ -XXX,XX +XXX,XX @@ EOF |
36 | fi | ||
37 | fi | ||
38 | |||
39 | +########################################## | ||
40 | +# detect CoreAudio | ||
41 | +if test "$coreaudio" != "no" ; then | ||
42 | + coreaudio_libs="-framework CoreAudio" | ||
43 | + cat > $TMPC << EOF | ||
44 | +#include <CoreAudio/CoreAudio.h> | ||
45 | +int main(void) | ||
46 | +{ | ||
47 | + return (int)AudioGetCurrentHostTime(); | ||
48 | +} | ||
49 | +EOF | ||
50 | + if compile_prog "" "$coreaudio_libs" ; then | ||
51 | + coreaudio=yes | ||
52 | + else | ||
53 | + coreaudio=no | ||
54 | + fi | ||
55 | +fi | ||
56 | + | ||
57 | ########################################## | ||
58 | # Sound support libraries probe | ||
59 | |||
60 | @@ -XXX,XX +XXX,XX @@ for drv in $audio_drv_list; do | ||
61 | fi | ||
62 | ;; | ||
63 | |||
64 | - coreaudio) | ||
65 | + coreaudio | try-coreaudio) | ||
66 | + if test "$coreaudio" = "no"; then | ||
67 | + if test "$drv" = "try-coreaudio"; then | ||
68 | + audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-coreaudio//') | ||
69 | + else | ||
70 | + error_exit "$drv check failed" \ | ||
71 | + "Make sure to have the $drv is available." | ||
72 | + fi | ||
73 | + else | ||
74 | coreaudio_libs="-framework CoreAudio" | ||
75 | + if test "$drv" = "try-coreaudio"; then | ||
76 | + audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-coreaudio/coreaudio/') | ||
77 | + fi | ||
78 | + fi | ||
79 | ;; | ||
80 | |||
81 | dsound) | ||
35 | -- | 82 | -- |
36 | 2.19.1 | 83 | 2.20.1 |
37 | 84 | ||
38 | 85 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Joelle van Dyne <j@getutm.app> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 3 | A workaround added in early days of 64-bit OSX forced x86_64 if the |
4 | Message-id: 20181011205206.3552-4-richard.henderson@linaro.org | 4 | host machine had 64-bit support. This creates issues when cross- |
5 | compiling for ARM64. Additionally, the user can always use --cpu=* to | ||
6 | manually set the host CPU and therefore this workaround should be | ||
7 | removed. | ||
8 | |||
5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
10 | Signed-off-by: Joelle van Dyne <j@getutm.app> | ||
11 | Message-id: 20210126012457.39046-12-j@getutm.app | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | --- | 13 | --- |
8 | target/arm/translate-a64.c | 28 +++------------------------- | 14 | configure | 11 ----------- |
9 | 1 file changed, 3 insertions(+), 25 deletions(-) | 15 | 1 file changed, 11 deletions(-) |
10 | 16 | ||
11 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 17 | diff --git a/configure b/configure |
12 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100755 |
13 | --- a/target/arm/translate-a64.c | 19 | --- a/configure |
14 | +++ b/target/arm/translate-a64.c | 20 | +++ b/configure |
15 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_single_struct(DisasContext *s, uint32_t insn) | 21 | @@ -XXX,XX +XXX,XX @@ fi |
16 | for (xs = 0; xs < selem; xs++) { | 22 | # the correct CPU with the --cpu option. |
17 | if (replicate) { | 23 | case $targetos in |
18 | /* Load and replicate to all elements */ | 24 | Darwin) |
19 | - uint64_t mulconst; | 25 | - # on Leopard most of the system is 32-bit, so we have to ask the kernel if we can |
20 | TCGv_i64 tcg_tmp = tcg_temp_new_i64(); | 26 | - # run 64-bit userspace code. |
21 | 27 | - # If the user didn't specify a CPU explicitly and the kernel says this is | |
22 | tcg_gen_qemu_ld_i64(tcg_tmp, tcg_addr, | 28 | - # 64 bit hw, then assume x86_64. Otherwise fall through to the usual detection code. |
23 | get_mem_index(s), s->be_data + scale); | 29 | - if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then |
24 | - switch (scale) { | 30 | - cpu="x86_64" |
25 | - case 0: | 31 | - fi |
26 | - mulconst = 0x0101010101010101ULL; | 32 | HOST_DSOSUF=".dylib" |
27 | - break; | 33 | ;; |
28 | - case 1: | 34 | SunOS) |
29 | - mulconst = 0x0001000100010001ULL; | 35 | @@ -XXX,XX +XXX,XX @@ OpenBSD) |
30 | - break; | 36 | Darwin) |
31 | - case 2: | 37 | bsd="yes" |
32 | - mulconst = 0x0000000100000001ULL; | 38 | darwin="yes" |
33 | - break; | 39 | - if [ "$cpu" = "x86_64" ] ; then |
34 | - case 3: | 40 | - QEMU_CFLAGS="-arch x86_64 $QEMU_CFLAGS" |
35 | - mulconst = 0; | 41 | - QEMU_LDFLAGS="-arch x86_64 $QEMU_LDFLAGS" |
36 | - break; | 42 | - fi |
37 | - default: | 43 | audio_drv_list="try-coreaudio try-sdl" |
38 | - g_assert_not_reached(); | 44 | audio_possible_drivers="coreaudio sdl" |
39 | - } | 45 | # Disable attempts to use ObjectiveC features in os/object.h since they |
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 | -- | 46 | -- |
56 | 2.19.1 | 47 | 2.20.1 |
57 | 48 | ||
58 | 49 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Alexander Graf <agraf@csgraf.de> |
---|---|---|---|
2 | 2 | ||
3 | Instantiating mps2-an505 (cortex-m33) will fail make check when | 3 | In macOS 11, QEMU only gets access to Hypervisor.framework if it has the |
4 | V7VE asserts that ID_ISAR0.Divide includes ARM division. It is | 4 | respective entitlement. Add an entitlement template and automatically self |
5 | also wrong to include ARM_FEATURE_LPAE. | 5 | sign and apply the entitlement in the build. |
6 | 6 | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 7 | Signed-off-by: Alexander Graf <agraf@csgraf.de> |
8 | Message-id: 20181016223115.24100-3-richard.henderson@linaro.org | 8 | Reviewed-by: Roman Bolshakov <r.bolshakov@yadro.com> |
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Tested-by: Roman Bolshakov <r.bolshakov@yadro.com> |
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 11 | --- |
12 | target/arm/cpu.c | 6 +++++- | 12 | meson.build | 29 +++++++++++++++++++++++++---- |
13 | 1 file changed, 5 insertions(+), 1 deletion(-) | 13 | accel/hvf/entitlements.plist | 8 ++++++++ |
14 | scripts/entitlement.sh | 13 +++++++++++++ | ||
15 | 3 files changed, 46 insertions(+), 4 deletions(-) | ||
16 | create mode 100644 accel/hvf/entitlements.plist | ||
17 | create mode 100755 scripts/entitlement.sh | ||
14 | 18 | ||
15 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | 19 | diff --git a/meson.build b/meson.build |
16 | index XXXXXXX..XXXXXXX 100644 | 20 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/cpu.c | 21 | --- a/meson.build |
18 | +++ b/target/arm/cpu.c | 22 | +++ b/meson.build |
19 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) | 23 | @@ -XXX,XX +XXX,XX @@ foreach target : target_dirs |
20 | 24 | }] | |
21 | /* Some features automatically imply others: */ | 25 | endif |
22 | if (arm_feature(env, ARM_FEATURE_V8)) { | 26 | foreach exe: execs |
23 | - set_feature(env, ARM_FEATURE_V7VE); | 27 | - emulators += {exe['name']: |
24 | + if (arm_feature(env, ARM_FEATURE_M)) { | 28 | - executable(exe['name'], exe['sources'], |
25 | + set_feature(env, ARM_FEATURE_V7); | 29 | - install: true, |
26 | + } else { | 30 | + exe_name = exe['name'] |
27 | + set_feature(env, ARM_FEATURE_V7VE); | 31 | + exe_sign = 'CONFIG_HVF' in config_target |
28 | + } | 32 | + if exe_sign |
29 | } | 33 | + exe_name += '-unsigned' |
30 | if (arm_feature(env, ARM_FEATURE_V7VE)) { | 34 | + endif |
31 | /* v7 Virtualization Extensions. In real hardware this implies | 35 | + |
36 | + emulator = executable(exe_name, exe['sources'], | ||
37 | + install: not exe_sign, | ||
38 | c_args: c_args, | ||
39 | dependencies: arch_deps + deps + exe['dependencies'], | ||
40 | objects: lib.extract_all_objects(recursive: true), | ||
41 | @@ -XXX,XX +XXX,XX @@ foreach target : target_dirs | ||
42 | link_depends: [block_syms, qemu_syms] + exe.get('link_depends', []), | ||
43 | link_args: link_args, | ||
44 | gui_app: exe['gui']) | ||
45 | - } | ||
46 | + | ||
47 | + if exe_sign | ||
48 | + emulators += {exe['name'] : custom_target(exe['name'], | ||
49 | + install: true, | ||
50 | + install_dir: get_option('bindir'), | ||
51 | + depends: emulator, | ||
52 | + output: exe['name'], | ||
53 | + command: [ | ||
54 | + meson.current_source_dir() / 'scripts/entitlement.sh', | ||
55 | + meson.current_build_dir() / exe_name, | ||
56 | + meson.current_build_dir() / exe['name'], | ||
57 | + meson.current_source_dir() / 'accel/hvf/entitlements.plist' | ||
58 | + ]) | ||
59 | + } | ||
60 | + else | ||
61 | + emulators += {exe['name']: emulator} | ||
62 | + endif | ||
63 | |||
64 | if 'CONFIG_TRACE_SYSTEMTAP' in config_host | ||
65 | foreach stp: [ | ||
66 | diff --git a/accel/hvf/entitlements.plist b/accel/hvf/entitlements.plist | ||
67 | new file mode 100644 | ||
68 | index XXXXXXX..XXXXXXX | ||
69 | --- /dev/null | ||
70 | +++ b/accel/hvf/entitlements.plist | ||
71 | @@ -XXX,XX +XXX,XX @@ | ||
72 | +<?xml version="1.0" encoding="UTF-8"?> | ||
73 | +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
74 | +<plist version="1.0"> | ||
75 | +<dict> | ||
76 | + <key>com.apple.security.hypervisor</key> | ||
77 | + <true/> | ||
78 | +</dict> | ||
79 | +</plist> | ||
80 | diff --git a/scripts/entitlement.sh b/scripts/entitlement.sh | ||
81 | new file mode 100755 | ||
82 | index XXXXXXX..XXXXXXX | ||
83 | --- /dev/null | ||
84 | +++ b/scripts/entitlement.sh | ||
85 | @@ -XXX,XX +XXX,XX @@ | ||
86 | +#!/bin/sh -e | ||
87 | +# | ||
88 | +# Helper script for the build process to apply entitlements | ||
89 | + | ||
90 | +SRC="$1" | ||
91 | +DST="$2" | ||
92 | +ENTITLEMENT="$3" | ||
93 | + | ||
94 | +trap 'rm "$DST.tmp"' exit | ||
95 | +cp -af "$SRC" "$DST.tmp" | ||
96 | +codesign --entitlements "$ENTITLEMENT" --force -s - "$DST.tmp" | ||
97 | +mv "$DST.tmp" "$DST" | ||
98 | +trap '' exit | ||
32 | -- | 99 | -- |
33 | 2.19.1 | 100 | 2.20.1 |
34 | 101 | ||
35 | 102 | diff view generated by jsdifflib |
1 | The HCR.FB virtualization configuration register bit requests that | 1 | From: Mihai Carabas <mihai.carabas@oracle.com> |
---|---|---|---|
2 | TLB maintenance, branch predictor invalidate-all and icache | 2 | |
3 | invalidate-all operations performed in NS EL1 should be upgraded | 3 | To ease the PCI device addition in next patches, split the code as follows: |
4 | from "local CPU only to "broadcast within Inner Shareable domain". | 4 | - generic code (read/write/setup) is being kept in pvpanic.c |
5 | For QEMU we NOP the branch predictor and icache operations, so | 5 | - ISA dependent code moved to pvpanic-isa.c |
6 | we only need to upgrade the TLB invalidates: | 6 | |
7 | AArch32 TLBIALL, TLBIMVA, TLBIASID, DTLBIALL, DTLBIMVA, DTLBIASID, | 7 | Also, rename: |
8 | ITLBIALL, ITLBIMVA, ITLBIASID, TLBIMVAA, TLBIMVAL, TLBIMVAAL | 8 | - ISA_PVPANIC_DEVICE -> PVPANIC_ISA_DEVICE. |
9 | AArch64 TLBI VMALLE1, TLBI VAE1, TLBI ASIDE1, TLBI VAAE1, | 9 | - TYPE_PVPANIC -> TYPE_PVPANIC_ISA. |
10 | TLBI VALE1, TLBI VAALE1 | 10 | - MemoryRegion io -> mr. |
11 | 11 | - pvpanic_ioport_* in pvpanic_*. | |
12 | |||
13 | Update the build system with the new files and config structure. | ||
14 | |||
15 | Signed-off-by: Mihai Carabas <mihai.carabas@oracle.com> | ||
16 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 17 | 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 | --- | 18 | --- |
16 | target/arm/helper.c | 191 +++++++++++++++++++++++++++----------------- | 19 | include/hw/misc/pvpanic.h | 23 +++++++++- |
17 | 1 file changed, 116 insertions(+), 75 deletions(-) | 20 | hw/misc/pvpanic-isa.c | 94 +++++++++++++++++++++++++++++++++++++++ |
18 | 21 | hw/misc/pvpanic.c | 85 +++-------------------------------- | |
19 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 22 | hw/i386/Kconfig | 2 +- |
20 | index XXXXXXX..XXXXXXX 100644 | 23 | hw/misc/Kconfig | 6 ++- |
21 | --- a/target/arm/helper.c | 24 | hw/misc/meson.build | 3 +- |
22 | +++ b/target/arm/helper.c | 25 | tests/qtest/meson.build | 2 +- |
23 | @@ -XXX,XX +XXX,XX @@ static void contextidr_write(CPUARMState *env, const ARMCPRegInfo *ri, | 26 | 7 files changed, 130 insertions(+), 85 deletions(-) |
24 | raw_write(env, ri, value); | 27 | create mode 100644 hw/misc/pvpanic-isa.c |
25 | } | 28 | |
26 | 29 | diff --git a/include/hw/misc/pvpanic.h b/include/hw/misc/pvpanic.h | |
27 | -static void tlbiall_write(CPUARMState *env, const ARMCPRegInfo *ri, | 30 | index XXXXXXX..XXXXXXX 100644 |
28 | - uint64_t value) | 31 | --- a/include/hw/misc/pvpanic.h |
29 | -{ | 32 | +++ b/include/hw/misc/pvpanic.h |
30 | - /* Invalidate all (TLBIALL) */ | 33 | @@ -XXX,XX +XXX,XX @@ |
31 | - ARMCPU *cpu = arm_env_get_cpu(env); | 34 | |
32 | - | 35 | #include "qom/object.h" |
33 | - tlb_flush(CPU(cpu)); | 36 | |
34 | -} | 37 | -#define TYPE_PVPANIC "pvpanic" |
35 | - | 38 | +#define TYPE_PVPANIC_ISA_DEVICE "pvpanic" |
36 | -static void tlbimva_write(CPUARMState *env, const ARMCPRegInfo *ri, | 39 | |
37 | - uint64_t value) | 40 | #define PVPANIC_IOPORT_PROP "ioport" |
38 | -{ | 41 | |
39 | - /* Invalidate single TLB entry by MVA and ASID (TLBIMVA) */ | 42 | +/* The bit of supported pv event, TODO: include uapi header and remove this */ |
40 | - ARMCPU *cpu = arm_env_get_cpu(env); | 43 | +#define PVPANIC_F_PANICKED 0 |
41 | - | 44 | +#define PVPANIC_F_CRASHLOADED 1 |
42 | - tlb_flush_page(CPU(cpu), value & TARGET_PAGE_MASK); | 45 | + |
43 | -} | 46 | +/* The pv event value */ |
44 | - | 47 | +#define PVPANIC_PANICKED (1 << PVPANIC_F_PANICKED) |
45 | -static void tlbiasid_write(CPUARMState *env, const ARMCPRegInfo *ri, | 48 | +#define PVPANIC_CRASHLOADED (1 << PVPANIC_F_CRASHLOADED) |
46 | - uint64_t value) | 49 | + |
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 | } | ||
69 | |||
70 | +/* | 50 | +/* |
71 | + * Non-IS variants of TLB operations are upgraded to | 51 | + * PVPanicState for any device type |
72 | + * IS versions if we are at NS EL1 and HCR_EL2.FB is set to | ||
73 | + * force broadcast of these operations. | ||
74 | + */ | 52 | + */ |
75 | +static bool tlb_force_broadcast(CPUARMState *env) | 53 | +typedef struct PVPanicState PVPanicState; |
54 | +struct PVPanicState { | ||
55 | + MemoryRegion mr; | ||
56 | + uint8_t events; | ||
57 | +}; | ||
58 | + | ||
59 | +void pvpanic_setup_io(PVPanicState *s, DeviceState *dev, unsigned size); | ||
60 | + | ||
61 | static inline uint16_t pvpanic_port(void) | ||
62 | { | ||
63 | - Object *o = object_resolve_path_type("", TYPE_PVPANIC, NULL); | ||
64 | + Object *o = object_resolve_path_type("", TYPE_PVPANIC_ISA_DEVICE, NULL); | ||
65 | if (!o) { | ||
66 | return 0; | ||
67 | } | ||
68 | diff --git a/hw/misc/pvpanic-isa.c b/hw/misc/pvpanic-isa.c | ||
69 | new file mode 100644 | ||
70 | index XXXXXXX..XXXXXXX | ||
71 | --- /dev/null | ||
72 | +++ b/hw/misc/pvpanic-isa.c | ||
73 | @@ -XXX,XX +XXX,XX @@ | ||
74 | +/* | ||
75 | + * QEMU simulated pvpanic device. | ||
76 | + * | ||
77 | + * Copyright Fujitsu, Corp. 2013 | ||
78 | + * | ||
79 | + * Authors: | ||
80 | + * Wen Congyang <wency@cn.fujitsu.com> | ||
81 | + * Hu Tao <hutao@cn.fujitsu.com> | ||
82 | + * | ||
83 | + * This work is licensed under the terms of the GNU GPL, version 2 or later. | ||
84 | + * See the COPYING file in the top-level directory. | ||
85 | + * | ||
86 | + */ | ||
87 | + | ||
88 | +#include "qemu/osdep.h" | ||
89 | +#include "qemu/log.h" | ||
90 | +#include "qemu/module.h" | ||
91 | +#include "sysemu/runstate.h" | ||
92 | + | ||
93 | +#include "hw/nvram/fw_cfg.h" | ||
94 | +#include "hw/qdev-properties.h" | ||
95 | +#include "hw/misc/pvpanic.h" | ||
96 | +#include "qom/object.h" | ||
97 | +#include "hw/isa/isa.h" | ||
98 | + | ||
99 | +OBJECT_DECLARE_SIMPLE_TYPE(PVPanicISAState, PVPANIC_ISA_DEVICE) | ||
100 | + | ||
101 | +/* | ||
102 | + * PVPanicISAState for ISA device and | ||
103 | + * use ioport. | ||
104 | + */ | ||
105 | +struct PVPanicISAState { | ||
106 | + ISADevice parent_obj; | ||
107 | + | ||
108 | + uint16_t ioport; | ||
109 | + PVPanicState pvpanic; | ||
110 | +}; | ||
111 | + | ||
112 | +static void pvpanic_isa_initfn(Object *obj) | ||
76 | +{ | 113 | +{ |
77 | + return (env->cp15.hcr_el2 & HCR_FB) && | 114 | + PVPanicISAState *s = PVPANIC_ISA_DEVICE(obj); |
78 | + arm_current_el(env) == 1 && arm_is_secure_below_el3(env); | 115 | + |
116 | + pvpanic_setup_io(&s->pvpanic, DEVICE(s), 1); | ||
79 | +} | 117 | +} |
80 | + | 118 | + |
81 | +static void tlbiall_write(CPUARMState *env, const ARMCPRegInfo *ri, | 119 | +static void pvpanic_isa_realizefn(DeviceState *dev, Error **errp) |
82 | + uint64_t value) | ||
83 | +{ | 120 | +{ |
84 | + /* Invalidate all (TLBIALL) */ | 121 | + ISADevice *d = ISA_DEVICE(dev); |
85 | + ARMCPU *cpu = arm_env_get_cpu(env); | 122 | + PVPanicISAState *s = PVPANIC_ISA_DEVICE(dev); |
86 | + | 123 | + PVPanicState *ps = &s->pvpanic; |
87 | + if (tlb_force_broadcast(env)) { | 124 | + FWCfgState *fw_cfg = fw_cfg_find(); |
88 | + tlbiall_is_write(env, NULL, value); | 125 | + uint16_t *pvpanic_port; |
126 | + | ||
127 | + if (!fw_cfg) { | ||
89 | + return; | 128 | + return; |
90 | + } | 129 | + } |
91 | + | 130 | + |
92 | + tlb_flush(CPU(cpu)); | 131 | + pvpanic_port = g_malloc(sizeof(*pvpanic_port)); |
132 | + *pvpanic_port = cpu_to_le16(s->ioport); | ||
133 | + fw_cfg_add_file(fw_cfg, "etc/pvpanic-port", pvpanic_port, | ||
134 | + sizeof(*pvpanic_port)); | ||
135 | + | ||
136 | + isa_register_ioport(d, &ps->mr, s->ioport); | ||
93 | +} | 137 | +} |
94 | + | 138 | + |
95 | +static void tlbimva_write(CPUARMState *env, const ARMCPRegInfo *ri, | 139 | +static Property pvpanic_isa_properties[] = { |
96 | + uint64_t value) | 140 | + DEFINE_PROP_UINT16(PVPANIC_IOPORT_PROP, PVPanicISAState, ioport, 0x505), |
141 | + DEFINE_PROP_UINT8("events", PVPanicISAState, pvpanic.events, PVPANIC_PANICKED | PVPANIC_CRASHLOADED), | ||
142 | + DEFINE_PROP_END_OF_LIST(), | ||
143 | +}; | ||
144 | + | ||
145 | +static void pvpanic_isa_class_init(ObjectClass *klass, void *data) | ||
97 | +{ | 146 | +{ |
98 | + /* Invalidate single TLB entry by MVA and ASID (TLBIMVA) */ | 147 | + DeviceClass *dc = DEVICE_CLASS(klass); |
99 | + ARMCPU *cpu = arm_env_get_cpu(env); | 148 | + |
100 | + | 149 | + dc->realize = pvpanic_isa_realizefn; |
101 | + if (tlb_force_broadcast(env)) { | 150 | + device_class_set_props(dc, pvpanic_isa_properties); |
102 | + tlbimva_is_write(env, NULL, value); | 151 | + set_bit(DEVICE_CATEGORY_MISC, dc->categories); |
103 | + return; | ||
104 | + } | ||
105 | + | ||
106 | + tlb_flush_page(CPU(cpu), value & TARGET_PAGE_MASK); | ||
107 | +} | 152 | +} |
108 | + | 153 | + |
109 | +static void tlbiasid_write(CPUARMState *env, const ARMCPRegInfo *ri, | 154 | +static TypeInfo pvpanic_isa_info = { |
110 | + uint64_t value) | 155 | + .name = TYPE_PVPANIC_ISA_DEVICE, |
156 | + .parent = TYPE_ISA_DEVICE, | ||
157 | + .instance_size = sizeof(PVPanicISAState), | ||
158 | + .instance_init = pvpanic_isa_initfn, | ||
159 | + .class_init = pvpanic_isa_class_init, | ||
160 | +}; | ||
161 | + | ||
162 | +static void pvpanic_register_types(void) | ||
111 | +{ | 163 | +{ |
112 | + /* Invalidate by ASID (TLBIASID) */ | 164 | + type_register_static(&pvpanic_isa_info); |
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 | +} | 165 | +} |
122 | + | 166 | + |
123 | +static void tlbimvaa_write(CPUARMState *env, const ARMCPRegInfo *ri, | 167 | +type_init(pvpanic_register_types) |
124 | + uint64_t value) | 168 | diff --git a/hw/misc/pvpanic.c b/hw/misc/pvpanic.c |
125 | +{ | 169 | index XXXXXXX..XXXXXXX 100644 |
126 | + /* Invalidate single entry by MVA, all ASIDs (TLBIMVAA) */ | 170 | --- a/hw/misc/pvpanic.c |
127 | + ARMCPU *cpu = arm_env_get_cpu(env); | 171 | +++ b/hw/misc/pvpanic.c |
128 | + | 172 | @@ -XXX,XX +XXX,XX @@ |
129 | + if (tlb_force_broadcast(env)) { | 173 | #include "hw/misc/pvpanic.h" |
130 | + tlbimvaa_is_write(env, NULL, value); | 174 | #include "qom/object.h" |
131 | + return; | 175 | |
132 | + } | 176 | -/* The bit of supported pv event, TODO: include uapi header and remove this */ |
133 | + | 177 | -#define PVPANIC_F_PANICKED 0 |
134 | + tlb_flush_page(CPU(cpu), value & TARGET_PAGE_MASK); | 178 | -#define PVPANIC_F_CRASHLOADED 1 |
135 | +} | 179 | - |
136 | + | 180 | -/* The pv event value */ |
137 | static void tlbiall_nsnh_write(CPUARMState *env, const ARMCPRegInfo *ri, | 181 | -#define PVPANIC_PANICKED (1 << PVPANIC_F_PANICKED) |
138 | uint64_t value) | 182 | -#define PVPANIC_CRASHLOADED (1 << PVPANIC_F_CRASHLOADED) |
139 | { | 183 | - |
140 | @@ -XXX,XX +XXX,XX @@ static CPAccessResult aa64_cacheop_access(CPUARMState *env, | 184 | -typedef struct PVPanicState PVPanicState; |
141 | * Page D4-1736 (DDI0487A.b) | 185 | -DECLARE_INSTANCE_CHECKER(PVPanicState, ISA_PVPANIC_DEVICE, |
142 | */ | 186 | - TYPE_PVPANIC) |
143 | 187 | - | |
144 | -static void tlbi_aa64_vmalle1_write(CPUARMState *env, const ARMCPRegInfo *ri, | 188 | static void handle_event(int event) |
145 | - uint64_t value) | 189 | { |
146 | -{ | 190 | static bool logged; |
147 | - CPUState *cs = ENV_GET_CPU(env); | 191 | @@ -XXX,XX +XXX,XX @@ static void handle_event(int event) |
148 | - | ||
149 | - if (arm_is_secure_below_el3(env)) { | ||
150 | - tlb_flush_by_mmuidx(cs, | ||
151 | - ARMMMUIdxBit_S1SE1 | | ||
152 | - ARMMMUIdxBit_S1SE0); | ||
153 | - } else { | ||
154 | - tlb_flush_by_mmuidx(cs, | ||
155 | - ARMMMUIdxBit_S12NSE1 | | ||
156 | - ARMMMUIdxBit_S12NSE0); | ||
157 | - } | ||
158 | -} | ||
159 | - | ||
160 | static void tlbi_aa64_vmalle1is_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
161 | uint64_t value) | ||
162 | { | ||
163 | @@ -XXX,XX +XXX,XX @@ static void tlbi_aa64_vmalle1is_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
164 | } | 192 | } |
165 | } | 193 | } |
166 | 194 | ||
167 | +static void tlbi_aa64_vmalle1_write(CPUARMState *env, const ARMCPRegInfo *ri, | 195 | -#include "hw/isa/isa.h" |
168 | + uint64_t value) | 196 | - |
169 | +{ | 197 | -struct PVPanicState { |
170 | + CPUState *cs = ENV_GET_CPU(env); | 198 | - ISADevice parent_obj; |
171 | + | 199 | - |
172 | + if (tlb_force_broadcast(env)) { | 200 | - MemoryRegion io; |
173 | + tlbi_aa64_vmalle1_write(env, NULL, value); | 201 | - uint16_t ioport; |
174 | + return; | 202 | - uint8_t events; |
175 | + } | 203 | -}; |
176 | + | 204 | - |
177 | + if (arm_is_secure_below_el3(env)) { | 205 | /* return supported events on read */ |
178 | + tlb_flush_by_mmuidx(cs, | 206 | -static uint64_t pvpanic_ioport_read(void *opaque, hwaddr addr, unsigned size) |
179 | + ARMMMUIdxBit_S1SE1 | | 207 | +static uint64_t pvpanic_read(void *opaque, hwaddr addr, unsigned size) |
180 | + ARMMMUIdxBit_S1SE0); | 208 | { |
181 | + } else { | 209 | PVPanicState *pvp = opaque; |
182 | + tlb_flush_by_mmuidx(cs, | 210 | return pvp->events; |
183 | + ARMMMUIdxBit_S12NSE1 | | ||
184 | + ARMMMUIdxBit_S12NSE0); | ||
185 | + } | ||
186 | +} | ||
187 | + | ||
188 | static void tlbi_aa64_alle1_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
189 | uint64_t value) | ||
190 | { | ||
191 | @@ -XXX,XX +XXX,XX @@ static void tlbi_aa64_alle3is_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
192 | tlb_flush_by_mmuidx_all_cpus_synced(cs, ARMMMUIdxBit_S1E3); | ||
193 | } | 211 | } |
194 | 212 | ||
195 | -static void tlbi_aa64_vae1_write(CPUARMState *env, const ARMCPRegInfo *ri, | 213 | -static void pvpanic_ioport_write(void *opaque, hwaddr addr, uint64_t val, |
196 | - uint64_t value) | 214 | +static void pvpanic_write(void *opaque, hwaddr addr, uint64_t val, |
215 | unsigned size) | ||
216 | { | ||
217 | handle_event(val); | ||
218 | } | ||
219 | |||
220 | static const MemoryRegionOps pvpanic_ops = { | ||
221 | - .read = pvpanic_ioport_read, | ||
222 | - .write = pvpanic_ioport_write, | ||
223 | + .read = pvpanic_read, | ||
224 | + .write = pvpanic_write, | ||
225 | .impl = { | ||
226 | .min_access_size = 1, | ||
227 | .max_access_size = 1, | ||
228 | }, | ||
229 | }; | ||
230 | |||
231 | -static void pvpanic_isa_initfn(Object *obj) | ||
232 | +void pvpanic_setup_io(PVPanicState *s, DeviceState *dev, unsigned size) | ||
233 | { | ||
234 | - PVPanicState *s = ISA_PVPANIC_DEVICE(obj); | ||
235 | - | ||
236 | - memory_region_init_io(&s->io, OBJECT(s), &pvpanic_ops, s, "pvpanic", 1); | ||
237 | + memory_region_init_io(&s->mr, OBJECT(dev), &pvpanic_ops, s, "pvpanic", size); | ||
238 | } | ||
239 | - | ||
240 | -static void pvpanic_isa_realizefn(DeviceState *dev, Error **errp) | ||
197 | -{ | 241 | -{ |
198 | - /* Invalidate by VA, EL1&0 (AArch64 version). | 242 | - ISADevice *d = ISA_DEVICE(dev); |
199 | - * Currently handles all of VAE1, VAAE1, VAALE1 and VALE1, | 243 | - PVPanicState *s = ISA_PVPANIC_DEVICE(dev); |
200 | - * since we don't support flush-for-specific-ASID-only or | 244 | - FWCfgState *fw_cfg = fw_cfg_find(); |
201 | - * flush-last-level-only. | 245 | - uint16_t *pvpanic_port; |
202 | - */ | 246 | - |
203 | - ARMCPU *cpu = arm_env_get_cpu(env); | 247 | - if (!fw_cfg) { |
204 | - CPUState *cs = CPU(cpu); | 248 | - return; |
205 | - uint64_t pageaddr = sextract64(value << 12, 0, 56); | ||
206 | - | ||
207 | - if (arm_is_secure_below_el3(env)) { | ||
208 | - tlb_flush_page_by_mmuidx(cs, pageaddr, | ||
209 | - ARMMMUIdxBit_S1SE1 | | ||
210 | - ARMMMUIdxBit_S1SE0); | ||
211 | - } else { | ||
212 | - tlb_flush_page_by_mmuidx(cs, pageaddr, | ||
213 | - ARMMMUIdxBit_S12NSE1 | | ||
214 | - ARMMMUIdxBit_S12NSE0); | ||
215 | - } | 249 | - } |
250 | - | ||
251 | - pvpanic_port = g_malloc(sizeof(*pvpanic_port)); | ||
252 | - *pvpanic_port = cpu_to_le16(s->ioport); | ||
253 | - fw_cfg_add_file(fw_cfg, "etc/pvpanic-port", pvpanic_port, | ||
254 | - sizeof(*pvpanic_port)); | ||
255 | - | ||
256 | - isa_register_ioport(d, &s->io, s->ioport); | ||
216 | -} | 257 | -} |
217 | - | 258 | - |
218 | static void tlbi_aa64_vae2_write(CPUARMState *env, const ARMCPRegInfo *ri, | 259 | -static Property pvpanic_isa_properties[] = { |
219 | uint64_t value) | 260 | - DEFINE_PROP_UINT16(PVPANIC_IOPORT_PROP, PVPanicState, ioport, 0x505), |
220 | { | 261 | - DEFINE_PROP_UINT8("events", PVPanicState, events, PVPANIC_PANICKED | PVPANIC_CRASHLOADED), |
221 | @@ -XXX,XX +XXX,XX @@ static void tlbi_aa64_vae1is_write(CPUARMState *env, const ARMCPRegInfo *ri, | 262 | - DEFINE_PROP_END_OF_LIST(), |
222 | } | 263 | -}; |
223 | } | 264 | - |
224 | 265 | -static void pvpanic_isa_class_init(ObjectClass *klass, void *data) | |
225 | +static void tlbi_aa64_vae1_write(CPUARMState *env, const ARMCPRegInfo *ri, | 266 | -{ |
226 | + uint64_t value) | 267 | - DeviceClass *dc = DEVICE_CLASS(klass); |
227 | +{ | 268 | - |
228 | + /* Invalidate by VA, EL1&0 (AArch64 version). | 269 | - dc->realize = pvpanic_isa_realizefn; |
229 | + * Currently handles all of VAE1, VAAE1, VAALE1 and VALE1, | 270 | - device_class_set_props(dc, pvpanic_isa_properties); |
230 | + * since we don't support flush-for-specific-ASID-only or | 271 | - set_bit(DEVICE_CATEGORY_MISC, dc->categories); |
231 | + * flush-last-level-only. | 272 | -} |
232 | + */ | 273 | - |
233 | + ARMCPU *cpu = arm_env_get_cpu(env); | 274 | -static TypeInfo pvpanic_isa_info = { |
234 | + CPUState *cs = CPU(cpu); | 275 | - .name = TYPE_PVPANIC, |
235 | + uint64_t pageaddr = sextract64(value << 12, 0, 56); | 276 | - .parent = TYPE_ISA_DEVICE, |
236 | + | 277 | - .instance_size = sizeof(PVPanicState), |
237 | + if (tlb_force_broadcast(env)) { | 278 | - .instance_init = pvpanic_isa_initfn, |
238 | + tlbi_aa64_vae1is_write(env, NULL, value); | 279 | - .class_init = pvpanic_isa_class_init, |
239 | + return; | 280 | -}; |
240 | + } | 281 | - |
241 | + | 282 | -static void pvpanic_register_types(void) |
242 | + if (arm_is_secure_below_el3(env)) { | 283 | -{ |
243 | + tlb_flush_page_by_mmuidx(cs, pageaddr, | 284 | - type_register_static(&pvpanic_isa_info); |
244 | + ARMMMUIdxBit_S1SE1 | | 285 | -} |
245 | + ARMMMUIdxBit_S1SE0); | 286 | - |
246 | + } else { | 287 | -type_init(pvpanic_register_types) |
247 | + tlb_flush_page_by_mmuidx(cs, pageaddr, | 288 | diff --git a/hw/i386/Kconfig b/hw/i386/Kconfig |
248 | + ARMMMUIdxBit_S12NSE1 | | 289 | index XXXXXXX..XXXXXXX 100644 |
249 | + ARMMMUIdxBit_S12NSE0); | 290 | --- a/hw/i386/Kconfig |
250 | + } | 291 | +++ b/hw/i386/Kconfig |
251 | +} | 292 | @@ -XXX,XX +XXX,XX @@ config PC |
252 | + | 293 | imply ISA_DEBUG |
253 | static void tlbi_aa64_vae2is_write(CPUARMState *env, const ARMCPRegInfo *ri, | 294 | imply PARALLEL |
254 | uint64_t value) | 295 | imply PCI_DEVICES |
255 | { | 296 | - imply PVPANIC |
297 | + imply PVPANIC_ISA | ||
298 | imply QXL | ||
299 | imply SEV | ||
300 | imply SGA | ||
301 | diff --git a/hw/misc/Kconfig b/hw/misc/Kconfig | ||
302 | index XXXXXXX..XXXXXXX 100644 | ||
303 | --- a/hw/misc/Kconfig | ||
304 | +++ b/hw/misc/Kconfig | ||
305 | @@ -XXX,XX +XXX,XX @@ config IOTKIT_SYSCTL | ||
306 | config IOTKIT_SYSINFO | ||
307 | bool | ||
308 | |||
309 | -config PVPANIC | ||
310 | +config PVPANIC_COMMON | ||
311 | + bool | ||
312 | + | ||
313 | +config PVPANIC_ISA | ||
314 | bool | ||
315 | depends on ISA_BUS | ||
316 | + select PVPANIC_COMMON | ||
317 | |||
318 | config AUX | ||
319 | bool | ||
320 | diff --git a/hw/misc/meson.build b/hw/misc/meson.build | ||
321 | index XXXXXXX..XXXXXXX 100644 | ||
322 | --- a/hw/misc/meson.build | ||
323 | +++ b/hw/misc/meson.build | ||
324 | @@ -XXX,XX +XXX,XX @@ softmmu_ss.add(when: 'CONFIG_EMC141X', if_true: files('emc141x.c')) | ||
325 | softmmu_ss.add(when: 'CONFIG_UNIMP', if_true: files('unimp.c')) | ||
326 | softmmu_ss.add(when: 'CONFIG_EMPTY_SLOT', if_true: files('empty_slot.c')) | ||
327 | softmmu_ss.add(when: 'CONFIG_LED', if_true: files('led.c')) | ||
328 | +softmmu_ss.add(when: 'CONFIG_PVPANIC_COMMON', if_true: files('pvpanic.c')) | ||
329 | |||
330 | # ARM devices | ||
331 | softmmu_ss.add(when: 'CONFIG_PL310', if_true: files('arm_l2x0.c')) | ||
332 | @@ -XXX,XX +XXX,XX @@ softmmu_ss.add(when: 'CONFIG_IOTKIT_SYSINFO', if_true: files('iotkit-sysinfo.c') | ||
333 | softmmu_ss.add(when: 'CONFIG_ARMSSE_CPUID', if_true: files('armsse-cpuid.c')) | ||
334 | softmmu_ss.add(when: 'CONFIG_ARMSSE_MHU', if_true: files('armsse-mhu.c')) | ||
335 | |||
336 | -softmmu_ss.add(when: 'CONFIG_PVPANIC', if_true: files('pvpanic.c')) | ||
337 | +softmmu_ss.add(when: 'CONFIG_PVPANIC_ISA', if_true: files('pvpanic-isa.c')) | ||
338 | softmmu_ss.add(when: 'CONFIG_AUX', if_true: files('auxbus.c')) | ||
339 | softmmu_ss.add(when: 'CONFIG_ASPEED_SOC', if_true: files('aspeed_scu.c', 'aspeed_sdmc.c', 'aspeed_xdma.c')) | ||
340 | softmmu_ss.add(when: 'CONFIG_MSF2', if_true: files('msf2-sysreg.c')) | ||
341 | diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build | ||
342 | index XXXXXXX..XXXXXXX 100644 | ||
343 | --- a/tests/qtest/meson.build | ||
344 | +++ b/tests/qtest/meson.build | ||
345 | @@ -XXX,XX +XXX,XX @@ qtests_i386 = \ | ||
346 | (config_host.has_key('CONFIG_LINUX') and \ | ||
347 | config_all_devices.has_key('CONFIG_ISA_IPMI_BT') ? ['ipmi-bt-test'] : []) + \ | ||
348 | (config_all_devices.has_key('CONFIG_WDT_IB700') ? ['wdt_ib700-test'] : []) + \ | ||
349 | - (config_all_devices.has_key('CONFIG_PVPANIC') ? ['pvpanic-test'] : []) + \ | ||
350 | + (config_all_devices.has_key('CONFIG_PVPANIC_ISA') ? ['pvpanic-test'] : []) + \ | ||
351 | (config_all_devices.has_key('CONFIG_HDA') ? ['intel-hda-test'] : []) + \ | ||
352 | (config_all_devices.has_key('CONFIG_I82801B11') ? ['i82801b11-test'] : []) + \ | ||
353 | (config_all_devices.has_key('CONFIG_IOH3420') ? ['ioh3420-test'] : []) + \ | ||
256 | -- | 354 | -- |
257 | 2.19.1 | 355 | 2.20.1 |
258 | 356 | ||
259 | 357 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Mihai Carabas <mihai.carabas@oracle.com> |
---|---|---|---|
2 | 2 | ||
3 | Move mla_op and mls_op expanders from translate-a64.c. | 3 | Add PCI interface support for PVPANIC device. Create a new file pvpanic-pci.c |
4 | where the PCI specific routines reside and update the build system with the new | ||
5 | files and config structure. | ||
4 | 6 | ||
5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 7 | Signed-off-by: Mihai Carabas <mihai.carabas@oracle.com> |
6 | Message-id: 20181011205206.3552-16-richard.henderson@linaro.org | 8 | Reviewed-by: Gerd Hoffmann <kraxel@redhat.com> |
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
10 | Signed-off-by: Mihai Carabas <mihai.carabas@oracle.com> | ||
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 | docs/specs/pci-ids.txt | 1 + |
11 | target/arm/translate-a64.c | 106 ----------------------------- | 14 | include/hw/misc/pvpanic.h | 1 + |
12 | target/arm/translate.c | 134 ++++++++++++++++++++++++++++++++----- | 15 | include/hw/pci/pci.h | 1 + |
13 | 3 files changed, 120 insertions(+), 122 deletions(-) | 16 | hw/misc/pvpanic-pci.c | 94 +++++++++++++++++++++++++++++++++++++++ |
17 | hw/misc/Kconfig | 6 +++ | ||
18 | hw/misc/meson.build | 1 + | ||
19 | 6 files changed, 104 insertions(+) | ||
20 | create mode 100644 hw/misc/pvpanic-pci.c | ||
14 | 21 | ||
15 | diff --git a/target/arm/translate.h b/target/arm/translate.h | 22 | diff --git a/docs/specs/pci-ids.txt b/docs/specs/pci-ids.txt |
16 | index XXXXXXX..XXXXXXX 100644 | 23 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/translate.h | 24 | --- a/docs/specs/pci-ids.txt |
18 | +++ b/target/arm/translate.h | 25 | +++ b/docs/specs/pci-ids.txt |
19 | @@ -XXX,XX +XXX,XX @@ static inline TCGv_i32 get_ahp_flag(void) | 26 | @@ -XXX,XX +XXX,XX @@ PCI devices (other than virtio): |
20 | extern const GVecGen3 bsl_op; | 27 | 1b36:000d PCI xhci usb host adapter |
21 | extern const GVecGen3 bit_op; | 28 | 1b36:000f mdpy (mdev sample device), linux/samples/vfio-mdev/mdpy.c |
22 | extern const GVecGen3 bif_op; | 29 | 1b36:0010 PCIe NVMe device (-device nvme) |
23 | +extern const GVecGen3 mla_op[4]; | 30 | +1b36:0011 PCI PVPanic device (-device pvpanic-pci) |
24 | +extern const GVecGen3 mls_op[4]; | 31 | |
25 | extern const GVecGen2i ssra_op[4]; | 32 | All these devices are documented in docs/specs. |
26 | extern const GVecGen2i usra_op[4]; | 33 | |
27 | extern const GVecGen2i sri_op[4]; | 34 | diff --git a/include/hw/misc/pvpanic.h b/include/hw/misc/pvpanic.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/include/hw/misc/pvpanic.h |
31 | +++ b/target/arm/translate-a64.c | 37 | +++ b/include/hw/misc/pvpanic.h |
32 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_3same_float(DisasContext *s, uint32_t insn) | 38 | @@ -XXX,XX +XXX,XX @@ |
33 | } | 39 | #include "qom/object.h" |
34 | } | 40 | |
35 | 41 | #define TYPE_PVPANIC_ISA_DEVICE "pvpanic" | |
36 | -static void gen_mla8_i32(TCGv_i32 d, TCGv_i32 a, TCGv_i32 b) | 42 | +#define TYPE_PVPANIC_PCI_DEVICE "pvpanic-pci" |
37 | -{ | 43 | |
38 | - gen_helper_neon_mul_u8(a, a, b); | 44 | #define PVPANIC_IOPORT_PROP "ioport" |
39 | - gen_helper_neon_add_u8(d, d, a); | 45 | |
40 | -} | 46 | diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h |
41 | - | ||
42 | -static void gen_mla16_i32(TCGv_i32 d, TCGv_i32 a, TCGv_i32 b) | ||
43 | -{ | ||
44 | - gen_helper_neon_mul_u16(a, a, b); | ||
45 | - gen_helper_neon_add_u16(d, d, a); | ||
46 | -} | ||
47 | - | ||
48 | -static void gen_mla32_i32(TCGv_i32 d, TCGv_i32 a, TCGv_i32 b) | ||
49 | -{ | ||
50 | - tcg_gen_mul_i32(a, a, b); | ||
51 | - tcg_gen_add_i32(d, d, a); | ||
52 | -} | ||
53 | - | ||
54 | -static void gen_mla64_i64(TCGv_i64 d, TCGv_i64 a, TCGv_i64 b) | ||
55 | -{ | ||
56 | - tcg_gen_mul_i64(a, a, b); | ||
57 | - tcg_gen_add_i64(d, d, a); | ||
58 | -} | ||
59 | - | ||
60 | -static void gen_mla_vec(unsigned vece, TCGv_vec d, TCGv_vec a, TCGv_vec b) | ||
61 | -{ | ||
62 | - tcg_gen_mul_vec(vece, a, a, b); | ||
63 | - tcg_gen_add_vec(vece, d, d, a); | ||
64 | -} | ||
65 | - | ||
66 | -static void gen_mls8_i32(TCGv_i32 d, TCGv_i32 a, TCGv_i32 b) | ||
67 | -{ | ||
68 | - gen_helper_neon_mul_u8(a, a, b); | ||
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 | { | ||
99 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_3same_int(DisasContext *s, uint32_t insn) | ||
100 | .prefer_i64 = TCG_TARGET_REG_BITS == 64, | ||
101 | .vece = MO_64 }, | ||
102 | }; | ||
103 | - static const GVecGen3 mla_op[4] = { | ||
104 | - { .fni4 = gen_mla8_i32, | ||
105 | - .fniv = gen_mla_vec, | ||
106 | - .opc = INDEX_op_mul_vec, | ||
107 | - .load_dest = true, | ||
108 | - .vece = MO_8 }, | ||
109 | - { .fni4 = gen_mla16_i32, | ||
110 | - .fniv = gen_mla_vec, | ||
111 | - .opc = INDEX_op_mul_vec, | ||
112 | - .load_dest = true, | ||
113 | - .vece = MO_16 }, | ||
114 | - { .fni4 = gen_mla32_i32, | ||
115 | - .fniv = gen_mla_vec, | ||
116 | - .opc = INDEX_op_mul_vec, | ||
117 | - .load_dest = true, | ||
118 | - .vece = MO_32 }, | ||
119 | - { .fni8 = gen_mla64_i64, | ||
120 | - .fniv = gen_mla_vec, | ||
121 | - .opc = INDEX_op_mul_vec, | ||
122 | - .prefer_i64 = TCG_TARGET_REG_BITS == 64, | ||
123 | - .load_dest = true, | ||
124 | - .vece = MO_64 }, | ||
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 | 47 | index XXXXXXX..XXXXXXX 100644 |
154 | --- a/target/arm/translate.c | 48 | --- a/include/hw/pci/pci.h |
155 | +++ b/target/arm/translate.c | 49 | +++ b/include/hw/pci/pci.h |
156 | @@ -XXX,XX +XXX,XX @@ static void gen_neon_narrow_op(int op, int u, int size, | 50 | @@ -XXX,XX +XXX,XX @@ extern bool pci_available; |
157 | #define NEON_3R_VABA 15 | 51 | #define PCI_DEVICE_ID_REDHAT_PCIE_BRIDGE 0x000e |
158 | #define NEON_3R_VADD_VSUB 16 | 52 | #define PCI_DEVICE_ID_REDHAT_MDPY 0x000f |
159 | #define NEON_3R_VTST_VCEQ 17 | 53 | #define PCI_DEVICE_ID_REDHAT_NVME 0x0010 |
160 | -#define NEON_3R_VML 18 /* VMLA, VMLAL, VMLS, VMLSL */ | 54 | +#define PCI_DEVICE_ID_REDHAT_PVPANIC 0x0011 |
161 | +#define NEON_3R_VML 18 /* VMLA, VMLS */ | 55 | #define PCI_DEVICE_ID_REDHAT_QXL 0x0100 |
162 | #define NEON_3R_VMUL 19 | 56 | |
163 | #define NEON_3R_VPMAX 20 | 57 | #define FMT_PCIBUS PRIx64 |
164 | #define NEON_3R_VPMIN 21 | 58 | diff --git a/hw/misc/pvpanic-pci.c b/hw/misc/pvpanic-pci.c |
165 | @@ -XXX,XX +XXX,XX @@ const GVecGen2i sli_op[4] = { | 59 | new file mode 100644 |
166 | .vece = MO_64 }, | 60 | index XXXXXXX..XXXXXXX |
167 | }; | 61 | --- /dev/null |
168 | 62 | +++ b/hw/misc/pvpanic-pci.c | |
169 | +static void gen_mla8_i32(TCGv_i32 d, TCGv_i32 a, TCGv_i32 b) | 63 | @@ -XXX,XX +XXX,XX @@ |
64 | +/* | ||
65 | + * QEMU simulated PCI pvpanic device. | ||
66 | + * | ||
67 | + * Copyright (C) 2020 Oracle | ||
68 | + * | ||
69 | + * Authors: | ||
70 | + * Mihai Carabas <mihai.carabas@oracle.com> | ||
71 | + * | ||
72 | + * This work is licensed under the terms of the GNU GPL, version 2 or later. | ||
73 | + * See the COPYING file in the top-level directory. | ||
74 | + * | ||
75 | + */ | ||
76 | + | ||
77 | +#include "qemu/osdep.h" | ||
78 | +#include "qemu/log.h" | ||
79 | +#include "qemu/module.h" | ||
80 | +#include "sysemu/runstate.h" | ||
81 | + | ||
82 | +#include "hw/nvram/fw_cfg.h" | ||
83 | +#include "hw/qdev-properties.h" | ||
84 | +#include "migration/vmstate.h" | ||
85 | +#include "hw/misc/pvpanic.h" | ||
86 | +#include "qom/object.h" | ||
87 | +#include "hw/pci/pci.h" | ||
88 | + | ||
89 | +OBJECT_DECLARE_SIMPLE_TYPE(PVPanicPCIState, PVPANIC_PCI_DEVICE) | ||
90 | + | ||
91 | +/* | ||
92 | + * PVPanicPCIState for PCI device | ||
93 | + */ | ||
94 | +typedef struct PVPanicPCIState { | ||
95 | + PCIDevice dev; | ||
96 | + PVPanicState pvpanic; | ||
97 | +} PVPanicPCIState; | ||
98 | + | ||
99 | +static const VMStateDescription vmstate_pvpanic_pci = { | ||
100 | + .name = "pvpanic-pci", | ||
101 | + .version_id = 1, | ||
102 | + .minimum_version_id = 1, | ||
103 | + .fields = (VMStateField[]) { | ||
104 | + VMSTATE_PCI_DEVICE(dev, PVPanicPCIState), | ||
105 | + VMSTATE_END_OF_LIST() | ||
106 | + } | ||
107 | +}; | ||
108 | + | ||
109 | +static void pvpanic_pci_realizefn(PCIDevice *dev, Error **errp) | ||
170 | +{ | 110 | +{ |
171 | + gen_helper_neon_mul_u8(a, a, b); | 111 | + PVPanicPCIState *s = PVPANIC_PCI_DEVICE(dev); |
172 | + gen_helper_neon_add_u8(d, d, a); | 112 | + PVPanicState *ps = &s->pvpanic; |
113 | + | ||
114 | + pvpanic_setup_io(&s->pvpanic, DEVICE(s), 2); | ||
115 | + | ||
116 | + pci_register_bar(dev, 0, PCI_BASE_ADDRESS_SPACE_MEMORY, &ps->mr); | ||
173 | +} | 117 | +} |
174 | + | 118 | + |
175 | +static void gen_mls8_i32(TCGv_i32 d, TCGv_i32 a, TCGv_i32 b) | 119 | +static Property pvpanic_pci_properties[] = { |
120 | + DEFINE_PROP_UINT8("events", PVPanicPCIState, pvpanic.events, PVPANIC_PANICKED | PVPANIC_CRASHLOADED), | ||
121 | + DEFINE_PROP_END_OF_LIST(), | ||
122 | +}; | ||
123 | + | ||
124 | +static void pvpanic_pci_class_init(ObjectClass *klass, void *data) | ||
176 | +{ | 125 | +{ |
177 | + gen_helper_neon_mul_u8(a, a, b); | 126 | + DeviceClass *dc = DEVICE_CLASS(klass); |
178 | + gen_helper_neon_sub_u8(d, d, a); | 127 | + PCIDeviceClass *pc = PCI_DEVICE_CLASS(klass); |
128 | + | ||
129 | + device_class_set_props(dc, pvpanic_pci_properties); | ||
130 | + | ||
131 | + pc->realize = pvpanic_pci_realizefn; | ||
132 | + pc->vendor_id = PCI_VENDOR_ID_REDHAT; | ||
133 | + pc->device_id = PCI_DEVICE_ID_REDHAT_PVPANIC; | ||
134 | + pc->revision = 1; | ||
135 | + pc->class_id = PCI_CLASS_SYSTEM_OTHER; | ||
136 | + dc->vmsd = &vmstate_pvpanic_pci; | ||
137 | + | ||
138 | + set_bit(DEVICE_CATEGORY_MISC, dc->categories); | ||
179 | +} | 139 | +} |
180 | + | 140 | + |
181 | +static void gen_mla16_i32(TCGv_i32 d, TCGv_i32 a, TCGv_i32 b) | 141 | +static TypeInfo pvpanic_pci_info = { |
142 | + .name = TYPE_PVPANIC_PCI_DEVICE, | ||
143 | + .parent = TYPE_PCI_DEVICE, | ||
144 | + .instance_size = sizeof(PVPanicPCIState), | ||
145 | + .class_init = pvpanic_pci_class_init, | ||
146 | + .interfaces = (InterfaceInfo[]) { | ||
147 | + { INTERFACE_CONVENTIONAL_PCI_DEVICE }, | ||
148 | + { } | ||
149 | + } | ||
150 | +}; | ||
151 | + | ||
152 | +static void pvpanic_register_types(void) | ||
182 | +{ | 153 | +{ |
183 | + gen_helper_neon_mul_u16(a, a, b); | 154 | + type_register_static(&pvpanic_pci_info); |
184 | + gen_helper_neon_add_u16(d, d, a); | ||
185 | +} | 155 | +} |
186 | + | 156 | + |
187 | +static void gen_mls16_i32(TCGv_i32 d, TCGv_i32 a, TCGv_i32 b) | 157 | +type_init(pvpanic_register_types); |
188 | +{ | 158 | diff --git a/hw/misc/Kconfig b/hw/misc/Kconfig |
189 | + gen_helper_neon_mul_u16(a, a, b); | 159 | index XXXXXXX..XXXXXXX 100644 |
190 | + gen_helper_neon_sub_u16(d, d, a); | 160 | --- a/hw/misc/Kconfig |
191 | +} | 161 | +++ b/hw/misc/Kconfig |
162 | @@ -XXX,XX +XXX,XX @@ config IOTKIT_SYSINFO | ||
163 | config PVPANIC_COMMON | ||
164 | bool | ||
165 | |||
166 | +config PVPANIC_PCI | ||
167 | + bool | ||
168 | + default y if PCI_DEVICES | ||
169 | + depends on PCI | ||
170 | + select PVPANIC_COMMON | ||
192 | + | 171 | + |
193 | +static void gen_mla32_i32(TCGv_i32 d, TCGv_i32 a, TCGv_i32 b) | 172 | config PVPANIC_ISA |
194 | +{ | 173 | bool |
195 | + tcg_gen_mul_i32(a, a, b); | 174 | depends on ISA_BUS |
196 | + tcg_gen_add_i32(d, d, a); | 175 | diff --git a/hw/misc/meson.build b/hw/misc/meson.build |
197 | +} | 176 | index XXXXXXX..XXXXXXX 100644 |
198 | + | 177 | --- a/hw/misc/meson.build |
199 | +static void gen_mls32_i32(TCGv_i32 d, TCGv_i32 a, TCGv_i32 b) | 178 | +++ b/hw/misc/meson.build |
200 | +{ | 179 | @@ -XXX,XX +XXX,XX @@ softmmu_ss.add(when: 'CONFIG_ARMSSE_CPUID', if_true: files('armsse-cpuid.c')) |
201 | + tcg_gen_mul_i32(a, a, b); | 180 | softmmu_ss.add(when: 'CONFIG_ARMSSE_MHU', if_true: files('armsse-mhu.c')) |
202 | + tcg_gen_sub_i32(d, d, a); | 181 | |
203 | +} | 182 | softmmu_ss.add(when: 'CONFIG_PVPANIC_ISA', if_true: files('pvpanic-isa.c')) |
204 | + | 183 | +softmmu_ss.add(when: 'CONFIG_PVPANIC_PCI', if_true: files('pvpanic-pci.c')) |
205 | +static void gen_mla64_i64(TCGv_i64 d, TCGv_i64 a, TCGv_i64 b) | 184 | softmmu_ss.add(when: 'CONFIG_AUX', if_true: files('auxbus.c')) |
206 | +{ | 185 | softmmu_ss.add(when: 'CONFIG_ASPEED_SOC', if_true: files('aspeed_scu.c', 'aspeed_sdmc.c', 'aspeed_xdma.c')) |
207 | + tcg_gen_mul_i64(a, a, b); | 186 | softmmu_ss.add(when: 'CONFIG_MSF2', if_true: files('msf2-sysreg.c')) |
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 | -- | 187 | -- |
320 | 2.19.1 | 188 | 2.20.1 |
321 | 189 | ||
322 | 190 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Mihai Carabas <mihai.carabas@oracle.com> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 3 | Add pvpanic PCI device support details in docs/specs/pvpanic.txt. |
4 | Message-id: 20181011205206.3552-13-richard.henderson@linaro.org | 4 | |
5 | Signed-off-by: Mihai Carabas <mihai.carabas@oracle.com> | ||
5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | --- | 8 | --- |
8 | target/arm/translate.c | 70 +++++++++++++++++++++++++++++------------- | 9 | docs/specs/pvpanic.txt | 13 ++++++++++++- |
9 | 1 file changed, 48 insertions(+), 22 deletions(-) | 10 | 1 file changed, 12 insertions(+), 1 deletion(-) |
10 | 11 | ||
11 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 12 | diff --git a/docs/specs/pvpanic.txt b/docs/specs/pvpanic.txt |
12 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/target/arm/translate.c | 14 | --- a/docs/specs/pvpanic.txt |
14 | +++ b/target/arm/translate.c | 15 | +++ b/docs/specs/pvpanic.txt |
15 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | 16 | @@ -XXX,XX +XXX,XX @@ |
16 | size--; | 17 | PVPANIC DEVICE |
17 | } | 18 | ============== |
18 | shift = (insn >> 16) & ((1 << (3 + size)) - 1); | 19 | |
19 | - /* To avoid excessive duplication of ops we implement shift | 20 | -pvpanic device is a simulated ISA device, through which a guest panic |
20 | - by immediate using the variable shift operations. */ | 21 | +pvpanic device is a simulated device, through which a guest panic |
21 | if (op < 8) { | 22 | event is sent to qemu, and a QMP event is generated. This allows |
22 | /* Shift by immediate: | 23 | management apps (e.g. libvirt) to be notified and respond to the event. |
23 | VSHR, VSRA, VRSHR, VRSRA, VSRI, VSHL, VQSHL, VQSHLU. */ | 24 | |
24 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | 25 | @@ -XXX,XX +XXX,XX @@ The management app has the option of waiting for GUEST_PANICKED events, |
25 | } | 26 | and/or polling for guest-panicked RunState, to learn when the pvpanic |
26 | /* Right shifts are encoded as N - shift, where N is the | 27 | device has fired a panic event. |
27 | element size in bits. */ | 28 | |
28 | - if (op <= 4) | 29 | +The pvpanic device can be implemented as an ISA device (using IOPORT) or as a |
29 | + if (op <= 4) { | 30 | +PCI device. |
30 | shift = shift - (1 << (size + 3)); | ||
31 | + } | ||
32 | + | 31 | + |
33 | + switch (op) { | 32 | ISA Interface |
34 | + case 0: /* VSHR */ | 33 | ------------- |
35 | + /* Right shift comes here negative. */ | 34 | |
36 | + shift = -shift; | 35 | @@ -XXX,XX +XXX,XX @@ bit 1: a guest panic has happened and will be handled by the guest; |
37 | + /* Shifts larger than the element size are architecturally | 36 | the host should record it or report it, but should not affect |
38 | + * valid. Unsigned results in all zeros; signed results | 37 | the execution of the guest. |
39 | + * in all sign bits. | 38 | |
40 | + */ | 39 | +PCI Interface |
41 | + if (!u) { | 40 | +------------- |
42 | + tcg_gen_gvec_sari(size, rd_ofs, rm_ofs, | ||
43 | + MIN(shift, (8 << size) - 1), | ||
44 | + vec_size, vec_size); | ||
45 | + } else if (shift >= 8 << size) { | ||
46 | + tcg_gen_gvec_dup8i(rd_ofs, vec_size, vec_size, 0); | ||
47 | + } else { | ||
48 | + tcg_gen_gvec_shri(size, rd_ofs, rm_ofs, shift, | ||
49 | + vec_size, vec_size); | ||
50 | + } | ||
51 | + return 0; | ||
52 | + | 41 | + |
53 | + case 5: /* VSHL, VSLI */ | 42 | +The PCI interface is similar to the ISA interface except that it uses an MMIO |
54 | + if (!u) { /* VSHL */ | 43 | +address space provided by its BAR0, 1 byte long. Any machine with a PCI bus |
55 | + /* Shifts larger than the element size are | 44 | +can enable a pvpanic device by adding '-device pvpanic-pci' to the command |
56 | + * architecturally valid and results in zero. | 45 | +line. |
57 | + */ | ||
58 | + if (shift >= 8 << size) { | ||
59 | + tcg_gen_gvec_dup8i(rd_ofs, vec_size, vec_size, 0); | ||
60 | + } else { | ||
61 | + tcg_gen_gvec_shli(size, rd_ofs, rm_ofs, shift, | ||
62 | + vec_size, vec_size); | ||
63 | + } | ||
64 | + return 0; | ||
65 | + } | ||
66 | + break; | ||
67 | + } | ||
68 | + | 46 | + |
69 | if (size == 3) { | 47 | ACPI Interface |
70 | count = q + 1; | 48 | -------------- |
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 | 49 | ||
132 | -- | 50 | -- |
133 | 2.19.1 | 51 | 2.20.1 |
134 | 52 | ||
135 | 53 | diff view generated by jsdifflib |
1 | From: Dongjiu Geng <gengdongjiu@huawei.com> | 1 | From: Mihai Carabas <mihai.carabas@oracle.com> |
---|---|---|---|
2 | 2 | ||
3 | This patch extends the qemu-kvm state sync logic with support for | 3 | Add a test case for pvpanic-pci device. The scenario is the same as pvpanic |
4 | KVM_GET/SET_VCPU_EVENTS, giving access to yet missing SError exception. | 4 | ISA device, but is using the PCI bus. |
5 | And also it can support the exception state migration. | ||
6 | 5 | ||
7 | The SError exception states include SError pending state and ESR value, | 6 | Signed-off-by: Mihai Carabas <mihai.carabas@oracle.com> |
8 | the kvm_put/get_vcpu_events() will be called when set or get system | 7 | Acked-by: Thomas Huth <thuth@redhat.com> |
9 | registers. When do migration, if source machine has SError pending, | ||
10 | QEMU will do this migration regardless whether the target machine supports | ||
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 | |||
14 | Signed-off-by: Dongjiu Geng <gengdongjiu@huawei.com> | ||
15 | Reviewed-by: Andrew Jones <drjones@redhat.com> | ||
16 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
17 | Message-id: 1538067351-23931-3-git-send-email-gengdongjiu@huawei.com | 9 | Signed-off-by: Mihai Carabas <mihai.carabas@oracle.com> |
18 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
19 | --- | 11 | --- |
20 | target/arm/cpu.h | 7 ++++++ | 12 | tests/qtest/pvpanic-pci-test.c | 94 ++++++++++++++++++++++++++++++++++ |
21 | target/arm/kvm_arm.h | 24 ++++++++++++++++++ | 13 | tests/qtest/meson.build | 1 + |
22 | target/arm/kvm.c | 60 ++++++++++++++++++++++++++++++++++++++++++++ | 14 | 2 files changed, 95 insertions(+) |
23 | target/arm/kvm32.c | 13 ++++++++++ | 15 | create mode 100644 tests/qtest/pvpanic-pci-test.c |
24 | target/arm/kvm64.c | 13 ++++++++++ | ||
25 | target/arm/machine.c | 22 ++++++++++++++++ | ||
26 | 6 files changed, 139 insertions(+) | ||
27 | 16 | ||
28 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 17 | diff --git a/tests/qtest/pvpanic-pci-test.c b/tests/qtest/pvpanic-pci-test.c |
29 | index XXXXXXX..XXXXXXX 100644 | 18 | new file mode 100644 |
30 | --- a/target/arm/cpu.h | 19 | index XXXXXXX..XXXXXXX |
31 | +++ b/target/arm/cpu.h | 20 | --- /dev/null |
32 | @@ -XXX,XX +XXX,XX @@ typedef struct CPUARMState { | 21 | +++ b/tests/qtest/pvpanic-pci-test.c |
33 | */ | 22 | @@ -XXX,XX +XXX,XX @@ |
34 | } exception; | 23 | +/* |
35 | 24 | + * QTest testcase for PV Panic PCI device | |
36 | + /* Information associated with an SError */ | 25 | + * |
37 | + struct { | 26 | + * Copyright (C) 2020 Oracle |
38 | + uint8_t pending; | 27 | + * |
39 | + uint8_t has_esr; | 28 | + * Authors: |
40 | + uint64_t esr; | 29 | + * Mihai Carabas <mihai.carabas@oracle.com> |
41 | + } serror; | 30 | + * |
31 | + * This work is licensed under the terms of the GNU GPL, version 2 or later. | ||
32 | + * See the COPYING file in the top-level directory. | ||
33 | + * | ||
34 | + */ | ||
42 | + | 35 | + |
43 | /* Thumb-2 EE state. */ | 36 | +#include "qemu/osdep.h" |
44 | uint32_t teecr; | 37 | +#include "libqos/libqtest.h" |
45 | uint32_t teehbr; | 38 | +#include "qapi/qmp/qdict.h" |
46 | diff --git a/target/arm/kvm_arm.h b/target/arm/kvm_arm.h | 39 | +#include "libqos/pci.h" |
47 | index XXXXXXX..XXXXXXX 100644 | 40 | +#include "libqos/pci-pc.h" |
48 | --- a/target/arm/kvm_arm.h | 41 | +#include "hw/pci/pci_regs.h" |
49 | +++ b/target/arm/kvm_arm.h | ||
50 | @@ -XXX,XX +XXX,XX @@ bool write_kvmstate_to_list(ARMCPU *cpu); | ||
51 | */ | ||
52 | void kvm_arm_reset_vcpu(ARMCPU *cpu); | ||
53 | |||
54 | +/** | ||
55 | + * kvm_arm_init_serror_injection: | ||
56 | + * @cs: CPUState | ||
57 | + * | ||
58 | + * Check whether KVM can set guest SError syndrome. | ||
59 | + */ | ||
60 | +void kvm_arm_init_serror_injection(CPUState *cs); | ||
61 | + | 42 | + |
62 | +/** | 43 | +static void test_panic_nopause(void) |
63 | + * kvm_get_vcpu_events: | 44 | +{ |
64 | + * @cpu: ARMCPU | 45 | + uint8_t val; |
65 | + * | 46 | + QDict *response, *data; |
66 | + * Get VCPU related state from kvm. | 47 | + QTestState *qts; |
67 | + */ | 48 | + QPCIBus *pcibus; |
68 | +int kvm_get_vcpu_events(ARMCPU *cpu); | 49 | + QPCIDevice *dev; |
50 | + QPCIBar bar; | ||
69 | + | 51 | + |
70 | +/** | 52 | + qts = qtest_init("-device pvpanic-pci,addr=04.0 -action panic=none"); |
71 | + * kvm_put_vcpu_events: | 53 | + pcibus = qpci_new_pc(qts, NULL); |
72 | + * @cpu: ARMCPU | 54 | + dev = qpci_device_find(pcibus, QPCI_DEVFN(0x4, 0x0)); |
73 | + * | 55 | + qpci_device_enable(dev); |
74 | + * Put VCPU related state to kvm. | 56 | + bar = qpci_iomap(dev, 0, NULL); |
75 | + */ | ||
76 | +int kvm_put_vcpu_events(ARMCPU *cpu); | ||
77 | + | 57 | + |
78 | #ifdef CONFIG_KVM | 58 | + qpci_memread(dev, bar, 0, &val, sizeof(val)); |
79 | /** | 59 | + g_assert_cmpuint(val, ==, 3); |
80 | * kvm_arm_create_scratch_host_vcpu: | 60 | + |
81 | diff --git a/target/arm/kvm.c b/target/arm/kvm.c | 61 | + val = 1; |
82 | index XXXXXXX..XXXXXXX 100644 | 62 | + qpci_memwrite(dev, bar, 0, &val, sizeof(val)); |
83 | --- a/target/arm/kvm.c | 63 | + |
84 | +++ b/target/arm/kvm.c | 64 | + response = qtest_qmp_eventwait_ref(qts, "GUEST_PANICKED"); |
85 | @@ -XXX,XX +XXX,XX @@ const KVMCapabilityInfo kvm_arch_required_capabilities[] = { | 65 | + g_assert(qdict_haskey(response, "data")); |
86 | }; | 66 | + data = qdict_get_qdict(response, "data"); |
87 | 67 | + g_assert(qdict_haskey(data, "action")); | |
88 | static bool cap_has_mp_state; | 68 | + g_assert_cmpstr(qdict_get_str(data, "action"), ==, "run"); |
89 | +static bool cap_has_inject_serror_esr; | 69 | + qobject_unref(response); |
90 | 70 | + | |
91 | static ARMHostCPUFeatures arm_host_cpu_features; | 71 | + qtest_quit(qts); |
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 | +} | 72 | +} |
102 | + | 73 | + |
103 | bool kvm_arm_create_scratch_host_vcpu(const uint32_t *cpus_to_try, | 74 | +static void test_panic(void) |
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 | +{ | 75 | +{ |
112 | + CPUARMState *env = &cpu->env; | 76 | + uint8_t val; |
113 | + struct kvm_vcpu_events events; | 77 | + QDict *response, *data; |
78 | + QTestState *qts; | ||
79 | + QPCIBus *pcibus; | ||
80 | + QPCIDevice *dev; | ||
81 | + QPCIBar bar; | ||
82 | + | ||
83 | + qts = qtest_init("-device pvpanic-pci,addr=04.0 -action panic=pause"); | ||
84 | + pcibus = qpci_new_pc(qts, NULL); | ||
85 | + dev = qpci_device_find(pcibus, QPCI_DEVFN(0x4, 0x0)); | ||
86 | + qpci_device_enable(dev); | ||
87 | + bar = qpci_iomap(dev, 0, NULL); | ||
88 | + | ||
89 | + qpci_memread(dev, bar, 0, &val, sizeof(val)); | ||
90 | + g_assert_cmpuint(val, ==, 3); | ||
91 | + | ||
92 | + val = 1; | ||
93 | + qpci_memwrite(dev, bar, 0, &val, sizeof(val)); | ||
94 | + | ||
95 | + response = qtest_qmp_eventwait_ref(qts, "GUEST_PANICKED"); | ||
96 | + g_assert(qdict_haskey(response, "data")); | ||
97 | + data = qdict_get_qdict(response, "data"); | ||
98 | + g_assert(qdict_haskey(data, "action")); | ||
99 | + g_assert_cmpstr(qdict_get_str(data, "action"), ==, "pause"); | ||
100 | + qobject_unref(response); | ||
101 | + | ||
102 | + qtest_quit(qts); | ||
103 | +} | ||
104 | + | ||
105 | +int main(int argc, char **argv) | ||
106 | +{ | ||
114 | + int ret; | 107 | + int ret; |
115 | + | 108 | + |
116 | + if (!kvm_has_vcpu_events()) { | 109 | + g_test_init(&argc, &argv, NULL); |
117 | + return 0; | 110 | + qtest_add_func("/pvpanic-pci/panic", test_panic); |
118 | + } | 111 | + qtest_add_func("/pvpanic-pci/panic-nopause", test_panic_nopause); |
119 | + | 112 | + |
120 | + memset(&events, 0, sizeof(events)); | 113 | + ret = g_test_run(); |
121 | + events.exception.serror_pending = env->serror.pending; | ||
122 | + | ||
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 | + } | ||
130 | + | ||
131 | + ret = kvm_vcpu_ioctl(CPU(cpu), KVM_SET_VCPU_EVENTS, &events); | ||
132 | + if (ret) { | ||
133 | + error_report("failed to put vcpu events"); | ||
134 | + } | ||
135 | + | 114 | + |
136 | + return ret; | 115 | + return ret; |
137 | +} | 116 | +} |
138 | + | 117 | diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build |
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 | } | ||
166 | diff --git a/target/arm/kvm32.c b/target/arm/kvm32.c | ||
167 | index XXXXXXX..XXXXXXX 100644 | 118 | index XXXXXXX..XXXXXXX 100644 |
168 | --- a/target/arm/kvm32.c | 119 | --- a/tests/qtest/meson.build |
169 | +++ b/target/arm/kvm32.c | 120 | +++ b/tests/qtest/meson.build |
170 | @@ -XXX,XX +XXX,XX @@ int kvm_arch_init_vcpu(CPUState *cs) | 121 | @@ -XXX,XX +XXX,XX @@ qtests_i386 = \ |
171 | } | 122 | config_all_devices.has_key('CONFIG_ISA_IPMI_BT') ? ['ipmi-bt-test'] : []) + \ |
172 | cpu->mp_affinity = mpidr & ARM32_AFFINITY_MASK; | 123 | (config_all_devices.has_key('CONFIG_WDT_IB700') ? ['wdt_ib700-test'] : []) + \ |
173 | 124 | (config_all_devices.has_key('CONFIG_PVPANIC_ISA') ? ['pvpanic-test'] : []) + \ | |
174 | + /* Check whether userspace can specify guest syndrome value */ | 125 | + (config_all_devices.has_key('CONFIG_PVPANIC_PCI') ? ['pvpanic-pci-test'] : []) + \ |
175 | + kvm_arm_init_serror_injection(cs); | 126 | (config_all_devices.has_key('CONFIG_HDA') ? ['intel-hda-test'] : []) + \ |
176 | + | 127 | (config_all_devices.has_key('CONFIG_I82801B11') ? ['i82801b11-test'] : []) + \ |
177 | return kvm_arm_init_cpreg_list(cpu); | 128 | (config_all_devices.has_key('CONFIG_IOH3420') ? ['ioh3420-test'] : []) + \ |
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 | -- | 129 | -- |
283 | 2.19.1 | 130 | 2.20.1 |
284 | 131 | ||
285 | 132 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | The ptimer API currently provides two methods for setting the period: |
---|---|---|---|
2 | ptimer_set_period(), which takes a period in nanoseconds, and | ||
3 | ptimer_set_freq(), which takes a frequency in Hz. Neither of these | ||
4 | lines up nicely with the Clock API, because although both the Clock | ||
5 | and the ptimer track the frequency using a representation of whole | ||
6 | and fractional nanoseconds, conversion via either period-in-ns or | ||
7 | frequency-in-Hz will introduce a rounding error. | ||
2 | 8 | ||
3 | Move shi_op and sli_op expanders from translate-a64.c. | 9 | Add a new function ptimer_set_period_from_clock() which takes the |
10 | Clock object directly to avoid the rounding issues. This includes a | ||
11 | facility for the user to specify that there is a frequency divider | ||
12 | between the Clock proper and the timer, as some timer devices like | ||
13 | the CMSDK APB dualtimer need this. | ||
4 | 14 | ||
5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 15 | To avoid having to drag in clock.h from ptimer.h we add the Clock |
6 | Message-id: 20181011205206.3552-15-richard.henderson@linaro.org | 16 | type to typedefs.h. |
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 17 | |
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 18 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
19 | Reviewed-by: Luc Michel <luc@lmichel.fr> | ||
20 | Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
21 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
22 | Message-id: 20210128114145.20536-2-peter.maydell@linaro.org | ||
23 | Message-id: 20210121190622.22000-2-peter.maydell@linaro.org | ||
9 | --- | 24 | --- |
10 | target/arm/translate.h | 2 + | 25 | include/hw/ptimer.h | 22 ++++++++++++++++++++++ |
11 | target/arm/translate-a64.c | 152 +---------------------- | 26 | include/qemu/typedefs.h | 1 + |
12 | target/arm/translate.c | 244 ++++++++++++++++++++++++++----------- | 27 | hw/core/ptimer.c | 34 ++++++++++++++++++++++++++++++++++ |
13 | 3 files changed, 179 insertions(+), 219 deletions(-) | 28 | 3 files changed, 57 insertions(+) |
14 | 29 | ||
15 | diff --git a/target/arm/translate.h b/target/arm/translate.h | 30 | diff --git a/include/hw/ptimer.h b/include/hw/ptimer.h |
16 | index XXXXXXX..XXXXXXX 100644 | 31 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/translate.h | 32 | --- a/include/hw/ptimer.h |
18 | +++ b/target/arm/translate.h | 33 | +++ b/include/hw/ptimer.h |
19 | @@ -XXX,XX +XXX,XX @@ extern const GVecGen3 bit_op; | 34 | @@ -XXX,XX +XXX,XX @@ void ptimer_transaction_commit(ptimer_state *s); |
20 | extern const GVecGen3 bif_op; | 35 | */ |
21 | extern const GVecGen2i ssra_op[4]; | 36 | void ptimer_set_period(ptimer_state *s, int64_t period); |
22 | extern const GVecGen2i usra_op[4]; | 37 | |
23 | +extern const GVecGen2i sri_op[4]; | 38 | +/** |
24 | +extern const GVecGen2i sli_op[4]; | 39 | + * ptimer_set_period_from_clock - Set counter increment from a Clock |
25 | 40 | + * @s: ptimer to configure | |
26 | /* | 41 | + * @clk: pointer to Clock object to take period from |
27 | * Forward to the isar_feature_* tests given a DisasContext pointer. | 42 | + * @divisor: value to scale the clock frequency down by |
28 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 43 | + * |
44 | + * If the ptimer is being driven from a Clock, this is the preferred | ||
45 | + * way to tell the ptimer about the period, because it avoids any | ||
46 | + * possible rounding errors that might happen if the internal | ||
47 | + * representation of the Clock period was converted to either a period | ||
48 | + * in ns or a frequency in Hz. | ||
49 | + * | ||
50 | + * If the ptimer should run at the same frequency as the clock, | ||
51 | + * pass 1 as the @divisor; if the ptimer should run at half the | ||
52 | + * frequency, pass 2, and so on. | ||
53 | + * | ||
54 | + * This function will assert if it is called outside a | ||
55 | + * ptimer_transaction_begin/commit block. | ||
56 | + */ | ||
57 | +void ptimer_set_period_from_clock(ptimer_state *s, const Clock *clock, | ||
58 | + unsigned int divisor); | ||
59 | + | ||
60 | /** | ||
61 | * ptimer_set_freq - Set counter frequency in Hz | ||
62 | * @s: ptimer to configure | ||
63 | diff --git a/include/qemu/typedefs.h b/include/qemu/typedefs.h | ||
29 | index XXXXXXX..XXXXXXX 100644 | 64 | index XXXXXXX..XXXXXXX 100644 |
30 | --- a/target/arm/translate-a64.c | 65 | --- a/include/qemu/typedefs.h |
31 | +++ b/target/arm/translate-a64.c | 66 | +++ b/include/qemu/typedefs.h |
32 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_scalar_two_reg_misc(DisasContext *s, uint32_t insn) | 67 | @@ -XXX,XX +XXX,XX @@ typedef struct BlockDriverState BlockDriverState; |
68 | typedef struct BusClass BusClass; | ||
69 | typedef struct BusState BusState; | ||
70 | typedef struct Chardev Chardev; | ||
71 | +typedef struct Clock Clock; | ||
72 | typedef struct CompatProperty CompatProperty; | ||
73 | typedef struct CoMutex CoMutex; | ||
74 | typedef struct CPUAddressSpace CPUAddressSpace; | ||
75 | diff --git a/hw/core/ptimer.c b/hw/core/ptimer.c | ||
76 | index XXXXXXX..XXXXXXX 100644 | ||
77 | --- a/hw/core/ptimer.c | ||
78 | +++ b/hw/core/ptimer.c | ||
79 | @@ -XXX,XX +XXX,XX @@ | ||
80 | #include "sysemu/qtest.h" | ||
81 | #include "block/aio.h" | ||
82 | #include "sysemu/cpus.h" | ||
83 | +#include "hw/clock.h" | ||
84 | |||
85 | #define DELTA_ADJUST 1 | ||
86 | #define DELTA_NO_ADJUST -1 | ||
87 | @@ -XXX,XX +XXX,XX @@ void ptimer_set_period(ptimer_state *s, int64_t period) | ||
33 | } | 88 | } |
34 | } | 89 | } |
35 | 90 | ||
36 | -static void gen_shr8_ins_i64(TCGv_i64 d, TCGv_i64 a, int64_t shift) | 91 | +/* Set counter increment interval from a Clock */ |
37 | -{ | 92 | +void ptimer_set_period_from_clock(ptimer_state *s, const Clock *clk, |
38 | - uint64_t mask = dup_const(MO_8, 0xff >> shift); | 93 | + unsigned int divisor) |
39 | - TCGv_i64 t = tcg_temp_new_i64(); | ||
40 | - | ||
41 | - tcg_gen_shri_i64(t, a, shift); | ||
42 | - tcg_gen_andi_i64(t, t, mask); | ||
43 | - tcg_gen_andi_i64(d, d, ~mask); | ||
44 | - tcg_gen_or_i64(d, d, t); | ||
45 | - tcg_temp_free_i64(t); | ||
46 | -} | ||
47 | - | ||
48 | -static void gen_shr16_ins_i64(TCGv_i64 d, TCGv_i64 a, int64_t shift) | ||
49 | -{ | ||
50 | - uint64_t mask = dup_const(MO_16, 0xffff >> shift); | ||
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 | -} | ||
59 | - | ||
60 | -static void gen_shr32_ins_i32(TCGv_i32 d, TCGv_i32 a, int32_t shift) | ||
61 | -{ | ||
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 | { | ||
91 | - static const GVecGen2i sri_op[4] = { | ||
92 | - { .fni8 = gen_shr8_ins_i64, | ||
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 | } | ||
121 | |||
122 | -static void gen_shl8_ins_i64(TCGv_i64 d, TCGv_i64 a, int64_t shift) | ||
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 | +{ | 94 | +{ |
223 | + uint64_t mask = dup_const(MO_8, 0xff >> shift); | 95 | + /* |
224 | + TCGv_i64 t = tcg_temp_new_i64(); | 96 | + * The raw clock period is a 64-bit value in units of 2^-32 ns; |
97 | + * put another way it's a 32.32 fixed-point ns value. Our internal | ||
98 | + * representation of the period is 64.32 fixed point ns, so | ||
99 | + * the conversion is simple. | ||
100 | + */ | ||
101 | + uint64_t raw_period = clock_get(clk); | ||
102 | + uint64_t period_frac; | ||
225 | + | 103 | + |
226 | + tcg_gen_shri_i64(t, a, shift); | 104 | + assert(s->in_transaction); |
227 | + tcg_gen_andi_i64(t, t, mask); | 105 | + s->delta = ptimer_get_count(s); |
228 | + tcg_gen_andi_i64(d, d, ~mask); | 106 | + s->period = extract64(raw_period, 32, 32); |
229 | + tcg_gen_or_i64(d, d, t); | 107 | + period_frac = extract64(raw_period, 0, 32); |
230 | + tcg_temp_free_i64(t); | 108 | + /* |
231 | +} | 109 | + * divisor specifies a possible frequency divisor between the |
110 | + * clock and the timer, so it is a multiplier on the period. | ||
111 | + * We do the multiply after splitting the raw period out into | ||
112 | + * period and frac to avoid having to do a 32*64->96 multiply. | ||
113 | + */ | ||
114 | + s->period *= divisor; | ||
115 | + period_frac *= divisor; | ||
116 | + s->period += extract64(period_frac, 32, 32); | ||
117 | + s->period_frac = (uint32_t)period_frac; | ||
232 | + | 118 | + |
233 | +static void gen_shr16_ins_i64(TCGv_i64 d, TCGv_i64 a, int64_t shift) | 119 | + if (s->enabled) { |
234 | +{ | 120 | + s->need_reload = true; |
235 | + uint64_t mask = dup_const(MO_16, 0xffff >> shift); | ||
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 | +} | ||
244 | + | ||
245 | +static void gen_shr32_ins_i32(TCGv_i32 d, TCGv_i32 a, int32_t shift) | ||
246 | +{ | ||
247 | + tcg_gen_shri_i32(a, a, shift); | ||
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 | + } | 121 | + } |
273 | +} | 122 | +} |
274 | + | 123 | + |
275 | +const GVecGen2i sri_op[4] = { | 124 | /* Set counter frequency in Hz. */ |
276 | + { .fni8 = gen_shr8_ins_i64, | 125 | void ptimer_set_freq(ptimer_state *s, uint32_t freq) |
277 | + .fniv = gen_shr_ins_vec, | 126 | { |
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 | -- | 127 | -- |
520 | 2.19.1 | 128 | 2.20.1 |
521 | 129 | ||
522 | 130 | diff view generated by jsdifflib |
1 | For AArch32, exception return happens through certain kinds | 1 | Add a function for checking whether a clock has a source. This is |
---|---|---|---|
2 | of CPSR write. We don't currently have any CPU_LOG_INT logging | 2 | useful for devices which have input clocks that must be wired up by |
3 | of these events (unlike AArch64, where we log in the ERET | 3 | the board as it allows them to fail in realize rather than ploughing |
4 | instruction). Add some suitable logging. | 4 | on with a zero-period clock. |
5 | |||
6 | This will log exception returns like this: | ||
7 | Exception return from AArch32 hyp to usr PC 0x80100374 | ||
8 | |||
9 | paralleling the existing logging in the exception_return | ||
10 | helper for AArch64 exception returns: | ||
11 | Exception return from AArch64 EL2 to AArch64 EL0 PC 0x8003045c | ||
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 | 5 | ||
17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
18 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 7 | Reviewed-by: Luc Michel <luc@lmichel.fr> |
19 | Message-id: 20181012144235.19646-2-peter.maydell@linaro.org | 8 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
9 | Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
10 | Message-id: 20210128114145.20536-3-peter.maydell@linaro.org | ||
11 | Message-id: 20210121190622.22000-3-peter.maydell@linaro.org | ||
20 | --- | 12 | --- |
21 | target/arm/internals.h | 18 ++++++++++++++++++ | 13 | docs/devel/clocks.rst | 16 ++++++++++++++++ |
22 | target/arm/helper.c | 10 ++++++++++ | 14 | include/hw/clock.h | 15 +++++++++++++++ |
23 | target/arm/translate.c | 7 +------ | 15 | 2 files changed, 31 insertions(+) |
24 | 3 files changed, 29 insertions(+), 6 deletions(-) | ||
25 | 16 | ||
26 | diff --git a/target/arm/internals.h b/target/arm/internals.h | 17 | diff --git a/docs/devel/clocks.rst b/docs/devel/clocks.rst |
27 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
28 | --- a/target/arm/internals.h | 19 | --- a/docs/devel/clocks.rst |
29 | +++ b/target/arm/internals.h | 20 | +++ b/docs/devel/clocks.rst |
30 | @@ -XXX,XX +XXX,XX @@ static inline uint32_t v7m_sp_limit(CPUARMState *env) | 21 | @@ -XXX,XX +XXX,XX @@ object during device instance init. For example: |
31 | } | 22 | /* set initial value to 10ns / 100MHz */ |
32 | } | 23 | clock_set_ns(clk, 10); |
24 | |||
25 | +To enforce that the clock is wired up by the board code, you can | ||
26 | +call ``clock_has_source()`` in your device's realize method: | ||
27 | + | ||
28 | +.. code-block:: c | ||
29 | + | ||
30 | + if (!clock_has_source(s->clk)) { | ||
31 | + error_setg(errp, "MyDevice: clk input must be connected"); | ||
32 | + return; | ||
33 | + } | ||
34 | + | ||
35 | +Note that this only checks that the clock has been wired up; it is | ||
36 | +still possible that the output clock connected to it is disabled | ||
37 | +or has not yet been configured, in which case the period will be | ||
38 | +zero. You should use the clock callback to find out when the clock | ||
39 | +period changes. | ||
40 | + | ||
41 | Fetching clock frequency/period | ||
42 | ------------------------------- | ||
43 | |||
44 | diff --git a/include/hw/clock.h b/include/hw/clock.h | ||
45 | index XXXXXXX..XXXXXXX 100644 | ||
46 | --- a/include/hw/clock.h | ||
47 | +++ b/include/hw/clock.h | ||
48 | @@ -XXX,XX +XXX,XX @@ void clock_clear_callback(Clock *clk); | ||
49 | */ | ||
50 | void clock_set_source(Clock *clk, Clock *src); | ||
33 | 51 | ||
34 | +/** | 52 | +/** |
35 | + * aarch32_mode_name(): Return name of the AArch32 CPU mode | 53 | + * clock_has_source: |
36 | + * @psr: Program Status Register indicating CPU mode | 54 | + * @clk: the clock |
37 | + * | 55 | + * |
38 | + * Returns, for debug logging purposes, a printable representation | 56 | + * Returns true if the clock has a source clock connected to it. |
39 | + * of the AArch32 CPU mode ("svc", "usr", etc) as indicated by | 57 | + * This is useful for devices which have input clocks which must |
40 | + * the low bits of the specified PSR. | 58 | + * be connected by the board/SoC code which creates them. The |
59 | + * device code can use this to check in its realize method that | ||
60 | + * the clock has been connected. | ||
41 | + */ | 61 | + */ |
42 | +static inline const char *aarch32_mode_name(uint32_t psr) | 62 | +static inline bool clock_has_source(const Clock *clk) |
43 | +{ | 63 | +{ |
44 | + static const char cpu_mode_names[16][4] = { | 64 | + return clk->source != NULL; |
45 | + "usr", "fiq", "irq", "svc", "???", "???", "mon", "abt", | ||
46 | + "???", "???", "hyp", "und", "???", "???", "???", "sys" | ||
47 | + }; | ||
48 | + | ||
49 | + return cpu_mode_names[psr & 0xf]; | ||
50 | +} | 65 | +} |
51 | + | 66 | + |
52 | #endif | 67 | /** |
53 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 68 | * clock_set: |
54 | index XXXXXXX..XXXXXXX 100644 | 69 | * @clk: the clock to initialize. |
55 | --- a/target/arm/helper.c | ||
56 | +++ b/target/arm/helper.c | ||
57 | @@ -XXX,XX +XXX,XX @@ void cpsr_write(CPUARMState *env, uint32_t val, uint32_t mask, | ||
58 | mask |= CPSR_IL; | ||
59 | val |= CPSR_IL; | ||
60 | } | ||
61 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
62 | + "Illegal AArch32 mode switch attempt from %s to %s\n", | ||
63 | + aarch32_mode_name(env->uncached_cpsr), | ||
64 | + aarch32_mode_name(val)); | ||
65 | } else { | ||
66 | + qemu_log_mask(CPU_LOG_INT, "%s %s to %s PC 0x%" PRIx32 "\n", | ||
67 | + write_type == CPSRWriteExceptionReturn ? | ||
68 | + "Exception return from AArch32" : | ||
69 | + "AArch32 mode switch from", | ||
70 | + aarch32_mode_name(env->uncached_cpsr), | ||
71 | + aarch32_mode_name(val), env->regs[15]); | ||
72 | switch_mode(env, val & CPSR_M); | ||
73 | } | ||
74 | } | ||
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 | } | ||
82 | |||
83 | -static const char *cpu_mode_names[16] = { | ||
84 | - "usr", "fiq", "irq", "svc", "???", "???", "mon", "abt", | ||
85 | - "???", "???", "hyp", "und", "???", "???", "???", "sys" | ||
86 | -}; | ||
87 | - | ||
88 | void arm_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprintf, | ||
89 | int flags) | ||
90 | { | ||
91 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprintf, | ||
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 | } | ||
98 | |||
99 | if (flags & CPU_DUMP_FPU) { | ||
100 | -- | 70 | -- |
101 | 2.19.1 | 71 | 2.20.1 |
102 | 72 | ||
103 | 73 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | Add a simple test of the CMSDK APB timer, since we're about to do |
---|---|---|---|
2 | some refactoring of how it is clocked. | ||
2 | 3 | ||
3 | Also introduces neon_element_offset to find the env offset | 4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | of a specific element within a neon register. | 5 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
6 | Reviewed-by: Luc Michel <luc@lmichel.fr> | ||
7 | Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
8 | Message-id: 20210128114145.20536-4-peter.maydell@linaro.org | ||
9 | Message-id: 20210121190622.22000-4-peter.maydell@linaro.org | ||
10 | --- | ||
11 | tests/qtest/cmsdk-apb-timer-test.c | 75 ++++++++++++++++++++++++++++++ | ||
12 | MAINTAINERS | 1 + | ||
13 | tests/qtest/meson.build | 1 + | ||
14 | 3 files changed, 77 insertions(+) | ||
15 | create mode 100644 tests/qtest/cmsdk-apb-timer-test.c | ||
5 | 16 | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 17 | diff --git a/tests/qtest/cmsdk-apb-timer-test.c b/tests/qtest/cmsdk-apb-timer-test.c |
7 | Message-id: 20181011205206.3552-7-richard.henderson@linaro.org | 18 | new file mode 100644 |
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 19 | index XXXXXXX..XXXXXXX |
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 20 | --- /dev/null |
10 | --- | 21 | +++ b/tests/qtest/cmsdk-apb-timer-test.c |
11 | target/arm/translate.c | 63 ++++++++++++++++++++++++------------------ | 22 | @@ -XXX,XX +XXX,XX @@ |
12 | 1 file changed, 36 insertions(+), 27 deletions(-) | 23 | +/* |
13 | 24 | + * QTest testcase for the CMSDK APB timer device | |
14 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 25 | + * |
15 | index XXXXXXX..XXXXXXX 100644 | 26 | + * Copyright (c) 2021 Linaro Limited |
16 | --- a/target/arm/translate.c | 27 | + * |
17 | +++ b/target/arm/translate.c | 28 | + * This program is free software; you can redistribute it and/or modify it |
18 | @@ -XXX,XX +XXX,XX @@ neon_reg_offset (int reg, int n) | 29 | + * under the terms of the GNU General Public License as published by the |
19 | return vfp_reg_offset(0, sreg); | 30 | + * Free Software Foundation; either version 2 of the License, or |
20 | } | 31 | + * (at your option) any later version. |
21 | 32 | + * | |
22 | +/* Return the offset of a 2**SIZE piece of a NEON register, at index ELE, | 33 | + * This program is distributed in the hope that it will be useful, but WITHOUT |
23 | + * where 0 is the least significant end of the register. | 34 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
35 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
36 | + * for more details. | ||
24 | + */ | 37 | + */ |
25 | +static inline long | 38 | + |
26 | +neon_element_offset(int reg, int element, TCGMemOp size) | 39 | +#include "qemu/osdep.h" |
40 | +#include "libqtest-single.h" | ||
41 | + | ||
42 | +/* IoTKit/ARMSSE-200 timer0; driven at 25MHz in mps2-an385, so 40ns per tick */ | ||
43 | +#define TIMER_BASE 0x40000000 | ||
44 | + | ||
45 | +#define CTRL 0 | ||
46 | +#define VALUE 4 | ||
47 | +#define RELOAD 8 | ||
48 | +#define INTSTATUS 0xc | ||
49 | + | ||
50 | +static void test_timer(void) | ||
27 | +{ | 51 | +{ |
28 | + int element_size = 1 << size; | 52 | + g_assert_true(readl(TIMER_BASE + INTSTATUS) == 0); |
29 | + int ofs = element * element_size; | 53 | + |
30 | +#ifdef HOST_WORDS_BIGENDIAN | 54 | + /* Start timer: will fire after 40 * 1000 == 40000 ns */ |
31 | + /* Calculate the offset assuming fully little-endian, | 55 | + writel(TIMER_BASE + RELOAD, 1000); |
32 | + * then XOR to account for the order of the 8-byte units. | 56 | + writel(TIMER_BASE + CTRL, 9); |
33 | + */ | 57 | + |
34 | + if (element_size < 8) { | 58 | + /* Step to just past the 500th tick and check VALUE */ |
35 | + ofs ^= 8 - element_size; | 59 | + clock_step(40 * 500 + 1); |
36 | + } | 60 | + g_assert_cmpuint(readl(TIMER_BASE + INTSTATUS), ==, 0); |
37 | +#endif | 61 | + g_assert_cmpuint(readl(TIMER_BASE + VALUE), ==, 500); |
38 | + return neon_reg_offset(reg, 0) + ofs; | 62 | + |
63 | + /* Just past the 1000th tick: timer should have fired */ | ||
64 | + clock_step(40 * 500); | ||
65 | + g_assert_cmpuint(readl(TIMER_BASE + INTSTATUS), ==, 1); | ||
66 | + g_assert_cmpuint(readl(TIMER_BASE + VALUE), ==, 0); | ||
67 | + | ||
68 | + /* VALUE reloads at the following tick */ | ||
69 | + clock_step(40); | ||
70 | + g_assert_cmpuint(readl(TIMER_BASE + VALUE), ==, 1000); | ||
71 | + | ||
72 | + /* Check write-1-to-clear behaviour of INTSTATUS */ | ||
73 | + writel(TIMER_BASE + INTSTATUS, 0); | ||
74 | + g_assert_cmpuint(readl(TIMER_BASE + INTSTATUS), ==, 1); | ||
75 | + writel(TIMER_BASE + INTSTATUS, 1); | ||
76 | + g_assert_cmpuint(readl(TIMER_BASE + INTSTATUS), ==, 0); | ||
77 | + | ||
78 | + /* Turn off the timer */ | ||
79 | + writel(TIMER_BASE + CTRL, 0); | ||
39 | +} | 80 | +} |
40 | + | 81 | + |
41 | static TCGv_i32 neon_load_reg(int reg, int pass) | 82 | +int main(int argc, char **argv) |
42 | { | 83 | +{ |
43 | TCGv_i32 tmp = tcg_temp_new_i32(); | 84 | + int r; |
44 | @@ -XXX,XX +XXX,XX @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) | ||
45 | tmp = load_reg(s, rd); | ||
46 | if (insn & (1 << 23)) { | ||
47 | /* VDUP */ | ||
48 | - if (size == 0) { | ||
49 | - gen_neon_dup_u8(tmp, 0); | ||
50 | - } else if (size == 1) { | ||
51 | - gen_neon_dup_low16(tmp); | ||
52 | - } | ||
53 | - for (n = 0; n <= pass * 2; n++) { | ||
54 | - tmp2 = tcg_temp_new_i32(); | ||
55 | - tcg_gen_mov_i32(tmp2, tmp); | ||
56 | - neon_store_reg(rn, n, tmp2); | ||
57 | - } | ||
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 | + | 85 | + |
73 | if ((insn & (7 << 16)) == 0 || (q && (rd & 1))) { | 86 | + g_test_init(&argc, &argv, NULL); |
74 | return 1; | 87 | + |
75 | } | 88 | + qtest_start("-machine mps2-an385"); |
76 | - if (insn & (1 << 19)) { | 89 | + |
77 | - tmp = neon_load_reg(rm, 1); | 90 | + qtest_add_func("/cmsdk-apb-timer/timer", test_timer); |
78 | - } else { | 91 | + |
79 | - tmp = neon_load_reg(rm, 0); | 92 | + r = g_test_run(); |
80 | - } | 93 | + |
81 | if (insn & (1 << 16)) { | 94 | + qtest_end(); |
82 | - gen_neon_dup_u8(tmp, ((insn >> 17) & 3) * 8); | 95 | + |
83 | + size = MO_8; | 96 | + return r; |
84 | + element = (insn >> 17) & 7; | 97 | +} |
85 | } else if (insn & (1 << 17)) { | 98 | diff --git a/MAINTAINERS b/MAINTAINERS |
86 | - if ((insn >> 18) & 1) | 99 | index XXXXXXX..XXXXXXX 100644 |
87 | - gen_neon_dup_high16(tmp); | 100 | --- a/MAINTAINERS |
88 | - else | 101 | +++ b/MAINTAINERS |
89 | - gen_neon_dup_low16(tmp); | 102 | @@ -XXX,XX +XXX,XX @@ F: include/hw/rtc/pl031.h |
90 | + size = MO_16; | 103 | F: include/hw/arm/primecell.h |
91 | + element = (insn >> 18) & 3; | 104 | F: hw/timer/cmsdk-apb-timer.c |
92 | + } else { | 105 | F: include/hw/timer/cmsdk-apb-timer.h |
93 | + size = MO_32; | 106 | +F: tests/qtest/cmsdk-apb-timer-test.c |
94 | + element = (insn >> 19) & 1; | 107 | F: hw/timer/cmsdk-apb-dualtimer.c |
95 | } | 108 | F: include/hw/timer/cmsdk-apb-dualtimer.h |
96 | - for (pass = 0; pass < (q ? 4 : 2); pass++) { | 109 | F: hw/char/cmsdk-apb-uart.c |
97 | - tmp2 = tcg_temp_new_i32(); | 110 | diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build |
98 | - tcg_gen_mov_i32(tmp2, tmp); | 111 | index XXXXXXX..XXXXXXX 100644 |
99 | - neon_store_reg(rd, pass, tmp2); | 112 | --- a/tests/qtest/meson.build |
100 | - } | 113 | +++ b/tests/qtest/meson.build |
101 | - tcg_temp_free_i32(tmp); | 114 | @@ -XXX,XX +XXX,XX @@ qtests_npcm7xx = \ |
102 | + tcg_gen_gvec_dup_mem(size, neon_reg_offset(rd, 0), | 115 | 'npcm7xx_timer-test', |
103 | + neon_element_offset(rm, element, size), | 116 | 'npcm7xx_watchdog_timer-test'] |
104 | + q ? 16 : 8, q ? 16 : 8); | 117 | qtests_arm = \ |
105 | } else { | 118 | + (config_all_devices.has_key('CONFIG_CMSDK_APB_TIMER') ? ['cmsdk-apb-timer-test'] : []) + \ |
106 | return 1; | 119 | (config_all_devices.has_key('CONFIG_PFLASH_CFI02') ? ['pflash-cfi02-test'] : []) + \ |
107 | } | 120 | (config_all_devices.has_key('CONFIG_NPCM7XX') ? qtests_npcm7xx : []) + \ |
121 | ['arm-cpu-features', | ||
108 | -- | 122 | -- |
109 | 2.19.1 | 123 | 2.20.1 |
110 | 124 | ||
111 | 125 | diff view generated by jsdifflib |
1 | Create and use a utility function to extract the EC field | 1 | Add a simple test of the CMSDK watchdog, since we're about to do some |
---|---|---|---|
2 | from a syndrome, rather than open-coding the shift. | 2 | refactoring of how it is clocked. |
3 | 3 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 5 | Reviewed-by: Luc Michel <luc@lmichel.fr> |
6 | Message-id: 20181012144235.19646-9-peter.maydell@linaro.org | 6 | Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
7 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
8 | Message-id: 20210128114145.20536-5-peter.maydell@linaro.org | ||
9 | Message-id: 20210121190622.22000-5-peter.maydell@linaro.org | ||
10 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
7 | --- | 11 | --- |
8 | target/arm/internals.h | 5 +++++ | 12 | tests/qtest/cmsdk-apb-watchdog-test.c | 79 +++++++++++++++++++++++++++ |
9 | target/arm/helper.c | 4 ++-- | 13 | MAINTAINERS | 1 + |
10 | target/arm/kvm64.c | 2 +- | 14 | tests/qtest/meson.build | 1 + |
11 | target/arm/op_helper.c | 2 +- | 15 | 3 files changed, 81 insertions(+) |
12 | 4 files changed, 9 insertions(+), 4 deletions(-) | 16 | create mode 100644 tests/qtest/cmsdk-apb-watchdog-test.c |
13 | 17 | ||
14 | diff --git a/target/arm/internals.h b/target/arm/internals.h | 18 | diff --git a/tests/qtest/cmsdk-apb-watchdog-test.c b/tests/qtest/cmsdk-apb-watchdog-test.c |
15 | index XXXXXXX..XXXXXXX 100644 | 19 | new file mode 100644 |
16 | --- a/target/arm/internals.h | 20 | index XXXXXXX..XXXXXXX |
17 | +++ b/target/arm/internals.h | 21 | --- /dev/null |
18 | @@ -XXX,XX +XXX,XX @@ enum arm_exception_class { | 22 | +++ b/tests/qtest/cmsdk-apb-watchdog-test.c |
19 | #define ARM_EL_IL (1 << ARM_EL_IL_SHIFT) | 23 | @@ -XXX,XX +XXX,XX @@ |
20 | #define ARM_EL_ISV (1 << ARM_EL_ISV_SHIFT) | 24 | +/* |
21 | 25 | + * QTest testcase for the CMSDK APB watchdog device | |
22 | +static inline uint32_t syn_get_ec(uint32_t syn) | 26 | + * |
27 | + * Copyright (c) 2021 Linaro Limited | ||
28 | + * | ||
29 | + * This program is free software; you can redistribute it and/or modify it | ||
30 | + * under the terms of the GNU General Public License as published by the | ||
31 | + * Free Software Foundation; either version 2 of the License, or | ||
32 | + * (at your option) any later version. | ||
33 | + * | ||
34 | + * This program is distributed in the hope that it will be useful, but WITHOUT | ||
35 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
36 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
37 | + * for more details. | ||
38 | + */ | ||
39 | + | ||
40 | +#include "qemu/osdep.h" | ||
41 | +#include "libqtest-single.h" | ||
42 | + | ||
43 | +/* | ||
44 | + * lm3s811evb watchdog; at board startup this runs at 200MHz / 16 == 12.5MHz, | ||
45 | + * which is 80ns per tick. | ||
46 | + */ | ||
47 | +#define WDOG_BASE 0x40000000 | ||
48 | + | ||
49 | +#define WDOGLOAD 0 | ||
50 | +#define WDOGVALUE 4 | ||
51 | +#define WDOGCONTROL 8 | ||
52 | +#define WDOGINTCLR 0xc | ||
53 | +#define WDOGRIS 0x10 | ||
54 | +#define WDOGMIS 0x14 | ||
55 | +#define WDOGLOCK 0xc00 | ||
56 | + | ||
57 | +static void test_watchdog(void) | ||
23 | +{ | 58 | +{ |
24 | + return syn >> ARM_EL_EC_SHIFT; | 59 | + g_assert_cmpuint(readl(WDOG_BASE + WDOGRIS), ==, 0); |
60 | + | ||
61 | + writel(WDOG_BASE + WDOGCONTROL, 1); | ||
62 | + writel(WDOG_BASE + WDOGLOAD, 1000); | ||
63 | + | ||
64 | + /* Step to just past the 500th tick */ | ||
65 | + clock_step(500 * 80 + 1); | ||
66 | + g_assert_cmpuint(readl(WDOG_BASE + WDOGRIS), ==, 0); | ||
67 | + g_assert_cmpuint(readl(WDOG_BASE + WDOGVALUE), ==, 500); | ||
68 | + | ||
69 | + /* Just past the 1000th tick: timer should have fired */ | ||
70 | + clock_step(500 * 80); | ||
71 | + g_assert_cmpuint(readl(WDOG_BASE + WDOGRIS), ==, 1); | ||
72 | + g_assert_cmpuint(readl(WDOG_BASE + WDOGVALUE), ==, 0); | ||
73 | + | ||
74 | + /* VALUE reloads at following tick */ | ||
75 | + clock_step(80); | ||
76 | + g_assert_cmpuint(readl(WDOG_BASE + WDOGVALUE), ==, 1000); | ||
77 | + | ||
78 | + /* Writing any value to WDOGINTCLR clears the interrupt and reloads */ | ||
79 | + clock_step(500 * 80); | ||
80 | + g_assert_cmpuint(readl(WDOG_BASE + WDOGVALUE), ==, 500); | ||
81 | + g_assert_cmpuint(readl(WDOG_BASE + WDOGRIS), ==, 1); | ||
82 | + writel(WDOG_BASE + WDOGINTCLR, 0); | ||
83 | + g_assert_cmpuint(readl(WDOG_BASE + WDOGVALUE), ==, 1000); | ||
84 | + g_assert_cmpuint(readl(WDOG_BASE + WDOGRIS), ==, 0); | ||
25 | +} | 85 | +} |
26 | + | 86 | + |
27 | /* Utility functions for constructing various kinds of syndrome value. | 87 | +int main(int argc, char **argv) |
28 | * Note that in general we follow the AArch64 syndrome values; in a | 88 | +{ |
29 | * few cases the value in HSR for exceptions taken to AArch32 Hyp | 89 | + int r; |
30 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 90 | + |
91 | + g_test_init(&argc, &argv, NULL); | ||
92 | + | ||
93 | + qtest_start("-machine lm3s811evb"); | ||
94 | + | ||
95 | + qtest_add_func("/cmsdk-apb-watchdog/watchdog", test_watchdog); | ||
96 | + | ||
97 | + r = g_test_run(); | ||
98 | + | ||
99 | + qtest_end(); | ||
100 | + | ||
101 | + return r; | ||
102 | +} | ||
103 | diff --git a/MAINTAINERS b/MAINTAINERS | ||
31 | index XXXXXXX..XXXXXXX 100644 | 104 | index XXXXXXX..XXXXXXX 100644 |
32 | --- a/target/arm/helper.c | 105 | --- a/MAINTAINERS |
33 | +++ b/target/arm/helper.c | 106 | +++ b/MAINTAINERS |
34 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_do_interrupt_aarch32(CPUState *cs) | 107 | @@ -XXX,XX +XXX,XX @@ F: hw/char/cmsdk-apb-uart.c |
35 | uint32_t moe; | 108 | F: include/hw/char/cmsdk-apb-uart.h |
36 | 109 | F: hw/watchdog/cmsdk-apb-watchdog.c | |
37 | /* If this is a debug exception we must update the DBGDSCR.MOE bits */ | 110 | F: include/hw/watchdog/cmsdk-apb-watchdog.h |
38 | - switch (env->exception.syndrome >> ARM_EL_EC_SHIFT) { | 111 | +F: tests/qtest/cmsdk-apb-watchdog-test.c |
39 | + switch (syn_get_ec(env->exception.syndrome)) { | 112 | F: hw/misc/tz-ppc.c |
40 | case EC_BREAKPOINT: | 113 | F: include/hw/misc/tz-ppc.h |
41 | case EC_BREAKPOINT_SAME_EL: | 114 | F: hw/misc/tz-mpc.c |
42 | moe = 1; | 115 | diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build |
43 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_do_interrupt(CPUState *cs) | ||
44 | if (qemu_loglevel_mask(CPU_LOG_INT) | ||
45 | && !excp_is_internal(cs->exception_index)) { | ||
46 | qemu_log_mask(CPU_LOG_INT, "...with ESR 0x%x/0x%" PRIx32 "\n", | ||
47 | - env->exception.syndrome >> ARM_EL_EC_SHIFT, | ||
48 | + syn_get_ec(env->exception.syndrome), | ||
49 | env->exception.syndrome); | ||
50 | } | ||
51 | |||
52 | diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c | ||
53 | index XXXXXXX..XXXXXXX 100644 | 116 | index XXXXXXX..XXXXXXX 100644 |
54 | --- a/target/arm/kvm64.c | 117 | --- a/tests/qtest/meson.build |
55 | +++ b/target/arm/kvm64.c | 118 | +++ b/tests/qtest/meson.build |
56 | @@ -XXX,XX +XXX,XX @@ int kvm_arch_remove_sw_breakpoint(CPUState *cs, struct kvm_sw_breakpoint *bp) | 119 | @@ -XXX,XX +XXX,XX @@ qtests_npcm7xx = \ |
57 | 120 | 'npcm7xx_watchdog_timer-test'] | |
58 | bool kvm_arm_handle_debug(CPUState *cs, struct kvm_debug_exit_arch *debug_exit) | 121 | qtests_arm = \ |
59 | { | 122 | (config_all_devices.has_key('CONFIG_CMSDK_APB_TIMER') ? ['cmsdk-apb-timer-test'] : []) + \ |
60 | - int hsr_ec = debug_exit->hsr >> ARM_EL_EC_SHIFT; | 123 | + (config_all_devices.has_key('CONFIG_CMSDK_APB_WATCHDOG') ? ['cmsdk-apb-watchdog-test'] : []) + \ |
61 | + int hsr_ec = syn_get_ec(debug_exit->hsr); | 124 | (config_all_devices.has_key('CONFIG_PFLASH_CFI02') ? ['pflash-cfi02-test'] : []) + \ |
62 | ARMCPU *cpu = ARM_CPU(cs); | 125 | (config_all_devices.has_key('CONFIG_NPCM7XX') ? qtests_npcm7xx : []) + \ |
63 | CPUClass *cc = CPU_GET_CLASS(cs); | 126 | ['arm-cpu-features', |
64 | CPUARMState *env = &cpu->env; | ||
65 | diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c | ||
66 | index XXXXXXX..XXXXXXX 100644 | ||
67 | --- a/target/arm/op_helper.c | ||
68 | +++ b/target/arm/op_helper.c | ||
69 | @@ -XXX,XX +XXX,XX @@ void raise_exception(CPUARMState *env, uint32_t excp, | ||
70 | * (see DDI0478C.a D1.10.4) | ||
71 | */ | ||
72 | target_el = 2; | ||
73 | - if (syndrome >> ARM_EL_EC_SHIFT == EC_ADVSIMDFPACCESSTRAP) { | ||
74 | + if (syn_get_ec(syndrome) == EC_ADVSIMDFPACCESSTRAP) { | ||
75 | syndrome = syn_uncategorized(); | ||
76 | } | ||
77 | } | ||
78 | -- | 127 | -- |
79 | 2.19.1 | 128 | 2.20.1 |
80 | 129 | ||
81 | 130 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | Add a simple test of the CMSDK dual timer, since we're about to do |
---|---|---|---|
2 | some refactoring of how it is clocked. | ||
2 | 3 | ||
3 | Both arm and thumb2 division are controlled by the same ISAR field, | 4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | which takes care of the arm implies thumb case. Having M imply | 5 | Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
5 | thumb2 division was wrong for cortex-m0, which is v6m and does not | 6 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
6 | have thumb2 at all, much less thumb2 division. | 7 | Reviewed-by: Luc Michel <luc@lmichel.fr> |
8 | Message-id: 20210128114145.20536-6-peter.maydell@linaro.org | ||
9 | Message-id: 20210121190622.22000-6-peter.maydell@linaro.org | ||
10 | --- | ||
11 | tests/qtest/cmsdk-apb-dualtimer-test.c | 130 +++++++++++++++++++++++++ | ||
12 | MAINTAINERS | 1 + | ||
13 | tests/qtest/meson.build | 1 + | ||
14 | 3 files changed, 132 insertions(+) | ||
15 | create mode 100644 tests/qtest/cmsdk-apb-dualtimer-test.c | ||
7 | 16 | ||
8 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 17 | diff --git a/tests/qtest/cmsdk-apb-dualtimer-test.c b/tests/qtest/cmsdk-apb-dualtimer-test.c |
9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 18 | new file mode 100644 |
10 | Message-id: 20181016223115.24100-5-richard.henderson@linaro.org | 19 | index XXXXXXX..XXXXXXX |
11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 20 | --- /dev/null |
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 21 | +++ b/tests/qtest/cmsdk-apb-dualtimer-test.c |
13 | --- | 22 | @@ -XXX,XX +XXX,XX @@ |
14 | target/arm/cpu.h | 12 ++++++++++-- | 23 | +/* |
15 | linux-user/elfload.c | 4 ++-- | 24 | + * QTest testcase for the CMSDK APB dualtimer device |
16 | target/arm/cpu.c | 10 +--------- | 25 | + * |
17 | target/arm/translate.c | 4 ++-- | 26 | + * Copyright (c) 2021 Linaro Limited |
18 | 4 files changed, 15 insertions(+), 15 deletions(-) | 27 | + * |
19 | 28 | + * This program is free software; you can redistribute it and/or modify it | |
20 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 29 | + * under the terms of the GNU General Public License as published by the |
21 | index XXXXXXX..XXXXXXX 100644 | 30 | + * Free Software Foundation; either version 2 of the License, or |
22 | --- a/target/arm/cpu.h | 31 | + * (at your option) any later version. |
23 | +++ b/target/arm/cpu.h | 32 | + * |
24 | @@ -XXX,XX +XXX,XX @@ enum arm_features { | 33 | + * This program is distributed in the hope that it will be useful, but WITHOUT |
25 | ARM_FEATURE_VFP3, | 34 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
26 | ARM_FEATURE_VFP_FP16, | 35 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
27 | ARM_FEATURE_NEON, | 36 | + * for more details. |
28 | - ARM_FEATURE_THUMB_DIV, /* divide supported in Thumb encoding */ | 37 | + */ |
29 | ARM_FEATURE_M, /* Microcontroller profile. */ | 38 | + |
30 | ARM_FEATURE_OMAPCP, /* OMAP specific CP15 ops handling. */ | 39 | +#include "qemu/osdep.h" |
31 | ARM_FEATURE_THUMB2EE, | 40 | +#include "libqtest-single.h" |
32 | @@ -XXX,XX +XXX,XX @@ enum arm_features { | 41 | + |
33 | ARM_FEATURE_V5, | 42 | +/* IoTKit/ARMSSE dualtimer; driven at 25MHz in mps2-an385, so 40ns per tick */ |
34 | ARM_FEATURE_STRONGARM, | 43 | +#define TIMER_BASE 0x40002000 |
35 | ARM_FEATURE_VAPA, /* cp15 VA to PA lookups */ | 44 | + |
36 | - ARM_FEATURE_ARM_DIV, /* divide supported in ARM encoding */ | 45 | +#define TIMER1LOAD 0 |
37 | ARM_FEATURE_VFP4, /* VFPv4 (implies that NEON is v2) */ | 46 | +#define TIMER1VALUE 4 |
38 | ARM_FEATURE_GENERIC_TIMER, | 47 | +#define TIMER1CONTROL 8 |
39 | ARM_FEATURE_MVFR, /* Media and VFP Feature Registers 0 and 1 */ | 48 | +#define TIMER1INTCLR 0xc |
40 | @@ -XXX,XX +XXX,XX @@ extern const uint64_t pred_esz_masks[4]; | 49 | +#define TIMER1RIS 0x10 |
41 | /* | 50 | +#define TIMER1MIS 0x14 |
42 | * 32-bit feature tests via id registers. | 51 | +#define TIMER1BGLOAD 0x18 |
43 | */ | 52 | + |
44 | +static inline bool isar_feature_thumb_div(const ARMISARegisters *id) | 53 | +#define TIMER2LOAD 0x20 |
54 | +#define TIMER2VALUE 0x24 | ||
55 | +#define TIMER2CONTROL 0x28 | ||
56 | +#define TIMER2INTCLR 0x2c | ||
57 | +#define TIMER2RIS 0x30 | ||
58 | +#define TIMER2MIS 0x34 | ||
59 | +#define TIMER2BGLOAD 0x38 | ||
60 | + | ||
61 | +#define CTRL_ENABLE (1 << 7) | ||
62 | +#define CTRL_PERIODIC (1 << 6) | ||
63 | +#define CTRL_INTEN (1 << 5) | ||
64 | +#define CTRL_PRESCALE_1 (0 << 2) | ||
65 | +#define CTRL_PRESCALE_16 (1 << 2) | ||
66 | +#define CTRL_PRESCALE_256 (2 << 2) | ||
67 | +#define CTRL_32BIT (1 << 1) | ||
68 | +#define CTRL_ONESHOT (1 << 0) | ||
69 | + | ||
70 | +static void test_dualtimer(void) | ||
45 | +{ | 71 | +{ |
46 | + return FIELD_EX32(id->id_isar0, ID_ISAR0, DIVIDE) != 0; | 72 | + g_assert_true(readl(TIMER_BASE + TIMER1RIS) == 0); |
73 | + | ||
74 | + /* Start timer: will fire after 40000 ns */ | ||
75 | + writel(TIMER_BASE + TIMER1LOAD, 1000); | ||
76 | + /* enable in free-running, wrapping, interrupt mode */ | ||
77 | + writel(TIMER_BASE + TIMER1CONTROL, CTRL_ENABLE | CTRL_INTEN); | ||
78 | + | ||
79 | + /* Step to just past the 500th tick and check VALUE */ | ||
80 | + clock_step(500 * 40 + 1); | ||
81 | + g_assert_cmpuint(readl(TIMER_BASE + TIMER1RIS), ==, 0); | ||
82 | + g_assert_cmpuint(readl(TIMER_BASE + TIMER1VALUE), ==, 500); | ||
83 | + | ||
84 | + /* Just past the 1000th tick: timer should have fired */ | ||
85 | + clock_step(500 * 40); | ||
86 | + g_assert_cmpuint(readl(TIMER_BASE + TIMER1RIS), ==, 1); | ||
87 | + g_assert_cmpuint(readl(TIMER_BASE + TIMER1VALUE), ==, 0); | ||
88 | + | ||
89 | + /* | ||
90 | + * We are in free-running wrapping 16-bit mode, so on the following | ||
91 | + * tick VALUE should have wrapped round to 0xffff. | ||
92 | + */ | ||
93 | + clock_step(40); | ||
94 | + g_assert_cmpuint(readl(TIMER_BASE + TIMER1VALUE), ==, 0xffff); | ||
95 | + | ||
96 | + /* Check that any write to INTCLR clears interrupt */ | ||
97 | + writel(TIMER_BASE + TIMER1INTCLR, 1); | ||
98 | + g_assert_cmpuint(readl(TIMER_BASE + TIMER1RIS), ==, 0); | ||
99 | + | ||
100 | + /* Turn off the timer */ | ||
101 | + writel(TIMER_BASE + TIMER1CONTROL, 0); | ||
47 | +} | 102 | +} |
48 | + | 103 | + |
49 | +static inline bool isar_feature_arm_div(const ARMISARegisters *id) | 104 | +static void test_prescale(void) |
50 | +{ | 105 | +{ |
51 | + return FIELD_EX32(id->id_isar0, ID_ISAR0, DIVIDE) > 1; | 106 | + g_assert_true(readl(TIMER_BASE + TIMER2RIS) == 0); |
107 | + | ||
108 | + /* Start timer: will fire after 40 * 256 * 1000 == 1024000 ns */ | ||
109 | + writel(TIMER_BASE + TIMER2LOAD, 1000); | ||
110 | + /* enable in periodic, wrapping, interrupt mode, prescale 256 */ | ||
111 | + writel(TIMER_BASE + TIMER2CONTROL, | ||
112 | + CTRL_ENABLE | CTRL_INTEN | CTRL_PERIODIC | CTRL_PRESCALE_256); | ||
113 | + | ||
114 | + /* Step to just past the 500th tick and check VALUE */ | ||
115 | + clock_step(40 * 256 * 501); | ||
116 | + g_assert_cmpuint(readl(TIMER_BASE + TIMER2RIS), ==, 0); | ||
117 | + g_assert_cmpuint(readl(TIMER_BASE + TIMER2VALUE), ==, 500); | ||
118 | + | ||
119 | + /* Just past the 1000th tick: timer should have fired */ | ||
120 | + clock_step(40 * 256 * 500); | ||
121 | + g_assert_cmpuint(readl(TIMER_BASE + TIMER2RIS), ==, 1); | ||
122 | + g_assert_cmpuint(readl(TIMER_BASE + TIMER2VALUE), ==, 0); | ||
123 | + | ||
124 | + /* In periodic mode the tick VALUE now reloads */ | ||
125 | + clock_step(40 * 256); | ||
126 | + g_assert_cmpuint(readl(TIMER_BASE + TIMER2VALUE), ==, 1000); | ||
127 | + | ||
128 | + /* Check that any write to INTCLR clears interrupt */ | ||
129 | + writel(TIMER_BASE + TIMER2INTCLR, 1); | ||
130 | + g_assert_cmpuint(readl(TIMER_BASE + TIMER2RIS), ==, 0); | ||
131 | + | ||
132 | + /* Turn off the timer */ | ||
133 | + writel(TIMER_BASE + TIMER2CONTROL, 0); | ||
52 | +} | 134 | +} |
53 | + | 135 | + |
54 | static inline bool isar_feature_aa32_aes(const ARMISARegisters *id) | 136 | +int main(int argc, char **argv) |
55 | { | 137 | +{ |
56 | return FIELD_EX32(id->id_isar5, ID_ISAR5, AES) != 0; | 138 | + int r; |
57 | diff --git a/linux-user/elfload.c b/linux-user/elfload.c | 139 | + |
140 | + g_test_init(&argc, &argv, NULL); | ||
141 | + | ||
142 | + qtest_start("-machine mps2-an385"); | ||
143 | + | ||
144 | + qtest_add_func("/cmsdk-apb-dualtimer/dualtimer", test_dualtimer); | ||
145 | + qtest_add_func("/cmsdk-apb-dualtimer/prescale", test_prescale); | ||
146 | + | ||
147 | + r = g_test_run(); | ||
148 | + | ||
149 | + qtest_end(); | ||
150 | + | ||
151 | + return r; | ||
152 | +} | ||
153 | diff --git a/MAINTAINERS b/MAINTAINERS | ||
58 | index XXXXXXX..XXXXXXX 100644 | 154 | index XXXXXXX..XXXXXXX 100644 |
59 | --- a/linux-user/elfload.c | 155 | --- a/MAINTAINERS |
60 | +++ b/linux-user/elfload.c | 156 | +++ b/MAINTAINERS |
61 | @@ -XXX,XX +XXX,XX @@ static uint32_t get_elf_hwcap(void) | 157 | @@ -XXX,XX +XXX,XX @@ F: include/hw/timer/cmsdk-apb-timer.h |
62 | GET_FEATURE(ARM_FEATURE_VFP3, ARM_HWCAP_ARM_VFPv3); | 158 | F: tests/qtest/cmsdk-apb-timer-test.c |
63 | GET_FEATURE(ARM_FEATURE_V6K, ARM_HWCAP_ARM_TLS); | 159 | F: hw/timer/cmsdk-apb-dualtimer.c |
64 | GET_FEATURE(ARM_FEATURE_VFP4, ARM_HWCAP_ARM_VFPv4); | 160 | F: include/hw/timer/cmsdk-apb-dualtimer.h |
65 | - GET_FEATURE(ARM_FEATURE_ARM_DIV, ARM_HWCAP_ARM_IDIVA); | 161 | +F: tests/qtest/cmsdk-apb-dualtimer-test.c |
66 | - GET_FEATURE(ARM_FEATURE_THUMB_DIV, ARM_HWCAP_ARM_IDIVT); | 162 | F: hw/char/cmsdk-apb-uart.c |
67 | + GET_FEATURE_ID(arm_div, ARM_HWCAP_ARM_IDIVA); | 163 | F: include/hw/char/cmsdk-apb-uart.h |
68 | + GET_FEATURE_ID(thumb_div, ARM_HWCAP_ARM_IDIVT); | 164 | F: hw/watchdog/cmsdk-apb-watchdog.c |
69 | /* All QEMU's VFPv3 CPUs have 32 registers, see VFP_DREG in translate.c. | 165 | diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build |
70 | * Note that the ARM_HWCAP_ARM_VFPv3D16 bit is always the inverse of | ||
71 | * ARM_HWCAP_ARM_VFPD32 (and so always clear for QEMU); it is unrelated | ||
72 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | ||
73 | index XXXXXXX..XXXXXXX 100644 | 166 | index XXXXXXX..XXXXXXX 100644 |
74 | --- a/target/arm/cpu.c | 167 | --- a/tests/qtest/meson.build |
75 | +++ b/target/arm/cpu.c | 168 | +++ b/tests/qtest/meson.build |
76 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) | 169 | @@ -XXX,XX +XXX,XX @@ qtests_npcm7xx = \ |
77 | * Presence of EL2 itself is ARM_FEATURE_EL2, and of the | 170 | 'npcm7xx_timer-test', |
78 | * Security Extensions is ARM_FEATURE_EL3. | 171 | 'npcm7xx_watchdog_timer-test'] |
79 | */ | 172 | qtests_arm = \ |
80 | - set_feature(env, ARM_FEATURE_ARM_DIV); | 173 | + (config_all_devices.has_key('CONFIG_CMSDK_APB_DUALTIMER') ? ['cmsdk-apb-dualtimer-test'] : []) + \ |
81 | + assert(cpu_isar_feature(arm_div, cpu)); | 174 | (config_all_devices.has_key('CONFIG_CMSDK_APB_TIMER') ? ['cmsdk-apb-timer-test'] : []) + \ |
82 | set_feature(env, ARM_FEATURE_LPAE); | 175 | (config_all_devices.has_key('CONFIG_CMSDK_APB_WATCHDOG') ? ['cmsdk-apb-watchdog-test'] : []) + \ |
83 | set_feature(env, ARM_FEATURE_V7); | 176 | (config_all_devices.has_key('CONFIG_PFLASH_CFI02') ? ['pflash-cfi02-test'] : []) + \ |
84 | } | ||
85 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) | ||
86 | if (arm_feature(env, ARM_FEATURE_V5)) { | ||
87 | set_feature(env, ARM_FEATURE_V4T); | ||
88 | } | ||
89 | - if (arm_feature(env, ARM_FEATURE_M)) { | ||
90 | - set_feature(env, ARM_FEATURE_THUMB_DIV); | ||
91 | - } | ||
92 | - if (arm_feature(env, ARM_FEATURE_ARM_DIV)) { | ||
93 | - set_feature(env, ARM_FEATURE_THUMB_DIV); | ||
94 | - } | ||
95 | if (arm_feature(env, ARM_FEATURE_VFP4)) { | ||
96 | set_feature(env, ARM_FEATURE_VFP3); | ||
97 | set_feature(env, ARM_FEATURE_VFP_FP16); | ||
98 | @@ -XXX,XX +XXX,XX @@ static void cortex_r5_initfn(Object *obj) | ||
99 | ARMCPU *cpu = ARM_CPU(obj); | ||
100 | |||
101 | set_feature(&cpu->env, ARM_FEATURE_V7); | ||
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 | -- | 177 | -- |
130 | 2.19.1 | 178 | 2.20.1 |
131 | 179 | ||
132 | 180 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | The state struct for the CMSDK APB timer device doesn't follow our |
---|---|---|---|
2 | usual naming convention of camelcase -- "CMSDK" and "APB" are both | ||
3 | acronyms, but "TIMER" is not so should not be all-uppercase. | ||
4 | Globally rename the struct to "CMSDKAPBTimer" (bringing it into line | ||
5 | with CMSDKAPBWatchdog and CMSDKAPBDualTimer; CMSDKAPBUART remains | ||
6 | as-is because "UART" is an acronym). | ||
2 | 7 | ||
3 | Instead of shifts and masks, use direct loads and stores from the neon | 8 | Commit created with: |
4 | register file. Mirror the iteration structure of the ARM pseudocode | 9 | perl -p -i -e 's/CMSDKAPBTIMER/CMSDKAPBTimer/g' hw/timer/cmsdk-apb-timer.c include/hw/arm/armsse.h include/hw/timer/cmsdk-apb-timer.h |
5 | more closely. Correct the parameters of the VLD2 A2 insn. | ||
6 | 10 | ||
7 | Note that this includes a bugfix for handling of the insn | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | "VLD2 (multiple 2-element structures)" -- we were using an | 12 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
9 | incorrect stride value. | 13 | Reviewed-by: Luc Michel <luc@lmichel.fr> |
14 | Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
15 | Message-id: 20210128114145.20536-7-peter.maydell@linaro.org | ||
16 | Message-id: 20210121190622.22000-7-peter.maydell@linaro.org | ||
17 | --- | ||
18 | include/hw/arm/armsse.h | 6 +++--- | ||
19 | include/hw/timer/cmsdk-apb-timer.h | 4 ++-- | ||
20 | hw/timer/cmsdk-apb-timer.c | 28 ++++++++++++++-------------- | ||
21 | 3 files changed, 19 insertions(+), 19 deletions(-) | ||
10 | 22 | ||
11 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 23 | diff --git a/include/hw/arm/armsse.h b/include/hw/arm/armsse.h |
12 | Message-id: 20181011205206.3552-19-richard.henderson@linaro.org | ||
13 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
15 | --- | ||
16 | target/arm/translate.c | 170 ++++++++++++++++++----------------------- | ||
17 | 1 file changed, 74 insertions(+), 96 deletions(-) | ||
18 | |||
19 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
20 | index XXXXXXX..XXXXXXX 100644 | 24 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/target/arm/translate.c | 25 | --- a/include/hw/arm/armsse.h |
22 | +++ b/target/arm/translate.c | 26 | +++ b/include/hw/arm/armsse.h |
23 | @@ -XXX,XX +XXX,XX @@ static TCGv_i32 neon_load_reg(int reg, int pass) | 27 | @@ -XXX,XX +XXX,XX @@ struct ARMSSE { |
24 | return tmp; | 28 | TZPPC apb_ppc0; |
29 | TZPPC apb_ppc1; | ||
30 | TZMPC mpc[IOTS_NUM_MPC]; | ||
31 | - CMSDKAPBTIMER timer0; | ||
32 | - CMSDKAPBTIMER timer1; | ||
33 | - CMSDKAPBTIMER s32ktimer; | ||
34 | + CMSDKAPBTimer timer0; | ||
35 | + CMSDKAPBTimer timer1; | ||
36 | + CMSDKAPBTimer s32ktimer; | ||
37 | qemu_or_irq ppc_irq_orgate; | ||
38 | SplitIRQ sec_resp_splitter; | ||
39 | SplitIRQ ppc_irq_splitter[NUM_PPCS]; | ||
40 | diff --git a/include/hw/timer/cmsdk-apb-timer.h b/include/hw/timer/cmsdk-apb-timer.h | ||
41 | index XXXXXXX..XXXXXXX 100644 | ||
42 | --- a/include/hw/timer/cmsdk-apb-timer.h | ||
43 | +++ b/include/hw/timer/cmsdk-apb-timer.h | ||
44 | @@ -XXX,XX +XXX,XX @@ | ||
45 | #include "qom/object.h" | ||
46 | |||
47 | #define TYPE_CMSDK_APB_TIMER "cmsdk-apb-timer" | ||
48 | -OBJECT_DECLARE_SIMPLE_TYPE(CMSDKAPBTIMER, CMSDK_APB_TIMER) | ||
49 | +OBJECT_DECLARE_SIMPLE_TYPE(CMSDKAPBTimer, CMSDK_APB_TIMER) | ||
50 | |||
51 | -struct CMSDKAPBTIMER { | ||
52 | +struct CMSDKAPBTimer { | ||
53 | /*< private >*/ | ||
54 | SysBusDevice parent_obj; | ||
55 | |||
56 | diff --git a/hw/timer/cmsdk-apb-timer.c b/hw/timer/cmsdk-apb-timer.c | ||
57 | index XXXXXXX..XXXXXXX 100644 | ||
58 | --- a/hw/timer/cmsdk-apb-timer.c | ||
59 | +++ b/hw/timer/cmsdk-apb-timer.c | ||
60 | @@ -XXX,XX +XXX,XX @@ static const int timer_id[] = { | ||
61 | 0x0d, 0xf0, 0x05, 0xb1, /* CID0..CID3 */ | ||
62 | }; | ||
63 | |||
64 | -static void cmsdk_apb_timer_update(CMSDKAPBTIMER *s) | ||
65 | +static void cmsdk_apb_timer_update(CMSDKAPBTimer *s) | ||
66 | { | ||
67 | qemu_set_irq(s->timerint, !!(s->intstatus & R_INTSTATUS_IRQ_MASK)); | ||
25 | } | 68 | } |
26 | 69 | ||
27 | +static void neon_load_element64(TCGv_i64 var, int reg, int ele, TCGMemOp mop) | 70 | static uint64_t cmsdk_apb_timer_read(void *opaque, hwaddr offset, unsigned size) |
28 | +{ | ||
29 | + long offset = neon_element_offset(reg, ele, mop & MO_SIZE); | ||
30 | + | ||
31 | + switch (mop) { | ||
32 | + case MO_UB: | ||
33 | + tcg_gen_ld8u_i64(var, cpu_env, offset); | ||
34 | + break; | ||
35 | + case MO_UW: | ||
36 | + tcg_gen_ld16u_i64(var, cpu_env, offset); | ||
37 | + break; | ||
38 | + case MO_UL: | ||
39 | + tcg_gen_ld32u_i64(var, cpu_env, offset); | ||
40 | + break; | ||
41 | + case MO_Q: | ||
42 | + tcg_gen_ld_i64(var, cpu_env, offset); | ||
43 | + break; | ||
44 | + default: | ||
45 | + g_assert_not_reached(); | ||
46 | + } | ||
47 | +} | ||
48 | + | ||
49 | static void neon_store_reg(int reg, int pass, TCGv_i32 var) | ||
50 | { | 71 | { |
51 | tcg_gen_st_i32(var, cpu_env, neon_reg_offset(reg, pass)); | 72 | - CMSDKAPBTIMER *s = CMSDK_APB_TIMER(opaque); |
52 | tcg_temp_free_i32(var); | 73 | + CMSDKAPBTimer *s = CMSDK_APB_TIMER(opaque); |
53 | } | 74 | uint64_t r; |
54 | 75 | ||
55 | +static void neon_store_element64(int reg, int ele, TCGMemOp size, TCGv_i64 var) | 76 | switch (offset) { |
56 | +{ | 77 | @@ -XXX,XX +XXX,XX @@ static uint64_t cmsdk_apb_timer_read(void *opaque, hwaddr offset, unsigned size) |
57 | + long offset = neon_element_offset(reg, ele, size); | 78 | static void cmsdk_apb_timer_write(void *opaque, hwaddr offset, uint64_t value, |
58 | + | 79 | unsigned size) |
59 | + switch (size) { | ||
60 | + case MO_8: | ||
61 | + tcg_gen_st8_i64(var, cpu_env, offset); | ||
62 | + break; | ||
63 | + case MO_16: | ||
64 | + tcg_gen_st16_i64(var, cpu_env, offset); | ||
65 | + break; | ||
66 | + case MO_32: | ||
67 | + tcg_gen_st32_i64(var, cpu_env, offset); | ||
68 | + break; | ||
69 | + case MO_64: | ||
70 | + tcg_gen_st_i64(var, cpu_env, offset); | ||
71 | + break; | ||
72 | + default: | ||
73 | + g_assert_not_reached(); | ||
74 | + } | ||
75 | +} | ||
76 | + | ||
77 | static inline void neon_load_reg64(TCGv_i64 var, int reg) | ||
78 | { | 80 | { |
79 | tcg_gen_ld_i64(var, cpu_env, vfp_reg_offset(1, reg)); | 81 | - CMSDKAPBTIMER *s = CMSDK_APB_TIMER(opaque); |
80 | @@ -XXX,XX +XXX,XX @@ static struct { | 82 | + CMSDKAPBTimer *s = CMSDK_APB_TIMER(opaque); |
81 | int interleave; | 83 | |
82 | int spacing; | 84 | trace_cmsdk_apb_timer_write(offset, value, size); |
83 | } const neon_ls_element_type[11] = { | 85 | |
84 | - {4, 4, 1}, | 86 | @@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps cmsdk_apb_timer_ops = { |
85 | - {4, 4, 2}, | 87 | |
86 | + {1, 4, 1}, | 88 | static void cmsdk_apb_timer_tick(void *opaque) |
87 | + {1, 4, 2}, | 89 | { |
88 | {4, 1, 1}, | 90 | - CMSDKAPBTIMER *s = CMSDK_APB_TIMER(opaque); |
89 | - {4, 2, 1}, | 91 | + CMSDKAPBTimer *s = CMSDK_APB_TIMER(opaque); |
90 | - {3, 3, 1}, | 92 | |
91 | - {3, 3, 2}, | 93 | if (s->ctrl & R_CTRL_IRQEN_MASK) { |
92 | + {2, 2, 2}, | 94 | s->intstatus |= R_INTSTATUS_IRQ_MASK; |
93 | + {1, 3, 1}, | 95 | @@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_timer_tick(void *opaque) |
94 | + {1, 3, 2}, | 96 | |
95 | {3, 1, 1}, | 97 | static void cmsdk_apb_timer_reset(DeviceState *dev) |
96 | {1, 1, 1}, | 98 | { |
97 | - {2, 2, 1}, | 99 | - CMSDKAPBTIMER *s = CMSDK_APB_TIMER(dev); |
98 | - {2, 2, 2}, | 100 | + CMSDKAPBTimer *s = CMSDK_APB_TIMER(dev); |
99 | + {1, 2, 1}, | 101 | |
100 | + {1, 2, 2}, | 102 | trace_cmsdk_apb_timer_reset(); |
101 | {2, 1, 1} | 103 | s->ctrl = 0; |
104 | @@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_timer_reset(DeviceState *dev) | ||
105 | static void cmsdk_apb_timer_init(Object *obj) | ||
106 | { | ||
107 | SysBusDevice *sbd = SYS_BUS_DEVICE(obj); | ||
108 | - CMSDKAPBTIMER *s = CMSDK_APB_TIMER(obj); | ||
109 | + CMSDKAPBTimer *s = CMSDK_APB_TIMER(obj); | ||
110 | |||
111 | memory_region_init_io(&s->iomem, obj, &cmsdk_apb_timer_ops, | ||
112 | s, "cmsdk-apb-timer", 0x1000); | ||
113 | @@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_timer_init(Object *obj) | ||
114 | |||
115 | static void cmsdk_apb_timer_realize(DeviceState *dev, Error **errp) | ||
116 | { | ||
117 | - CMSDKAPBTIMER *s = CMSDK_APB_TIMER(dev); | ||
118 | + CMSDKAPBTimer *s = CMSDK_APB_TIMER(dev); | ||
119 | |||
120 | if (s->pclk_frq == 0) { | ||
121 | error_setg(errp, "CMSDK APB timer: pclk-frq property must be set"); | ||
122 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription cmsdk_apb_timer_vmstate = { | ||
123 | .version_id = 1, | ||
124 | .minimum_version_id = 1, | ||
125 | .fields = (VMStateField[]) { | ||
126 | - VMSTATE_PTIMER(timer, CMSDKAPBTIMER), | ||
127 | - VMSTATE_UINT32(ctrl, CMSDKAPBTIMER), | ||
128 | - VMSTATE_UINT32(value, CMSDKAPBTIMER), | ||
129 | - VMSTATE_UINT32(reload, CMSDKAPBTIMER), | ||
130 | - VMSTATE_UINT32(intstatus, CMSDKAPBTIMER), | ||
131 | + VMSTATE_PTIMER(timer, CMSDKAPBTimer), | ||
132 | + VMSTATE_UINT32(ctrl, CMSDKAPBTimer), | ||
133 | + VMSTATE_UINT32(value, CMSDKAPBTimer), | ||
134 | + VMSTATE_UINT32(reload, CMSDKAPBTimer), | ||
135 | + VMSTATE_UINT32(intstatus, CMSDKAPBTimer), | ||
136 | VMSTATE_END_OF_LIST() | ||
137 | } | ||
102 | }; | 138 | }; |
103 | 139 | ||
104 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_ls_insn(DisasContext *s, uint32_t insn) | 140 | static Property cmsdk_apb_timer_properties[] = { |
105 | int shift; | 141 | - DEFINE_PROP_UINT32("pclk-frq", CMSDKAPBTIMER, pclk_frq, 0), |
106 | int n; | 142 | + DEFINE_PROP_UINT32("pclk-frq", CMSDKAPBTimer, pclk_frq, 0), |
107 | int vec_size; | 143 | DEFINE_PROP_END_OF_LIST(), |
108 | + int mmu_idx; | 144 | }; |
109 | + TCGMemOp endian; | 145 | |
110 | TCGv_i32 addr; | 146 | @@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_timer_class_init(ObjectClass *klass, void *data) |
111 | TCGv_i32 tmp; | 147 | static const TypeInfo cmsdk_apb_timer_info = { |
112 | TCGv_i32 tmp2; | 148 | .name = TYPE_CMSDK_APB_TIMER, |
113 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_ls_insn(DisasContext *s, uint32_t insn) | 149 | .parent = TYPE_SYS_BUS_DEVICE, |
114 | rn = (insn >> 16) & 0xf; | 150 | - .instance_size = sizeof(CMSDKAPBTIMER), |
115 | rm = insn & 0xf; | 151 | + .instance_size = sizeof(CMSDKAPBTimer), |
116 | load = (insn & (1 << 21)) != 0; | 152 | .instance_init = cmsdk_apb_timer_init, |
117 | + endian = s->be_data; | 153 | .class_init = cmsdk_apb_timer_class_init, |
118 | + mmu_idx = get_mem_index(s); | 154 | }; |
119 | if ((insn & (1 << 23)) == 0) { | ||
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 | -- | 155 | -- |
247 | 2.19.1 | 156 | 2.20.1 |
248 | 157 | ||
249 | 158 | diff view generated by jsdifflib |
1 | For traps of FP/SIMD instructions to AArch32 Hyp mode, the syndrome | 1 | As the first step in converting the CMSDK_APB_TIMER device to the |
---|---|---|---|
2 | provided in HSR has more information than is reported to AArch64. | 2 | Clock framework, add a Clock input. For the moment we do nothing |
3 | Specifically, there are extra fields TA and coproc which indicate | 3 | with this clock; we will change the behaviour from using the pclk-frq |
4 | whether the trapped instruction was FP or SIMD. Add this extra | 4 | property to using the Clock once all the users of this device have |
5 | information to the syndromes we construct, and mask it out when | 5 | been converted to wire up the Clock. |
6 | taking the exception to AArch64. | 6 | |
7 | Since the device doesn't already have a doc comment for its "QEMU | ||
8 | interface", we add one including the new Clock. | ||
9 | |||
10 | This is a migration compatibility break for machines mps2-an505, | ||
11 | mps2-an521, musca-a, musca-b1. | ||
7 | 12 | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 14 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
10 | Message-id: 20181012144235.19646-11-peter.maydell@linaro.org | 15 | Reviewed-by: Luc Michel <luc@lmichel.fr> |
16 | Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
17 | Message-id: 20210128114145.20536-8-peter.maydell@linaro.org | ||
18 | Message-id: 20210121190622.22000-8-peter.maydell@linaro.org | ||
11 | --- | 19 | --- |
12 | target/arm/internals.h | 14 +++++++++++++- | 20 | include/hw/timer/cmsdk-apb-timer.h | 9 +++++++++ |
13 | target/arm/helper.c | 9 +++++++++ | 21 | hw/timer/cmsdk-apb-timer.c | 7 +++++-- |
14 | target/arm/translate.c | 8 ++++---- | 22 | 2 files changed, 14 insertions(+), 2 deletions(-) |
15 | 3 files changed, 26 insertions(+), 5 deletions(-) | ||
16 | 23 | ||
17 | diff --git a/target/arm/internals.h b/target/arm/internals.h | 24 | diff --git a/include/hw/timer/cmsdk-apb-timer.h b/include/hw/timer/cmsdk-apb-timer.h |
18 | index XXXXXXX..XXXXXXX 100644 | 25 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/target/arm/internals.h | 26 | --- a/include/hw/timer/cmsdk-apb-timer.h |
20 | +++ b/target/arm/internals.h | 27 | +++ b/include/hw/timer/cmsdk-apb-timer.h |
21 | @@ -XXX,XX +XXX,XX @@ static inline uint32_t syn_get_ec(uint32_t syn) | 28 | @@ -XXX,XX +XXX,XX @@ |
22 | * few cases the value in HSR for exceptions taken to AArch32 Hyp | 29 | #include "hw/qdev-properties.h" |
23 | * mode differs slightly, and we fix this up when populating HSR in | 30 | #include "hw/sysbus.h" |
24 | * arm_cpu_do_interrupt_aarch32_hyp(). | 31 | #include "hw/ptimer.h" |
25 | + * The exception is FP/SIMD access traps -- these report extra information | 32 | +#include "hw/clock.h" |
26 | + * when taking an exception to AArch32. For those we include the extra coproc | 33 | #include "qom/object.h" |
27 | + * and TA fields, and mask them out when taking the exception to AArch64. | 34 | |
28 | */ | 35 | #define TYPE_CMSDK_APB_TIMER "cmsdk-apb-timer" |
29 | static inline uint32_t syn_uncategorized(void) | 36 | OBJECT_DECLARE_SIMPLE_TYPE(CMSDKAPBTimer, CMSDK_APB_TIMER) |
30 | { | 37 | |
31 | @@ -XXX,XX +XXX,XX @@ static inline uint32_t syn_cp15_rrt_trap(int cv, int cond, int opc1, int crm, | 38 | +/* |
32 | 39 | + * QEMU interface: | |
33 | static inline uint32_t syn_fp_access_trap(int cv, int cond, bool is_16bit) | 40 | + * + QOM property "pclk-frq": frequency at which the timer is clocked |
34 | { | 41 | + * + Clock input "pclk": clock for the timer |
35 | + /* AArch32 FP trap or any AArch64 FP/SIMD trap: TA == 0 coproc == 0xa */ | 42 | + * + sysbus MMIO region 0: the register bank |
36 | return (EC_ADVSIMDFPACCESSTRAP << ARM_EL_EC_SHIFT) | 43 | + * + sysbus IRQ 0: timer interrupt TIMERINT |
37 | | (is_16bit ? 0 : ARM_EL_IL) | 44 | + */ |
38 | - | (cv << 24) | (cond << 20); | 45 | struct CMSDKAPBTimer { |
39 | + | (cv << 24) | (cond << 20) | 0xa; | 46 | /*< private >*/ |
40 | +} | 47 | SysBusDevice parent_obj; |
41 | + | 48 | @@ -XXX,XX +XXX,XX @@ struct CMSDKAPBTimer { |
42 | +static inline uint32_t syn_simd_access_trap(int cv, int cond, bool is_16bit) | 49 | qemu_irq timerint; |
43 | +{ | 50 | uint32_t pclk_frq; |
44 | + /* AArch32 SIMD trap: TA == 1 coproc == 0 */ | 51 | struct ptimer_state *timer; |
45 | + return (EC_ADVSIMDFPACCESSTRAP << ARM_EL_EC_SHIFT) | 52 | + Clock *pclk; |
46 | + | (is_16bit ? 0 : ARM_EL_IL) | 53 | |
47 | + | (cv << 24) | (cond << 20) | (1 << 5); | 54 | uint32_t ctrl; |
55 | uint32_t value; | ||
56 | diff --git a/hw/timer/cmsdk-apb-timer.c b/hw/timer/cmsdk-apb-timer.c | ||
57 | index XXXXXXX..XXXXXXX 100644 | ||
58 | --- a/hw/timer/cmsdk-apb-timer.c | ||
59 | +++ b/hw/timer/cmsdk-apb-timer.c | ||
60 | @@ -XXX,XX +XXX,XX @@ | ||
61 | #include "hw/sysbus.h" | ||
62 | #include "hw/irq.h" | ||
63 | #include "hw/registerfields.h" | ||
64 | +#include "hw/qdev-clock.h" | ||
65 | #include "hw/timer/cmsdk-apb-timer.h" | ||
66 | #include "migration/vmstate.h" | ||
67 | |||
68 | @@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_timer_init(Object *obj) | ||
69 | s, "cmsdk-apb-timer", 0x1000); | ||
70 | sysbus_init_mmio(sbd, &s->iomem); | ||
71 | sysbus_init_irq(sbd, &s->timerint); | ||
72 | + s->pclk = qdev_init_clock_in(DEVICE(s), "pclk", NULL, NULL); | ||
48 | } | 73 | } |
49 | 74 | ||
50 | static inline uint32_t syn_sve_access_trap(void) | 75 | static void cmsdk_apb_timer_realize(DeviceState *dev, Error **errp) |
51 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 76 | @@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_timer_realize(DeviceState *dev, Error **errp) |
52 | index XXXXXXX..XXXXXXX 100644 | 77 | |
53 | --- a/target/arm/helper.c | 78 | static const VMStateDescription cmsdk_apb_timer_vmstate = { |
54 | +++ b/target/arm/helper.c | 79 | .name = "cmsdk-apb-timer", |
55 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_do_interrupt_aarch64(CPUState *cs) | 80 | - .version_id = 1, |
56 | case EXCP_HVC: | 81 | - .minimum_version_id = 1, |
57 | case EXCP_HYP_TRAP: | 82 | + .version_id = 2, |
58 | case EXCP_SMC: | 83 | + .minimum_version_id = 2, |
59 | + if (syn_get_ec(env->exception.syndrome) == EC_ADVSIMDFPACCESSTRAP) { | 84 | .fields = (VMStateField[]) { |
60 | + /* | 85 | VMSTATE_PTIMER(timer, CMSDKAPBTimer), |
61 | + * QEMU internal FP/SIMD syndromes from AArch32 include the | 86 | + VMSTATE_CLOCK(pclk, CMSDKAPBTimer), |
62 | + * TA and coproc fields which are only exposed if the exception | 87 | VMSTATE_UINT32(ctrl, CMSDKAPBTimer), |
63 | + * is taken to AArch32 Hyp mode. Mask them out to get a valid | 88 | VMSTATE_UINT32(value, CMSDKAPBTimer), |
64 | + * AArch64 format syndrome. | 89 | VMSTATE_UINT32(reload, CMSDKAPBTimer), |
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 | -- | 90 | -- |
112 | 2.19.1 | 91 | 2.20.1 |
113 | 92 | ||
114 | 93 | diff view generated by jsdifflib |
1 | The HCR_EL2 VI and VF bits are supposed to track whether there is | 1 | As the first step in converting the CMSDK_APB_DUALTIMER device to the |
---|---|---|---|
2 | a pending virtual IRQ or virtual FIQ. For QEMU we store the | 2 | Clock framework, add a Clock input. For the moment we do nothing |
3 | pending VIRQ/VFIQ status in cs->interrupt_request, so this means: | 3 | with this clock; we will change the behaviour from using the pclk-frq |
4 | * if the register is read we must get these bit values from | 4 | property to using the Clock once all the users of this device have |
5 | cs->interrupt_request | 5 | been converted to wire up the Clock. |
6 | * if the register is written then we must write the bit | 6 | |
7 | values back into cs->interrupt_request | 7 | We take the opportunity to correct the name of the clock input to |
8 | match the hardware -- the dual timer names the clock which drives the | ||
9 | timers TIMCLK. (It does also have a 'pclk' input, which is used only | ||
10 | for the register and APB bus logic; on the SSE-200 these clocks are | ||
11 | both connected together.) | ||
12 | |||
13 | This is a migration compatibility break for machines mps2-an385, | ||
14 | mps2-an386, mps2-an500, mps2-an511, mps2-an505, mps2-an521, musca-a, | ||
15 | musca-b1. | ||
8 | 16 | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 18 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
11 | Message-id: 20181012144235.19646-7-peter.maydell@linaro.org | 19 | Reviewed-by: Luc Michel <luc@lmichel.fr> |
20 | Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
21 | Message-id: 20210128114145.20536-9-peter.maydell@linaro.org | ||
22 | Message-id: 20210121190622.22000-9-peter.maydell@linaro.org | ||
12 | --- | 23 | --- |
13 | target/arm/helper.c | 47 +++++++++++++++++++++++++++++++++++++++++---- | 24 | include/hw/timer/cmsdk-apb-dualtimer.h | 3 +++ |
14 | 1 file changed, 43 insertions(+), 4 deletions(-) | 25 | hw/timer/cmsdk-apb-dualtimer.c | 7 +++++-- |
26 | 2 files changed, 8 insertions(+), 2 deletions(-) | ||
15 | 27 | ||
16 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 28 | diff --git a/include/hw/timer/cmsdk-apb-dualtimer.h b/include/hw/timer/cmsdk-apb-dualtimer.h |
17 | index XXXXXXX..XXXXXXX 100644 | 29 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/target/arm/helper.c | 30 | --- a/include/hw/timer/cmsdk-apb-dualtimer.h |
19 | +++ b/target/arm/helper.c | 31 | +++ b/include/hw/timer/cmsdk-apb-dualtimer.h |
20 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo el3_no_el2_v8_cp_reginfo[] = { | 32 | @@ -XXX,XX +XXX,XX @@ |
21 | static void hcr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) | 33 | * |
22 | { | 34 | * QEMU interface: |
23 | ARMCPU *cpu = arm_env_get_cpu(env); | 35 | * + QOM property "pclk-frq": frequency at which the timer is clocked |
24 | + CPUState *cs = ENV_GET_CPU(env); | 36 | + * + Clock input "TIMCLK": clock (for both timers) |
25 | uint64_t valid_mask = HCR_MASK; | 37 | * + sysbus MMIO region 0: the register bank |
26 | 38 | * + sysbus IRQ 0: combined timer interrupt TIMINTC | |
27 | if (arm_feature(env, ARM_FEATURE_EL3)) { | 39 | * + sysbus IRO 1: timer block 1 interrupt TIMINT1 |
28 | @@ -XXX,XX +XXX,XX @@ static void hcr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) | 40 | @@ -XXX,XX +XXX,XX @@ |
29 | /* Clear RES0 bits. */ | 41 | |
30 | value &= valid_mask; | 42 | #include "hw/sysbus.h" |
31 | 43 | #include "hw/ptimer.h" | |
32 | + /* | 44 | +#include "hw/clock.h" |
33 | + * VI and VF are kept in cs->interrupt_request. Modifying that | 45 | #include "qom/object.h" |
34 | + * requires that we have the iothread lock, which is done by | 46 | |
35 | + * marking the reginfo structs as ARM_CP_IO. | 47 | #define TYPE_CMSDK_APB_DUALTIMER "cmsdk-apb-dualtimer" |
36 | + * Note that if a write to HCR pends a VIRQ or VFIQ it is never | 48 | @@ -XXX,XX +XXX,XX @@ struct CMSDKAPBDualTimer { |
37 | + * possible for it to be taken immediately, because VIRQ and | 49 | MemoryRegion iomem; |
38 | + * VFIQ are masked unless running at EL0 or EL1, and HCR | 50 | qemu_irq timerintc; |
39 | + * can only be written at EL2. | 51 | uint32_t pclk_frq; |
40 | + */ | 52 | + Clock *timclk; |
41 | + g_assert(qemu_mutex_iothread_locked()); | 53 | |
42 | + if (value & HCR_VI) { | 54 | CMSDKAPBDualTimerModule timermod[CMSDK_APB_DUALTIMER_NUM_MODULES]; |
43 | + cs->interrupt_request |= CPU_INTERRUPT_VIRQ; | 55 | uint32_t timeritcr; |
44 | + } else { | 56 | diff --git a/hw/timer/cmsdk-apb-dualtimer.c b/hw/timer/cmsdk-apb-dualtimer.c |
45 | + cs->interrupt_request &= ~CPU_INTERRUPT_VIRQ; | 57 | index XXXXXXX..XXXXXXX 100644 |
46 | + } | 58 | --- a/hw/timer/cmsdk-apb-dualtimer.c |
47 | + if (value & HCR_VF) { | 59 | +++ b/hw/timer/cmsdk-apb-dualtimer.c |
48 | + cs->interrupt_request |= CPU_INTERRUPT_VFIQ; | 60 | @@ -XXX,XX +XXX,XX @@ |
49 | + } else { | 61 | #include "hw/irq.h" |
50 | + cs->interrupt_request &= ~CPU_INTERRUPT_VFIQ; | 62 | #include "hw/qdev-properties.h" |
51 | + } | 63 | #include "hw/registerfields.h" |
52 | + value &= ~(HCR_VI | HCR_VF); | 64 | +#include "hw/qdev-clock.h" |
53 | + | 65 | #include "hw/timer/cmsdk-apb-dualtimer.h" |
54 | /* These bits change the MMU setup: | 66 | #include "migration/vmstate.h" |
55 | * HCR_VM enables stage 2 translation | 67 | |
56 | * HCR_PTW forbids certain page-table setups | 68 | @@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_dualtimer_init(Object *obj) |
57 | @@ -XXX,XX +XXX,XX @@ static void hcr_writelow(CPUARMState *env, const ARMCPRegInfo *ri, | 69 | for (i = 0; i < ARRAY_SIZE(s->timermod); i++) { |
58 | hcr_write(env, NULL, value); | 70 | sysbus_init_irq(sbd, &s->timermod[i].timerint); |
71 | } | ||
72 | + s->timclk = qdev_init_clock_in(DEVICE(s), "TIMCLK", NULL, NULL); | ||
59 | } | 73 | } |
60 | 74 | ||
61 | +static uint64_t hcr_read(CPUARMState *env, const ARMCPRegInfo *ri) | 75 | static void cmsdk_apb_dualtimer_realize(DeviceState *dev, Error **errp) |
62 | +{ | 76 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription cmsdk_dualtimermod_vmstate = { |
63 | + /* The VI and VF bits live in cs->interrupt_request */ | 77 | |
64 | + uint64_t ret = env->cp15.hcr_el2 & ~(HCR_VI | HCR_VF); | 78 | static const VMStateDescription cmsdk_apb_dualtimer_vmstate = { |
65 | + CPUState *cs = ENV_GET_CPU(env); | 79 | .name = "cmsdk-apb-dualtimer", |
66 | + | 80 | - .version_id = 1, |
67 | + if (cs->interrupt_request & CPU_INTERRUPT_VIRQ) { | 81 | - .minimum_version_id = 1, |
68 | + ret |= HCR_VI; | 82 | + .version_id = 2, |
69 | + } | 83 | + .minimum_version_id = 2, |
70 | + if (cs->interrupt_request & CPU_INTERRUPT_VFIQ) { | 84 | .fields = (VMStateField[]) { |
71 | + ret |= HCR_VF; | 85 | + VMSTATE_CLOCK(timclk, CMSDKAPBDualTimer), |
72 | + } | 86 | VMSTATE_STRUCT_ARRAY(timermod, CMSDKAPBDualTimer, |
73 | + return ret; | 87 | CMSDK_APB_DUALTIMER_NUM_MODULES, |
74 | +} | 88 | 1, cmsdk_dualtimermod_vmstate, |
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 | -- | 89 | -- |
103 | 2.19.1 | 90 | 2.20.1 |
104 | 91 | ||
105 | 92 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | As the first step in converting the CMSDK_APB_TIMER device to the | ||
2 | Clock framework, add a Clock input. For the moment we do nothing | ||
3 | with this clock; we will change the behaviour from using the | ||
4 | wdogclk-frq property to using the Clock once all the users of this | ||
5 | device have been converted to wire up the Clock. | ||
1 | 6 | ||
7 | This is a migration compatibility break for machines mps2-an385, | ||
8 | mps2-an386, mps2-an500, mps2-an511, mps2-an505, mps2-an521, musca-a, | ||
9 | musca-b1, lm3s811evb, lm3s6965evb. | ||
10 | |||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
13 | Reviewed-by: Luc Michel <luc@lmichel.fr> | ||
14 | Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
15 | Message-id: 20210128114145.20536-10-peter.maydell@linaro.org | ||
16 | Message-id: 20210121190622.22000-10-peter.maydell@linaro.org | ||
17 | --- | ||
18 | include/hw/watchdog/cmsdk-apb-watchdog.h | 3 +++ | ||
19 | hw/watchdog/cmsdk-apb-watchdog.c | 7 +++++-- | ||
20 | 2 files changed, 8 insertions(+), 2 deletions(-) | ||
21 | |||
22 | diff --git a/include/hw/watchdog/cmsdk-apb-watchdog.h b/include/hw/watchdog/cmsdk-apb-watchdog.h | ||
23 | index XXXXXXX..XXXXXXX 100644 | ||
24 | --- a/include/hw/watchdog/cmsdk-apb-watchdog.h | ||
25 | +++ b/include/hw/watchdog/cmsdk-apb-watchdog.h | ||
26 | @@ -XXX,XX +XXX,XX @@ | ||
27 | * | ||
28 | * QEMU interface: | ||
29 | * + QOM property "wdogclk-frq": frequency at which the watchdog is clocked | ||
30 | + * + Clock input "WDOGCLK": clock for the watchdog's timer | ||
31 | * + sysbus MMIO region 0: the register bank | ||
32 | * + sysbus IRQ 0: watchdog interrupt | ||
33 | * | ||
34 | @@ -XXX,XX +XXX,XX @@ | ||
35 | |||
36 | #include "hw/sysbus.h" | ||
37 | #include "hw/ptimer.h" | ||
38 | +#include "hw/clock.h" | ||
39 | #include "qom/object.h" | ||
40 | |||
41 | #define TYPE_CMSDK_APB_WATCHDOG "cmsdk-apb-watchdog" | ||
42 | @@ -XXX,XX +XXX,XX @@ struct CMSDKAPBWatchdog { | ||
43 | uint32_t wdogclk_frq; | ||
44 | bool is_luminary; | ||
45 | struct ptimer_state *timer; | ||
46 | + Clock *wdogclk; | ||
47 | |||
48 | uint32_t control; | ||
49 | uint32_t intstatus; | ||
50 | diff --git a/hw/watchdog/cmsdk-apb-watchdog.c b/hw/watchdog/cmsdk-apb-watchdog.c | ||
51 | index XXXXXXX..XXXXXXX 100644 | ||
52 | --- a/hw/watchdog/cmsdk-apb-watchdog.c | ||
53 | +++ b/hw/watchdog/cmsdk-apb-watchdog.c | ||
54 | @@ -XXX,XX +XXX,XX @@ | ||
55 | #include "hw/irq.h" | ||
56 | #include "hw/qdev-properties.h" | ||
57 | #include "hw/registerfields.h" | ||
58 | +#include "hw/qdev-clock.h" | ||
59 | #include "hw/watchdog/cmsdk-apb-watchdog.h" | ||
60 | #include "migration/vmstate.h" | ||
61 | |||
62 | @@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_watchdog_init(Object *obj) | ||
63 | s, "cmsdk-apb-watchdog", 0x1000); | ||
64 | sysbus_init_mmio(sbd, &s->iomem); | ||
65 | sysbus_init_irq(sbd, &s->wdogint); | ||
66 | + s->wdogclk = qdev_init_clock_in(DEVICE(s), "WDOGCLK", NULL, NULL); | ||
67 | |||
68 | s->is_luminary = false; | ||
69 | s->id = cmsdk_apb_watchdog_id; | ||
70 | @@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_watchdog_realize(DeviceState *dev, Error **errp) | ||
71 | |||
72 | static const VMStateDescription cmsdk_apb_watchdog_vmstate = { | ||
73 | .name = "cmsdk-apb-watchdog", | ||
74 | - .version_id = 1, | ||
75 | - .minimum_version_id = 1, | ||
76 | + .version_id = 2, | ||
77 | + .minimum_version_id = 2, | ||
78 | .fields = (VMStateField[]) { | ||
79 | + VMSTATE_CLOCK(wdogclk, CMSDKAPBWatchdog), | ||
80 | VMSTATE_PTIMER(timer, CMSDKAPBWatchdog), | ||
81 | VMSTATE_UINT32(control, CMSDKAPBWatchdog), | ||
82 | VMSTATE_UINT32(intstatus, CMSDKAPBWatchdog), | ||
83 | -- | ||
84 | 2.20.1 | ||
85 | |||
86 | diff view generated by jsdifflib |
1 | From: Stewart Hildebrand <Stewart.Hildebrand@dornerworks.com> | 1 | While we transition the ARMSSE code from integer properties |
---|---|---|---|
2 | specifying clock frequencies to Clock objects, we want to have the | ||
3 | device provide both at once. We want the final name of the main | ||
4 | input Clock to be "MAINCLK", following the hardware name. | ||
5 | Unfortunately creating an input Clock with a name X creates an | ||
6 | under-the-hood QOM property X; for "MAINCLK" this clashes with the | ||
7 | existing UINT32 property of that name. | ||
2 | 8 | ||
3 | "The Image must be placed text_offset bytes from a 2MB aligned base | 9 | Rename the UINT32 property to MAINCLK_FRQ so it can coexist with the |
4 | address anywhere in usable system RAM and called there." | 10 | MAINCLK Clock; once the transition is complete MAINCLK_FRQ will be |
11 | deleted. | ||
5 | 12 | ||
6 | For the virt board, we write our startup bootloader at the very | 13 | Commit created with: |
7 | bottom of RAM, so that bit can't be used for the image. To avoid | 14 | perl -p -i -e 's/MAINCLK/MAINCLK_FRQ/g' hw/arm/{armsse,mps2-tz,musca}.c include/hw/arm/armsse.h |
8 | overlap in case the image requests to be loaded at an offset | ||
9 | smaller than our bootloader, we increment the load offset to the | ||
10 | next 2MB. | ||
11 | 15 | ||
12 | This fixes a boot failure for Xen AArch64. | 16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
17 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
18 | Reviewed-by: Luc Michel <luc@lmichel.fr> | ||
19 | Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
20 | Message-id: 20210128114145.20536-11-peter.maydell@linaro.org | ||
21 | Message-id: 20210121190622.22000-11-peter.maydell@linaro.org | ||
22 | --- | ||
23 | include/hw/arm/armsse.h | 2 +- | ||
24 | hw/arm/armsse.c | 6 +++--- | ||
25 | hw/arm/mps2-tz.c | 2 +- | ||
26 | hw/arm/musca.c | 2 +- | ||
27 | 4 files changed, 6 insertions(+), 6 deletions(-) | ||
13 | 28 | ||
14 | Signed-off-by: Stewart Hildebrand <stewart.hildebrand@dornerworks.com> | 29 | diff --git a/include/hw/arm/armsse.h b/include/hw/arm/armsse.h |
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> | ||
20 | --- | ||
21 | hw/arm/boot.c | 18 ++++++++++++++++++ | ||
22 | 1 file changed, 18 insertions(+) | ||
23 | |||
24 | diff --git a/hw/arm/boot.c b/hw/arm/boot.c | ||
25 | index XXXXXXX..XXXXXXX 100644 | 30 | index XXXXXXX..XXXXXXX 100644 |
26 | --- a/hw/arm/boot.c | 31 | --- a/include/hw/arm/armsse.h |
27 | +++ b/hw/arm/boot.c | 32 | +++ b/include/hw/arm/armsse.h |
28 | @@ -XXX,XX +XXX,XX @@ | 33 | @@ -XXX,XX +XXX,XX @@ |
29 | #include "qemu/config-file.h" | 34 | * QEMU interface: |
30 | #include "qemu/option.h" | 35 | * + QOM property "memory" is a MemoryRegion containing the devices provided |
31 | #include "exec/address-spaces.h" | 36 | * by the board model. |
32 | +#include "qemu/units.h" | 37 | - * + QOM property "MAINCLK" is the frequency of the main system clock |
33 | 38 | + * + QOM property "MAINCLK_FRQ" is the frequency of the main system clock | |
34 | /* Kernel boot protocol is specified in the kernel docs | 39 | * + QOM property "EXP_NUMIRQ" sets the number of expansion interrupts. |
35 | * Documentation/arm/Booting and Documentation/arm64/booting.txt | 40 | * (In hardware, the SSE-200 permits the number of expansion interrupts |
36 | @@ -XXX,XX +XXX,XX @@ | 41 | * for the two CPUs to be configured separately, but we restrict it to |
37 | #define ARM64_TEXT_OFFSET_OFFSET 8 | 42 | diff --git a/hw/arm/armsse.c b/hw/arm/armsse.c |
38 | #define ARM64_MAGIC_OFFSET 56 | 43 | index XXXXXXX..XXXXXXX 100644 |
39 | 44 | --- a/hw/arm/armsse.c | |
40 | +#define BOOTLOADER_MAX_SIZE (4 * KiB) | 45 | +++ b/hw/arm/armsse.c |
41 | + | 46 | @@ -XXX,XX +XXX,XX @@ static Property iotkit_properties[] = { |
42 | AddressSpace *arm_boot_address_space(ARMCPU *cpu, | 47 | DEFINE_PROP_LINK("memory", ARMSSE, board_memory, TYPE_MEMORY_REGION, |
43 | const struct arm_boot_info *info) | 48 | MemoryRegion *), |
44 | { | 49 | DEFINE_PROP_UINT32("EXP_NUMIRQ", ARMSSE, exp_numirq, 64), |
45 | @@ -XXX,XX +XXX,XX @@ static void write_bootloader(const char *name, hwaddr addr, | 50 | - DEFINE_PROP_UINT32("MAINCLK", ARMSSE, mainclk_frq, 0), |
46 | code[i] = tswap32(insn); | 51 | + DEFINE_PROP_UINT32("MAINCLK_FRQ", ARMSSE, mainclk_frq, 0), |
52 | DEFINE_PROP_UINT32("SRAM_ADDR_WIDTH", ARMSSE, sram_addr_width, 15), | ||
53 | DEFINE_PROP_UINT32("init-svtor", ARMSSE, init_svtor, 0x10000000), | ||
54 | DEFINE_PROP_BOOL("CPU0_FPU", ARMSSE, cpu_fpu[0], true), | ||
55 | @@ -XXX,XX +XXX,XX @@ static Property armsse_properties[] = { | ||
56 | DEFINE_PROP_LINK("memory", ARMSSE, board_memory, TYPE_MEMORY_REGION, | ||
57 | MemoryRegion *), | ||
58 | DEFINE_PROP_UINT32("EXP_NUMIRQ", ARMSSE, exp_numirq, 64), | ||
59 | - DEFINE_PROP_UINT32("MAINCLK", ARMSSE, mainclk_frq, 0), | ||
60 | + DEFINE_PROP_UINT32("MAINCLK_FRQ", ARMSSE, mainclk_frq, 0), | ||
61 | DEFINE_PROP_UINT32("SRAM_ADDR_WIDTH", ARMSSE, sram_addr_width, 15), | ||
62 | DEFINE_PROP_UINT32("init-svtor", ARMSSE, init_svtor, 0x10000000), | ||
63 | DEFINE_PROP_BOOL("CPU0_FPU", ARMSSE, cpu_fpu[0], false), | ||
64 | @@ -XXX,XX +XXX,XX @@ static void armsse_realize(DeviceState *dev, Error **errp) | ||
47 | } | 65 | } |
48 | 66 | ||
49 | + assert((len * sizeof(uint32_t)) < BOOTLOADER_MAX_SIZE); | 67 | if (!s->mainclk_frq) { |
50 | + | 68 | - error_setg(errp, "MAINCLK property was not set"); |
51 | rom_add_blob_fixed_as(name, code, len * sizeof(uint32_t), addr, as); | 69 | + error_setg(errp, "MAINCLK_FRQ property was not set"); |
52 | 70 | return; | |
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 | } | 71 | } |
73 | 72 | ||
73 | diff --git a/hw/arm/mps2-tz.c b/hw/arm/mps2-tz.c | ||
74 | index XXXXXXX..XXXXXXX 100644 | ||
75 | --- a/hw/arm/mps2-tz.c | ||
76 | +++ b/hw/arm/mps2-tz.c | ||
77 | @@ -XXX,XX +XXX,XX @@ static void mps2tz_common_init(MachineState *machine) | ||
78 | object_property_set_link(OBJECT(&mms->iotkit), "memory", | ||
79 | OBJECT(system_memory), &error_abort); | ||
80 | qdev_prop_set_uint32(iotkitdev, "EXP_NUMIRQ", MPS2TZ_NUMIRQ); | ||
81 | - qdev_prop_set_uint32(iotkitdev, "MAINCLK", SYSCLK_FRQ); | ||
82 | + qdev_prop_set_uint32(iotkitdev, "MAINCLK_FRQ", SYSCLK_FRQ); | ||
83 | sysbus_realize(SYS_BUS_DEVICE(&mms->iotkit), &error_fatal); | ||
84 | |||
85 | /* | ||
86 | diff --git a/hw/arm/musca.c b/hw/arm/musca.c | ||
87 | index XXXXXXX..XXXXXXX 100644 | ||
88 | --- a/hw/arm/musca.c | ||
89 | +++ b/hw/arm/musca.c | ||
90 | @@ -XXX,XX +XXX,XX @@ static void musca_init(MachineState *machine) | ||
91 | qdev_prop_set_uint32(ssedev, "EXP_NUMIRQ", mmc->num_irqs); | ||
92 | qdev_prop_set_uint32(ssedev, "init-svtor", mmc->init_svtor); | ||
93 | qdev_prop_set_uint32(ssedev, "SRAM_ADDR_WIDTH", mmc->sram_addr_width); | ||
94 | - qdev_prop_set_uint32(ssedev, "MAINCLK", SYSCLK_FRQ); | ||
95 | + qdev_prop_set_uint32(ssedev, "MAINCLK_FRQ", SYSCLK_FRQ); | ||
96 | /* | ||
97 | * Musca-A takes the default SSE-200 FPU/DSP settings (ie no for | ||
98 | * CPU0 and yes for CPU1); Musca-B1 explicitly enables them for CPU0. | ||
74 | -- | 99 | -- |
75 | 2.19.1 | 100 | 2.20.1 |
76 | 101 | ||
77 | 102 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | Create two input clocks on the ARMSSE devices, one for the normal |
---|---|---|---|
2 | MAINCLK, and one for the 32KHz S32KCLK, and wire these up to the | ||
3 | appropriate devices. The old property-based clock frequency setting | ||
4 | will remain in place until conversion is complete. | ||
2 | 5 | ||
3 | Most of the v8 extensions are self-contained within the ISAR | 6 | This is a migration compatibility break for machines mps2-an505, |
4 | registers and are not implied by other feature bits, which | 7 | mps2-an521, musca-a, musca-b1. |
5 | makes them the easiest to convert. | ||
6 | 8 | ||
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> | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
11 | Reviewed-by: Luc Michel <luc@lmichel.fr> | ||
12 | Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
13 | Message-id: 20210128114145.20536-12-peter.maydell@linaro.org | ||
14 | Message-id: 20210121190622.22000-12-peter.maydell@linaro.org | ||
12 | --- | 15 | --- |
13 | target/arm/cpu.h | 131 +++++++++++++++++++++++++++++++++---- | 16 | include/hw/arm/armsse.h | 6 ++++++ |
14 | target/arm/translate.h | 7 ++ | 17 | hw/arm/armsse.c | 17 +++++++++++++++-- |
15 | linux-user/elfload.c | 46 ++++++++----- | 18 | 2 files changed, 21 insertions(+), 2 deletions(-) |
16 | target/arm/cpu.c | 27 +++++--- | ||
17 | target/arm/cpu64.c | 57 +++++++++------- | ||
18 | target/arm/translate-a64.c | 101 ++++++++++++++-------------- | ||
19 | target/arm/translate.c | 36 +++++----- | ||
20 | 7 files changed, 273 insertions(+), 132 deletions(-) | ||
21 | 19 | ||
22 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 20 | diff --git a/include/hw/arm/armsse.h b/include/hw/arm/armsse.h |
23 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
24 | --- a/target/arm/cpu.h | 22 | --- a/include/hw/arm/armsse.h |
25 | +++ b/target/arm/cpu.h | 23 | +++ b/include/hw/arm/armsse.h |
26 | @@ -XXX,XX +XXX,XX @@ typedef enum ARMPSCIState { | 24 | @@ -XXX,XX +XXX,XX @@ |
27 | PSCI_ON_PENDING = 2 | 25 | * per-CPU identity and control register blocks |
28 | } ARMPSCIState; | 26 | * |
29 | 27 | * QEMU interface: | |
30 | +typedef struct ARMISARegisters ARMISARegisters; | 28 | + * + Clock input "MAINCLK": clock for CPUs and most peripherals |
29 | + * + Clock input "S32KCLK": slow 32KHz clock used for a few peripherals | ||
30 | * + QOM property "memory" is a MemoryRegion containing the devices provided | ||
31 | * by the board model. | ||
32 | * + QOM property "MAINCLK_FRQ" is the frequency of the main system clock | ||
33 | @@ -XXX,XX +XXX,XX @@ | ||
34 | #include "hw/misc/armsse-mhu.h" | ||
35 | #include "hw/misc/unimp.h" | ||
36 | #include "hw/or-irq.h" | ||
37 | +#include "hw/clock.h" | ||
38 | #include "hw/core/split-irq.h" | ||
39 | #include "hw/cpu/cluster.h" | ||
40 | #include "qom/object.h" | ||
41 | @@ -XXX,XX +XXX,XX @@ struct ARMSSE { | ||
42 | |||
43 | uint32_t nsccfg; | ||
44 | |||
45 | + Clock *mainclk; | ||
46 | + Clock *s32kclk; | ||
31 | + | 47 | + |
32 | /** | 48 | /* Properties */ |
33 | * ARMCPU: | 49 | MemoryRegion *board_memory; |
34 | * @env: #CPUARMState | 50 | uint32_t exp_numirq; |
35 | @@ -XXX,XX +XXX,XX @@ enum arm_features { | 51 | diff --git a/hw/arm/armsse.c b/hw/arm/armsse.c |
36 | ARM_FEATURE_LPAE, /* has Large Physical Address Extension */ | 52 | index XXXXXXX..XXXXXXX 100644 |
37 | ARM_FEATURE_V8, | 53 | --- a/hw/arm/armsse.c |
38 | ARM_FEATURE_AARCH64, /* supports 64 bit mode */ | 54 | +++ b/hw/arm/armsse.c |
39 | - ARM_FEATURE_V8_AES, /* implements AES part of v8 Crypto Extensions */ | 55 | @@ -XXX,XX +XXX,XX @@ |
40 | ARM_FEATURE_CBAR, /* has cp15 CBAR */ | 56 | #include "hw/arm/armsse.h" |
41 | ARM_FEATURE_CRC, /* ARMv8 CRC instructions */ | 57 | #include "hw/arm/boot.h" |
42 | ARM_FEATURE_CBAR_RO, /* has cp15 CBAR and it is read-only */ | 58 | #include "hw/irq.h" |
43 | ARM_FEATURE_EL2, /* has EL2 Virtualization support */ | 59 | +#include "hw/qdev-clock.h" |
44 | ARM_FEATURE_EL3, /* has EL3 Secure monitor support */ | 60 | |
45 | - ARM_FEATURE_V8_SHA1, /* implements SHA1 part of v8 Crypto Extensions */ | 61 | /* Format of the System Information block SYS_CONFIG register */ |
46 | - ARM_FEATURE_V8_SHA256, /* implements SHA256 part of v8 Crypto Extensions */ | 62 | typedef enum SysConfigFormat { |
47 | - ARM_FEATURE_V8_PMULL, /* implements PMULL part of v8 Crypto Extensions */ | 63 | @@ -XXX,XX +XXX,XX @@ static void armsse_init(Object *obj) |
48 | ARM_FEATURE_THUMB_DSP, /* DSP insns supported in the Thumb encodings */ | 64 | assert(info->sram_banks <= MAX_SRAM_BANKS); |
49 | ARM_FEATURE_PMU, /* has PMU support */ | 65 | assert(info->num_cpus <= SSE_MAX_CPUS); |
50 | ARM_FEATURE_VBAR, /* has cp15 VBAR */ | 66 | |
51 | ARM_FEATURE_M_SECURITY, /* M profile Security Extension */ | 67 | + s->mainclk = qdev_init_clock_in(DEVICE(s), "MAINCLK", NULL, NULL); |
52 | ARM_FEATURE_JAZELLE, /* has (trivial) Jazelle implementation */ | 68 | + s->s32kclk = qdev_init_clock_in(DEVICE(s), "S32KCLK", NULL, NULL); |
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 | + | 69 | + |
78 | +static inline bool isar_feature_aa32_pmull(const ARMISARegisters *id) | 70 | memory_region_init(&s->container, obj, "armsse-container", UINT64_MAX); |
79 | +{ | 71 | |
80 | + return FIELD_EX32(id->id_isar5, ID_ISAR5, AES) > 1; | 72 | for (i = 0; i < info->num_cpus; i++) { |
81 | +} | 73 | @@ -XXX,XX +XXX,XX @@ static void armsse_realize(DeviceState *dev, Error **errp) |
82 | + | 74 | * map its upstream ends to the right place in the container. |
83 | +static inline bool isar_feature_aa32_sha1(const ARMISARegisters *id) | 75 | */ |
84 | +{ | 76 | qdev_prop_set_uint32(DEVICE(&s->timer0), "pclk-frq", s->mainclk_frq); |
85 | + return FIELD_EX32(id->id_isar5, ID_ISAR5, SHA1) != 0; | 77 | + qdev_connect_clock_in(DEVICE(&s->timer0), "pclk", s->mainclk); |
86 | +} | 78 | if (!sysbus_realize(SYS_BUS_DEVICE(&s->timer0), errp)) { |
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 | ||
189 | index XXXXXXX..XXXXXXX 100644 | ||
190 | --- a/target/arm/translate.h | ||
191 | +++ b/target/arm/translate.h | ||
192 | @@ -XXX,XX +XXX,XX @@ | ||
193 | /* internal defines */ | ||
194 | typedef struct DisasContext { | ||
195 | DisasContextBase base; | ||
196 | + const ARMISARegisters *isar; | ||
197 | |||
198 | target_ulong pc; | ||
199 | target_ulong page_start; | ||
200 | @@ -XXX,XX +XXX,XX @@ static inline TCGv_i32 get_ahp_flag(void) | ||
201 | return ret; | ||
202 | } | ||
203 | |||
204 | +/* | ||
205 | + * Forward to the isar_feature_* tests given a DisasContext pointer. | ||
206 | + */ | ||
207 | +#define dc_isar_feature(name, ctx) \ | ||
208 | + ({ DisasContext *ctx_ = (ctx); isar_feature_##name(ctx_->isar); }) | ||
209 | + | ||
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 | ||
291 | index XXXXXXX..XXXXXXX 100644 | ||
292 | --- a/target/arm/cpu.c | ||
293 | +++ b/target/arm/cpu.c | ||
294 | @@ -XXX,XX +XXX,XX @@ static void arm_max_initfn(Object *obj) | ||
295 | cortex_a15_initfn(obj); | ||
296 | #ifdef CONFIG_USER_ONLY | ||
297 | /* We don't set these in system emulation mode for the moment, | ||
298 | - * since we don't correctly set the ID registers to advertise them, | ||
299 | + * since we don't correctly set (all of) the ID registers to | ||
300 | + * advertise them. | ||
301 | */ | ||
302 | set_feature(&cpu->env, ARM_FEATURE_V8); | ||
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 | ||
328 | } | ||
329 | } | ||
330 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | ||
331 | index XXXXXXX..XXXXXXX 100644 | ||
332 | --- a/target/arm/cpu64.c | ||
333 | +++ b/target/arm/cpu64.c | ||
334 | @@ -XXX,XX +XXX,XX @@ static void aarch64_a57_initfn(Object *obj) | ||
335 | set_feature(&cpu->env, ARM_FEATURE_GENERIC_TIMER); | ||
336 | set_feature(&cpu->env, ARM_FEATURE_AARCH64); | ||
337 | set_feature(&cpu->env, ARM_FEATURE_CBAR_RO); | ||
338 | - set_feature(&cpu->env, ARM_FEATURE_V8_AES); | ||
339 | - set_feature(&cpu->env, ARM_FEATURE_V8_SHA1); | ||
340 | - set_feature(&cpu->env, ARM_FEATURE_V8_SHA256); | ||
341 | - set_feature(&cpu->env, ARM_FEATURE_V8_PMULL); | ||
342 | - set_feature(&cpu->env, ARM_FEATURE_CRC); | ||
343 | set_feature(&cpu->env, ARM_FEATURE_EL2); | ||
344 | set_feature(&cpu->env, ARM_FEATURE_EL3); | ||
345 | set_feature(&cpu->env, ARM_FEATURE_PMU); | ||
346 | @@ -XXX,XX +XXX,XX @@ static void aarch64_a53_initfn(Object *obj) | ||
347 | set_feature(&cpu->env, ARM_FEATURE_GENERIC_TIMER); | ||
348 | set_feature(&cpu->env, ARM_FEATURE_AARCH64); | ||
349 | set_feature(&cpu->env, ARM_FEATURE_CBAR_RO); | ||
350 | - set_feature(&cpu->env, ARM_FEATURE_V8_AES); | ||
351 | - set_feature(&cpu->env, ARM_FEATURE_V8_SHA1); | ||
352 | - set_feature(&cpu->env, ARM_FEATURE_V8_SHA256); | ||
353 | - set_feature(&cpu->env, ARM_FEATURE_V8_PMULL); | ||
354 | - set_feature(&cpu->env, ARM_FEATURE_CRC); | ||
355 | set_feature(&cpu->env, ARM_FEATURE_EL2); | ||
356 | set_feature(&cpu->env, ARM_FEATURE_EL3); | ||
357 | set_feature(&cpu->env, ARM_FEATURE_PMU); | ||
358 | @@ -XXX,XX +XXX,XX @@ static void aarch64_a72_initfn(Object *obj) | ||
359 | set_feature(&cpu->env, ARM_FEATURE_GENERIC_TIMER); | ||
360 | set_feature(&cpu->env, ARM_FEATURE_AARCH64); | ||
361 | set_feature(&cpu->env, ARM_FEATURE_CBAR_RO); | ||
362 | - set_feature(&cpu->env, ARM_FEATURE_V8_AES); | ||
363 | - set_feature(&cpu->env, ARM_FEATURE_V8_SHA1); | ||
364 | - set_feature(&cpu->env, ARM_FEATURE_V8_SHA256); | ||
365 | - set_feature(&cpu->env, ARM_FEATURE_V8_PMULL); | ||
366 | - set_feature(&cpu->env, ARM_FEATURE_CRC); | ||
367 | set_feature(&cpu->env, ARM_FEATURE_EL2); | ||
368 | set_feature(&cpu->env, ARM_FEATURE_EL3); | ||
369 | set_feature(&cpu->env, ARM_FEATURE_PMU); | ||
370 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) | ||
371 | if (kvm_enabled()) { | ||
372 | kvm_arm_set_cpu_features_from_host(cpu); | ||
373 | } else { | ||
374 | + uint64_t t; | ||
375 | + uint32_t u; | ||
376 | aarch64_a57_initfn(obj); | ||
377 | + | ||
378 | + t = cpu->isar.id_aa64isar0; | ||
379 | + t = FIELD_DP64(t, ID_AA64ISAR0, AES, 2); /* AES + PMULL */ | ||
380 | + t = FIELD_DP64(t, ID_AA64ISAR0, SHA1, 1); | ||
381 | + t = FIELD_DP64(t, ID_AA64ISAR0, SHA2, 2); /* SHA512 */ | ||
382 | + t = FIELD_DP64(t, ID_AA64ISAR0, CRC32, 1); | ||
383 | + t = FIELD_DP64(t, ID_AA64ISAR0, ATOMIC, 2); | ||
384 | + t = FIELD_DP64(t, ID_AA64ISAR0, RDM, 1); | ||
385 | + t = FIELD_DP64(t, ID_AA64ISAR0, SHA3, 1); | ||
386 | + t = FIELD_DP64(t, ID_AA64ISAR0, SM3, 1); | ||
387 | + t = FIELD_DP64(t, ID_AA64ISAR0, SM4, 1); | ||
388 | + t = FIELD_DP64(t, ID_AA64ISAR0, DP, 1); | ||
389 | + cpu->isar.id_aa64isar0 = t; | ||
390 | + | ||
391 | + t = cpu->isar.id_aa64isar1; | ||
392 | + t = FIELD_DP64(t, ID_AA64ISAR1, FCMA, 1); | ||
393 | + cpu->isar.id_aa64isar1 = t; | ||
394 | + | ||
395 | + /* Replicate the same data to the 32-bit id registers. */ | ||
396 | + u = cpu->isar.id_isar5; | ||
397 | + u = FIELD_DP32(u, ID_ISAR5, AES, 2); /* AES + PMULL */ | ||
398 | + u = FIELD_DP32(u, ID_ISAR5, SHA1, 1); | ||
399 | + u = FIELD_DP32(u, ID_ISAR5, SHA2, 1); | ||
400 | + u = FIELD_DP32(u, ID_ISAR5, CRC32, 1); | ||
401 | + u = FIELD_DP32(u, ID_ISAR5, RDM, 1); | ||
402 | + u = FIELD_DP32(u, ID_ISAR5, VCMA, 1); | ||
403 | + cpu->isar.id_isar5 = u; | ||
404 | + | ||
405 | + u = cpu->isar.id_isar6; | ||
406 | + u = FIELD_DP32(u, ID_ISAR6, DP, 1); | ||
407 | + cpu->isar.id_isar6 = u; | ||
408 | + | ||
409 | #ifdef CONFIG_USER_ONLY | ||
410 | /* We don't set these in system emulation mode for the moment, | ||
411 | * since we don't correctly set the ID registers to advertise them, | ||
412 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) | ||
413 | * whereas the architecture requires them to be present in both if | ||
414 | * present in either. | ||
415 | */ | ||
416 | - set_feature(&cpu->env, ARM_FEATURE_V8_SHA512); | ||
417 | - set_feature(&cpu->env, ARM_FEATURE_V8_SHA3); | ||
418 | - set_feature(&cpu->env, ARM_FEATURE_V8_SM3); | ||
419 | - set_feature(&cpu->env, ARM_FEATURE_V8_SM4); | ||
420 | - set_feature(&cpu->env, ARM_FEATURE_V8_ATOMICS); | ||
421 | - set_feature(&cpu->env, ARM_FEATURE_V8_RDM); | ||
422 | - set_feature(&cpu->env, ARM_FEATURE_V8_DOTPROD); | ||
423 | set_feature(&cpu->env, ARM_FEATURE_V8_FP16); | ||
424 | - set_feature(&cpu->env, ARM_FEATURE_V8_FCMA); | ||
425 | set_feature(&cpu->env, ARM_FEATURE_SVE); | ||
426 | /* For usermode -cpu max we can use a larger and more efficient DCZ | ||
427 | * blocksize since we don't have to follow what the hardware does. | ||
428 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
429 | index XXXXXXX..XXXXXXX 100644 | ||
430 | --- a/target/arm/translate-a64.c | ||
431 | +++ b/target/arm/translate-a64.c | ||
432 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_excl(DisasContext *s, uint32_t insn) | ||
433 | } | ||
434 | if (rt2 == 31 | ||
435 | && ((rt | rs) & 1) == 0 | ||
436 | - && arm_dc_feature(s, ARM_FEATURE_V8_ATOMICS)) { | ||
437 | + && dc_isar_feature(aa64_atomics, s)) { | ||
438 | /* CASP / CASPL */ | ||
439 | gen_compare_and_swap_pair(s, rs, rt, rn, size | 2); | ||
440 | return; | ||
441 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_excl(DisasContext *s, uint32_t insn) | ||
442 | } | ||
443 | if (rt2 == 31 | ||
444 | && ((rt | rs) & 1) == 0 | ||
445 | - && arm_dc_feature(s, ARM_FEATURE_V8_ATOMICS)) { | ||
446 | + && dc_isar_feature(aa64_atomics, s)) { | ||
447 | /* CASPA / CASPAL */ | ||
448 | gen_compare_and_swap_pair(s, rs, rt, rn, size | 2); | ||
449 | return; | ||
450 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_excl(DisasContext *s, uint32_t insn) | ||
451 | case 0xb: /* CASL */ | ||
452 | case 0xe: /* CASA */ | ||
453 | case 0xf: /* CASAL */ | ||
454 | - if (rt2 == 31 && arm_dc_feature(s, ARM_FEATURE_V8_ATOMICS)) { | ||
455 | + if (rt2 == 31 && dc_isar_feature(aa64_atomics, s)) { | ||
456 | gen_compare_and_swap(s, rs, rt, rn, size); | ||
457 | return; | ||
458 | } | ||
459 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_atomic(DisasContext *s, uint32_t insn, | ||
460 | int rs = extract32(insn, 16, 5); | ||
461 | int rn = extract32(insn, 5, 5); | ||
462 | int o3_opc = extract32(insn, 12, 4); | ||
463 | - int feature = ARM_FEATURE_V8_ATOMICS; | ||
464 | TCGv_i64 tcg_rn, tcg_rs; | ||
465 | AtomicThreeOpFn *fn; | ||
466 | |||
467 | - if (is_vector) { | ||
468 | + if (is_vector || !dc_isar_feature(aa64_atomics, s)) { | ||
469 | unallocated_encoding(s); | ||
470 | return; | 79 | return; |
471 | } | 80 | } |
472 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_atomic(DisasContext *s, uint32_t insn, | 81 | @@ -XXX,XX +XXX,XX @@ static void armsse_realize(DeviceState *dev, Error **errp) |
473 | unallocated_encoding(s); | 82 | &error_abort); |
83 | |||
84 | qdev_prop_set_uint32(DEVICE(&s->timer1), "pclk-frq", s->mainclk_frq); | ||
85 | + qdev_connect_clock_in(DEVICE(&s->timer1), "pclk", s->mainclk); | ||
86 | if (!sysbus_realize(SYS_BUS_DEVICE(&s->timer1), errp)) { | ||
474 | return; | 87 | return; |
475 | } | 88 | } |
476 | - if (!arm_dc_feature(s, feature)) { | 89 | @@ -XXX,XX +XXX,XX @@ static void armsse_realize(DeviceState *dev, Error **errp) |
477 | - unallocated_encoding(s); | 90 | &error_abort); |
478 | - return; | 91 | |
479 | - } | 92 | qdev_prop_set_uint32(DEVICE(&s->dualtimer), "pclk-frq", s->mainclk_frq); |
480 | 93 | + qdev_connect_clock_in(DEVICE(&s->dualtimer), "TIMCLK", s->mainclk); | |
481 | if (rn == 31) { | 94 | if (!sysbus_realize(SYS_BUS_DEVICE(&s->dualtimer), errp)) { |
482 | gen_check_sp_alignment(s); | ||
483 | @@ -XXX,XX +XXX,XX @@ static void handle_crc32(DisasContext *s, | ||
484 | TCGv_i64 tcg_acc, tcg_val; | ||
485 | TCGv_i32 tcg_bytes; | ||
486 | |||
487 | - if (!arm_dc_feature(s, ARM_FEATURE_CRC) | ||
488 | + if (!dc_isar_feature(aa64_crc32, s) | ||
489 | || (sf == 1 && sz != 3) | ||
490 | || (sf == 0 && sz == 3)) { | ||
491 | unallocated_encoding(s); | ||
492 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_scalar_three_reg_same_extra(DisasContext *s, | ||
493 | bool u = extract32(insn, 29, 1); | ||
494 | TCGv_i32 ele1, ele2, ele3; | ||
495 | TCGv_i64 res; | ||
496 | - int feature; | ||
497 | + bool feature; | ||
498 | |||
499 | switch (u * 16 + opcode) { | ||
500 | case 0x10: /* SQRDMLAH (vector) */ | ||
501 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_scalar_three_reg_same_extra(DisasContext *s, | ||
502 | unallocated_encoding(s); | ||
503 | return; | ||
504 | } | ||
505 | - feature = ARM_FEATURE_V8_RDM; | ||
506 | + feature = dc_isar_feature(aa64_rdm, s); | ||
507 | break; | ||
508 | default: | ||
509 | unallocated_encoding(s); | ||
510 | return; | 95 | return; |
511 | } | 96 | } |
512 | - if (!arm_dc_feature(s, feature)) { | 97 | @@ -XXX,XX +XXX,XX @@ static void armsse_realize(DeviceState *dev, Error **errp) |
513 | + if (!feature) { | 98 | * 0x4002f000: S32K timer |
514 | unallocated_encoding(s); | 99 | */ |
100 | qdev_prop_set_uint32(DEVICE(&s->s32ktimer), "pclk-frq", S32KCLK); | ||
101 | + qdev_connect_clock_in(DEVICE(&s->s32ktimer), "pclk", s->s32kclk); | ||
102 | if (!sysbus_realize(SYS_BUS_DEVICE(&s->s32ktimer), errp)) { | ||
515 | return; | 103 | return; |
516 | } | 104 | } |
517 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_three_reg_diff(DisasContext *s, uint32_t insn) | 105 | @@ -XXX,XX +XXX,XX @@ static void armsse_realize(DeviceState *dev, Error **errp) |
518 | return; | 106 | qdev_get_gpio_in_named(DEVICE(&s->armv7m), "NMI", 0)); |
519 | } | 107 | |
520 | if (size == 3) { | 108 | qdev_prop_set_uint32(DEVICE(&s->s32kwatchdog), "wdogclk-frq", S32KCLK); |
521 | - if (!arm_dc_feature(s, ARM_FEATURE_V8_PMULL)) { | 109 | + qdev_connect_clock_in(DEVICE(&s->s32kwatchdog), "WDOGCLK", s->s32kclk); |
522 | + if (!dc_isar_feature(aa64_pmull, s)) { | 110 | if (!sysbus_realize(SYS_BUS_DEVICE(&s->s32kwatchdog), errp)) { |
523 | unallocated_encoding(s); | ||
524 | return; | ||
525 | } | ||
526 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_three_reg_same_extra(DisasContext *s, uint32_t insn) | ||
527 | int size = extract32(insn, 22, 2); | ||
528 | bool u = extract32(insn, 29, 1); | ||
529 | bool is_q = extract32(insn, 30, 1); | ||
530 | - int feature, rot; | ||
531 | + bool feature; | ||
532 | + int rot; | ||
533 | |||
534 | switch (u * 16 + opcode) { | ||
535 | case 0x10: /* SQRDMLAH (vector) */ | ||
536 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_three_reg_same_extra(DisasContext *s, uint32_t insn) | ||
537 | unallocated_encoding(s); | ||
538 | return; | ||
539 | } | ||
540 | - feature = ARM_FEATURE_V8_RDM; | ||
541 | + feature = dc_isar_feature(aa64_rdm, s); | ||
542 | break; | ||
543 | case 0x02: /* SDOT (vector) */ | ||
544 | case 0x12: /* UDOT (vector) */ | ||
545 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_three_reg_same_extra(DisasContext *s, uint32_t insn) | ||
546 | unallocated_encoding(s); | ||
547 | return; | ||
548 | } | ||
549 | - feature = ARM_FEATURE_V8_DOTPROD; | ||
550 | + feature = dc_isar_feature(aa64_dp, s); | ||
551 | break; | ||
552 | case 0x18: /* FCMLA, #0 */ | ||
553 | case 0x19: /* FCMLA, #90 */ | ||
554 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_three_reg_same_extra(DisasContext *s, uint32_t insn) | ||
555 | unallocated_encoding(s); | ||
556 | return; | ||
557 | } | ||
558 | - feature = ARM_FEATURE_V8_FCMA; | ||
559 | + feature = dc_isar_feature(aa64_fcma, s); | ||
560 | break; | ||
561 | default: | ||
562 | unallocated_encoding(s); | ||
563 | return; | 111 | return; |
564 | } | 112 | } |
565 | - if (!arm_dc_feature(s, feature)) { | 113 | @@ -XXX,XX +XXX,XX @@ static void armsse_realize(DeviceState *dev, Error **errp) |
566 | + if (!feature) { | 114 | /* 0x40080000 .. 0x4008ffff : ARMSSE second Base peripheral region */ |
567 | unallocated_encoding(s); | 115 | |
116 | qdev_prop_set_uint32(DEVICE(&s->nswatchdog), "wdogclk-frq", s->mainclk_frq); | ||
117 | + qdev_connect_clock_in(DEVICE(&s->nswatchdog), "WDOGCLK", s->mainclk); | ||
118 | if (!sysbus_realize(SYS_BUS_DEVICE(&s->nswatchdog), errp)) { | ||
568 | return; | 119 | return; |
569 | } | 120 | } |
570 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_indexed(DisasContext *s, uint32_t insn) | 121 | @@ -XXX,XX +XXX,XX @@ static void armsse_realize(DeviceState *dev, Error **errp) |
571 | break; | 122 | sysbus_mmio_map(SYS_BUS_DEVICE(&s->nswatchdog), 0, 0x40081000); |
572 | case 0x1d: /* SQRDMLAH */ | 123 | |
573 | case 0x1f: /* SQRDMLSH */ | 124 | qdev_prop_set_uint32(DEVICE(&s->swatchdog), "wdogclk-frq", s->mainclk_frq); |
574 | - if (!arm_dc_feature(s, ARM_FEATURE_V8_RDM)) { | 125 | + qdev_connect_clock_in(DEVICE(&s->swatchdog), "WDOGCLK", s->mainclk); |
575 | + if (!dc_isar_feature(aa64_rdm, s)) { | 126 | if (!sysbus_realize(SYS_BUS_DEVICE(&s->swatchdog), errp)) { |
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; | 127 | return; |
605 | } | 128 | } |
606 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_three_reg_sha(DisasContext *s, uint32_t insn) | 129 | @@ -XXX,XX +XXX,XX @@ static void armsse_idau_check(IDAUInterface *ii, uint32_t address, |
607 | int rd = extract32(insn, 0, 5); | 130 | |
608 | CryptoThreeOpFn *genfn; | 131 | static const VMStateDescription armsse_vmstate = { |
609 | TCGv_ptr tcg_rd_ptr, tcg_rn_ptr, tcg_rm_ptr; | 132 | .name = "iotkit", |
610 | - int feature = ARM_FEATURE_V8_SHA256; | 133 | - .version_id = 1, |
611 | + bool feature; | 134 | - .minimum_version_id = 1, |
612 | 135 | + .version_id = 2, | |
613 | if (size != 0) { | 136 | + .minimum_version_id = 2, |
614 | unallocated_encoding(s); | 137 | .fields = (VMStateField[]) { |
615 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_three_reg_sha(DisasContext *s, uint32_t insn) | 138 | + VMSTATE_CLOCK(mainclk, ARMSSE), |
616 | case 2: /* SHA1M */ | 139 | + VMSTATE_CLOCK(s32kclk, ARMSSE), |
617 | case 3: /* SHA1SU0 */ | 140 | VMSTATE_UINT32(nsccfg, ARMSSE), |
618 | genfn = NULL; | 141 | VMSTATE_END_OF_LIST() |
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 | } | 142 | } |
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 | ||
822 | index XXXXXXX..XXXXXXX 100644 | ||
823 | --- a/target/arm/translate.c | ||
824 | +++ b/target/arm/translate.c | ||
825 | @@ -XXX,XX +XXX,XX @@ static const uint8_t neon_2rm_sizes[] = { | ||
826 | static int do_v81_helper(DisasContext *s, gen_helper_gvec_3_ptr *fn, | ||
827 | int q, int rd, int rn, int rm) | ||
828 | { | ||
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 | -- | 143 | -- |
976 | 2.19.1 | 144 | 2.20.1 |
977 | 145 | ||
978 | 146 | diff view generated by jsdifflib |
1 | The HCR.DC virtualization configuration register bit has the | 1 | The old-style convenience function cmsdk_apb_timer_create() for |
---|---|---|---|
2 | following effects: | 2 | creating CMSDK_APB_TIMER objects is used in only two places in |
3 | * SCTLR.M behaves as if it is 0 for all purposes except | 3 | mps2.c. Most of the rest of the code in that file uses the new |
4 | direct reads of the bit | 4 | "initialize in place" coding style. |
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 | 5 | ||
12 | Implement this behaviour. | 6 | We want to connect up a Clock object which should be done between the |
7 | object creation and realization; rather than adding a Clock* argument | ||
8 | to the convenience function, convert the timer creation code in | ||
9 | mps2.c to the same style as is used already for the watchdog, | ||
10 | dualtimer and other devices, and delete the now-unused convenience | ||
11 | function. | ||
13 | 12 | ||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
15 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 14 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
16 | Message-id: 20181012144235.19646-5-peter.maydell@linaro.org | 15 | Reviewed-by: Luc Michel <luc@lmichel.fr> |
16 | Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
17 | Message-id: 20210128114145.20536-13-peter.maydell@linaro.org | ||
18 | Message-id: 20210121190622.22000-13-peter.maydell@linaro.org | ||
17 | --- | 19 | --- |
18 | target/arm/helper.c | 23 +++++++++++++++++++++-- | 20 | include/hw/timer/cmsdk-apb-timer.h | 21 --------------------- |
19 | 1 file changed, 21 insertions(+), 2 deletions(-) | 21 | hw/arm/mps2.c | 18 ++++++++++++++++-- |
22 | 2 files changed, 16 insertions(+), 23 deletions(-) | ||
20 | 23 | ||
21 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 24 | diff --git a/include/hw/timer/cmsdk-apb-timer.h b/include/hw/timer/cmsdk-apb-timer.h |
22 | index XXXXXXX..XXXXXXX 100644 | 25 | index XXXXXXX..XXXXXXX 100644 |
23 | --- a/target/arm/helper.c | 26 | --- a/include/hw/timer/cmsdk-apb-timer.h |
24 | +++ b/target/arm/helper.c | 27 | +++ b/include/hw/timer/cmsdk-apb-timer.h |
25 | @@ -XXX,XX +XXX,XX @@ static uint64_t do_ats_write(CPUARMState *env, uint64_t value, | 28 | @@ -XXX,XX +XXX,XX @@ struct CMSDKAPBTimer { |
26 | * * The Non-secure TTBCR.EAE bit is set to 1 | 29 | uint32_t intstatus; |
27 | * * The implementation includes EL2, and the value of HCR.VM is 1 | 30 | }; |
28 | * | 31 | |
29 | + * (Note that HCR.DC makes HCR.VM behave as if it is 1.) | 32 | -/** |
30 | + * | 33 | - * cmsdk_apb_timer_create - convenience function to create TYPE_CMSDK_APB_TIMER |
31 | * ATS1Hx always uses the 64bit format (not supported yet). | 34 | - * @addr: location in system memory to map registers |
32 | */ | 35 | - * @pclk_frq: frequency in Hz of the PCLK clock (used for calculating baud rate) |
33 | format64 = arm_s1_regime_using_lpae_format(env, mmu_idx); | 36 | - */ |
34 | 37 | -static inline DeviceState *cmsdk_apb_timer_create(hwaddr addr, | |
35 | if (arm_feature(env, ARM_FEATURE_EL2)) { | 38 | - qemu_irq timerint, |
36 | if (mmu_idx == ARMMMUIdx_S12NSE0 || mmu_idx == ARMMMUIdx_S12NSE1) { | 39 | - uint32_t pclk_frq) |
37 | - format64 |= env->cp15.hcr_el2 & HCR_VM; | 40 | -{ |
38 | + format64 |= env->cp15.hcr_el2 & (HCR_VM | HCR_DC); | 41 | - DeviceState *dev; |
39 | } else { | 42 | - SysBusDevice *s; |
40 | format64 |= arm_current_el(env) == 2; | 43 | - |
41 | } | 44 | - dev = qdev_new(TYPE_CMSDK_APB_TIMER); |
42 | @@ -XXX,XX +XXX,XX @@ static inline bool regime_translation_disabled(CPUARMState *env, | 45 | - s = SYS_BUS_DEVICE(dev); |
46 | - qdev_prop_set_uint32(dev, "pclk-frq", pclk_frq); | ||
47 | - sysbus_realize_and_unref(s, &error_fatal); | ||
48 | - sysbus_mmio_map(s, 0, addr); | ||
49 | - sysbus_connect_irq(s, 0, timerint); | ||
50 | - return dev; | ||
51 | -} | ||
52 | - | ||
53 | #endif | ||
54 | diff --git a/hw/arm/mps2.c b/hw/arm/mps2.c | ||
55 | index XXXXXXX..XXXXXXX 100644 | ||
56 | --- a/hw/arm/mps2.c | ||
57 | +++ b/hw/arm/mps2.c | ||
58 | @@ -XXX,XX +XXX,XX @@ struct MPS2MachineState { | ||
59 | /* CMSDK APB subsystem */ | ||
60 | CMSDKAPBDualTimer dualtimer; | ||
61 | CMSDKAPBWatchdog watchdog; | ||
62 | + CMSDKAPBTimer timer[2]; | ||
63 | }; | ||
64 | |||
65 | #define TYPE_MPS2_MACHINE "mps2" | ||
66 | @@ -XXX,XX +XXX,XX @@ static void mps2_common_init(MachineState *machine) | ||
43 | } | 67 | } |
44 | 68 | ||
45 | if (mmu_idx == ARMMMUIdx_S2NS) { | 69 | /* CMSDK APB subsystem */ |
46 | - return (env->cp15.hcr_el2 & HCR_VM) == 0; | 70 | - cmsdk_apb_timer_create(0x40000000, qdev_get_gpio_in(armv7m, 8), SYSCLK_FRQ); |
47 | + /* HCR.DC means HCR.VM behaves as 1 */ | 71 | - cmsdk_apb_timer_create(0x40001000, qdev_get_gpio_in(armv7m, 9), SYSCLK_FRQ); |
48 | + return (env->cp15.hcr_el2 & (HCR_DC | HCR_VM)) == 0; | 72 | + for (i = 0; i < ARRAY_SIZE(mms->timer); i++) { |
49 | } | 73 | + g_autofree char *name = g_strdup_printf("timer%d", i); |
50 | 74 | + hwaddr base = 0x40000000 + i * 0x1000; | |
51 | if (env->cp15.hcr_el2 & HCR_TGE) { | 75 | + int irqno = 8 + i; |
52 | @@ -XXX,XX +XXX,XX @@ static inline bool regime_translation_disabled(CPUARMState *env, | 76 | + SysBusDevice *sbd; |
53 | } | 77 | + |
54 | } | 78 | + object_initialize_child(OBJECT(mms), name, &mms->timer[i], |
55 | 79 | + TYPE_CMSDK_APB_TIMER); | |
56 | + if ((env->cp15.hcr_el2 & HCR_DC) && | 80 | + sbd = SYS_BUS_DEVICE(&mms->timer[i]); |
57 | + (mmu_idx == ARMMMUIdx_S1NSE0 || mmu_idx == ARMMMUIdx_S1NSE1)) { | 81 | + qdev_prop_set_uint32(DEVICE(&mms->timer[i]), "pclk-frq", SYSCLK_FRQ); |
58 | + /* HCR.DC means SCTLR_EL1.M behaves as 0 */ | 82 | + sysbus_realize_and_unref(sbd, &error_fatal); |
59 | + return true; | 83 | + sysbus_mmio_map(sbd, 0, base); |
84 | + sysbus_connect_irq(sbd, 0, qdev_get_gpio_in(armv7m, irqno)); | ||
60 | + } | 85 | + } |
61 | + | 86 | + |
62 | return (regime_sctlr(env, mmu_idx) & SCTLR_M) == 0; | 87 | object_initialize_child(OBJECT(mms), "dualtimer", &mms->dualtimer, |
63 | } | 88 | TYPE_CMSDK_APB_DUALTIMER); |
64 | 89 | qdev_prop_set_uint32(DEVICE(&mms->dualtimer), "pclk-frq", SYSCLK_FRQ); | |
65 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr(CPUARMState *env, target_ulong address, | ||
66 | |||
67 | /* Combine the S1 and S2 cache attributes, if needed */ | ||
68 | if (!ret && cacheattrs != NULL) { | ||
69 | + if (env->cp15.hcr_el2 & HCR_DC) { | ||
70 | + /* | ||
71 | + * HCR.DC forces the first stage attributes to | ||
72 | + * Normal Non-Shareable, | ||
73 | + * Inner Write-Back Read-Allocate Write-Allocate, | ||
74 | + * Outer Write-Back Read-Allocate Write-Allocate. | ||
75 | + */ | ||
76 | + cacheattrs->attrs = 0xff; | ||
77 | + cacheattrs->shareability = 0; | ||
78 | + } | ||
79 | *cacheattrs = combine_cacheattrs(*cacheattrs, cacheattrs2); | ||
80 | } | ||
81 | |||
82 | -- | 90 | -- |
83 | 2.19.1 | 91 | 2.20.1 |
84 | 92 | ||
85 | 93 | diff view generated by jsdifflib |
1 | If the HCR_EL2 PTW virtualizaiton configuration register bit | 1 | Create a fixed-frequency Clock object to be the SYSCLK, and wire it |
---|---|---|---|
2 | is set, then this means that a stage 2 Permission fault must | 2 | up to the devices that require it. |
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 | 3 | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 5 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
9 | Message-id: 20181012144235.19646-8-peter.maydell@linaro.org | 6 | Reviewed-by: Luc Michel <luc@lmichel.fr> |
7 | Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
8 | Message-id: 20210128114145.20536-14-peter.maydell@linaro.org | ||
9 | Message-id: 20210121190622.22000-14-peter.maydell@linaro.org | ||
10 | --- | 10 | --- |
11 | target/arm/helper.c | 21 ++++++++++++++++++++- | 11 | hw/arm/mps2.c | 9 +++++++++ |
12 | 1 file changed, 20 insertions(+), 1 deletion(-) | 12 | 1 file changed, 9 insertions(+) |
13 | 13 | ||
14 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 14 | diff --git a/hw/arm/mps2.c b/hw/arm/mps2.c |
15 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/helper.c | 16 | --- a/hw/arm/mps2.c |
17 | +++ b/target/arm/helper.c | 17 | +++ b/hw/arm/mps2.c |
18 | @@ -XXX,XX +XXX,XX @@ static hwaddr S1_ptw_translate(CPUARMState *env, ARMMMUIdx mmu_idx, | 18 | @@ -XXX,XX +XXX,XX @@ |
19 | hwaddr s2pa; | 19 | #include "hw/net/lan9118.h" |
20 | int s2prot; | 20 | #include "net/net.h" |
21 | int ret; | 21 | #include "hw/watchdog/cmsdk-apb-watchdog.h" |
22 | + ARMCacheAttrs cacheattrs = {}; | 22 | +#include "hw/qdev-clock.h" |
23 | + ARMCacheAttrs *pcacheattrs = NULL; | 23 | #include "qom/object.h" |
24 | |||
25 | typedef enum MPS2FPGAType { | ||
26 | @@ -XXX,XX +XXX,XX @@ struct MPS2MachineState { | ||
27 | CMSDKAPBDualTimer dualtimer; | ||
28 | CMSDKAPBWatchdog watchdog; | ||
29 | CMSDKAPBTimer timer[2]; | ||
30 | + Clock *sysclk; | ||
31 | }; | ||
32 | |||
33 | #define TYPE_MPS2_MACHINE "mps2" | ||
34 | @@ -XXX,XX +XXX,XX @@ static void mps2_common_init(MachineState *machine) | ||
35 | exit(EXIT_FAILURE); | ||
36 | } | ||
37 | |||
38 | + /* This clock doesn't need migration because it is fixed-frequency */ | ||
39 | + mms->sysclk = clock_new(OBJECT(machine), "SYSCLK"); | ||
40 | + clock_set_hz(mms->sysclk, SYSCLK_FRQ); | ||
24 | + | 41 | + |
25 | + if (env->cp15.hcr_el2 & HCR_PTW) { | 42 | /* The FPGA images have an odd combination of different RAMs, |
26 | + /* | 43 | * because in hardware they are different implementations and |
27 | + * PTW means we must fault if this S1 walk touches S2 Device | 44 | * connected to different buses, giving varying performance/size |
28 | + * memory; otherwise we don't care about the attributes and can | 45 | @@ -XXX,XX +XXX,XX @@ static void mps2_common_init(MachineState *machine) |
29 | + * save the S2 translation the effort of computing them. | 46 | TYPE_CMSDK_APB_TIMER); |
30 | + */ | 47 | sbd = SYS_BUS_DEVICE(&mms->timer[i]); |
31 | + pcacheattrs = &cacheattrs; | 48 | qdev_prop_set_uint32(DEVICE(&mms->timer[i]), "pclk-frq", SYSCLK_FRQ); |
32 | + } | 49 | + qdev_connect_clock_in(DEVICE(&mms->timer[i]), "pclk", mms->sysclk); |
33 | 50 | sysbus_realize_and_unref(sbd, &error_fatal); | |
34 | ret = get_phys_addr_lpae(env, addr, 0, ARMMMUIdx_S2NS, &s2pa, | 51 | sysbus_mmio_map(sbd, 0, base); |
35 | - &txattrs, &s2prot, &s2size, fi, NULL); | 52 | sysbus_connect_irq(sbd, 0, qdev_get_gpio_in(armv7m, irqno)); |
36 | + &txattrs, &s2prot, &s2size, fi, pcacheattrs); | 53 | @@ -XXX,XX +XXX,XX @@ static void mps2_common_init(MachineState *machine) |
37 | if (ret) { | 54 | object_initialize_child(OBJECT(mms), "dualtimer", &mms->dualtimer, |
38 | assert(fi->type != ARMFault_None); | 55 | TYPE_CMSDK_APB_DUALTIMER); |
39 | fi->s2addr = addr; | 56 | qdev_prop_set_uint32(DEVICE(&mms->dualtimer), "pclk-frq", SYSCLK_FRQ); |
40 | @@ -XXX,XX +XXX,XX @@ static hwaddr S1_ptw_translate(CPUARMState *env, ARMMMUIdx mmu_idx, | 57 | + qdev_connect_clock_in(DEVICE(&mms->dualtimer), "TIMCLK", mms->sysclk); |
41 | fi->s1ptw = true; | 58 | sysbus_realize(SYS_BUS_DEVICE(&mms->dualtimer), &error_fatal); |
42 | return ~0; | 59 | sysbus_connect_irq(SYS_BUS_DEVICE(&mms->dualtimer), 0, |
43 | } | 60 | qdev_get_gpio_in(armv7m, 10)); |
44 | + if (pcacheattrs && (pcacheattrs->attrs & 0xf0) == 0) { | 61 | @@ -XXX,XX +XXX,XX @@ static void mps2_common_init(MachineState *machine) |
45 | + /* Access was to Device memory: generate Permission fault */ | 62 | object_initialize_child(OBJECT(mms), "watchdog", &mms->watchdog, |
46 | + fi->type = ARMFault_Permission; | 63 | TYPE_CMSDK_APB_WATCHDOG); |
47 | + fi->s2addr = addr; | 64 | qdev_prop_set_uint32(DEVICE(&mms->watchdog), "wdogclk-frq", SYSCLK_FRQ); |
48 | + fi->stage2 = true; | 65 | + qdev_connect_clock_in(DEVICE(&mms->watchdog), "WDOGCLK", mms->sysclk); |
49 | + fi->s1ptw = true; | 66 | sysbus_realize(SYS_BUS_DEVICE(&mms->watchdog), &error_fatal); |
50 | + return ~0; | 67 | sysbus_connect_irq(SYS_BUS_DEVICE(&mms->watchdog), 0, |
51 | + } | 68 | qdev_get_gpio_in_named(armv7m, "NMI", 0)); |
52 | addr = s2pa; | ||
53 | } | ||
54 | return addr; | ||
55 | -- | 69 | -- |
56 | 2.19.1 | 70 | 2.20.1 |
57 | 71 | ||
58 | 72 | diff view generated by jsdifflib |
1 | The A/I/F bits in ISR_EL1 should track the virtual interrupt | 1 | Create and connect the two clocks needed by the ARMSSE. |
---|---|---|---|
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 | |||
6 | We don't currently implement anything to do with external | ||
7 | aborts, so this applies only to the I and F bits (though it | ||
8 | ought to be possible for the outer guest to present a virtual | ||
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 | 2 | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 3 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 4 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
15 | Message-id: 20181012144235.19646-6-peter.maydell@linaro.org | 5 | Reviewed-by: Luc Michel <luc@lmichel.fr> |
6 | Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
7 | Message-id: 20210128114145.20536-15-peter.maydell@linaro.org | ||
8 | Message-id: 20210121190622.22000-15-peter.maydell@linaro.org | ||
16 | --- | 9 | --- |
17 | target/arm/helper.c | 22 ++++++++++++++++++---- | 10 | hw/arm/mps2-tz.c | 13 +++++++++++++ |
18 | 1 file changed, 18 insertions(+), 4 deletions(-) | 11 | 1 file changed, 13 insertions(+) |
19 | 12 | ||
20 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 13 | diff --git a/hw/arm/mps2-tz.c b/hw/arm/mps2-tz.c |
21 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/target/arm/helper.c | 15 | --- a/hw/arm/mps2-tz.c |
23 | +++ b/target/arm/helper.c | 16 | +++ b/hw/arm/mps2-tz.c |
24 | @@ -XXX,XX +XXX,XX @@ static uint64_t isr_read(CPUARMState *env, const ARMCPRegInfo *ri) | 17 | @@ -XXX,XX +XXX,XX @@ |
25 | CPUState *cs = ENV_GET_CPU(env); | 18 | #include "hw/net/lan9118.h" |
26 | uint64_t ret = 0; | 19 | #include "net/net.h" |
27 | 20 | #include "hw/core/split-irq.h" | |
28 | - if (cs->interrupt_request & CPU_INTERRUPT_HARD) { | 21 | +#include "hw/qdev-clock.h" |
29 | - ret |= CPSR_I; | 22 | #include "qom/object.h" |
30 | + if (arm_hcr_el2_imo(env)) { | 23 | |
31 | + if (cs->interrupt_request & CPU_INTERRUPT_VIRQ) { | 24 | #define MPS2TZ_NUMIRQ 92 |
32 | + ret |= CPSR_I; | 25 | @@ -XXX,XX +XXX,XX @@ struct MPS2TZMachineState { |
33 | + } | 26 | qemu_or_irq uart_irq_orgate; |
34 | + } else { | 27 | DeviceState *lan9118; |
35 | + if (cs->interrupt_request & CPU_INTERRUPT_HARD) { | 28 | SplitIRQ cpu_irq_splitter[MPS2TZ_NUMIRQ]; |
36 | + ret |= CPSR_I; | 29 | + Clock *sysclk; |
37 | + } | 30 | + Clock *s32kclk; |
31 | }; | ||
32 | |||
33 | #define TYPE_MPS2TZ_MACHINE "mps2tz" | ||
34 | @@ -XXX,XX +XXX,XX @@ OBJECT_DECLARE_TYPE(MPS2TZMachineState, MPS2TZMachineClass, MPS2TZ_MACHINE) | ||
35 | |||
36 | /* Main SYSCLK frequency in Hz */ | ||
37 | #define SYSCLK_FRQ 20000000 | ||
38 | +/* Slow 32Khz S32KCLK frequency in Hz */ | ||
39 | +#define S32KCLK_FRQ (32 * 1000) | ||
40 | |||
41 | /* Create an alias of an entire original MemoryRegion @orig | ||
42 | * located at @base in the memory map. | ||
43 | @@ -XXX,XX +XXX,XX @@ static void mps2tz_common_init(MachineState *machine) | ||
44 | exit(EXIT_FAILURE); | ||
38 | } | 45 | } |
39 | - if (cs->interrupt_request & CPU_INTERRUPT_FIQ) { | 46 | |
40 | - ret |= CPSR_F; | 47 | + /* These clocks don't need migration because they are fixed-frequency */ |
48 | + mms->sysclk = clock_new(OBJECT(machine), "SYSCLK"); | ||
49 | + clock_set_hz(mms->sysclk, SYSCLK_FRQ); | ||
50 | + mms->s32kclk = clock_new(OBJECT(machine), "S32KCLK"); | ||
51 | + clock_set_hz(mms->s32kclk, S32KCLK_FRQ); | ||
41 | + | 52 | + |
42 | + if (arm_hcr_el2_fmo(env)) { | 53 | object_initialize_child(OBJECT(machine), TYPE_IOTKIT, &mms->iotkit, |
43 | + if (cs->interrupt_request & CPU_INTERRUPT_VFIQ) { | 54 | mmc->armsse_type); |
44 | + ret |= CPSR_F; | 55 | iotkitdev = DEVICE(&mms->iotkit); |
45 | + } | 56 | @@ -XXX,XX +XXX,XX @@ static void mps2tz_common_init(MachineState *machine) |
46 | + } else { | 57 | OBJECT(system_memory), &error_abort); |
47 | + if (cs->interrupt_request & CPU_INTERRUPT_FIQ) { | 58 | qdev_prop_set_uint32(iotkitdev, "EXP_NUMIRQ", MPS2TZ_NUMIRQ); |
48 | + ret |= CPSR_F; | 59 | qdev_prop_set_uint32(iotkitdev, "MAINCLK_FRQ", SYSCLK_FRQ); |
49 | + } | 60 | + qdev_connect_clock_in(iotkitdev, "MAINCLK", mms->sysclk); |
50 | } | 61 | + qdev_connect_clock_in(iotkitdev, "S32KCLK", mms->s32kclk); |
51 | + | 62 | sysbus_realize(SYS_BUS_DEVICE(&mms->iotkit), &error_fatal); |
52 | /* External aborts are not possible in QEMU so A bit is always clear */ | 63 | |
53 | return ret; | 64 | /* |
54 | } | ||
55 | -- | 65 | -- |
56 | 2.19.1 | 66 | 2.20.1 |
57 | 67 | ||
58 | 68 | diff view generated by jsdifflib |
1 | For the v7 version of the Arm architecture, the IL bit in | 1 | Create and connect the two clocks needed by the ARMSSE. |
---|---|---|---|
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 | |||
10 | (The fourth case listed in the v8 Arm ARM DDI 0487C.a in | ||
11 | section G7.2.70, "illegal state exception", can't happen | ||
12 | on a v7 CPU.) | ||
13 | |||
14 | This deals with a corner case noted in a comment. | ||
15 | 2 | ||
16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 3 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
17 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 4 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
18 | Message-id: 20181012144235.19646-10-peter.maydell@linaro.org | 5 | Reviewed-by: Luc Michel <luc@lmichel.fr> |
6 | Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
7 | Message-id: 20210128114145.20536-16-peter.maydell@linaro.org | ||
8 | Message-id: 20210121190622.22000-16-peter.maydell@linaro.org | ||
19 | --- | 9 | --- |
20 | target/arm/internals.h | 7 ++----- | 10 | hw/arm/musca.c | 12 ++++++++++++ |
21 | target/arm/helper.c | 13 +++++++++++++ | 11 | 1 file changed, 12 insertions(+) |
22 | 2 files changed, 15 insertions(+), 5 deletions(-) | ||
23 | 12 | ||
24 | diff --git a/target/arm/internals.h b/target/arm/internals.h | 13 | diff --git a/hw/arm/musca.c b/hw/arm/musca.c |
25 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
26 | --- a/target/arm/internals.h | 15 | --- a/hw/arm/musca.c |
27 | +++ b/target/arm/internals.h | 16 | +++ b/hw/arm/musca.c |
28 | @@ -XXX,XX +XXX,XX @@ static inline uint32_t syn_get_ec(uint32_t syn) | 17 | @@ -XXX,XX +XXX,XX @@ |
29 | /* Utility functions for constructing various kinds of syndrome value. | 18 | #include "hw/misc/tz-ppc.h" |
30 | * Note that in general we follow the AArch64 syndrome values; in a | 19 | #include "hw/misc/unimp.h" |
31 | * few cases the value in HSR for exceptions taken to AArch32 Hyp | 20 | #include "hw/rtc/pl031.h" |
32 | - * mode differs slightly, so if we ever implemented Hyp mode then the | 21 | +#include "hw/qdev-clock.h" |
33 | - * syndrome value would need some massaging on exception entry. | 22 | #include "qom/object.h" |
34 | - * (One example of this is that AArch64 defaults to IL bit set for | 23 | |
35 | - * exceptions which don't specifically indicate information about the | 24 | #define MUSCA_NUMIRQ_MAX 96 |
36 | - * trapping instruction, whereas AArch32 defaults to IL bit clear.) | 25 | @@ -XXX,XX +XXX,XX @@ struct MuscaMachineState { |
37 | + * mode differs slightly, and we fix this up when populating HSR in | 26 | UnimplementedDeviceState sdio; |
38 | + * arm_cpu_do_interrupt_aarch32_hyp(). | 27 | UnimplementedDeviceState gpio; |
28 | UnimplementedDeviceState cryptoisland; | ||
29 | + Clock *sysclk; | ||
30 | + Clock *s32kclk; | ||
31 | }; | ||
32 | |||
33 | #define TYPE_MUSCA_MACHINE "musca" | ||
34 | @@ -XXX,XX +XXX,XX @@ OBJECT_DECLARE_TYPE(MuscaMachineState, MuscaMachineClass, MUSCA_MACHINE) | ||
35 | * don't model that in our SSE-200 model yet. | ||
39 | */ | 36 | */ |
40 | static inline uint32_t syn_uncategorized(void) | 37 | #define SYSCLK_FRQ 40000000 |
38 | +/* Slow 32Khz S32KCLK frequency in Hz */ | ||
39 | +#define S32KCLK_FRQ (32 * 1000) | ||
40 | |||
41 | static qemu_irq get_sse_irq_in(MuscaMachineState *mms, int irqno) | ||
41 | { | 42 | { |
42 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 43 | @@ -XXX,XX +XXX,XX @@ static void musca_init(MachineState *machine) |
43 | index XXXXXXX..XXXXXXX 100644 | 44 | exit(1); |
44 | --- a/target/arm/helper.c | ||
45 | +++ b/target/arm/helper.c | ||
46 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_do_interrupt_aarch32_hyp(CPUState *cs) | ||
47 | } | 45 | } |
48 | 46 | ||
49 | if (cs->exception_index != EXCP_IRQ && cs->exception_index != EXCP_FIQ) { | 47 | + mms->sysclk = clock_new(OBJECT(machine), "SYSCLK"); |
50 | + if (!arm_feature(env, ARM_FEATURE_V8)) { | 48 | + clock_set_hz(mms->sysclk, SYSCLK_FRQ); |
51 | + /* | 49 | + mms->s32kclk = clock_new(OBJECT(machine), "S32KCLK"); |
52 | + * QEMU syndrome values are v8-style. v7 has the IL bit | 50 | + clock_set_hz(mms->s32kclk, S32KCLK_FRQ); |
53 | + * UNK/SBZP for "field not valid" cases, where v8 uses RES1. | 51 | + |
54 | + * If this is a v7 CPU, squash the IL bit in those cases. | 52 | object_initialize_child(OBJECT(machine), "sse-200", &mms->sse, |
55 | + */ | 53 | TYPE_SSE200); |
56 | + if (cs->exception_index == EXCP_PREFETCH_ABORT || | 54 | ssedev = DEVICE(&mms->sse); |
57 | + (cs->exception_index == EXCP_DATA_ABORT && | 55 | @@ -XXX,XX +XXX,XX @@ static void musca_init(MachineState *machine) |
58 | + !(env->exception.syndrome & ARM_EL_ISV)) || | 56 | qdev_prop_set_uint32(ssedev, "init-svtor", mmc->init_svtor); |
59 | + syn_get_ec(env->exception.syndrome) == EC_UNCATEGORIZED) { | 57 | qdev_prop_set_uint32(ssedev, "SRAM_ADDR_WIDTH", mmc->sram_addr_width); |
60 | + env->exception.syndrome &= ~ARM_EL_IL; | 58 | qdev_prop_set_uint32(ssedev, "MAINCLK_FRQ", SYSCLK_FRQ); |
61 | + } | 59 | + qdev_connect_clock_in(ssedev, "MAINCLK", mms->sysclk); |
62 | + } | 60 | + qdev_connect_clock_in(ssedev, "S32KCLK", mms->s32kclk); |
63 | env->cp15.esr_el[2] = env->exception.syndrome; | 61 | /* |
64 | } | 62 | * Musca-A takes the default SSE-200 FPU/DSP settings (ie no for |
65 | 63 | * CPU0 and yes for CPU1); Musca-B1 explicitly enables them for CPU0. | |
66 | -- | 64 | -- |
67 | 2.19.1 | 65 | 2.20.1 |
68 | 66 | ||
69 | 67 | diff view generated by jsdifflib |
1 | The switch_mode() function is defined in target/arm/helper.c and used | 1 | Convert the SSYS code in the Stellaris boards (which encapsulates the |
---|---|---|---|
2 | only in that file and nowhere else, so we can make it file-local | 2 | system registers) to a proper QOM device. This will provide us with |
3 | rather than global. | 3 | somewhere to put the output Clock whose frequency depends on the |
4 | setting of the PLL configuration registers. | ||
5 | |||
6 | This is a migration compatibility break for lm3s811evb, lm3s6965evb. | ||
7 | |||
8 | We use 3-phase reset here because the Clock will need to propagate | ||
9 | its value in the hold phase. | ||
10 | |||
11 | For the moment we reset the device during the board creation so that | ||
12 | the system_clock_scale global gets set; this will be removed in a | ||
13 | subsequent commit. | ||
4 | 14 | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 16 | Reviewed-by: Luc Michel <luc@lmichel.fr> |
7 | Message-id: 20181012144235.19646-3-peter.maydell@linaro.org | 17 | Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
18 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
19 | Message-id: 20210128114145.20536-17-peter.maydell@linaro.org | ||
20 | Message-id: 20210121190622.22000-17-peter.maydell@linaro.org | ||
21 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
8 | --- | 22 | --- |
9 | target/arm/internals.h | 1 - | 23 | hw/arm/stellaris.c | 132 ++++++++++++++++++++++++++++++++++++--------- |
10 | target/arm/helper.c | 6 ++++-- | 24 | 1 file changed, 107 insertions(+), 25 deletions(-) |
11 | 2 files changed, 4 insertions(+), 3 deletions(-) | 25 | |
12 | 26 | diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c | |
13 | diff --git a/target/arm/internals.h b/target/arm/internals.h | ||
14 | index XXXXXXX..XXXXXXX 100644 | 27 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/internals.h | 28 | --- a/hw/arm/stellaris.c |
16 | +++ b/target/arm/internals.h | 29 | +++ b/hw/arm/stellaris.c |
17 | @@ -XXX,XX +XXX,XX @@ static inline int bank_number(int mode) | 30 | @@ -XXX,XX +XXX,XX @@ static void stellaris_gptm_realize(DeviceState *dev, Error **errp) |
18 | g_assert_not_reached(); | 31 | |
32 | /* System controller. */ | ||
33 | |||
34 | -typedef struct { | ||
35 | +#define TYPE_STELLARIS_SYS "stellaris-sys" | ||
36 | +OBJECT_DECLARE_SIMPLE_TYPE(ssys_state, STELLARIS_SYS) | ||
37 | + | ||
38 | +struct ssys_state { | ||
39 | + SysBusDevice parent_obj; | ||
40 | + | ||
41 | MemoryRegion iomem; | ||
42 | uint32_t pborctl; | ||
43 | uint32_t ldopctl; | ||
44 | @@ -XXX,XX +XXX,XX @@ typedef struct { | ||
45 | uint32_t dcgc[3]; | ||
46 | uint32_t clkvclr; | ||
47 | uint32_t ldoarst; | ||
48 | + qemu_irq irq; | ||
49 | + /* Properties (all read-only registers) */ | ||
50 | uint32_t user0; | ||
51 | uint32_t user1; | ||
52 | - qemu_irq irq; | ||
53 | - stellaris_board_info *board; | ||
54 | -} ssys_state; | ||
55 | + uint32_t did0; | ||
56 | + uint32_t did1; | ||
57 | + uint32_t dc0; | ||
58 | + uint32_t dc1; | ||
59 | + uint32_t dc2; | ||
60 | + uint32_t dc3; | ||
61 | + uint32_t dc4; | ||
62 | +}; | ||
63 | |||
64 | static void ssys_update(ssys_state *s) | ||
65 | { | ||
66 | @@ -XXX,XX +XXX,XX @@ static uint32_t pllcfg_fury[16] = { | ||
67 | |||
68 | static int ssys_board_class(const ssys_state *s) | ||
69 | { | ||
70 | - uint32_t did0 = s->board->did0; | ||
71 | + uint32_t did0 = s->did0; | ||
72 | switch (did0 & DID0_VER_MASK) { | ||
73 | case DID0_VER_0: | ||
74 | return DID0_CLASS_SANDSTORM; | ||
75 | @@ -XXX,XX +XXX,XX @@ static uint64_t ssys_read(void *opaque, hwaddr offset, | ||
76 | |||
77 | switch (offset) { | ||
78 | case 0x000: /* DID0 */ | ||
79 | - return s->board->did0; | ||
80 | + return s->did0; | ||
81 | case 0x004: /* DID1 */ | ||
82 | - return s->board->did1; | ||
83 | + return s->did1; | ||
84 | case 0x008: /* DC0 */ | ||
85 | - return s->board->dc0; | ||
86 | + return s->dc0; | ||
87 | case 0x010: /* DC1 */ | ||
88 | - return s->board->dc1; | ||
89 | + return s->dc1; | ||
90 | case 0x014: /* DC2 */ | ||
91 | - return s->board->dc2; | ||
92 | + return s->dc2; | ||
93 | case 0x018: /* DC3 */ | ||
94 | - return s->board->dc3; | ||
95 | + return s->dc3; | ||
96 | case 0x01c: /* DC4 */ | ||
97 | - return s->board->dc4; | ||
98 | + return s->dc4; | ||
99 | case 0x030: /* PBORCTL */ | ||
100 | return s->pborctl; | ||
101 | case 0x034: /* LDOPCTL */ | ||
102 | @@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps ssys_ops = { | ||
103 | .endianness = DEVICE_NATIVE_ENDIAN, | ||
104 | }; | ||
105 | |||
106 | -static void ssys_reset(void *opaque) | ||
107 | +static void stellaris_sys_reset_enter(Object *obj, ResetType type) | ||
108 | { | ||
109 | - ssys_state *s = (ssys_state *)opaque; | ||
110 | + ssys_state *s = STELLARIS_SYS(obj); | ||
111 | |||
112 | s->pborctl = 0x7ffd; | ||
113 | s->rcc = 0x078e3ac0; | ||
114 | @@ -XXX,XX +XXX,XX @@ static void ssys_reset(void *opaque) | ||
115 | s->rcgc[0] = 1; | ||
116 | s->scgc[0] = 1; | ||
117 | s->dcgc[0] = 1; | ||
118 | +} | ||
119 | + | ||
120 | +static void stellaris_sys_reset_hold(Object *obj) | ||
121 | +{ | ||
122 | + ssys_state *s = STELLARIS_SYS(obj); | ||
123 | + | ||
124 | ssys_calculate_system_clock(s); | ||
19 | } | 125 | } |
20 | 126 | ||
21 | -void switch_mode(CPUARMState *, int); | 127 | +static void stellaris_sys_reset_exit(Object *obj) |
22 | void arm_cpu_register_gdb_regs_for_features(ARMCPU *cpu); | 128 | +{ |
23 | void arm_translate_init(void); | 129 | +} |
24 | 130 | + | |
25 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 131 | static int stellaris_sys_post_load(void *opaque, int version_id) |
26 | index XXXXXXX..XXXXXXX 100644 | 132 | { |
27 | --- a/target/arm/helper.c | 133 | ssys_state *s = opaque; |
28 | +++ b/target/arm/helper.c | 134 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_stellaris_sys = { |
29 | @@ -XXX,XX +XXX,XX @@ static void v8m_security_lookup(CPUARMState *env, uint32_t address, | 135 | } |
30 | V8M_SAttributes *sattrs); | 136 | }; |
31 | #endif | 137 | |
32 | 138 | +static Property stellaris_sys_properties[] = { | |
33 | +static void switch_mode(CPUARMState *env, int mode); | 139 | + DEFINE_PROP_UINT32("user0", ssys_state, user0, 0), |
34 | + | 140 | + DEFINE_PROP_UINT32("user1", ssys_state, user1, 0), |
35 | static int vfp_gdb_get_reg(CPUARMState *env, uint8_t *buf, int reg) | 141 | + DEFINE_PROP_UINT32("did0", ssys_state, did0, 0), |
36 | { | 142 | + DEFINE_PROP_UINT32("did1", ssys_state, did1, 0), |
37 | int nregs; | 143 | + DEFINE_PROP_UINT32("dc0", ssys_state, dc0, 0), |
38 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(v7m_tt)(CPUARMState *env, uint32_t addr, uint32_t op) | 144 | + DEFINE_PROP_UINT32("dc1", ssys_state, dc1, 0), |
145 | + DEFINE_PROP_UINT32("dc2", ssys_state, dc2, 0), | ||
146 | + DEFINE_PROP_UINT32("dc3", ssys_state, dc3, 0), | ||
147 | + DEFINE_PROP_UINT32("dc4", ssys_state, dc4, 0), | ||
148 | + DEFINE_PROP_END_OF_LIST() | ||
149 | +}; | ||
150 | + | ||
151 | +static void stellaris_sys_instance_init(Object *obj) | ||
152 | +{ | ||
153 | + ssys_state *s = STELLARIS_SYS(obj); | ||
154 | + SysBusDevice *sbd = SYS_BUS_DEVICE(s); | ||
155 | + | ||
156 | + memory_region_init_io(&s->iomem, obj, &ssys_ops, s, "ssys", 0x00001000); | ||
157 | + sysbus_init_mmio(sbd, &s->iomem); | ||
158 | + sysbus_init_irq(sbd, &s->irq); | ||
159 | +} | ||
160 | + | ||
161 | static int stellaris_sys_init(uint32_t base, qemu_irq irq, | ||
162 | stellaris_board_info * board, | ||
163 | uint8_t *macaddr) | ||
164 | { | ||
165 | - ssys_state *s; | ||
166 | + DeviceState *dev = qdev_new(TYPE_STELLARIS_SYS); | ||
167 | + SysBusDevice *sbd = SYS_BUS_DEVICE(dev); | ||
168 | |||
169 | - s = g_new0(ssys_state, 1); | ||
170 | - s->irq = irq; | ||
171 | - s->board = board; | ||
172 | /* Most devices come preprogrammed with a MAC address in the user data. */ | ||
173 | - s->user0 = macaddr[0] | (macaddr[1] << 8) | (macaddr[2] << 16); | ||
174 | - s->user1 = macaddr[3] | (macaddr[4] << 8) | (macaddr[5] << 16); | ||
175 | + qdev_prop_set_uint32(dev, "user0", | ||
176 | + macaddr[0] | (macaddr[1] << 8) | (macaddr[2] << 16)); | ||
177 | + qdev_prop_set_uint32(dev, "user1", | ||
178 | + macaddr[3] | (macaddr[4] << 8) | (macaddr[5] << 16)); | ||
179 | + qdev_prop_set_uint32(dev, "did0", board->did0); | ||
180 | + qdev_prop_set_uint32(dev, "did1", board->did1); | ||
181 | + qdev_prop_set_uint32(dev, "dc0", board->dc0); | ||
182 | + qdev_prop_set_uint32(dev, "dc1", board->dc1); | ||
183 | + qdev_prop_set_uint32(dev, "dc2", board->dc2); | ||
184 | + qdev_prop_set_uint32(dev, "dc3", board->dc3); | ||
185 | + qdev_prop_set_uint32(dev, "dc4", board->dc4); | ||
186 | + | ||
187 | + sysbus_realize_and_unref(sbd, &error_fatal); | ||
188 | + sysbus_mmio_map(sbd, 0, base); | ||
189 | + sysbus_connect_irq(sbd, 0, irq); | ||
190 | + | ||
191 | + /* | ||
192 | + * Normally we should not be resetting devices like this during | ||
193 | + * board creation. For the moment we need to do so, because | ||
194 | + * system_clock_scale will only get set when the STELLARIS_SYS | ||
195 | + * device is reset, and we need its initial value to pass to | ||
196 | + * the watchdog device. This hack can be removed once the | ||
197 | + * watchdog has been converted to use a Clock input instead. | ||
198 | + */ | ||
199 | + device_cold_reset(dev); | ||
200 | |||
201 | - memory_region_init_io(&s->iomem, NULL, &ssys_ops, s, "ssys", 0x00001000); | ||
202 | - memory_region_add_subregion(get_system_memory(), base, &s->iomem); | ||
203 | - ssys_reset(s); | ||
204 | - vmstate_register(NULL, VMSTATE_INSTANCE_ID_ANY, &vmstate_stellaris_sys, s); | ||
39 | return 0; | 205 | return 0; |
40 | } | 206 | } |
41 | 207 | ||
42 | -void switch_mode(CPUARMState *env, int mode) | 208 | - |
43 | +static void switch_mode(CPUARMState *env, int mode) | 209 | /* I2C controller. */ |
44 | { | 210 | |
45 | ARMCPU *cpu = arm_env_get_cpu(env); | 211 | #define TYPE_STELLARIS_I2C "stellaris-i2c" |
46 | 212 | @@ -XXX,XX +XXX,XX @@ static const TypeInfo stellaris_adc_info = { | |
47 | @@ -XXX,XX +XXX,XX @@ void aarch64_sync_64_to_32(CPUARMState *env) | 213 | .class_init = stellaris_adc_class_init, |
48 | 214 | }; | |
49 | #else | 215 | |
50 | 216 | +static void stellaris_sys_class_init(ObjectClass *klass, void *data) | |
51 | -void switch_mode(CPUARMState *env, int mode) | 217 | +{ |
52 | +static void switch_mode(CPUARMState *env, int mode) | 218 | + DeviceClass *dc = DEVICE_CLASS(klass); |
53 | { | 219 | + ResettableClass *rc = RESETTABLE_CLASS(klass); |
54 | int old_mode; | 220 | + |
55 | int i; | 221 | + dc->vmsd = &vmstate_stellaris_sys; |
222 | + rc->phases.enter = stellaris_sys_reset_enter; | ||
223 | + rc->phases.hold = stellaris_sys_reset_hold; | ||
224 | + rc->phases.exit = stellaris_sys_reset_exit; | ||
225 | + device_class_set_props(dc, stellaris_sys_properties); | ||
226 | +} | ||
227 | + | ||
228 | +static const TypeInfo stellaris_sys_info = { | ||
229 | + .name = TYPE_STELLARIS_SYS, | ||
230 | + .parent = TYPE_SYS_BUS_DEVICE, | ||
231 | + .instance_size = sizeof(ssys_state), | ||
232 | + .instance_init = stellaris_sys_instance_init, | ||
233 | + .class_init = stellaris_sys_class_init, | ||
234 | +}; | ||
235 | + | ||
236 | static void stellaris_register_types(void) | ||
237 | { | ||
238 | type_register_static(&stellaris_i2c_info); | ||
239 | type_register_static(&stellaris_gptm_info); | ||
240 | type_register_static(&stellaris_adc_info); | ||
241 | + type_register_static(&stellaris_sys_info); | ||
242 | } | ||
243 | |||
244 | type_init(stellaris_register_types) | ||
56 | -- | 245 | -- |
57 | 2.19.1 | 246 | 2.20.1 |
58 | 247 | ||
59 | 248 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | Create and connect the Clock input for the watchdog device on the |
---|---|---|---|
2 | Stellaris boards. Because the Stellaris boards model the ability to | ||
3 | change the clock rate by programming PLL registers, we have to create | ||
4 | an output Clock on the ssys_state device and wire it up to the | ||
5 | watchdog. | ||
2 | 6 | ||
3 | Move expanders for VBSL, VBIT, and VBIF from translate-a64.c. | 7 | Note that the old comment on ssys_calculate_system_clock() got the |
8 | units wrong -- system_clock_scale is in nanoseconds, not | ||
9 | milliseconds. Improve the commentary to clarify how we are | ||
10 | calculating the period. | ||
4 | 11 | ||
5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20181011205206.3552-9-richard.henderson@linaro.org | ||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | Reviewed-by: Luc Michel <luc@lmichel.fr> | ||
14 | Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
15 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
16 | Message-id: 20210128114145.20536-18-peter.maydell@linaro.org | ||
17 | Message-id: 20210121190622.22000-18-peter.maydell@linaro.org | ||
18 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
9 | --- | 19 | --- |
10 | target/arm/translate.h | 6 ++ | 20 | hw/arm/stellaris.c | 43 +++++++++++++++++++++++++++++++------------ |
11 | target/arm/translate-a64.c | 61 -------------- | 21 | 1 file changed, 31 insertions(+), 12 deletions(-) |
12 | target/arm/translate.c | 162 +++++++++++++++++++++++++++---------- | ||
13 | 3 files changed, 124 insertions(+), 105 deletions(-) | ||
14 | 22 | ||
15 | diff --git a/target/arm/translate.h b/target/arm/translate.h | 23 | diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c |
16 | index XXXXXXX..XXXXXXX 100644 | 24 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/translate.h | 25 | --- a/hw/arm/stellaris.c |
18 | +++ b/target/arm/translate.h | 26 | +++ b/hw/arm/stellaris.c |
19 | @@ -XXX,XX +XXX,XX @@ static inline TCGv_i32 get_ahp_flag(void) | 27 | @@ -XXX,XX +XXX,XX @@ |
20 | return ret; | 28 | #include "hw/watchdog/cmsdk-apb-watchdog.h" |
29 | #include "migration/vmstate.h" | ||
30 | #include "hw/misc/unimp.h" | ||
31 | +#include "hw/qdev-clock.h" | ||
32 | #include "cpu.h" | ||
33 | #include "qom/object.h" | ||
34 | |||
35 | @@ -XXX,XX +XXX,XX @@ struct ssys_state { | ||
36 | uint32_t clkvclr; | ||
37 | uint32_t ldoarst; | ||
38 | qemu_irq irq; | ||
39 | + Clock *sysclk; | ||
40 | /* Properties (all read-only registers) */ | ||
41 | uint32_t user0; | ||
42 | uint32_t user1; | ||
43 | @@ -XXX,XX +XXX,XX @@ static bool ssys_use_rcc2(ssys_state *s) | ||
21 | } | 44 | } |
22 | 45 | ||
23 | + | ||
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 | /* | 46 | /* |
30 | * Forward to the isar_feature_* tests given a DisasContext pointer. | 47 | - * Caculate the sys. clock period in ms. |
48 | + * Calculate the system clock period. We only want to propagate | ||
49 | + * this change to the rest of the system if we're not being called | ||
50 | + * from migration post-load. | ||
31 | */ | 51 | */ |
32 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 52 | -static void ssys_calculate_system_clock(ssys_state *s) |
33 | index XXXXXXX..XXXXXXX 100644 | 53 | +static void ssys_calculate_system_clock(ssys_state *s, bool propagate_clock) |
34 | --- a/target/arm/translate-a64.c | 54 | { |
35 | +++ b/target/arm/translate-a64.c | 55 | + /* |
36 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_three_reg_diff(DisasContext *s, uint32_t insn) | 56 | + * SYSDIV field specifies divisor: 0 == /1, 1 == /2, etc. Input |
57 | + * clock is 200MHz, which is a period of 5 ns. Dividing the clock | ||
58 | + * frequency by X is the same as multiplying the period by X. | ||
59 | + */ | ||
60 | if (ssys_use_rcc2(s)) { | ||
61 | system_clock_scale = 5 * (((s->rcc2 >> 23) & 0x3f) + 1); | ||
62 | } else { | ||
63 | system_clock_scale = 5 * (((s->rcc >> 23) & 0xf) + 1); | ||
37 | } | 64 | } |
65 | + clock_set_ns(s->sysclk, system_clock_scale); | ||
66 | + if (propagate_clock) { | ||
67 | + clock_propagate(s->sysclk); | ||
68 | + } | ||
38 | } | 69 | } |
39 | 70 | ||
40 | -static void gen_bsl_i64(TCGv_i64 rd, TCGv_i64 rn, TCGv_i64 rm) | 71 | static void ssys_write(void *opaque, hwaddr offset, |
41 | -{ | 72 | @@ -XXX,XX +XXX,XX @@ static void ssys_write(void *opaque, hwaddr offset, |
42 | - tcg_gen_xor_i64(rn, rn, rm); | 73 | s->int_status |= (1 << 6); |
43 | - tcg_gen_and_i64(rn, rn, rd); | 74 | } |
44 | - tcg_gen_xor_i64(rd, rm, rn); | 75 | s->rcc = value; |
45 | -} | 76 | - ssys_calculate_system_clock(s); |
46 | - | 77 | + ssys_calculate_system_clock(s, true); |
47 | -static void gen_bit_i64(TCGv_i64 rd, TCGv_i64 rn, TCGv_i64 rm) | 78 | break; |
48 | -{ | 79 | case 0x070: /* RCC2 */ |
49 | - tcg_gen_xor_i64(rn, rn, rd); | 80 | if (ssys_board_class(s) == DID0_CLASS_SANDSTORM) { |
50 | - tcg_gen_and_i64(rn, rn, rm); | 81 | @@ -XXX,XX +XXX,XX @@ static void ssys_write(void *opaque, hwaddr offset, |
51 | - tcg_gen_xor_i64(rd, rd, rn); | 82 | s->int_status |= (1 << 6); |
52 | -} | 83 | } |
53 | - | 84 | s->rcc2 = value; |
54 | -static void gen_bif_i64(TCGv_i64 rd, TCGv_i64 rn, TCGv_i64 rm) | 85 | - ssys_calculate_system_clock(s); |
55 | -{ | 86 | + ssys_calculate_system_clock(s, true); |
56 | - tcg_gen_xor_i64(rn, rn, rd); | 87 | break; |
57 | - tcg_gen_andc_i64(rn, rn, rm); | 88 | case 0x100: /* RCGC0 */ |
58 | - tcg_gen_xor_i64(rd, rd, rn); | 89 | s->rcgc[0] = value; |
59 | -} | 90 | @@ -XXX,XX +XXX,XX @@ static void stellaris_sys_reset_hold(Object *obj) |
60 | - | ||
61 | -static void gen_bsl_vec(unsigned vece, TCGv_vec rd, TCGv_vec rn, TCGv_vec rm) | ||
62 | -{ | ||
63 | - tcg_gen_xor_vec(vece, rn, rn, rm); | ||
64 | - tcg_gen_and_vec(vece, rn, rn, rd); | ||
65 | - tcg_gen_xor_vec(vece, rd, rm, rn); | ||
66 | -} | ||
67 | - | ||
68 | -static void gen_bit_vec(unsigned vece, TCGv_vec rd, TCGv_vec rn, TCGv_vec rm) | ||
69 | -{ | ||
70 | - tcg_gen_xor_vec(vece, rn, rn, rd); | ||
71 | - tcg_gen_and_vec(vece, rn, rn, rm); | ||
72 | - tcg_gen_xor_vec(vece, rd, rd, rn); | ||
73 | -} | ||
74 | - | ||
75 | -static void gen_bif_vec(unsigned vece, TCGv_vec rd, TCGv_vec rn, TCGv_vec rm) | ||
76 | -{ | ||
77 | - tcg_gen_xor_vec(vece, rn, rn, rd); | ||
78 | - tcg_gen_andc_vec(vece, rn, rn, rm); | ||
79 | - tcg_gen_xor_vec(vece, rd, rd, rn); | ||
80 | -} | ||
81 | - | ||
82 | /* Logic op (opcode == 3) subgroup of C3.6.16. */ | ||
83 | static void disas_simd_3same_logic(DisasContext *s, uint32_t insn) | ||
84 | { | 91 | { |
85 | - static const GVecGen3 bsl_op = { | 92 | ssys_state *s = STELLARIS_SYS(obj); |
86 | - .fni8 = gen_bsl_i64, | 93 | |
87 | - .fniv = gen_bsl_vec, | 94 | - ssys_calculate_system_clock(s); |
88 | - .prefer_i64 = TCG_TARGET_REG_BITS == 64, | 95 | + /* OK to propagate clocks from the hold phase */ |
89 | - .load_dest = true | 96 | + ssys_calculate_system_clock(s, true); |
90 | - }; | 97 | } |
91 | - static const GVecGen3 bit_op = { | 98 | |
92 | - .fni8 = gen_bit_i64, | 99 | static void stellaris_sys_reset_exit(Object *obj) |
93 | - .fniv = gen_bit_vec, | 100 | @@ -XXX,XX +XXX,XX @@ static int stellaris_sys_post_load(void *opaque, int version_id) |
94 | - .prefer_i64 = TCG_TARGET_REG_BITS == 64, | 101 | { |
95 | - .load_dest = true | 102 | ssys_state *s = opaque; |
96 | - }; | 103 | |
97 | - static const GVecGen3 bif_op = { | 104 | - ssys_calculate_system_clock(s); |
98 | - .fni8 = gen_bif_i64, | 105 | + ssys_calculate_system_clock(s, false); |
99 | - .fniv = gen_bif_vec, | 106 | |
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; | 107 | return 0; |
113 | } | 108 | } |
114 | 109 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_stellaris_sys = { | |
115 | -/* Bitwise select. dest = c ? t : f. Clobbers T and F. */ | 110 | VMSTATE_UINT32_ARRAY(dcgc, ssys_state, 3), |
116 | -static void gen_neon_bsl(TCGv_i32 dest, TCGv_i32 t, TCGv_i32 f, TCGv_i32 c) | 111 | VMSTATE_UINT32(clkvclr, ssys_state), |
117 | -{ | 112 | VMSTATE_UINT32(ldoarst, ssys_state), |
118 | - tcg_gen_and_i32(t, t, c); | 113 | + /* No field for sysclk -- handled in post-load instead */ |
119 | - tcg_gen_andc_i32(f, f, c); | 114 | VMSTATE_END_OF_LIST() |
120 | - tcg_gen_or_i32(dest, t, f); | 115 | } |
121 | -} | 116 | }; |
122 | - | 117 | @@ -XXX,XX +XXX,XX @@ static void stellaris_sys_instance_init(Object *obj) |
123 | static inline void gen_neon_narrow(int size, TCGv_i32 dest, TCGv_i64 src) | 118 | memory_region_init_io(&s->iomem, obj, &ssys_ops, s, "ssys", 0x00001000); |
119 | sysbus_init_mmio(sbd, &s->iomem); | ||
120 | sysbus_init_irq(sbd, &s->irq); | ||
121 | + s->sysclk = qdev_init_clock_out(DEVICE(s), "SYSCLK"); | ||
122 | } | ||
123 | |||
124 | -static int stellaris_sys_init(uint32_t base, qemu_irq irq, | ||
125 | - stellaris_board_info * board, | ||
126 | - uint8_t *macaddr) | ||
127 | +static DeviceState *stellaris_sys_init(uint32_t base, qemu_irq irq, | ||
128 | + stellaris_board_info *board, | ||
129 | + uint8_t *macaddr) | ||
124 | { | 130 | { |
125 | switch (size) { | 131 | DeviceState *dev = qdev_new(TYPE_STELLARIS_SYS); |
126 | @@ -XXX,XX +XXX,XX @@ static int do_v81_helper(DisasContext *s, gen_helper_gvec_3_ptr *fn, | 132 | SysBusDevice *sbd = SYS_BUS_DEVICE(dev); |
127 | return 1; | 133 | @@ -XXX,XX +XXX,XX @@ static int stellaris_sys_init(uint32_t base, qemu_irq irq, |
134 | */ | ||
135 | device_cold_reset(dev); | ||
136 | |||
137 | - return 0; | ||
138 | + return dev; | ||
128 | } | 139 | } |
129 | 140 | ||
130 | +/* | 141 | /* I2C controller. */ |
131 | + * Expanders for VBitOps_VBIF, VBIT, VBSL. | 142 | @@ -XXX,XX +XXX,XX @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board) |
132 | + */ | 143 | int flash_size; |
133 | +static void gen_bsl_i64(TCGv_i64 rd, TCGv_i64 rn, TCGv_i64 rm) | 144 | I2CBus *i2c; |
134 | +{ | 145 | DeviceState *dev; |
135 | + tcg_gen_xor_i64(rn, rn, rm); | 146 | + DeviceState *ssys_dev; |
136 | + tcg_gen_and_i64(rn, rn, rd); | 147 | int i; |
137 | + tcg_gen_xor_i64(rd, rm, rn); | 148 | int j; |
138 | +} | 149 | |
139 | + | 150 | @@ -XXX,XX +XXX,XX @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board) |
140 | +static void gen_bit_i64(TCGv_i64 rd, TCGv_i64 rn, TCGv_i64 rm) | ||
141 | +{ | ||
142 | + tcg_gen_xor_i64(rn, rn, rd); | ||
143 | + tcg_gen_and_i64(rn, rn, rm); | ||
144 | + tcg_gen_xor_i64(rd, rd, rn); | ||
145 | +} | ||
146 | + | ||
147 | +static void gen_bif_i64(TCGv_i64 rd, TCGv_i64 rn, TCGv_i64 rm) | ||
148 | +{ | ||
149 | + tcg_gen_xor_i64(rn, rn, rd); | ||
150 | + tcg_gen_andc_i64(rn, rn, rm); | ||
151 | + tcg_gen_xor_i64(rd, rd, rn); | ||
152 | +} | ||
153 | + | ||
154 | +static void gen_bsl_vec(unsigned vece, TCGv_vec rd, TCGv_vec rn, TCGv_vec rm) | ||
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 | { | ||
202 | int op; | ||
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 | } | 151 | } |
276 | - if (size == 3 && op != NEON_3R_LOGIC) { | 152 | } |
277 | + if (size == 3) { | 153 | |
278 | /* 64-bit element instructions. */ | 154 | - stellaris_sys_init(0x400fe000, qdev_get_gpio_in(nvic, 28), |
279 | for (pass = 0; pass < (q ? 2 : 1); pass++) { | 155 | - board, nd_table[0].macaddr.a); |
280 | neon_load_reg64(cpu_V0, rn + pass); | 156 | + ssys_dev = stellaris_sys_init(0x400fe000, qdev_get_gpio_in(nvic, 28), |
281 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | 157 | + board, nd_table[0].macaddr.a); |
282 | case NEON_3R_VRHADD: | 158 | |
283 | GEN_NEON_INTEGER_OP(rhadd); | 159 | |
284 | break; | 160 | if (board->dc1 & (1 << 3)) { /* watchdog present */ |
285 | - case NEON_3R_LOGIC: /* Logic ops. */ | 161 | @@ -XXX,XX +XXX,XX @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board) |
286 | - switch ((u << 2) | size) { | 162 | /* system_clock_scale is valid now */ |
287 | - case 0: /* VAND */ | 163 | uint32_t mainclk = NANOSECONDS_PER_SECOND / system_clock_scale; |
288 | - tcg_gen_and_i32(tmp, tmp, tmp2); | 164 | qdev_prop_set_uint32(dev, "wdogclk-frq", mainclk); |
289 | - break; | 165 | + qdev_connect_clock_in(dev, "WDOGCLK", |
290 | - case 1: /* BIC */ | 166 | + qdev_get_clock_out(ssys_dev, "SYSCLK")); |
291 | - tcg_gen_andc_i32(tmp, tmp, tmp2); | 167 | |
292 | - break; | 168 | sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); |
293 | - case 2: /* VORR */ | 169 | sysbus_mmio_map(SYS_BUS_DEVICE(dev), |
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 | -- | 170 | -- |
323 | 2.19.1 | 171 | 2.20.1 |
324 | 172 | ||
325 | 173 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | Switch the CMSDK APB timer device over to using its Clock input; the |
---|---|---|---|
2 | pclk-frq property is now ignored. | ||
2 | 3 | ||
3 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Message-id: 20181016223115.24100-9-richard.henderson@linaro.org | ||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
6 | Reviewed-by: Luc Michel <luc@lmichel.fr> | ||
7 | Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
8 | Message-id: 20210128114145.20536-19-peter.maydell@linaro.org | ||
9 | Message-id: 20210121190622.22000-19-peter.maydell@linaro.org | ||
8 | --- | 10 | --- |
9 | target/arm/cpu.h | 17 +++++++++++++++- | 11 | hw/timer/cmsdk-apb-timer.c | 18 ++++++++++++++---- |
10 | linux-user/elfload.c | 6 +----- | 12 | 1 file changed, 14 insertions(+), 4 deletions(-) |
11 | target/arm/cpu64.c | 16 ++++++++------- | ||
12 | target/arm/helper.c | 2 +- | ||
13 | target/arm/translate-a64.c | 40 +++++++++++++++++++------------------- | ||
14 | target/arm/translate.c | 6 +++--- | ||
15 | 6 files changed, 50 insertions(+), 37 deletions(-) | ||
16 | 13 | ||
17 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 14 | diff --git a/hw/timer/cmsdk-apb-timer.c b/hw/timer/cmsdk-apb-timer.c |
18 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/target/arm/cpu.h | 16 | --- a/hw/timer/cmsdk-apb-timer.c |
20 | +++ b/target/arm/cpu.h | 17 | +++ b/hw/timer/cmsdk-apb-timer.c |
21 | @@ -XXX,XX +XXX,XX @@ enum arm_features { | 18 | @@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_timer_reset(DeviceState *dev) |
22 | ARM_FEATURE_PMU, /* has PMU support */ | 19 | ptimer_transaction_commit(s->timer); |
23 | ARM_FEATURE_VBAR, /* has cp15 VBAR */ | ||
24 | ARM_FEATURE_M_SECURITY, /* M profile Security Extension */ | ||
25 | - ARM_FEATURE_V8_FP16, /* implements v8.2 half-precision float */ | ||
26 | ARM_FEATURE_M_MAIN, /* M profile Main Extension */ | ||
27 | }; | ||
28 | |||
29 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa32_dp(const ARMISARegisters *id) | ||
30 | return FIELD_EX32(id->id_isar6, ID_ISAR6, DP) != 0; | ||
31 | } | 20 | } |
32 | 21 | ||
33 | +static inline bool isar_feature_aa32_fp16_arith(const ARMISARegisters *id) | 22 | +static void cmsdk_apb_timer_clk_update(void *opaque) |
34 | +{ | 23 | +{ |
35 | + /* | 24 | + CMSDKAPBTimer *s = CMSDK_APB_TIMER(opaque); |
36 | + * This is a placeholder for use by VCMA until the rest of | 25 | + |
37 | + * the ARMv8.2-FP16 extension is implemented for aa32 mode. | 26 | + ptimer_transaction_begin(s->timer); |
38 | + * At which point we can properly set and check MVFR1.FPHP. | 27 | + ptimer_set_period_from_clock(s->timer, s->pclk, 1); |
39 | + */ | 28 | + ptimer_transaction_commit(s->timer); |
40 | + return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, FP) == 1; | ||
41 | +} | 29 | +} |
42 | + | 30 | + |
43 | /* | 31 | static void cmsdk_apb_timer_init(Object *obj) |
44 | * 64-bit feature tests via id registers. | 32 | { |
45 | */ | 33 | SysBusDevice *sbd = SYS_BUS_DEVICE(obj); |
46 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa64_fcma(const ARMISARegisters *id) | 34 | @@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_timer_init(Object *obj) |
47 | return FIELD_EX64(id->id_aa64isar1, ID_AA64ISAR1, FCMA) != 0; | 35 | s, "cmsdk-apb-timer", 0x1000); |
36 | sysbus_init_mmio(sbd, &s->iomem); | ||
37 | sysbus_init_irq(sbd, &s->timerint); | ||
38 | - s->pclk = qdev_init_clock_in(DEVICE(s), "pclk", NULL, NULL); | ||
39 | + s->pclk = qdev_init_clock_in(DEVICE(s), "pclk", | ||
40 | + cmsdk_apb_timer_clk_update, s); | ||
48 | } | 41 | } |
49 | 42 | ||
50 | +static inline bool isar_feature_aa64_fp16(const ARMISARegisters *id) | 43 | static void cmsdk_apb_timer_realize(DeviceState *dev, Error **errp) |
51 | +{ | ||
52 | + /* We always set the AdvSIMD and FP fields identically wrt FP16. */ | ||
53 | + return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, FP) == 1; | ||
54 | +} | ||
55 | + | ||
56 | static inline bool isar_feature_aa64_sve(const ARMISARegisters *id) | ||
57 | { | 44 | { |
58 | return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, SVE) != 0; | 45 | CMSDKAPBTimer *s = CMSDK_APB_TIMER(dev); |
59 | diff --git a/linux-user/elfload.c b/linux-user/elfload.c | 46 | |
60 | index XXXXXXX..XXXXXXX 100644 | 47 | - if (s->pclk_frq == 0) { |
61 | --- a/linux-user/elfload.c | 48 | - error_setg(errp, "CMSDK APB timer: pclk-frq property must be set"); |
62 | +++ b/linux-user/elfload.c | 49 | + if (!clock_has_source(s->pclk)) { |
63 | @@ -XXX,XX +XXX,XX @@ static uint32_t get_elf_hwcap(void) | 50 | + error_setg(errp, "CMSDK APB timer: pclk clock must be connected"); |
64 | hwcaps |= ARM_HWCAP_A64_ASIMD; | ||
65 | |||
66 | /* probe for the extra features */ | ||
67 | -#define GET_FEATURE(feat, hwcap) \ | ||
68 | - do { if (arm_feature(&cpu->env, feat)) { hwcaps |= hwcap; } } while (0) | ||
69 | #define GET_FEATURE_ID(feat, hwcap) \ | ||
70 | do { if (cpu_isar_feature(feat, cpu)) { hwcaps |= hwcap; } } while (0) | ||
71 | |||
72 | @@ -XXX,XX +XXX,XX @@ static uint32_t get_elf_hwcap(void) | ||
73 | GET_FEATURE_ID(aa64_sha3, ARM_HWCAP_A64_SHA3); | ||
74 | GET_FEATURE_ID(aa64_sm3, ARM_HWCAP_A64_SM3); | ||
75 | GET_FEATURE_ID(aa64_sm4, ARM_HWCAP_A64_SM4); | ||
76 | - GET_FEATURE(ARM_FEATURE_V8_FP16, | ||
77 | - ARM_HWCAP_A64_FPHP | ARM_HWCAP_A64_ASIMDHP); | ||
78 | + GET_FEATURE_ID(aa64_fp16, ARM_HWCAP_A64_FPHP | ARM_HWCAP_A64_ASIMDHP); | ||
79 | GET_FEATURE_ID(aa64_atomics, ARM_HWCAP_A64_ATOMICS); | ||
80 | GET_FEATURE_ID(aa64_rdm, ARM_HWCAP_A64_ASIMDRDM); | ||
81 | GET_FEATURE_ID(aa64_dp, ARM_HWCAP_A64_ASIMDDP); | ||
82 | GET_FEATURE_ID(aa64_fcma, ARM_HWCAP_A64_FCMA); | ||
83 | GET_FEATURE_ID(aa64_sve, ARM_HWCAP_A64_SVE); | ||
84 | |||
85 | -#undef GET_FEATURE | ||
86 | #undef GET_FEATURE_ID | ||
87 | |||
88 | return hwcaps; | ||
89 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | ||
90 | index XXXXXXX..XXXXXXX 100644 | ||
91 | --- a/target/arm/cpu64.c | ||
92 | +++ b/target/arm/cpu64.c | ||
93 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) | ||
94 | |||
95 | t = cpu->isar.id_aa64pfr0; | ||
96 | t = FIELD_DP64(t, ID_AA64PFR0, SVE, 1); | ||
97 | + t = FIELD_DP64(t, ID_AA64PFR0, FP, 1); | ||
98 | + t = FIELD_DP64(t, ID_AA64PFR0, ADVSIMD, 1); | ||
99 | cpu->isar.id_aa64pfr0 = t; | ||
100 | |||
101 | /* Replicate the same data to the 32-bit id registers. */ | ||
102 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) | ||
103 | u = FIELD_DP32(u, ID_ISAR6, DP, 1); | ||
104 | cpu->isar.id_isar6 = u; | ||
105 | |||
106 | -#ifdef CONFIG_USER_ONLY | ||
107 | - /* We don't set these in system emulation mode for the moment, | ||
108 | - * since we don't correctly set the ID registers to advertise them, | ||
109 | - * and in some cases they're only available in AArch64 and not AArch32, | ||
110 | - * whereas the architecture requires them to be present in both if | ||
111 | - * present in either. | ||
112 | + /* | ||
113 | + * FIXME: We do not yet support ARMv8.2-fp16 for AArch32 yet, | ||
114 | + * so do not set MVFR1.FPHP. Strictly speaking this is not legal, | ||
115 | + * but it is also not legal to enable SVE without support for FP16, | ||
116 | + * and enabling SVE in system mode is more useful in the short term. | ||
117 | */ | ||
118 | - set_feature(&cpu->env, ARM_FEATURE_V8_FP16); | ||
119 | + | ||
120 | +#ifdef CONFIG_USER_ONLY | ||
121 | /* For usermode -cpu max we can use a larger and more efficient DCZ | ||
122 | * blocksize since we don't have to follow what the hardware does. | ||
123 | */ | ||
124 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
125 | index XXXXXXX..XXXXXXX 100644 | ||
126 | --- a/target/arm/helper.c | ||
127 | +++ b/target/arm/helper.c | ||
128 | @@ -XXX,XX +XXX,XX @@ void HELPER(vfp_set_fpscr)(CPUARMState *env, uint32_t val) | ||
129 | uint32_t changed; | ||
130 | |||
131 | /* When ARMv8.2-FP16 is not supported, FZ16 is RES0. */ | ||
132 | - if (!arm_feature(env, ARM_FEATURE_V8_FP16)) { | ||
133 | + if (!cpu_isar_feature(aa64_fp16, arm_env_get_cpu(env))) { | ||
134 | val &= ~FPCR_FZ16; | ||
135 | } | ||
136 | |||
137 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
138 | index XXXXXXX..XXXXXXX 100644 | ||
139 | --- a/target/arm/translate-a64.c | ||
140 | +++ b/target/arm/translate-a64.c | ||
141 | @@ -XXX,XX +XXX,XX @@ static void disas_fp_compare(DisasContext *s, uint32_t insn) | ||
142 | break; | ||
143 | case 3: | ||
144 | size = MO_16; | ||
145 | - if (arm_dc_feature(s, ARM_FEATURE_V8_FP16)) { | ||
146 | + if (dc_isar_feature(aa64_fp16, s)) { | ||
147 | break; | ||
148 | } | ||
149 | /* fallthru */ | ||
150 | @@ -XXX,XX +XXX,XX @@ static void disas_fp_ccomp(DisasContext *s, uint32_t insn) | ||
151 | break; | ||
152 | case 3: | ||
153 | size = MO_16; | ||
154 | - if (arm_dc_feature(s, ARM_FEATURE_V8_FP16)) { | ||
155 | + if (dc_isar_feature(aa64_fp16, s)) { | ||
156 | break; | ||
157 | } | ||
158 | /* fallthru */ | ||
159 | @@ -XXX,XX +XXX,XX @@ static void disas_fp_csel(DisasContext *s, uint32_t insn) | ||
160 | break; | ||
161 | case 3: | ||
162 | sz = MO_16; | ||
163 | - if (arm_dc_feature(s, ARM_FEATURE_V8_FP16)) { | ||
164 | + if (dc_isar_feature(aa64_fp16, s)) { | ||
165 | break; | ||
166 | } | ||
167 | /* fallthru */ | ||
168 | @@ -XXX,XX +XXX,XX @@ static void disas_fp_1src(DisasContext *s, uint32_t insn) | ||
169 | handle_fp_1src_double(s, opcode, rd, rn); | ||
170 | break; | ||
171 | case 3: | ||
172 | - if (!arm_dc_feature(s, ARM_FEATURE_V8_FP16)) { | ||
173 | + if (!dc_isar_feature(aa64_fp16, s)) { | ||
174 | unallocated_encoding(s); | ||
175 | return; | ||
176 | } | ||
177 | @@ -XXX,XX +XXX,XX @@ static void disas_fp_2src(DisasContext *s, uint32_t insn) | ||
178 | handle_fp_2src_double(s, opcode, rd, rn, rm); | ||
179 | break; | ||
180 | case 3: | ||
181 | - if (!arm_dc_feature(s, ARM_FEATURE_V8_FP16)) { | ||
182 | + if (!dc_isar_feature(aa64_fp16, s)) { | ||
183 | unallocated_encoding(s); | ||
184 | return; | ||
185 | } | ||
186 | @@ -XXX,XX +XXX,XX @@ static void disas_fp_3src(DisasContext *s, uint32_t insn) | ||
187 | handle_fp_3src_double(s, o0, o1, rd, rn, rm, ra); | ||
188 | break; | ||
189 | case 3: | ||
190 | - if (!arm_dc_feature(s, ARM_FEATURE_V8_FP16)) { | ||
191 | + if (!dc_isar_feature(aa64_fp16, s)) { | ||
192 | unallocated_encoding(s); | ||
193 | return; | ||
194 | } | ||
195 | @@ -XXX,XX +XXX,XX @@ static void disas_fp_imm(DisasContext *s, uint32_t insn) | ||
196 | break; | ||
197 | case 3: | ||
198 | sz = MO_16; | ||
199 | - if (arm_dc_feature(s, ARM_FEATURE_V8_FP16)) { | ||
200 | + if (dc_isar_feature(aa64_fp16, s)) { | ||
201 | break; | ||
202 | } | ||
203 | /* fallthru */ | ||
204 | @@ -XXX,XX +XXX,XX @@ static void disas_fp_fixed_conv(DisasContext *s, uint32_t insn) | ||
205 | case 1: /* float64 */ | ||
206 | break; | ||
207 | case 3: /* float16 */ | ||
208 | - if (arm_dc_feature(s, ARM_FEATURE_V8_FP16)) { | ||
209 | + if (dc_isar_feature(aa64_fp16, s)) { | ||
210 | break; | ||
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; | 51 | return; |
278 | } | 52 | } |
279 | 53 | ||
280 | - if (!arm_dc_feature(s, ARM_FEATURE_V8_FP16)) { | 54 | @@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_timer_realize(DeviceState *dev, Error **errp) |
281 | + if (!dc_isar_feature(aa64_fp16, s)) { | 55 | PTIMER_POLICY_NO_COUNTER_ROUND_DOWN); |
282 | unallocated_encoding(s); | 56 | |
283 | } | 57 | ptimer_transaction_begin(s->timer); |
284 | 58 | - ptimer_set_freq(s->timer, s->pclk_frq); | |
285 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_three_reg_same_fp16(DisasContext *s, uint32_t insn) | 59 | + ptimer_set_period_from_clock(s->timer, s->pclk, 1); |
286 | TCGv_ptr fpst; | 60 | ptimer_transaction_commit(s->timer); |
287 | bool pairwise = false; | 61 | } |
288 | 62 | ||
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 | -- | 63 | -- |
353 | 2.19.1 | 64 | 2.20.1 |
354 | 65 | ||
355 | 66 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | Switch the CMSDK APB dualtimer device over to using its Clock input; |
---|---|---|---|
2 | the pclk-frq property is now ignored. | ||
2 | 3 | ||
3 | Instead of shifts and masks, use direct loads and stores from | 4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | the neon register file. | 5 | Reviewed-by: Luc Michel <luc@lmichel.fr> |
6 | Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
7 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
8 | Message-id: 20210128114145.20536-20-peter.maydell@linaro.org | ||
9 | Message-id: 20210121190622.22000-20-peter.maydell@linaro.org | ||
10 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
11 | --- | ||
12 | hw/timer/cmsdk-apb-dualtimer.c | 42 ++++++++++++++++++++++++++++++---- | ||
13 | 1 file changed, 37 insertions(+), 5 deletions(-) | ||
5 | 14 | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 15 | diff --git a/hw/timer/cmsdk-apb-dualtimer.c b/hw/timer/cmsdk-apb-dualtimer.c |
7 | Message-id: 20181011205206.3552-21-richard.henderson@linaro.org | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | target/arm/translate.c | 92 +++++++++++++++++++++++------------------- | ||
12 | 1 file changed, 50 insertions(+), 42 deletions(-) | ||
13 | |||
14 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
15 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/translate.c | 17 | --- a/hw/timer/cmsdk-apb-dualtimer.c |
17 | +++ b/target/arm/translate.c | 18 | +++ b/hw/timer/cmsdk-apb-dualtimer.c |
18 | @@ -XXX,XX +XXX,XX @@ static TCGv_i32 neon_load_reg(int reg, int pass) | 19 | @@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_dualtimer_update(CMSDKAPBDualTimer *s) |
19 | return tmp; | 20 | qemu_set_irq(s->timerintc, timintc); |
20 | } | 21 | } |
21 | 22 | ||
22 | +static void neon_load_element(TCGv_i32 var, int reg, int ele, TCGMemOp mop) | 23 | +static int cmsdk_dualtimermod_divisor(CMSDKAPBDualTimerModule *m) |
23 | +{ | 24 | +{ |
24 | + long offset = neon_element_offset(reg, ele, mop & MO_SIZE); | 25 | + /* Return the divisor set by the current CONTROL.PRESCALE value */ |
25 | + | 26 | + switch (FIELD_EX32(m->control, CONTROL, PRESCALE)) { |
26 | + switch (mop) { | 27 | + case 0: |
27 | + case MO_UB: | 28 | + return 1; |
28 | + tcg_gen_ld8u_i32(var, cpu_env, offset); | 29 | + case 1: |
29 | + break; | 30 | + return 16; |
30 | + case MO_UW: | 31 | + case 2: |
31 | + tcg_gen_ld16u_i32(var, cpu_env, offset); | 32 | + case 3: /* UNDEFINED, we treat like 2 (and complained when it was set) */ |
32 | + break; | 33 | + return 256; |
33 | + case MO_UL: | ||
34 | + tcg_gen_ld_i32(var, cpu_env, offset); | ||
35 | + break; | ||
36 | + default: | 34 | + default: |
37 | + g_assert_not_reached(); | 35 | + g_assert_not_reached(); |
38 | + } | 36 | + } |
39 | +} | 37 | +} |
40 | + | 38 | + |
41 | static void neon_load_element64(TCGv_i64 var, int reg, int ele, TCGMemOp mop) | 39 | static void cmsdk_dualtimermod_write_control(CMSDKAPBDualTimerModule *m, |
40 | uint32_t newctrl) | ||
42 | { | 41 | { |
43 | long offset = neon_element_offset(reg, ele, mop & MO_SIZE); | 42 | @@ -XXX,XX +XXX,XX @@ static void cmsdk_dualtimermod_write_control(CMSDKAPBDualTimerModule *m, |
44 | @@ -XXX,XX +XXX,XX @@ static void neon_store_reg(int reg, int pass, TCGv_i32 var) | 43 | default: |
45 | tcg_temp_free_i32(var); | 44 | g_assert_not_reached(); |
45 | } | ||
46 | - ptimer_set_freq(m->timer, m->parent->pclk_frq / divisor); | ||
47 | + ptimer_set_period_from_clock(m->timer, m->parent->timclk, divisor); | ||
48 | } | ||
49 | |||
50 | if (changed & R_CONTROL_MODE_MASK) { | ||
51 | @@ -XXX,XX +XXX,XX @@ static void cmsdk_dualtimermod_reset(CMSDKAPBDualTimerModule *m) | ||
52 | * limit must both be set to 0xffff, so we wrap at 16 bits. | ||
53 | */ | ||
54 | ptimer_set_limit(m->timer, 0xffff, 1); | ||
55 | - ptimer_set_freq(m->timer, m->parent->pclk_frq); | ||
56 | + ptimer_set_period_from_clock(m->timer, m->parent->timclk, | ||
57 | + cmsdk_dualtimermod_divisor(m)); | ||
58 | ptimer_transaction_commit(m->timer); | ||
46 | } | 59 | } |
47 | 60 | ||
48 | +static void neon_store_element(int reg, int ele, TCGMemOp size, TCGv_i32 var) | 61 | @@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_dualtimer_reset(DeviceState *dev) |
62 | s->timeritop = 0; | ||
63 | } | ||
64 | |||
65 | +static void cmsdk_apb_dualtimer_clk_update(void *opaque) | ||
49 | +{ | 66 | +{ |
50 | + long offset = neon_element_offset(reg, ele, size); | 67 | + CMSDKAPBDualTimer *s = CMSDK_APB_DUALTIMER(opaque); |
68 | + int i; | ||
51 | + | 69 | + |
52 | + switch (size) { | 70 | + for (i = 0; i < ARRAY_SIZE(s->timermod); i++) { |
53 | + case MO_8: | 71 | + CMSDKAPBDualTimerModule *m = &s->timermod[i]; |
54 | + tcg_gen_st8_i32(var, cpu_env, offset); | 72 | + ptimer_transaction_begin(m->timer); |
55 | + break; | 73 | + ptimer_set_period_from_clock(m->timer, m->parent->timclk, |
56 | + case MO_16: | 74 | + cmsdk_dualtimermod_divisor(m)); |
57 | + tcg_gen_st16_i32(var, cpu_env, offset); | 75 | + ptimer_transaction_commit(m->timer); |
58 | + break; | ||
59 | + case MO_32: | ||
60 | + tcg_gen_st_i32(var, cpu_env, offset); | ||
61 | + break; | ||
62 | + default: | ||
63 | + g_assert_not_reached(); | ||
64 | + } | 76 | + } |
65 | +} | 77 | +} |
66 | + | 78 | + |
67 | static void neon_store_element64(int reg, int ele, TCGMemOp size, TCGv_i64 var) | 79 | static void cmsdk_apb_dualtimer_init(Object *obj) |
68 | { | 80 | { |
69 | long offset = neon_element_offset(reg, ele, size); | 81 | SysBusDevice *sbd = SYS_BUS_DEVICE(obj); |
70 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_ls_insn(DisasContext *s, uint32_t insn) | 82 | @@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_dualtimer_init(Object *obj) |
71 | int stride; | 83 | for (i = 0; i < ARRAY_SIZE(s->timermod); i++) { |
72 | int size; | 84 | sysbus_init_irq(sbd, &s->timermod[i].timerint); |
73 | int reg; | ||
74 | - int pass; | ||
75 | int load; | ||
76 | - int shift; | ||
77 | int n; | ||
78 | int vec_size; | ||
79 | int mmu_idx; | ||
80 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_ls_insn(DisasContext *s, uint32_t insn) | ||
81 | } else { | ||
82 | /* Single element. */ | ||
83 | int idx = (insn >> 4) & 0xf; | ||
84 | - pass = (insn >> 7) & 1; | ||
85 | + int reg_idx; | ||
86 | switch (size) { | ||
87 | case 0: | ||
88 | - shift = ((insn >> 5) & 3) * 8; | ||
89 | + reg_idx = (insn >> 5) & 7; | ||
90 | stride = 1; | ||
91 | break; | ||
92 | case 1: | ||
93 | - shift = ((insn >> 6) & 1) * 16; | ||
94 | + reg_idx = (insn >> 6) & 3; | ||
95 | stride = (insn & (1 << 5)) ? 2 : 1; | ||
96 | break; | ||
97 | case 2: | ||
98 | - shift = 0; | ||
99 | + reg_idx = (insn >> 7) & 1; | ||
100 | stride = (insn & (1 << 6)) ? 2 : 1; | ||
101 | break; | ||
102 | default: | ||
103 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_ls_insn(DisasContext *s, uint32_t insn) | ||
104 | */ | ||
105 | return 1; | ||
106 | } | ||
107 | + tmp = tcg_temp_new_i32(); | ||
108 | addr = tcg_temp_new_i32(); | ||
109 | load_reg_var(s, addr, rn); | ||
110 | for (reg = 0; reg < nregs; reg++) { | ||
111 | if (load) { | ||
112 | - tmp = tcg_temp_new_i32(); | ||
113 | - switch (size) { | ||
114 | - case 0: | ||
115 | - gen_aa32_ld8u(s, tmp, addr, get_mem_index(s)); | ||
116 | - break; | ||
117 | - case 1: | ||
118 | - gen_aa32_ld16u(s, tmp, addr, get_mem_index(s)); | ||
119 | - break; | ||
120 | - case 2: | ||
121 | - gen_aa32_ld32u(s, tmp, addr, get_mem_index(s)); | ||
122 | - break; | ||
123 | - default: /* Avoid compiler warnings. */ | ||
124 | - abort(); | ||
125 | - } | ||
126 | - if (size != 2) { | ||
127 | - tmp2 = neon_load_reg(rd, pass); | ||
128 | - tcg_gen_deposit_i32(tmp, tmp2, tmp, | ||
129 | - shift, size ? 16 : 8); | ||
130 | - tcg_temp_free_i32(tmp2); | ||
131 | - } | ||
132 | - neon_store_reg(rd, pass, tmp); | ||
133 | + gen_aa32_ld_i32(s, tmp, addr, get_mem_index(s), | ||
134 | + s->be_data | size); | ||
135 | + neon_store_element(rd, reg_idx, size, tmp); | ||
136 | } else { /* Store */ | ||
137 | - tmp = neon_load_reg(rd, pass); | ||
138 | - if (shift) | ||
139 | - tcg_gen_shri_i32(tmp, tmp, shift); | ||
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 | } | 85 | } |
86 | - s->timclk = qdev_init_clock_in(DEVICE(s), "TIMCLK", NULL, NULL); | ||
87 | + s->timclk = qdev_init_clock_in(DEVICE(s), "TIMCLK", | ||
88 | + cmsdk_apb_dualtimer_clk_update, s); | ||
89 | } | ||
90 | |||
91 | static void cmsdk_apb_dualtimer_realize(DeviceState *dev, Error **errp) | ||
92 | @@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_dualtimer_realize(DeviceState *dev, Error **errp) | ||
93 | CMSDKAPBDualTimer *s = CMSDK_APB_DUALTIMER(dev); | ||
94 | int i; | ||
95 | |||
96 | - if (s->pclk_frq == 0) { | ||
97 | - error_setg(errp, "CMSDK APB timer: pclk-frq property must be set"); | ||
98 | + if (!clock_has_source(s->timclk)) { | ||
99 | + error_setg(errp, "CMSDK APB dualtimer: TIMCLK clock must be connected"); | ||
100 | return; | ||
101 | } | ||
102 | |||
164 | -- | 103 | -- |
165 | 2.19.1 | 104 | 2.20.1 |
166 | 105 | ||
167 | 106 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | Switch the CMSDK APB watchdog device over to using its Clock input; |
---|---|---|---|
2 | the wdogclk_frq property is now ignored. | ||
2 | 3 | ||
3 | Having V6 alone imply jazelle was wrong for cortex-m0. | 4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | Change to an assertion for V6 & !M. | 5 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
6 | Reviewed-by: Luc Michel <luc@lmichel.fr> | ||
7 | Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
8 | Message-id: 20210128114145.20536-21-peter.maydell@linaro.org | ||
9 | Message-id: 20210121190622.22000-21-peter.maydell@linaro.org | ||
10 | --- | ||
11 | hw/watchdog/cmsdk-apb-watchdog.c | 18 ++++++++++++++---- | ||
12 | 1 file changed, 14 insertions(+), 4 deletions(-) | ||
5 | 13 | ||
6 | This was harmless, because the only place we tested ARM_FEATURE_JAZELLE | 14 | diff --git a/hw/watchdog/cmsdk-apb-watchdog.c b/hw/watchdog/cmsdk-apb-watchdog.c |
7 | was for 'bxj' in disas_arm(), which is unreachable for M-profile cores. | ||
8 | |||
9 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
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> | ||
14 | --- | ||
15 | target/arm/cpu.h | 6 +++++- | ||
16 | target/arm/cpu.c | 17 ++++++++++++++--- | ||
17 | target/arm/translate.c | 2 +- | ||
18 | 3 files changed, 20 insertions(+), 5 deletions(-) | ||
19 | |||
20 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
21 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/target/arm/cpu.h | 16 | --- a/hw/watchdog/cmsdk-apb-watchdog.c |
23 | +++ b/target/arm/cpu.h | 17 | +++ b/hw/watchdog/cmsdk-apb-watchdog.c |
24 | @@ -XXX,XX +XXX,XX @@ enum arm_features { | 18 | @@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_watchdog_reset(DeviceState *dev) |
25 | ARM_FEATURE_PMU, /* has PMU support */ | 19 | ptimer_transaction_commit(s->timer); |
26 | ARM_FEATURE_VBAR, /* has cp15 VBAR */ | ||
27 | ARM_FEATURE_M_SECURITY, /* M profile Security Extension */ | ||
28 | - ARM_FEATURE_JAZELLE, /* has (trivial) Jazelle implementation */ | ||
29 | ARM_FEATURE_SVE, /* has Scalable Vector Extension */ | ||
30 | ARM_FEATURE_V8_FP16, /* implements v8.2 half-precision float */ | ||
31 | ARM_FEATURE_M_MAIN, /* M profile Main Extension */ | ||
32 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_arm_div(const ARMISARegisters *id) | ||
33 | return FIELD_EX32(id->id_isar0, ID_ISAR0, DIVIDE) > 1; | ||
34 | } | 20 | } |
35 | 21 | ||
36 | +static inline bool isar_feature_jazelle(const ARMISARegisters *id) | 22 | +static void cmsdk_apb_watchdog_clk_update(void *opaque) |
37 | +{ | 23 | +{ |
38 | + return FIELD_EX32(id->id_isar1, ID_ISAR1, JAZELLE) != 0; | 24 | + CMSDKAPBWatchdog *s = CMSDK_APB_WATCHDOG(opaque); |
25 | + | ||
26 | + ptimer_transaction_begin(s->timer); | ||
27 | + ptimer_set_period_from_clock(s->timer, s->wdogclk, 1); | ||
28 | + ptimer_transaction_commit(s->timer); | ||
39 | +} | 29 | +} |
40 | + | 30 | + |
41 | static inline bool isar_feature_aa32_aes(const ARMISARegisters *id) | 31 | static void cmsdk_apb_watchdog_init(Object *obj) |
42 | { | 32 | { |
43 | return FIELD_EX32(id->id_isar5, ID_ISAR5, AES) != 0; | 33 | SysBusDevice *sbd = SYS_BUS_DEVICE(obj); |
44 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | 34 | @@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_watchdog_init(Object *obj) |
45 | index XXXXXXX..XXXXXXX 100644 | 35 | s, "cmsdk-apb-watchdog", 0x1000); |
46 | --- a/target/arm/cpu.c | 36 | sysbus_init_mmio(sbd, &s->iomem); |
47 | +++ b/target/arm/cpu.c | 37 | sysbus_init_irq(sbd, &s->wdogint); |
48 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) | 38 | - s->wdogclk = qdev_init_clock_in(DEVICE(s), "WDOGCLK", NULL, NULL); |
39 | + s->wdogclk = qdev_init_clock_in(DEVICE(s), "WDOGCLK", | ||
40 | + cmsdk_apb_watchdog_clk_update, s); | ||
41 | |||
42 | s->is_luminary = false; | ||
43 | s->id = cmsdk_apb_watchdog_id; | ||
44 | @@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_watchdog_realize(DeviceState *dev, Error **errp) | ||
45 | { | ||
46 | CMSDKAPBWatchdog *s = CMSDK_APB_WATCHDOG(dev); | ||
47 | |||
48 | - if (s->wdogclk_frq == 0) { | ||
49 | + if (!clock_has_source(s->wdogclk)) { | ||
50 | error_setg(errp, | ||
51 | - "CMSDK APB watchdog: wdogclk-frq property must be set"); | ||
52 | + "CMSDK APB watchdog: WDOGCLK clock must be connected"); | ||
53 | return; | ||
49 | } | 54 | } |
50 | if (arm_feature(env, ARM_FEATURE_V6)) { | 55 | |
51 | set_feature(env, ARM_FEATURE_V5); | 56 | @@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_watchdog_realize(DeviceState *dev, Error **errp) |
52 | - set_feature(env, ARM_FEATURE_JAZELLE); | 57 | PTIMER_POLICY_NO_COUNTER_ROUND_DOWN); |
53 | if (!arm_feature(env, ARM_FEATURE_M)) { | 58 | |
54 | + assert(cpu_isar_feature(jazelle, cpu)); | 59 | ptimer_transaction_begin(s->timer); |
55 | set_feature(env, ARM_FEATURE_AUXCR); | 60 | - ptimer_set_freq(s->timer, s->wdogclk_frq); |
56 | } | 61 | + ptimer_set_period_from_clock(s->timer, s->wdogclk, 1); |
57 | } | 62 | ptimer_transaction_commit(s->timer); |
58 | @@ -XXX,XX +XXX,XX @@ static void arm926_initfn(Object *obj) | ||
59 | set_feature(&cpu->env, ARM_FEATURE_VFP); | ||
60 | set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS); | ||
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 | } | 63 | } |
74 | 64 | ||
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 | -- | 65 | -- |
110 | 2.19.1 | 66 | 2.20.1 |
111 | 67 | ||
112 | 68 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | Now that the CMSDK APB watchdog uses its Clock input, it will |
---|---|---|---|
2 | correctly respond when the system clock frequency is changed using | ||
3 | the RCC register on in the Stellaris board system registers. Test | ||
4 | that when the RCC register is written it causes the watchdog timer to | ||
5 | change speed. | ||
2 | 6 | ||
3 | Move ssra_op and usra_op expanders from translate-a64.c. | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
9 | Reviewed-by: Luc Michel <luc@lmichel.fr> | ||
10 | Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
11 | Message-id: 20210128114145.20536-22-peter.maydell@linaro.org | ||
12 | Message-id: 20210121190622.22000-22-peter.maydell@linaro.org | ||
13 | --- | ||
14 | tests/qtest/cmsdk-apb-watchdog-test.c | 52 +++++++++++++++++++++++++++ | ||
15 | 1 file changed, 52 insertions(+) | ||
4 | 16 | ||
5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 17 | diff --git a/tests/qtest/cmsdk-apb-watchdog-test.c b/tests/qtest/cmsdk-apb-watchdog-test.c |
6 | Message-id: 20181011205206.3552-14-richard.henderson@linaro.org | ||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | --- | ||
10 | target/arm/translate.h | 2 + | ||
11 | target/arm/translate-a64.c | 106 ---------------------------- | ||
12 | target/arm/translate.c | 139 ++++++++++++++++++++++++++++++++++--- | ||
13 | 3 files changed, 130 insertions(+), 117 deletions(-) | ||
14 | |||
15 | diff --git a/target/arm/translate.h b/target/arm/translate.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/translate.h | 19 | --- a/tests/qtest/cmsdk-apb-watchdog-test.c |
18 | +++ b/target/arm/translate.h | 20 | +++ b/tests/qtest/cmsdk-apb-watchdog-test.c |
19 | @@ -XXX,XX +XXX,XX @@ static inline TCGv_i32 get_ahp_flag(void) | 21 | @@ -XXX,XX +XXX,XX @@ |
20 | extern const GVecGen3 bsl_op; | 22 | */ |
21 | extern const GVecGen3 bit_op; | 23 | |
22 | extern const GVecGen3 bif_op; | 24 | #include "qemu/osdep.h" |
23 | +extern const GVecGen2i ssra_op[4]; | 25 | +#include "qemu/bitops.h" |
24 | +extern const GVecGen2i usra_op[4]; | 26 | #include "libqtest-single.h" |
25 | 27 | ||
26 | /* | 28 | /* |
27 | * Forward to the isar_feature_* tests given a DisasContext pointer. | 29 | @@ -XXX,XX +XXX,XX @@ |
28 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 30 | #define WDOGMIS 0x14 |
29 | index XXXXXXX..XXXXXXX 100644 | 31 | #define WDOGLOCK 0xc00 |
30 | --- a/target/arm/translate-a64.c | 32 | |
31 | +++ b/target/arm/translate-a64.c | 33 | +#define SSYS_BASE 0x400fe000 |
32 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_scalar_two_reg_misc(DisasContext *s, uint32_t insn) | 34 | +#define RCC 0x60 |
33 | } | 35 | +#define SYSDIV_SHIFT 23 |
36 | +#define SYSDIV_LENGTH 4 | ||
37 | + | ||
38 | static void test_watchdog(void) | ||
39 | { | ||
40 | g_assert_cmpuint(readl(WDOG_BASE + WDOGRIS), ==, 0); | ||
41 | @@ -XXX,XX +XXX,XX @@ static void test_watchdog(void) | ||
42 | g_assert_cmpuint(readl(WDOG_BASE + WDOGRIS), ==, 0); | ||
34 | } | 43 | } |
35 | 44 | ||
36 | -static void gen_ssra8_i64(TCGv_i64 d, TCGv_i64 a, int64_t shift) | 45 | +static void test_clock_change(void) |
37 | -{ | ||
38 | - tcg_gen_vec_sar8i_i64(a, a, shift); | ||
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 | +{ | 46 | +{ |
162 | + tcg_gen_vec_sar8i_i64(a, a, shift); | 47 | + uint32_t rcc; |
163 | + tcg_gen_vec_add8_i64(d, d, a); | 48 | + |
49 | + /* | ||
50 | + * Test that writing to the stellaris board's RCC register to | ||
51 | + * change the system clock frequency causes the watchdog | ||
52 | + * to change the speed it counts at. | ||
53 | + */ | ||
54 | + g_assert_cmpuint(readl(WDOG_BASE + WDOGRIS), ==, 0); | ||
55 | + | ||
56 | + writel(WDOG_BASE + WDOGCONTROL, 1); | ||
57 | + writel(WDOG_BASE + WDOGLOAD, 1000); | ||
58 | + | ||
59 | + /* Step to just past the 500th tick */ | ||
60 | + clock_step(80 * 500 + 1); | ||
61 | + g_assert_cmpuint(readl(WDOG_BASE + WDOGRIS), ==, 0); | ||
62 | + g_assert_cmpuint(readl(WDOG_BASE + WDOGVALUE), ==, 500); | ||
63 | + | ||
64 | + /* Rewrite RCC.SYSDIV from 16 to 8, so the clock is now 40ns per tick */ | ||
65 | + rcc = readl(SSYS_BASE + RCC); | ||
66 | + g_assert_cmpuint(extract32(rcc, SYSDIV_SHIFT, SYSDIV_LENGTH), ==, 0xf); | ||
67 | + rcc = deposit32(rcc, SYSDIV_SHIFT, SYSDIV_LENGTH, 7); | ||
68 | + writel(SSYS_BASE + RCC, rcc); | ||
69 | + | ||
70 | + /* Just past the 1000th tick: timer should have fired */ | ||
71 | + clock_step(40 * 500); | ||
72 | + g_assert_cmpuint(readl(WDOG_BASE + WDOGRIS), ==, 1); | ||
73 | + | ||
74 | + g_assert_cmpuint(readl(WDOG_BASE + WDOGVALUE), ==, 0); | ||
75 | + | ||
76 | + /* VALUE reloads at following tick */ | ||
77 | + clock_step(41); | ||
78 | + g_assert_cmpuint(readl(WDOG_BASE + WDOGVALUE), ==, 1000); | ||
79 | + | ||
80 | + /* Writing any value to WDOGINTCLR clears the interrupt and reloads */ | ||
81 | + clock_step(40 * 500); | ||
82 | + g_assert_cmpuint(readl(WDOG_BASE + WDOGVALUE), ==, 500); | ||
83 | + g_assert_cmpuint(readl(WDOG_BASE + WDOGRIS), ==, 1); | ||
84 | + writel(WDOG_BASE + WDOGINTCLR, 0); | ||
85 | + g_assert_cmpuint(readl(WDOG_BASE + WDOGVALUE), ==, 1000); | ||
86 | + g_assert_cmpuint(readl(WDOG_BASE + WDOGRIS), ==, 0); | ||
164 | +} | 87 | +} |
165 | + | 88 | + |
166 | +static void gen_ssra16_i64(TCGv_i64 d, TCGv_i64 a, int64_t shift) | 89 | int main(int argc, char **argv) |
167 | +{ | 90 | { |
168 | + tcg_gen_vec_sar16i_i64(a, a, shift); | 91 | int r; |
169 | + tcg_gen_vec_add16_i64(d, d, a); | 92 | @@ -XXX,XX +XXX,XX @@ int main(int argc, char **argv) |
170 | +} | 93 | qtest_start("-machine lm3s811evb"); |
171 | + | 94 | |
172 | +static void gen_ssra32_i32(TCGv_i32 d, TCGv_i32 a, int32_t shift) | 95 | qtest_add_func("/cmsdk-apb-watchdog/watchdog", test_watchdog); |
173 | +{ | 96 | + qtest_add_func("/cmsdk-apb-watchdog/watchdog_clock_change", |
174 | + tcg_gen_sari_i32(a, a, shift); | 97 | + test_clock_change); |
175 | + tcg_gen_add_i32(d, d, a); | 98 | |
176 | +} | 99 | r = g_test_run(); |
177 | + | 100 | |
178 | +static void gen_ssra64_i64(TCGv_i64 d, TCGv_i64 a, int64_t shift) | ||
179 | +{ | ||
180 | + tcg_gen_sari_i64(a, a, shift); | ||
181 | + tcg_gen_add_i64(d, d, a); | ||
182 | +} | ||
183 | + | ||
184 | +static void gen_ssra_vec(unsigned vece, TCGv_vec d, TCGv_vec a, int64_t sh) | ||
185 | +{ | ||
186 | + tcg_gen_sari_vec(vece, a, a, sh); | ||
187 | + tcg_gen_add_vec(vece, d, d, a); | ||
188 | +} | ||
189 | + | ||
190 | +const GVecGen2i ssra_op[4] = { | ||
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 | -- | 101 | -- |
338 | 2.19.1 | 102 | 2.20.1 |
339 | 103 | ||
340 | 104 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | Use the MAINCLK Clock input to set the system_clock_scale variable |
---|---|---|---|
2 | rather than using the mainclk_frq property. | ||
2 | 3 | ||
3 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Message-id: 20181016223115.24100-8-richard.henderson@linaro.org | ||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
6 | Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
7 | Reviewed-by: Luc Michel <luc@lmichel.fr> | ||
8 | Message-id: 20210128114145.20536-23-peter.maydell@linaro.org | ||
9 | Message-id: 20210121190622.22000-23-peter.maydell@linaro.org | ||
8 | --- | 10 | --- |
9 | target/arm/cpu.h | 16 +++++++++++++++- | 11 | hw/arm/armsse.c | 24 +++++++++++++++++++----- |
10 | linux-user/aarch64/signal.c | 4 ++-- | 12 | 1 file changed, 19 insertions(+), 5 deletions(-) |
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 | 13 | ||
19 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 14 | diff --git a/hw/arm/armsse.c b/hw/arm/armsse.c |
20 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/target/arm/cpu.h | 16 | --- a/hw/arm/armsse.c |
22 | +++ b/target/arm/cpu.h | 17 | +++ b/hw/arm/armsse.c |
23 | @@ -XXX,XX +XXX,XX @@ FIELD(ID_AA64ISAR1, FRINTTS, 32, 4) | 18 | @@ -XXX,XX +XXX,XX @@ static void armsse_forward_sec_resp_cfg(ARMSSE *s) |
24 | FIELD(ID_AA64ISAR1, SB, 36, 4) | 19 | qdev_connect_gpio_out(dev_splitter, 2, s->sec_resp_cfg_in); |
25 | FIELD(ID_AA64ISAR1, SPECRES, 40, 4) | ||
26 | |||
27 | +FIELD(ID_AA64PFR0, EL0, 0, 4) | ||
28 | +FIELD(ID_AA64PFR0, EL1, 4, 4) | ||
29 | +FIELD(ID_AA64PFR0, EL2, 8, 4) | ||
30 | +FIELD(ID_AA64PFR0, EL3, 12, 4) | ||
31 | +FIELD(ID_AA64PFR0, FP, 16, 4) | ||
32 | +FIELD(ID_AA64PFR0, ADVSIMD, 20, 4) | ||
33 | +FIELD(ID_AA64PFR0, GIC, 24, 4) | ||
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 | } | 20 | } |
51 | 21 | ||
52 | +static inline bool isar_feature_aa64_sve(const ARMISARegisters *id) | 22 | +static void armsse_mainclk_update(void *opaque) |
53 | +{ | 23 | +{ |
54 | + return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, SVE) != 0; | 24 | + ARMSSE *s = ARM_SSE(opaque); |
25 | + /* | ||
26 | + * Set system_clock_scale from our Clock input; this is what | ||
27 | + * controls the tick rate of the CPU SysTick timer. | ||
28 | + */ | ||
29 | + system_clock_scale = clock_ticks_to_ns(s->mainclk, 1); | ||
55 | +} | 30 | +} |
56 | + | 31 | + |
57 | /* | 32 | static void armsse_init(Object *obj) |
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 | { | 33 | { |
180 | + ARMCPU *cpu = arm_env_get_cpu(env); | 34 | ARMSSE *s = ARM_SSE(obj); |
181 | int old_len, new_len; | 35 | @@ -XXX,XX +XXX,XX @@ static void armsse_init(Object *obj) |
182 | bool old_a64, new_a64; | 36 | assert(info->sram_banks <= MAX_SRAM_BANKS); |
183 | 37 | assert(info->num_cpus <= SSE_MAX_CPUS); | |
184 | /* Nothing to do if no SVE. */ | 38 | |
185 | - if (!arm_feature(env, ARM_FEATURE_SVE)) { | 39 | - s->mainclk = qdev_init_clock_in(DEVICE(s), "MAINCLK", NULL, NULL); |
186 | + if (!cpu_isar_feature(aa64_sve, cpu)) { | 40 | + s->mainclk = qdev_init_clock_in(DEVICE(s), "MAINCLK", |
41 | + armsse_mainclk_update, s); | ||
42 | s->s32kclk = qdev_init_clock_in(DEVICE(s), "S32KCLK", NULL, NULL); | ||
43 | |||
44 | memory_region_init(&s->container, obj, "armsse-container", UINT64_MAX); | ||
45 | @@ -XXX,XX +XXX,XX @@ static void armsse_realize(DeviceState *dev, Error **errp) | ||
187 | return; | 46 | return; |
188 | } | 47 | } |
189 | 48 | ||
190 | diff --git a/target/arm/machine.c b/target/arm/machine.c | 49 | - if (!s->mainclk_frq) { |
191 | index XXXXXXX..XXXXXXX 100644 | 50 | - error_setg(errp, "MAINCLK_FRQ property was not set"); |
192 | --- a/target/arm/machine.c | 51 | - return; |
193 | +++ b/target/arm/machine.c | 52 | + if (!clock_has_source(s->mainclk)) { |
194 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_iwmmxt = { | 53 | + error_setg(errp, "MAINCLK clock was not connected"); |
195 | static bool sve_needed(void *opaque) | 54 | + } |
196 | { | 55 | + if (!clock_has_source(s->s32kclk)) { |
197 | ARMCPU *cpu = opaque; | 56 | + error_setg(errp, "S32KCLK clock was not connected"); |
198 | - CPUARMState *env = &cpu->env; | 57 | } |
199 | 58 | ||
200 | - return arm_feature(env, ARM_FEATURE_SVE); | 59 | assert(info->num_cpus <= SSE_MAX_CPUS); |
201 | + return cpu_isar_feature(aa64_sve, cpu); | 60 | @@ -XXX,XX +XXX,XX @@ static void armsse_realize(DeviceState *dev, Error **errp) |
61 | */ | ||
62 | sysbus_init_mmio(SYS_BUS_DEVICE(s), &s->container); | ||
63 | |||
64 | - system_clock_scale = NANOSECONDS_PER_SECOND / s->mainclk_frq; | ||
65 | + /* Set initial system_clock_scale from MAINCLK */ | ||
66 | + armsse_mainclk_update(s); | ||
202 | } | 67 | } |
203 | 68 | ||
204 | /* The first two words of each Zreg is stored in VFP state. */ | 69 | static void armsse_idau_check(IDAUInterface *ii, uint32_t address, |
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 | } | ||
226 | break; | ||
227 | -- | 70 | -- |
228 | 2.19.1 | 71 | 2.20.1 |
229 | 72 | ||
230 | 73 | diff view generated by jsdifflib |
1 | From: Richard Henderson <rth@twiddle.net> | 1 | Remove all the code that sets frequency properties on the CMSDK |
---|---|---|---|
2 | timer, dualtimer and watchdog devices and on the ARMSSE SoC device: | ||
3 | these properties are unused now that the devices rely on their Clock | ||
4 | inputs instead. | ||
2 | 5 | ||
3 | This can reduce the number of opcodes required for certain | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | complex forms of load-multiple (e.g. ld4.16b). | 7 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
8 | Reviewed-by: Luc Michel <luc@lmichel.fr> | ||
9 | Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
10 | Message-id: 20210128114145.20536-24-peter.maydell@linaro.org | ||
11 | Message-id: 20210121190622.22000-24-peter.maydell@linaro.org | ||
12 | --- | ||
13 | hw/arm/armsse.c | 7 ------- | ||
14 | hw/arm/mps2-tz.c | 1 - | ||
15 | hw/arm/mps2.c | 3 --- | ||
16 | hw/arm/musca.c | 1 - | ||
17 | hw/arm/stellaris.c | 3 --- | ||
18 | 5 files changed, 15 deletions(-) | ||
5 | 19 | ||
6 | Signed-off-by: Richard Henderson <rth@twiddle.net> | 20 | diff --git a/hw/arm/armsse.c b/hw/arm/armsse.c |
7 | Message-id: 20181011205206.3552-2-richard.henderson@linaro.org | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | target/arm/translate-a64.c | 12 ++++++++---- | ||
12 | 1 file changed, 8 insertions(+), 4 deletions(-) | ||
13 | |||
14 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
15 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/translate-a64.c | 22 | --- a/hw/arm/armsse.c |
17 | +++ b/target/arm/translate-a64.c | 23 | +++ b/hw/arm/armsse.c |
18 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_multiple_struct(DisasContext *s, uint32_t insn) | 24 | @@ -XXX,XX +XXX,XX @@ static void armsse_realize(DeviceState *dev, Error **errp) |
19 | bool is_store = !extract32(insn, 22, 1); | 25 | * it to the appropriate PPC port; then we can realize the PPC and |
20 | bool is_postidx = extract32(insn, 23, 1); | 26 | * map its upstream ends to the right place in the container. |
21 | bool is_q = extract32(insn, 30, 1); | 27 | */ |
22 | - TCGv_i64 tcg_addr, tcg_rn; | 28 | - qdev_prop_set_uint32(DEVICE(&s->timer0), "pclk-frq", s->mainclk_frq); |
23 | + TCGv_i64 tcg_addr, tcg_rn, tcg_ebytes; | 29 | qdev_connect_clock_in(DEVICE(&s->timer0), "pclk", s->mainclk); |
24 | 30 | if (!sysbus_realize(SYS_BUS_DEVICE(&s->timer0), errp)) { | |
25 | int ebytes = 1 << size; | 31 | return; |
26 | int elements = (is_q ? 128 : 64) / (8 << size); | 32 | @@ -XXX,XX +XXX,XX @@ static void armsse_realize(DeviceState *dev, Error **errp) |
27 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_multiple_struct(DisasContext *s, uint32_t insn) | 33 | object_property_set_link(OBJECT(&s->apb_ppc0), "port[0]", OBJECT(mr), |
28 | tcg_rn = cpu_reg_sp(s, rn); | 34 | &error_abort); |
29 | tcg_addr = tcg_temp_new_i64(); | 35 | |
30 | tcg_gen_mov_i64(tcg_addr, tcg_rn); | 36 | - qdev_prop_set_uint32(DEVICE(&s->timer1), "pclk-frq", s->mainclk_frq); |
31 | + tcg_ebytes = tcg_const_i64(ebytes); | 37 | qdev_connect_clock_in(DEVICE(&s->timer1), "pclk", s->mainclk); |
32 | 38 | if (!sysbus_realize(SYS_BUS_DEVICE(&s->timer1), errp)) { | |
33 | for (r = 0; r < rpt; r++) { | 39 | return; |
34 | int e; | 40 | @@ -XXX,XX +XXX,XX @@ static void armsse_realize(DeviceState *dev, Error **errp) |
35 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_multiple_struct(DisasContext *s, uint32_t insn) | 41 | object_property_set_link(OBJECT(&s->apb_ppc0), "port[1]", OBJECT(mr), |
36 | clear_vec_high(s, is_q, tt); | 42 | &error_abort); |
37 | } | 43 | |
38 | } | 44 | - qdev_prop_set_uint32(DEVICE(&s->dualtimer), "pclk-frq", s->mainclk_frq); |
39 | - tcg_gen_addi_i64(tcg_addr, tcg_addr, ebytes); | 45 | qdev_connect_clock_in(DEVICE(&s->dualtimer), "TIMCLK", s->mainclk); |
40 | + tcg_gen_add_i64(tcg_addr, tcg_addr, tcg_ebytes); | 46 | if (!sysbus_realize(SYS_BUS_DEVICE(&s->dualtimer), errp)) { |
41 | tt = (tt + 1) % 32; | 47 | return; |
42 | } | 48 | @@ -XXX,XX +XXX,XX @@ static void armsse_realize(DeviceState *dev, Error **errp) |
43 | } | 49 | /* Devices behind APB PPC1: |
44 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_multiple_struct(DisasContext *s, uint32_t insn) | 50 | * 0x4002f000: S32K timer |
45 | tcg_gen_add_i64(tcg_rn, tcg_rn, cpu_reg(s, rm)); | 51 | */ |
46 | } | 52 | - qdev_prop_set_uint32(DEVICE(&s->s32ktimer), "pclk-frq", S32KCLK); |
47 | } | 53 | qdev_connect_clock_in(DEVICE(&s->s32ktimer), "pclk", s->s32kclk); |
48 | + tcg_temp_free_i64(tcg_ebytes); | 54 | if (!sysbus_realize(SYS_BUS_DEVICE(&s->s32ktimer), errp)) { |
49 | tcg_temp_free_i64(tcg_addr); | 55 | return; |
50 | } | 56 | @@ -XXX,XX +XXX,XX @@ static void armsse_realize(DeviceState *dev, Error **errp) |
51 | 57 | qdev_connect_gpio_out(DEVICE(&s->nmi_orgate), 0, | |
52 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_single_struct(DisasContext *s, uint32_t insn) | 58 | qdev_get_gpio_in_named(DEVICE(&s->armv7m), "NMI", 0)); |
53 | bool replicate = false; | 59 | |
54 | int index = is_q << 3 | S << 2 | size; | 60 | - qdev_prop_set_uint32(DEVICE(&s->s32kwatchdog), "wdogclk-frq", S32KCLK); |
55 | int ebytes, xs; | 61 | qdev_connect_clock_in(DEVICE(&s->s32kwatchdog), "WDOGCLK", s->s32kclk); |
56 | - TCGv_i64 tcg_addr, tcg_rn; | 62 | if (!sysbus_realize(SYS_BUS_DEVICE(&s->s32kwatchdog), errp)) { |
57 | + TCGv_i64 tcg_addr, tcg_rn, tcg_ebytes; | 63 | return; |
58 | 64 | @@ -XXX,XX +XXX,XX @@ static void armsse_realize(DeviceState *dev, Error **errp) | |
59 | switch (scale) { | 65 | |
60 | case 3: | 66 | /* 0x40080000 .. 0x4008ffff : ARMSSE second Base peripheral region */ |
61 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_single_struct(DisasContext *s, uint32_t insn) | 67 | |
62 | tcg_rn = cpu_reg_sp(s, rn); | 68 | - qdev_prop_set_uint32(DEVICE(&s->nswatchdog), "wdogclk-frq", s->mainclk_frq); |
63 | tcg_addr = tcg_temp_new_i64(); | 69 | qdev_connect_clock_in(DEVICE(&s->nswatchdog), "WDOGCLK", s->mainclk); |
64 | tcg_gen_mov_i64(tcg_addr, tcg_rn); | 70 | if (!sysbus_realize(SYS_BUS_DEVICE(&s->nswatchdog), errp)) { |
65 | + tcg_ebytes = tcg_const_i64(ebytes); | 71 | return; |
66 | 72 | @@ -XXX,XX +XXX,XX @@ static void armsse_realize(DeviceState *dev, Error **errp) | |
67 | for (xs = 0; xs < selem; xs++) { | 73 | armsse_get_common_irq_in(s, 1)); |
68 | if (replicate) { | 74 | sysbus_mmio_map(SYS_BUS_DEVICE(&s->nswatchdog), 0, 0x40081000); |
69 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_single_struct(DisasContext *s, uint32_t insn) | 75 | |
70 | do_vec_st(s, rt, index, tcg_addr, scale); | 76 | - qdev_prop_set_uint32(DEVICE(&s->swatchdog), "wdogclk-frq", s->mainclk_frq); |
71 | } | 77 | qdev_connect_clock_in(DEVICE(&s->swatchdog), "WDOGCLK", s->mainclk); |
72 | } | 78 | if (!sysbus_realize(SYS_BUS_DEVICE(&s->swatchdog), errp)) { |
73 | - tcg_gen_addi_i64(tcg_addr, tcg_addr, ebytes); | 79 | return; |
74 | + tcg_gen_add_i64(tcg_addr, tcg_addr, tcg_ebytes); | 80 | diff --git a/hw/arm/mps2-tz.c b/hw/arm/mps2-tz.c |
75 | rt = (rt + 1) % 32; | 81 | index XXXXXXX..XXXXXXX 100644 |
76 | } | 82 | --- a/hw/arm/mps2-tz.c |
77 | 83 | +++ b/hw/arm/mps2-tz.c | |
78 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_single_struct(DisasContext *s, uint32_t insn) | 84 | @@ -XXX,XX +XXX,XX @@ static void mps2tz_common_init(MachineState *machine) |
79 | tcg_gen_add_i64(tcg_rn, tcg_rn, cpu_reg(s, rm)); | 85 | object_property_set_link(OBJECT(&mms->iotkit), "memory", |
80 | } | 86 | OBJECT(system_memory), &error_abort); |
81 | } | 87 | qdev_prop_set_uint32(iotkitdev, "EXP_NUMIRQ", MPS2TZ_NUMIRQ); |
82 | + tcg_temp_free_i64(tcg_ebytes); | 88 | - qdev_prop_set_uint32(iotkitdev, "MAINCLK_FRQ", SYSCLK_FRQ); |
83 | tcg_temp_free_i64(tcg_addr); | 89 | qdev_connect_clock_in(iotkitdev, "MAINCLK", mms->sysclk); |
84 | } | 90 | qdev_connect_clock_in(iotkitdev, "S32KCLK", mms->s32kclk); |
91 | sysbus_realize(SYS_BUS_DEVICE(&mms->iotkit), &error_fatal); | ||
92 | diff --git a/hw/arm/mps2.c b/hw/arm/mps2.c | ||
93 | index XXXXXXX..XXXXXXX 100644 | ||
94 | --- a/hw/arm/mps2.c | ||
95 | +++ b/hw/arm/mps2.c | ||
96 | @@ -XXX,XX +XXX,XX @@ static void mps2_common_init(MachineState *machine) | ||
97 | object_initialize_child(OBJECT(mms), name, &mms->timer[i], | ||
98 | TYPE_CMSDK_APB_TIMER); | ||
99 | sbd = SYS_BUS_DEVICE(&mms->timer[i]); | ||
100 | - qdev_prop_set_uint32(DEVICE(&mms->timer[i]), "pclk-frq", SYSCLK_FRQ); | ||
101 | qdev_connect_clock_in(DEVICE(&mms->timer[i]), "pclk", mms->sysclk); | ||
102 | sysbus_realize_and_unref(sbd, &error_fatal); | ||
103 | sysbus_mmio_map(sbd, 0, base); | ||
104 | @@ -XXX,XX +XXX,XX @@ static void mps2_common_init(MachineState *machine) | ||
105 | |||
106 | object_initialize_child(OBJECT(mms), "dualtimer", &mms->dualtimer, | ||
107 | TYPE_CMSDK_APB_DUALTIMER); | ||
108 | - qdev_prop_set_uint32(DEVICE(&mms->dualtimer), "pclk-frq", SYSCLK_FRQ); | ||
109 | qdev_connect_clock_in(DEVICE(&mms->dualtimer), "TIMCLK", mms->sysclk); | ||
110 | sysbus_realize(SYS_BUS_DEVICE(&mms->dualtimer), &error_fatal); | ||
111 | sysbus_connect_irq(SYS_BUS_DEVICE(&mms->dualtimer), 0, | ||
112 | @@ -XXX,XX +XXX,XX @@ static void mps2_common_init(MachineState *machine) | ||
113 | sysbus_mmio_map(SYS_BUS_DEVICE(&mms->dualtimer), 0, 0x40002000); | ||
114 | object_initialize_child(OBJECT(mms), "watchdog", &mms->watchdog, | ||
115 | TYPE_CMSDK_APB_WATCHDOG); | ||
116 | - qdev_prop_set_uint32(DEVICE(&mms->watchdog), "wdogclk-frq", SYSCLK_FRQ); | ||
117 | qdev_connect_clock_in(DEVICE(&mms->watchdog), "WDOGCLK", mms->sysclk); | ||
118 | sysbus_realize(SYS_BUS_DEVICE(&mms->watchdog), &error_fatal); | ||
119 | sysbus_connect_irq(SYS_BUS_DEVICE(&mms->watchdog), 0, | ||
120 | diff --git a/hw/arm/musca.c b/hw/arm/musca.c | ||
121 | index XXXXXXX..XXXXXXX 100644 | ||
122 | --- a/hw/arm/musca.c | ||
123 | +++ b/hw/arm/musca.c | ||
124 | @@ -XXX,XX +XXX,XX @@ static void musca_init(MachineState *machine) | ||
125 | qdev_prop_set_uint32(ssedev, "EXP_NUMIRQ", mmc->num_irqs); | ||
126 | qdev_prop_set_uint32(ssedev, "init-svtor", mmc->init_svtor); | ||
127 | qdev_prop_set_uint32(ssedev, "SRAM_ADDR_WIDTH", mmc->sram_addr_width); | ||
128 | - qdev_prop_set_uint32(ssedev, "MAINCLK_FRQ", SYSCLK_FRQ); | ||
129 | qdev_connect_clock_in(ssedev, "MAINCLK", mms->sysclk); | ||
130 | qdev_connect_clock_in(ssedev, "S32KCLK", mms->s32kclk); | ||
131 | /* | ||
132 | diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c | ||
133 | index XXXXXXX..XXXXXXX 100644 | ||
134 | --- a/hw/arm/stellaris.c | ||
135 | +++ b/hw/arm/stellaris.c | ||
136 | @@ -XXX,XX +XXX,XX @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board) | ||
137 | if (board->dc1 & (1 << 3)) { /* watchdog present */ | ||
138 | dev = qdev_new(TYPE_LUMINARY_WATCHDOG); | ||
139 | |||
140 | - /* system_clock_scale is valid now */ | ||
141 | - uint32_t mainclk = NANOSECONDS_PER_SECOND / system_clock_scale; | ||
142 | - qdev_prop_set_uint32(dev, "wdogclk-frq", mainclk); | ||
143 | qdev_connect_clock_in(dev, "WDOGCLK", | ||
144 | qdev_get_clock_out(ssys_dev, "SYSCLK")); | ||
85 | 145 | ||
86 | -- | 146 | -- |
87 | 2.19.1 | 147 | 2.20.1 |
88 | 148 | ||
89 | 149 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | Now no users are setting the frq properties on the CMSDK timer, |
---|---|---|---|
2 | dualtimer, watchdog or ARMSSE SoC devices, we can remove the | ||
3 | properties and the struct fields that back them. | ||
2 | 4 | ||
3 | This is done generically in translator_loop. | 5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
7 | Reviewed-by: Luc Michel <luc@lmichel.fr> | ||
8 | Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
9 | Message-id: 20210128114145.20536-25-peter.maydell@linaro.org | ||
10 | Message-id: 20210121190622.22000-25-peter.maydell@linaro.org | ||
11 | --- | ||
12 | include/hw/arm/armsse.h | 2 -- | ||
13 | include/hw/timer/cmsdk-apb-dualtimer.h | 2 -- | ||
14 | include/hw/timer/cmsdk-apb-timer.h | 2 -- | ||
15 | include/hw/watchdog/cmsdk-apb-watchdog.h | 2 -- | ||
16 | hw/arm/armsse.c | 2 -- | ||
17 | hw/timer/cmsdk-apb-dualtimer.c | 6 ------ | ||
18 | hw/timer/cmsdk-apb-timer.c | 6 ------ | ||
19 | hw/watchdog/cmsdk-apb-watchdog.c | 6 ------ | ||
20 | 8 files changed, 28 deletions(-) | ||
4 | 21 | ||
5 | Reported-by: Laurent Desnogues <laurent.desnogues@gmail.com> | 22 | diff --git a/include/hw/arm/armsse.h b/include/hw/arm/armsse.h |
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | 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> | ||
11 | --- | ||
12 | target/arm/translate-a64.c | 1 - | ||
13 | target/arm/translate.c | 1 - | ||
14 | 2 files changed, 2 deletions(-) | ||
15 | |||
16 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
17 | index XXXXXXX..XXXXXXX 100644 | 23 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/target/arm/translate-a64.c | 24 | --- a/include/hw/arm/armsse.h |
19 | +++ b/target/arm/translate-a64.c | 25 | +++ b/include/hw/arm/armsse.h |
20 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_init_disas_context(DisasContextBase *dcbase, | 26 | @@ -XXX,XX +XXX,XX @@ |
21 | 27 | * + Clock input "S32KCLK": slow 32KHz clock used for a few peripherals | |
22 | static void aarch64_tr_tb_start(DisasContextBase *db, CPUState *cpu) | 28 | * + QOM property "memory" is a MemoryRegion containing the devices provided |
29 | * by the board model. | ||
30 | - * + QOM property "MAINCLK_FRQ" is the frequency of the main system clock | ||
31 | * + QOM property "EXP_NUMIRQ" sets the number of expansion interrupts. | ||
32 | * (In hardware, the SSE-200 permits the number of expansion interrupts | ||
33 | * for the two CPUs to be configured separately, but we restrict it to | ||
34 | @@ -XXX,XX +XXX,XX @@ struct ARMSSE { | ||
35 | /* Properties */ | ||
36 | MemoryRegion *board_memory; | ||
37 | uint32_t exp_numirq; | ||
38 | - uint32_t mainclk_frq; | ||
39 | uint32_t sram_addr_width; | ||
40 | uint32_t init_svtor; | ||
41 | bool cpu_fpu[SSE_MAX_CPUS]; | ||
42 | diff --git a/include/hw/timer/cmsdk-apb-dualtimer.h b/include/hw/timer/cmsdk-apb-dualtimer.h | ||
43 | index XXXXXXX..XXXXXXX 100644 | ||
44 | --- a/include/hw/timer/cmsdk-apb-dualtimer.h | ||
45 | +++ b/include/hw/timer/cmsdk-apb-dualtimer.h | ||
46 | @@ -XXX,XX +XXX,XX @@ | ||
47 | * https://developer.arm.com/products/system-design/system-design-kits/cortex-m-system-design-kit | ||
48 | * | ||
49 | * QEMU interface: | ||
50 | - * + QOM property "pclk-frq": frequency at which the timer is clocked | ||
51 | * + Clock input "TIMCLK": clock (for both timers) | ||
52 | * + sysbus MMIO region 0: the register bank | ||
53 | * + sysbus IRQ 0: combined timer interrupt TIMINTC | ||
54 | @@ -XXX,XX +XXX,XX @@ struct CMSDKAPBDualTimer { | ||
55 | /*< public >*/ | ||
56 | MemoryRegion iomem; | ||
57 | qemu_irq timerintc; | ||
58 | - uint32_t pclk_frq; | ||
59 | Clock *timclk; | ||
60 | |||
61 | CMSDKAPBDualTimerModule timermod[CMSDK_APB_DUALTIMER_NUM_MODULES]; | ||
62 | diff --git a/include/hw/timer/cmsdk-apb-timer.h b/include/hw/timer/cmsdk-apb-timer.h | ||
63 | index XXXXXXX..XXXXXXX 100644 | ||
64 | --- a/include/hw/timer/cmsdk-apb-timer.h | ||
65 | +++ b/include/hw/timer/cmsdk-apb-timer.h | ||
66 | @@ -XXX,XX +XXX,XX @@ OBJECT_DECLARE_SIMPLE_TYPE(CMSDKAPBTimer, CMSDK_APB_TIMER) | ||
67 | |||
68 | /* | ||
69 | * QEMU interface: | ||
70 | - * + QOM property "pclk-frq": frequency at which the timer is clocked | ||
71 | * + Clock input "pclk": clock for the timer | ||
72 | * + sysbus MMIO region 0: the register bank | ||
73 | * + sysbus IRQ 0: timer interrupt TIMERINT | ||
74 | @@ -XXX,XX +XXX,XX @@ struct CMSDKAPBTimer { | ||
75 | /*< public >*/ | ||
76 | MemoryRegion iomem; | ||
77 | qemu_irq timerint; | ||
78 | - uint32_t pclk_frq; | ||
79 | struct ptimer_state *timer; | ||
80 | Clock *pclk; | ||
81 | |||
82 | diff --git a/include/hw/watchdog/cmsdk-apb-watchdog.h b/include/hw/watchdog/cmsdk-apb-watchdog.h | ||
83 | index XXXXXXX..XXXXXXX 100644 | ||
84 | --- a/include/hw/watchdog/cmsdk-apb-watchdog.h | ||
85 | +++ b/include/hw/watchdog/cmsdk-apb-watchdog.h | ||
86 | @@ -XXX,XX +XXX,XX @@ | ||
87 | * https://developer.arm.com/products/system-design/system-design-kits/cortex-m-system-design-kit | ||
88 | * | ||
89 | * QEMU interface: | ||
90 | - * + QOM property "wdogclk-frq": frequency at which the watchdog is clocked | ||
91 | * + Clock input "WDOGCLK": clock for the watchdog's timer | ||
92 | * + sysbus MMIO region 0: the register bank | ||
93 | * + sysbus IRQ 0: watchdog interrupt | ||
94 | @@ -XXX,XX +XXX,XX @@ struct CMSDKAPBWatchdog { | ||
95 | /*< public >*/ | ||
96 | MemoryRegion iomem; | ||
97 | qemu_irq wdogint; | ||
98 | - uint32_t wdogclk_frq; | ||
99 | bool is_luminary; | ||
100 | struct ptimer_state *timer; | ||
101 | Clock *wdogclk; | ||
102 | diff --git a/hw/arm/armsse.c b/hw/arm/armsse.c | ||
103 | index XXXXXXX..XXXXXXX 100644 | ||
104 | --- a/hw/arm/armsse.c | ||
105 | +++ b/hw/arm/armsse.c | ||
106 | @@ -XXX,XX +XXX,XX @@ static Property iotkit_properties[] = { | ||
107 | DEFINE_PROP_LINK("memory", ARMSSE, board_memory, TYPE_MEMORY_REGION, | ||
108 | MemoryRegion *), | ||
109 | DEFINE_PROP_UINT32("EXP_NUMIRQ", ARMSSE, exp_numirq, 64), | ||
110 | - DEFINE_PROP_UINT32("MAINCLK_FRQ", ARMSSE, mainclk_frq, 0), | ||
111 | DEFINE_PROP_UINT32("SRAM_ADDR_WIDTH", ARMSSE, sram_addr_width, 15), | ||
112 | DEFINE_PROP_UINT32("init-svtor", ARMSSE, init_svtor, 0x10000000), | ||
113 | DEFINE_PROP_BOOL("CPU0_FPU", ARMSSE, cpu_fpu[0], true), | ||
114 | @@ -XXX,XX +XXX,XX @@ static Property armsse_properties[] = { | ||
115 | DEFINE_PROP_LINK("memory", ARMSSE, board_memory, TYPE_MEMORY_REGION, | ||
116 | MemoryRegion *), | ||
117 | DEFINE_PROP_UINT32("EXP_NUMIRQ", ARMSSE, exp_numirq, 64), | ||
118 | - DEFINE_PROP_UINT32("MAINCLK_FRQ", ARMSSE, mainclk_frq, 0), | ||
119 | DEFINE_PROP_UINT32("SRAM_ADDR_WIDTH", ARMSSE, sram_addr_width, 15), | ||
120 | DEFINE_PROP_UINT32("init-svtor", ARMSSE, init_svtor, 0x10000000), | ||
121 | DEFINE_PROP_BOOL("CPU0_FPU", ARMSSE, cpu_fpu[0], false), | ||
122 | diff --git a/hw/timer/cmsdk-apb-dualtimer.c b/hw/timer/cmsdk-apb-dualtimer.c | ||
123 | index XXXXXXX..XXXXXXX 100644 | ||
124 | --- a/hw/timer/cmsdk-apb-dualtimer.c | ||
125 | +++ b/hw/timer/cmsdk-apb-dualtimer.c | ||
126 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription cmsdk_apb_dualtimer_vmstate = { | ||
127 | } | ||
128 | }; | ||
129 | |||
130 | -static Property cmsdk_apb_dualtimer_properties[] = { | ||
131 | - DEFINE_PROP_UINT32("pclk-frq", CMSDKAPBDualTimer, pclk_frq, 0), | ||
132 | - DEFINE_PROP_END_OF_LIST(), | ||
133 | -}; | ||
134 | - | ||
135 | static void cmsdk_apb_dualtimer_class_init(ObjectClass *klass, void *data) | ||
23 | { | 136 | { |
24 | - tcg_clear_temp_count(); | 137 | DeviceClass *dc = DEVICE_CLASS(klass); |
138 | @@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_dualtimer_class_init(ObjectClass *klass, void *data) | ||
139 | dc->realize = cmsdk_apb_dualtimer_realize; | ||
140 | dc->vmsd = &cmsdk_apb_dualtimer_vmstate; | ||
141 | dc->reset = cmsdk_apb_dualtimer_reset; | ||
142 | - device_class_set_props(dc, cmsdk_apb_dualtimer_properties); | ||
25 | } | 143 | } |
26 | 144 | ||
27 | static void aarch64_tr_insn_start(DisasContextBase *dcbase, CPUState *cpu) | 145 | static const TypeInfo cmsdk_apb_dualtimer_info = { |
28 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 146 | diff --git a/hw/timer/cmsdk-apb-timer.c b/hw/timer/cmsdk-apb-timer.c |
29 | index XXXXXXX..XXXXXXX 100644 | 147 | index XXXXXXX..XXXXXXX 100644 |
30 | --- a/target/arm/translate.c | 148 | --- a/hw/timer/cmsdk-apb-timer.c |
31 | +++ b/target/arm/translate.c | 149 | +++ b/hw/timer/cmsdk-apb-timer.c |
32 | @@ -XXX,XX +XXX,XX @@ static void arm_tr_tb_start(DisasContextBase *dcbase, CPUState *cpu) | 150 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription cmsdk_apb_timer_vmstate = { |
33 | tcg_gen_movi_i32(tmp, 0); | ||
34 | store_cpu_field(tmp, condexec_bits); | ||
35 | } | 151 | } |
36 | - tcg_clear_temp_count(); | 152 | }; |
153 | |||
154 | -static Property cmsdk_apb_timer_properties[] = { | ||
155 | - DEFINE_PROP_UINT32("pclk-frq", CMSDKAPBTimer, pclk_frq, 0), | ||
156 | - DEFINE_PROP_END_OF_LIST(), | ||
157 | -}; | ||
158 | - | ||
159 | static void cmsdk_apb_timer_class_init(ObjectClass *klass, void *data) | ||
160 | { | ||
161 | DeviceClass *dc = DEVICE_CLASS(klass); | ||
162 | @@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_timer_class_init(ObjectClass *klass, void *data) | ||
163 | dc->realize = cmsdk_apb_timer_realize; | ||
164 | dc->vmsd = &cmsdk_apb_timer_vmstate; | ||
165 | dc->reset = cmsdk_apb_timer_reset; | ||
166 | - device_class_set_props(dc, cmsdk_apb_timer_properties); | ||
37 | } | 167 | } |
38 | 168 | ||
39 | static void arm_tr_insn_start(DisasContextBase *dcbase, CPUState *cpu) | 169 | static const TypeInfo cmsdk_apb_timer_info = { |
170 | diff --git a/hw/watchdog/cmsdk-apb-watchdog.c b/hw/watchdog/cmsdk-apb-watchdog.c | ||
171 | index XXXXXXX..XXXXXXX 100644 | ||
172 | --- a/hw/watchdog/cmsdk-apb-watchdog.c | ||
173 | +++ b/hw/watchdog/cmsdk-apb-watchdog.c | ||
174 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription cmsdk_apb_watchdog_vmstate = { | ||
175 | } | ||
176 | }; | ||
177 | |||
178 | -static Property cmsdk_apb_watchdog_properties[] = { | ||
179 | - DEFINE_PROP_UINT32("wdogclk-frq", CMSDKAPBWatchdog, wdogclk_frq, 0), | ||
180 | - DEFINE_PROP_END_OF_LIST(), | ||
181 | -}; | ||
182 | - | ||
183 | static void cmsdk_apb_watchdog_class_init(ObjectClass *klass, void *data) | ||
184 | { | ||
185 | DeviceClass *dc = DEVICE_CLASS(klass); | ||
186 | @@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_watchdog_class_init(ObjectClass *klass, void *data) | ||
187 | dc->realize = cmsdk_apb_watchdog_realize; | ||
188 | dc->vmsd = &cmsdk_apb_watchdog_vmstate; | ||
189 | dc->reset = cmsdk_apb_watchdog_reset; | ||
190 | - device_class_set_props(dc, cmsdk_apb_watchdog_properties); | ||
191 | } | ||
192 | |||
193 | static const TypeInfo cmsdk_apb_watchdog_info = { | ||
40 | -- | 194 | -- |
41 | 2.19.1 | 195 | 2.20.1 |
42 | 196 | ||
43 | 197 | diff view generated by jsdifflib |
1 | From: Markus Armbruster <armbru@redhat.com> | 1 | Now that the watchdog device uses its Clock input rather than being |
---|---|---|---|
2 | passed the value of system_clock_scale at creation time, we can | ||
3 | remove the hack where we reset the STELLARIS_SYS at board creation | ||
4 | time to force it to set system_clock_scale. Instead it will be reset | ||
5 | at the usual point in startup and will inform the watchdog of the | ||
6 | clock frequency at that point. | ||
2 | 7 | ||
3 | Device models aren't supposed to go on fishing expeditions for | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | backends. They should expose suitable properties for the user to set. | 9 | Reviewed-by: Luc Michel <luc@lmichel.fr> |
5 | For onboard devices, board code sets them. | 10 | Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
11 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
12 | Message-id: 20210128114145.20536-26-peter.maydell@linaro.org | ||
13 | Message-id: 20210121190622.22000-26-peter.maydell@linaro.org | ||
14 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
15 | --- | ||
16 | hw/arm/stellaris.c | 10 ---------- | ||
17 | 1 file changed, 10 deletions(-) | ||
6 | 18 | ||
7 | Device ssi-sd picks up its block backend in its init() method with | 19 | diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c |
8 | drive_get_next() instead. This mistake is already marked FIXME since | ||
9 | commit af9e40a. | ||
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> | ||
22 | --- | ||
23 | hw/sd/ssi-sd.c | 2 ++ | ||
24 | 1 file changed, 2 insertions(+) | ||
25 | |||
26 | diff --git a/hw/sd/ssi-sd.c b/hw/sd/ssi-sd.c | ||
27 | index XXXXXXX..XXXXXXX 100644 | 20 | index XXXXXXX..XXXXXXX 100644 |
28 | --- a/hw/sd/ssi-sd.c | 21 | --- a/hw/arm/stellaris.c |
29 | +++ b/hw/sd/ssi-sd.c | 22 | +++ b/hw/arm/stellaris.c |
30 | @@ -XXX,XX +XXX,XX @@ static void ssi_sd_class_init(ObjectClass *klass, void *data) | 23 | @@ -XXX,XX +XXX,XX @@ static DeviceState *stellaris_sys_init(uint32_t base, qemu_irq irq, |
31 | k->cs_polarity = SSI_CS_LOW; | 24 | sysbus_mmio_map(sbd, 0, base); |
32 | dc->vmsd = &vmstate_ssi_sd; | 25 | sysbus_connect_irq(sbd, 0, irq); |
33 | dc->reset = ssi_sd_reset; | 26 | |
34 | + /* Reason: init() method uses drive_get_next() */ | 27 | - /* |
35 | + dc->user_creatable = false; | 28 | - * Normally we should not be resetting devices like this during |
29 | - * board creation. For the moment we need to do so, because | ||
30 | - * system_clock_scale will only get set when the STELLARIS_SYS | ||
31 | - * device is reset, and we need its initial value to pass to | ||
32 | - * the watchdog device. This hack can be removed once the | ||
33 | - * watchdog has been converted to use a Clock input instead. | ||
34 | - */ | ||
35 | - device_cold_reset(dev); | ||
36 | - | ||
37 | return dev; | ||
36 | } | 38 | } |
37 | 39 | ||
38 | static const TypeInfo ssi_sd_info = { | ||
39 | -- | 40 | -- |
40 | 2.19.1 | 41 | 2.20.1 |
41 | 42 | ||
42 | 43 | diff view generated by jsdifflib |