1 | The following changes since commit 61fee7f45955cd0bf9b79be9fa9c7ebabb5e6a85: | 1 | The following changes since commit 8f6330a807f2642dc2a3cdf33347aa28a4c00a87: |
---|---|---|---|
2 | 2 | ||
3 | Merge remote-tracking branch 'remotes/philmd-gitlab/tags/acceptance-testing-20200622' into staging (2020-06-22 20:50:10 +0100) | 3 | Merge tag 'pull-maintainer-updates-060324-1' of https://gitlab.com/stsquad/qemu into staging (2024-03-06 16:56:20 +0000) |
4 | 4 | ||
5 | are available in the Git repository at: | 5 | are available in the Git repository at: |
6 | 6 | ||
7 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20200623 | 7 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20240308 |
8 | 8 | ||
9 | for you to fetch changes up to 539533b85fbd269f777bed931de8ccae1dd837e9: | 9 | for you to fetch changes up to bbf6c6dbead82292a20951eb1204442a6b838de9: |
10 | 10 | ||
11 | arm/virt: Add memory hot remove support (2020-06-23 11:39:48 +0100) | 11 | target/arm: Move v7m-related code from cpu32.c into a separate file (2024-03-08 14:45:03 +0000) |
12 | 12 | ||
13 | ---------------------------------------------------------------- | 13 | ---------------------------------------------------------------- |
14 | target-arm queue: | 14 | target-arm queue: |
15 | * util/oslib-posix : qemu_init_exec_dir implementation for Mac | 15 | * Implement FEAT_ECV |
16 | * target/arm: Last parts of neon decodetree conversion | 16 | * STM32L4x5: Implement GPIO device |
17 | * hw/arm/virt: Add 5.0 HW compat props | 17 | * Fix 32-bit SMOPA |
18 | * hw/watchdog/cmsdk-apb-watchdog: Add trace event for lock status | 18 | * Refactor v7m related code from cpu32.c into its own file |
19 | * mps2: Add CMSDK APB watchdog, FPGAIO block, S2I devices and I2C devices | 19 | * hw/rtc/sun4v-rtc: Relicense to GPLv2-or-later |
20 | * mps2: Add some unimplemented-device stubs for audio and GPIO | ||
21 | * mps2-tz: Use the ARM SBCon two-wire serial bus interface | ||
22 | * target/arm: Check supported KVM features globally (not per vCPU) | ||
23 | * tests/qtest/arm-cpu-features: Add feature setting tests | ||
24 | * arm/virt: Add memory hot remove support | ||
25 | 20 | ||
26 | ---------------------------------------------------------------- | 21 | ---------------------------------------------------------------- |
27 | Andrew Jones (2): | 22 | Inès Varhol (3): |
28 | hw/arm/virt: Add 5.0 HW compat props | 23 | hw/gpio: Implement STM32L4x5 GPIO |
29 | tests/qtest/arm-cpu-features: Add feature setting tests | 24 | hw/arm: Connect STM32L4x5 GPIO to STM32L4x5 SoC |
25 | tests/qtest: Add STM32L4x5 GPIO QTest testcase | ||
30 | 26 | ||
31 | David CARLIER (1): | 27 | Peter Maydell (9): |
32 | util/oslib-posix : qemu_init_exec_dir implementation for Mac | 28 | target/arm: Move some register related defines to internals.h |
29 | target/arm: Timer _EL02 registers UNDEF for E2H == 0 | ||
30 | target/arm: use FIELD macro for CNTHCTL bit definitions | ||
31 | target/arm: Don't allow RES0 CNTHCTL_EL2 bits to be written | ||
32 | target/arm: Implement new FEAT_ECV trap bits | ||
33 | target/arm: Define CNTPCTSS_EL0 and CNTVCTSS_EL0 | ||
34 | target/arm: Implement FEAT_ECV CNTPOFF_EL2 handling | ||
35 | target/arm: Enable FEAT_ECV for 'max' CPU | ||
36 | hw/rtc/sun4v-rtc: Relicense to GPLv2-or-later | ||
33 | 37 | ||
34 | Peter Maydell (23): | 38 | Richard Henderson (1): |
35 | target/arm: Convert Neon 2-reg-misc VREV64 to decodetree | 39 | target/arm: Fix 32-bit SMOPA |
36 | target/arm: Convert Neon 2-reg-misc pairwise ops to decodetree | ||
37 | target/arm: Convert VZIP, VUZP to decodetree | ||
38 | target/arm: Convert Neon narrowing moves to decodetree | ||
39 | target/arm: Convert Neon 2-reg-misc VSHLL to decodetree | ||
40 | target/arm: Convert Neon VCVT f16/f32 insns to decodetree | ||
41 | target/arm: Convert vectorised 2-reg-misc Neon ops to decodetree | ||
42 | target/arm: Convert Neon 2-reg-misc crypto operations to decodetree | ||
43 | target/arm: Rename NeonGenOneOpFn to NeonGenOne64OpFn | ||
44 | target/arm: Fix capitalization in NeonGenTwo{Single, Double}OPFn typedefs | ||
45 | target/arm: Make gen_swap_half() take separate src and dest | ||
46 | target/arm: Convert Neon 2-reg-misc VREV32 and VREV16 to decodetree | ||
47 | target/arm: Convert remaining simple 2-reg-misc Neon ops | ||
48 | target/arm: Convert Neon VQABS, VQNEG to decodetree | ||
49 | target/arm: Convert simple fp Neon 2-reg-misc insns | ||
50 | target/arm: Convert Neon 2-reg-misc fp-compare-with-zero insns to decodetree | ||
51 | target/arm: Convert Neon 2-reg-misc VRINT insns to decodetree | ||
52 | target/arm: Convert Neon 2-reg-misc VCVT insns to decodetree | ||
53 | target/arm: Convert Neon VSWP to decodetree | ||
54 | target/arm: Convert Neon VTRN to decodetree | ||
55 | target/arm: Move some functions used only in translate-neon.inc.c to that file | ||
56 | target/arm: Remove unnecessary gen_io_end() calls | ||
57 | target/arm: Remove dead code relating to SABA and UABA | ||
58 | 40 | ||
59 | Philippe Mathieu-Daudé (15): | 41 | Thomas Huth (1): |
60 | hw/watchdog/cmsdk-apb-watchdog: Add trace event for lock status | 42 | target/arm: Move v7m-related code from cpu32.c into a separate file |
61 | hw/i2c/versatile_i2c: Add definitions for register addresses | ||
62 | hw/i2c/versatile_i2c: Add SCL/SDA definitions | ||
63 | hw/i2c: Add header for ARM SBCon two-wire serial bus interface | ||
64 | hw/arm: Use TYPE_VERSATILE_I2C instead of hardcoded string | ||
65 | hw/arm/mps2: Document CMSDK/FPGA APB subsystem sections | ||
66 | hw/arm/mps2: Rename CMSDK AHB peripheral region | ||
67 | hw/arm/mps2: Add CMSDK APB watchdog device | ||
68 | hw/arm/mps2: Add CMSDK AHB GPIO peripherals as unimplemented devices | ||
69 | hw/arm/mps2: Map the FPGA I/O block | ||
70 | hw/arm/mps2: Add SPI devices | ||
71 | hw/arm/mps2: Add I2C devices | ||
72 | hw/arm/mps2: Add audio I2S interface as unimplemented device | ||
73 | hw/arm/mps2-tz: Use the ARM SBCon two-wire serial bus interface | ||
74 | target/arm: Check supported KVM features globally (not per vCPU) | ||
75 | 43 | ||
76 | Shameer Kolothum (1): | 44 | MAINTAINERS | 1 + |
77 | arm/virt: Add memory hot remove support | 45 | docs/system/arm/b-l475e-iot01a.rst | 2 +- |
46 | docs/system/arm/emulation.rst | 1 + | ||
47 | include/hw/arm/stm32l4x5_soc.h | 2 + | ||
48 | include/hw/gpio/stm32l4x5_gpio.h | 71 +++++ | ||
49 | include/hw/misc/stm32l4x5_syscfg.h | 3 +- | ||
50 | include/hw/rtc/sun4v-rtc.h | 2 +- | ||
51 | target/arm/cpu-features.h | 10 + | ||
52 | target/arm/cpu.h | 129 +-------- | ||
53 | target/arm/internals.h | 151 ++++++++++ | ||
54 | hw/arm/stm32l4x5_soc.c | 71 ++++- | ||
55 | hw/gpio/stm32l4x5_gpio.c | 477 ++++++++++++++++++++++++++++++++ | ||
56 | hw/misc/stm32l4x5_syscfg.c | 1 + | ||
57 | hw/rtc/sun4v-rtc.c | 2 +- | ||
58 | target/arm/helper.c | 189 ++++++++++++- | ||
59 | target/arm/tcg/cpu-v7m.c | 290 +++++++++++++++++++ | ||
60 | target/arm/tcg/cpu32.c | 261 ------------------ | ||
61 | target/arm/tcg/cpu64.c | 1 + | ||
62 | target/arm/tcg/sme_helper.c | 77 +++--- | ||
63 | tests/qtest/stm32l4x5_gpio-test.c | 551 +++++++++++++++++++++++++++++++++++++ | ||
64 | tests/tcg/aarch64/sme-smopa-1.c | 47 ++++ | ||
65 | tests/tcg/aarch64/sme-smopa-2.c | 54 ++++ | ||
66 | hw/arm/Kconfig | 3 +- | ||
67 | hw/gpio/Kconfig | 3 + | ||
68 | hw/gpio/meson.build | 1 + | ||
69 | hw/gpio/trace-events | 6 + | ||
70 | target/arm/meson.build | 3 + | ||
71 | target/arm/tcg/meson.build | 3 + | ||
72 | target/arm/trace-events | 1 + | ||
73 | tests/qtest/meson.build | 3 +- | ||
74 | tests/tcg/aarch64/Makefile.target | 2 +- | ||
75 | 31 files changed, 1962 insertions(+), 456 deletions(-) | ||
76 | create mode 100644 include/hw/gpio/stm32l4x5_gpio.h | ||
77 | create mode 100644 hw/gpio/stm32l4x5_gpio.c | ||
78 | create mode 100644 target/arm/tcg/cpu-v7m.c | ||
79 | create mode 100644 tests/qtest/stm32l4x5_gpio-test.c | ||
80 | create mode 100644 tests/tcg/aarch64/sme-smopa-1.c | ||
81 | create mode 100644 tests/tcg/aarch64/sme-smopa-2.c | ||
78 | 82 | ||
79 | include/hw/i2c/arm_sbcon_i2c.h | 35 ++ | ||
80 | target/arm/cpu.h | 2 +- | ||
81 | target/arm/kvm_arm.h | 21 +- | ||
82 | target/arm/translate.h | 8 +- | ||
83 | target/arm/neon-dp.decode | 106 ++++ | ||
84 | hw/acpi/generic_event_device.c | 29 + | ||
85 | hw/arm/mps2-tz.c | 23 +- | ||
86 | hw/arm/mps2.c | 65 ++- | ||
87 | hw/arm/realview.c | 3 +- | ||
88 | hw/arm/versatilepb.c | 3 +- | ||
89 | hw/arm/vexpress.c | 3 +- | ||
90 | hw/arm/virt.c | 63 +- | ||
91 | hw/i2c/versatile_i2c.c | 38 +- | ||
92 | hw/watchdog/cmsdk-apb-watchdog.c | 1 + | ||
93 | target/arm/cpu.c | 2 +- | ||
94 | target/arm/cpu64.c | 10 +- | ||
95 | target/arm/kvm.c | 4 +- | ||
96 | target/arm/kvm64.c | 14 +- | ||
97 | target/arm/translate-a64.c | 20 +- | ||
98 | target/arm/translate-neon.inc.c | 1191 +++++++++++++++++++++++++++++++++++++- | ||
99 | target/arm/translate-vfp.inc.c | 7 +- | ||
100 | target/arm/translate.c | 1064 +--------------------------------- | ||
101 | tests/qtest/arm-cpu-features.c | 38 +- | ||
102 | util/oslib-posix.c | 15 + | ||
103 | MAINTAINERS | 1 + | ||
104 | hw/arm/Kconfig | 8 +- | ||
105 | hw/watchdog/trace-events | 1 + | ||
106 | 27 files changed, 1624 insertions(+), 1151 deletions(-) | ||
107 | create mode 100644 include/hw/i2c/arm_sbcon_i2c.h | ||
108 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Andrew Jones <drjones@redhat.com> | ||
2 | 1 | ||
3 | Cc: Cornelia Huck <cohuck@redhat.com> | ||
4 | Signed-off-by: Andrew Jones <drjones@redhat.com> | ||
5 | Reviewed-by: Cornelia Huck <cohuck@redhat.com> | ||
6 | Message-id: 20200616140803.25515-1-drjones@redhat.com | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | --- | ||
9 | hw/arm/virt.c | 1 + | ||
10 | 1 file changed, 1 insertion(+) | ||
11 | |||
12 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/hw/arm/virt.c | ||
15 | +++ b/hw/arm/virt.c | ||
16 | @@ -XXX,XX +XXX,XX @@ DEFINE_VIRT_MACHINE_AS_LATEST(5, 1) | ||
17 | static void virt_machine_5_0_options(MachineClass *mc) | ||
18 | { | ||
19 | virt_machine_5_1_options(mc); | ||
20 | + compat_props_add(mc->compat_props, hw_compat_5_0, hw_compat_5_0_len); | ||
21 | } | ||
22 | DEFINE_VIRT_MACHINE(5, 0) | ||
23 | |||
24 | -- | ||
25 | 2.20.1 | ||
26 | |||
27 | diff view generated by jsdifflib |
1 | Since commit ba3e7926691ed3 it has been unnecessary for target code | 1 | cpu.h has a lot of #defines relating to CPU register fields. |
---|---|---|---|
2 | to call gen_io_end() after an IO instruction in icount mode; it is | 2 | Most of these aren't actually used outside target/arm code, |
3 | sufficient to call gen_io_start() before it and to force the end of | 3 | so there's no point in cluttering up the cpu.h file with them. |
4 | the TB. | 4 | Move some easy ones to internals.h. |
5 | |||
6 | Many now-unnecessary calls to gen_io_end() were removed in commit | ||
7 | 9e9b10c6491153b, but some were missed or accidentally added later. | ||
8 | Remove unneeded calls from the arm target: | ||
9 | |||
10 | * the call in the handling of exception-return-via-LDM is | ||
11 | unnecessary, and the code is already forcing end-of-TB | ||
12 | * the call in the VFP access check code is more complicated: | ||
13 | we weren't ending the TB, so we need to add the code to | ||
14 | force that by setting DISAS_UPDATE | ||
15 | * the doc comment for ARM_CP_IO doesn't need to mention | ||
16 | gen_io_end() any more | ||
17 | 5 | ||
18 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
19 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | 7 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
20 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
21 | Reviewed-by: Pavel Dovgalyuk <Pavel.Dovgaluk@ispras.ru> | 9 | Message-id: 20240301183219.2424889-2-peter.maydell@linaro.org |
22 | Message-id: 20200619170324.12093-1-peter.maydell@linaro.org | ||
23 | --- | 10 | --- |
24 | target/arm/cpu.h | 2 +- | 11 | target/arm/cpu.h | 128 ----------------------------------------- |
25 | target/arm/translate-vfp.inc.c | 7 +++---- | 12 | target/arm/internals.h | 128 +++++++++++++++++++++++++++++++++++++++++ |
26 | target/arm/translate.c | 3 --- | 13 | 2 files changed, 128 insertions(+), 128 deletions(-) |
27 | 3 files changed, 4 insertions(+), 8 deletions(-) | ||
28 | 14 | ||
29 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 15 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
30 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
31 | --- a/target/arm/cpu.h | 17 | --- a/target/arm/cpu.h |
32 | +++ b/target/arm/cpu.h | 18 | +++ b/target/arm/cpu.h |
33 | @@ -XXX,XX +XXX,XX @@ static inline uint64_t cpreg_to_kvm_id(uint32_t cpregid) | 19 | @@ -XXX,XX +XXX,XX @@ typedef struct ARMGenericTimer { |
34 | * migration or KVM state synchronization. (Typically this is for "registers" | 20 | uint64_t ctl; /* Timer Control register */ |
35 | * which are actually used as instructions for cache maintenance and so on.) | 21 | } ARMGenericTimer; |
36 | * IO indicates that this register does I/O and therefore its accesses | 22 | |
37 | - * need to be surrounded by gen_io_start()/gen_io_end(). In particular, | 23 | -#define VTCR_NSW (1u << 29) |
38 | + * need to be marked with gen_io_start() and also end the TB. In particular, | 24 | -#define VTCR_NSA (1u << 30) |
39 | * registers which implement clocks or timers require this. | 25 | -#define VSTCR_SW VTCR_NSW |
40 | * RAISES_EXC is for when the read or write hook might raise an exception; | 26 | -#define VSTCR_SA VTCR_NSA |
41 | * the generated code will synchronize the CPU state before calling the hook | 27 | - |
42 | diff --git a/target/arm/translate-vfp.inc.c b/target/arm/translate-vfp.inc.c | 28 | /* Define a maximum sized vector register. |
29 | * For 32-bit, this is a 128-bit NEON/AdvSIMD register. | ||
30 | * For 64-bit, this is a 2048-bit SVE register. | ||
31 | @@ -XXX,XX +XXX,XX @@ void pmu_init(ARMCPU *cpu); | ||
32 | #define SCTLR_SPINTMASK (1ULL << 62) /* FEAT_NMI */ | ||
33 | #define SCTLR_TIDCP (1ULL << 63) /* FEAT_TIDCP1 */ | ||
34 | |||
35 | -/* Bit definitions for CPACR (AArch32 only) */ | ||
36 | -FIELD(CPACR, CP10, 20, 2) | ||
37 | -FIELD(CPACR, CP11, 22, 2) | ||
38 | -FIELD(CPACR, TRCDIS, 28, 1) /* matches CPACR_EL1.TTA */ | ||
39 | -FIELD(CPACR, D32DIS, 30, 1) /* up to v7; RAZ in v8 */ | ||
40 | -FIELD(CPACR, ASEDIS, 31, 1) | ||
41 | - | ||
42 | -/* Bit definitions for CPACR_EL1 (AArch64 only) */ | ||
43 | -FIELD(CPACR_EL1, ZEN, 16, 2) | ||
44 | -FIELD(CPACR_EL1, FPEN, 20, 2) | ||
45 | -FIELD(CPACR_EL1, SMEN, 24, 2) | ||
46 | -FIELD(CPACR_EL1, TTA, 28, 1) /* matches CPACR.TRCDIS */ | ||
47 | - | ||
48 | -/* Bit definitions for HCPTR (AArch32 only) */ | ||
49 | -FIELD(HCPTR, TCP10, 10, 1) | ||
50 | -FIELD(HCPTR, TCP11, 11, 1) | ||
51 | -FIELD(HCPTR, TASE, 15, 1) | ||
52 | -FIELD(HCPTR, TTA, 20, 1) | ||
53 | -FIELD(HCPTR, TAM, 30, 1) /* matches CPTR_EL2.TAM */ | ||
54 | -FIELD(HCPTR, TCPAC, 31, 1) /* matches CPTR_EL2.TCPAC */ | ||
55 | - | ||
56 | -/* Bit definitions for CPTR_EL2 (AArch64 only) */ | ||
57 | -FIELD(CPTR_EL2, TZ, 8, 1) /* !E2H */ | ||
58 | -FIELD(CPTR_EL2, TFP, 10, 1) /* !E2H, matches HCPTR.TCP10 */ | ||
59 | -FIELD(CPTR_EL2, TSM, 12, 1) /* !E2H */ | ||
60 | -FIELD(CPTR_EL2, ZEN, 16, 2) /* E2H */ | ||
61 | -FIELD(CPTR_EL2, FPEN, 20, 2) /* E2H */ | ||
62 | -FIELD(CPTR_EL2, SMEN, 24, 2) /* E2H */ | ||
63 | -FIELD(CPTR_EL2, TTA, 28, 1) | ||
64 | -FIELD(CPTR_EL2, TAM, 30, 1) /* matches HCPTR.TAM */ | ||
65 | -FIELD(CPTR_EL2, TCPAC, 31, 1) /* matches HCPTR.TCPAC */ | ||
66 | - | ||
67 | -/* Bit definitions for CPTR_EL3 (AArch64 only) */ | ||
68 | -FIELD(CPTR_EL3, EZ, 8, 1) | ||
69 | -FIELD(CPTR_EL3, TFP, 10, 1) | ||
70 | -FIELD(CPTR_EL3, ESM, 12, 1) | ||
71 | -FIELD(CPTR_EL3, TTA, 20, 1) | ||
72 | -FIELD(CPTR_EL3, TAM, 30, 1) | ||
73 | -FIELD(CPTR_EL3, TCPAC, 31, 1) | ||
74 | - | ||
75 | -#define MDCR_MTPME (1U << 28) | ||
76 | -#define MDCR_TDCC (1U << 27) | ||
77 | -#define MDCR_HLP (1U << 26) /* MDCR_EL2 */ | ||
78 | -#define MDCR_SCCD (1U << 23) /* MDCR_EL3 */ | ||
79 | -#define MDCR_HCCD (1U << 23) /* MDCR_EL2 */ | ||
80 | -#define MDCR_EPMAD (1U << 21) | ||
81 | -#define MDCR_EDAD (1U << 20) | ||
82 | -#define MDCR_TTRF (1U << 19) | ||
83 | -#define MDCR_STE (1U << 18) /* MDCR_EL3 */ | ||
84 | -#define MDCR_SPME (1U << 17) /* MDCR_EL3 */ | ||
85 | -#define MDCR_HPMD (1U << 17) /* MDCR_EL2 */ | ||
86 | -#define MDCR_SDD (1U << 16) | ||
87 | -#define MDCR_SPD (3U << 14) | ||
88 | -#define MDCR_TDRA (1U << 11) | ||
89 | -#define MDCR_TDOSA (1U << 10) | ||
90 | -#define MDCR_TDA (1U << 9) | ||
91 | -#define MDCR_TDE (1U << 8) | ||
92 | -#define MDCR_HPME (1U << 7) | ||
93 | -#define MDCR_TPM (1U << 6) | ||
94 | -#define MDCR_TPMCR (1U << 5) | ||
95 | -#define MDCR_HPMN (0x1fU) | ||
96 | - | ||
97 | -/* Not all of the MDCR_EL3 bits are present in the 32-bit SDCR */ | ||
98 | -#define SDCR_VALID_MASK (MDCR_MTPME | MDCR_TDCC | MDCR_SCCD | \ | ||
99 | - MDCR_EPMAD | MDCR_EDAD | MDCR_TTRF | \ | ||
100 | - MDCR_STE | MDCR_SPME | MDCR_SPD) | ||
101 | - | ||
102 | #define CPSR_M (0x1fU) | ||
103 | #define CPSR_T (1U << 5) | ||
104 | #define CPSR_F (1U << 6) | ||
105 | @@ -XXX,XX +XXX,XX @@ FIELD(CPTR_EL3, TCPAC, 31, 1) | ||
106 | #define XPSR_NZCV CPSR_NZCV | ||
107 | #define XPSR_IT CPSR_IT | ||
108 | |||
109 | -#define TTBCR_N (7U << 0) /* TTBCR.EAE==0 */ | ||
110 | -#define TTBCR_T0SZ (7U << 0) /* TTBCR.EAE==1 */ | ||
111 | -#define TTBCR_PD0 (1U << 4) | ||
112 | -#define TTBCR_PD1 (1U << 5) | ||
113 | -#define TTBCR_EPD0 (1U << 7) | ||
114 | -#define TTBCR_IRGN0 (3U << 8) | ||
115 | -#define TTBCR_ORGN0 (3U << 10) | ||
116 | -#define TTBCR_SH0 (3U << 12) | ||
117 | -#define TTBCR_T1SZ (3U << 16) | ||
118 | -#define TTBCR_A1 (1U << 22) | ||
119 | -#define TTBCR_EPD1 (1U << 23) | ||
120 | -#define TTBCR_IRGN1 (3U << 24) | ||
121 | -#define TTBCR_ORGN1 (3U << 26) | ||
122 | -#define TTBCR_SH1 (1U << 28) | ||
123 | -#define TTBCR_EAE (1U << 31) | ||
124 | - | ||
125 | -FIELD(VTCR, T0SZ, 0, 6) | ||
126 | -FIELD(VTCR, SL0, 6, 2) | ||
127 | -FIELD(VTCR, IRGN0, 8, 2) | ||
128 | -FIELD(VTCR, ORGN0, 10, 2) | ||
129 | -FIELD(VTCR, SH0, 12, 2) | ||
130 | -FIELD(VTCR, TG0, 14, 2) | ||
131 | -FIELD(VTCR, PS, 16, 3) | ||
132 | -FIELD(VTCR, VS, 19, 1) | ||
133 | -FIELD(VTCR, HA, 21, 1) | ||
134 | -FIELD(VTCR, HD, 22, 1) | ||
135 | -FIELD(VTCR, HWU59, 25, 1) | ||
136 | -FIELD(VTCR, HWU60, 26, 1) | ||
137 | -FIELD(VTCR, HWU61, 27, 1) | ||
138 | -FIELD(VTCR, HWU62, 28, 1) | ||
139 | -FIELD(VTCR, NSW, 29, 1) | ||
140 | -FIELD(VTCR, NSA, 30, 1) | ||
141 | -FIELD(VTCR, DS, 32, 1) | ||
142 | -FIELD(VTCR, SL2, 33, 1) | ||
143 | - | ||
144 | /* Bit definitions for ARMv8 SPSR (PSTATE) format. | ||
145 | * Only these are valid when in AArch64 mode; in | ||
146 | * AArch32 mode SPSRs are basically CPSR-format. | ||
147 | @@ -XXX,XX +XXX,XX @@ static inline void xpsr_write(CPUARMState *env, uint32_t val, uint32_t mask) | ||
148 | #define HCR_TWEDEN (1ULL << 59) | ||
149 | #define HCR_TWEDEL MAKE_64BIT_MASK(60, 4) | ||
150 | |||
151 | -#define HCRX_ENAS0 (1ULL << 0) | ||
152 | -#define HCRX_ENALS (1ULL << 1) | ||
153 | -#define HCRX_ENASR (1ULL << 2) | ||
154 | -#define HCRX_FNXS (1ULL << 3) | ||
155 | -#define HCRX_FGTNXS (1ULL << 4) | ||
156 | -#define HCRX_SMPME (1ULL << 5) | ||
157 | -#define HCRX_TALLINT (1ULL << 6) | ||
158 | -#define HCRX_VINMI (1ULL << 7) | ||
159 | -#define HCRX_VFNMI (1ULL << 8) | ||
160 | -#define HCRX_CMOW (1ULL << 9) | ||
161 | -#define HCRX_MCE2 (1ULL << 10) | ||
162 | -#define HCRX_MSCEN (1ULL << 11) | ||
163 | - | ||
164 | -#define HPFAR_NS (1ULL << 63) | ||
165 | - | ||
166 | #define SCR_NS (1ULL << 0) | ||
167 | #define SCR_IRQ (1ULL << 1) | ||
168 | #define SCR_FIQ (1ULL << 2) | ||
169 | @@ -XXX,XX +XXX,XX @@ static inline void xpsr_write(CPUARMState *env, uint32_t val, uint32_t mask) | ||
170 | #define SCR_GPF (1ULL << 48) | ||
171 | #define SCR_NSE (1ULL << 62) | ||
172 | |||
173 | -#define HSTR_TTEE (1 << 16) | ||
174 | -#define HSTR_TJDBX (1 << 17) | ||
175 | - | ||
176 | -#define CNTHCTL_CNTVMASK (1 << 18) | ||
177 | -#define CNTHCTL_CNTPMASK (1 << 19) | ||
178 | - | ||
179 | /* Return the current FPSCR value. */ | ||
180 | uint32_t vfp_get_fpscr(CPUARMState *env); | ||
181 | void vfp_set_fpscr(CPUARMState *env, uint32_t val); | ||
182 | diff --git a/target/arm/internals.h b/target/arm/internals.h | ||
43 | index XXXXXXX..XXXXXXX 100644 | 183 | index XXXXXXX..XXXXXXX 100644 |
44 | --- a/target/arm/translate-vfp.inc.c | 184 | --- a/target/arm/internals.h |
45 | +++ b/target/arm/translate-vfp.inc.c | 185 | +++ b/target/arm/internals.h |
46 | @@ -XXX,XX +XXX,XX @@ static bool full_vfp_access_check(DisasContext *s, bool ignore_vfp_enabled) | 186 | @@ -XXX,XX +XXX,XX @@ FIELD(DBGWCR, WT, 20, 1) |
47 | if (s->v7m_lspact) { | 187 | FIELD(DBGWCR, MASK, 24, 5) |
48 | /* | 188 | FIELD(DBGWCR, SSCE, 29, 1) |
49 | * Lazy state saving affects external memory and also the NVIC, | 189 | |
50 | - * so we must mark it as an IO operation for icount. | 190 | +#define VTCR_NSW (1u << 29) |
51 | + * so we must mark it as an IO operation for icount (and cause | 191 | +#define VTCR_NSA (1u << 30) |
52 | + * this to be the last insn in the TB). | 192 | +#define VSTCR_SW VTCR_NSW |
53 | */ | 193 | +#define VSTCR_SA VTCR_NSA |
54 | if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) { | 194 | + |
55 | + s->base.is_jmp = DISAS_UPDATE; | 195 | +/* Bit definitions for CPACR (AArch32 only) */ |
56 | gen_io_start(); | 196 | +FIELD(CPACR, CP10, 20, 2) |
57 | } | 197 | +FIELD(CPACR, CP11, 22, 2) |
58 | gen_helper_v7m_preserve_fp_state(cpu_env); | 198 | +FIELD(CPACR, TRCDIS, 28, 1) /* matches CPACR_EL1.TTA */ |
59 | - if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) { | 199 | +FIELD(CPACR, D32DIS, 30, 1) /* up to v7; RAZ in v8 */ |
60 | - gen_io_end(); | 200 | +FIELD(CPACR, ASEDIS, 31, 1) |
61 | - } | 201 | + |
62 | /* | 202 | +/* Bit definitions for CPACR_EL1 (AArch64 only) */ |
63 | * If the preserve_fp_state helper doesn't throw an exception | 203 | +FIELD(CPACR_EL1, ZEN, 16, 2) |
64 | * then it will clear LSPACT; we don't need to repeat this for | 204 | +FIELD(CPACR_EL1, FPEN, 20, 2) |
65 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 205 | +FIELD(CPACR_EL1, SMEN, 24, 2) |
66 | index XXXXXXX..XXXXXXX 100644 | 206 | +FIELD(CPACR_EL1, TTA, 28, 1) /* matches CPACR.TRCDIS */ |
67 | --- a/target/arm/translate.c | 207 | + |
68 | +++ b/target/arm/translate.c | 208 | +/* Bit definitions for HCPTR (AArch32 only) */ |
69 | @@ -XXX,XX +XXX,XX @@ static bool do_ldm(DisasContext *s, arg_ldst_block *a, int min_n) | 209 | +FIELD(HCPTR, TCP10, 10, 1) |
70 | gen_io_start(); | 210 | +FIELD(HCPTR, TCP11, 11, 1) |
71 | } | 211 | +FIELD(HCPTR, TASE, 15, 1) |
72 | gen_helper_cpsr_write_eret(cpu_env, tmp); | 212 | +FIELD(HCPTR, TTA, 20, 1) |
73 | - if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) { | 213 | +FIELD(HCPTR, TAM, 30, 1) /* matches CPTR_EL2.TAM */ |
74 | - gen_io_end(); | 214 | +FIELD(HCPTR, TCPAC, 31, 1) /* matches CPTR_EL2.TCPAC */ |
75 | - } | 215 | + |
76 | tcg_temp_free_i32(tmp); | 216 | +/* Bit definitions for CPTR_EL2 (AArch64 only) */ |
77 | /* Must exit loop to check un-masked IRQs */ | 217 | +FIELD(CPTR_EL2, TZ, 8, 1) /* !E2H */ |
78 | s->base.is_jmp = DISAS_EXIT; | 218 | +FIELD(CPTR_EL2, TFP, 10, 1) /* !E2H, matches HCPTR.TCP10 */ |
219 | +FIELD(CPTR_EL2, TSM, 12, 1) /* !E2H */ | ||
220 | +FIELD(CPTR_EL2, ZEN, 16, 2) /* E2H */ | ||
221 | +FIELD(CPTR_EL2, FPEN, 20, 2) /* E2H */ | ||
222 | +FIELD(CPTR_EL2, SMEN, 24, 2) /* E2H */ | ||
223 | +FIELD(CPTR_EL2, TTA, 28, 1) | ||
224 | +FIELD(CPTR_EL2, TAM, 30, 1) /* matches HCPTR.TAM */ | ||
225 | +FIELD(CPTR_EL2, TCPAC, 31, 1) /* matches HCPTR.TCPAC */ | ||
226 | + | ||
227 | +/* Bit definitions for CPTR_EL3 (AArch64 only) */ | ||
228 | +FIELD(CPTR_EL3, EZ, 8, 1) | ||
229 | +FIELD(CPTR_EL3, TFP, 10, 1) | ||
230 | +FIELD(CPTR_EL3, ESM, 12, 1) | ||
231 | +FIELD(CPTR_EL3, TTA, 20, 1) | ||
232 | +FIELD(CPTR_EL3, TAM, 30, 1) | ||
233 | +FIELD(CPTR_EL3, TCPAC, 31, 1) | ||
234 | + | ||
235 | +#define MDCR_MTPME (1U << 28) | ||
236 | +#define MDCR_TDCC (1U << 27) | ||
237 | +#define MDCR_HLP (1U << 26) /* MDCR_EL2 */ | ||
238 | +#define MDCR_SCCD (1U << 23) /* MDCR_EL3 */ | ||
239 | +#define MDCR_HCCD (1U << 23) /* MDCR_EL2 */ | ||
240 | +#define MDCR_EPMAD (1U << 21) | ||
241 | +#define MDCR_EDAD (1U << 20) | ||
242 | +#define MDCR_TTRF (1U << 19) | ||
243 | +#define MDCR_STE (1U << 18) /* MDCR_EL3 */ | ||
244 | +#define MDCR_SPME (1U << 17) /* MDCR_EL3 */ | ||
245 | +#define MDCR_HPMD (1U << 17) /* MDCR_EL2 */ | ||
246 | +#define MDCR_SDD (1U << 16) | ||
247 | +#define MDCR_SPD (3U << 14) | ||
248 | +#define MDCR_TDRA (1U << 11) | ||
249 | +#define MDCR_TDOSA (1U << 10) | ||
250 | +#define MDCR_TDA (1U << 9) | ||
251 | +#define MDCR_TDE (1U << 8) | ||
252 | +#define MDCR_HPME (1U << 7) | ||
253 | +#define MDCR_TPM (1U << 6) | ||
254 | +#define MDCR_TPMCR (1U << 5) | ||
255 | +#define MDCR_HPMN (0x1fU) | ||
256 | + | ||
257 | +/* Not all of the MDCR_EL3 bits are present in the 32-bit SDCR */ | ||
258 | +#define SDCR_VALID_MASK (MDCR_MTPME | MDCR_TDCC | MDCR_SCCD | \ | ||
259 | + MDCR_EPMAD | MDCR_EDAD | MDCR_TTRF | \ | ||
260 | + MDCR_STE | MDCR_SPME | MDCR_SPD) | ||
261 | + | ||
262 | +#define TTBCR_N (7U << 0) /* TTBCR.EAE==0 */ | ||
263 | +#define TTBCR_T0SZ (7U << 0) /* TTBCR.EAE==1 */ | ||
264 | +#define TTBCR_PD0 (1U << 4) | ||
265 | +#define TTBCR_PD1 (1U << 5) | ||
266 | +#define TTBCR_EPD0 (1U << 7) | ||
267 | +#define TTBCR_IRGN0 (3U << 8) | ||
268 | +#define TTBCR_ORGN0 (3U << 10) | ||
269 | +#define TTBCR_SH0 (3U << 12) | ||
270 | +#define TTBCR_T1SZ (3U << 16) | ||
271 | +#define TTBCR_A1 (1U << 22) | ||
272 | +#define TTBCR_EPD1 (1U << 23) | ||
273 | +#define TTBCR_IRGN1 (3U << 24) | ||
274 | +#define TTBCR_ORGN1 (3U << 26) | ||
275 | +#define TTBCR_SH1 (1U << 28) | ||
276 | +#define TTBCR_EAE (1U << 31) | ||
277 | + | ||
278 | +FIELD(VTCR, T0SZ, 0, 6) | ||
279 | +FIELD(VTCR, SL0, 6, 2) | ||
280 | +FIELD(VTCR, IRGN0, 8, 2) | ||
281 | +FIELD(VTCR, ORGN0, 10, 2) | ||
282 | +FIELD(VTCR, SH0, 12, 2) | ||
283 | +FIELD(VTCR, TG0, 14, 2) | ||
284 | +FIELD(VTCR, PS, 16, 3) | ||
285 | +FIELD(VTCR, VS, 19, 1) | ||
286 | +FIELD(VTCR, HA, 21, 1) | ||
287 | +FIELD(VTCR, HD, 22, 1) | ||
288 | +FIELD(VTCR, HWU59, 25, 1) | ||
289 | +FIELD(VTCR, HWU60, 26, 1) | ||
290 | +FIELD(VTCR, HWU61, 27, 1) | ||
291 | +FIELD(VTCR, HWU62, 28, 1) | ||
292 | +FIELD(VTCR, NSW, 29, 1) | ||
293 | +FIELD(VTCR, NSA, 30, 1) | ||
294 | +FIELD(VTCR, DS, 32, 1) | ||
295 | +FIELD(VTCR, SL2, 33, 1) | ||
296 | + | ||
297 | +#define HCRX_ENAS0 (1ULL << 0) | ||
298 | +#define HCRX_ENALS (1ULL << 1) | ||
299 | +#define HCRX_ENASR (1ULL << 2) | ||
300 | +#define HCRX_FNXS (1ULL << 3) | ||
301 | +#define HCRX_FGTNXS (1ULL << 4) | ||
302 | +#define HCRX_SMPME (1ULL << 5) | ||
303 | +#define HCRX_TALLINT (1ULL << 6) | ||
304 | +#define HCRX_VINMI (1ULL << 7) | ||
305 | +#define HCRX_VFNMI (1ULL << 8) | ||
306 | +#define HCRX_CMOW (1ULL << 9) | ||
307 | +#define HCRX_MCE2 (1ULL << 10) | ||
308 | +#define HCRX_MSCEN (1ULL << 11) | ||
309 | + | ||
310 | +#define HPFAR_NS (1ULL << 63) | ||
311 | + | ||
312 | +#define HSTR_TTEE (1 << 16) | ||
313 | +#define HSTR_TJDBX (1 << 17) | ||
314 | + | ||
315 | +#define CNTHCTL_CNTVMASK (1 << 18) | ||
316 | +#define CNTHCTL_CNTPMASK (1 << 19) | ||
317 | + | ||
318 | /* We use a few fake FSR values for internal purposes in M profile. | ||
319 | * M profile cores don't have A/R format FSRs, but currently our | ||
320 | * get_phys_addr() code assumes A/R profile and reports failures via | ||
79 | -- | 321 | -- |
80 | 2.20.1 | 322 | 2.34.1 |
81 | 323 | ||
82 | 324 | diff view generated by jsdifflib |
1 | Convert the Neon insns in the 2-reg-misc group which are | 1 | The timer _EL02 registers should UNDEF for invalid accesses from EL2 |
---|---|---|---|
2 | VCVT between f32 and f16 to decodetree. | 2 | or EL3 when HCR_EL2.E2H == 0, not take a cp access trap. We were |
3 | delivering the exception to EL2 with the wrong syndrome. | ||
3 | 4 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
6 | Message-id: 20200616170844.13318-7-peter.maydell@linaro.org | 7 | Message-id: 20240301183219.2424889-3-peter.maydell@linaro.org |
7 | --- | 8 | --- |
8 | target/arm/neon-dp.decode | 3 ++ | 9 | target/arm/helper.c | 2 +- |
9 | target/arm/translate-neon.inc.c | 96 +++++++++++++++++++++++++++++++++ | 10 | 1 file changed, 1 insertion(+), 1 deletion(-) |
10 | target/arm/translate.c | 65 ++-------------------- | ||
11 | 3 files changed, 102 insertions(+), 62 deletions(-) | ||
12 | 11 | ||
13 | diff --git a/target/arm/neon-dp.decode b/target/arm/neon-dp.decode | 12 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
14 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/neon-dp.decode | 14 | --- a/target/arm/helper.c |
16 | +++ b/target/arm/neon-dp.decode | 15 | +++ b/target/arm/helper.c |
17 | @@ -XXX,XX +XXX,XX @@ Vimm_1r 1111 001 . 1 . 000 ... .... cmode:4 0 . op:1 1 .... @1reg_imm | 16 | @@ -XXX,XX +XXX,XX @@ static CPAccessResult e2h_access(CPUARMState *env, const ARMCPRegInfo *ri, |
18 | VQMOVN_U 1111 001 11 . 11 .. 10 .... 0 0101 1 . 0 .... @2misc_q0 | 17 | return CP_ACCESS_OK; |
19 | 18 | } | |
20 | VSHLL 1111 001 11 . 11 .. 10 .... 0 0110 0 . 0 .... @2misc_q0 | 19 | if (!(arm_hcr_el2_eff(env) & HCR_E2H)) { |
21 | + | 20 | - return CP_ACCESS_TRAP; |
22 | + VCVT_F16_F32 1111 001 11 . 11 .. 10 .... 0 1100 0 . 0 .... @2misc_q0 | 21 | + return CP_ACCESS_TRAP_UNCATEGORIZED; |
23 | + VCVT_F32_F16 1111 001 11 . 11 .. 10 .... 0 1110 0 . 0 .... @2misc_q0 | 22 | } |
24 | ] | 23 | return CP_ACCESS_OK; |
25 | |||
26 | # Subgroup for size != 0b11 | ||
27 | diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c | ||
28 | index XXXXXXX..XXXXXXX 100644 | ||
29 | --- a/target/arm/translate-neon.inc.c | ||
30 | +++ b/target/arm/translate-neon.inc.c | ||
31 | @@ -XXX,XX +XXX,XX @@ static bool trans_VSHLL(DisasContext *s, arg_2misc *a) | ||
32 | tcg_temp_free_i32(rm1); | ||
33 | return true; | ||
34 | } | 24 | } |
35 | + | ||
36 | +static bool trans_VCVT_F16_F32(DisasContext *s, arg_2misc *a) | ||
37 | +{ | ||
38 | + TCGv_ptr fpst; | ||
39 | + TCGv_i32 ahp, tmp, tmp2, tmp3; | ||
40 | + | ||
41 | + if (!arm_dc_feature(s, ARM_FEATURE_NEON) || | ||
42 | + !dc_isar_feature(aa32_fp16_spconv, s)) { | ||
43 | + return false; | ||
44 | + } | ||
45 | + | ||
46 | + /* UNDEF accesses to D16-D31 if they don't exist. */ | ||
47 | + if (!dc_isar_feature(aa32_simd_r32, s) && | ||
48 | + ((a->vd | a->vm) & 0x10)) { | ||
49 | + return false; | ||
50 | + } | ||
51 | + | ||
52 | + if ((a->vm & 1) || (a->size != 1)) { | ||
53 | + return false; | ||
54 | + } | ||
55 | + | ||
56 | + if (!vfp_access_check(s)) { | ||
57 | + return true; | ||
58 | + } | ||
59 | + | ||
60 | + fpst = get_fpstatus_ptr(true); | ||
61 | + ahp = get_ahp_flag(); | ||
62 | + tmp = neon_load_reg(a->vm, 0); | ||
63 | + gen_helper_vfp_fcvt_f32_to_f16(tmp, tmp, fpst, ahp); | ||
64 | + tmp2 = neon_load_reg(a->vm, 1); | ||
65 | + gen_helper_vfp_fcvt_f32_to_f16(tmp2, tmp2, fpst, ahp); | ||
66 | + tcg_gen_shli_i32(tmp2, tmp2, 16); | ||
67 | + tcg_gen_or_i32(tmp2, tmp2, tmp); | ||
68 | + tcg_temp_free_i32(tmp); | ||
69 | + tmp = neon_load_reg(a->vm, 2); | ||
70 | + gen_helper_vfp_fcvt_f32_to_f16(tmp, tmp, fpst, ahp); | ||
71 | + tmp3 = neon_load_reg(a->vm, 3); | ||
72 | + neon_store_reg(a->vd, 0, tmp2); | ||
73 | + gen_helper_vfp_fcvt_f32_to_f16(tmp3, tmp3, fpst, ahp); | ||
74 | + tcg_gen_shli_i32(tmp3, tmp3, 16); | ||
75 | + tcg_gen_or_i32(tmp3, tmp3, tmp); | ||
76 | + neon_store_reg(a->vd, 1, tmp3); | ||
77 | + tcg_temp_free_i32(tmp); | ||
78 | + tcg_temp_free_i32(ahp); | ||
79 | + tcg_temp_free_ptr(fpst); | ||
80 | + | ||
81 | + return true; | ||
82 | +} | ||
83 | + | ||
84 | +static bool trans_VCVT_F32_F16(DisasContext *s, arg_2misc *a) | ||
85 | +{ | ||
86 | + TCGv_ptr fpst; | ||
87 | + TCGv_i32 ahp, tmp, tmp2, tmp3; | ||
88 | + | ||
89 | + if (!arm_dc_feature(s, ARM_FEATURE_NEON) || | ||
90 | + !dc_isar_feature(aa32_fp16_spconv, s)) { | ||
91 | + return false; | ||
92 | + } | ||
93 | + | ||
94 | + /* UNDEF accesses to D16-D31 if they don't exist. */ | ||
95 | + if (!dc_isar_feature(aa32_simd_r32, s) && | ||
96 | + ((a->vd | a->vm) & 0x10)) { | ||
97 | + return false; | ||
98 | + } | ||
99 | + | ||
100 | + if ((a->vd & 1) || (a->size != 1)) { | ||
101 | + return false; | ||
102 | + } | ||
103 | + | ||
104 | + if (!vfp_access_check(s)) { | ||
105 | + return true; | ||
106 | + } | ||
107 | + | ||
108 | + fpst = get_fpstatus_ptr(true); | ||
109 | + ahp = get_ahp_flag(); | ||
110 | + tmp3 = tcg_temp_new_i32(); | ||
111 | + tmp = neon_load_reg(a->vm, 0); | ||
112 | + tmp2 = neon_load_reg(a->vm, 1); | ||
113 | + tcg_gen_ext16u_i32(tmp3, tmp); | ||
114 | + gen_helper_vfp_fcvt_f16_to_f32(tmp3, tmp3, fpst, ahp); | ||
115 | + neon_store_reg(a->vd, 0, tmp3); | ||
116 | + tcg_gen_shri_i32(tmp, tmp, 16); | ||
117 | + gen_helper_vfp_fcvt_f16_to_f32(tmp, tmp, fpst, ahp); | ||
118 | + neon_store_reg(a->vd, 1, tmp); | ||
119 | + tmp3 = tcg_temp_new_i32(); | ||
120 | + tcg_gen_ext16u_i32(tmp3, tmp2); | ||
121 | + gen_helper_vfp_fcvt_f16_to_f32(tmp3, tmp3, fpst, ahp); | ||
122 | + neon_store_reg(a->vd, 2, tmp3); | ||
123 | + tcg_gen_shri_i32(tmp2, tmp2, 16); | ||
124 | + gen_helper_vfp_fcvt_f16_to_f32(tmp2, tmp2, fpst, ahp); | ||
125 | + neon_store_reg(a->vd, 3, tmp2); | ||
126 | + tcg_temp_free_i32(ahp); | ||
127 | + tcg_temp_free_ptr(fpst); | ||
128 | + | ||
129 | + return true; | ||
130 | +} | ||
131 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
132 | index XXXXXXX..XXXXXXX 100644 | ||
133 | --- a/target/arm/translate.c | ||
134 | +++ b/target/arm/translate.c | ||
135 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
136 | int pass; | ||
137 | int u; | ||
138 | int vec_size; | ||
139 | - TCGv_i32 tmp, tmp2, tmp3; | ||
140 | + TCGv_i32 tmp, tmp2; | ||
141 | |||
142 | if (!arm_dc_feature(s, ARM_FEATURE_NEON)) { | ||
143 | return 1; | ||
144 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
145 | case NEON_2RM_VZIP: | ||
146 | case NEON_2RM_VMOVN: case NEON_2RM_VQMOVN: | ||
147 | case NEON_2RM_VSHLL: | ||
148 | + case NEON_2RM_VCVT_F16_F32: | ||
149 | + case NEON_2RM_VCVT_F32_F16: | ||
150 | /* handled by decodetree */ | ||
151 | return 1; | ||
152 | case NEON_2RM_VTRN: | ||
153 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
154 | goto elementwise; | ||
155 | } | ||
156 | break; | ||
157 | - case NEON_2RM_VCVT_F16_F32: | ||
158 | - { | ||
159 | - TCGv_ptr fpst; | ||
160 | - TCGv_i32 ahp; | ||
161 | - | ||
162 | - if (!dc_isar_feature(aa32_fp16_spconv, s) || | ||
163 | - q || (rm & 1)) { | ||
164 | - return 1; | ||
165 | - } | ||
166 | - fpst = get_fpstatus_ptr(true); | ||
167 | - ahp = get_ahp_flag(); | ||
168 | - tmp = neon_load_reg(rm, 0); | ||
169 | - gen_helper_vfp_fcvt_f32_to_f16(tmp, tmp, fpst, ahp); | ||
170 | - tmp2 = neon_load_reg(rm, 1); | ||
171 | - gen_helper_vfp_fcvt_f32_to_f16(tmp2, tmp2, fpst, ahp); | ||
172 | - tcg_gen_shli_i32(tmp2, tmp2, 16); | ||
173 | - tcg_gen_or_i32(tmp2, tmp2, tmp); | ||
174 | - tcg_temp_free_i32(tmp); | ||
175 | - tmp = neon_load_reg(rm, 2); | ||
176 | - gen_helper_vfp_fcvt_f32_to_f16(tmp, tmp, fpst, ahp); | ||
177 | - tmp3 = neon_load_reg(rm, 3); | ||
178 | - neon_store_reg(rd, 0, tmp2); | ||
179 | - gen_helper_vfp_fcvt_f32_to_f16(tmp3, tmp3, fpst, ahp); | ||
180 | - tcg_gen_shli_i32(tmp3, tmp3, 16); | ||
181 | - tcg_gen_or_i32(tmp3, tmp3, tmp); | ||
182 | - neon_store_reg(rd, 1, tmp3); | ||
183 | - tcg_temp_free_i32(tmp); | ||
184 | - tcg_temp_free_i32(ahp); | ||
185 | - tcg_temp_free_ptr(fpst); | ||
186 | - break; | ||
187 | - } | ||
188 | - case NEON_2RM_VCVT_F32_F16: | ||
189 | - { | ||
190 | - TCGv_ptr fpst; | ||
191 | - TCGv_i32 ahp; | ||
192 | - if (!dc_isar_feature(aa32_fp16_spconv, s) || | ||
193 | - q || (rd & 1)) { | ||
194 | - return 1; | ||
195 | - } | ||
196 | - fpst = get_fpstatus_ptr(true); | ||
197 | - ahp = get_ahp_flag(); | ||
198 | - tmp3 = tcg_temp_new_i32(); | ||
199 | - tmp = neon_load_reg(rm, 0); | ||
200 | - tmp2 = neon_load_reg(rm, 1); | ||
201 | - tcg_gen_ext16u_i32(tmp3, tmp); | ||
202 | - gen_helper_vfp_fcvt_f16_to_f32(tmp3, tmp3, fpst, ahp); | ||
203 | - neon_store_reg(rd, 0, tmp3); | ||
204 | - tcg_gen_shri_i32(tmp, tmp, 16); | ||
205 | - gen_helper_vfp_fcvt_f16_to_f32(tmp, tmp, fpst, ahp); | ||
206 | - neon_store_reg(rd, 1, tmp); | ||
207 | - tmp3 = tcg_temp_new_i32(); | ||
208 | - tcg_gen_ext16u_i32(tmp3, tmp2); | ||
209 | - gen_helper_vfp_fcvt_f16_to_f32(tmp3, tmp3, fpst, ahp); | ||
210 | - neon_store_reg(rd, 2, tmp3); | ||
211 | - tcg_gen_shri_i32(tmp2, tmp2, 16); | ||
212 | - gen_helper_vfp_fcvt_f16_to_f32(tmp2, tmp2, fpst, ahp); | ||
213 | - neon_store_reg(rd, 3, tmp2); | ||
214 | - tcg_temp_free_i32(ahp); | ||
215 | - tcg_temp_free_ptr(fpst); | ||
216 | - break; | ||
217 | - } | ||
218 | case NEON_2RM_AESE: case NEON_2RM_AESMC: | ||
219 | if (!dc_isar_feature(aa32_aes, s) || ((rm | rd) & 1)) { | ||
220 | return 1; | ||
221 | -- | 25 | -- |
222 | 2.20.1 | 26 | 2.34.1 |
223 | |||
224 | diff view generated by jsdifflib |
1 | From: Andrew Jones <drjones@redhat.com> | 1 | We prefer the FIELD macro over ad-hoc #defines for register bits; |
---|---|---|---|
2 | switch CNTHCTL to that style before we add any more bits. | ||
2 | 3 | ||
3 | Some cpu features may be enabled and disabled for all configurations | 4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | that support the feature. Let's test that. | 5 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20240301183219.2424889-4-peter.maydell@linaro.org | ||
8 | --- | ||
9 | target/arm/internals.h | 27 +++++++++++++++++++++++++-- | ||
10 | target/arm/helper.c | 9 ++++----- | ||
11 | 2 files changed, 29 insertions(+), 7 deletions(-) | ||
5 | 12 | ||
6 | A recent regression[*] inspired adding these tests. | 13 | diff --git a/target/arm/internals.h b/target/arm/internals.h |
7 | |||
8 | [*] '-cpu host,pmu=on' caused a segfault | ||
9 | |||
10 | Signed-off-by: Andrew Jones <drjones@redhat.com> | ||
11 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
12 | Message-id: 20200623090622.30365-2-philmd@redhat.com | ||
13 | Message-Id: <20200623082310.17577-1-drjones@redhat.com> | ||
14 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
16 | --- | ||
17 | tests/qtest/arm-cpu-features.c | 38 ++++++++++++++++++++++++++++++---- | ||
18 | 1 file changed, 34 insertions(+), 4 deletions(-) | ||
19 | |||
20 | diff --git a/tests/qtest/arm-cpu-features.c b/tests/qtest/arm-cpu-features.c | ||
21 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/tests/qtest/arm-cpu-features.c | 15 | --- a/target/arm/internals.h |
23 | +++ b/tests/qtest/arm-cpu-features.c | 16 | +++ b/target/arm/internals.h |
24 | @@ -XXX,XX +XXX,XX @@ static bool resp_get_feature(QDict *resp, const char *feature) | 17 | @@ -XXX,XX +XXX,XX @@ FIELD(VTCR, SL2, 33, 1) |
25 | qobject_unref(_resp); \ | 18 | #define HSTR_TTEE (1 << 16) |
26 | }) | 19 | #define HSTR_TJDBX (1 << 17) |
27 | 20 | ||
28 | -#define assert_feature(qts, cpu_type, feature, expected_value) \ | 21 | -#define CNTHCTL_CNTVMASK (1 << 18) |
29 | +#define resp_assert_feature(resp, feature, expected_value) \ | 22 | -#define CNTHCTL_CNTPMASK (1 << 19) |
30 | ({ \ | 23 | +/* |
31 | - QDict *_resp, *_props; \ | 24 | + * Depending on the value of HCR_EL2.E2H, bits 0 and 1 |
32 | + QDict *_props; \ | 25 | + * have different bit definitions, and EL1PCTEN might be |
33 | \ | 26 | + * bit 0 or bit 10. We use _E2H1 and _E2H0 suffixes to |
34 | - _resp = do_query_no_props(qts, cpu_type); \ | 27 | + * disambiguate if necessary. |
35 | g_assert(_resp); \ | 28 | + */ |
36 | g_assert(resp_has_props(_resp)); \ | 29 | +FIELD(CNTHCTL, EL0PCTEN_E2H1, 0, 1) |
37 | _props = resp_get_props(_resp); \ | 30 | +FIELD(CNTHCTL, EL0VCTEN_E2H1, 1, 1) |
38 | g_assert(qdict_get(_props, feature)); \ | 31 | +FIELD(CNTHCTL, EL1PCTEN_E2H0, 0, 1) |
39 | g_assert(qdict_get_bool(_props, feature) == (expected_value)); \ | 32 | +FIELD(CNTHCTL, EL1PCEN_E2H0, 1, 1) |
40 | +}) | 33 | +FIELD(CNTHCTL, EVNTEN, 2, 1) |
41 | + | 34 | +FIELD(CNTHCTL, EVNTDIR, 3, 1) |
42 | +#define assert_feature(qts, cpu_type, feature, expected_value) \ | 35 | +FIELD(CNTHCTL, EVNTI, 4, 4) |
43 | +({ \ | 36 | +FIELD(CNTHCTL, EL0VTEN, 8, 1) |
44 | + QDict *_resp; \ | 37 | +FIELD(CNTHCTL, EL0PTEN, 9, 1) |
45 | + \ | 38 | +FIELD(CNTHCTL, EL1PCTEN_E2H1, 10, 1) |
46 | + _resp = do_query_no_props(qts, cpu_type); \ | 39 | +FIELD(CNTHCTL, EL1PTEN, 11, 1) |
47 | + g_assert(_resp); \ | 40 | +FIELD(CNTHCTL, ECV, 12, 1) |
48 | + resp_assert_feature(_resp, feature, expected_value); \ | 41 | +FIELD(CNTHCTL, EL1TVT, 13, 1) |
49 | + qobject_unref(_resp); \ | 42 | +FIELD(CNTHCTL, EL1TVCT, 14, 1) |
50 | +}) | 43 | +FIELD(CNTHCTL, EL1NVPCT, 15, 1) |
51 | + | 44 | +FIELD(CNTHCTL, EL1NVVCT, 16, 1) |
52 | +#define assert_set_feature(qts, cpu_type, feature, value) \ | 45 | +FIELD(CNTHCTL, EVNTIS, 17, 1) |
53 | +({ \ | 46 | +FIELD(CNTHCTL, CNTVMASK, 18, 1) |
54 | + const char *_fmt = (value) ? "{ %s: true }" : "{ %s: false }"; \ | 47 | +FIELD(CNTHCTL, CNTPMASK, 19, 1) |
55 | + QDict *_resp; \ | 48 | |
56 | + \ | 49 | /* We use a few fake FSR values for internal purposes in M profile. |
57 | + _resp = do_query(qts, cpu_type, _fmt, feature); \ | 50 | * M profile cores don't have A/R format FSRs, but currently our |
58 | + g_assert(_resp); \ | 51 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
59 | + resp_assert_feature(_resp, feature, value); \ | 52 | index XXXXXXX..XXXXXXX 100644 |
60 | qobject_unref(_resp); \ | 53 | --- a/target/arm/helper.c |
61 | }) | 54 | +++ b/target/arm/helper.c |
62 | 55 | @@ -XXX,XX +XXX,XX @@ static void gt_update_irq(ARMCPU *cpu, int timeridx) | |
63 | @@ -XXX,XX +XXX,XX @@ static void test_query_cpu_model_expansion(const void *data) | 56 | * It is RES0 in Secure and NonSecure state. |
64 | assert_error(qts, "host", "The CPU type 'host' requires KVM", NULL); | 57 | */ |
65 | 58 | if ((ss == ARMSS_Root || ss == ARMSS_Realm) && | |
66 | /* Test expected feature presence/absence for some cpu types */ | 59 | - ((timeridx == GTIMER_VIRT && (cnthctl & CNTHCTL_CNTVMASK)) || |
67 | - assert_has_feature_enabled(qts, "max", "pmu"); | 60 | - (timeridx == GTIMER_PHYS && (cnthctl & CNTHCTL_CNTPMASK)))) { |
68 | assert_has_feature_enabled(qts, "cortex-a15", "pmu"); | 61 | + ((timeridx == GTIMER_VIRT && (cnthctl & R_CNTHCTL_CNTVMASK_MASK)) || |
69 | assert_has_not_feature(qts, "cortex-a15", "aarch64"); | 62 | + (timeridx == GTIMER_PHYS && (cnthctl & R_CNTHCTL_CNTPMASK_MASK)))) { |
70 | 63 | irqstate = 0; | |
71 | + /* Enabling and disabling pmu should always work. */ | ||
72 | + assert_has_feature_enabled(qts, "max", "pmu"); | ||
73 | + assert_set_feature(qts, "max", "pmu", false); | ||
74 | + assert_set_feature(qts, "max", "pmu", true); | ||
75 | + | ||
76 | assert_has_not_feature(qts, "max", "kvm-no-adjvtime"); | ||
77 | |||
78 | if (g_str_equal(qtest_get_arch(), "aarch64")) { | ||
79 | @@ -XXX,XX +XXX,XX @@ static void test_query_cpu_model_expansion_kvm(const void *data) | ||
80 | return; | ||
81 | } | 64 | } |
82 | 65 | ||
83 | + /* Enabling and disabling kvm-no-adjvtime should always work. */ | 66 | @@ -XXX,XX +XXX,XX @@ static void gt_cnthctl_write(CPUARMState *env, const ARMCPRegInfo *ri, |
84 | assert_has_feature_disabled(qts, "host", "kvm-no-adjvtime"); | 67 | { |
85 | + assert_set_feature(qts, "host", "kvm-no-adjvtime", true); | 68 | ARMCPU *cpu = env_archcpu(env); |
86 | + assert_set_feature(qts, "host", "kvm-no-adjvtime", false); | 69 | uint32_t oldval = env->cp15.cnthctl_el2; |
87 | 70 | - | |
88 | if (g_str_equal(qtest_get_arch(), "aarch64")) { | 71 | raw_write(env, ri, value); |
89 | bool kvm_supports_sve; | 72 | |
90 | @@ -XXX,XX +XXX,XX @@ static void test_query_cpu_model_expansion_kvm(const void *data) | 73 | - if ((oldval ^ value) & CNTHCTL_CNTVMASK) { |
91 | char *error; | 74 | + if ((oldval ^ value) & R_CNTHCTL_CNTVMASK_MASK) { |
92 | 75 | gt_update_irq(cpu, GTIMER_VIRT); | |
93 | assert_has_feature_enabled(qts, "host", "aarch64"); | 76 | - } else if ((oldval ^ value) & CNTHCTL_CNTPMASK) { |
94 | + | 77 | + } else if ((oldval ^ value) & R_CNTHCTL_CNTPMASK_MASK) { |
95 | + /* Enabling and disabling pmu should always work. */ | 78 | gt_update_irq(cpu, GTIMER_PHYS); |
96 | assert_has_feature_enabled(qts, "host", "pmu"); | 79 | } |
97 | + assert_set_feature(qts, "host", "pmu", false); | 80 | } |
98 | + assert_set_feature(qts, "host", "pmu", true); | ||
99 | |||
100 | assert_error(qts, "cortex-a15", | ||
101 | "We cannot guarantee the CPU type 'cortex-a15' works " | ||
102 | -- | 81 | -- |
103 | 2.20.1 | 82 | 2.34.1 |
104 | 83 | ||
105 | 84 | diff view generated by jsdifflib |
1 | Convert the VSHLL insn in the 2-reg-misc Neon group to decodetree. | 1 | Don't allow the guest to write CNTHCTL_EL2 bits which don't exist. |
---|---|---|---|
2 | This is not strictly architecturally required, but it is how we've | ||
3 | tended to implement registers more recently. | ||
4 | |||
5 | In particular, bits [19:18] are only present with FEAT_RME, | ||
6 | and bits [17:12] will only be present with FEAT_ECV. | ||
2 | 7 | ||
3 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
5 | Message-id: 20200616170844.13318-6-peter.maydell@linaro.org | 10 | Message-id: 20240301183219.2424889-5-peter.maydell@linaro.org |
6 | --- | 11 | --- |
7 | target/arm/neon-dp.decode | 2 ++ | 12 | target/arm/helper.c | 18 ++++++++++++++++++ |
8 | target/arm/translate-neon.inc.c | 52 +++++++++++++++++++++++++++++++++ | 13 | 1 file changed, 18 insertions(+) |
9 | target/arm/translate.c | 35 +--------------------- | ||
10 | 3 files changed, 55 insertions(+), 34 deletions(-) | ||
11 | 14 | ||
12 | diff --git a/target/arm/neon-dp.decode b/target/arm/neon-dp.decode | 15 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
13 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
14 | --- a/target/arm/neon-dp.decode | 17 | --- a/target/arm/helper.c |
15 | +++ b/target/arm/neon-dp.decode | 18 | +++ b/target/arm/helper.c |
16 | @@ -XXX,XX +XXX,XX @@ Vimm_1r 1111 001 . 1 . 000 ... .... cmode:4 0 . op:1 1 .... @1reg_imm | 19 | @@ -XXX,XX +XXX,XX @@ static void gt_cnthctl_write(CPUARMState *env, const ARMCPRegInfo *ri, |
17 | # VQMOVN: signed result, source may be signed (_S) or unsigned (_U) | 20 | { |
18 | VQMOVN_S 1111 001 11 . 11 .. 10 .... 0 0101 0 . 0 .... @2misc_q0 | 21 | ARMCPU *cpu = env_archcpu(env); |
19 | VQMOVN_U 1111 001 11 . 11 .. 10 .... 0 0101 1 . 0 .... @2misc_q0 | 22 | uint32_t oldval = env->cp15.cnthctl_el2; |
23 | + uint32_t valid_mask = | ||
24 | + R_CNTHCTL_EL0PCTEN_E2H1_MASK | | ||
25 | + R_CNTHCTL_EL0VCTEN_E2H1_MASK | | ||
26 | + R_CNTHCTL_EVNTEN_MASK | | ||
27 | + R_CNTHCTL_EVNTDIR_MASK | | ||
28 | + R_CNTHCTL_EVNTI_MASK | | ||
29 | + R_CNTHCTL_EL0VTEN_MASK | | ||
30 | + R_CNTHCTL_EL0PTEN_MASK | | ||
31 | + R_CNTHCTL_EL1PCTEN_E2H1_MASK | | ||
32 | + R_CNTHCTL_EL1PTEN_MASK; | ||
20 | + | 33 | + |
21 | + VSHLL 1111 001 11 . 11 .. 10 .... 0 0110 0 . 0 .... @2misc_q0 | 34 | + if (cpu_isar_feature(aa64_rme, cpu)) { |
22 | ] | 35 | + valid_mask |= R_CNTHCTL_CNTVMASK_MASK | R_CNTHCTL_CNTPMASK_MASK; |
23 | |||
24 | # Subgroup for size != 0b11 | ||
25 | diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c | ||
26 | index XXXXXXX..XXXXXXX 100644 | ||
27 | --- a/target/arm/translate-neon.inc.c | ||
28 | +++ b/target/arm/translate-neon.inc.c | ||
29 | @@ -XXX,XX +XXX,XX @@ DO_VMOVN(VMOVN, gen_neon_narrow_u) | ||
30 | DO_VMOVN(VQMOVUN, gen_helper_neon_unarrow_sat) | ||
31 | DO_VMOVN(VQMOVN_S, gen_helper_neon_narrow_sat_s) | ||
32 | DO_VMOVN(VQMOVN_U, gen_helper_neon_narrow_sat_u) | ||
33 | + | ||
34 | +static bool trans_VSHLL(DisasContext *s, arg_2misc *a) | ||
35 | +{ | ||
36 | + TCGv_i32 rm0, rm1; | ||
37 | + TCGv_i64 rd; | ||
38 | + static NeonGenWidenFn * const widenfns[] = { | ||
39 | + gen_helper_neon_widen_u8, | ||
40 | + gen_helper_neon_widen_u16, | ||
41 | + tcg_gen_extu_i32_i64, | ||
42 | + NULL, | ||
43 | + }; | ||
44 | + NeonGenWidenFn *widenfn = widenfns[a->size]; | ||
45 | + | ||
46 | + if (!arm_dc_feature(s, ARM_FEATURE_NEON)) { | ||
47 | + return false; | ||
48 | + } | 36 | + } |
49 | + | 37 | + |
50 | + /* UNDEF accesses to D16-D31 if they don't exist. */ | 38 | + /* Clear RES0 bits */ |
51 | + if (!dc_isar_feature(aa32_simd_r32, s) && | 39 | + value &= valid_mask; |
52 | + ((a->vd | a->vm) & 0x10)) { | ||
53 | + return false; | ||
54 | + } | ||
55 | + | 40 | + |
56 | + if (a->vd & 1) { | 41 | raw_write(env, ri, value); |
57 | + return false; | 42 | |
58 | + } | 43 | if ((oldval ^ value) & R_CNTHCTL_CNTVMASK_MASK) { |
59 | + | ||
60 | + if (!widenfn) { | ||
61 | + return false; | ||
62 | + } | ||
63 | + | ||
64 | + if (!vfp_access_check(s)) { | ||
65 | + return true; | ||
66 | + } | ||
67 | + | ||
68 | + rd = tcg_temp_new_i64(); | ||
69 | + | ||
70 | + rm0 = neon_load_reg(a->vm, 0); | ||
71 | + rm1 = neon_load_reg(a->vm, 1); | ||
72 | + | ||
73 | + widenfn(rd, rm0); | ||
74 | + tcg_gen_shli_i64(rd, rd, 8 << a->size); | ||
75 | + neon_store_reg64(rd, a->vd); | ||
76 | + widenfn(rd, rm1); | ||
77 | + tcg_gen_shli_i64(rd, rd, 8 << a->size); | ||
78 | + neon_store_reg64(rd, a->vd + 1); | ||
79 | + | ||
80 | + tcg_temp_free_i64(rd); | ||
81 | + tcg_temp_free_i32(rm0); | ||
82 | + tcg_temp_free_i32(rm1); | ||
83 | + return true; | ||
84 | +} | ||
85 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
86 | index XXXXXXX..XXXXXXX 100644 | ||
87 | --- a/target/arm/translate.c | ||
88 | +++ b/target/arm/translate.c | ||
89 | @@ -XXX,XX +XXX,XX @@ static void gen_neon_trn_u16(TCGv_i32 t0, TCGv_i32 t1) | ||
90 | tcg_temp_free_i32(rd); | ||
91 | } | ||
92 | |||
93 | -static inline void gen_neon_widen(TCGv_i64 dest, TCGv_i32 src, int size, int u) | ||
94 | -{ | ||
95 | - if (u) { | ||
96 | - switch (size) { | ||
97 | - case 0: gen_helper_neon_widen_u8(dest, src); break; | ||
98 | - case 1: gen_helper_neon_widen_u16(dest, src); break; | ||
99 | - case 2: tcg_gen_extu_i32_i64(dest, src); break; | ||
100 | - default: abort(); | ||
101 | - } | ||
102 | - } else { | ||
103 | - switch (size) { | ||
104 | - case 0: gen_helper_neon_widen_s8(dest, src); break; | ||
105 | - case 1: gen_helper_neon_widen_s16(dest, src); break; | ||
106 | - case 2: tcg_gen_ext_i32_i64(dest, src); break; | ||
107 | - default: abort(); | ||
108 | - } | ||
109 | - } | ||
110 | - tcg_temp_free_i32(src); | ||
111 | -} | ||
112 | - | ||
113 | /* Symbolic constants for op fields for Neon 2-register miscellaneous. | ||
114 | * The values correspond to bits [17:16,10:7]; see the ARM ARM DDI0406B | ||
115 | * table A7-13. | ||
116 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
117 | case NEON_2RM_VUZP: | ||
118 | case NEON_2RM_VZIP: | ||
119 | case NEON_2RM_VMOVN: case NEON_2RM_VQMOVN: | ||
120 | + case NEON_2RM_VSHLL: | ||
121 | /* handled by decodetree */ | ||
122 | return 1; | ||
123 | case NEON_2RM_VTRN: | ||
124 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
125 | goto elementwise; | ||
126 | } | ||
127 | break; | ||
128 | - case NEON_2RM_VSHLL: | ||
129 | - if (q || (rd & 1)) { | ||
130 | - return 1; | ||
131 | - } | ||
132 | - tmp = neon_load_reg(rm, 0); | ||
133 | - tmp2 = neon_load_reg(rm, 1); | ||
134 | - for (pass = 0; pass < 2; pass++) { | ||
135 | - if (pass == 1) | ||
136 | - tmp = tmp2; | ||
137 | - gen_neon_widen(cpu_V0, tmp, size, 1); | ||
138 | - tcg_gen_shli_i64(cpu_V0, cpu_V0, 8 << size); | ||
139 | - neon_store_reg64(cpu_V0, rd + pass); | ||
140 | - } | ||
141 | - break; | ||
142 | case NEON_2RM_VCVT_F16_F32: | ||
143 | { | ||
144 | TCGv_ptr fpst; | ||
145 | -- | 44 | -- |
146 | 2.20.1 | 45 | 2.34.1 |
147 | |||
148 | diff view generated by jsdifflib |
1 | Convert the pairwise ops VPADDL and VPADAL in the 2-reg-misc grouping | 1 | The functionality defined by ID_AA64MMFR0_EL1.ECV == 1 is: |
---|---|---|---|
2 | to decodetree. | 2 | * four new trap bits for various counter and timer registers |
3 | * the CNTHCTL_EL2.EVNTIS and CNTKCTL_EL1.EVNTIS bits which control | ||
4 | scaling of the event stream. This is a no-op for us, because we don't | ||
5 | implement the event stream (our WFE is a NOP): all we need to do is | ||
6 | allow CNTHCTL_EL2.ENVTIS to be read and written. | ||
7 | * extensions to PMSCR_EL1.PCT, PMSCR_EL2.PCT, TRFCR_EL1.TS and | ||
8 | TRFCR_EL2.TS: these are all no-ops for us, because we don't implement | ||
9 | FEAT_SPE or FEAT_TRF. | ||
10 | * new registers CNTPCTSS_EL0 and NCTVCTSS_EL0 which are | ||
11 | "self-sychronizing" views of the CNTPCT_EL0 and CNTVCT_EL0, meaning | ||
12 | that no barriers are needed around their accesses. For us these | ||
13 | are just the same as the normal views, because all our sysregs are | ||
14 | inherently self-sychronizing. | ||
3 | 15 | ||
4 | At this point we can get rid of the weird CPU_V001 #define that was | 16 | In this commit we implement the trap handling and permit the new |
5 | used to avoid having to explicitly list all the arguments being | 17 | CNTHCTL_EL2 bits to be written. |
6 | passed to some TCG gen/helper functions. | ||
7 | 18 | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 19 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 20 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
10 | Message-id: 20200616170844.13318-3-peter.maydell@linaro.org | 21 | Message-id: 20240301183219.2424889-6-peter.maydell@linaro.org |
11 | --- | 22 | --- |
12 | target/arm/neon-dp.decode | 6 ++ | 23 | target/arm/cpu-features.h | 5 ++++ |
13 | target/arm/translate-neon.inc.c | 149 ++++++++++++++++++++++++++++++++ | 24 | target/arm/helper.c | 51 +++++++++++++++++++++++++++++++++++---- |
14 | target/arm/translate.c | 35 +------- | 25 | 2 files changed, 51 insertions(+), 5 deletions(-) |
15 | 3 files changed, 157 insertions(+), 33 deletions(-) | ||
16 | 26 | ||
17 | diff --git a/target/arm/neon-dp.decode b/target/arm/neon-dp.decode | 27 | diff --git a/target/arm/cpu-features.h b/target/arm/cpu-features.h |
18 | index XXXXXXX..XXXXXXX 100644 | 28 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/target/arm/neon-dp.decode | 29 | --- a/target/arm/cpu-features.h |
20 | +++ b/target/arm/neon-dp.decode | 30 | +++ b/target/arm/cpu-features.h |
21 | @@ -XXX,XX +XXX,XX @@ Vimm_1r 1111 001 . 1 . 000 ... .... cmode:4 0 . op:1 1 .... @1reg_imm | 31 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa64_fgt(const ARMISARegisters *id) |
22 | &2misc vm=%vm_dp vd=%vd_dp | 32 | return FIELD_EX64(id->id_aa64mmfr0, ID_AA64MMFR0, FGT) != 0; |
23 | |||
24 | VREV64 1111 001 11 . 11 .. 00 .... 0 0000 . . 0 .... @2misc | ||
25 | + | ||
26 | + VPADDL_S 1111 001 11 . 11 .. 00 .... 0 0100 . . 0 .... @2misc | ||
27 | + VPADDL_U 1111 001 11 . 11 .. 00 .... 0 0101 . . 0 .... @2misc | ||
28 | + | ||
29 | + VPADAL_S 1111 001 11 . 11 .. 00 .... 0 1100 . . 0 .... @2misc | ||
30 | + VPADAL_U 1111 001 11 . 11 .. 00 .... 0 1101 . . 0 .... @2misc | ||
31 | ] | ||
32 | |||
33 | # Subgroup for size != 0b11 | ||
34 | diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c | ||
35 | index XXXXXXX..XXXXXXX 100644 | ||
36 | --- a/target/arm/translate-neon.inc.c | ||
37 | +++ b/target/arm/translate-neon.inc.c | ||
38 | @@ -XXX,XX +XXX,XX @@ static bool trans_VREV64(DisasContext *s, arg_VREV64 *a) | ||
39 | } | ||
40 | return true; | ||
41 | } | 33 | } |
42 | + | 34 | |
43 | +static bool do_2misc_pairwise(DisasContext *s, arg_2misc *a, | 35 | +static inline bool isar_feature_aa64_ecv_traps(const ARMISARegisters *id) |
44 | + NeonGenWidenFn *widenfn, | ||
45 | + NeonGenTwo64OpFn *opfn, | ||
46 | + NeonGenTwo64OpFn *accfn) | ||
47 | +{ | 36 | +{ |
48 | + /* | 37 | + return FIELD_EX64(id->id_aa64mmfr0, ID_AA64MMFR0, ECV) > 0; |
49 | + * Pairwise long operations: widen both halves of the pair, | ||
50 | + * combine the pairs with the opfn, and then possibly accumulate | ||
51 | + * into the destination with the accfn. | ||
52 | + */ | ||
53 | + int pass; | ||
54 | + | ||
55 | + if (!arm_dc_feature(s, ARM_FEATURE_NEON)) { | ||
56 | + return false; | ||
57 | + } | ||
58 | + | ||
59 | + /* UNDEF accesses to D16-D31 if they don't exist. */ | ||
60 | + if (!dc_isar_feature(aa32_simd_r32, s) && | ||
61 | + ((a->vd | a->vm) & 0x10)) { | ||
62 | + return false; | ||
63 | + } | ||
64 | + | ||
65 | + if ((a->vd | a->vm) & a->q) { | ||
66 | + return false; | ||
67 | + } | ||
68 | + | ||
69 | + if (!widenfn) { | ||
70 | + return false; | ||
71 | + } | ||
72 | + | ||
73 | + if (!vfp_access_check(s)) { | ||
74 | + return true; | ||
75 | + } | ||
76 | + | ||
77 | + for (pass = 0; pass < a->q + 1; pass++) { | ||
78 | + TCGv_i32 tmp; | ||
79 | + TCGv_i64 rm0_64, rm1_64, rd_64; | ||
80 | + | ||
81 | + rm0_64 = tcg_temp_new_i64(); | ||
82 | + rm1_64 = tcg_temp_new_i64(); | ||
83 | + rd_64 = tcg_temp_new_i64(); | ||
84 | + tmp = neon_load_reg(a->vm, pass * 2); | ||
85 | + widenfn(rm0_64, tmp); | ||
86 | + tcg_temp_free_i32(tmp); | ||
87 | + tmp = neon_load_reg(a->vm, pass * 2 + 1); | ||
88 | + widenfn(rm1_64, tmp); | ||
89 | + tcg_temp_free_i32(tmp); | ||
90 | + opfn(rd_64, rm0_64, rm1_64); | ||
91 | + tcg_temp_free_i64(rm0_64); | ||
92 | + tcg_temp_free_i64(rm1_64); | ||
93 | + | ||
94 | + if (accfn) { | ||
95 | + TCGv_i64 tmp64 = tcg_temp_new_i64(); | ||
96 | + neon_load_reg64(tmp64, a->vd + pass); | ||
97 | + accfn(rd_64, tmp64, rd_64); | ||
98 | + tcg_temp_free_i64(tmp64); | ||
99 | + } | ||
100 | + neon_store_reg64(rd_64, a->vd + pass); | ||
101 | + tcg_temp_free_i64(rd_64); | ||
102 | + } | ||
103 | + return true; | ||
104 | +} | 38 | +} |
105 | + | 39 | + |
106 | +static bool trans_VPADDL_S(DisasContext *s, arg_2misc *a) | 40 | static inline bool isar_feature_aa64_vh(const ARMISARegisters *id) |
41 | { | ||
42 | return FIELD_EX64(id->id_aa64mmfr1, ID_AA64MMFR1, VH) != 0; | ||
43 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
44 | index XXXXXXX..XXXXXXX 100644 | ||
45 | --- a/target/arm/helper.c | ||
46 | +++ b/target/arm/helper.c | ||
47 | @@ -XXX,XX +XXX,XX @@ static CPAccessResult gt_counter_access(CPUARMState *env, int timeridx, | ||
48 | : !extract32(env->cp15.cnthctl_el2, 0, 1))) { | ||
49 | return CP_ACCESS_TRAP_EL2; | ||
50 | } | ||
51 | + if (has_el2 && timeridx == GTIMER_VIRT) { | ||
52 | + if (FIELD_EX64(env->cp15.cnthctl_el2, CNTHCTL, EL1TVCT)) { | ||
53 | + return CP_ACCESS_TRAP_EL2; | ||
54 | + } | ||
55 | + } | ||
56 | break; | ||
57 | } | ||
58 | return CP_ACCESS_OK; | ||
59 | @@ -XXX,XX +XXX,XX @@ static CPAccessResult gt_timer_access(CPUARMState *env, int timeridx, | ||
60 | } | ||
61 | } | ||
62 | } | ||
63 | + if (has_el2 && timeridx == GTIMER_VIRT) { | ||
64 | + if (FIELD_EX64(env->cp15.cnthctl_el2, CNTHCTL, EL1TVT)) { | ||
65 | + return CP_ACCESS_TRAP_EL2; | ||
66 | + } | ||
67 | + } | ||
68 | break; | ||
69 | } | ||
70 | return CP_ACCESS_OK; | ||
71 | @@ -XXX,XX +XXX,XX @@ static void gt_cnthctl_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
72 | if (cpu_isar_feature(aa64_rme, cpu)) { | ||
73 | valid_mask |= R_CNTHCTL_CNTVMASK_MASK | R_CNTHCTL_CNTPMASK_MASK; | ||
74 | } | ||
75 | + if (cpu_isar_feature(aa64_ecv_traps, cpu)) { | ||
76 | + valid_mask |= | ||
77 | + R_CNTHCTL_EL1TVT_MASK | | ||
78 | + R_CNTHCTL_EL1TVCT_MASK | | ||
79 | + R_CNTHCTL_EL1NVPCT_MASK | | ||
80 | + R_CNTHCTL_EL1NVVCT_MASK | | ||
81 | + R_CNTHCTL_EVNTIS_MASK; | ||
82 | + } | ||
83 | |||
84 | /* Clear RES0 bits */ | ||
85 | value &= valid_mask; | ||
86 | @@ -XXX,XX +XXX,XX @@ static CPAccessResult e2h_access(CPUARMState *env, const ARMCPRegInfo *ri, | ||
87 | { | ||
88 | if (arm_current_el(env) == 1) { | ||
89 | /* This must be a FEAT_NV access */ | ||
90 | - /* TODO: FEAT_ECV will need to check CNTHCTL_EL2 here */ | ||
91 | return CP_ACCESS_OK; | ||
92 | } | ||
93 | if (!(arm_hcr_el2_eff(env) & HCR_E2H)) { | ||
94 | @@ -XXX,XX +XXX,XX @@ static CPAccessResult e2h_access(CPUARMState *env, const ARMCPRegInfo *ri, | ||
95 | return CP_ACCESS_OK; | ||
96 | } | ||
97 | |||
98 | +static CPAccessResult access_el1nvpct(CPUARMState *env, const ARMCPRegInfo *ri, | ||
99 | + bool isread) | ||
107 | +{ | 100 | +{ |
108 | + static NeonGenWidenFn * const widenfn[] = { | 101 | + if (arm_current_el(env) == 1) { |
109 | + gen_helper_neon_widen_s8, | 102 | + /* This must be a FEAT_NV access with NVx == 101 */ |
110 | + gen_helper_neon_widen_s16, | 103 | + if (FIELD_EX64(env->cp15.cnthctl_el2, CNTHCTL, EL1NVPCT)) { |
111 | + tcg_gen_ext_i32_i64, | 104 | + return CP_ACCESS_TRAP_EL2; |
112 | + NULL, | 105 | + } |
113 | + }; | 106 | + } |
114 | + static NeonGenTwo64OpFn * const opfn[] = { | 107 | + return e2h_access(env, ri, isread); |
115 | + gen_helper_neon_paddl_u16, | ||
116 | + gen_helper_neon_paddl_u32, | ||
117 | + tcg_gen_add_i64, | ||
118 | + NULL, | ||
119 | + }; | ||
120 | + | ||
121 | + return do_2misc_pairwise(s, a, widenfn[a->size], opfn[a->size], NULL); | ||
122 | +} | 108 | +} |
123 | + | 109 | + |
124 | +static bool trans_VPADDL_U(DisasContext *s, arg_2misc *a) | 110 | +static CPAccessResult access_el1nvvct(CPUARMState *env, const ARMCPRegInfo *ri, |
111 | + bool isread) | ||
125 | +{ | 112 | +{ |
126 | + static NeonGenWidenFn * const widenfn[] = { | 113 | + if (arm_current_el(env) == 1) { |
127 | + gen_helper_neon_widen_u8, | 114 | + /* This must be a FEAT_NV access with NVx == 101 */ |
128 | + gen_helper_neon_widen_u16, | 115 | + if (FIELD_EX64(env->cp15.cnthctl_el2, CNTHCTL, EL1NVVCT)) { |
129 | + tcg_gen_extu_i32_i64, | 116 | + return CP_ACCESS_TRAP_EL2; |
130 | + NULL, | 117 | + } |
131 | + }; | 118 | + } |
132 | + static NeonGenTwo64OpFn * const opfn[] = { | 119 | + return e2h_access(env, ri, isread); |
133 | + gen_helper_neon_paddl_u16, | ||
134 | + gen_helper_neon_paddl_u32, | ||
135 | + tcg_gen_add_i64, | ||
136 | + NULL, | ||
137 | + }; | ||
138 | + | ||
139 | + return do_2misc_pairwise(s, a, widenfn[a->size], opfn[a->size], NULL); | ||
140 | +} | 120 | +} |
141 | + | 121 | + |
142 | +static bool trans_VPADAL_S(DisasContext *s, arg_2misc *a) | 122 | /* Test if system register redirection is to occur in the current state. */ |
143 | +{ | 123 | static bool redirect_for_e2h(CPUARMState *env) |
144 | + static NeonGenWidenFn * const widenfn[] = { | ||
145 | + gen_helper_neon_widen_s8, | ||
146 | + gen_helper_neon_widen_s16, | ||
147 | + tcg_gen_ext_i32_i64, | ||
148 | + NULL, | ||
149 | + }; | ||
150 | + static NeonGenTwo64OpFn * const opfn[] = { | ||
151 | + gen_helper_neon_paddl_u16, | ||
152 | + gen_helper_neon_paddl_u32, | ||
153 | + tcg_gen_add_i64, | ||
154 | + NULL, | ||
155 | + }; | ||
156 | + static NeonGenTwo64OpFn * const accfn[] = { | ||
157 | + gen_helper_neon_addl_u16, | ||
158 | + gen_helper_neon_addl_u32, | ||
159 | + tcg_gen_add_i64, | ||
160 | + NULL, | ||
161 | + }; | ||
162 | + | ||
163 | + return do_2misc_pairwise(s, a, widenfn[a->size], opfn[a->size], | ||
164 | + accfn[a->size]); | ||
165 | +} | ||
166 | + | ||
167 | +static bool trans_VPADAL_U(DisasContext *s, arg_2misc *a) | ||
168 | +{ | ||
169 | + static NeonGenWidenFn * const widenfn[] = { | ||
170 | + gen_helper_neon_widen_u8, | ||
171 | + gen_helper_neon_widen_u16, | ||
172 | + tcg_gen_extu_i32_i64, | ||
173 | + NULL, | ||
174 | + }; | ||
175 | + static NeonGenTwo64OpFn * const opfn[] = { | ||
176 | + gen_helper_neon_paddl_u16, | ||
177 | + gen_helper_neon_paddl_u32, | ||
178 | + tcg_gen_add_i64, | ||
179 | + NULL, | ||
180 | + }; | ||
181 | + static NeonGenTwo64OpFn * const accfn[] = { | ||
182 | + gen_helper_neon_addl_u16, | ||
183 | + gen_helper_neon_addl_u32, | ||
184 | + tcg_gen_add_i64, | ||
185 | + NULL, | ||
186 | + }; | ||
187 | + | ||
188 | + return do_2misc_pairwise(s, a, widenfn[a->size], opfn[a->size], | ||
189 | + accfn[a->size]); | ||
190 | +} | ||
191 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
192 | index XXXXXXX..XXXXXXX 100644 | ||
193 | --- a/target/arm/translate.c | ||
194 | +++ b/target/arm/translate.c | ||
195 | @@ -XXX,XX +XXX,XX @@ static void gen_exception_return(DisasContext *s, TCGv_i32 pc) | ||
196 | gen_rfe(s, pc, load_cpu_field(spsr)); | ||
197 | } | ||
198 | |||
199 | -#define CPU_V001 cpu_V0, cpu_V0, cpu_V1 | ||
200 | - | ||
201 | static int gen_neon_unzip(int rd, int rm, int size, int q) | ||
202 | { | 124 | { |
203 | TCGv_ptr pd, pm; | 125 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo vhe_reginfo[] = { |
204 | @@ -XXX,XX +XXX,XX @@ static inline void gen_neon_widen(TCGv_i64 dest, TCGv_i32 src, int size, int u) | 126 | { .name = "CNTP_CTL_EL02", .state = ARM_CP_STATE_AA64, |
205 | tcg_temp_free_i32(src); | 127 | .opc0 = 3, .opc1 = 5, .crn = 14, .crm = 2, .opc2 = 1, |
206 | } | 128 | .type = ARM_CP_IO | ARM_CP_ALIAS, |
207 | 129 | - .access = PL2_RW, .accessfn = e2h_access, | |
208 | -static inline void gen_neon_addl(int size) | 130 | + .access = PL2_RW, .accessfn = access_el1nvpct, |
209 | -{ | 131 | .nv2_redirect_offset = 0x180 | NV2_REDIR_NO_NV1, |
210 | - switch (size) { | 132 | .fieldoffset = offsetof(CPUARMState, cp15.c14_timer[GTIMER_PHYS].ctl), |
211 | - case 0: gen_helper_neon_addl_u16(CPU_V001); break; | 133 | .writefn = gt_phys_ctl_write, .raw_writefn = raw_write }, |
212 | - case 1: gen_helper_neon_addl_u32(CPU_V001); break; | 134 | { .name = "CNTV_CTL_EL02", .state = ARM_CP_STATE_AA64, |
213 | - case 2: tcg_gen_add_i64(CPU_V001); break; | 135 | .opc0 = 3, .opc1 = 5, .crn = 14, .crm = 3, .opc2 = 1, |
214 | - default: abort(); | 136 | .type = ARM_CP_IO | ARM_CP_ALIAS, |
215 | - } | 137 | - .access = PL2_RW, .accessfn = e2h_access, |
216 | -} | 138 | + .access = PL2_RW, .accessfn = access_el1nvvct, |
217 | - | 139 | .nv2_redirect_offset = 0x170 | NV2_REDIR_NO_NV1, |
218 | static void gen_neon_narrow_op(int op, int u, int size, | 140 | .fieldoffset = offsetof(CPUARMState, cp15.c14_timer[GTIMER_VIRT].ctl), |
219 | TCGv_i32 dest, TCGv_i64 src) | 141 | .writefn = gt_virt_ctl_write, .raw_writefn = raw_write }, |
220 | { | 142 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo vhe_reginfo[] = { |
221 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | 143 | .type = ARM_CP_IO | ARM_CP_ALIAS, |
222 | } | 144 | .fieldoffset = offsetof(CPUARMState, cp15.c14_timer[GTIMER_PHYS].cval), |
223 | switch (op) { | 145 | .nv2_redirect_offset = 0x178 | NV2_REDIR_NO_NV1, |
224 | case NEON_2RM_VREV64: | 146 | - .access = PL2_RW, .accessfn = e2h_access, |
225 | - /* handled by decodetree */ | 147 | + .access = PL2_RW, .accessfn = access_el1nvpct, |
226 | - return 1; | 148 | .writefn = gt_phys_cval_write, .raw_writefn = raw_write }, |
227 | case NEON_2RM_VPADDL: case NEON_2RM_VPADDL_U: | 149 | { .name = "CNTV_CVAL_EL02", .state = ARM_CP_STATE_AA64, |
228 | case NEON_2RM_VPADAL: case NEON_2RM_VPADAL_U: | 150 | .opc0 = 3, .opc1 = 5, .crn = 14, .crm = 3, .opc2 = 2, |
229 | - for (pass = 0; pass < q + 1; pass++) { | 151 | .type = ARM_CP_IO | ARM_CP_ALIAS, |
230 | - tmp = neon_load_reg(rm, pass * 2); | 152 | .nv2_redirect_offset = 0x168 | NV2_REDIR_NO_NV1, |
231 | - gen_neon_widen(cpu_V0, tmp, size, op & 1); | 153 | .fieldoffset = offsetof(CPUARMState, cp15.c14_timer[GTIMER_VIRT].cval), |
232 | - tmp = neon_load_reg(rm, pass * 2 + 1); | 154 | - .access = PL2_RW, .accessfn = e2h_access, |
233 | - gen_neon_widen(cpu_V1, tmp, size, op & 1); | 155 | + .access = PL2_RW, .accessfn = access_el1nvvct, |
234 | - switch (size) { | 156 | .writefn = gt_virt_cval_write, .raw_writefn = raw_write }, |
235 | - case 0: gen_helper_neon_paddl_u16(CPU_V001); break; | 157 | #endif |
236 | - case 1: gen_helper_neon_paddl_u32(CPU_V001); break; | 158 | }; |
237 | - case 2: tcg_gen_add_i64(CPU_V001); break; | ||
238 | - default: abort(); | ||
239 | - } | ||
240 | - if (op >= NEON_2RM_VPADAL) { | ||
241 | - /* Accumulate. */ | ||
242 | - neon_load_reg64(cpu_V1, rd + pass); | ||
243 | - gen_neon_addl(size); | ||
244 | - } | ||
245 | - neon_store_reg64(cpu_V0, rd + pass); | ||
246 | - } | ||
247 | - break; | ||
248 | + /* handled by decodetree */ | ||
249 | + return 1; | ||
250 | case NEON_2RM_VTRN: | ||
251 | if (size == 2) { | ||
252 | int n; | ||
253 | -- | 159 | -- |
254 | 2.20.1 | 160 | 2.34.1 |
255 | |||
256 | diff view generated by jsdifflib |
1 | Convert the Neon narrowing moves VMQNV, VQMOVN, VQMOVUN in the 2-reg-misc | 1 | For FEAT_ECV, new registers CNTPCTSS_EL0 and CNTVCTSS_EL0 are |
---|---|---|---|
2 | group to decodetree. | 2 | defined, which are "self-synchronized" views of the physical and |
3 | virtual counts as seen in the CNTPCT_EL0 and CNTVCT_EL0 registers | ||
4 | (meaning that no barriers are needed around accesses to them to | ||
5 | ensure that reads of them do not occur speculatively and out-of-order | ||
6 | with other instructions). | ||
7 | |||
8 | For QEMU, all our system registers are self-synchronized, so we can | ||
9 | simply copy the existing implementation of CNTPCT_EL0 and CNTVCT_EL0 | ||
10 | to the new register encodings. | ||
11 | |||
12 | This means we now implement all the functionality required for | ||
13 | ID_AA64MMFR0_EL1.ECV == 0b0001. | ||
3 | 14 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 16 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
6 | Message-id: 20200616170844.13318-5-peter.maydell@linaro.org | 17 | Message-id: 20240301183219.2424889-7-peter.maydell@linaro.org |
7 | --- | 18 | --- |
8 | target/arm/neon-dp.decode | 9 ++++ | 19 | target/arm/helper.c | 43 +++++++++++++++++++++++++++++++++++++++++++ |
9 | target/arm/translate-neon.inc.c | 59 ++++++++++++++++++++++++ | 20 | 1 file changed, 43 insertions(+) |
10 | target/arm/translate.c | 81 +-------------------------------- | ||
11 | 3 files changed, 70 insertions(+), 79 deletions(-) | ||
12 | 21 | ||
13 | diff --git a/target/arm/neon-dp.decode b/target/arm/neon-dp.decode | 22 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
14 | index XXXXXXX..XXXXXXX 100644 | 23 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/neon-dp.decode | 24 | --- a/target/arm/helper.c |
16 | +++ b/target/arm/neon-dp.decode | 25 | +++ b/target/arm/helper.c |
17 | @@ -XXX,XX +XXX,XX @@ Vimm_1r 1111 001 . 1 . 000 ... .... cmode:4 0 . op:1 1 .... @1reg_imm | 26 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo generic_timer_cp_reginfo[] = { |
18 | 27 | }, | |
19 | @2misc .... ... .. . .. size:2 .. .... . .... q:1 . . .... \ | 28 | }; |
20 | &2misc vm=%vm_dp vd=%vd_dp | 29 | |
21 | + @2misc_q0 .... ... .. . .. size:2 .. .... . .... . . . .... \ | 30 | +/* |
22 | + &2misc vm=%vm_dp vd=%vd_dp q=0 | 31 | + * FEAT_ECV adds extra views of CNTVCT_EL0 and CNTPCT_EL0 which |
23 | 32 | + * are "self-synchronizing". For QEMU all sysregs are self-synchronizing, | |
24 | VREV64 1111 001 11 . 11 .. 00 .... 0 0000 . . 0 .... @2misc | 33 | + * so our implementations here are identical to the normal registers. |
25 | 34 | + */ | |
26 | @@ -XXX,XX +XXX,XX @@ Vimm_1r 1111 001 . 1 . 000 ... .... cmode:4 0 . op:1 1 .... @1reg_imm | 35 | +static const ARMCPRegInfo gen_timer_ecv_cp_reginfo[] = { |
27 | 36 | + { .name = "CNTVCTSS", .cp = 15, .crm = 14, .opc1 = 9, | |
28 | VUZP 1111 001 11 . 11 .. 10 .... 0 0010 . . 0 .... @2misc | 37 | + .access = PL0_R, .type = ARM_CP_64BIT | ARM_CP_NO_RAW | ARM_CP_IO, |
29 | VZIP 1111 001 11 . 11 .. 10 .... 0 0011 . . 0 .... @2misc | 38 | + .accessfn = gt_vct_access, |
39 | + .readfn = gt_virt_cnt_read, .resetfn = arm_cp_reset_ignore, | ||
40 | + }, | ||
41 | + { .name = "CNTVCTSS_EL0", .state = ARM_CP_STATE_AA64, | ||
42 | + .opc0 = 3, .opc1 = 3, .crn = 14, .crm = 0, .opc2 = 6, | ||
43 | + .access = PL0_R, .type = ARM_CP_NO_RAW | ARM_CP_IO, | ||
44 | + .accessfn = gt_vct_access, .readfn = gt_virt_cnt_read, | ||
45 | + }, | ||
46 | + { .name = "CNTPCTSS", .cp = 15, .crm = 14, .opc1 = 8, | ||
47 | + .access = PL0_R, .type = ARM_CP_64BIT | ARM_CP_NO_RAW | ARM_CP_IO, | ||
48 | + .accessfn = gt_pct_access, | ||
49 | + .readfn = gt_cnt_read, .resetfn = arm_cp_reset_ignore, | ||
50 | + }, | ||
51 | + { .name = "CNTPCTSS_EL0", .state = ARM_CP_STATE_AA64, | ||
52 | + .opc0 = 3, .opc1 = 3, .crn = 14, .crm = 0, .opc2 = 5, | ||
53 | + .access = PL0_R, .type = ARM_CP_NO_RAW | ARM_CP_IO, | ||
54 | + .accessfn = gt_pct_access, .readfn = gt_cnt_read, | ||
55 | + }, | ||
56 | +}; | ||
30 | + | 57 | + |
31 | + VMOVN 1111 001 11 . 11 .. 10 .... 0 0100 0 . 0 .... @2misc_q0 | 58 | #else |
32 | + # VQMOVUN: unsigned result (source is always signed) | 59 | |
33 | + VQMOVUN 1111 001 11 . 11 .. 10 .... 0 0100 1 . 0 .... @2misc_q0 | 60 | /* |
34 | + # VQMOVN: signed result, source may be signed (_S) or unsigned (_U) | 61 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo generic_timer_cp_reginfo[] = { |
35 | + VQMOVN_S 1111 001 11 . 11 .. 10 .... 0 0101 0 . 0 .... @2misc_q0 | 62 | }, |
36 | + VQMOVN_U 1111 001 11 . 11 .. 10 .... 0 0101 1 . 0 .... @2misc_q0 | 63 | }; |
37 | ] | 64 | |
38 | 65 | +/* | |
39 | # Subgroup for size != 0b11 | 66 | + * CNTVCTSS_EL0 has the same trap conditions as CNTVCT_EL0, so it also |
40 | diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c | 67 | + * is exposed to userspace by Linux. |
41 | index XXXXXXX..XXXXXXX 100644 | 68 | + */ |
42 | --- a/target/arm/translate-neon.inc.c | 69 | +static const ARMCPRegInfo gen_timer_ecv_cp_reginfo[] = { |
43 | +++ b/target/arm/translate-neon.inc.c | 70 | + { .name = "CNTVCTSS_EL0", .state = ARM_CP_STATE_AA64, |
44 | @@ -XXX,XX +XXX,XX @@ static bool trans_VZIP(DisasContext *s, arg_2misc *a) | 71 | + .opc0 = 3, .opc1 = 3, .crn = 14, .crm = 0, .opc2 = 6, |
45 | }; | 72 | + .access = PL0_R, .type = ARM_CP_NO_RAW | ARM_CP_IO, |
46 | return do_zip_uzp(s, a, fn[a->q][a->size]); | 73 | + .readfn = gt_virt_cnt_read, |
47 | } | 74 | + }, |
75 | +}; | ||
48 | + | 76 | + |
49 | +static bool do_vmovn(DisasContext *s, arg_2misc *a, | 77 | #endif |
50 | + NeonGenNarrowEnvFn *narrowfn) | 78 | |
51 | +{ | 79 | static void par_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) |
52 | + TCGv_i64 rm; | 80 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) |
53 | + TCGv_i32 rd0, rd1; | 81 | if (arm_feature(env, ARM_FEATURE_GENERIC_TIMER)) { |
54 | + | 82 | define_arm_cp_regs(cpu, generic_timer_cp_reginfo); |
55 | + if (!arm_dc_feature(s, ARM_FEATURE_NEON)) { | 83 | } |
56 | + return false; | 84 | + if (cpu_isar_feature(aa64_ecv_traps, cpu)) { |
85 | + define_arm_cp_regs(cpu, gen_timer_ecv_cp_reginfo); | ||
57 | + } | 86 | + } |
58 | + | 87 | if (arm_feature(env, ARM_FEATURE_VAPA)) { |
59 | + /* UNDEF accesses to D16-D31 if they don't exist. */ | 88 | ARMCPRegInfo vapa_cp_reginfo[] = { |
60 | + if (!dc_isar_feature(aa32_simd_r32, s) && | 89 | { .name = "PAR", .cp = 15, .crn = 7, .crm = 4, .opc1 = 0, .opc2 = 0, |
61 | + ((a->vd | a->vm) & 0x10)) { | ||
62 | + return false; | ||
63 | + } | ||
64 | + | ||
65 | + if (a->vm & 1) { | ||
66 | + return false; | ||
67 | + } | ||
68 | + | ||
69 | + if (!narrowfn) { | ||
70 | + return false; | ||
71 | + } | ||
72 | + | ||
73 | + if (!vfp_access_check(s)) { | ||
74 | + return true; | ||
75 | + } | ||
76 | + | ||
77 | + rm = tcg_temp_new_i64(); | ||
78 | + rd0 = tcg_temp_new_i32(); | ||
79 | + rd1 = tcg_temp_new_i32(); | ||
80 | + | ||
81 | + neon_load_reg64(rm, a->vm); | ||
82 | + narrowfn(rd0, cpu_env, rm); | ||
83 | + neon_load_reg64(rm, a->vm + 1); | ||
84 | + narrowfn(rd1, cpu_env, rm); | ||
85 | + neon_store_reg(a->vd, 0, rd0); | ||
86 | + neon_store_reg(a->vd, 1, rd1); | ||
87 | + tcg_temp_free_i64(rm); | ||
88 | + return true; | ||
89 | +} | ||
90 | + | ||
91 | +#define DO_VMOVN(INSN, FUNC) \ | ||
92 | + static bool trans_##INSN(DisasContext *s, arg_2misc *a) \ | ||
93 | + { \ | ||
94 | + static NeonGenNarrowEnvFn * const narrowfn[] = { \ | ||
95 | + FUNC##8, \ | ||
96 | + FUNC##16, \ | ||
97 | + FUNC##32, \ | ||
98 | + NULL, \ | ||
99 | + }; \ | ||
100 | + return do_vmovn(s, a, narrowfn[a->size]); \ | ||
101 | + } | ||
102 | + | ||
103 | +DO_VMOVN(VMOVN, gen_neon_narrow_u) | ||
104 | +DO_VMOVN(VQMOVUN, gen_helper_neon_unarrow_sat) | ||
105 | +DO_VMOVN(VQMOVN_S, gen_helper_neon_narrow_sat_s) | ||
106 | +DO_VMOVN(VQMOVN_U, gen_helper_neon_narrow_sat_u) | ||
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 gen_neon_trn_u16(TCGv_i32 t0, TCGv_i32 t1) | ||
112 | tcg_temp_free_i32(rd); | ||
113 | } | ||
114 | |||
115 | -static inline void gen_neon_narrow(int size, TCGv_i32 dest, TCGv_i64 src) | ||
116 | -{ | ||
117 | - switch (size) { | ||
118 | - case 0: gen_helper_neon_narrow_u8(dest, src); break; | ||
119 | - case 1: gen_helper_neon_narrow_u16(dest, src); break; | ||
120 | - case 2: tcg_gen_extrl_i64_i32(dest, src); break; | ||
121 | - default: abort(); | ||
122 | - } | ||
123 | -} | ||
124 | - | ||
125 | -static inline void gen_neon_narrow_sats(int size, TCGv_i32 dest, TCGv_i64 src) | ||
126 | -{ | ||
127 | - switch (size) { | ||
128 | - case 0: gen_helper_neon_narrow_sat_s8(dest, cpu_env, src); break; | ||
129 | - case 1: gen_helper_neon_narrow_sat_s16(dest, cpu_env, src); break; | ||
130 | - case 2: gen_helper_neon_narrow_sat_s32(dest, cpu_env, src); break; | ||
131 | - default: abort(); | ||
132 | - } | ||
133 | -} | ||
134 | - | ||
135 | -static inline void gen_neon_narrow_satu(int size, TCGv_i32 dest, TCGv_i64 src) | ||
136 | -{ | ||
137 | - switch (size) { | ||
138 | - case 0: gen_helper_neon_narrow_sat_u8(dest, cpu_env, src); break; | ||
139 | - case 1: gen_helper_neon_narrow_sat_u16(dest, cpu_env, src); break; | ||
140 | - case 2: gen_helper_neon_narrow_sat_u32(dest, cpu_env, src); break; | ||
141 | - default: abort(); | ||
142 | - } | ||
143 | -} | ||
144 | - | ||
145 | -static inline void gen_neon_unarrow_sats(int size, TCGv_i32 dest, TCGv_i64 src) | ||
146 | -{ | ||
147 | - switch (size) { | ||
148 | - case 0: gen_helper_neon_unarrow_sat8(dest, cpu_env, src); break; | ||
149 | - case 1: gen_helper_neon_unarrow_sat16(dest, cpu_env, src); break; | ||
150 | - case 2: gen_helper_neon_unarrow_sat32(dest, cpu_env, src); break; | ||
151 | - default: abort(); | ||
152 | - } | ||
153 | -} | ||
154 | - | ||
155 | static inline void gen_neon_widen(TCGv_i64 dest, TCGv_i32 src, int size, int u) | ||
156 | { | ||
157 | if (u) { | ||
158 | @@ -XXX,XX +XXX,XX @@ static inline void gen_neon_widen(TCGv_i64 dest, TCGv_i32 src, int size, int u) | ||
159 | tcg_temp_free_i32(src); | ||
160 | } | ||
161 | |||
162 | -static void gen_neon_narrow_op(int op, int u, int size, | ||
163 | - TCGv_i32 dest, TCGv_i64 src) | ||
164 | -{ | ||
165 | - if (op) { | ||
166 | - if (u) { | ||
167 | - gen_neon_unarrow_sats(size, dest, src); | ||
168 | - } else { | ||
169 | - gen_neon_narrow(size, dest, src); | ||
170 | - } | ||
171 | - } else { | ||
172 | - if (u) { | ||
173 | - gen_neon_narrow_satu(size, dest, src); | ||
174 | - } else { | ||
175 | - gen_neon_narrow_sats(size, dest, src); | ||
176 | - } | ||
177 | - } | ||
178 | -} | ||
179 | - | ||
180 | /* Symbolic constants for op fields for Neon 2-register miscellaneous. | ||
181 | * The values correspond to bits [17:16,10:7]; see the ARM ARM DDI0406B | ||
182 | * table A7-13. | ||
183 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
184 | !arm_dc_feature(s, ARM_FEATURE_V8)) { | ||
185 | return 1; | ||
186 | } | ||
187 | - if ((op != NEON_2RM_VMOVN && op != NEON_2RM_VQMOVN) && | ||
188 | - q && ((rm | rd) & 1)) { | ||
189 | + if (q && ((rm | rd) & 1)) { | ||
190 | return 1; | ||
191 | } | ||
192 | switch (op) { | ||
193 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
194 | case NEON_2RM_VPADAL: case NEON_2RM_VPADAL_U: | ||
195 | case NEON_2RM_VUZP: | ||
196 | case NEON_2RM_VZIP: | ||
197 | + case NEON_2RM_VMOVN: case NEON_2RM_VQMOVN: | ||
198 | /* handled by decodetree */ | ||
199 | return 1; | ||
200 | case NEON_2RM_VTRN: | ||
201 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
202 | goto elementwise; | ||
203 | } | ||
204 | break; | ||
205 | - case NEON_2RM_VMOVN: case NEON_2RM_VQMOVN: | ||
206 | - /* also VQMOVUN; op field and mnemonics don't line up */ | ||
207 | - if (rm & 1) { | ||
208 | - return 1; | ||
209 | - } | ||
210 | - tmp2 = NULL; | ||
211 | - for (pass = 0; pass < 2; pass++) { | ||
212 | - neon_load_reg64(cpu_V0, rm + pass); | ||
213 | - tmp = tcg_temp_new_i32(); | ||
214 | - gen_neon_narrow_op(op == NEON_2RM_VMOVN, q, size, | ||
215 | - tmp, cpu_V0); | ||
216 | - if (pass == 0) { | ||
217 | - tmp2 = tmp; | ||
218 | - } else { | ||
219 | - neon_store_reg(rd, 0, tmp2); | ||
220 | - neon_store_reg(rd, 1, tmp); | ||
221 | - } | ||
222 | - } | ||
223 | - break; | ||
224 | case NEON_2RM_VSHLL: | ||
225 | if (q || (rd & 1)) { | ||
226 | return 1; | ||
227 | -- | 90 | -- |
228 | 2.20.1 | 91 | 2.34.1 |
229 | |||
230 | diff view generated by jsdifflib |
1 | Convert the remaining ops in the Neon 2-reg-misc group which | 1 | When ID_AA64MMFR0_EL1.ECV is 0b0010, a new register CNTPOFF_EL2 is |
---|---|---|---|
2 | can be implemented simply with our do_2misc() helper. | 2 | implemented. This is similar to the existing CNTVOFF_EL2, except |
3 | that it controls a hypervisor-adjustable offset made to the physical | ||
4 | counter and timer. | ||
5 | |||
6 | Implement the handling for this register, which includes control/trap | ||
7 | bits in SCR_EL3 and CNTHCTL_EL2. | ||
3 | 8 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
6 | Message-id: 20200616170844.13318-14-peter.maydell@linaro.org | 11 | Message-id: 20240301183219.2424889-8-peter.maydell@linaro.org |
7 | --- | 12 | --- |
8 | target/arm/neon-dp.decode | 10 +++++ | 13 | target/arm/cpu-features.h | 5 +++ |
9 | target/arm/translate-neon.inc.c | 69 +++++++++++++++++++++++++++++++++ | 14 | target/arm/cpu.h | 1 + |
10 | target/arm/translate.c | 38 ++++-------------- | 15 | target/arm/helper.c | 68 +++++++++++++++++++++++++++++++++++++-- |
11 | 3 files changed, 86 insertions(+), 31 deletions(-) | 16 | target/arm/trace-events | 1 + |
17 | 4 files changed, 73 insertions(+), 2 deletions(-) | ||
12 | 18 | ||
13 | diff --git a/target/arm/neon-dp.decode b/target/arm/neon-dp.decode | 19 | diff --git a/target/arm/cpu-features.h b/target/arm/cpu-features.h |
14 | index XXXXXXX..XXXXXXX 100644 | 20 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/neon-dp.decode | 21 | --- a/target/arm/cpu-features.h |
16 | +++ b/target/arm/neon-dp.decode | 22 | +++ b/target/arm/cpu-features.h |
17 | @@ -XXX,XX +XXX,XX @@ Vimm_1r 1111 001 . 1 . 000 ... .... cmode:4 0 . op:1 1 .... @1reg_imm | 23 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa64_ecv_traps(const ARMISARegisters *id) |
18 | AESMC 1111 001 11 . 11 .. 00 .... 0 0111 0 . 0 .... @2misc_q1 | 24 | return FIELD_EX64(id->id_aa64mmfr0, ID_AA64MMFR0, ECV) > 0; |
19 | AESIMC 1111 001 11 . 11 .. 00 .... 0 0111 1 . 0 .... @2misc_q1 | ||
20 | |||
21 | + VCLS 1111 001 11 . 11 .. 00 .... 0 1000 . . 0 .... @2misc | ||
22 | + VCLZ 1111 001 11 . 11 .. 00 .... 0 1001 . . 0 .... @2misc | ||
23 | + VCNT 1111 001 11 . 11 .. 00 .... 0 1010 . . 0 .... @2misc | ||
24 | + | ||
25 | VMVN 1111 001 11 . 11 .. 00 .... 0 1011 . . 0 .... @2misc | ||
26 | |||
27 | VPADAL_S 1111 001 11 . 11 .. 00 .... 0 1100 . . 0 .... @2misc | ||
28 | @@ -XXX,XX +XXX,XX @@ Vimm_1r 1111 001 . 1 . 000 ... .... cmode:4 0 . op:1 1 .... @1reg_imm | ||
29 | VABS 1111 001 11 . 11 .. 01 .... 0 0110 . . 0 .... @2misc | ||
30 | VNEG 1111 001 11 . 11 .. 01 .... 0 0111 . . 0 .... @2misc | ||
31 | |||
32 | + VABS_F 1111 001 11 . 11 .. 01 .... 0 1110 . . 0 .... @2misc | ||
33 | + VNEG_F 1111 001 11 . 11 .. 01 .... 0 1111 . . 0 .... @2misc | ||
34 | + | ||
35 | VUZP 1111 001 11 . 11 .. 10 .... 0 0010 . . 0 .... @2misc | ||
36 | VZIP 1111 001 11 . 11 .. 10 .... 0 0011 . . 0 .... @2misc | ||
37 | |||
38 | @@ -XXX,XX +XXX,XX @@ Vimm_1r 1111 001 . 1 . 000 ... .... cmode:4 0 . op:1 1 .... @1reg_imm | ||
39 | |||
40 | VCVT_F16_F32 1111 001 11 . 11 .. 10 .... 0 1100 0 . 0 .... @2misc_q0 | ||
41 | VCVT_F32_F16 1111 001 11 . 11 .. 10 .... 0 1110 0 . 0 .... @2misc_q0 | ||
42 | + | ||
43 | + VRECPE 1111 001 11 . 11 .. 11 .... 0 1000 . . 0 .... @2misc | ||
44 | + VRSQRTE 1111 001 11 . 11 .. 11 .... 0 1001 . . 0 .... @2misc | ||
45 | ] | ||
46 | |||
47 | # Subgroup for size != 0b11 | ||
48 | diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c | ||
49 | index XXXXXXX..XXXXXXX 100644 | ||
50 | --- a/target/arm/translate-neon.inc.c | ||
51 | +++ b/target/arm/translate-neon.inc.c | ||
52 | @@ -XXX,XX +XXX,XX @@ static bool trans_VREV16(DisasContext *s, arg_2misc *a) | ||
53 | } | ||
54 | return do_2misc(s, a, gen_rev16); | ||
55 | } | 25 | } |
56 | + | 26 | |
57 | +static bool trans_VCLS(DisasContext *s, arg_2misc *a) | 27 | +static inline bool isar_feature_aa64_ecv(const ARMISARegisters *id) |
58 | +{ | 28 | +{ |
59 | + static NeonGenOneOpFn * const fn[] = { | 29 | + return FIELD_EX64(id->id_aa64mmfr0, ID_AA64MMFR0, ECV) > 1; |
60 | + gen_helper_neon_cls_s8, | ||
61 | + gen_helper_neon_cls_s16, | ||
62 | + gen_helper_neon_cls_s32, | ||
63 | + NULL, | ||
64 | + }; | ||
65 | + return do_2misc(s, a, fn[a->size]); | ||
66 | +} | 30 | +} |
67 | + | 31 | + |
68 | +static void do_VCLZ_32(TCGv_i32 rd, TCGv_i32 rm) | 32 | static inline bool isar_feature_aa64_vh(const ARMISARegisters *id) |
33 | { | ||
34 | return FIELD_EX64(id->id_aa64mmfr1, ID_AA64MMFR1, VH) != 0; | ||
35 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
36 | index XXXXXXX..XXXXXXX 100644 | ||
37 | --- a/target/arm/cpu.h | ||
38 | +++ b/target/arm/cpu.h | ||
39 | @@ -XXX,XX +XXX,XX @@ typedef struct CPUArchState { | ||
40 | uint64_t c14_cntkctl; /* Timer Control register */ | ||
41 | uint64_t cnthctl_el2; /* Counter/Timer Hyp Control register */ | ||
42 | uint64_t cntvoff_el2; /* Counter Virtual Offset register */ | ||
43 | + uint64_t cntpoff_el2; /* Counter Physical Offset register */ | ||
44 | ARMGenericTimer c14_timer[NUM_GTIMERS]; | ||
45 | uint32_t c15_cpar; /* XScale Coprocessor Access Register */ | ||
46 | uint32_t c15_ticonfig; /* TI925T configuration byte. */ | ||
47 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
48 | index XXXXXXX..XXXXXXX 100644 | ||
49 | --- a/target/arm/helper.c | ||
50 | +++ b/target/arm/helper.c | ||
51 | @@ -XXX,XX +XXX,XX @@ static void scr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) | ||
52 | if (cpu_isar_feature(aa64_rme, cpu)) { | ||
53 | valid_mask |= SCR_NSE | SCR_GPF; | ||
54 | } | ||
55 | + if (cpu_isar_feature(aa64_ecv, cpu)) { | ||
56 | + valid_mask |= SCR_ECVEN; | ||
57 | + } | ||
58 | } else { | ||
59 | valid_mask &= ~(SCR_RW | SCR_ST); | ||
60 | if (cpu_isar_feature(aa32_ras, cpu)) { | ||
61 | @@ -XXX,XX +XXX,XX @@ void gt_rme_post_el_change(ARMCPU *cpu, void *ignored) | ||
62 | gt_update_irq(cpu, GTIMER_PHYS); | ||
63 | } | ||
64 | |||
65 | +static uint64_t gt_phys_raw_cnt_offset(CPUARMState *env) | ||
69 | +{ | 66 | +{ |
70 | + tcg_gen_clzi_i32(rd, rm, 32); | 67 | + if ((env->cp15.scr_el3 & SCR_ECVEN) && |
68 | + FIELD_EX64(env->cp15.cnthctl_el2, CNTHCTL, ECV) && | ||
69 | + arm_is_el2_enabled(env) && | ||
70 | + (arm_hcr_el2_eff(env) & (HCR_E2H | HCR_TGE)) != (HCR_E2H | HCR_TGE)) { | ||
71 | + return env->cp15.cntpoff_el2; | ||
72 | + } | ||
73 | + return 0; | ||
71 | +} | 74 | +} |
72 | + | 75 | + |
73 | +static bool trans_VCLZ(DisasContext *s, arg_2misc *a) | 76 | +static uint64_t gt_phys_cnt_offset(CPUARMState *env) |
74 | +{ | 77 | +{ |
75 | + static NeonGenOneOpFn * const fn[] = { | 78 | + if (arm_current_el(env) >= 2) { |
76 | + gen_helper_neon_clz_u8, | 79 | + return 0; |
77 | + gen_helper_neon_clz_u16, | 80 | + } |
78 | + do_VCLZ_32, | 81 | + return gt_phys_raw_cnt_offset(env); |
79 | + NULL, | ||
80 | + }; | ||
81 | + return do_2misc(s, a, fn[a->size]); | ||
82 | +} | 82 | +} |
83 | + | 83 | + |
84 | +static bool trans_VCNT(DisasContext *s, arg_2misc *a) | 84 | static void gt_recalc_timer(ARMCPU *cpu, int timeridx) |
85 | { | ||
86 | ARMGenericTimer *gt = &cpu->env.cp15.c14_timer[timeridx]; | ||
87 | @@ -XXX,XX +XXX,XX @@ static void gt_recalc_timer(ARMCPU *cpu, int timeridx) | ||
88 | * reset timer to when ISTATUS next has to change | ||
89 | */ | ||
90 | uint64_t offset = timeridx == GTIMER_VIRT ? | ||
91 | - cpu->env.cp15.cntvoff_el2 : 0; | ||
92 | + cpu->env.cp15.cntvoff_el2 : gt_phys_raw_cnt_offset(&cpu->env); | ||
93 | uint64_t count = gt_get_countervalue(&cpu->env); | ||
94 | /* Note that this must be unsigned 64 bit arithmetic: */ | ||
95 | int istatus = count - offset >= gt->cval; | ||
96 | @@ -XXX,XX +XXX,XX @@ static void gt_timer_reset(CPUARMState *env, const ARMCPRegInfo *ri, | ||
97 | |||
98 | static uint64_t gt_cnt_read(CPUARMState *env, const ARMCPRegInfo *ri) | ||
99 | { | ||
100 | - return gt_get_countervalue(env); | ||
101 | + return gt_get_countervalue(env) - gt_phys_cnt_offset(env); | ||
102 | } | ||
103 | |||
104 | static uint64_t gt_virt_cnt_offset(CPUARMState *env) | ||
105 | @@ -XXX,XX +XXX,XX @@ static uint64_t gt_tval_read(CPUARMState *env, const ARMCPRegInfo *ri, | ||
106 | case GTIMER_HYPVIRT: | ||
107 | offset = gt_virt_cnt_offset(env); | ||
108 | break; | ||
109 | + case GTIMER_PHYS: | ||
110 | + offset = gt_phys_cnt_offset(env); | ||
111 | + break; | ||
112 | } | ||
113 | |||
114 | return (uint32_t)(env->cp15.c14_timer[timeridx].cval - | ||
115 | @@ -XXX,XX +XXX,XX @@ static void gt_tval_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
116 | case GTIMER_HYPVIRT: | ||
117 | offset = gt_virt_cnt_offset(env); | ||
118 | break; | ||
119 | + case GTIMER_PHYS: | ||
120 | + offset = gt_phys_cnt_offset(env); | ||
121 | + break; | ||
122 | } | ||
123 | |||
124 | trace_arm_gt_tval_write(timeridx, value); | ||
125 | @@ -XXX,XX +XXX,XX @@ static void gt_cnthctl_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
126 | R_CNTHCTL_EL1NVVCT_MASK | | ||
127 | R_CNTHCTL_EVNTIS_MASK; | ||
128 | } | ||
129 | + if (cpu_isar_feature(aa64_ecv, cpu)) { | ||
130 | + valid_mask |= R_CNTHCTL_ECV_MASK; | ||
131 | + } | ||
132 | |||
133 | /* Clear RES0 bits */ | ||
134 | value &= valid_mask; | ||
135 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo gen_timer_ecv_cp_reginfo[] = { | ||
136 | }, | ||
137 | }; | ||
138 | |||
139 | +static CPAccessResult gt_cntpoff_access(CPUARMState *env, | ||
140 | + const ARMCPRegInfo *ri, | ||
141 | + bool isread) | ||
85 | +{ | 142 | +{ |
86 | + if (a->size != 0) { | 143 | + if (arm_current_el(env) == 2 && !(env->cp15.scr_el3 & SCR_ECVEN)) { |
87 | + return false; | 144 | + return CP_ACCESS_TRAP_EL3; |
88 | + } | 145 | + } |
89 | + return do_2misc(s, a, gen_helper_neon_cnt_u8); | 146 | + return CP_ACCESS_OK; |
90 | +} | 147 | +} |
91 | + | 148 | + |
92 | +static bool trans_VABS_F(DisasContext *s, arg_2misc *a) | 149 | +static void gt_cntpoff_write(CPUARMState *env, const ARMCPRegInfo *ri, |
150 | + uint64_t value) | ||
93 | +{ | 151 | +{ |
94 | + if (a->size != 2) { | 152 | + ARMCPU *cpu = env_archcpu(env); |
95 | + return false; | 153 | + |
96 | + } | 154 | + trace_arm_gt_cntpoff_write(value); |
97 | + /* TODO: FP16 : size == 1 */ | 155 | + raw_write(env, ri, value); |
98 | + return do_2misc(s, a, gen_helper_vfp_abss); | 156 | + gt_recalc_timer(cpu, GTIMER_PHYS); |
99 | +} | 157 | +} |
100 | + | 158 | + |
101 | +static bool trans_VNEG_F(DisasContext *s, arg_2misc *a) | 159 | +static const ARMCPRegInfo gen_timer_cntpoff_reginfo = { |
102 | +{ | 160 | + .name = "CNTPOFF_EL2", .state = ARM_CP_STATE_AA64, |
103 | + if (a->size != 2) { | 161 | + .opc0 = 3, .opc1 = 4, .crn = 14, .crm = 0, .opc2 = 6, |
104 | + return false; | 162 | + .access = PL2_RW, .type = ARM_CP_IO, .resetvalue = 0, |
163 | + .accessfn = gt_cntpoff_access, .writefn = gt_cntpoff_write, | ||
164 | + .nv2_redirect_offset = 0x1a8, | ||
165 | + .fieldoffset = offsetof(CPUARMState, cp15.cntpoff_el2), | ||
166 | +}; | ||
167 | #else | ||
168 | |||
169 | /* | ||
170 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
171 | if (cpu_isar_feature(aa64_ecv_traps, cpu)) { | ||
172 | define_arm_cp_regs(cpu, gen_timer_ecv_cp_reginfo); | ||
173 | } | ||
174 | +#ifndef CONFIG_USER_ONLY | ||
175 | + if (cpu_isar_feature(aa64_ecv, cpu)) { | ||
176 | + define_one_arm_cp_reg(cpu, &gen_timer_cntpoff_reginfo); | ||
105 | + } | 177 | + } |
106 | + /* TODO: FP16 : size == 1 */ | 178 | +#endif |
107 | + return do_2misc(s, a, gen_helper_vfp_negs); | 179 | if (arm_feature(env, ARM_FEATURE_VAPA)) { |
108 | +} | 180 | ARMCPRegInfo vapa_cp_reginfo[] = { |
109 | + | 181 | { .name = "PAR", .cp = 15, .crn = 7, .crm = 4, .opc1 = 0, .opc2 = 0, |
110 | +static bool trans_VRECPE(DisasContext *s, arg_2misc *a) | 182 | diff --git a/target/arm/trace-events b/target/arm/trace-events |
111 | +{ | ||
112 | + if (a->size != 2) { | ||
113 | + return false; | ||
114 | + } | ||
115 | + return do_2misc(s, a, gen_helper_recpe_u32); | ||
116 | +} | ||
117 | + | ||
118 | +static bool trans_VRSQRTE(DisasContext *s, arg_2misc *a) | ||
119 | +{ | ||
120 | + if (a->size != 2) { | ||
121 | + return false; | ||
122 | + } | ||
123 | + return do_2misc(s, a, gen_helper_rsqrte_u32); | ||
124 | +} | ||
125 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
126 | index XXXXXXX..XXXXXXX 100644 | 183 | index XXXXXXX..XXXXXXX 100644 |
127 | --- a/target/arm/translate.c | 184 | --- a/target/arm/trace-events |
128 | +++ b/target/arm/translate.c | 185 | +++ b/target/arm/trace-events |
129 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | 186 | @@ -XXX,XX +XXX,XX @@ arm_gt_tval_write(int timer, uint64_t value) "gt_tval_write: timer %d value 0x%" |
130 | case NEON_2RM_SHA1SU1: | 187 | arm_gt_ctl_write(int timer, uint64_t value) "gt_ctl_write: timer %d value 0x%" PRIx64 |
131 | case NEON_2RM_VREV32: | 188 | arm_gt_imask_toggle(int timer) "gt_ctl_write: timer %d IMASK toggle" |
132 | case NEON_2RM_VREV16: | 189 | arm_gt_cntvoff_write(uint64_t value) "gt_cntvoff_write: value 0x%" PRIx64 |
133 | + case NEON_2RM_VCLS: | 190 | +arm_gt_cntpoff_write(uint64_t value) "gt_cntpoff_write: value 0x%" PRIx64 |
134 | + case NEON_2RM_VCLZ: | 191 | arm_gt_update_irq(int timer, int irqstate) "gt_update_irq: timer %d irqstate %d" |
135 | + case NEON_2RM_VCNT: | 192 | |
136 | + case NEON_2RM_VABS_F: | 193 | # kvm.c |
137 | + case NEON_2RM_VNEG_F: | ||
138 | + case NEON_2RM_VRECPE: | ||
139 | + case NEON_2RM_VRSQRTE: | ||
140 | /* handled by decodetree */ | ||
141 | return 1; | ||
142 | case NEON_2RM_VTRN: | ||
143 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
144 | for (pass = 0; pass < (q ? 4 : 2); pass++) { | ||
145 | tmp = neon_load_reg(rm, pass); | ||
146 | switch (op) { | ||
147 | - case NEON_2RM_VCLS: | ||
148 | - switch (size) { | ||
149 | - case 0: gen_helper_neon_cls_s8(tmp, tmp); break; | ||
150 | - case 1: gen_helper_neon_cls_s16(tmp, tmp); break; | ||
151 | - case 2: gen_helper_neon_cls_s32(tmp, tmp); break; | ||
152 | - default: abort(); | ||
153 | - } | ||
154 | - break; | ||
155 | - case NEON_2RM_VCLZ: | ||
156 | - switch (size) { | ||
157 | - case 0: gen_helper_neon_clz_u8(tmp, tmp); break; | ||
158 | - case 1: gen_helper_neon_clz_u16(tmp, tmp); break; | ||
159 | - case 2: tcg_gen_clzi_i32(tmp, tmp, 32); break; | ||
160 | - default: abort(); | ||
161 | - } | ||
162 | - break; | ||
163 | - case NEON_2RM_VCNT: | ||
164 | - gen_helper_neon_cnt_u8(tmp, tmp); | ||
165 | - break; | ||
166 | case NEON_2RM_VQABS: | ||
167 | switch (size) { | ||
168 | case 0: | ||
169 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
170 | tcg_temp_free_ptr(fpstatus); | ||
171 | break; | ||
172 | } | ||
173 | - case NEON_2RM_VABS_F: | ||
174 | - gen_helper_vfp_abss(tmp, tmp); | ||
175 | - break; | ||
176 | - case NEON_2RM_VNEG_F: | ||
177 | - gen_helper_vfp_negs(tmp, tmp); | ||
178 | - break; | ||
179 | case NEON_2RM_VSWP: | ||
180 | tmp2 = neon_load_reg(rd, pass); | ||
181 | neon_store_reg(rm, pass, tmp2); | ||
182 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
183 | tcg_temp_free_ptr(fpst); | ||
184 | break; | ||
185 | } | ||
186 | - case NEON_2RM_VRECPE: | ||
187 | - gen_helper_recpe_u32(tmp, tmp); | ||
188 | - break; | ||
189 | - case NEON_2RM_VRSQRTE: | ||
190 | - gen_helper_rsqrte_u32(tmp, tmp); | ||
191 | - break; | ||
192 | case NEON_2RM_VRECPE_F: | ||
193 | { | ||
194 | TCGv_ptr fpstatus = get_fpstatus_ptr(1); | ||
195 | -- | 194 | -- |
196 | 2.20.1 | 195 | 2.34.1 |
197 | |||
198 | diff view generated by jsdifflib |
1 | Convert the Neon VZIP and VUZP insns in the 2-reg-misc group to | 1 | Enable all FEAT_ECV features on the 'max' CPU. |
---|---|---|---|
2 | decodetree. | ||
3 | 2 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 3 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
6 | Message-id: 20200616170844.13318-4-peter.maydell@linaro.org | 6 | Message-id: 20240301183219.2424889-9-peter.maydell@linaro.org |
7 | --- | 7 | --- |
8 | target/arm/neon-dp.decode | 3 ++ | 8 | docs/system/arm/emulation.rst | 1 + |
9 | target/arm/translate-neon.inc.c | 74 ++++++++++++++++++++++++++ | 9 | target/arm/tcg/cpu64.c | 1 + |
10 | target/arm/translate.c | 92 +-------------------------------- | 10 | 2 files changed, 2 insertions(+) |
11 | 3 files changed, 79 insertions(+), 90 deletions(-) | ||
12 | 11 | ||
13 | diff --git a/target/arm/neon-dp.decode b/target/arm/neon-dp.decode | 12 | diff --git a/docs/system/arm/emulation.rst b/docs/system/arm/emulation.rst |
14 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/neon-dp.decode | 14 | --- a/docs/system/arm/emulation.rst |
16 | +++ b/target/arm/neon-dp.decode | 15 | +++ b/docs/system/arm/emulation.rst |
17 | @@ -XXX,XX +XXX,XX @@ Vimm_1r 1111 001 . 1 . 000 ... .... cmode:4 0 . op:1 1 .... @1reg_imm | 16 | @@ -XXX,XX +XXX,XX @@ the following architecture extensions: |
18 | 17 | - FEAT_DotProd (Advanced SIMD dot product instructions) | |
19 | VPADAL_S 1111 001 11 . 11 .. 00 .... 0 1100 . . 0 .... @2misc | 18 | - FEAT_DoubleFault (Double Fault Extension) |
20 | VPADAL_U 1111 001 11 . 11 .. 00 .... 0 1101 . . 0 .... @2misc | 19 | - FEAT_E0PD (Preventing EL0 access to halves of address maps) |
21 | + | 20 | +- FEAT_ECV (Enhanced Counter Virtualization) |
22 | + VUZP 1111 001 11 . 11 .. 10 .... 0 0010 . . 0 .... @2misc | 21 | - FEAT_EPAC (Enhanced pointer authentication) |
23 | + VZIP 1111 001 11 . 11 .. 10 .... 0 0011 . . 0 .... @2misc | 22 | - FEAT_ETS (Enhanced Translation Synchronization) |
24 | ] | 23 | - FEAT_EVT (Enhanced Virtualization Traps) |
25 | 24 | diff --git a/target/arm/tcg/cpu64.c b/target/arm/tcg/cpu64.c | |
26 | # Subgroup for size != 0b11 | ||
27 | diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c | ||
28 | index XXXXXXX..XXXXXXX 100644 | 25 | index XXXXXXX..XXXXXXX 100644 |
29 | --- a/target/arm/translate-neon.inc.c | 26 | --- a/target/arm/tcg/cpu64.c |
30 | +++ b/target/arm/translate-neon.inc.c | 27 | +++ b/target/arm/tcg/cpu64.c |
31 | @@ -XXX,XX +XXX,XX @@ static bool trans_VPADAL_U(DisasContext *s, arg_2misc *a) | 28 | @@ -XXX,XX +XXX,XX @@ void aarch64_max_tcg_initfn(Object *obj) |
32 | return do_2misc_pairwise(s, a, widenfn[a->size], opfn[a->size], | 29 | t = FIELD_DP64(t, ID_AA64MMFR0, TGRAN64_2, 2); /* 64k stage2 supported */ |
33 | accfn[a->size]); | 30 | t = FIELD_DP64(t, ID_AA64MMFR0, TGRAN4_2, 2); /* 4k stage2 supported */ |
34 | } | 31 | t = FIELD_DP64(t, ID_AA64MMFR0, FGT, 1); /* FEAT_FGT */ |
35 | + | 32 | + t = FIELD_DP64(t, ID_AA64MMFR0, ECV, 2); /* FEAT_ECV */ |
36 | +typedef void ZipFn(TCGv_ptr, TCGv_ptr); | 33 | cpu->isar.id_aa64mmfr0 = t; |
37 | + | 34 | |
38 | +static bool do_zip_uzp(DisasContext *s, arg_2misc *a, | 35 | t = cpu->isar.id_aa64mmfr1; |
39 | + ZipFn *fn) | ||
40 | +{ | ||
41 | + TCGv_ptr pd, pm; | ||
42 | + | ||
43 | + if (!arm_dc_feature(s, ARM_FEATURE_NEON)) { | ||
44 | + return false; | ||
45 | + } | ||
46 | + | ||
47 | + /* UNDEF accesses to D16-D31 if they don't exist. */ | ||
48 | + if (!dc_isar_feature(aa32_simd_r32, s) && | ||
49 | + ((a->vd | a->vm) & 0x10)) { | ||
50 | + return false; | ||
51 | + } | ||
52 | + | ||
53 | + if ((a->vd | a->vm) & a->q) { | ||
54 | + return false; | ||
55 | + } | ||
56 | + | ||
57 | + if (!fn) { | ||
58 | + /* Bad size or size/q combination */ | ||
59 | + return false; | ||
60 | + } | ||
61 | + | ||
62 | + if (!vfp_access_check(s)) { | ||
63 | + return true; | ||
64 | + } | ||
65 | + | ||
66 | + pd = vfp_reg_ptr(true, a->vd); | ||
67 | + pm = vfp_reg_ptr(true, a->vm); | ||
68 | + fn(pd, pm); | ||
69 | + tcg_temp_free_ptr(pd); | ||
70 | + tcg_temp_free_ptr(pm); | ||
71 | + return true; | ||
72 | +} | ||
73 | + | ||
74 | +static bool trans_VUZP(DisasContext *s, arg_2misc *a) | ||
75 | +{ | ||
76 | + static ZipFn * const fn[2][4] = { | ||
77 | + { | ||
78 | + gen_helper_neon_unzip8, | ||
79 | + gen_helper_neon_unzip16, | ||
80 | + NULL, | ||
81 | + NULL, | ||
82 | + }, { | ||
83 | + gen_helper_neon_qunzip8, | ||
84 | + gen_helper_neon_qunzip16, | ||
85 | + gen_helper_neon_qunzip32, | ||
86 | + NULL, | ||
87 | + } | ||
88 | + }; | ||
89 | + return do_zip_uzp(s, a, fn[a->q][a->size]); | ||
90 | +} | ||
91 | + | ||
92 | +static bool trans_VZIP(DisasContext *s, arg_2misc *a) | ||
93 | +{ | ||
94 | + static ZipFn * const fn[2][4] = { | ||
95 | + { | ||
96 | + gen_helper_neon_zip8, | ||
97 | + gen_helper_neon_zip16, | ||
98 | + NULL, | ||
99 | + NULL, | ||
100 | + }, { | ||
101 | + gen_helper_neon_qzip8, | ||
102 | + gen_helper_neon_qzip16, | ||
103 | + gen_helper_neon_qzip32, | ||
104 | + NULL, | ||
105 | + } | ||
106 | + }; | ||
107 | + return do_zip_uzp(s, a, fn[a->q][a->size]); | ||
108 | +} | ||
109 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
110 | index XXXXXXX..XXXXXXX 100644 | ||
111 | --- a/target/arm/translate.c | ||
112 | +++ b/target/arm/translate.c | ||
113 | @@ -XXX,XX +XXX,XX @@ static void gen_exception_return(DisasContext *s, TCGv_i32 pc) | ||
114 | gen_rfe(s, pc, load_cpu_field(spsr)); | ||
115 | } | ||
116 | |||
117 | -static int gen_neon_unzip(int rd, int rm, int size, int q) | ||
118 | -{ | ||
119 | - TCGv_ptr pd, pm; | ||
120 | - | ||
121 | - if (!q && size == 2) { | ||
122 | - return 1; | ||
123 | - } | ||
124 | - pd = vfp_reg_ptr(true, rd); | ||
125 | - pm = vfp_reg_ptr(true, rm); | ||
126 | - if (q) { | ||
127 | - switch (size) { | ||
128 | - case 0: | ||
129 | - gen_helper_neon_qunzip8(pd, pm); | ||
130 | - break; | ||
131 | - case 1: | ||
132 | - gen_helper_neon_qunzip16(pd, pm); | ||
133 | - break; | ||
134 | - case 2: | ||
135 | - gen_helper_neon_qunzip32(pd, pm); | ||
136 | - break; | ||
137 | - default: | ||
138 | - abort(); | ||
139 | - } | ||
140 | - } else { | ||
141 | - switch (size) { | ||
142 | - case 0: | ||
143 | - gen_helper_neon_unzip8(pd, pm); | ||
144 | - break; | ||
145 | - case 1: | ||
146 | - gen_helper_neon_unzip16(pd, pm); | ||
147 | - break; | ||
148 | - default: | ||
149 | - abort(); | ||
150 | - } | ||
151 | - } | ||
152 | - tcg_temp_free_ptr(pd); | ||
153 | - tcg_temp_free_ptr(pm); | ||
154 | - return 0; | ||
155 | -} | ||
156 | - | ||
157 | -static int gen_neon_zip(int rd, int rm, int size, int q) | ||
158 | -{ | ||
159 | - TCGv_ptr pd, pm; | ||
160 | - | ||
161 | - if (!q && size == 2) { | ||
162 | - return 1; | ||
163 | - } | ||
164 | - pd = vfp_reg_ptr(true, rd); | ||
165 | - pm = vfp_reg_ptr(true, rm); | ||
166 | - if (q) { | ||
167 | - switch (size) { | ||
168 | - case 0: | ||
169 | - gen_helper_neon_qzip8(pd, pm); | ||
170 | - break; | ||
171 | - case 1: | ||
172 | - gen_helper_neon_qzip16(pd, pm); | ||
173 | - break; | ||
174 | - case 2: | ||
175 | - gen_helper_neon_qzip32(pd, pm); | ||
176 | - break; | ||
177 | - default: | ||
178 | - abort(); | ||
179 | - } | ||
180 | - } else { | ||
181 | - switch (size) { | ||
182 | - case 0: | ||
183 | - gen_helper_neon_zip8(pd, pm); | ||
184 | - break; | ||
185 | - case 1: | ||
186 | - gen_helper_neon_zip16(pd, pm); | ||
187 | - break; | ||
188 | - default: | ||
189 | - abort(); | ||
190 | - } | ||
191 | - } | ||
192 | - tcg_temp_free_ptr(pd); | ||
193 | - tcg_temp_free_ptr(pm); | ||
194 | - return 0; | ||
195 | -} | ||
196 | - | ||
197 | static void gen_neon_trn_u8(TCGv_i32 t0, TCGv_i32 t1) | ||
198 | { | ||
199 | TCGv_i32 rd, tmp; | ||
200 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
201 | case NEON_2RM_VREV64: | ||
202 | case NEON_2RM_VPADDL: case NEON_2RM_VPADDL_U: | ||
203 | case NEON_2RM_VPADAL: case NEON_2RM_VPADAL_U: | ||
204 | + case NEON_2RM_VUZP: | ||
205 | + case NEON_2RM_VZIP: | ||
206 | /* handled by decodetree */ | ||
207 | return 1; | ||
208 | case NEON_2RM_VTRN: | ||
209 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
210 | goto elementwise; | ||
211 | } | ||
212 | break; | ||
213 | - case NEON_2RM_VUZP: | ||
214 | - if (gen_neon_unzip(rd, rm, size, q)) { | ||
215 | - return 1; | ||
216 | - } | ||
217 | - break; | ||
218 | - case NEON_2RM_VZIP: | ||
219 | - if (gen_neon_zip(rd, rm, size, q)) { | ||
220 | - return 1; | ||
221 | - } | ||
222 | - break; | ||
223 | case NEON_2RM_VMOVN: case NEON_2RM_VQMOVN: | ||
224 | /* also VQMOVUN; op field and mnemonics don't line up */ | ||
225 | if (rm & 1) { | ||
226 | -- | 36 | -- |
227 | 2.20.1 | 37 | 2.34.1 |
228 | 38 | ||
229 | 39 | diff view generated by jsdifflib |
1 | From: David CARLIER <devnexen@gmail.com> | 1 | From: Inès Varhol <ines.varhol@telecom-paris.fr> |
---|---|---|---|
2 | 2 | ||
3 | From 3025a0ce3fdf7d3559fc35a52c659f635f5c750c Mon Sep 17 00:00:00 2001 | 3 | Features supported : |
4 | From: David Carlier <devnexen@gmail.com> | 4 | - the 8 STM32L4x5 GPIOs are initialized with their reset values |
5 | Date: Tue, 26 May 2020 21:35:27 +0100 | 5 | (except IDR, see below) |
6 | Subject: [PATCH] util/oslib-posix : qemu_init_exec_dir implementation for Mac | 6 | - input mode : setting a pin in input mode "externally" (using input |
7 | irqs) results in an out irq (transmitted to SYSCFG) | ||
8 | - output mode : setting a bit in ODR sets the corresponding out irq | ||
9 | (if this line is configured in output mode) | ||
10 | - pull-up, pull-down | ||
11 | - push-pull, open-drain | ||
7 | 12 | ||
8 | Using dyld API to get the full path of the current process. | 13 | Difference with the real GPIOs : |
14 | - Alternate Function and Analog mode aren't implemented : | ||
15 | pins in AF/Analog behave like pins in input mode | ||
16 | - floating pins stay at their last value | ||
17 | - register IDR reset values differ from the real one : | ||
18 | values are coherent with the other registers reset values | ||
19 | and the fact that AF/Analog modes aren't implemented | ||
20 | - setting I/O output speed isn't supported | ||
21 | - locking port bits isn't supported | ||
22 | - ADC function isn't supported | ||
23 | - GPIOH has 16 pins instead of 2 pins | ||
24 | - writing to registers LCKR, AFRL, AFRH and ASCR is ineffective | ||
9 | 25 | ||
10 | Signed-off-by: David Carlier <devnexen@gmail.com> | 26 | Signed-off-by: Arnaud Minier <arnaud.minier@telecom-paris.fr> |
11 | Message-id: CA+XhMqxwC10XHVs4Z-JfE0-WLAU3ztDuU9QKVi31mjr59HWCxg@mail.gmail.com | 27 | Signed-off-by: Inès Varhol <ines.varhol@telecom-paris.fr> |
12 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 28 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
29 | Acked-by: Alistair Francis <alistair.francis@wdc.com> | ||
30 | Message-id: 20240305210444.310665-2-ines.varhol@telecom-paris.fr | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 31 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | --- | 32 | --- |
15 | util/oslib-posix.c | 15 +++++++++++++++ | 33 | MAINTAINERS | 1 + |
16 | 1 file changed, 15 insertions(+) | 34 | docs/system/arm/b-l475e-iot01a.rst | 2 +- |
35 | include/hw/gpio/stm32l4x5_gpio.h | 70 +++++ | ||
36 | hw/gpio/stm32l4x5_gpio.c | 477 +++++++++++++++++++++++++++++ | ||
37 | hw/gpio/Kconfig | 3 + | ||
38 | hw/gpio/meson.build | 1 + | ||
39 | hw/gpio/trace-events | 6 + | ||
40 | 7 files changed, 559 insertions(+), 1 deletion(-) | ||
41 | create mode 100644 include/hw/gpio/stm32l4x5_gpio.h | ||
42 | create mode 100644 hw/gpio/stm32l4x5_gpio.c | ||
17 | 43 | ||
18 | diff --git a/util/oslib-posix.c b/util/oslib-posix.c | 44 | diff --git a/MAINTAINERS b/MAINTAINERS |
19 | index XXXXXXX..XXXXXXX 100644 | 45 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/util/oslib-posix.c | 46 | --- a/MAINTAINERS |
21 | +++ b/util/oslib-posix.c | 47 | +++ b/MAINTAINERS |
48 | @@ -XXX,XX +XXX,XX @@ F: hw/arm/stm32l4x5_soc.c | ||
49 | F: hw/misc/stm32l4x5_exti.c | ||
50 | F: hw/misc/stm32l4x5_syscfg.c | ||
51 | F: hw/misc/stm32l4x5_rcc.c | ||
52 | +F: hw/gpio/stm32l4x5_gpio.c | ||
53 | F: include/hw/*/stm32l4x5_*.h | ||
54 | |||
55 | B-L475E-IOT01A IoT Node | ||
56 | diff --git a/docs/system/arm/b-l475e-iot01a.rst b/docs/system/arm/b-l475e-iot01a.rst | ||
57 | index XXXXXXX..XXXXXXX 100644 | ||
58 | --- a/docs/system/arm/b-l475e-iot01a.rst | ||
59 | +++ b/docs/system/arm/b-l475e-iot01a.rst | ||
60 | @@ -XXX,XX +XXX,XX @@ Currently B-L475E-IOT01A machine's only supports the following devices: | ||
61 | - STM32L4x5 EXTI (Extended interrupts and events controller) | ||
62 | - STM32L4x5 SYSCFG (System configuration controller) | ||
63 | - STM32L4x5 RCC (Reset and clock control) | ||
64 | +- STM32L4x5 GPIOs (General-purpose I/Os) | ||
65 | |||
66 | Missing devices | ||
67 | """"""""""""""" | ||
68 | @@ -XXX,XX +XXX,XX @@ Missing devices | ||
69 | The B-L475E-IOT01A does *not* support the following devices: | ||
70 | |||
71 | - Serial ports (UART) | ||
72 | -- General-purpose I/Os (GPIO) | ||
73 | - Analog to Digital Converter (ADC) | ||
74 | - SPI controller | ||
75 | - Timer controller (TIMER) | ||
76 | diff --git a/include/hw/gpio/stm32l4x5_gpio.h b/include/hw/gpio/stm32l4x5_gpio.h | ||
77 | new file mode 100644 | ||
78 | index XXXXXXX..XXXXXXX | ||
79 | --- /dev/null | ||
80 | +++ b/include/hw/gpio/stm32l4x5_gpio.h | ||
22 | @@ -XXX,XX +XXX,XX @@ | 81 | @@ -XXX,XX +XXX,XX @@ |
23 | #include <lwp.h> | 82 | +/* |
24 | #endif | 83 | + * STM32L4x5 GPIO (General Purpose Input/Ouput) |
25 | 84 | + * | |
26 | +#ifdef __APPLE__ | 85 | + * Copyright (c) 2024 Arnaud Minier <arnaud.minier@telecom-paris.fr> |
27 | +#include <mach-o/dyld.h> | 86 | + * Copyright (c) 2024 Inès Varhol <ines.varhol@telecom-paris.fr> |
87 | + * | ||
88 | + * SPDX-License-Identifier: GPL-2.0-or-later | ||
89 | + * | ||
90 | + * This work is licensed under the terms of the GNU GPL, version 2 or later. | ||
91 | + * See the COPYING file in the top-level directory. | ||
92 | + */ | ||
93 | + | ||
94 | +/* | ||
95 | + * The reference used is the STMicroElectronics RM0351 Reference manual | ||
96 | + * for STM32L4x5 and STM32L4x6 advanced Arm ® -based 32-bit MCUs. | ||
97 | + * https://www.st.com/en/microcontrollers-microprocessors/stm32l4x5/documentation.html | ||
98 | + */ | ||
99 | + | ||
100 | +#ifndef HW_STM32L4X5_GPIO_H | ||
101 | +#define HW_STM32L4X5_GPIO_H | ||
102 | + | ||
103 | +#include "hw/sysbus.h" | ||
104 | +#include "qom/object.h" | ||
105 | + | ||
106 | +#define TYPE_STM32L4X5_GPIO "stm32l4x5-gpio" | ||
107 | +OBJECT_DECLARE_SIMPLE_TYPE(Stm32l4x5GpioState, STM32L4X5_GPIO) | ||
108 | + | ||
109 | +#define GPIO_NUM_PINS 16 | ||
110 | + | ||
111 | +struct Stm32l4x5GpioState { | ||
112 | + SysBusDevice parent_obj; | ||
113 | + | ||
114 | + MemoryRegion mmio; | ||
115 | + | ||
116 | + /* GPIO registers */ | ||
117 | + uint32_t moder; | ||
118 | + uint32_t otyper; | ||
119 | + uint32_t ospeedr; | ||
120 | + uint32_t pupdr; | ||
121 | + uint32_t idr; | ||
122 | + uint32_t odr; | ||
123 | + uint32_t lckr; | ||
124 | + uint32_t afrl; | ||
125 | + uint32_t afrh; | ||
126 | + uint32_t ascr; | ||
127 | + | ||
128 | + /* GPIO registers reset values */ | ||
129 | + uint32_t moder_reset; | ||
130 | + uint32_t ospeedr_reset; | ||
131 | + uint32_t pupdr_reset; | ||
132 | + | ||
133 | + /* | ||
134 | + * External driving of pins. | ||
135 | + * The pins can be set externally through the device | ||
136 | + * anonymous input GPIOs lines under certain conditions. | ||
137 | + * The pin must not be in push-pull output mode, | ||
138 | + * and can't be set high in open-drain mode. | ||
139 | + * Pins driven externally and configured to | ||
140 | + * output mode will in general be "disconnected" | ||
141 | + * (see `get_gpio_pinmask_to_disconnect()`) | ||
142 | + */ | ||
143 | + uint16_t disconnected_pins; | ||
144 | + uint16_t pins_connected_high; | ||
145 | + | ||
146 | + char *name; | ||
147 | + Clock *clk; | ||
148 | + qemu_irq pin[GPIO_NUM_PINS]; | ||
149 | +}; | ||
150 | + | ||
28 | +#endif | 151 | +#endif |
29 | + | 152 | diff --git a/hw/gpio/stm32l4x5_gpio.c b/hw/gpio/stm32l4x5_gpio.c |
30 | #include "qemu/mmap-alloc.h" | 153 | new file mode 100644 |
31 | 154 | index XXXXXXX..XXXXXXX | |
32 | #ifdef CONFIG_DEBUG_STACK_USAGE | 155 | --- /dev/null |
33 | @@ -XXX,XX +XXX,XX @@ void qemu_init_exec_dir(const char *argv0) | 156 | +++ b/hw/gpio/stm32l4x5_gpio.c |
34 | p = buf; | 157 | @@ -XXX,XX +XXX,XX @@ |
35 | } | 158 | +/* |
36 | } | 159 | + * STM32L4x5 GPIO (General Purpose Input/Ouput) |
37 | +#elif defined(__APPLE__) | 160 | + * |
38 | + { | 161 | + * Copyright (c) 2024 Arnaud Minier <arnaud.minier@telecom-paris.fr> |
39 | + char fpath[PATH_MAX]; | 162 | + * Copyright (c) 2024 Inès Varhol <ines.varhol@telecom-paris.fr> |
40 | + uint32_t len = sizeof(fpath); | 163 | + * |
41 | + if (_NSGetExecutablePath(fpath, &len) == 0) { | 164 | + * SPDX-License-Identifier: GPL-2.0-or-later |
42 | + p = realpath(fpath, buf); | 165 | + * |
43 | + if (!p) { | 166 | + * This work is licensed under the terms of the GNU GPL, version 2 or later. |
44 | + return; | 167 | + * See the COPYING file in the top-level directory. |
168 | + */ | ||
169 | + | ||
170 | +/* | ||
171 | + * The reference used is the STMicroElectronics RM0351 Reference manual | ||
172 | + * for STM32L4x5 and STM32L4x6 advanced Arm ® -based 32-bit MCUs. | ||
173 | + * https://www.st.com/en/microcontrollers-microprocessors/stm32l4x5/documentation.html | ||
174 | + */ | ||
175 | + | ||
176 | +#include "qemu/osdep.h" | ||
177 | +#include "qemu/log.h" | ||
178 | +#include "hw/gpio/stm32l4x5_gpio.h" | ||
179 | +#include "hw/irq.h" | ||
180 | +#include "hw/qdev-clock.h" | ||
181 | +#include "hw/qdev-properties.h" | ||
182 | +#include "qapi/visitor.h" | ||
183 | +#include "qapi/error.h" | ||
184 | +#include "migration/vmstate.h" | ||
185 | +#include "trace.h" | ||
186 | + | ||
187 | +#define GPIO_MODER 0x00 | ||
188 | +#define GPIO_OTYPER 0x04 | ||
189 | +#define GPIO_OSPEEDR 0x08 | ||
190 | +#define GPIO_PUPDR 0x0C | ||
191 | +#define GPIO_IDR 0x10 | ||
192 | +#define GPIO_ODR 0x14 | ||
193 | +#define GPIO_BSRR 0x18 | ||
194 | +#define GPIO_LCKR 0x1C | ||
195 | +#define GPIO_AFRL 0x20 | ||
196 | +#define GPIO_AFRH 0x24 | ||
197 | +#define GPIO_BRR 0x28 | ||
198 | +#define GPIO_ASCR 0x2C | ||
199 | + | ||
200 | +/* 0b11111111_11111111_00000000_00000000 */ | ||
201 | +#define RESERVED_BITS_MASK 0xFFFF0000 | ||
202 | + | ||
203 | +static void update_gpio_idr(Stm32l4x5GpioState *s); | ||
204 | + | ||
205 | +static bool is_pull_up(Stm32l4x5GpioState *s, unsigned pin) | ||
206 | +{ | ||
207 | + return extract32(s->pupdr, 2 * pin, 2) == 1; | ||
208 | +} | ||
209 | + | ||
210 | +static bool is_pull_down(Stm32l4x5GpioState *s, unsigned pin) | ||
211 | +{ | ||
212 | + return extract32(s->pupdr, 2 * pin, 2) == 2; | ||
213 | +} | ||
214 | + | ||
215 | +static bool is_output(Stm32l4x5GpioState *s, unsigned pin) | ||
216 | +{ | ||
217 | + return extract32(s->moder, 2 * pin, 2) == 1; | ||
218 | +} | ||
219 | + | ||
220 | +static bool is_open_drain(Stm32l4x5GpioState *s, unsigned pin) | ||
221 | +{ | ||
222 | + return extract32(s->otyper, pin, 1) == 1; | ||
223 | +} | ||
224 | + | ||
225 | +static bool is_push_pull(Stm32l4x5GpioState *s, unsigned pin) | ||
226 | +{ | ||
227 | + return extract32(s->otyper, pin, 1) == 0; | ||
228 | +} | ||
229 | + | ||
230 | +static void stm32l4x5_gpio_reset_hold(Object *obj) | ||
231 | +{ | ||
232 | + Stm32l4x5GpioState *s = STM32L4X5_GPIO(obj); | ||
233 | + | ||
234 | + s->moder = s->moder_reset; | ||
235 | + s->otyper = 0x00000000; | ||
236 | + s->ospeedr = s->ospeedr_reset; | ||
237 | + s->pupdr = s->pupdr_reset; | ||
238 | + s->idr = 0x00000000; | ||
239 | + s->odr = 0x00000000; | ||
240 | + s->lckr = 0x00000000; | ||
241 | + s->afrl = 0x00000000; | ||
242 | + s->afrh = 0x00000000; | ||
243 | + s->ascr = 0x00000000; | ||
244 | + | ||
245 | + s->disconnected_pins = 0xFFFF; | ||
246 | + s->pins_connected_high = 0x0000; | ||
247 | + update_gpio_idr(s); | ||
248 | +} | ||
249 | + | ||
250 | +static void stm32l4x5_gpio_set(void *opaque, int line, int level) | ||
251 | +{ | ||
252 | + Stm32l4x5GpioState *s = opaque; | ||
253 | + /* | ||
254 | + * The pin isn't set if line is configured in output mode | ||
255 | + * except if level is 0 and the output is open-drain. | ||
256 | + * This way there will be no short-circuit prone situations. | ||
257 | + */ | ||
258 | + if (is_output(s, line) && !(is_open_drain(s, line) && (level == 0))) { | ||
259 | + qemu_log_mask(LOG_GUEST_ERROR, "Line %d can't be driven externally\n", | ||
260 | + line); | ||
261 | + return; | ||
262 | + } | ||
263 | + | ||
264 | + s->disconnected_pins &= ~(1 << line); | ||
265 | + if (level) { | ||
266 | + s->pins_connected_high |= (1 << line); | ||
267 | + } else { | ||
268 | + s->pins_connected_high &= ~(1 << line); | ||
269 | + } | ||
270 | + trace_stm32l4x5_gpio_pins(s->name, s->disconnected_pins, | ||
271 | + s->pins_connected_high); | ||
272 | + update_gpio_idr(s); | ||
273 | +} | ||
274 | + | ||
275 | + | ||
276 | +static void update_gpio_idr(Stm32l4x5GpioState *s) | ||
277 | +{ | ||
278 | + uint32_t new_idr_mask = 0; | ||
279 | + uint32_t new_idr = s->odr; | ||
280 | + uint32_t old_idr = s->idr; | ||
281 | + int new_pin_state, old_pin_state; | ||
282 | + | ||
283 | + for (int i = 0; i < GPIO_NUM_PINS; i++) { | ||
284 | + if (is_output(s, i)) { | ||
285 | + if (is_push_pull(s, i)) { | ||
286 | + new_idr_mask |= (1 << i); | ||
287 | + } else if (!(s->odr & (1 << i))) { | ||
288 | + /* open-drain ODR 0 */ | ||
289 | + new_idr_mask |= (1 << i); | ||
290 | + /* open-drain ODR 1 */ | ||
291 | + } else if (!(s->disconnected_pins & (1 << i)) && | ||
292 | + !(s->pins_connected_high & (1 << i))) { | ||
293 | + /* open-drain ODR 1 with pin connected low */ | ||
294 | + new_idr_mask |= (1 << i); | ||
295 | + new_idr &= ~(1 << i); | ||
296 | + /* open-drain ODR 1 with unactive pin */ | ||
297 | + } else if (is_pull_up(s, i)) { | ||
298 | + new_idr_mask |= (1 << i); | ||
299 | + } else if (is_pull_down(s, i)) { | ||
300 | + new_idr_mask |= (1 << i); | ||
301 | + new_idr &= ~(1 << i); | ||
302 | + } | ||
303 | + /* | ||
304 | + * The only case left is for open-drain ODR 1 | ||
305 | + * with unactive pin without pull-up or pull-down : | ||
306 | + * the value is floating. | ||
307 | + */ | ||
308 | + /* input or analog mode with connected pin */ | ||
309 | + } else if (!(s->disconnected_pins & (1 << i))) { | ||
310 | + if (s->pins_connected_high & (1 << i)) { | ||
311 | + /* pin high */ | ||
312 | + new_idr_mask |= (1 << i); | ||
313 | + new_idr |= (1 << i); | ||
314 | + } else { | ||
315 | + /* pin low */ | ||
316 | + new_idr_mask |= (1 << i); | ||
317 | + new_idr &= ~(1 << i); | ||
318 | + } | ||
319 | + /* input or analog mode with disconnected pin */ | ||
320 | + } else { | ||
321 | + if (is_pull_up(s, i)) { | ||
322 | + /* pull-up */ | ||
323 | + new_idr_mask |= (1 << i); | ||
324 | + new_idr |= (1 << i); | ||
325 | + } else if (is_pull_down(s, i)) { | ||
326 | + /* pull-down */ | ||
327 | + new_idr_mask |= (1 << i); | ||
328 | + new_idr &= ~(1 << i); | ||
329 | + } | ||
330 | + /* | ||
331 | + * The only case left is for a disconnected pin | ||
332 | + * without pull-up or pull-down : | ||
333 | + * the value is floating. | ||
334 | + */ | ||
335 | + } | ||
336 | + } | ||
337 | + | ||
338 | + s->idr = (old_idr & ~new_idr_mask) | (new_idr & new_idr_mask); | ||
339 | + trace_stm32l4x5_gpio_update_idr(s->name, old_idr, s->idr); | ||
340 | + | ||
341 | + for (int i = 0; i < GPIO_NUM_PINS; i++) { | ||
342 | + if (new_idr_mask & (1 << i)) { | ||
343 | + new_pin_state = (new_idr & (1 << i)) > 0; | ||
344 | + old_pin_state = (old_idr & (1 << i)) > 0; | ||
345 | + if (new_pin_state > old_pin_state) { | ||
346 | + qemu_irq_raise(s->pin[i]); | ||
347 | + } else if (new_pin_state < old_pin_state) { | ||
348 | + qemu_irq_lower(s->pin[i]); | ||
45 | + } | 349 | + } |
46 | + } | 350 | + } |
47 | + } | 351 | + } |
48 | #endif | 352 | +} |
49 | /* If we don't have any way of figuring out the actual executable | 353 | + |
50 | location then try argv[0]. */ | 354 | +/* |
355 | + * Return mask of pins that are both configured in output | ||
356 | + * mode and externally driven (except pins in open-drain | ||
357 | + * mode externally set to 0). | ||
358 | + */ | ||
359 | +static uint32_t get_gpio_pinmask_to_disconnect(Stm32l4x5GpioState *s) | ||
360 | +{ | ||
361 | + uint32_t pins_to_disconnect = 0; | ||
362 | + for (int i = 0; i < GPIO_NUM_PINS; i++) { | ||
363 | + /* for each connected pin in output mode */ | ||
364 | + if (!(s->disconnected_pins & (1 << i)) && is_output(s, i)) { | ||
365 | + /* if either push-pull or high level */ | ||
366 | + if (is_push_pull(s, i) || s->pins_connected_high & (1 << i)) { | ||
367 | + pins_to_disconnect |= (1 << i); | ||
368 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
369 | + "Line %d can't be driven externally\n", | ||
370 | + i); | ||
371 | + } | ||
372 | + } | ||
373 | + } | ||
374 | + return pins_to_disconnect; | ||
375 | +} | ||
376 | + | ||
377 | +/* | ||
378 | + * Set field `disconnected_pins` and call `update_gpio_idr()` | ||
379 | + */ | ||
380 | +static void disconnect_gpio_pins(Stm32l4x5GpioState *s, uint16_t lines) | ||
381 | +{ | ||
382 | + s->disconnected_pins |= lines; | ||
383 | + trace_stm32l4x5_gpio_pins(s->name, s->disconnected_pins, | ||
384 | + s->pins_connected_high); | ||
385 | + update_gpio_idr(s); | ||
386 | +} | ||
387 | + | ||
388 | +static void disconnected_pins_set(Object *obj, Visitor *v, | ||
389 | + const char *name, void *opaque, Error **errp) | ||
390 | +{ | ||
391 | + Stm32l4x5GpioState *s = STM32L4X5_GPIO(obj); | ||
392 | + uint16_t value; | ||
393 | + if (!visit_type_uint16(v, name, &value, errp)) { | ||
394 | + return; | ||
395 | + } | ||
396 | + disconnect_gpio_pins(s, value); | ||
397 | +} | ||
398 | + | ||
399 | +static void disconnected_pins_get(Object *obj, Visitor *v, | ||
400 | + const char *name, void *opaque, Error **errp) | ||
401 | +{ | ||
402 | + visit_type_uint16(v, name, (uint16_t *)opaque, errp); | ||
403 | +} | ||
404 | + | ||
405 | +static void clock_freq_get(Object *obj, Visitor *v, | ||
406 | + const char *name, void *opaque, Error **errp) | ||
407 | +{ | ||
408 | + Stm32l4x5GpioState *s = STM32L4X5_GPIO(obj); | ||
409 | + uint32_t clock_freq_hz = clock_get_hz(s->clk); | ||
410 | + visit_type_uint32(v, name, &clock_freq_hz, errp); | ||
411 | +} | ||
412 | + | ||
413 | +static void stm32l4x5_gpio_write(void *opaque, hwaddr addr, | ||
414 | + uint64_t val64, unsigned int size) | ||
415 | +{ | ||
416 | + Stm32l4x5GpioState *s = opaque; | ||
417 | + | ||
418 | + uint32_t value = val64; | ||
419 | + trace_stm32l4x5_gpio_write(s->name, addr, val64); | ||
420 | + | ||
421 | + switch (addr) { | ||
422 | + case GPIO_MODER: | ||
423 | + s->moder = value; | ||
424 | + disconnect_gpio_pins(s, get_gpio_pinmask_to_disconnect(s)); | ||
425 | + qemu_log_mask(LOG_UNIMP, | ||
426 | + "%s: Analog and AF modes aren't supported\n\ | ||
427 | + Analog and AF mode behave like input mode\n", | ||
428 | + __func__); | ||
429 | + return; | ||
430 | + case GPIO_OTYPER: | ||
431 | + s->otyper = value & ~RESERVED_BITS_MASK; | ||
432 | + disconnect_gpio_pins(s, get_gpio_pinmask_to_disconnect(s)); | ||
433 | + return; | ||
434 | + case GPIO_OSPEEDR: | ||
435 | + qemu_log_mask(LOG_UNIMP, | ||
436 | + "%s: Changing I/O output speed isn't supported\n\ | ||
437 | + I/O speed is already maximal\n", | ||
438 | + __func__); | ||
439 | + s->ospeedr = value; | ||
440 | + return; | ||
441 | + case GPIO_PUPDR: | ||
442 | + s->pupdr = value; | ||
443 | + update_gpio_idr(s); | ||
444 | + return; | ||
445 | + case GPIO_IDR: | ||
446 | + qemu_log_mask(LOG_UNIMP, | ||
447 | + "%s: GPIO->IDR is read-only\n", | ||
448 | + __func__); | ||
449 | + return; | ||
450 | + case GPIO_ODR: | ||
451 | + s->odr = value & ~RESERVED_BITS_MASK; | ||
452 | + update_gpio_idr(s); | ||
453 | + return; | ||
454 | + case GPIO_BSRR: { | ||
455 | + uint32_t bits_to_reset = (value & RESERVED_BITS_MASK) >> GPIO_NUM_PINS; | ||
456 | + uint32_t bits_to_set = value & ~RESERVED_BITS_MASK; | ||
457 | + /* If both BSx and BRx are set, BSx has priority.*/ | ||
458 | + s->odr &= ~bits_to_reset; | ||
459 | + s->odr |= bits_to_set; | ||
460 | + update_gpio_idr(s); | ||
461 | + return; | ||
462 | + } | ||
463 | + case GPIO_LCKR: | ||
464 | + qemu_log_mask(LOG_UNIMP, | ||
465 | + "%s: Locking port bits configuration isn't supported\n", | ||
466 | + __func__); | ||
467 | + s->lckr = value & ~RESERVED_BITS_MASK; | ||
468 | + return; | ||
469 | + case GPIO_AFRL: | ||
470 | + qemu_log_mask(LOG_UNIMP, | ||
471 | + "%s: Alternate functions aren't supported\n", | ||
472 | + __func__); | ||
473 | + s->afrl = value; | ||
474 | + return; | ||
475 | + case GPIO_AFRH: | ||
476 | + qemu_log_mask(LOG_UNIMP, | ||
477 | + "%s: Alternate functions aren't supported\n", | ||
478 | + __func__); | ||
479 | + s->afrh = value; | ||
480 | + return; | ||
481 | + case GPIO_BRR: { | ||
482 | + uint32_t bits_to_reset = value & ~RESERVED_BITS_MASK; | ||
483 | + s->odr &= ~bits_to_reset; | ||
484 | + update_gpio_idr(s); | ||
485 | + return; | ||
486 | + } | ||
487 | + case GPIO_ASCR: | ||
488 | + qemu_log_mask(LOG_UNIMP, | ||
489 | + "%s: ADC function isn't supported\n", | ||
490 | + __func__); | ||
491 | + s->ascr = value & ~RESERVED_BITS_MASK; | ||
492 | + return; | ||
493 | + default: | ||
494 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
495 | + "%s: Bad offset 0x%" HWADDR_PRIx "\n", __func__, addr); | ||
496 | + } | ||
497 | +} | ||
498 | + | ||
499 | +static uint64_t stm32l4x5_gpio_read(void *opaque, hwaddr addr, | ||
500 | + unsigned int size) | ||
501 | +{ | ||
502 | + Stm32l4x5GpioState *s = opaque; | ||
503 | + | ||
504 | + trace_stm32l4x5_gpio_read(s->name, addr); | ||
505 | + | ||
506 | + switch (addr) { | ||
507 | + case GPIO_MODER: | ||
508 | + return s->moder; | ||
509 | + case GPIO_OTYPER: | ||
510 | + return s->otyper; | ||
511 | + case GPIO_OSPEEDR: | ||
512 | + return s->ospeedr; | ||
513 | + case GPIO_PUPDR: | ||
514 | + return s->pupdr; | ||
515 | + case GPIO_IDR: | ||
516 | + return s->idr; | ||
517 | + case GPIO_ODR: | ||
518 | + return s->odr; | ||
519 | + case GPIO_BSRR: | ||
520 | + return 0; | ||
521 | + case GPIO_LCKR: | ||
522 | + return s->lckr; | ||
523 | + case GPIO_AFRL: | ||
524 | + return s->afrl; | ||
525 | + case GPIO_AFRH: | ||
526 | + return s->afrh; | ||
527 | + case GPIO_BRR: | ||
528 | + return 0; | ||
529 | + case GPIO_ASCR: | ||
530 | + return s->ascr; | ||
531 | + default: | ||
532 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
533 | + "%s: Bad offset 0x%" HWADDR_PRIx "\n", __func__, addr); | ||
534 | + return 0; | ||
535 | + } | ||
536 | +} | ||
537 | + | ||
538 | +static const MemoryRegionOps stm32l4x5_gpio_ops = { | ||
539 | + .read = stm32l4x5_gpio_read, | ||
540 | + .write = stm32l4x5_gpio_write, | ||
541 | + .endianness = DEVICE_NATIVE_ENDIAN, | ||
542 | + .impl = { | ||
543 | + .min_access_size = 4, | ||
544 | + .max_access_size = 4, | ||
545 | + .unaligned = false, | ||
546 | + }, | ||
547 | + .valid = { | ||
548 | + .min_access_size = 4, | ||
549 | + .max_access_size = 4, | ||
550 | + .unaligned = false, | ||
551 | + }, | ||
552 | +}; | ||
553 | + | ||
554 | +static void stm32l4x5_gpio_init(Object *obj) | ||
555 | +{ | ||
556 | + Stm32l4x5GpioState *s = STM32L4X5_GPIO(obj); | ||
557 | + | ||
558 | + memory_region_init_io(&s->mmio, obj, &stm32l4x5_gpio_ops, s, | ||
559 | + TYPE_STM32L4X5_GPIO, 0x400); | ||
560 | + | ||
561 | + sysbus_init_mmio(SYS_BUS_DEVICE(obj), &s->mmio); | ||
562 | + | ||
563 | + qdev_init_gpio_out(DEVICE(obj), s->pin, GPIO_NUM_PINS); | ||
564 | + qdev_init_gpio_in(DEVICE(obj), stm32l4x5_gpio_set, GPIO_NUM_PINS); | ||
565 | + | ||
566 | + s->clk = qdev_init_clock_in(DEVICE(s), "clk", NULL, s, 0); | ||
567 | + | ||
568 | + object_property_add(obj, "disconnected-pins", "uint16", | ||
569 | + disconnected_pins_get, disconnected_pins_set, | ||
570 | + NULL, &s->disconnected_pins); | ||
571 | + object_property_add(obj, "clock-freq-hz", "uint32", | ||
572 | + clock_freq_get, NULL, NULL, NULL); | ||
573 | +} | ||
574 | + | ||
575 | +static void stm32l4x5_gpio_realize(DeviceState *dev, Error **errp) | ||
576 | +{ | ||
577 | + Stm32l4x5GpioState *s = STM32L4X5_GPIO(dev); | ||
578 | + if (!clock_has_source(s->clk)) { | ||
579 | + error_setg(errp, "GPIO: clk input must be connected"); | ||
580 | + return; | ||
581 | + } | ||
582 | +} | ||
583 | + | ||
584 | +static const VMStateDescription vmstate_stm32l4x5_gpio = { | ||
585 | + .name = TYPE_STM32L4X5_GPIO, | ||
586 | + .version_id = 1, | ||
587 | + .minimum_version_id = 1, | ||
588 | + .fields = (VMStateField[]){ | ||
589 | + VMSTATE_UINT32(moder, Stm32l4x5GpioState), | ||
590 | + VMSTATE_UINT32(otyper, Stm32l4x5GpioState), | ||
591 | + VMSTATE_UINT32(ospeedr, Stm32l4x5GpioState), | ||
592 | + VMSTATE_UINT32(pupdr, Stm32l4x5GpioState), | ||
593 | + VMSTATE_UINT32(idr, Stm32l4x5GpioState), | ||
594 | + VMSTATE_UINT32(odr, Stm32l4x5GpioState), | ||
595 | + VMSTATE_UINT32(lckr, Stm32l4x5GpioState), | ||
596 | + VMSTATE_UINT32(afrl, Stm32l4x5GpioState), | ||
597 | + VMSTATE_UINT32(afrh, Stm32l4x5GpioState), | ||
598 | + VMSTATE_UINT32(ascr, Stm32l4x5GpioState), | ||
599 | + VMSTATE_UINT16(disconnected_pins, Stm32l4x5GpioState), | ||
600 | + VMSTATE_UINT16(pins_connected_high, Stm32l4x5GpioState), | ||
601 | + VMSTATE_END_OF_LIST() | ||
602 | + } | ||
603 | +}; | ||
604 | + | ||
605 | +static Property stm32l4x5_gpio_properties[] = { | ||
606 | + DEFINE_PROP_STRING("name", Stm32l4x5GpioState, name), | ||
607 | + DEFINE_PROP_UINT32("mode-reset", Stm32l4x5GpioState, moder_reset, 0), | ||
608 | + DEFINE_PROP_UINT32("ospeed-reset", Stm32l4x5GpioState, ospeedr_reset, 0), | ||
609 | + DEFINE_PROP_UINT32("pupd-reset", Stm32l4x5GpioState, pupdr_reset, 0), | ||
610 | + DEFINE_PROP_END_OF_LIST(), | ||
611 | +}; | ||
612 | + | ||
613 | +static void stm32l4x5_gpio_class_init(ObjectClass *klass, void *data) | ||
614 | +{ | ||
615 | + DeviceClass *dc = DEVICE_CLASS(klass); | ||
616 | + ResettableClass *rc = RESETTABLE_CLASS(klass); | ||
617 | + | ||
618 | + device_class_set_props(dc, stm32l4x5_gpio_properties); | ||
619 | + dc->vmsd = &vmstate_stm32l4x5_gpio; | ||
620 | + dc->realize = stm32l4x5_gpio_realize; | ||
621 | + rc->phases.hold = stm32l4x5_gpio_reset_hold; | ||
622 | +} | ||
623 | + | ||
624 | +static const TypeInfo stm32l4x5_gpio_types[] = { | ||
625 | + { | ||
626 | + .name = TYPE_STM32L4X5_GPIO, | ||
627 | + .parent = TYPE_SYS_BUS_DEVICE, | ||
628 | + .instance_size = sizeof(Stm32l4x5GpioState), | ||
629 | + .instance_init = stm32l4x5_gpio_init, | ||
630 | + .class_init = stm32l4x5_gpio_class_init, | ||
631 | + }, | ||
632 | +}; | ||
633 | + | ||
634 | +DEFINE_TYPES(stm32l4x5_gpio_types) | ||
635 | diff --git a/hw/gpio/Kconfig b/hw/gpio/Kconfig | ||
636 | index XXXXXXX..XXXXXXX 100644 | ||
637 | --- a/hw/gpio/Kconfig | ||
638 | +++ b/hw/gpio/Kconfig | ||
639 | @@ -XXX,XX +XXX,XX @@ config GPIO_PWR | ||
640 | |||
641 | config SIFIVE_GPIO | ||
642 | bool | ||
643 | + | ||
644 | +config STM32L4X5_GPIO | ||
645 | + bool | ||
646 | diff --git a/hw/gpio/meson.build b/hw/gpio/meson.build | ||
647 | index XXXXXXX..XXXXXXX 100644 | ||
648 | --- a/hw/gpio/meson.build | ||
649 | +++ b/hw/gpio/meson.build | ||
650 | @@ -XXX,XX +XXX,XX @@ system_ss.add(when: 'CONFIG_RASPI', if_true: files( | ||
651 | 'bcm2835_gpio.c', | ||
652 | 'bcm2838_gpio.c' | ||
653 | )) | ||
654 | +system_ss.add(when: 'CONFIG_STM32L4X5_SOC', if_true: files('stm32l4x5_gpio.c')) | ||
655 | system_ss.add(when: 'CONFIG_ASPEED_SOC', if_true: files('aspeed_gpio.c')) | ||
656 | system_ss.add(when: 'CONFIG_SIFIVE_GPIO', if_true: files('sifive_gpio.c')) | ||
657 | diff --git a/hw/gpio/trace-events b/hw/gpio/trace-events | ||
658 | index XXXXXXX..XXXXXXX 100644 | ||
659 | --- a/hw/gpio/trace-events | ||
660 | +++ b/hw/gpio/trace-events | ||
661 | @@ -XXX,XX +XXX,XX @@ sifive_gpio_update_output_irq(int64_t line, int64_t value) "line %" PRIi64 " val | ||
662 | # aspeed_gpio.c | ||
663 | aspeed_gpio_read(uint64_t offset, uint64_t value) "offset: 0x%" PRIx64 " value 0x%" PRIx64 | ||
664 | aspeed_gpio_write(uint64_t offset, uint64_t value) "offset: 0x%" PRIx64 " value 0x%" PRIx64 | ||
665 | + | ||
666 | +# stm32l4x5_gpio.c | ||
667 | +stm32l4x5_gpio_read(char *gpio, uint64_t addr) "GPIO%s addr: 0x%" PRIx64 " " | ||
668 | +stm32l4x5_gpio_write(char *gpio, uint64_t addr, uint64_t data) "GPIO%s addr: 0x%" PRIx64 " val: 0x%" PRIx64 "" | ||
669 | +stm32l4x5_gpio_update_idr(char *gpio, uint32_t old_idr, uint32_t new_idr) "GPIO%s from: 0x%x to: 0x%x" | ||
670 | +stm32l4x5_gpio_pins(char *gpio, uint16_t disconnected, uint16_t high) "GPIO%s disconnected pins: 0x%x levels: 0x%x" | ||
51 | -- | 671 | -- |
52 | 2.20.1 | 672 | 2.34.1 |
53 | 673 | ||
54 | 674 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Convert the Neon VREV64 insn from the 2-reg-misc grouping to decodetree. | ||
2 | 1 | ||
3 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Message-id: 20200616170844.13318-2-peter.maydell@linaro.org | ||
6 | --- | ||
7 | target/arm/neon-dp.decode | 12 ++++++++ | ||
8 | target/arm/translate-neon.inc.c | 50 +++++++++++++++++++++++++++++++++ | ||
9 | target/arm/translate.c | 24 ++-------------- | ||
10 | 3 files changed, 64 insertions(+), 22 deletions(-) | ||
11 | |||
12 | diff --git a/target/arm/neon-dp.decode b/target/arm/neon-dp.decode | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/target/arm/neon-dp.decode | ||
15 | +++ b/target/arm/neon-dp.decode | ||
16 | @@ -XXX,XX +XXX,XX @@ Vimm_1r 1111 001 . 1 . 000 ... .... cmode:4 0 . op:1 1 .... @1reg_imm | ||
17 | vm=%vm_dp vd=%vd_dp size=1 | ||
18 | VDUP_scalar 1111 001 1 1 . 11 index:1 100 .... 11 000 q:1 . 0 .... \ | ||
19 | vm=%vm_dp vd=%vd_dp size=2 | ||
20 | + | ||
21 | + ################################################################## | ||
22 | + # 2-reg-misc grouping: | ||
23 | + # 1111 001 11 D 11 size:2 opc1:2 Vd:4 0 opc2:4 q:1 M 0 Vm:4 | ||
24 | + ################################################################## | ||
25 | + | ||
26 | + &2misc vd vm q size | ||
27 | + | ||
28 | + @2misc .... ... .. . .. size:2 .. .... . .... q:1 . . .... \ | ||
29 | + &2misc vm=%vm_dp vd=%vd_dp | ||
30 | + | ||
31 | + VREV64 1111 001 11 . 11 .. 00 .... 0 0000 . . 0 .... @2misc | ||
32 | ] | ||
33 | |||
34 | # Subgroup for size != 0b11 | ||
35 | diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c | ||
36 | index XXXXXXX..XXXXXXX 100644 | ||
37 | --- a/target/arm/translate-neon.inc.c | ||
38 | +++ b/target/arm/translate-neon.inc.c | ||
39 | @@ -XXX,XX +XXX,XX @@ static bool trans_VDUP_scalar(DisasContext *s, arg_VDUP_scalar *a) | ||
40 | a->q ? 16 : 8, a->q ? 16 : 8); | ||
41 | return true; | ||
42 | } | ||
43 | + | ||
44 | +static bool trans_VREV64(DisasContext *s, arg_VREV64 *a) | ||
45 | +{ | ||
46 | + int pass, half; | ||
47 | + | ||
48 | + if (!arm_dc_feature(s, ARM_FEATURE_NEON)) { | ||
49 | + return false; | ||
50 | + } | ||
51 | + | ||
52 | + /* UNDEF accesses to D16-D31 if they don't exist. */ | ||
53 | + if (!dc_isar_feature(aa32_simd_r32, s) && | ||
54 | + ((a->vd | a->vm) & 0x10)) { | ||
55 | + return false; | ||
56 | + } | ||
57 | + | ||
58 | + if ((a->vd | a->vm) & a->q) { | ||
59 | + return false; | ||
60 | + } | ||
61 | + | ||
62 | + if (a->size == 3) { | ||
63 | + return false; | ||
64 | + } | ||
65 | + | ||
66 | + if (!vfp_access_check(s)) { | ||
67 | + return true; | ||
68 | + } | ||
69 | + | ||
70 | + for (pass = 0; pass < (a->q ? 2 : 1); pass++) { | ||
71 | + TCGv_i32 tmp[2]; | ||
72 | + | ||
73 | + for (half = 0; half < 2; half++) { | ||
74 | + tmp[half] = neon_load_reg(a->vm, pass * 2 + half); | ||
75 | + switch (a->size) { | ||
76 | + case 0: | ||
77 | + tcg_gen_bswap32_i32(tmp[half], tmp[half]); | ||
78 | + break; | ||
79 | + case 1: | ||
80 | + gen_swap_half(tmp[half]); | ||
81 | + break; | ||
82 | + case 2: | ||
83 | + break; | ||
84 | + default: | ||
85 | + g_assert_not_reached(); | ||
86 | + } | ||
87 | + } | ||
88 | + neon_store_reg(a->vd, pass * 2, tmp[1]); | ||
89 | + neon_store_reg(a->vd, pass * 2 + 1, tmp[0]); | ||
90 | + } | ||
91 | + return true; | ||
92 | +} | ||
93 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
94 | index XXXXXXX..XXXXXXX 100644 | ||
95 | --- a/target/arm/translate.c | ||
96 | +++ b/target/arm/translate.c | ||
97 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
98 | } | ||
99 | switch (op) { | ||
100 | case NEON_2RM_VREV64: | ||
101 | - for (pass = 0; pass < (q ? 2 : 1); pass++) { | ||
102 | - tmp = neon_load_reg(rm, pass * 2); | ||
103 | - tmp2 = neon_load_reg(rm, pass * 2 + 1); | ||
104 | - switch (size) { | ||
105 | - case 0: tcg_gen_bswap32_i32(tmp, tmp); break; | ||
106 | - case 1: gen_swap_half(tmp); break; | ||
107 | - case 2: /* no-op */ break; | ||
108 | - default: abort(); | ||
109 | - } | ||
110 | - neon_store_reg(rd, pass * 2 + 1, tmp); | ||
111 | - if (size == 2) { | ||
112 | - neon_store_reg(rd, pass * 2, tmp2); | ||
113 | - } else { | ||
114 | - switch (size) { | ||
115 | - case 0: tcg_gen_bswap32_i32(tmp2, tmp2); break; | ||
116 | - case 1: gen_swap_half(tmp2); break; | ||
117 | - default: abort(); | ||
118 | - } | ||
119 | - neon_store_reg(rd, pass * 2, tmp2); | ||
120 | - } | ||
121 | - } | ||
122 | - break; | ||
123 | + /* handled by decodetree */ | ||
124 | + return 1; | ||
125 | case NEON_2RM_VPADDL: case NEON_2RM_VPADDL_U: | ||
126 | case NEON_2RM_VPADAL: case NEON_2RM_VPADAL_U: | ||
127 | for (pass = 0; pass < q + 1; pass++) { | ||
128 | -- | ||
129 | 2.20.1 | ||
130 | |||
131 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Convert to decodetree the insns in the Neon 2-reg-misc grouping which | ||
2 | we implement using gvec. | ||
3 | 1 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20200616170844.13318-8-peter.maydell@linaro.org | ||
7 | --- | ||
8 | target/arm/neon-dp.decode | 11 +++++++ | ||
9 | target/arm/translate-neon.inc.c | 55 +++++++++++++++++++++++++++++++++ | ||
10 | target/arm/translate.c | 35 +++++---------------- | ||
11 | 3 files changed, 74 insertions(+), 27 deletions(-) | ||
12 | |||
13 | diff --git a/target/arm/neon-dp.decode b/target/arm/neon-dp.decode | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/target/arm/neon-dp.decode | ||
16 | +++ b/target/arm/neon-dp.decode | ||
17 | @@ -XXX,XX +XXX,XX @@ Vimm_1r 1111 001 . 1 . 000 ... .... cmode:4 0 . op:1 1 .... @1reg_imm | ||
18 | VPADDL_S 1111 001 11 . 11 .. 00 .... 0 0100 . . 0 .... @2misc | ||
19 | VPADDL_U 1111 001 11 . 11 .. 00 .... 0 0101 . . 0 .... @2misc | ||
20 | |||
21 | + VMVN 1111 001 11 . 11 .. 00 .... 0 1011 . . 0 .... @2misc | ||
22 | + | ||
23 | VPADAL_S 1111 001 11 . 11 .. 00 .... 0 1100 . . 0 .... @2misc | ||
24 | VPADAL_U 1111 001 11 . 11 .. 00 .... 0 1101 . . 0 .... @2misc | ||
25 | |||
26 | + VCGT0 1111 001 11 . 11 .. 01 .... 0 0000 . . 0 .... @2misc | ||
27 | + VCGE0 1111 001 11 . 11 .. 01 .... 0 0001 . . 0 .... @2misc | ||
28 | + VCEQ0 1111 001 11 . 11 .. 01 .... 0 0010 . . 0 .... @2misc | ||
29 | + VCLE0 1111 001 11 . 11 .. 01 .... 0 0011 . . 0 .... @2misc | ||
30 | + VCLT0 1111 001 11 . 11 .. 01 .... 0 0100 . . 0 .... @2misc | ||
31 | + | ||
32 | + VABS 1111 001 11 . 11 .. 01 .... 0 0110 . . 0 .... @2misc | ||
33 | + VNEG 1111 001 11 . 11 .. 01 .... 0 0111 . . 0 .... @2misc | ||
34 | + | ||
35 | VUZP 1111 001 11 . 11 .. 10 .... 0 0010 . . 0 .... @2misc | ||
36 | VZIP 1111 001 11 . 11 .. 10 .... 0 0011 . . 0 .... @2misc | ||
37 | |||
38 | diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c | ||
39 | index XXXXXXX..XXXXXXX 100644 | ||
40 | --- a/target/arm/translate-neon.inc.c | ||
41 | +++ b/target/arm/translate-neon.inc.c | ||
42 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_F32_F16(DisasContext *s, arg_2misc *a) | ||
43 | |||
44 | return true; | ||
45 | } | ||
46 | + | ||
47 | +static bool do_2misc_vec(DisasContext *s, arg_2misc *a, GVecGen2Fn *fn) | ||
48 | +{ | ||
49 | + int vec_size = a->q ? 16 : 8; | ||
50 | + int rd_ofs = neon_reg_offset(a->vd, 0); | ||
51 | + int rm_ofs = neon_reg_offset(a->vm, 0); | ||
52 | + | ||
53 | + if (!arm_dc_feature(s, ARM_FEATURE_NEON)) { | ||
54 | + return false; | ||
55 | + } | ||
56 | + | ||
57 | + /* UNDEF accesses to D16-D31 if they don't exist. */ | ||
58 | + if (!dc_isar_feature(aa32_simd_r32, s) && | ||
59 | + ((a->vd | a->vm) & 0x10)) { | ||
60 | + return false; | ||
61 | + } | ||
62 | + | ||
63 | + if (a->size == 3) { | ||
64 | + return false; | ||
65 | + } | ||
66 | + | ||
67 | + if ((a->vd | a->vm) & a->q) { | ||
68 | + return false; | ||
69 | + } | ||
70 | + | ||
71 | + if (!vfp_access_check(s)) { | ||
72 | + return true; | ||
73 | + } | ||
74 | + | ||
75 | + fn(a->size, rd_ofs, rm_ofs, vec_size, vec_size); | ||
76 | + | ||
77 | + return true; | ||
78 | +} | ||
79 | + | ||
80 | +#define DO_2MISC_VEC(INSN, FN) \ | ||
81 | + static bool trans_##INSN(DisasContext *s, arg_2misc *a) \ | ||
82 | + { \ | ||
83 | + return do_2misc_vec(s, a, FN); \ | ||
84 | + } | ||
85 | + | ||
86 | +DO_2MISC_VEC(VNEG, tcg_gen_gvec_neg) | ||
87 | +DO_2MISC_VEC(VABS, tcg_gen_gvec_abs) | ||
88 | +DO_2MISC_VEC(VCEQ0, gen_gvec_ceq0) | ||
89 | +DO_2MISC_VEC(VCGT0, gen_gvec_cgt0) | ||
90 | +DO_2MISC_VEC(VCLE0, gen_gvec_cle0) | ||
91 | +DO_2MISC_VEC(VCGE0, gen_gvec_cge0) | ||
92 | +DO_2MISC_VEC(VCLT0, gen_gvec_clt0) | ||
93 | + | ||
94 | +static bool trans_VMVN(DisasContext *s, arg_2misc *a) | ||
95 | +{ | ||
96 | + if (a->size != 0) { | ||
97 | + return false; | ||
98 | + } | ||
99 | + return do_2misc_vec(s, a, tcg_gen_gvec_not); | ||
100 | +} | ||
101 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
102 | index XXXXXXX..XXXXXXX 100644 | ||
103 | --- a/target/arm/translate.c | ||
104 | +++ b/target/arm/translate.c | ||
105 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
106 | int size; | ||
107 | int pass; | ||
108 | int u; | ||
109 | - int vec_size; | ||
110 | TCGv_i32 tmp, tmp2; | ||
111 | |||
112 | if (!arm_dc_feature(s, ARM_FEATURE_NEON)) { | ||
113 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
114 | VFP_DREG_D(rd, insn); | ||
115 | VFP_DREG_M(rm, insn); | ||
116 | size = (insn >> 20) & 3; | ||
117 | - vec_size = q ? 16 : 8; | ||
118 | rd_ofs = neon_reg_offset(rd, 0); | ||
119 | rm_ofs = neon_reg_offset(rm, 0); | ||
120 | |||
121 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
122 | case NEON_2RM_VSHLL: | ||
123 | case NEON_2RM_VCVT_F16_F32: | ||
124 | case NEON_2RM_VCVT_F32_F16: | ||
125 | + case NEON_2RM_VMVN: | ||
126 | + case NEON_2RM_VNEG: | ||
127 | + case NEON_2RM_VABS: | ||
128 | + case NEON_2RM_VCEQ0: | ||
129 | + case NEON_2RM_VCGT0: | ||
130 | + case NEON_2RM_VCLE0: | ||
131 | + case NEON_2RM_VCGE0: | ||
132 | + case NEON_2RM_VCLT0: | ||
133 | /* handled by decodetree */ | ||
134 | return 1; | ||
135 | case NEON_2RM_VTRN: | ||
136 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
137 | q ? gen_helper_crypto_sha256su0 | ||
138 | : gen_helper_crypto_sha1su1); | ||
139 | break; | ||
140 | - case NEON_2RM_VMVN: | ||
141 | - tcg_gen_gvec_not(0, rd_ofs, rm_ofs, vec_size, vec_size); | ||
142 | - break; | ||
143 | - case NEON_2RM_VNEG: | ||
144 | - tcg_gen_gvec_neg(size, rd_ofs, rm_ofs, vec_size, vec_size); | ||
145 | - break; | ||
146 | - case NEON_2RM_VABS: | ||
147 | - tcg_gen_gvec_abs(size, rd_ofs, rm_ofs, vec_size, vec_size); | ||
148 | - break; | ||
149 | - | ||
150 | - case NEON_2RM_VCEQ0: | ||
151 | - gen_gvec_ceq0(size, rd_ofs, rm_ofs, vec_size, vec_size); | ||
152 | - break; | ||
153 | - case NEON_2RM_VCGT0: | ||
154 | - gen_gvec_cgt0(size, rd_ofs, rm_ofs, vec_size, vec_size); | ||
155 | - break; | ||
156 | - case NEON_2RM_VCLE0: | ||
157 | - gen_gvec_cle0(size, rd_ofs, rm_ofs, vec_size, vec_size); | ||
158 | - break; | ||
159 | - case NEON_2RM_VCGE0: | ||
160 | - gen_gvec_cge0(size, rd_ofs, rm_ofs, vec_size, vec_size); | ||
161 | - break; | ||
162 | - case NEON_2RM_VCLT0: | ||
163 | - gen_gvec_clt0(size, rd_ofs, rm_ofs, vec_size, vec_size); | ||
164 | - break; | ||
165 | |||
166 | default: | ||
167 | elementwise: | ||
168 | -- | ||
169 | 2.20.1 | ||
170 | |||
171 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Convert the Neon-2-reg misc crypto ops (AESE, AESMC, SHA1H, SHA1SU1) | ||
2 | to decodetree. | ||
3 | 1 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20200616170844.13318-9-peter.maydell@linaro.org | ||
7 | --- | ||
8 | target/arm/neon-dp.decode | 12 ++++++++ | ||
9 | target/arm/translate-neon.inc.c | 42 ++++++++++++++++++++++++++ | ||
10 | target/arm/translate.c | 52 +++------------------------------ | ||
11 | 3 files changed, 58 insertions(+), 48 deletions(-) | ||
12 | |||
13 | diff --git a/target/arm/neon-dp.decode b/target/arm/neon-dp.decode | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/target/arm/neon-dp.decode | ||
16 | +++ b/target/arm/neon-dp.decode | ||
17 | @@ -XXX,XX +XXX,XX @@ Vimm_1r 1111 001 . 1 . 000 ... .... cmode:4 0 . op:1 1 .... @1reg_imm | ||
18 | &2misc vm=%vm_dp vd=%vd_dp | ||
19 | @2misc_q0 .... ... .. . .. size:2 .. .... . .... . . . .... \ | ||
20 | &2misc vm=%vm_dp vd=%vd_dp q=0 | ||
21 | + @2misc_q1 .... ... .. . .. size:2 .. .... . .... . . . .... \ | ||
22 | + &2misc vm=%vm_dp vd=%vd_dp q=1 | ||
23 | |||
24 | VREV64 1111 001 11 . 11 .. 00 .... 0 0000 . . 0 .... @2misc | ||
25 | |||
26 | VPADDL_S 1111 001 11 . 11 .. 00 .... 0 0100 . . 0 .... @2misc | ||
27 | VPADDL_U 1111 001 11 . 11 .. 00 .... 0 0101 . . 0 .... @2misc | ||
28 | |||
29 | + AESE 1111 001 11 . 11 .. 00 .... 0 0110 0 . 0 .... @2misc_q1 | ||
30 | + AESD 1111 001 11 . 11 .. 00 .... 0 0110 1 . 0 .... @2misc_q1 | ||
31 | + AESMC 1111 001 11 . 11 .. 00 .... 0 0111 0 . 0 .... @2misc_q1 | ||
32 | + AESIMC 1111 001 11 . 11 .. 00 .... 0 0111 1 . 0 .... @2misc_q1 | ||
33 | + | ||
34 | VMVN 1111 001 11 . 11 .. 00 .... 0 1011 . . 0 .... @2misc | ||
35 | |||
36 | VPADAL_S 1111 001 11 . 11 .. 00 .... 0 1100 . . 0 .... @2misc | ||
37 | @@ -XXX,XX +XXX,XX @@ Vimm_1r 1111 001 . 1 . 000 ... .... cmode:4 0 . op:1 1 .... @1reg_imm | ||
38 | VCLE0 1111 001 11 . 11 .. 01 .... 0 0011 . . 0 .... @2misc | ||
39 | VCLT0 1111 001 11 . 11 .. 01 .... 0 0100 . . 0 .... @2misc | ||
40 | |||
41 | + SHA1H 1111 001 11 . 11 .. 01 .... 0 0101 1 . 0 .... @2misc_q1 | ||
42 | + | ||
43 | VABS 1111 001 11 . 11 .. 01 .... 0 0110 . . 0 .... @2misc | ||
44 | VNEG 1111 001 11 . 11 .. 01 .... 0 0111 . . 0 .... @2misc | ||
45 | |||
46 | @@ -XXX,XX +XXX,XX @@ Vimm_1r 1111 001 . 1 . 000 ... .... cmode:4 0 . op:1 1 .... @1reg_imm | ||
47 | |||
48 | VSHLL 1111 001 11 . 11 .. 10 .... 0 0110 0 . 0 .... @2misc_q0 | ||
49 | |||
50 | + SHA1SU1 1111 001 11 . 11 .. 10 .... 0 0111 0 . 0 .... @2misc_q1 | ||
51 | + SHA256SU0 1111 001 11 . 11 .. 10 .... 0 0111 1 . 0 .... @2misc_q1 | ||
52 | + | ||
53 | VCVT_F16_F32 1111 001 11 . 11 .. 10 .... 0 1100 0 . 0 .... @2misc_q0 | ||
54 | VCVT_F32_F16 1111 001 11 . 11 .. 10 .... 0 1110 0 . 0 .... @2misc_q0 | ||
55 | ] | ||
56 | diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c | ||
57 | index XXXXXXX..XXXXXXX 100644 | ||
58 | --- a/target/arm/translate-neon.inc.c | ||
59 | +++ b/target/arm/translate-neon.inc.c | ||
60 | @@ -XXX,XX +XXX,XX @@ static bool trans_VMVN(DisasContext *s, arg_2misc *a) | ||
61 | } | ||
62 | return do_2misc_vec(s, a, tcg_gen_gvec_not); | ||
63 | } | ||
64 | + | ||
65 | +#define WRAP_2M_3_OOL_FN(WRAPNAME, FUNC, DATA) \ | ||
66 | + static void WRAPNAME(unsigned vece, uint32_t rd_ofs, \ | ||
67 | + uint32_t rm_ofs, uint32_t oprsz, \ | ||
68 | + uint32_t maxsz) \ | ||
69 | + { \ | ||
70 | + tcg_gen_gvec_3_ool(rd_ofs, rd_ofs, rm_ofs, oprsz, maxsz, \ | ||
71 | + DATA, FUNC); \ | ||
72 | + } | ||
73 | + | ||
74 | +#define WRAP_2M_2_OOL_FN(WRAPNAME, FUNC, DATA) \ | ||
75 | + static void WRAPNAME(unsigned vece, uint32_t rd_ofs, \ | ||
76 | + uint32_t rm_ofs, uint32_t oprsz, \ | ||
77 | + uint32_t maxsz) \ | ||
78 | + { \ | ||
79 | + tcg_gen_gvec_2_ool(rd_ofs, rm_ofs, oprsz, maxsz, DATA, FUNC); \ | ||
80 | + } | ||
81 | + | ||
82 | +WRAP_2M_3_OOL_FN(gen_AESE, gen_helper_crypto_aese, 0) | ||
83 | +WRAP_2M_3_OOL_FN(gen_AESD, gen_helper_crypto_aese, 1) | ||
84 | +WRAP_2M_2_OOL_FN(gen_AESMC, gen_helper_crypto_aesmc, 0) | ||
85 | +WRAP_2M_2_OOL_FN(gen_AESIMC, gen_helper_crypto_aesmc, 1) | ||
86 | +WRAP_2M_2_OOL_FN(gen_SHA1H, gen_helper_crypto_sha1h, 0) | ||
87 | +WRAP_2M_2_OOL_FN(gen_SHA1SU1, gen_helper_crypto_sha1su1, 0) | ||
88 | +WRAP_2M_2_OOL_FN(gen_SHA256SU0, gen_helper_crypto_sha256su0, 0) | ||
89 | + | ||
90 | +#define DO_2M_CRYPTO(INSN, FEATURE, SIZE) \ | ||
91 | + static bool trans_##INSN(DisasContext *s, arg_2misc *a) \ | ||
92 | + { \ | ||
93 | + if (!dc_isar_feature(FEATURE, s) || a->size != SIZE) { \ | ||
94 | + return false; \ | ||
95 | + } \ | ||
96 | + return do_2misc_vec(s, a, gen_##INSN); \ | ||
97 | + } | ||
98 | + | ||
99 | +DO_2M_CRYPTO(AESE, aa32_aes, 0) | ||
100 | +DO_2M_CRYPTO(AESD, aa32_aes, 0) | ||
101 | +DO_2M_CRYPTO(AESMC, aa32_aes, 0) | ||
102 | +DO_2M_CRYPTO(AESIMC, aa32_aes, 0) | ||
103 | +DO_2M_CRYPTO(SHA1H, aa32_sha1, 2) | ||
104 | +DO_2M_CRYPTO(SHA1SU1, aa32_sha1, 2) | ||
105 | +DO_2M_CRYPTO(SHA256SU0, aa32_sha2, 2) | ||
106 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
107 | index XXXXXXX..XXXXXXX 100644 | ||
108 | --- a/target/arm/translate.c | ||
109 | +++ b/target/arm/translate.c | ||
110 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
111 | { | ||
112 | int op; | ||
113 | int q; | ||
114 | - int rd, rm, rd_ofs, rm_ofs; | ||
115 | + int rd, rm; | ||
116 | int size; | ||
117 | int pass; | ||
118 | int u; | ||
119 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
120 | VFP_DREG_D(rd, insn); | ||
121 | VFP_DREG_M(rm, insn); | ||
122 | size = (insn >> 20) & 3; | ||
123 | - rd_ofs = neon_reg_offset(rd, 0); | ||
124 | - rm_ofs = neon_reg_offset(rm, 0); | ||
125 | |||
126 | if ((insn & (1 << 23)) == 0) { | ||
127 | /* Three register same length: handled by decodetree */ | ||
128 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
129 | case NEON_2RM_VCLE0: | ||
130 | case NEON_2RM_VCGE0: | ||
131 | case NEON_2RM_VCLT0: | ||
132 | + case NEON_2RM_AESE: case NEON_2RM_AESMC: | ||
133 | + case NEON_2RM_SHA1H: | ||
134 | + case NEON_2RM_SHA1SU1: | ||
135 | /* handled by decodetree */ | ||
136 | return 1; | ||
137 | case NEON_2RM_VTRN: | ||
138 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
139 | goto elementwise; | ||
140 | } | ||
141 | break; | ||
142 | - case NEON_2RM_AESE: case NEON_2RM_AESMC: | ||
143 | - if (!dc_isar_feature(aa32_aes, s) || ((rm | rd) & 1)) { | ||
144 | - return 1; | ||
145 | - } | ||
146 | - /* | ||
147 | - * Bit 6 is the lowest opcode bit; it distinguishes | ||
148 | - * between encryption (AESE/AESMC) and decryption | ||
149 | - * (AESD/AESIMC). | ||
150 | - */ | ||
151 | - if (op == NEON_2RM_AESE) { | ||
152 | - tcg_gen_gvec_3_ool(vfp_reg_offset(true, rd), | ||
153 | - vfp_reg_offset(true, rd), | ||
154 | - vfp_reg_offset(true, rm), | ||
155 | - 16, 16, extract32(insn, 6, 1), | ||
156 | - gen_helper_crypto_aese); | ||
157 | - } else { | ||
158 | - tcg_gen_gvec_2_ool(vfp_reg_offset(true, rd), | ||
159 | - vfp_reg_offset(true, rm), | ||
160 | - 16, 16, extract32(insn, 6, 1), | ||
161 | - gen_helper_crypto_aesmc); | ||
162 | - } | ||
163 | - break; | ||
164 | - case NEON_2RM_SHA1H: | ||
165 | - if (!dc_isar_feature(aa32_sha1, s) || ((rm | rd) & 1)) { | ||
166 | - return 1; | ||
167 | - } | ||
168 | - tcg_gen_gvec_2_ool(rd_ofs, rm_ofs, 16, 16, 0, | ||
169 | - gen_helper_crypto_sha1h); | ||
170 | - break; | ||
171 | - case NEON_2RM_SHA1SU1: | ||
172 | - if ((rm | rd) & 1) { | ||
173 | - return 1; | ||
174 | - } | ||
175 | - /* bit 6 (q): set -> SHA256SU0, cleared -> SHA1SU1 */ | ||
176 | - if (q) { | ||
177 | - if (!dc_isar_feature(aa32_sha2, s)) { | ||
178 | - return 1; | ||
179 | - } | ||
180 | - } else if (!dc_isar_feature(aa32_sha1, s)) { | ||
181 | - return 1; | ||
182 | - } | ||
183 | - tcg_gen_gvec_2_ool(rd_ofs, rm_ofs, 16, 16, 0, | ||
184 | - q ? gen_helper_crypto_sha256su0 | ||
185 | - : gen_helper_crypto_sha1su1); | ||
186 | - break; | ||
187 | |||
188 | default: | ||
189 | elementwise: | ||
190 | -- | ||
191 | 2.20.1 | ||
192 | |||
193 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | The NeonGenOneOpFn typedef breaks with the pattern of the other | ||
2 | NeonGen*Fn typedefs, because it is a TCGv_i64 -> TCGv_i64 operation | ||
3 | but it does not have '64' in its name. Rename it to NeonGenOne64OpFn, | ||
4 | so that the old name is available for a TCGv_i32 -> TCGv_i32 operation | ||
5 | (which we will need in a subsequent commit). | ||
6 | 1 | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20200616170844.13318-10-peter.maydell@linaro.org | ||
10 | --- | ||
11 | target/arm/translate.h | 2 +- | ||
12 | target/arm/translate-a64.c | 4 ++-- | ||
13 | 2 files changed, 3 insertions(+), 3 deletions(-) | ||
14 | |||
15 | diff --git a/target/arm/translate.h b/target/arm/translate.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/target/arm/translate.h | ||
18 | +++ b/target/arm/translate.h | ||
19 | @@ -XXX,XX +XXX,XX @@ typedef void NeonGenWidenFn(TCGv_i64, TCGv_i32); | ||
20 | typedef void NeonGenTwoOpWidenFn(TCGv_i64, TCGv_i32, TCGv_i32); | ||
21 | typedef void NeonGenTwoSingleOPFn(TCGv_i32, TCGv_i32, TCGv_i32, TCGv_ptr); | ||
22 | typedef void NeonGenTwoDoubleOPFn(TCGv_i64, TCGv_i64, TCGv_i64, TCGv_ptr); | ||
23 | -typedef void NeonGenOneOpFn(TCGv_i64, TCGv_i64); | ||
24 | +typedef void NeonGenOne64OpFn(TCGv_i64, TCGv_i64); | ||
25 | typedef void CryptoTwoOpFn(TCGv_ptr, TCGv_ptr); | ||
26 | typedef void CryptoThreeOpIntFn(TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
27 | typedef void CryptoThreeOpFn(TCGv_ptr, TCGv_ptr, TCGv_ptr); | ||
28 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
29 | index XXXXXXX..XXXXXXX 100644 | ||
30 | --- a/target/arm/translate-a64.c | ||
31 | +++ b/target/arm/translate-a64.c | ||
32 | @@ -XXX,XX +XXX,XX @@ static void handle_2misc_pairwise(DisasContext *s, int opcode, bool u, | ||
33 | } else { | ||
34 | for (pass = 0; pass < maxpass; pass++) { | ||
35 | TCGv_i64 tcg_op = tcg_temp_new_i64(); | ||
36 | - NeonGenOneOpFn *genfn; | ||
37 | - static NeonGenOneOpFn * const fns[2][2] = { | ||
38 | + NeonGenOne64OpFn *genfn; | ||
39 | + static NeonGenOne64OpFn * const fns[2][2] = { | ||
40 | { gen_helper_neon_addlp_s8, gen_helper_neon_addlp_u8 }, | ||
41 | { gen_helper_neon_addlp_s16, gen_helper_neon_addlp_u16 }, | ||
42 | }; | ||
43 | -- | ||
44 | 2.20.1 | ||
45 | |||
46 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | All the other typedefs like these spell "Op" with a lowercase 'p'; | ||
2 | remane the NeonGenTwoSingleOPFn and NeonGenTwoDoubleOPFn typedefs to | ||
3 | match. | ||
4 | 1 | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20200616170844.13318-11-peter.maydell@linaro.org | ||
8 | --- | ||
9 | target/arm/translate.h | 4 ++-- | ||
10 | target/arm/translate-a64.c | 4 ++-- | ||
11 | target/arm/translate-neon.inc.c | 2 +- | ||
12 | 3 files changed, 5 insertions(+), 5 deletions(-) | ||
13 | |||
14 | diff --git a/target/arm/translate.h b/target/arm/translate.h | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/target/arm/translate.h | ||
17 | +++ b/target/arm/translate.h | ||
18 | @@ -XXX,XX +XXX,XX @@ typedef void NeonGenNarrowFn(TCGv_i32, TCGv_i64); | ||
19 | typedef void NeonGenNarrowEnvFn(TCGv_i32, TCGv_ptr, TCGv_i64); | ||
20 | typedef void NeonGenWidenFn(TCGv_i64, TCGv_i32); | ||
21 | typedef void NeonGenTwoOpWidenFn(TCGv_i64, TCGv_i32, TCGv_i32); | ||
22 | -typedef void NeonGenTwoSingleOPFn(TCGv_i32, TCGv_i32, TCGv_i32, TCGv_ptr); | ||
23 | -typedef void NeonGenTwoDoubleOPFn(TCGv_i64, TCGv_i64, TCGv_i64, TCGv_ptr); | ||
24 | +typedef void NeonGenTwoSingleOpFn(TCGv_i32, TCGv_i32, TCGv_i32, TCGv_ptr); | ||
25 | +typedef void NeonGenTwoDoubleOpFn(TCGv_i64, TCGv_i64, TCGv_i64, TCGv_ptr); | ||
26 | typedef void NeonGenOne64OpFn(TCGv_i64, TCGv_i64); | ||
27 | typedef void CryptoTwoOpFn(TCGv_ptr, TCGv_ptr); | ||
28 | typedef void CryptoThreeOpIntFn(TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
29 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
30 | index XXXXXXX..XXXXXXX 100644 | ||
31 | --- a/target/arm/translate-a64.c | ||
32 | +++ b/target/arm/translate-a64.c | ||
33 | @@ -XXX,XX +XXX,XX @@ static void handle_2misc_fcmp_zero(DisasContext *s, int opcode, | ||
34 | TCGv_i64 tcg_op = tcg_temp_new_i64(); | ||
35 | TCGv_i64 tcg_zero = tcg_const_i64(0); | ||
36 | TCGv_i64 tcg_res = tcg_temp_new_i64(); | ||
37 | - NeonGenTwoDoubleOPFn *genfn; | ||
38 | + NeonGenTwoDoubleOpFn *genfn; | ||
39 | bool swap = false; | ||
40 | int pass; | ||
41 | |||
42 | @@ -XXX,XX +XXX,XX @@ static void handle_2misc_fcmp_zero(DisasContext *s, int opcode, | ||
43 | TCGv_i32 tcg_op = tcg_temp_new_i32(); | ||
44 | TCGv_i32 tcg_zero = tcg_const_i32(0); | ||
45 | TCGv_i32 tcg_res = tcg_temp_new_i32(); | ||
46 | - NeonGenTwoSingleOPFn *genfn; | ||
47 | + NeonGenTwoSingleOpFn *genfn; | ||
48 | bool swap = false; | ||
49 | int pass, maxpasses; | ||
50 | |||
51 | diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c | ||
52 | index XXXXXXX..XXXXXXX 100644 | ||
53 | --- a/target/arm/translate-neon.inc.c | ||
54 | +++ b/target/arm/translate-neon.inc.c | ||
55 | @@ -XXX,XX +XXX,XX @@ static bool trans_VSHLL_U_2sh(DisasContext *s, arg_2reg_shift *a) | ||
56 | } | ||
57 | |||
58 | static bool do_fp_2sh(DisasContext *s, arg_2reg_shift *a, | ||
59 | - NeonGenTwoSingleOPFn *fn) | ||
60 | + NeonGenTwoSingleOpFn *fn) | ||
61 | { | ||
62 | /* FP operations in 2-reg-and-shift group */ | ||
63 | TCGv_i32 tmp, shiftv; | ||
64 | -- | ||
65 | 2.20.1 | ||
66 | |||
67 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Make gen_swap_half() take a source and destination TCGv_i32 rather | ||
2 | than modifying the input TCGv_i32; we're going to want to be able to | ||
3 | use it with the more flexible function signature, and this also | ||
4 | brings it into line with other functions like gen_rev16() and | ||
5 | gen_revsh(). | ||
6 | 1 | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20200616170844.13318-12-peter.maydell@linaro.org | ||
10 | --- | ||
11 | target/arm/translate-neon.inc.c | 2 +- | ||
12 | target/arm/translate.c | 10 +++++----- | ||
13 | 2 files changed, 6 insertions(+), 6 deletions(-) | ||
14 | |||
15 | diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/target/arm/translate-neon.inc.c | ||
18 | +++ b/target/arm/translate-neon.inc.c | ||
19 | @@ -XXX,XX +XXX,XX @@ static bool trans_VREV64(DisasContext *s, arg_VREV64 *a) | ||
20 | tcg_gen_bswap32_i32(tmp[half], tmp[half]); | ||
21 | break; | ||
22 | case 1: | ||
23 | - gen_swap_half(tmp[half]); | ||
24 | + gen_swap_half(tmp[half], tmp[half]); | ||
25 | break; | ||
26 | case 2: | ||
27 | break; | ||
28 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
29 | index XXXXXXX..XXXXXXX 100644 | ||
30 | --- a/target/arm/translate.c | ||
31 | +++ b/target/arm/translate.c | ||
32 | @@ -XXX,XX +XXX,XX @@ static void gen_revsh(TCGv_i32 dest, TCGv_i32 var) | ||
33 | } | ||
34 | |||
35 | /* Swap low and high halfwords. */ | ||
36 | -static void gen_swap_half(TCGv_i32 var) | ||
37 | +static void gen_swap_half(TCGv_i32 dest, TCGv_i32 var) | ||
38 | { | ||
39 | - tcg_gen_rotri_i32(var, var, 16); | ||
40 | + tcg_gen_rotri_i32(dest, var, 16); | ||
41 | } | ||
42 | |||
43 | /* Dual 16-bit add. Result placed in t0 and t1 is marked as dead. | ||
44 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
45 | case NEON_2RM_VREV32: | ||
46 | switch (size) { | ||
47 | case 0: tcg_gen_bswap32_i32(tmp, tmp); break; | ||
48 | - case 1: gen_swap_half(tmp); break; | ||
49 | + case 1: gen_swap_half(tmp, tmp); break; | ||
50 | default: abort(); | ||
51 | } | ||
52 | break; | ||
53 | @@ -XXX,XX +XXX,XX @@ static bool op_smlad(DisasContext *s, arg_rrrr *a, bool m_swap, bool sub) | ||
54 | t1 = load_reg(s, a->rn); | ||
55 | t2 = load_reg(s, a->rm); | ||
56 | if (m_swap) { | ||
57 | - gen_swap_half(t2); | ||
58 | + gen_swap_half(t2, t2); | ||
59 | } | ||
60 | gen_smul_dual(t1, t2); | ||
61 | |||
62 | @@ -XXX,XX +XXX,XX @@ static bool op_smlald(DisasContext *s, arg_rrrr *a, bool m_swap, bool sub) | ||
63 | t1 = load_reg(s, a->rn); | ||
64 | t2 = load_reg(s, a->rm); | ||
65 | if (m_swap) { | ||
66 | - gen_swap_half(t2); | ||
67 | + gen_swap_half(t2, t2); | ||
68 | } | ||
69 | gen_smul_dual(t1, t2); | ||
70 | |||
71 | -- | ||
72 | 2.20.1 | ||
73 | |||
74 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Convert the VREV32 and VREV16 insns in the Neon 2-reg-misc group | ||
2 | to decodetree. | ||
3 | 1 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20200616170844.13318-13-peter.maydell@linaro.org | ||
7 | --- | ||
8 | target/arm/translate.h | 1 + | ||
9 | target/arm/neon-dp.decode | 2 ++ | ||
10 | target/arm/translate-neon.inc.c | 55 +++++++++++++++++++++++++++++++++ | ||
11 | target/arm/translate.c | 12 ++----- | ||
12 | 4 files changed, 60 insertions(+), 10 deletions(-) | ||
13 | |||
14 | diff --git a/target/arm/translate.h b/target/arm/translate.h | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/target/arm/translate.h | ||
17 | +++ b/target/arm/translate.h | ||
18 | @@ -XXX,XX +XXX,XX @@ typedef void GVecGen4Fn(unsigned, uint32_t, uint32_t, uint32_t, | ||
19 | uint32_t, uint32_t, uint32_t); | ||
20 | |||
21 | /* Function prototype for gen_ functions for calling Neon helpers */ | ||
22 | +typedef void NeonGenOneOpFn(TCGv_i32, TCGv_i32); | ||
23 | typedef void NeonGenOneOpEnvFn(TCGv_i32, TCGv_ptr, TCGv_i32); | ||
24 | typedef void NeonGenTwoOpFn(TCGv_i32, TCGv_i32, TCGv_i32); | ||
25 | typedef void NeonGenTwoOpEnvFn(TCGv_i32, TCGv_ptr, TCGv_i32, TCGv_i32); | ||
26 | diff --git a/target/arm/neon-dp.decode b/target/arm/neon-dp.decode | ||
27 | index XXXXXXX..XXXXXXX 100644 | ||
28 | --- a/target/arm/neon-dp.decode | ||
29 | +++ b/target/arm/neon-dp.decode | ||
30 | @@ -XXX,XX +XXX,XX @@ Vimm_1r 1111 001 . 1 . 000 ... .... cmode:4 0 . op:1 1 .... @1reg_imm | ||
31 | &2misc vm=%vm_dp vd=%vd_dp q=1 | ||
32 | |||
33 | VREV64 1111 001 11 . 11 .. 00 .... 0 0000 . . 0 .... @2misc | ||
34 | + VREV32 1111 001 11 . 11 .. 00 .... 0 0001 . . 0 .... @2misc | ||
35 | + VREV16 1111 001 11 . 11 .. 00 .... 0 0010 . . 0 .... @2misc | ||
36 | |||
37 | VPADDL_S 1111 001 11 . 11 .. 00 .... 0 0100 . . 0 .... @2misc | ||
38 | VPADDL_U 1111 001 11 . 11 .. 00 .... 0 0101 . . 0 .... @2misc | ||
39 | diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c | ||
40 | index XXXXXXX..XXXXXXX 100644 | ||
41 | --- a/target/arm/translate-neon.inc.c | ||
42 | +++ b/target/arm/translate-neon.inc.c | ||
43 | @@ -XXX,XX +XXX,XX @@ DO_2M_CRYPTO(AESIMC, aa32_aes, 0) | ||
44 | DO_2M_CRYPTO(SHA1H, aa32_sha1, 2) | ||
45 | DO_2M_CRYPTO(SHA1SU1, aa32_sha1, 2) | ||
46 | DO_2M_CRYPTO(SHA256SU0, aa32_sha2, 2) | ||
47 | + | ||
48 | +static bool do_2misc(DisasContext *s, arg_2misc *a, NeonGenOneOpFn *fn) | ||
49 | +{ | ||
50 | + int pass; | ||
51 | + | ||
52 | + /* Handle a 2-reg-misc operation by iterating 32 bits at a time */ | ||
53 | + if (!arm_dc_feature(s, ARM_FEATURE_NEON)) { | ||
54 | + return false; | ||
55 | + } | ||
56 | + | ||
57 | + /* UNDEF accesses to D16-D31 if they don't exist. */ | ||
58 | + if (!dc_isar_feature(aa32_simd_r32, s) && | ||
59 | + ((a->vd | a->vm) & 0x10)) { | ||
60 | + return false; | ||
61 | + } | ||
62 | + | ||
63 | + if (!fn) { | ||
64 | + return false; | ||
65 | + } | ||
66 | + | ||
67 | + if ((a->vd | a->vm) & a->q) { | ||
68 | + return false; | ||
69 | + } | ||
70 | + | ||
71 | + if (!vfp_access_check(s)) { | ||
72 | + return true; | ||
73 | + } | ||
74 | + | ||
75 | + for (pass = 0; pass < (a->q ? 4 : 2); pass++) { | ||
76 | + TCGv_i32 tmp = neon_load_reg(a->vm, pass); | ||
77 | + fn(tmp, tmp); | ||
78 | + neon_store_reg(a->vd, pass, tmp); | ||
79 | + } | ||
80 | + | ||
81 | + return true; | ||
82 | +} | ||
83 | + | ||
84 | +static bool trans_VREV32(DisasContext *s, arg_2misc *a) | ||
85 | +{ | ||
86 | + static NeonGenOneOpFn * const fn[] = { | ||
87 | + tcg_gen_bswap32_i32, | ||
88 | + gen_swap_half, | ||
89 | + NULL, | ||
90 | + NULL, | ||
91 | + }; | ||
92 | + return do_2misc(s, a, fn[a->size]); | ||
93 | +} | ||
94 | + | ||
95 | +static bool trans_VREV16(DisasContext *s, arg_2misc *a) | ||
96 | +{ | ||
97 | + if (a->size != 0) { | ||
98 | + return false; | ||
99 | + } | ||
100 | + return do_2misc(s, a, gen_rev16); | ||
101 | +} | ||
102 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
103 | index XXXXXXX..XXXXXXX 100644 | ||
104 | --- a/target/arm/translate.c | ||
105 | +++ b/target/arm/translate.c | ||
106 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
107 | case NEON_2RM_AESE: case NEON_2RM_AESMC: | ||
108 | case NEON_2RM_SHA1H: | ||
109 | case NEON_2RM_SHA1SU1: | ||
110 | + case NEON_2RM_VREV32: | ||
111 | + case NEON_2RM_VREV16: | ||
112 | /* handled by decodetree */ | ||
113 | return 1; | ||
114 | case NEON_2RM_VTRN: | ||
115 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
116 | for (pass = 0; pass < (q ? 4 : 2); pass++) { | ||
117 | tmp = neon_load_reg(rm, pass); | ||
118 | switch (op) { | ||
119 | - case NEON_2RM_VREV32: | ||
120 | - switch (size) { | ||
121 | - case 0: tcg_gen_bswap32_i32(tmp, tmp); break; | ||
122 | - case 1: gen_swap_half(tmp, tmp); break; | ||
123 | - default: abort(); | ||
124 | - } | ||
125 | - break; | ||
126 | - case NEON_2RM_VREV16: | ||
127 | - gen_rev16(tmp, tmp); | ||
128 | - break; | ||
129 | case NEON_2RM_VCLS: | ||
130 | switch (size) { | ||
131 | case 0: gen_helper_neon_cls_s8(tmp, tmp); break; | ||
132 | -- | ||
133 | 2.20.1 | ||
134 | |||
135 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Convert the Neon VQABS and VQNEG insns to decodetree. | ||
2 | Since these are the only ones which need cpu_env passing to | ||
3 | the helper, we wrap the helper rather than creating a whole | ||
4 | new do_2misc_env() function. | ||
5 | 1 | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20200616170844.13318-15-peter.maydell@linaro.org | ||
9 | --- | ||
10 | target/arm/neon-dp.decode | 3 +++ | ||
11 | target/arm/translate-neon.inc.c | 35 +++++++++++++++++++++++++++++++++ | ||
12 | target/arm/translate.c | 30 ++-------------------------- | ||
13 | 3 files changed, 40 insertions(+), 28 deletions(-) | ||
14 | |||
15 | diff --git a/target/arm/neon-dp.decode b/target/arm/neon-dp.decode | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/target/arm/neon-dp.decode | ||
18 | +++ b/target/arm/neon-dp.decode | ||
19 | @@ -XXX,XX +XXX,XX @@ Vimm_1r 1111 001 . 1 . 000 ... .... cmode:4 0 . op:1 1 .... @1reg_imm | ||
20 | VPADAL_S 1111 001 11 . 11 .. 00 .... 0 1100 . . 0 .... @2misc | ||
21 | VPADAL_U 1111 001 11 . 11 .. 00 .... 0 1101 . . 0 .... @2misc | ||
22 | |||
23 | + VQABS 1111 001 11 . 11 .. 00 .... 0 1110 . . 0 .... @2misc | ||
24 | + VQNEG 1111 001 11 . 11 .. 00 .... 0 1111 . . 0 .... @2misc | ||
25 | + | ||
26 | VCGT0 1111 001 11 . 11 .. 01 .... 0 0000 . . 0 .... @2misc | ||
27 | VCGE0 1111 001 11 . 11 .. 01 .... 0 0001 . . 0 .... @2misc | ||
28 | VCEQ0 1111 001 11 . 11 .. 01 .... 0 0010 . . 0 .... @2misc | ||
29 | diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c | ||
30 | index XXXXXXX..XXXXXXX 100644 | ||
31 | --- a/target/arm/translate-neon.inc.c | ||
32 | +++ b/target/arm/translate-neon.inc.c | ||
33 | @@ -XXX,XX +XXX,XX @@ static bool trans_VRSQRTE(DisasContext *s, arg_2misc *a) | ||
34 | } | ||
35 | return do_2misc(s, a, gen_helper_rsqrte_u32); | ||
36 | } | ||
37 | + | ||
38 | +#define WRAP_1OP_ENV_FN(WRAPNAME, FUNC) \ | ||
39 | + static void WRAPNAME(TCGv_i32 d, TCGv_i32 m) \ | ||
40 | + { \ | ||
41 | + FUNC(d, cpu_env, m); \ | ||
42 | + } | ||
43 | + | ||
44 | +WRAP_1OP_ENV_FN(gen_VQABS_s8, gen_helper_neon_qabs_s8) | ||
45 | +WRAP_1OP_ENV_FN(gen_VQABS_s16, gen_helper_neon_qabs_s16) | ||
46 | +WRAP_1OP_ENV_FN(gen_VQABS_s32, gen_helper_neon_qabs_s32) | ||
47 | +WRAP_1OP_ENV_FN(gen_VQNEG_s8, gen_helper_neon_qneg_s8) | ||
48 | +WRAP_1OP_ENV_FN(gen_VQNEG_s16, gen_helper_neon_qneg_s16) | ||
49 | +WRAP_1OP_ENV_FN(gen_VQNEG_s32, gen_helper_neon_qneg_s32) | ||
50 | + | ||
51 | +static bool trans_VQABS(DisasContext *s, arg_2misc *a) | ||
52 | +{ | ||
53 | + static NeonGenOneOpFn * const fn[] = { | ||
54 | + gen_VQABS_s8, | ||
55 | + gen_VQABS_s16, | ||
56 | + gen_VQABS_s32, | ||
57 | + NULL, | ||
58 | + }; | ||
59 | + return do_2misc(s, a, fn[a->size]); | ||
60 | +} | ||
61 | + | ||
62 | +static bool trans_VQNEG(DisasContext *s, arg_2misc *a) | ||
63 | +{ | ||
64 | + static NeonGenOneOpFn * const fn[] = { | ||
65 | + gen_VQNEG_s8, | ||
66 | + gen_VQNEG_s16, | ||
67 | + gen_VQNEG_s32, | ||
68 | + NULL, | ||
69 | + }; | ||
70 | + return do_2misc(s, a, fn[a->size]); | ||
71 | +} | ||
72 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
73 | index XXXXXXX..XXXXXXX 100644 | ||
74 | --- a/target/arm/translate.c | ||
75 | +++ b/target/arm/translate.c | ||
76 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
77 | case NEON_2RM_VNEG_F: | ||
78 | case NEON_2RM_VRECPE: | ||
79 | case NEON_2RM_VRSQRTE: | ||
80 | + case NEON_2RM_VQABS: | ||
81 | + case NEON_2RM_VQNEG: | ||
82 | /* handled by decodetree */ | ||
83 | return 1; | ||
84 | case NEON_2RM_VTRN: | ||
85 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
86 | for (pass = 0; pass < (q ? 4 : 2); pass++) { | ||
87 | tmp = neon_load_reg(rm, pass); | ||
88 | switch (op) { | ||
89 | - case NEON_2RM_VQABS: | ||
90 | - switch (size) { | ||
91 | - case 0: | ||
92 | - gen_helper_neon_qabs_s8(tmp, cpu_env, tmp); | ||
93 | - break; | ||
94 | - case 1: | ||
95 | - gen_helper_neon_qabs_s16(tmp, cpu_env, tmp); | ||
96 | - break; | ||
97 | - case 2: | ||
98 | - gen_helper_neon_qabs_s32(tmp, cpu_env, tmp); | ||
99 | - break; | ||
100 | - default: abort(); | ||
101 | - } | ||
102 | - break; | ||
103 | - case NEON_2RM_VQNEG: | ||
104 | - switch (size) { | ||
105 | - case 0: | ||
106 | - gen_helper_neon_qneg_s8(tmp, cpu_env, tmp); | ||
107 | - break; | ||
108 | - case 1: | ||
109 | - gen_helper_neon_qneg_s16(tmp, cpu_env, tmp); | ||
110 | - break; | ||
111 | - case 2: | ||
112 | - gen_helper_neon_qneg_s32(tmp, cpu_env, tmp); | ||
113 | - break; | ||
114 | - default: abort(); | ||
115 | - } | ||
116 | - break; | ||
117 | case NEON_2RM_VCGT0_F: | ||
118 | { | ||
119 | TCGv_ptr fpstatus = get_fpstatus_ptr(1); | ||
120 | -- | ||
121 | 2.20.1 | ||
122 | |||
123 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Convert the Neon 2-reg-misc insns which are implemented with | ||
2 | simple calls to functions that take the input, output and | ||
3 | fpstatus pointer. | ||
4 | 1 | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20200616170844.13318-16-peter.maydell@linaro.org | ||
8 | --- | ||
9 | target/arm/translate.h | 1 + | ||
10 | target/arm/neon-dp.decode | 8 +++++ | ||
11 | target/arm/translate-neon.inc.c | 62 +++++++++++++++++++++++++++++++++ | ||
12 | target/arm/translate.c | 56 ++++------------------------- | ||
13 | 4 files changed, 78 insertions(+), 49 deletions(-) | ||
14 | |||
15 | diff --git a/target/arm/translate.h b/target/arm/translate.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/target/arm/translate.h | ||
18 | +++ b/target/arm/translate.h | ||
19 | @@ -XXX,XX +XXX,XX @@ typedef void NeonGenNarrowFn(TCGv_i32, TCGv_i64); | ||
20 | typedef void NeonGenNarrowEnvFn(TCGv_i32, TCGv_ptr, TCGv_i64); | ||
21 | typedef void NeonGenWidenFn(TCGv_i64, TCGv_i32); | ||
22 | typedef void NeonGenTwoOpWidenFn(TCGv_i64, TCGv_i32, TCGv_i32); | ||
23 | +typedef void NeonGenOneSingleOpFn(TCGv_i32, TCGv_i32, TCGv_ptr); | ||
24 | typedef void NeonGenTwoSingleOpFn(TCGv_i32, TCGv_i32, TCGv_i32, TCGv_ptr); | ||
25 | typedef void NeonGenTwoDoubleOpFn(TCGv_i64, TCGv_i64, TCGv_i64, TCGv_ptr); | ||
26 | typedef void NeonGenOne64OpFn(TCGv_i64, TCGv_i64); | ||
27 | diff --git a/target/arm/neon-dp.decode b/target/arm/neon-dp.decode | ||
28 | index XXXXXXX..XXXXXXX 100644 | ||
29 | --- a/target/arm/neon-dp.decode | ||
30 | +++ b/target/arm/neon-dp.decode | ||
31 | @@ -XXX,XX +XXX,XX @@ Vimm_1r 1111 001 . 1 . 000 ... .... cmode:4 0 . op:1 1 .... @1reg_imm | ||
32 | SHA1SU1 1111 001 11 . 11 .. 10 .... 0 0111 0 . 0 .... @2misc_q1 | ||
33 | SHA256SU0 1111 001 11 . 11 .. 10 .... 0 0111 1 . 0 .... @2misc_q1 | ||
34 | |||
35 | + VRINTX 1111 001 11 . 11 .. 10 .... 0 1001 . . 0 .... @2misc | ||
36 | + | ||
37 | VCVT_F16_F32 1111 001 11 . 11 .. 10 .... 0 1100 0 . 0 .... @2misc_q0 | ||
38 | VCVT_F32_F16 1111 001 11 . 11 .. 10 .... 0 1110 0 . 0 .... @2misc_q0 | ||
39 | |||
40 | VRECPE 1111 001 11 . 11 .. 11 .... 0 1000 . . 0 .... @2misc | ||
41 | VRSQRTE 1111 001 11 . 11 .. 11 .... 0 1001 . . 0 .... @2misc | ||
42 | + VRECPE_F 1111 001 11 . 11 .. 11 .... 0 1010 . . 0 .... @2misc | ||
43 | + VRSQRTE_F 1111 001 11 . 11 .. 11 .... 0 1011 . . 0 .... @2misc | ||
44 | + VCVT_FS 1111 001 11 . 11 .. 11 .... 0 1100 . . 0 .... @2misc | ||
45 | + VCVT_FU 1111 001 11 . 11 .. 11 .... 0 1101 . . 0 .... @2misc | ||
46 | + VCVT_SF 1111 001 11 . 11 .. 11 .... 0 1110 . . 0 .... @2misc | ||
47 | + VCVT_UF 1111 001 11 . 11 .. 11 .... 0 1111 . . 0 .... @2misc | ||
48 | ] | ||
49 | |||
50 | # Subgroup for size != 0b11 | ||
51 | diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c | ||
52 | index XXXXXXX..XXXXXXX 100644 | ||
53 | --- a/target/arm/translate-neon.inc.c | ||
54 | +++ b/target/arm/translate-neon.inc.c | ||
55 | @@ -XXX,XX +XXX,XX @@ static bool trans_VQNEG(DisasContext *s, arg_2misc *a) | ||
56 | }; | ||
57 | return do_2misc(s, a, fn[a->size]); | ||
58 | } | ||
59 | + | ||
60 | +static bool do_2misc_fp(DisasContext *s, arg_2misc *a, | ||
61 | + NeonGenOneSingleOpFn *fn) | ||
62 | +{ | ||
63 | + int pass; | ||
64 | + TCGv_ptr fpst; | ||
65 | + | ||
66 | + /* Handle a 2-reg-misc operation by iterating 32 bits at a time */ | ||
67 | + if (!arm_dc_feature(s, ARM_FEATURE_NEON)) { | ||
68 | + return false; | ||
69 | + } | ||
70 | + | ||
71 | + /* UNDEF accesses to D16-D31 if they don't exist. */ | ||
72 | + if (!dc_isar_feature(aa32_simd_r32, s) && | ||
73 | + ((a->vd | a->vm) & 0x10)) { | ||
74 | + return false; | ||
75 | + } | ||
76 | + | ||
77 | + if (a->size != 2) { | ||
78 | + /* TODO: FP16 will be the size == 1 case */ | ||
79 | + return false; | ||
80 | + } | ||
81 | + | ||
82 | + if ((a->vd | a->vm) & a->q) { | ||
83 | + return false; | ||
84 | + } | ||
85 | + | ||
86 | + if (!vfp_access_check(s)) { | ||
87 | + return true; | ||
88 | + } | ||
89 | + | ||
90 | + fpst = get_fpstatus_ptr(1); | ||
91 | + for (pass = 0; pass < (a->q ? 4 : 2); pass++) { | ||
92 | + TCGv_i32 tmp = neon_load_reg(a->vm, pass); | ||
93 | + fn(tmp, tmp, fpst); | ||
94 | + neon_store_reg(a->vd, pass, tmp); | ||
95 | + } | ||
96 | + tcg_temp_free_ptr(fpst); | ||
97 | + | ||
98 | + return true; | ||
99 | +} | ||
100 | + | ||
101 | +#define DO_2MISC_FP(INSN, FUNC) \ | ||
102 | + static bool trans_##INSN(DisasContext *s, arg_2misc *a) \ | ||
103 | + { \ | ||
104 | + return do_2misc_fp(s, a, FUNC); \ | ||
105 | + } | ||
106 | + | ||
107 | +DO_2MISC_FP(VRECPE_F, gen_helper_recpe_f32) | ||
108 | +DO_2MISC_FP(VRSQRTE_F, gen_helper_rsqrte_f32) | ||
109 | +DO_2MISC_FP(VCVT_FS, gen_helper_vfp_sitos) | ||
110 | +DO_2MISC_FP(VCVT_FU, gen_helper_vfp_uitos) | ||
111 | +DO_2MISC_FP(VCVT_SF, gen_helper_vfp_tosizs) | ||
112 | +DO_2MISC_FP(VCVT_UF, gen_helper_vfp_touizs) | ||
113 | + | ||
114 | +static bool trans_VRINTX(DisasContext *s, arg_2misc *a) | ||
115 | +{ | ||
116 | + if (!arm_dc_feature(s, ARM_FEATURE_V8)) { | ||
117 | + return false; | ||
118 | + } | ||
119 | + return do_2misc_fp(s, a, gen_helper_rints_exact); | ||
120 | +} | ||
121 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
122 | index XXXXXXX..XXXXXXX 100644 | ||
123 | --- a/target/arm/translate.c | ||
124 | +++ b/target/arm/translate.c | ||
125 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
126 | case NEON_2RM_VRSQRTE: | ||
127 | case NEON_2RM_VQABS: | ||
128 | case NEON_2RM_VQNEG: | ||
129 | + case NEON_2RM_VRECPE_F: | ||
130 | + case NEON_2RM_VRSQRTE_F: | ||
131 | + case NEON_2RM_VCVT_FS: | ||
132 | + case NEON_2RM_VCVT_FU: | ||
133 | + case NEON_2RM_VCVT_SF: | ||
134 | + case NEON_2RM_VCVT_UF: | ||
135 | + case NEON_2RM_VRINTX: | ||
136 | /* handled by decodetree */ | ||
137 | return 1; | ||
138 | case NEON_2RM_VTRN: | ||
139 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
140 | tcg_temp_free_i32(tcg_rmode); | ||
141 | break; | ||
142 | } | ||
143 | - case NEON_2RM_VRINTX: | ||
144 | - { | ||
145 | - TCGv_ptr fpstatus = get_fpstatus_ptr(1); | ||
146 | - gen_helper_rints_exact(tmp, tmp, fpstatus); | ||
147 | - tcg_temp_free_ptr(fpstatus); | ||
148 | - break; | ||
149 | - } | ||
150 | case NEON_2RM_VCVTAU: | ||
151 | case NEON_2RM_VCVTAS: | ||
152 | case NEON_2RM_VCVTNU: | ||
153 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
154 | tcg_temp_free_ptr(fpst); | ||
155 | break; | ||
156 | } | ||
157 | - case NEON_2RM_VRECPE_F: | ||
158 | - { | ||
159 | - TCGv_ptr fpstatus = get_fpstatus_ptr(1); | ||
160 | - gen_helper_recpe_f32(tmp, tmp, fpstatus); | ||
161 | - tcg_temp_free_ptr(fpstatus); | ||
162 | - break; | ||
163 | - } | ||
164 | - case NEON_2RM_VRSQRTE_F: | ||
165 | - { | ||
166 | - TCGv_ptr fpstatus = get_fpstatus_ptr(1); | ||
167 | - gen_helper_rsqrte_f32(tmp, tmp, fpstatus); | ||
168 | - tcg_temp_free_ptr(fpstatus); | ||
169 | - break; | ||
170 | - } | ||
171 | - case NEON_2RM_VCVT_FS: /* VCVT.F32.S32 */ | ||
172 | - { | ||
173 | - TCGv_ptr fpstatus = get_fpstatus_ptr(1); | ||
174 | - gen_helper_vfp_sitos(tmp, tmp, fpstatus); | ||
175 | - tcg_temp_free_ptr(fpstatus); | ||
176 | - break; | ||
177 | - } | ||
178 | - case NEON_2RM_VCVT_FU: /* VCVT.F32.U32 */ | ||
179 | - { | ||
180 | - TCGv_ptr fpstatus = get_fpstatus_ptr(1); | ||
181 | - gen_helper_vfp_uitos(tmp, tmp, fpstatus); | ||
182 | - tcg_temp_free_ptr(fpstatus); | ||
183 | - break; | ||
184 | - } | ||
185 | - case NEON_2RM_VCVT_SF: /* VCVT.S32.F32 */ | ||
186 | - { | ||
187 | - TCGv_ptr fpstatus = get_fpstatus_ptr(1); | ||
188 | - gen_helper_vfp_tosizs(tmp, tmp, fpstatus); | ||
189 | - tcg_temp_free_ptr(fpstatus); | ||
190 | - break; | ||
191 | - } | ||
192 | - case NEON_2RM_VCVT_UF: /* VCVT.U32.F32 */ | ||
193 | - { | ||
194 | - TCGv_ptr fpstatus = get_fpstatus_ptr(1); | ||
195 | - gen_helper_vfp_touizs(tmp, tmp, fpstatus); | ||
196 | - tcg_temp_free_ptr(fpstatus); | ||
197 | - break; | ||
198 | - } | ||
199 | default: | ||
200 | /* Reserved op values were caught by the | ||
201 | * neon_2rm_sizes[] check earlier. | ||
202 | -- | ||
203 | 2.20.1 | ||
204 | |||
205 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Convert the fp-compare-with-zero insns in the Neon 2-reg-misc group to | ||
2 | decodetree. | ||
3 | 1 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20200616170844.13318-17-peter.maydell@linaro.org | ||
7 | --- | ||
8 | target/arm/neon-dp.decode | 6 ++++ | ||
9 | target/arm/translate-neon.inc.c | 28 ++++++++++++++++++ | ||
10 | target/arm/translate.c | 50 ++++----------------------------- | ||
11 | 3 files changed, 39 insertions(+), 45 deletions(-) | ||
12 | |||
13 | diff --git a/target/arm/neon-dp.decode b/target/arm/neon-dp.decode | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/target/arm/neon-dp.decode | ||
16 | +++ b/target/arm/neon-dp.decode | ||
17 | @@ -XXX,XX +XXX,XX @@ Vimm_1r 1111 001 . 1 . 000 ... .... cmode:4 0 . op:1 1 .... @1reg_imm | ||
18 | VABS 1111 001 11 . 11 .. 01 .... 0 0110 . . 0 .... @2misc | ||
19 | VNEG 1111 001 11 . 11 .. 01 .... 0 0111 . . 0 .... @2misc | ||
20 | |||
21 | + VCGT0_F 1111 001 11 . 11 .. 01 .... 0 1000 . . 0 .... @2misc | ||
22 | + VCGE0_F 1111 001 11 . 11 .. 01 .... 0 1001 . . 0 .... @2misc | ||
23 | + VCEQ0_F 1111 001 11 . 11 .. 01 .... 0 1010 . . 0 .... @2misc | ||
24 | + VCLE0_F 1111 001 11 . 11 .. 01 .... 0 1011 . . 0 .... @2misc | ||
25 | + VCLT0_F 1111 001 11 . 11 .. 01 .... 0 1100 . . 0 .... @2misc | ||
26 | + | ||
27 | VABS_F 1111 001 11 . 11 .. 01 .... 0 1110 . . 0 .... @2misc | ||
28 | VNEG_F 1111 001 11 . 11 .. 01 .... 0 1111 . . 0 .... @2misc | ||
29 | |||
30 | diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c | ||
31 | index XXXXXXX..XXXXXXX 100644 | ||
32 | --- a/target/arm/translate-neon.inc.c | ||
33 | +++ b/target/arm/translate-neon.inc.c | ||
34 | @@ -XXX,XX +XXX,XX @@ static bool trans_VRINTX(DisasContext *s, arg_2misc *a) | ||
35 | } | ||
36 | return do_2misc_fp(s, a, gen_helper_rints_exact); | ||
37 | } | ||
38 | + | ||
39 | +#define WRAP_FP_CMP0_FWD(WRAPNAME, FUNC) \ | ||
40 | + static void WRAPNAME(TCGv_i32 d, TCGv_i32 m, TCGv_ptr fpst) \ | ||
41 | + { \ | ||
42 | + TCGv_i32 zero = tcg_const_i32(0); \ | ||
43 | + FUNC(d, m, zero, fpst); \ | ||
44 | + tcg_temp_free_i32(zero); \ | ||
45 | + } | ||
46 | +#define WRAP_FP_CMP0_REV(WRAPNAME, FUNC) \ | ||
47 | + static void WRAPNAME(TCGv_i32 d, TCGv_i32 m, TCGv_ptr fpst) \ | ||
48 | + { \ | ||
49 | + TCGv_i32 zero = tcg_const_i32(0); \ | ||
50 | + FUNC(d, zero, m, fpst); \ | ||
51 | + tcg_temp_free_i32(zero); \ | ||
52 | + } | ||
53 | + | ||
54 | +#define DO_FP_CMP0(INSN, FUNC, REV) \ | ||
55 | + WRAP_FP_CMP0_##REV(gen_##INSN, FUNC) \ | ||
56 | + static bool trans_##INSN(DisasContext *s, arg_2misc *a) \ | ||
57 | + { \ | ||
58 | + return do_2misc_fp(s, a, gen_##INSN); \ | ||
59 | + } | ||
60 | + | ||
61 | +DO_FP_CMP0(VCGT0_F, gen_helper_neon_cgt_f32, FWD) | ||
62 | +DO_FP_CMP0(VCGE0_F, gen_helper_neon_cge_f32, FWD) | ||
63 | +DO_FP_CMP0(VCEQ0_F, gen_helper_neon_ceq_f32, FWD) | ||
64 | +DO_FP_CMP0(VCLE0_F, gen_helper_neon_cge_f32, REV) | ||
65 | +DO_FP_CMP0(VCLT0_F, gen_helper_neon_cgt_f32, REV) | ||
66 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
67 | index XXXXXXX..XXXXXXX 100644 | ||
68 | --- a/target/arm/translate.c | ||
69 | +++ b/target/arm/translate.c | ||
70 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
71 | case NEON_2RM_VCVT_SF: | ||
72 | case NEON_2RM_VCVT_UF: | ||
73 | case NEON_2RM_VRINTX: | ||
74 | + case NEON_2RM_VCGT0_F: | ||
75 | + case NEON_2RM_VCGE0_F: | ||
76 | + case NEON_2RM_VCEQ0_F: | ||
77 | + case NEON_2RM_VCLE0_F: | ||
78 | + case NEON_2RM_VCLT0_F: | ||
79 | /* handled by decodetree */ | ||
80 | return 1; | ||
81 | case NEON_2RM_VTRN: | ||
82 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
83 | for (pass = 0; pass < (q ? 4 : 2); pass++) { | ||
84 | tmp = neon_load_reg(rm, pass); | ||
85 | switch (op) { | ||
86 | - case NEON_2RM_VCGT0_F: | ||
87 | - { | ||
88 | - TCGv_ptr fpstatus = get_fpstatus_ptr(1); | ||
89 | - tmp2 = tcg_const_i32(0); | ||
90 | - gen_helper_neon_cgt_f32(tmp, tmp, tmp2, fpstatus); | ||
91 | - tcg_temp_free_i32(tmp2); | ||
92 | - tcg_temp_free_ptr(fpstatus); | ||
93 | - break; | ||
94 | - } | ||
95 | - case NEON_2RM_VCGE0_F: | ||
96 | - { | ||
97 | - TCGv_ptr fpstatus = get_fpstatus_ptr(1); | ||
98 | - tmp2 = tcg_const_i32(0); | ||
99 | - gen_helper_neon_cge_f32(tmp, tmp, tmp2, fpstatus); | ||
100 | - tcg_temp_free_i32(tmp2); | ||
101 | - tcg_temp_free_ptr(fpstatus); | ||
102 | - break; | ||
103 | - } | ||
104 | - case NEON_2RM_VCEQ0_F: | ||
105 | - { | ||
106 | - TCGv_ptr fpstatus = get_fpstatus_ptr(1); | ||
107 | - tmp2 = tcg_const_i32(0); | ||
108 | - gen_helper_neon_ceq_f32(tmp, tmp, tmp2, fpstatus); | ||
109 | - tcg_temp_free_i32(tmp2); | ||
110 | - tcg_temp_free_ptr(fpstatus); | ||
111 | - break; | ||
112 | - } | ||
113 | - case NEON_2RM_VCLE0_F: | ||
114 | - { | ||
115 | - TCGv_ptr fpstatus = get_fpstatus_ptr(1); | ||
116 | - tmp2 = tcg_const_i32(0); | ||
117 | - gen_helper_neon_cge_f32(tmp, tmp2, tmp, fpstatus); | ||
118 | - tcg_temp_free_i32(tmp2); | ||
119 | - tcg_temp_free_ptr(fpstatus); | ||
120 | - break; | ||
121 | - } | ||
122 | - case NEON_2RM_VCLT0_F: | ||
123 | - { | ||
124 | - TCGv_ptr fpstatus = get_fpstatus_ptr(1); | ||
125 | - tmp2 = tcg_const_i32(0); | ||
126 | - gen_helper_neon_cgt_f32(tmp, tmp2, tmp, fpstatus); | ||
127 | - tcg_temp_free_i32(tmp2); | ||
128 | - tcg_temp_free_ptr(fpstatus); | ||
129 | - break; | ||
130 | - } | ||
131 | case NEON_2RM_VSWP: | ||
132 | tmp2 = neon_load_reg(rd, pass); | ||
133 | neon_store_reg(rm, pass, tmp2); | ||
134 | -- | ||
135 | 2.20.1 | ||
136 | |||
137 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Convert the Neon 2-reg-misc VRINT insns to decodetree. | ||
2 | Giving these insns their own do_vrint() function allows us | ||
3 | to change the rounding mode just once at the start and end | ||
4 | rather than doing it for every element in the vector. | ||
5 | 1 | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20200616170844.13318-18-peter.maydell@linaro.org | ||
9 | --- | ||
10 | target/arm/neon-dp.decode | 8 +++++ | ||
11 | target/arm/translate-neon.inc.c | 61 +++++++++++++++++++++++++++++++++ | ||
12 | target/arm/translate.c | 31 +++-------------- | ||
13 | 3 files changed, 74 insertions(+), 26 deletions(-) | ||
14 | |||
15 | diff --git a/target/arm/neon-dp.decode b/target/arm/neon-dp.decode | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/target/arm/neon-dp.decode | ||
18 | +++ b/target/arm/neon-dp.decode | ||
19 | @@ -XXX,XX +XXX,XX @@ Vimm_1r 1111 001 . 1 . 000 ... .... cmode:4 0 . op:1 1 .... @1reg_imm | ||
20 | SHA1SU1 1111 001 11 . 11 .. 10 .... 0 0111 0 . 0 .... @2misc_q1 | ||
21 | SHA256SU0 1111 001 11 . 11 .. 10 .... 0 0111 1 . 0 .... @2misc_q1 | ||
22 | |||
23 | + VRINTN 1111 001 11 . 11 .. 10 .... 0 1000 . . 0 .... @2misc | ||
24 | VRINTX 1111 001 11 . 11 .. 10 .... 0 1001 . . 0 .... @2misc | ||
25 | + VRINTA 1111 001 11 . 11 .. 10 .... 0 1010 . . 0 .... @2misc | ||
26 | + VRINTZ 1111 001 11 . 11 .. 10 .... 0 1011 . . 0 .... @2misc | ||
27 | |||
28 | VCVT_F16_F32 1111 001 11 . 11 .. 10 .... 0 1100 0 . 0 .... @2misc_q0 | ||
29 | + | ||
30 | + VRINTM 1111 001 11 . 11 .. 10 .... 0 1101 . . 0 .... @2misc | ||
31 | + | ||
32 | VCVT_F32_F16 1111 001 11 . 11 .. 10 .... 0 1110 0 . 0 .... @2misc_q0 | ||
33 | |||
34 | + VRINTP 1111 001 11 . 11 .. 10 .... 0 1111 . . 0 .... @2misc | ||
35 | + | ||
36 | VRECPE 1111 001 11 . 11 .. 11 .... 0 1000 . . 0 .... @2misc | ||
37 | VRSQRTE 1111 001 11 . 11 .. 11 .... 0 1001 . . 0 .... @2misc | ||
38 | VRECPE_F 1111 001 11 . 11 .. 11 .... 0 1010 . . 0 .... @2misc | ||
39 | diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c | ||
40 | index XXXXXXX..XXXXXXX 100644 | ||
41 | --- a/target/arm/translate-neon.inc.c | ||
42 | +++ b/target/arm/translate-neon.inc.c | ||
43 | @@ -XXX,XX +XXX,XX @@ DO_FP_CMP0(VCGE0_F, gen_helper_neon_cge_f32, FWD) | ||
44 | DO_FP_CMP0(VCEQ0_F, gen_helper_neon_ceq_f32, FWD) | ||
45 | DO_FP_CMP0(VCLE0_F, gen_helper_neon_cge_f32, REV) | ||
46 | DO_FP_CMP0(VCLT0_F, gen_helper_neon_cgt_f32, REV) | ||
47 | + | ||
48 | +static bool do_vrint(DisasContext *s, arg_2misc *a, int rmode) | ||
49 | +{ | ||
50 | + /* | ||
51 | + * Handle a VRINT* operation by iterating 32 bits at a time, | ||
52 | + * with a specified rounding mode in operation. | ||
53 | + */ | ||
54 | + int pass; | ||
55 | + TCGv_ptr fpst; | ||
56 | + TCGv_i32 tcg_rmode; | ||
57 | + | ||
58 | + if (!arm_dc_feature(s, ARM_FEATURE_NEON) || | ||
59 | + !arm_dc_feature(s, ARM_FEATURE_V8)) { | ||
60 | + return false; | ||
61 | + } | ||
62 | + | ||
63 | + /* UNDEF accesses to D16-D31 if they don't exist. */ | ||
64 | + if (!dc_isar_feature(aa32_simd_r32, s) && | ||
65 | + ((a->vd | a->vm) & 0x10)) { | ||
66 | + return false; | ||
67 | + } | ||
68 | + | ||
69 | + if (a->size != 2) { | ||
70 | + /* TODO: FP16 will be the size == 1 case */ | ||
71 | + return false; | ||
72 | + } | ||
73 | + | ||
74 | + if ((a->vd | a->vm) & a->q) { | ||
75 | + return false; | ||
76 | + } | ||
77 | + | ||
78 | + if (!vfp_access_check(s)) { | ||
79 | + return true; | ||
80 | + } | ||
81 | + | ||
82 | + fpst = get_fpstatus_ptr(1); | ||
83 | + tcg_rmode = tcg_const_i32(arm_rmode_to_sf(rmode)); | ||
84 | + gen_helper_set_neon_rmode(tcg_rmode, tcg_rmode, cpu_env); | ||
85 | + for (pass = 0; pass < (a->q ? 4 : 2); pass++) { | ||
86 | + TCGv_i32 tmp = neon_load_reg(a->vm, pass); | ||
87 | + gen_helper_rints(tmp, tmp, fpst); | ||
88 | + neon_store_reg(a->vd, pass, tmp); | ||
89 | + } | ||
90 | + gen_helper_set_neon_rmode(tcg_rmode, tcg_rmode, cpu_env); | ||
91 | + tcg_temp_free_i32(tcg_rmode); | ||
92 | + tcg_temp_free_ptr(fpst); | ||
93 | + | ||
94 | + return true; | ||
95 | +} | ||
96 | + | ||
97 | +#define DO_VRINT(INSN, RMODE) \ | ||
98 | + static bool trans_##INSN(DisasContext *s, arg_2misc *a) \ | ||
99 | + { \ | ||
100 | + return do_vrint(s, a, RMODE); \ | ||
101 | + } | ||
102 | + | ||
103 | +DO_VRINT(VRINTN, FPROUNDING_TIEEVEN) | ||
104 | +DO_VRINT(VRINTA, FPROUNDING_TIEAWAY) | ||
105 | +DO_VRINT(VRINTZ, FPROUNDING_ZERO) | ||
106 | +DO_VRINT(VRINTM, FPROUNDING_NEGINF) | ||
107 | +DO_VRINT(VRINTP, FPROUNDING_POSINF) | ||
108 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
109 | index XXXXXXX..XXXXXXX 100644 | ||
110 | --- a/target/arm/translate.c | ||
111 | +++ b/target/arm/translate.c | ||
112 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
113 | case NEON_2RM_VCEQ0_F: | ||
114 | case NEON_2RM_VCLE0_F: | ||
115 | case NEON_2RM_VCLT0_F: | ||
116 | + case NEON_2RM_VRINTN: | ||
117 | + case NEON_2RM_VRINTA: | ||
118 | + case NEON_2RM_VRINTM: | ||
119 | + case NEON_2RM_VRINTP: | ||
120 | + case NEON_2RM_VRINTZ: | ||
121 | /* handled by decodetree */ | ||
122 | return 1; | ||
123 | case NEON_2RM_VTRN: | ||
124 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
125 | } | ||
126 | neon_store_reg(rm, pass, tmp2); | ||
127 | break; | ||
128 | - case NEON_2RM_VRINTN: | ||
129 | - case NEON_2RM_VRINTA: | ||
130 | - case NEON_2RM_VRINTM: | ||
131 | - case NEON_2RM_VRINTP: | ||
132 | - case NEON_2RM_VRINTZ: | ||
133 | - { | ||
134 | - TCGv_i32 tcg_rmode; | ||
135 | - TCGv_ptr fpstatus = get_fpstatus_ptr(1); | ||
136 | - int rmode; | ||
137 | - | ||
138 | - if (op == NEON_2RM_VRINTZ) { | ||
139 | - rmode = FPROUNDING_ZERO; | ||
140 | - } else { | ||
141 | - rmode = fp_decode_rm[((op & 0x6) >> 1) ^ 1]; | ||
142 | - } | ||
143 | - | ||
144 | - tcg_rmode = tcg_const_i32(arm_rmode_to_sf(rmode)); | ||
145 | - gen_helper_set_neon_rmode(tcg_rmode, tcg_rmode, | ||
146 | - cpu_env); | ||
147 | - gen_helper_rints(tmp, tmp, fpstatus); | ||
148 | - gen_helper_set_neon_rmode(tcg_rmode, tcg_rmode, | ||
149 | - cpu_env); | ||
150 | - tcg_temp_free_ptr(fpstatus); | ||
151 | - tcg_temp_free_i32(tcg_rmode); | ||
152 | - break; | ||
153 | - } | ||
154 | case NEON_2RM_VCVTAU: | ||
155 | case NEON_2RM_VCVTAS: | ||
156 | case NEON_2RM_VCVTNU: | ||
157 | -- | ||
158 | 2.20.1 | ||
159 | |||
160 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Convert the VCVT instructions in the 2-reg-misc grouping to | ||
2 | decodetree. | ||
3 | 1 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20200616170844.13318-19-peter.maydell@linaro.org | ||
7 | --- | ||
8 | target/arm/neon-dp.decode | 9 +++++ | ||
9 | target/arm/translate-neon.inc.c | 70 +++++++++++++++++++++++++++++++++ | ||
10 | target/arm/translate.c | 70 ++++----------------------------- | ||
11 | 3 files changed, 87 insertions(+), 62 deletions(-) | ||
12 | |||
13 | diff --git a/target/arm/neon-dp.decode b/target/arm/neon-dp.decode | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/target/arm/neon-dp.decode | ||
16 | +++ b/target/arm/neon-dp.decode | ||
17 | @@ -XXX,XX +XXX,XX @@ Vimm_1r 1111 001 . 1 . 000 ... .... cmode:4 0 . op:1 1 .... @1reg_imm | ||
18 | |||
19 | VRINTP 1111 001 11 . 11 .. 10 .... 0 1111 . . 0 .... @2misc | ||
20 | |||
21 | + VCVTAS 1111 001 11 . 11 .. 11 .... 0 0000 . . 0 .... @2misc | ||
22 | + VCVTAU 1111 001 11 . 11 .. 11 .... 0 0001 . . 0 .... @2misc | ||
23 | + VCVTNS 1111 001 11 . 11 .. 11 .... 0 0010 . . 0 .... @2misc | ||
24 | + VCVTNU 1111 001 11 . 11 .. 11 .... 0 0011 . . 0 .... @2misc | ||
25 | + VCVTPS 1111 001 11 . 11 .. 11 .... 0 0100 . . 0 .... @2misc | ||
26 | + VCVTPU 1111 001 11 . 11 .. 11 .... 0 0101 . . 0 .... @2misc | ||
27 | + VCVTMS 1111 001 11 . 11 .. 11 .... 0 0110 . . 0 .... @2misc | ||
28 | + VCVTMU 1111 001 11 . 11 .. 11 .... 0 0111 . . 0 .... @2misc | ||
29 | + | ||
30 | VRECPE 1111 001 11 . 11 .. 11 .... 0 1000 . . 0 .... @2misc | ||
31 | VRSQRTE 1111 001 11 . 11 .. 11 .... 0 1001 . . 0 .... @2misc | ||
32 | VRECPE_F 1111 001 11 . 11 .. 11 .... 0 1010 . . 0 .... @2misc | ||
33 | diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c | ||
34 | index XXXXXXX..XXXXXXX 100644 | ||
35 | --- a/target/arm/translate-neon.inc.c | ||
36 | +++ b/target/arm/translate-neon.inc.c | ||
37 | @@ -XXX,XX +XXX,XX @@ DO_VRINT(VRINTA, FPROUNDING_TIEAWAY) | ||
38 | DO_VRINT(VRINTZ, FPROUNDING_ZERO) | ||
39 | DO_VRINT(VRINTM, FPROUNDING_NEGINF) | ||
40 | DO_VRINT(VRINTP, FPROUNDING_POSINF) | ||
41 | + | ||
42 | +static bool do_vcvt(DisasContext *s, arg_2misc *a, int rmode, bool is_signed) | ||
43 | +{ | ||
44 | + /* | ||
45 | + * Handle a VCVT* operation by iterating 32 bits at a time, | ||
46 | + * with a specified rounding mode in operation. | ||
47 | + */ | ||
48 | + int pass; | ||
49 | + TCGv_ptr fpst; | ||
50 | + TCGv_i32 tcg_rmode, tcg_shift; | ||
51 | + | ||
52 | + if (!arm_dc_feature(s, ARM_FEATURE_NEON) || | ||
53 | + !arm_dc_feature(s, ARM_FEATURE_V8)) { | ||
54 | + return false; | ||
55 | + } | ||
56 | + | ||
57 | + /* UNDEF accesses to D16-D31 if they don't exist. */ | ||
58 | + if (!dc_isar_feature(aa32_simd_r32, s) && | ||
59 | + ((a->vd | a->vm) & 0x10)) { | ||
60 | + return false; | ||
61 | + } | ||
62 | + | ||
63 | + if (a->size != 2) { | ||
64 | + /* TODO: FP16 will be the size == 1 case */ | ||
65 | + return false; | ||
66 | + } | ||
67 | + | ||
68 | + if ((a->vd | a->vm) & a->q) { | ||
69 | + return false; | ||
70 | + } | ||
71 | + | ||
72 | + if (!vfp_access_check(s)) { | ||
73 | + return true; | ||
74 | + } | ||
75 | + | ||
76 | + fpst = get_fpstatus_ptr(1); | ||
77 | + tcg_shift = tcg_const_i32(0); | ||
78 | + tcg_rmode = tcg_const_i32(arm_rmode_to_sf(rmode)); | ||
79 | + gen_helper_set_neon_rmode(tcg_rmode, tcg_rmode, cpu_env); | ||
80 | + for (pass = 0; pass < (a->q ? 4 : 2); pass++) { | ||
81 | + TCGv_i32 tmp = neon_load_reg(a->vm, pass); | ||
82 | + if (is_signed) { | ||
83 | + gen_helper_vfp_tosls(tmp, tmp, tcg_shift, fpst); | ||
84 | + } else { | ||
85 | + gen_helper_vfp_touls(tmp, tmp, tcg_shift, fpst); | ||
86 | + } | ||
87 | + neon_store_reg(a->vd, pass, tmp); | ||
88 | + } | ||
89 | + gen_helper_set_neon_rmode(tcg_rmode, tcg_rmode, cpu_env); | ||
90 | + tcg_temp_free_i32(tcg_rmode); | ||
91 | + tcg_temp_free_i32(tcg_shift); | ||
92 | + tcg_temp_free_ptr(fpst); | ||
93 | + | ||
94 | + return true; | ||
95 | +} | ||
96 | + | ||
97 | +#define DO_VCVT(INSN, RMODE, SIGNED) \ | ||
98 | + static bool trans_##INSN(DisasContext *s, arg_2misc *a) \ | ||
99 | + { \ | ||
100 | + return do_vcvt(s, a, RMODE, SIGNED); \ | ||
101 | + } | ||
102 | + | ||
103 | +DO_VCVT(VCVTAU, FPROUNDING_TIEAWAY, false) | ||
104 | +DO_VCVT(VCVTAS, FPROUNDING_TIEAWAY, true) | ||
105 | +DO_VCVT(VCVTNU, FPROUNDING_TIEEVEN, false) | ||
106 | +DO_VCVT(VCVTNS, FPROUNDING_TIEEVEN, true) | ||
107 | +DO_VCVT(VCVTPU, FPROUNDING_POSINF, false) | ||
108 | +DO_VCVT(VCVTPS, FPROUNDING_POSINF, true) | ||
109 | +DO_VCVT(VCVTMU, FPROUNDING_NEGINF, false) | ||
110 | +DO_VCVT(VCVTMS, FPROUNDING_NEGINF, true) | ||
111 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
112 | index XXXXXXX..XXXXXXX 100644 | ||
113 | --- a/target/arm/translate.c | ||
114 | +++ b/target/arm/translate.c | ||
115 | @@ -XXX,XX +XXX,XX @@ static void gen_neon_trn_u16(TCGv_i32 t0, TCGv_i32 t1) | ||
116 | #define NEON_2RM_VCVT_SF 62 | ||
117 | #define NEON_2RM_VCVT_UF 63 | ||
118 | |||
119 | -static bool neon_2rm_is_v8_op(int op) | ||
120 | -{ | ||
121 | - /* Return true if this neon 2reg-misc op is ARMv8 and up */ | ||
122 | - switch (op) { | ||
123 | - case NEON_2RM_VRINTN: | ||
124 | - case NEON_2RM_VRINTA: | ||
125 | - case NEON_2RM_VRINTM: | ||
126 | - case NEON_2RM_VRINTP: | ||
127 | - case NEON_2RM_VRINTZ: | ||
128 | - case NEON_2RM_VRINTX: | ||
129 | - case NEON_2RM_VCVTAU: | ||
130 | - case NEON_2RM_VCVTAS: | ||
131 | - case NEON_2RM_VCVTNU: | ||
132 | - case NEON_2RM_VCVTNS: | ||
133 | - case NEON_2RM_VCVTPU: | ||
134 | - case NEON_2RM_VCVTPS: | ||
135 | - case NEON_2RM_VCVTMU: | ||
136 | - case NEON_2RM_VCVTMS: | ||
137 | - return true; | ||
138 | - default: | ||
139 | - return false; | ||
140 | - } | ||
141 | -} | ||
142 | - | ||
143 | /* Each entry in this array has bit n set if the insn allows | ||
144 | * size value n (otherwise it will UNDEF). Since unallocated | ||
145 | * op values will have no bits set they always UNDEF. | ||
146 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
147 | if ((neon_2rm_sizes[op] & (1 << size)) == 0) { | ||
148 | return 1; | ||
149 | } | ||
150 | - if (neon_2rm_is_v8_op(op) && | ||
151 | - !arm_dc_feature(s, ARM_FEATURE_V8)) { | ||
152 | - return 1; | ||
153 | - } | ||
154 | if (q && ((rm | rd) & 1)) { | ||
155 | return 1; | ||
156 | } | ||
157 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
158 | case NEON_2RM_VRINTM: | ||
159 | case NEON_2RM_VRINTP: | ||
160 | case NEON_2RM_VRINTZ: | ||
161 | + case NEON_2RM_VCVTAU: | ||
162 | + case NEON_2RM_VCVTAS: | ||
163 | + case NEON_2RM_VCVTNU: | ||
164 | + case NEON_2RM_VCVTNS: | ||
165 | + case NEON_2RM_VCVTPU: | ||
166 | + case NEON_2RM_VCVTPS: | ||
167 | + case NEON_2RM_VCVTMU: | ||
168 | + case NEON_2RM_VCVTMS: | ||
169 | /* handled by decodetree */ | ||
170 | return 1; | ||
171 | case NEON_2RM_VTRN: | ||
172 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
173 | } | ||
174 | neon_store_reg(rm, pass, tmp2); | ||
175 | break; | ||
176 | - case NEON_2RM_VCVTAU: | ||
177 | - case NEON_2RM_VCVTAS: | ||
178 | - case NEON_2RM_VCVTNU: | ||
179 | - case NEON_2RM_VCVTNS: | ||
180 | - case NEON_2RM_VCVTPU: | ||
181 | - case NEON_2RM_VCVTPS: | ||
182 | - case NEON_2RM_VCVTMU: | ||
183 | - case NEON_2RM_VCVTMS: | ||
184 | - { | ||
185 | - bool is_signed = !extract32(insn, 7, 1); | ||
186 | - TCGv_ptr fpst = get_fpstatus_ptr(1); | ||
187 | - TCGv_i32 tcg_rmode, tcg_shift; | ||
188 | - int rmode = fp_decode_rm[extract32(insn, 8, 2)]; | ||
189 | - | ||
190 | - tcg_shift = tcg_const_i32(0); | ||
191 | - tcg_rmode = tcg_const_i32(arm_rmode_to_sf(rmode)); | ||
192 | - gen_helper_set_neon_rmode(tcg_rmode, tcg_rmode, | ||
193 | - cpu_env); | ||
194 | - | ||
195 | - if (is_signed) { | ||
196 | - gen_helper_vfp_tosls(tmp, tmp, | ||
197 | - tcg_shift, fpst); | ||
198 | - } else { | ||
199 | - gen_helper_vfp_touls(tmp, tmp, | ||
200 | - tcg_shift, fpst); | ||
201 | - } | ||
202 | - | ||
203 | - gen_helper_set_neon_rmode(tcg_rmode, tcg_rmode, | ||
204 | - cpu_env); | ||
205 | - tcg_temp_free_i32(tcg_rmode); | ||
206 | - tcg_temp_free_i32(tcg_shift); | ||
207 | - tcg_temp_free_ptr(fpst); | ||
208 | - break; | ||
209 | - } | ||
210 | default: | ||
211 | /* Reserved op values were caught by the | ||
212 | * neon_2rm_sizes[] check earlier. | ||
213 | -- | ||
214 | 2.20.1 | ||
215 | |||
216 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Convert the Neon VSWP insn to decodetree. Since the new implementation | ||
2 | doesn't have to share a pass-loop with the other 2-reg-misc operations | ||
3 | we can implement the swap with 64-bit accesses rather than 32-bits | ||
4 | (which brings us into line with the pseudocode and is more efficient). | ||
5 | 1 | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20200616170844.13318-20-peter.maydell@linaro.org | ||
9 | --- | ||
10 | target/arm/neon-dp.decode | 2 ++ | ||
11 | target/arm/translate-neon.inc.c | 41 +++++++++++++++++++++++++++++++++ | ||
12 | target/arm/translate.c | 5 +--- | ||
13 | 3 files changed, 44 insertions(+), 4 deletions(-) | ||
14 | |||
15 | diff --git a/target/arm/neon-dp.decode b/target/arm/neon-dp.decode | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/target/arm/neon-dp.decode | ||
18 | +++ b/target/arm/neon-dp.decode | ||
19 | @@ -XXX,XX +XXX,XX @@ Vimm_1r 1111 001 . 1 . 000 ... .... cmode:4 0 . op:1 1 .... @1reg_imm | ||
20 | VABS_F 1111 001 11 . 11 .. 01 .... 0 1110 . . 0 .... @2misc | ||
21 | VNEG_F 1111 001 11 . 11 .. 01 .... 0 1111 . . 0 .... @2misc | ||
22 | |||
23 | + VSWP 1111 001 11 . 11 .. 10 .... 0 0000 . . 0 .... @2misc | ||
24 | + | ||
25 | VUZP 1111 001 11 . 11 .. 10 .... 0 0010 . . 0 .... @2misc | ||
26 | VZIP 1111 001 11 . 11 .. 10 .... 0 0011 . . 0 .... @2misc | ||
27 | |||
28 | diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c | ||
29 | index XXXXXXX..XXXXXXX 100644 | ||
30 | --- a/target/arm/translate-neon.inc.c | ||
31 | +++ b/target/arm/translate-neon.inc.c | ||
32 | @@ -XXX,XX +XXX,XX @@ DO_VCVT(VCVTPU, FPROUNDING_POSINF, false) | ||
33 | DO_VCVT(VCVTPS, FPROUNDING_POSINF, true) | ||
34 | DO_VCVT(VCVTMU, FPROUNDING_NEGINF, false) | ||
35 | DO_VCVT(VCVTMS, FPROUNDING_NEGINF, true) | ||
36 | + | ||
37 | +static bool trans_VSWP(DisasContext *s, arg_2misc *a) | ||
38 | +{ | ||
39 | + TCGv_i64 rm, rd; | ||
40 | + int pass; | ||
41 | + | ||
42 | + if (!arm_dc_feature(s, ARM_FEATURE_NEON)) { | ||
43 | + return false; | ||
44 | + } | ||
45 | + | ||
46 | + /* UNDEF accesses to D16-D31 if they don't exist. */ | ||
47 | + if (!dc_isar_feature(aa32_simd_r32, s) && | ||
48 | + ((a->vd | a->vm) & 0x10)) { | ||
49 | + return false; | ||
50 | + } | ||
51 | + | ||
52 | + if (a->size != 0) { | ||
53 | + return false; | ||
54 | + } | ||
55 | + | ||
56 | + if ((a->vd | a->vm) & a->q) { | ||
57 | + return false; | ||
58 | + } | ||
59 | + | ||
60 | + if (!vfp_access_check(s)) { | ||
61 | + return true; | ||
62 | + } | ||
63 | + | ||
64 | + rm = tcg_temp_new_i64(); | ||
65 | + rd = tcg_temp_new_i64(); | ||
66 | + for (pass = 0; pass < (a->q ? 2 : 1); pass++) { | ||
67 | + neon_load_reg64(rm, a->vm + pass); | ||
68 | + neon_load_reg64(rd, a->vd + pass); | ||
69 | + neon_store_reg64(rm, a->vd + pass); | ||
70 | + neon_store_reg64(rd, a->vm + pass); | ||
71 | + } | ||
72 | + tcg_temp_free_i64(rm); | ||
73 | + tcg_temp_free_i64(rd); | ||
74 | + | ||
75 | + return true; | ||
76 | +} | ||
77 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
78 | index XXXXXXX..XXXXXXX 100644 | ||
79 | --- a/target/arm/translate.c | ||
80 | +++ b/target/arm/translate.c | ||
81 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
82 | case NEON_2RM_VCVTPS: | ||
83 | case NEON_2RM_VCVTMU: | ||
84 | case NEON_2RM_VCVTMS: | ||
85 | + case NEON_2RM_VSWP: | ||
86 | /* handled by decodetree */ | ||
87 | return 1; | ||
88 | case NEON_2RM_VTRN: | ||
89 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
90 | for (pass = 0; pass < (q ? 4 : 2); pass++) { | ||
91 | tmp = neon_load_reg(rm, pass); | ||
92 | switch (op) { | ||
93 | - case NEON_2RM_VSWP: | ||
94 | - tmp2 = neon_load_reg(rd, pass); | ||
95 | - neon_store_reg(rm, pass, tmp2); | ||
96 | - break; | ||
97 | case NEON_2RM_VTRN: | ||
98 | tmp2 = neon_load_reg(rd, pass); | ||
99 | switch (size) { | ||
100 | -- | ||
101 | 2.20.1 | ||
102 | |||
103 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Convert the Neon VTRN insn to decodetree. This is the last insn in the | ||
2 | Neon data-processing group, so we can remove all the now-unused old | ||
3 | decoder framework. | ||
4 | 1 | ||
5 | It's possible that there's a more efficient implementation of | ||
6 | VTRN, but for this conversion we just copy the existing approach. | ||
7 | |||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
10 | Message-id: 20200616170844.13318-21-peter.maydell@linaro.org | ||
11 | --- | ||
12 | target/arm/neon-dp.decode | 2 +- | ||
13 | target/arm/translate-neon.inc.c | 90 ++++++++ | ||
14 | target/arm/translate.c | 363 +------------------------------- | ||
15 | 3 files changed, 93 insertions(+), 362 deletions(-) | ||
16 | |||
17 | diff --git a/target/arm/neon-dp.decode b/target/arm/neon-dp.decode | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/target/arm/neon-dp.decode | ||
20 | +++ b/target/arm/neon-dp.decode | ||
21 | @@ -XXX,XX +XXX,XX @@ Vimm_1r 1111 001 . 1 . 000 ... .... cmode:4 0 . op:1 1 .... @1reg_imm | ||
22 | VNEG_F 1111 001 11 . 11 .. 01 .... 0 1111 . . 0 .... @2misc | ||
23 | |||
24 | VSWP 1111 001 11 . 11 .. 10 .... 0 0000 . . 0 .... @2misc | ||
25 | - | ||
26 | + VTRN 1111 001 11 . 11 .. 10 .... 0 0001 . . 0 .... @2misc | ||
27 | VUZP 1111 001 11 . 11 .. 10 .... 0 0010 . . 0 .... @2misc | ||
28 | VZIP 1111 001 11 . 11 .. 10 .... 0 0011 . . 0 .... @2misc | ||
29 | |||
30 | diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c | ||
31 | index XXXXXXX..XXXXXXX 100644 | ||
32 | --- a/target/arm/translate-neon.inc.c | ||
33 | +++ b/target/arm/translate-neon.inc.c | ||
34 | @@ -XXX,XX +XXX,XX @@ static bool trans_VSWP(DisasContext *s, arg_2misc *a) | ||
35 | |||
36 | return true; | ||
37 | } | ||
38 | +static void gen_neon_trn_u8(TCGv_i32 t0, TCGv_i32 t1) | ||
39 | +{ | ||
40 | + TCGv_i32 rd, tmp; | ||
41 | + | ||
42 | + rd = tcg_temp_new_i32(); | ||
43 | + tmp = tcg_temp_new_i32(); | ||
44 | + | ||
45 | + tcg_gen_shli_i32(rd, t0, 8); | ||
46 | + tcg_gen_andi_i32(rd, rd, 0xff00ff00); | ||
47 | + tcg_gen_andi_i32(tmp, t1, 0x00ff00ff); | ||
48 | + tcg_gen_or_i32(rd, rd, tmp); | ||
49 | + | ||
50 | + tcg_gen_shri_i32(t1, t1, 8); | ||
51 | + tcg_gen_andi_i32(t1, t1, 0x00ff00ff); | ||
52 | + tcg_gen_andi_i32(tmp, t0, 0xff00ff00); | ||
53 | + tcg_gen_or_i32(t1, t1, tmp); | ||
54 | + tcg_gen_mov_i32(t0, rd); | ||
55 | + | ||
56 | + tcg_temp_free_i32(tmp); | ||
57 | + tcg_temp_free_i32(rd); | ||
58 | +} | ||
59 | + | ||
60 | +static void gen_neon_trn_u16(TCGv_i32 t0, TCGv_i32 t1) | ||
61 | +{ | ||
62 | + TCGv_i32 rd, tmp; | ||
63 | + | ||
64 | + rd = tcg_temp_new_i32(); | ||
65 | + tmp = tcg_temp_new_i32(); | ||
66 | + | ||
67 | + tcg_gen_shli_i32(rd, t0, 16); | ||
68 | + tcg_gen_andi_i32(tmp, t1, 0xffff); | ||
69 | + tcg_gen_or_i32(rd, rd, tmp); | ||
70 | + tcg_gen_shri_i32(t1, t1, 16); | ||
71 | + tcg_gen_andi_i32(tmp, t0, 0xffff0000); | ||
72 | + tcg_gen_or_i32(t1, t1, tmp); | ||
73 | + tcg_gen_mov_i32(t0, rd); | ||
74 | + | ||
75 | + tcg_temp_free_i32(tmp); | ||
76 | + tcg_temp_free_i32(rd); | ||
77 | +} | ||
78 | + | ||
79 | +static bool trans_VTRN(DisasContext *s, arg_2misc *a) | ||
80 | +{ | ||
81 | + TCGv_i32 tmp, tmp2; | ||
82 | + int pass; | ||
83 | + | ||
84 | + if (!arm_dc_feature(s, ARM_FEATURE_NEON)) { | ||
85 | + return false; | ||
86 | + } | ||
87 | + | ||
88 | + /* UNDEF accesses to D16-D31 if they don't exist. */ | ||
89 | + if (!dc_isar_feature(aa32_simd_r32, s) && | ||
90 | + ((a->vd | a->vm) & 0x10)) { | ||
91 | + return false; | ||
92 | + } | ||
93 | + | ||
94 | + if ((a->vd | a->vm) & a->q) { | ||
95 | + return false; | ||
96 | + } | ||
97 | + | ||
98 | + if (a->size == 3) { | ||
99 | + return false; | ||
100 | + } | ||
101 | + | ||
102 | + if (!vfp_access_check(s)) { | ||
103 | + return true; | ||
104 | + } | ||
105 | + | ||
106 | + if (a->size == 2) { | ||
107 | + for (pass = 0; pass < (a->q ? 4 : 2); pass += 2) { | ||
108 | + tmp = neon_load_reg(a->vm, pass); | ||
109 | + tmp2 = neon_load_reg(a->vd, pass + 1); | ||
110 | + neon_store_reg(a->vm, pass, tmp2); | ||
111 | + neon_store_reg(a->vd, pass + 1, tmp); | ||
112 | + } | ||
113 | + } else { | ||
114 | + for (pass = 0; pass < (a->q ? 4 : 2); pass++) { | ||
115 | + tmp = neon_load_reg(a->vm, pass); | ||
116 | + tmp2 = neon_load_reg(a->vd, pass); | ||
117 | + if (a->size == 0) { | ||
118 | + gen_neon_trn_u8(tmp, tmp2); | ||
119 | + } else { | ||
120 | + gen_neon_trn_u16(tmp, tmp2); | ||
121 | + } | ||
122 | + neon_store_reg(a->vm, pass, tmp2); | ||
123 | + neon_store_reg(a->vd, pass, tmp); | ||
124 | + } | ||
125 | + } | ||
126 | + return true; | ||
127 | +} | ||
128 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
129 | index XXXXXXX..XXXXXXX 100644 | ||
130 | --- a/target/arm/translate.c | ||
131 | +++ b/target/arm/translate.c | ||
132 | @@ -XXX,XX +XXX,XX @@ static void gen_exception_return(DisasContext *s, TCGv_i32 pc) | ||
133 | gen_rfe(s, pc, load_cpu_field(spsr)); | ||
134 | } | ||
135 | |||
136 | -static void gen_neon_trn_u8(TCGv_i32 t0, TCGv_i32 t1) | ||
137 | -{ | ||
138 | - TCGv_i32 rd, tmp; | ||
139 | - | ||
140 | - rd = tcg_temp_new_i32(); | ||
141 | - tmp = tcg_temp_new_i32(); | ||
142 | - | ||
143 | - tcg_gen_shli_i32(rd, t0, 8); | ||
144 | - tcg_gen_andi_i32(rd, rd, 0xff00ff00); | ||
145 | - tcg_gen_andi_i32(tmp, t1, 0x00ff00ff); | ||
146 | - tcg_gen_or_i32(rd, rd, tmp); | ||
147 | - | ||
148 | - tcg_gen_shri_i32(t1, t1, 8); | ||
149 | - tcg_gen_andi_i32(t1, t1, 0x00ff00ff); | ||
150 | - tcg_gen_andi_i32(tmp, t0, 0xff00ff00); | ||
151 | - tcg_gen_or_i32(t1, t1, tmp); | ||
152 | - tcg_gen_mov_i32(t0, rd); | ||
153 | - | ||
154 | - tcg_temp_free_i32(tmp); | ||
155 | - tcg_temp_free_i32(rd); | ||
156 | -} | ||
157 | - | ||
158 | -static void gen_neon_trn_u16(TCGv_i32 t0, TCGv_i32 t1) | ||
159 | -{ | ||
160 | - TCGv_i32 rd, tmp; | ||
161 | - | ||
162 | - rd = tcg_temp_new_i32(); | ||
163 | - tmp = tcg_temp_new_i32(); | ||
164 | - | ||
165 | - tcg_gen_shli_i32(rd, t0, 16); | ||
166 | - tcg_gen_andi_i32(tmp, t1, 0xffff); | ||
167 | - tcg_gen_or_i32(rd, rd, tmp); | ||
168 | - tcg_gen_shri_i32(t1, t1, 16); | ||
169 | - tcg_gen_andi_i32(tmp, t0, 0xffff0000); | ||
170 | - tcg_gen_or_i32(t1, t1, tmp); | ||
171 | - tcg_gen_mov_i32(t0, rd); | ||
172 | - | ||
173 | - tcg_temp_free_i32(tmp); | ||
174 | - tcg_temp_free_i32(rd); | ||
175 | -} | ||
176 | - | ||
177 | -/* Symbolic constants for op fields for Neon 2-register miscellaneous. | ||
178 | - * The values correspond to bits [17:16,10:7]; see the ARM ARM DDI0406B | ||
179 | - * table A7-13. | ||
180 | - */ | ||
181 | -#define NEON_2RM_VREV64 0 | ||
182 | -#define NEON_2RM_VREV32 1 | ||
183 | -#define NEON_2RM_VREV16 2 | ||
184 | -#define NEON_2RM_VPADDL 4 | ||
185 | -#define NEON_2RM_VPADDL_U 5 | ||
186 | -#define NEON_2RM_AESE 6 /* Includes AESD */ | ||
187 | -#define NEON_2RM_AESMC 7 /* Includes AESIMC */ | ||
188 | -#define NEON_2RM_VCLS 8 | ||
189 | -#define NEON_2RM_VCLZ 9 | ||
190 | -#define NEON_2RM_VCNT 10 | ||
191 | -#define NEON_2RM_VMVN 11 | ||
192 | -#define NEON_2RM_VPADAL 12 | ||
193 | -#define NEON_2RM_VPADAL_U 13 | ||
194 | -#define NEON_2RM_VQABS 14 | ||
195 | -#define NEON_2RM_VQNEG 15 | ||
196 | -#define NEON_2RM_VCGT0 16 | ||
197 | -#define NEON_2RM_VCGE0 17 | ||
198 | -#define NEON_2RM_VCEQ0 18 | ||
199 | -#define NEON_2RM_VCLE0 19 | ||
200 | -#define NEON_2RM_VCLT0 20 | ||
201 | -#define NEON_2RM_SHA1H 21 | ||
202 | -#define NEON_2RM_VABS 22 | ||
203 | -#define NEON_2RM_VNEG 23 | ||
204 | -#define NEON_2RM_VCGT0_F 24 | ||
205 | -#define NEON_2RM_VCGE0_F 25 | ||
206 | -#define NEON_2RM_VCEQ0_F 26 | ||
207 | -#define NEON_2RM_VCLE0_F 27 | ||
208 | -#define NEON_2RM_VCLT0_F 28 | ||
209 | -#define NEON_2RM_VABS_F 30 | ||
210 | -#define NEON_2RM_VNEG_F 31 | ||
211 | -#define NEON_2RM_VSWP 32 | ||
212 | -#define NEON_2RM_VTRN 33 | ||
213 | -#define NEON_2RM_VUZP 34 | ||
214 | -#define NEON_2RM_VZIP 35 | ||
215 | -#define NEON_2RM_VMOVN 36 /* Includes VQMOVN, VQMOVUN */ | ||
216 | -#define NEON_2RM_VQMOVN 37 /* Includes VQMOVUN */ | ||
217 | -#define NEON_2RM_VSHLL 38 | ||
218 | -#define NEON_2RM_SHA1SU1 39 /* Includes SHA256SU0 */ | ||
219 | -#define NEON_2RM_VRINTN 40 | ||
220 | -#define NEON_2RM_VRINTX 41 | ||
221 | -#define NEON_2RM_VRINTA 42 | ||
222 | -#define NEON_2RM_VRINTZ 43 | ||
223 | -#define NEON_2RM_VCVT_F16_F32 44 | ||
224 | -#define NEON_2RM_VRINTM 45 | ||
225 | -#define NEON_2RM_VCVT_F32_F16 46 | ||
226 | -#define NEON_2RM_VRINTP 47 | ||
227 | -#define NEON_2RM_VCVTAU 48 | ||
228 | -#define NEON_2RM_VCVTAS 49 | ||
229 | -#define NEON_2RM_VCVTNU 50 | ||
230 | -#define NEON_2RM_VCVTNS 51 | ||
231 | -#define NEON_2RM_VCVTPU 52 | ||
232 | -#define NEON_2RM_VCVTPS 53 | ||
233 | -#define NEON_2RM_VCVTMU 54 | ||
234 | -#define NEON_2RM_VCVTMS 55 | ||
235 | -#define NEON_2RM_VRECPE 56 | ||
236 | -#define NEON_2RM_VRSQRTE 57 | ||
237 | -#define NEON_2RM_VRECPE_F 58 | ||
238 | -#define NEON_2RM_VRSQRTE_F 59 | ||
239 | -#define NEON_2RM_VCVT_FS 60 | ||
240 | -#define NEON_2RM_VCVT_FU 61 | ||
241 | -#define NEON_2RM_VCVT_SF 62 | ||
242 | -#define NEON_2RM_VCVT_UF 63 | ||
243 | - | ||
244 | -/* Each entry in this array has bit n set if the insn allows | ||
245 | - * size value n (otherwise it will UNDEF). Since unallocated | ||
246 | - * op values will have no bits set they always UNDEF. | ||
247 | - */ | ||
248 | -static const uint8_t neon_2rm_sizes[] = { | ||
249 | - [NEON_2RM_VREV64] = 0x7, | ||
250 | - [NEON_2RM_VREV32] = 0x3, | ||
251 | - [NEON_2RM_VREV16] = 0x1, | ||
252 | - [NEON_2RM_VPADDL] = 0x7, | ||
253 | - [NEON_2RM_VPADDL_U] = 0x7, | ||
254 | - [NEON_2RM_AESE] = 0x1, | ||
255 | - [NEON_2RM_AESMC] = 0x1, | ||
256 | - [NEON_2RM_VCLS] = 0x7, | ||
257 | - [NEON_2RM_VCLZ] = 0x7, | ||
258 | - [NEON_2RM_VCNT] = 0x1, | ||
259 | - [NEON_2RM_VMVN] = 0x1, | ||
260 | - [NEON_2RM_VPADAL] = 0x7, | ||
261 | - [NEON_2RM_VPADAL_U] = 0x7, | ||
262 | - [NEON_2RM_VQABS] = 0x7, | ||
263 | - [NEON_2RM_VQNEG] = 0x7, | ||
264 | - [NEON_2RM_VCGT0] = 0x7, | ||
265 | - [NEON_2RM_VCGE0] = 0x7, | ||
266 | - [NEON_2RM_VCEQ0] = 0x7, | ||
267 | - [NEON_2RM_VCLE0] = 0x7, | ||
268 | - [NEON_2RM_VCLT0] = 0x7, | ||
269 | - [NEON_2RM_SHA1H] = 0x4, | ||
270 | - [NEON_2RM_VABS] = 0x7, | ||
271 | - [NEON_2RM_VNEG] = 0x7, | ||
272 | - [NEON_2RM_VCGT0_F] = 0x4, | ||
273 | - [NEON_2RM_VCGE0_F] = 0x4, | ||
274 | - [NEON_2RM_VCEQ0_F] = 0x4, | ||
275 | - [NEON_2RM_VCLE0_F] = 0x4, | ||
276 | - [NEON_2RM_VCLT0_F] = 0x4, | ||
277 | - [NEON_2RM_VABS_F] = 0x4, | ||
278 | - [NEON_2RM_VNEG_F] = 0x4, | ||
279 | - [NEON_2RM_VSWP] = 0x1, | ||
280 | - [NEON_2RM_VTRN] = 0x7, | ||
281 | - [NEON_2RM_VUZP] = 0x7, | ||
282 | - [NEON_2RM_VZIP] = 0x7, | ||
283 | - [NEON_2RM_VMOVN] = 0x7, | ||
284 | - [NEON_2RM_VQMOVN] = 0x7, | ||
285 | - [NEON_2RM_VSHLL] = 0x7, | ||
286 | - [NEON_2RM_SHA1SU1] = 0x4, | ||
287 | - [NEON_2RM_VRINTN] = 0x4, | ||
288 | - [NEON_2RM_VRINTX] = 0x4, | ||
289 | - [NEON_2RM_VRINTA] = 0x4, | ||
290 | - [NEON_2RM_VRINTZ] = 0x4, | ||
291 | - [NEON_2RM_VCVT_F16_F32] = 0x2, | ||
292 | - [NEON_2RM_VRINTM] = 0x4, | ||
293 | - [NEON_2RM_VCVT_F32_F16] = 0x2, | ||
294 | - [NEON_2RM_VRINTP] = 0x4, | ||
295 | - [NEON_2RM_VCVTAU] = 0x4, | ||
296 | - [NEON_2RM_VCVTAS] = 0x4, | ||
297 | - [NEON_2RM_VCVTNU] = 0x4, | ||
298 | - [NEON_2RM_VCVTNS] = 0x4, | ||
299 | - [NEON_2RM_VCVTPU] = 0x4, | ||
300 | - [NEON_2RM_VCVTPS] = 0x4, | ||
301 | - [NEON_2RM_VCVTMU] = 0x4, | ||
302 | - [NEON_2RM_VCVTMS] = 0x4, | ||
303 | - [NEON_2RM_VRECPE] = 0x4, | ||
304 | - [NEON_2RM_VRSQRTE] = 0x4, | ||
305 | - [NEON_2RM_VRECPE_F] = 0x4, | ||
306 | - [NEON_2RM_VRSQRTE_F] = 0x4, | ||
307 | - [NEON_2RM_VCVT_FS] = 0x4, | ||
308 | - [NEON_2RM_VCVT_FU] = 0x4, | ||
309 | - [NEON_2RM_VCVT_SF] = 0x4, | ||
310 | - [NEON_2RM_VCVT_UF] = 0x4, | ||
311 | -}; | ||
312 | - | ||
313 | static void gen_gvec_fn3_qc(uint32_t rd_ofs, uint32_t rn_ofs, uint32_t rm_ofs, | ||
314 | uint32_t opr_sz, uint32_t max_sz, | ||
315 | gen_helper_gvec_3_ptr *fn) | ||
316 | @@ -XXX,XX +XXX,XX @@ void gen_gvec_uaba(unsigned vece, uint32_t rd_ofs, uint32_t rn_ofs, | ||
317 | tcg_gen_gvec_3(rd_ofs, rn_ofs, rm_ofs, opr_sz, max_sz, &ops[vece]); | ||
318 | } | ||
319 | |||
320 | -/* Translate a NEON data processing instruction. Return nonzero if the | ||
321 | - instruction is invalid. | ||
322 | - We process data in a mixture of 32-bit and 64-bit chunks. | ||
323 | - Mostly we use 32-bit chunks so we can use normal scalar instructions. */ | ||
324 | - | ||
325 | -static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
326 | -{ | ||
327 | - int op; | ||
328 | - int q; | ||
329 | - int rd, rm; | ||
330 | - int size; | ||
331 | - int pass; | ||
332 | - int u; | ||
333 | - TCGv_i32 tmp, tmp2; | ||
334 | - | ||
335 | - if (!arm_dc_feature(s, ARM_FEATURE_NEON)) { | ||
336 | - return 1; | ||
337 | - } | ||
338 | - | ||
339 | - /* FIXME: this access check should not take precedence over UNDEF | ||
340 | - * for invalid encodings; we will generate incorrect syndrome information | ||
341 | - * for attempts to execute invalid vfp/neon encodings with FP disabled. | ||
342 | - */ | ||
343 | - if (s->fp_excp_el) { | ||
344 | - gen_exception_insn(s, s->pc_curr, EXCP_UDEF, | ||
345 | - syn_simd_access_trap(1, 0xe, false), s->fp_excp_el); | ||
346 | - return 0; | ||
347 | - } | ||
348 | - | ||
349 | - if (!s->vfp_enabled) | ||
350 | - return 1; | ||
351 | - q = (insn & (1 << 6)) != 0; | ||
352 | - u = (insn >> 24) & 1; | ||
353 | - VFP_DREG_D(rd, insn); | ||
354 | - VFP_DREG_M(rm, insn); | ||
355 | - size = (insn >> 20) & 3; | ||
356 | - | ||
357 | - if ((insn & (1 << 23)) == 0) { | ||
358 | - /* Three register same length: handled by decodetree */ | ||
359 | - return 1; | ||
360 | - } else if (insn & (1 << 4)) { | ||
361 | - /* Two registers and shift or reg and imm: handled by decodetree */ | ||
362 | - return 1; | ||
363 | - } else { /* (insn & 0x00800010 == 0x00800000) */ | ||
364 | - if (size != 3) { | ||
365 | - /* | ||
366 | - * Three registers of different lengths, or two registers and | ||
367 | - * a scalar: handled by decodetree | ||
368 | - */ | ||
369 | - return 1; | ||
370 | - } else { /* size == 3 */ | ||
371 | - if (!u) { | ||
372 | - /* Extract: handled by decodetree */ | ||
373 | - return 1; | ||
374 | - } else if ((insn & (1 << 11)) == 0) { | ||
375 | - /* Two register misc. */ | ||
376 | - op = ((insn >> 12) & 0x30) | ((insn >> 7) & 0xf); | ||
377 | - size = (insn >> 18) & 3; | ||
378 | - /* UNDEF for unknown op values and bad op-size combinations */ | ||
379 | - if ((neon_2rm_sizes[op] & (1 << size)) == 0) { | ||
380 | - return 1; | ||
381 | - } | ||
382 | - if (q && ((rm | rd) & 1)) { | ||
383 | - return 1; | ||
384 | - } | ||
385 | - switch (op) { | ||
386 | - case NEON_2RM_VREV64: | ||
387 | - case NEON_2RM_VPADDL: case NEON_2RM_VPADDL_U: | ||
388 | - case NEON_2RM_VPADAL: case NEON_2RM_VPADAL_U: | ||
389 | - case NEON_2RM_VUZP: | ||
390 | - case NEON_2RM_VZIP: | ||
391 | - case NEON_2RM_VMOVN: case NEON_2RM_VQMOVN: | ||
392 | - case NEON_2RM_VSHLL: | ||
393 | - case NEON_2RM_VCVT_F16_F32: | ||
394 | - case NEON_2RM_VCVT_F32_F16: | ||
395 | - case NEON_2RM_VMVN: | ||
396 | - case NEON_2RM_VNEG: | ||
397 | - case NEON_2RM_VABS: | ||
398 | - case NEON_2RM_VCEQ0: | ||
399 | - case NEON_2RM_VCGT0: | ||
400 | - case NEON_2RM_VCLE0: | ||
401 | - case NEON_2RM_VCGE0: | ||
402 | - case NEON_2RM_VCLT0: | ||
403 | - case NEON_2RM_AESE: case NEON_2RM_AESMC: | ||
404 | - case NEON_2RM_SHA1H: | ||
405 | - case NEON_2RM_SHA1SU1: | ||
406 | - case NEON_2RM_VREV32: | ||
407 | - case NEON_2RM_VREV16: | ||
408 | - case NEON_2RM_VCLS: | ||
409 | - case NEON_2RM_VCLZ: | ||
410 | - case NEON_2RM_VCNT: | ||
411 | - case NEON_2RM_VABS_F: | ||
412 | - case NEON_2RM_VNEG_F: | ||
413 | - case NEON_2RM_VRECPE: | ||
414 | - case NEON_2RM_VRSQRTE: | ||
415 | - case NEON_2RM_VQABS: | ||
416 | - case NEON_2RM_VQNEG: | ||
417 | - case NEON_2RM_VRECPE_F: | ||
418 | - case NEON_2RM_VRSQRTE_F: | ||
419 | - case NEON_2RM_VCVT_FS: | ||
420 | - case NEON_2RM_VCVT_FU: | ||
421 | - case NEON_2RM_VCVT_SF: | ||
422 | - case NEON_2RM_VCVT_UF: | ||
423 | - case NEON_2RM_VRINTX: | ||
424 | - case NEON_2RM_VCGT0_F: | ||
425 | - case NEON_2RM_VCGE0_F: | ||
426 | - case NEON_2RM_VCEQ0_F: | ||
427 | - case NEON_2RM_VCLE0_F: | ||
428 | - case NEON_2RM_VCLT0_F: | ||
429 | - case NEON_2RM_VRINTN: | ||
430 | - case NEON_2RM_VRINTA: | ||
431 | - case NEON_2RM_VRINTM: | ||
432 | - case NEON_2RM_VRINTP: | ||
433 | - case NEON_2RM_VRINTZ: | ||
434 | - case NEON_2RM_VCVTAU: | ||
435 | - case NEON_2RM_VCVTAS: | ||
436 | - case NEON_2RM_VCVTNU: | ||
437 | - case NEON_2RM_VCVTNS: | ||
438 | - case NEON_2RM_VCVTPU: | ||
439 | - case NEON_2RM_VCVTPS: | ||
440 | - case NEON_2RM_VCVTMU: | ||
441 | - case NEON_2RM_VCVTMS: | ||
442 | - case NEON_2RM_VSWP: | ||
443 | - /* handled by decodetree */ | ||
444 | - return 1; | ||
445 | - case NEON_2RM_VTRN: | ||
446 | - if (size == 2) { | ||
447 | - int n; | ||
448 | - for (n = 0; n < (q ? 4 : 2); n += 2) { | ||
449 | - tmp = neon_load_reg(rm, n); | ||
450 | - tmp2 = neon_load_reg(rd, n + 1); | ||
451 | - neon_store_reg(rm, n, tmp2); | ||
452 | - neon_store_reg(rd, n + 1, tmp); | ||
453 | - } | ||
454 | - } else { | ||
455 | - goto elementwise; | ||
456 | - } | ||
457 | - break; | ||
458 | - | ||
459 | - default: | ||
460 | - elementwise: | ||
461 | - for (pass = 0; pass < (q ? 4 : 2); pass++) { | ||
462 | - tmp = neon_load_reg(rm, pass); | ||
463 | - switch (op) { | ||
464 | - case NEON_2RM_VTRN: | ||
465 | - tmp2 = neon_load_reg(rd, pass); | ||
466 | - switch (size) { | ||
467 | - case 0: gen_neon_trn_u8(tmp, tmp2); break; | ||
468 | - case 1: gen_neon_trn_u16(tmp, tmp2); break; | ||
469 | - default: abort(); | ||
470 | - } | ||
471 | - neon_store_reg(rm, pass, tmp2); | ||
472 | - break; | ||
473 | - default: | ||
474 | - /* Reserved op values were caught by the | ||
475 | - * neon_2rm_sizes[] check earlier. | ||
476 | - */ | ||
477 | - abort(); | ||
478 | - } | ||
479 | - neon_store_reg(rd, pass, tmp); | ||
480 | - } | ||
481 | - break; | ||
482 | - } | ||
483 | - } else { | ||
484 | - /* VTBL, VTBX, VDUP: handled by decodetree */ | ||
485 | - return 1; | ||
486 | - } | ||
487 | - } | ||
488 | - } | ||
489 | - return 0; | ||
490 | -} | ||
491 | - | ||
492 | static int disas_coproc_insn(DisasContext *s, uint32_t insn) | ||
493 | { | ||
494 | int cpnum, is64, crn, crm, opc1, opc2, isread, rt, rt2; | ||
495 | @@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) | ||
496 | } | ||
497 | /* fall back to legacy decoder */ | ||
498 | |||
499 | - if (((insn >> 25) & 7) == 1) { | ||
500 | - /* NEON Data processing. */ | ||
501 | - if (disas_neon_data_insn(s, insn)) { | ||
502 | - goto illegal_op; | ||
503 | - } | ||
504 | - return; | ||
505 | - } | ||
506 | if ((insn & 0x0e000f00) == 0x0c000100) { | ||
507 | if (arm_dc_feature(s, ARM_FEATURE_IWMMXT)) { | ||
508 | /* iWMMXt register transfer. */ | ||
509 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) | ||
510 | break; | ||
511 | } | ||
512 | if (((insn >> 24) & 3) == 3) { | ||
513 | - /* Translate into the equivalent ARM encoding. */ | ||
514 | - insn = (insn & 0xe2ffffff) | ((insn & (1 << 28)) >> 4) | (1 << 28); | ||
515 | - if (disas_neon_data_insn(s, insn)) { | ||
516 | - goto illegal_op; | ||
517 | - } | ||
518 | + /* Neon DP, but failed disas_neon_dp() */ | ||
519 | + goto illegal_op; | ||
520 | } else if (((insn >> 8) & 0xe) == 10) { | ||
521 | /* VFP, but failed disas_vfp. */ | ||
522 | goto illegal_op; | ||
523 | -- | ||
524 | 2.20.1 | ||
525 | |||
526 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | The functions neon_element_offset(), neon_load_element(), | ||
2 | neon_load_element64(), neon_store_element() and | ||
3 | neon_store_element64() are used only in the translate-neon.inc.c | ||
4 | file, so move their definitions there. | ||
5 | 1 | ||
6 | Since the .inc.c file is #included in translate.c this doesn't make | ||
7 | much difference currently, but it's a more logical place to put the | ||
8 | functions and it might be helpful if we ever decide to try to make | ||
9 | the .inc.c files genuinely separate compilation units. | ||
10 | |||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
13 | Message-id: 20200616170844.13318-22-peter.maydell@linaro.org | ||
14 | --- | ||
15 | target/arm/translate-neon.inc.c | 101 ++++++++++++++++++++++++++++++++ | ||
16 | target/arm/translate.c | 101 -------------------------------- | ||
17 | 2 files changed, 101 insertions(+), 101 deletions(-) | ||
18 | |||
19 | diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c | ||
20 | index XXXXXXX..XXXXXXX 100644 | ||
21 | --- a/target/arm/translate-neon.inc.c | ||
22 | +++ b/target/arm/translate-neon.inc.c | ||
23 | @@ -XXX,XX +XXX,XX @@ static inline int rsub_8(DisasContext *s, int x) | ||
24 | #include "decode-neon-ls.inc.c" | ||
25 | #include "decode-neon-shared.inc.c" | ||
26 | |||
27 | +/* Return the offset of a 2**SIZE piece of a NEON register, at index ELE, | ||
28 | + * where 0 is the least significant end of the register. | ||
29 | + */ | ||
30 | +static inline long | ||
31 | +neon_element_offset(int reg, int element, MemOp size) | ||
32 | +{ | ||
33 | + int element_size = 1 << size; | ||
34 | + int ofs = element * element_size; | ||
35 | +#ifdef HOST_WORDS_BIGENDIAN | ||
36 | + /* Calculate the offset assuming fully little-endian, | ||
37 | + * then XOR to account for the order of the 8-byte units. | ||
38 | + */ | ||
39 | + if (element_size < 8) { | ||
40 | + ofs ^= 8 - element_size; | ||
41 | + } | ||
42 | +#endif | ||
43 | + return neon_reg_offset(reg, 0) + ofs; | ||
44 | +} | ||
45 | + | ||
46 | +static void neon_load_element(TCGv_i32 var, int reg, int ele, MemOp mop) | ||
47 | +{ | ||
48 | + long offset = neon_element_offset(reg, ele, mop & MO_SIZE); | ||
49 | + | ||
50 | + switch (mop) { | ||
51 | + case MO_UB: | ||
52 | + tcg_gen_ld8u_i32(var, cpu_env, offset); | ||
53 | + break; | ||
54 | + case MO_UW: | ||
55 | + tcg_gen_ld16u_i32(var, cpu_env, offset); | ||
56 | + break; | ||
57 | + case MO_UL: | ||
58 | + tcg_gen_ld_i32(var, cpu_env, offset); | ||
59 | + break; | ||
60 | + default: | ||
61 | + g_assert_not_reached(); | ||
62 | + } | ||
63 | +} | ||
64 | + | ||
65 | +static void neon_load_element64(TCGv_i64 var, int reg, int ele, MemOp mop) | ||
66 | +{ | ||
67 | + long offset = neon_element_offset(reg, ele, mop & MO_SIZE); | ||
68 | + | ||
69 | + switch (mop) { | ||
70 | + case MO_UB: | ||
71 | + tcg_gen_ld8u_i64(var, cpu_env, offset); | ||
72 | + break; | ||
73 | + case MO_UW: | ||
74 | + tcg_gen_ld16u_i64(var, cpu_env, offset); | ||
75 | + break; | ||
76 | + case MO_UL: | ||
77 | + tcg_gen_ld32u_i64(var, cpu_env, offset); | ||
78 | + break; | ||
79 | + case MO_Q: | ||
80 | + tcg_gen_ld_i64(var, cpu_env, offset); | ||
81 | + break; | ||
82 | + default: | ||
83 | + g_assert_not_reached(); | ||
84 | + } | ||
85 | +} | ||
86 | + | ||
87 | +static void neon_store_element(int reg, int ele, MemOp size, TCGv_i32 var) | ||
88 | +{ | ||
89 | + long offset = neon_element_offset(reg, ele, size); | ||
90 | + | ||
91 | + switch (size) { | ||
92 | + case MO_8: | ||
93 | + tcg_gen_st8_i32(var, cpu_env, offset); | ||
94 | + break; | ||
95 | + case MO_16: | ||
96 | + tcg_gen_st16_i32(var, cpu_env, offset); | ||
97 | + break; | ||
98 | + case MO_32: | ||
99 | + tcg_gen_st_i32(var, cpu_env, offset); | ||
100 | + break; | ||
101 | + default: | ||
102 | + g_assert_not_reached(); | ||
103 | + } | ||
104 | +} | ||
105 | + | ||
106 | +static void neon_store_element64(int reg, int ele, MemOp size, TCGv_i64 var) | ||
107 | +{ | ||
108 | + long offset = neon_element_offset(reg, ele, size); | ||
109 | + | ||
110 | + switch (size) { | ||
111 | + case MO_8: | ||
112 | + tcg_gen_st8_i64(var, cpu_env, offset); | ||
113 | + break; | ||
114 | + case MO_16: | ||
115 | + tcg_gen_st16_i64(var, cpu_env, offset); | ||
116 | + break; | ||
117 | + case MO_32: | ||
118 | + tcg_gen_st32_i64(var, cpu_env, offset); | ||
119 | + break; | ||
120 | + case MO_64: | ||
121 | + tcg_gen_st_i64(var, cpu_env, offset); | ||
122 | + break; | ||
123 | + default: | ||
124 | + g_assert_not_reached(); | ||
125 | + } | ||
126 | +} | ||
127 | + | ||
128 | static bool trans_VCMLA(DisasContext *s, arg_VCMLA *a) | ||
129 | { | ||
130 | int opr_sz; | ||
131 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
132 | index XXXXXXX..XXXXXXX 100644 | ||
133 | --- a/target/arm/translate.c | ||
134 | +++ b/target/arm/translate.c | ||
135 | @@ -XXX,XX +XXX,XX @@ neon_reg_offset (int reg, int n) | ||
136 | return vfp_reg_offset(0, sreg); | ||
137 | } | ||
138 | |||
139 | -/* Return the offset of a 2**SIZE piece of a NEON register, at index ELE, | ||
140 | - * where 0 is the least significant end of the register. | ||
141 | - */ | ||
142 | -static inline long | ||
143 | -neon_element_offset(int reg, int element, MemOp size) | ||
144 | -{ | ||
145 | - int element_size = 1 << size; | ||
146 | - int ofs = element * element_size; | ||
147 | -#ifdef HOST_WORDS_BIGENDIAN | ||
148 | - /* Calculate the offset assuming fully little-endian, | ||
149 | - * then XOR to account for the order of the 8-byte units. | ||
150 | - */ | ||
151 | - if (element_size < 8) { | ||
152 | - ofs ^= 8 - element_size; | ||
153 | - } | ||
154 | -#endif | ||
155 | - return neon_reg_offset(reg, 0) + ofs; | ||
156 | -} | ||
157 | - | ||
158 | static TCGv_i32 neon_load_reg(int reg, int pass) | ||
159 | { | ||
160 | TCGv_i32 tmp = tcg_temp_new_i32(); | ||
161 | @@ -XXX,XX +XXX,XX @@ static TCGv_i32 neon_load_reg(int reg, int pass) | ||
162 | return tmp; | ||
163 | } | ||
164 | |||
165 | -static void neon_load_element(TCGv_i32 var, int reg, int ele, MemOp mop) | ||
166 | -{ | ||
167 | - long offset = neon_element_offset(reg, ele, mop & MO_SIZE); | ||
168 | - | ||
169 | - switch (mop) { | ||
170 | - case MO_UB: | ||
171 | - tcg_gen_ld8u_i32(var, cpu_env, offset); | ||
172 | - break; | ||
173 | - case MO_UW: | ||
174 | - tcg_gen_ld16u_i32(var, cpu_env, offset); | ||
175 | - break; | ||
176 | - case MO_UL: | ||
177 | - tcg_gen_ld_i32(var, cpu_env, offset); | ||
178 | - break; | ||
179 | - default: | ||
180 | - g_assert_not_reached(); | ||
181 | - } | ||
182 | -} | ||
183 | - | ||
184 | -static void neon_load_element64(TCGv_i64 var, int reg, int ele, MemOp mop) | ||
185 | -{ | ||
186 | - long offset = neon_element_offset(reg, ele, mop & MO_SIZE); | ||
187 | - | ||
188 | - switch (mop) { | ||
189 | - case MO_UB: | ||
190 | - tcg_gen_ld8u_i64(var, cpu_env, offset); | ||
191 | - break; | ||
192 | - case MO_UW: | ||
193 | - tcg_gen_ld16u_i64(var, cpu_env, offset); | ||
194 | - break; | ||
195 | - case MO_UL: | ||
196 | - tcg_gen_ld32u_i64(var, cpu_env, offset); | ||
197 | - break; | ||
198 | - case MO_Q: | ||
199 | - tcg_gen_ld_i64(var, cpu_env, offset); | ||
200 | - break; | ||
201 | - default: | ||
202 | - g_assert_not_reached(); | ||
203 | - } | ||
204 | -} | ||
205 | - | ||
206 | static void neon_store_reg(int reg, int pass, TCGv_i32 var) | ||
207 | { | ||
208 | tcg_gen_st_i32(var, cpu_env, neon_reg_offset(reg, pass)); | ||
209 | tcg_temp_free_i32(var); | ||
210 | } | ||
211 | |||
212 | -static void neon_store_element(int reg, int ele, MemOp size, TCGv_i32 var) | ||
213 | -{ | ||
214 | - long offset = neon_element_offset(reg, ele, size); | ||
215 | - | ||
216 | - switch (size) { | ||
217 | - case MO_8: | ||
218 | - tcg_gen_st8_i32(var, cpu_env, offset); | ||
219 | - break; | ||
220 | - case MO_16: | ||
221 | - tcg_gen_st16_i32(var, cpu_env, offset); | ||
222 | - break; | ||
223 | - case MO_32: | ||
224 | - tcg_gen_st_i32(var, cpu_env, offset); | ||
225 | - break; | ||
226 | - default: | ||
227 | - g_assert_not_reached(); | ||
228 | - } | ||
229 | -} | ||
230 | - | ||
231 | -static void neon_store_element64(int reg, int ele, MemOp size, TCGv_i64 var) | ||
232 | -{ | ||
233 | - long offset = neon_element_offset(reg, ele, size); | ||
234 | - | ||
235 | - switch (size) { | ||
236 | - case MO_8: | ||
237 | - tcg_gen_st8_i64(var, cpu_env, offset); | ||
238 | - break; | ||
239 | - case MO_16: | ||
240 | - tcg_gen_st16_i64(var, cpu_env, offset); | ||
241 | - break; | ||
242 | - case MO_32: | ||
243 | - tcg_gen_st32_i64(var, cpu_env, offset); | ||
244 | - break; | ||
245 | - case MO_64: | ||
246 | - tcg_gen_st_i64(var, cpu_env, offset); | ||
247 | - break; | ||
248 | - default: | ||
249 | - g_assert_not_reached(); | ||
250 | - } | ||
251 | -} | ||
252 | - | ||
253 | static inline void neon_load_reg64(TCGv_i64 var, int reg) | ||
254 | { | ||
255 | tcg_gen_ld_i64(var, cpu_env, vfp_reg_offset(1, reg)); | ||
256 | -- | ||
257 | 2.20.1 | ||
258 | |||
259 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | In commit cfdb2c0c95ae9205b0 ("target/arm: Vectorize SABA/UABA") we | ||
2 | replaced the old handling of SABA/UABA with a vectorized implementation | ||
3 | which returns early rather than falling into the loop-ever-elements | ||
4 | code. We forgot to delete the part of the old looping code that | ||
5 | did the accumulate step, and Coverity correctly warns (CID 1428955) | ||
6 | that this code is now dead. Delete it. | ||
7 | 1 | ||
8 | Fixes: cfdb2c0c95ae9205b0 | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
11 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
12 | Message-id: 20200619171547.29780-1-peter.maydell@linaro.org | ||
13 | --- | ||
14 | target/arm/translate-a64.c | 12 ------------ | ||
15 | 1 file changed, 12 deletions(-) | ||
16 | |||
17 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/target/arm/translate-a64.c | ||
20 | +++ b/target/arm/translate-a64.c | ||
21 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_3same_int(DisasContext *s, uint32_t insn) | ||
22 | genfn(tcg_res, tcg_op1, tcg_op2); | ||
23 | } | ||
24 | |||
25 | - if (opcode == 0xf) { | ||
26 | - /* SABA, UABA: accumulating ops */ | ||
27 | - static NeonGenTwoOpFn * const fns[3] = { | ||
28 | - gen_helper_neon_add_u8, | ||
29 | - gen_helper_neon_add_u16, | ||
30 | - tcg_gen_add_i32, | ||
31 | - }; | ||
32 | - | ||
33 | - read_vec_element_i32(s, tcg_op1, rd, pass, MO_32); | ||
34 | - fns[size](tcg_res, tcg_op1, tcg_res); | ||
35 | - } | ||
36 | - | ||
37 | write_vec_element_i32(s, tcg_res, rd, pass, MO_32); | ||
38 | |||
39 | tcg_temp_free_i32(tcg_res); | ||
40 | -- | ||
41 | 2.20.1 | ||
42 | |||
43 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
2 | 1 | ||
3 | Add a trace event to see when a guest disable/enable the watchdog. | ||
4 | |||
5 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
6 | Message-id: 20200617072539.32686-2-f4bug@amsat.org | ||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | --- | ||
10 | hw/watchdog/cmsdk-apb-watchdog.c | 1 + | ||
11 | hw/watchdog/trace-events | 1 + | ||
12 | 2 files changed, 2 insertions(+) | ||
13 | |||
14 | diff --git a/hw/watchdog/cmsdk-apb-watchdog.c b/hw/watchdog/cmsdk-apb-watchdog.c | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/hw/watchdog/cmsdk-apb-watchdog.c | ||
17 | +++ b/hw/watchdog/cmsdk-apb-watchdog.c | ||
18 | @@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_watchdog_write(void *opaque, hwaddr offset, | ||
19 | break; | ||
20 | case A_WDOGLOCK: | ||
21 | s->lock = (value != WDOG_UNLOCK_VALUE); | ||
22 | + trace_cmsdk_apb_watchdog_lock(s->lock); | ||
23 | break; | ||
24 | case A_WDOGITCR: | ||
25 | if (s->is_luminary) { | ||
26 | diff --git a/hw/watchdog/trace-events b/hw/watchdog/trace-events | ||
27 | index XXXXXXX..XXXXXXX 100644 | ||
28 | --- a/hw/watchdog/trace-events | ||
29 | +++ b/hw/watchdog/trace-events | ||
30 | @@ -XXX,XX +XXX,XX @@ | ||
31 | cmsdk_apb_watchdog_read(uint64_t offset, uint64_t data, unsigned size) "CMSDK APB watchdog read: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u" | ||
32 | cmsdk_apb_watchdog_write(uint64_t offset, uint64_t data, unsigned size) "CMSDK APB watchdog write: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u" | ||
33 | cmsdk_apb_watchdog_reset(void) "CMSDK APB watchdog: reset" | ||
34 | +cmsdk_apb_watchdog_lock(uint32_t lock) "CMSDK APB watchdog: lock %" PRIu32 | ||
35 | -- | ||
36 | 2.20.1 | ||
37 | |||
38 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
2 | 1 | ||
3 | Use self-explicit definitions instead of magic values. | ||
4 | |||
5 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
6 | Message-id: 20200617072539.32686-3-f4bug@amsat.org | ||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | --- | ||
10 | hw/i2c/versatile_i2c.c | 14 ++++++++++---- | ||
11 | 1 file changed, 10 insertions(+), 4 deletions(-) | ||
12 | |||
13 | diff --git a/hw/i2c/versatile_i2c.c b/hw/i2c/versatile_i2c.c | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/hw/i2c/versatile_i2c.c | ||
16 | +++ b/hw/i2c/versatile_i2c.c | ||
17 | @@ -XXX,XX +XXX,XX @@ | ||
18 | #include "qemu/osdep.h" | ||
19 | #include "hw/sysbus.h" | ||
20 | #include "hw/i2c/bitbang_i2c.h" | ||
21 | +#include "hw/registerfields.h" | ||
22 | #include "qemu/log.h" | ||
23 | #include "qemu/module.h" | ||
24 | |||
25 | @@ -XXX,XX +XXX,XX @@ typedef struct VersatileI2CState { | ||
26 | int in; | ||
27 | } VersatileI2CState; | ||
28 | |||
29 | +REG32(CONTROL_GET, 0) | ||
30 | +REG32(CONTROL_SET, 0) | ||
31 | +REG32(CONTROL_CLR, 4) | ||
32 | + | ||
33 | static uint64_t versatile_i2c_read(void *opaque, hwaddr offset, | ||
34 | unsigned size) | ||
35 | { | ||
36 | VersatileI2CState *s = (VersatileI2CState *)opaque; | ||
37 | |||
38 | - if (offset == 0) { | ||
39 | + switch (offset) { | ||
40 | + case A_CONTROL_SET: | ||
41 | return (s->out & 1) | (s->in << 1); | ||
42 | - } else { | ||
43 | + default: | ||
44 | qemu_log_mask(LOG_GUEST_ERROR, | ||
45 | "%s: Bad offset 0x%x\n", __func__, (int)offset); | ||
46 | return -1; | ||
47 | @@ -XXX,XX +XXX,XX @@ static void versatile_i2c_write(void *opaque, hwaddr offset, | ||
48 | VersatileI2CState *s = (VersatileI2CState *)opaque; | ||
49 | |||
50 | switch (offset) { | ||
51 | - case 0: | ||
52 | + case A_CONTROL_SET: | ||
53 | s->out |= value & 3; | ||
54 | break; | ||
55 | - case 4: | ||
56 | + case A_CONTROL_CLR: | ||
57 | s->out &= ~value; | ||
58 | break; | ||
59 | default: | ||
60 | -- | ||
61 | 2.20.1 | ||
62 | |||
63 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
2 | 1 | ||
3 | Use self-explicit definitions instead of magic values. | ||
4 | |||
5 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
6 | Message-id: 20200617072539.32686-4-f4bug@amsat.org | ||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | --- | ||
10 | hw/i2c/versatile_i2c.c | 7 +++++-- | ||
11 | 1 file changed, 5 insertions(+), 2 deletions(-) | ||
12 | |||
13 | diff --git a/hw/i2c/versatile_i2c.c b/hw/i2c/versatile_i2c.c | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/hw/i2c/versatile_i2c.c | ||
16 | +++ b/hw/i2c/versatile_i2c.c | ||
17 | @@ -XXX,XX +XXX,XX @@ REG32(CONTROL_GET, 0) | ||
18 | REG32(CONTROL_SET, 0) | ||
19 | REG32(CONTROL_CLR, 4) | ||
20 | |||
21 | +#define SCL BIT(0) | ||
22 | +#define SDA BIT(1) | ||
23 | + | ||
24 | static uint64_t versatile_i2c_read(void *opaque, hwaddr offset, | ||
25 | unsigned size) | ||
26 | { | ||
27 | @@ -XXX,XX +XXX,XX @@ static void versatile_i2c_write(void *opaque, hwaddr offset, | ||
28 | qemu_log_mask(LOG_GUEST_ERROR, | ||
29 | "%s: Bad offset 0x%x\n", __func__, (int)offset); | ||
30 | } | ||
31 | - bitbang_i2c_set(&s->bitbang, BITBANG_I2C_SCL, (s->out & 1) != 0); | ||
32 | - s->in = bitbang_i2c_set(&s->bitbang, BITBANG_I2C_SDA, (s->out & 2) != 0); | ||
33 | + bitbang_i2c_set(&s->bitbang, BITBANG_I2C_SCL, (s->out & SCL) != 0); | ||
34 | + s->in = bitbang_i2c_set(&s->bitbang, BITBANG_I2C_SDA, (s->out & SDA) != 0); | ||
35 | } | ||
36 | |||
37 | static const MemoryRegionOps versatile_i2c_ops = { | ||
38 | -- | ||
39 | 2.20.1 | ||
40 | |||
41 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | From: Inès Varhol <ines.varhol@telecom-paris.fr> |
---|---|---|---|
2 | 2 | ||
3 | From 'Application Note AN385', chapter 3.14: | 3 | Signed-off-by: Arnaud Minier <arnaud.minier@telecom-paris.fr> |
4 | 4 | Signed-off-by: Inès Varhol <ines.varhol@telecom-paris.fr> | |
5 | The SMM implements a simple SBCon interface based on I2C. | 5 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
6 | 6 | Acked-by: Alistair Francis <alistair.francis@wdc.com> | |
7 | There are 4 SBCon interfaces on the FPGA APB subsystem. | 7 | Message-id: 20240305210444.310665-3-ines.varhol@telecom-paris.fr |
8 | |||
9 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
10 | Message-id: 20200617072539.32686-13-f4bug@amsat.org | ||
11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | --- | 9 | --- |
14 | hw/arm/mps2.c | 8 ++++++++ | 10 | include/hw/arm/stm32l4x5_soc.h | 2 + |
15 | hw/arm/Kconfig | 1 + | 11 | include/hw/gpio/stm32l4x5_gpio.h | 1 + |
16 | 2 files changed, 9 insertions(+) | 12 | include/hw/misc/stm32l4x5_syscfg.h | 3 +- |
17 | 13 | hw/arm/stm32l4x5_soc.c | 71 +++++++++++++++++++++++------- | |
18 | diff --git a/hw/arm/mps2.c b/hw/arm/mps2.c | 14 | hw/misc/stm32l4x5_syscfg.c | 1 + |
19 | index XXXXXXX..XXXXXXX 100644 | 15 | hw/arm/Kconfig | 3 +- |
20 | --- a/hw/arm/mps2.c | 16 | 6 files changed, 63 insertions(+), 18 deletions(-) |
21 | +++ b/hw/arm/mps2.c | 17 | |
22 | @@ -XXX,XX +XXX,XX @@ | 18 | diff --git a/include/hw/arm/stm32l4x5_soc.h b/include/hw/arm/stm32l4x5_soc.h |
23 | #include "hw/misc/mps2-scc.h" | 19 | index XXXXXXX..XXXXXXX 100644 |
24 | #include "hw/misc/mps2-fpgaio.h" | 20 | --- a/include/hw/arm/stm32l4x5_soc.h |
25 | #include "hw/ssi/pl022.h" | 21 | +++ b/include/hw/arm/stm32l4x5_soc.h |
26 | +#include "hw/i2c/arm_sbcon_i2c.h" | 22 | @@ -XXX,XX +XXX,XX @@ |
27 | #include "hw/net/lan9118.h" | 23 | #include "hw/misc/stm32l4x5_syscfg.h" |
28 | #include "net/net.h" | 24 | #include "hw/misc/stm32l4x5_exti.h" |
29 | #include "hw/watchdog/cmsdk-apb-watchdog.h" | 25 | #include "hw/misc/stm32l4x5_rcc.h" |
30 | @@ -XXX,XX +XXX,XX @@ static void mps2_common_init(MachineState *machine) | 26 | +#include "hw/gpio/stm32l4x5_gpio.h" |
31 | qdev_get_gpio_in(orgate_dev, j)); | 27 | #include "qom/object.h" |
28 | |||
29 | #define TYPE_STM32L4X5_SOC "stm32l4x5-soc" | ||
30 | @@ -XXX,XX +XXX,XX @@ struct Stm32l4x5SocState { | ||
31 | OrIRQState exti_or_gates[NUM_EXTI_OR_GATES]; | ||
32 | Stm32l4x5SyscfgState syscfg; | ||
33 | Stm32l4x5RccState rcc; | ||
34 | + Stm32l4x5GpioState gpio[NUM_GPIOS]; | ||
35 | |||
36 | MemoryRegion sram1; | ||
37 | MemoryRegion sram2; | ||
38 | diff --git a/include/hw/gpio/stm32l4x5_gpio.h b/include/hw/gpio/stm32l4x5_gpio.h | ||
39 | index XXXXXXX..XXXXXXX 100644 | ||
40 | --- a/include/hw/gpio/stm32l4x5_gpio.h | ||
41 | +++ b/include/hw/gpio/stm32l4x5_gpio.h | ||
42 | @@ -XXX,XX +XXX,XX @@ | ||
43 | #define TYPE_STM32L4X5_GPIO "stm32l4x5-gpio" | ||
44 | OBJECT_DECLARE_SIMPLE_TYPE(Stm32l4x5GpioState, STM32L4X5_GPIO) | ||
45 | |||
46 | +#define NUM_GPIOS 8 | ||
47 | #define GPIO_NUM_PINS 16 | ||
48 | |||
49 | struct Stm32l4x5GpioState { | ||
50 | diff --git a/include/hw/misc/stm32l4x5_syscfg.h b/include/hw/misc/stm32l4x5_syscfg.h | ||
51 | index XXXXXXX..XXXXXXX 100644 | ||
52 | --- a/include/hw/misc/stm32l4x5_syscfg.h | ||
53 | +++ b/include/hw/misc/stm32l4x5_syscfg.h | ||
54 | @@ -XXX,XX +XXX,XX @@ | ||
55 | |||
56 | #include "hw/sysbus.h" | ||
57 | #include "qom/object.h" | ||
58 | +#include "hw/gpio/stm32l4x5_gpio.h" | ||
59 | |||
60 | #define TYPE_STM32L4X5_SYSCFG "stm32l4x5-syscfg" | ||
61 | OBJECT_DECLARE_SIMPLE_TYPE(Stm32l4x5SyscfgState, STM32L4X5_SYSCFG) | ||
62 | |||
63 | -#define NUM_GPIOS 8 | ||
64 | -#define GPIO_NUM_PINS 16 | ||
65 | #define SYSCFG_NUM_EXTICR 4 | ||
66 | |||
67 | struct Stm32l4x5SyscfgState { | ||
68 | diff --git a/hw/arm/stm32l4x5_soc.c b/hw/arm/stm32l4x5_soc.c | ||
69 | index XXXXXXX..XXXXXXX 100644 | ||
70 | --- a/hw/arm/stm32l4x5_soc.c | ||
71 | +++ b/hw/arm/stm32l4x5_soc.c | ||
72 | @@ -XXX,XX +XXX,XX @@ | ||
73 | #include "sysemu/sysemu.h" | ||
74 | #include "hw/or-irq.h" | ||
75 | #include "hw/arm/stm32l4x5_soc.h" | ||
76 | +#include "hw/gpio/stm32l4x5_gpio.h" | ||
77 | #include "hw/qdev-clock.h" | ||
78 | #include "hw/misc/unimp.h" | ||
79 | |||
80 | @@ -XXX,XX +XXX,XX @@ static const int exti_or_gate1_lines_in[EXTI_OR_GATE1_NUM_LINES_IN] = { | ||
81 | 16, 35, 36, 37, 38, | ||
82 | }; | ||
83 | |||
84 | +static const struct { | ||
85 | + uint32_t addr; | ||
86 | + uint32_t moder_reset; | ||
87 | + uint32_t ospeedr_reset; | ||
88 | + uint32_t pupdr_reset; | ||
89 | +} stm32l4x5_gpio_cfg[NUM_GPIOS] = { | ||
90 | + { 0x48000000, 0xABFFFFFF, 0x0C000000, 0x64000000 }, | ||
91 | + { 0x48000400, 0xFFFFFEBF, 0x00000000, 0x00000100 }, | ||
92 | + { 0x48000800, 0xFFFFFFFF, 0x00000000, 0x00000000 }, | ||
93 | + { 0x48000C00, 0xFFFFFFFF, 0x00000000, 0x00000000 }, | ||
94 | + { 0x48001000, 0xFFFFFFFF, 0x00000000, 0x00000000 }, | ||
95 | + { 0x48001400, 0xFFFFFFFF, 0x00000000, 0x00000000 }, | ||
96 | + { 0x48001800, 0xFFFFFFFF, 0x00000000, 0x00000000 }, | ||
97 | + { 0x48001C00, 0x0000000F, 0x00000000, 0x00000000 }, | ||
98 | +}; | ||
99 | + | ||
100 | static void stm32l4x5_soc_initfn(Object *obj) | ||
101 | { | ||
102 | Stm32l4x5SocState *s = STM32L4X5_SOC(obj); | ||
103 | @@ -XXX,XX +XXX,XX @@ static void stm32l4x5_soc_initfn(Object *obj) | ||
104 | } | ||
105 | object_initialize_child(obj, "syscfg", &s->syscfg, TYPE_STM32L4X5_SYSCFG); | ||
106 | object_initialize_child(obj, "rcc", &s->rcc, TYPE_STM32L4X5_RCC); | ||
107 | + | ||
108 | + for (unsigned i = 0; i < NUM_GPIOS; i++) { | ||
109 | + g_autofree char *name = g_strdup_printf("gpio%c", 'a' + i); | ||
110 | + object_initialize_child(obj, name, &s->gpio[i], TYPE_STM32L4X5_GPIO); | ||
111 | + } | ||
112 | } | ||
113 | |||
114 | static void stm32l4x5_soc_realize(DeviceState *dev_soc, Error **errp) | ||
115 | @@ -XXX,XX +XXX,XX @@ static void stm32l4x5_soc_realize(DeviceState *dev_soc, Error **errp) | ||
116 | Stm32l4x5SocState *s = STM32L4X5_SOC(dev_soc); | ||
117 | const Stm32l4x5SocClass *sc = STM32L4X5_SOC_GET_CLASS(dev_soc); | ||
118 | MemoryRegion *system_memory = get_system_memory(); | ||
119 | - DeviceState *armv7m; | ||
120 | + DeviceState *armv7m, *dev; | ||
121 | SysBusDevice *busdev; | ||
122 | + uint32_t pin_index; | ||
123 | |||
124 | if (!memory_region_init_rom(&s->flash, OBJECT(dev_soc), "flash", | ||
125 | sc->flash_size, errp)) { | ||
126 | @@ -XXX,XX +XXX,XX @@ static void stm32l4x5_soc_realize(DeviceState *dev_soc, Error **errp) | ||
127 | return; | ||
128 | } | ||
129 | |||
130 | + /* GPIOs */ | ||
131 | + for (unsigned i = 0; i < NUM_GPIOS; i++) { | ||
132 | + g_autofree char *name = g_strdup_printf("%c", 'A' + i); | ||
133 | + dev = DEVICE(&s->gpio[i]); | ||
134 | + qdev_prop_set_string(dev, "name", name); | ||
135 | + qdev_prop_set_uint32(dev, "mode-reset", | ||
136 | + stm32l4x5_gpio_cfg[i].moder_reset); | ||
137 | + qdev_prop_set_uint32(dev, "ospeed-reset", | ||
138 | + stm32l4x5_gpio_cfg[i].ospeedr_reset); | ||
139 | + qdev_prop_set_uint32(dev, "pupd-reset", | ||
140 | + stm32l4x5_gpio_cfg[i].pupdr_reset); | ||
141 | + busdev = SYS_BUS_DEVICE(&s->gpio[i]); | ||
142 | + g_free(name); | ||
143 | + name = g_strdup_printf("gpio%c-out", 'a' + i); | ||
144 | + qdev_connect_clock_in(DEVICE(&s->gpio[i]), "clk", | ||
145 | + qdev_get_clock_out(DEVICE(&(s->rcc)), name)); | ||
146 | + if (!sysbus_realize(busdev, errp)) { | ||
147 | + return; | ||
148 | + } | ||
149 | + sysbus_mmio_map(busdev, 0, stm32l4x5_gpio_cfg[i].addr); | ||
150 | + } | ||
151 | + | ||
152 | /* System configuration controller */ | ||
153 | busdev = SYS_BUS_DEVICE(&s->syscfg); | ||
154 | if (!sysbus_realize(busdev, errp)) { | ||
155 | return; | ||
156 | } | ||
157 | sysbus_mmio_map(busdev, 0, SYSCFG_ADDR); | ||
158 | - /* | ||
159 | - * TODO: when the GPIO device is implemented, connect it | ||
160 | - * to SYCFG using `qdev_connect_gpio_out`, NUM_GPIOS and | ||
161 | - * GPIO_NUM_PINS. | ||
162 | - */ | ||
163 | + | ||
164 | + for (unsigned i = 0; i < NUM_GPIOS; i++) { | ||
165 | + for (unsigned j = 0; j < GPIO_NUM_PINS; j++) { | ||
166 | + pin_index = GPIO_NUM_PINS * i + j; | ||
167 | + qdev_connect_gpio_out(DEVICE(&s->gpio[i]), j, | ||
168 | + qdev_get_gpio_in(DEVICE(&s->syscfg), | ||
169 | + pin_index)); | ||
170 | + } | ||
171 | + } | ||
172 | |||
173 | /* EXTI device */ | ||
174 | busdev = SYS_BUS_DEVICE(&s->exti); | ||
175 | @@ -XXX,XX +XXX,XX @@ static void stm32l4x5_soc_realize(DeviceState *dev_soc, Error **errp) | ||
32 | } | 176 | } |
33 | } | 177 | } |
34 | + for (i = 0; i < 4; i++) { | 178 | |
35 | + static const hwaddr i2cbase[] = {0x40022000, /* Touch */ | 179 | - for (unsigned i = 0; i < 16; i++) { |
36 | + 0x40023000, /* Audio */ | 180 | + for (unsigned i = 0; i < GPIO_NUM_PINS; i++) { |
37 | + 0x40029000, /* Shield0 */ | 181 | qdev_connect_gpio_out(DEVICE(&s->syscfg), i, |
38 | + 0x4002a000}; /* Shield1 */ | 182 | qdev_get_gpio_in(DEVICE(&s->exti), i)); |
39 | + sysbus_create_simple(TYPE_ARM_SBCON_I2C, i2cbase[i], NULL); | 183 | } |
40 | + } | 184 | @@ -XXX,XX +XXX,XX @@ static void stm32l4x5_soc_realize(DeviceState *dev_soc, Error **errp) |
41 | 185 | /* RESERVED: 0x40024400, 0x7FDBC00 */ | |
42 | /* In hardware this is a LAN9220; the LAN9118 is software compatible | 186 | |
43 | * except that it doesn't support the checksum-offload feature. | 187 | /* AHB2 BUS */ |
188 | - create_unimplemented_device("GPIOA", 0x48000000, 0x400); | ||
189 | - create_unimplemented_device("GPIOB", 0x48000400, 0x400); | ||
190 | - create_unimplemented_device("GPIOC", 0x48000800, 0x400); | ||
191 | - create_unimplemented_device("GPIOD", 0x48000C00, 0x400); | ||
192 | - create_unimplemented_device("GPIOE", 0x48001000, 0x400); | ||
193 | - create_unimplemented_device("GPIOF", 0x48001400, 0x400); | ||
194 | - create_unimplemented_device("GPIOG", 0x48001800, 0x400); | ||
195 | - create_unimplemented_device("GPIOH", 0x48001C00, 0x400); | ||
196 | /* RESERVED: 0x48002000, 0x7FDBC00 */ | ||
197 | create_unimplemented_device("OTG_FS", 0x50000000, 0x40000); | ||
198 | create_unimplemented_device("ADC", 0x50040000, 0x400); | ||
199 | diff --git a/hw/misc/stm32l4x5_syscfg.c b/hw/misc/stm32l4x5_syscfg.c | ||
200 | index XXXXXXX..XXXXXXX 100644 | ||
201 | --- a/hw/misc/stm32l4x5_syscfg.c | ||
202 | +++ b/hw/misc/stm32l4x5_syscfg.c | ||
203 | @@ -XXX,XX +XXX,XX @@ | ||
204 | #include "hw/irq.h" | ||
205 | #include "migration/vmstate.h" | ||
206 | #include "hw/misc/stm32l4x5_syscfg.h" | ||
207 | +#include "hw/gpio/stm32l4x5_gpio.h" | ||
208 | |||
209 | #define SYSCFG_MEMRMP 0x00 | ||
210 | #define SYSCFG_CFGR1 0x04 | ||
44 | diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig | 211 | diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig |
45 | index XXXXXXX..XXXXXXX 100644 | 212 | index XXXXXXX..XXXXXXX 100644 |
46 | --- a/hw/arm/Kconfig | 213 | --- a/hw/arm/Kconfig |
47 | +++ b/hw/arm/Kconfig | 214 | +++ b/hw/arm/Kconfig |
48 | @@ -XXX,XX +XXX,XX @@ config MPS2 | 215 | @@ -XXX,XX +XXX,XX @@ config STM32L4X5_SOC |
49 | select SPLIT_IRQ | 216 | bool |
50 | select UNIMP | 217 | select ARM_V7M |
51 | select CMSDK_APB_WATCHDOG | 218 | select OR_IRQ |
52 | + select VERSATILE_I2C | 219 | - select STM32L4X5_SYSCFG |
53 | 220 | select STM32L4X5_EXTI | |
54 | config FSL_IMX7 | 221 | + select STM32L4X5_SYSCFG |
222 | select STM32L4X5_RCC | ||
223 | + select STM32L4X5_GPIO | ||
224 | |||
225 | config XLNX_ZYNQMP_ARM | ||
55 | bool | 226 | bool |
56 | -- | 227 | -- |
57 | 2.20.1 | 228 | 2.34.1 |
58 | 229 | ||
59 | 230 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 1 | From: Inès Varhol <ines.varhol@telecom-paris.fr> |
---|---|---|---|
2 | 2 | ||
3 | Since commit d70c996df23f, when enabling the PMU we get: | 3 | The testcase contains : |
4 | - `test_idr_reset_value()` : | ||
5 | Checks the reset values of MODER, OTYPER, PUPDR, ODR and IDR. | ||
6 | - `test_gpio_output_mode()` : | ||
7 | Checks that writing a bit in register ODR results in the corresponding | ||
8 | pin rising or lowering, if this pin is configured in output mode. | ||
9 | - `test_gpio_input_mode()` : | ||
10 | Checks that a input pin set high or low externally results | ||
11 | in the pin rising and lowering. | ||
12 | - `test_pull_up_pull_down()` : | ||
13 | Checks that a floating pin in pull-up/down mode is actually high/down. | ||
14 | - `test_push_pull()` : | ||
15 | Checks that a pin set externally is disconnected when configured in | ||
16 | push-pull output mode, and can't be set externally while in this mode. | ||
17 | - `test_open_drain()` : | ||
18 | Checks that a pin set externally high is disconnected when configured | ||
19 | in open-drain output mode, and can't be set high while in this mode. | ||
20 | - `test_bsrr_brr()` : | ||
21 | Checks that writing to BSRR and BRR has the desired result in ODR. | ||
22 | - `test_clock_enable()` : | ||
23 | Checks that GPIO clock is at the right frequency after enabling it. | ||
4 | 24 | ||
5 | $ qemu-system-aarch64 -cpu host,pmu=on -M virt,accel=kvm,gic-version=3 | 25 | Acked-by: Thomas Huth <thuth@redhat.com> |
6 | Segmentation fault (core dumped) | 26 | Signed-off-by: Arnaud Minier <arnaud.minier@telecom-paris.fr> |
7 | 27 | Signed-off-by: Inès Varhol <ines.varhol@telecom-paris.fr> | |
8 | Thread 1 "qemu-system-aar" received signal SIGSEGV, Segmentation fault. | 28 | Message-id: 20240305210444.310665-4-ines.varhol@telecom-paris.fr |
9 | 0x0000aaaaaae356d0 in kvm_ioctl (s=0x0, type=44547) at accel/kvm/kvm-all.c:2588 | ||
10 | 2588 ret = ioctl(s->fd, type, arg); | ||
11 | (gdb) bt | ||
12 | #0 0x0000aaaaaae356d0 in kvm_ioctl (s=0x0, type=44547) at accel/kvm/kvm-all.c:2588 | ||
13 | #1 0x0000aaaaaae31568 in kvm_check_extension (s=0x0, extension=126) at accel/kvm/kvm-all.c:916 | ||
14 | #2 0x0000aaaaaafce254 in kvm_arm_pmu_supported (cpu=0xaaaaac214ab0) at target/arm/kvm.c:213 | ||
15 | #3 0x0000aaaaaafc0f94 in arm_set_pmu (obj=0xaaaaac214ab0, value=true, errp=0xffffffffe438) at target/arm/cpu.c:1111 | ||
16 | #4 0x0000aaaaab5533ac in property_set_bool (obj=0xaaaaac214ab0, v=0xaaaaac223a80, name=0xaaaaac11a970 "pmu", opaque=0xaaaaac222730, errp=0xffffffffe438) at qom/object.c:2170 | ||
17 | #5 0x0000aaaaab5512f0 in object_property_set (obj=0xaaaaac214ab0, v=0xaaaaac223a80, name=0xaaaaac11a970 "pmu", errp=0xffffffffe438) at qom/object.c:1328 | ||
18 | #6 0x0000aaaaab551e10 in object_property_parse (obj=0xaaaaac214ab0, string=0xaaaaac11b4c0 "on", name=0xaaaaac11a970 "pmu", errp=0xffffffffe438) at qom/object.c:1561 | ||
19 | #7 0x0000aaaaab54ee8c in object_apply_global_props (obj=0xaaaaac214ab0, props=0xaaaaac018e20, errp=0xaaaaabd6fd88 <error_fatal>) at qom/object.c:407 | ||
20 | #8 0x0000aaaaab1dd5a4 in qdev_prop_set_globals (dev=0xaaaaac214ab0) at hw/core/qdev-properties.c:1218 | ||
21 | #9 0x0000aaaaab1d9fac in device_post_init (obj=0xaaaaac214ab0) at hw/core/qdev.c:1050 | ||
22 | ... | ||
23 | #15 0x0000aaaaab54f310 in object_initialize_with_type (obj=0xaaaaac214ab0, size=52208, type=0xaaaaabe237f0) at qom/object.c:512 | ||
24 | #16 0x0000aaaaab54fa24 in object_new_with_type (type=0xaaaaabe237f0) at qom/object.c:687 | ||
25 | #17 0x0000aaaaab54fa80 in object_new (typename=0xaaaaabe23970 "host-arm-cpu") at qom/object.c:702 | ||
26 | #18 0x0000aaaaaaf04a74 in machvirt_init (machine=0xaaaaac0a8550) at hw/arm/virt.c:1770 | ||
27 | #19 0x0000aaaaab1e8720 in machine_run_board_init (machine=0xaaaaac0a8550) at hw/core/machine.c:1138 | ||
28 | #20 0x0000aaaaaaf95394 in qemu_init (argc=5, argv=0xffffffffea58, envp=0xffffffffea88) at softmmu/vl.c:4348 | ||
29 | #21 0x0000aaaaaada3f74 in main (argc=<optimized out>, argv=<optimized out>, envp=<optimized out>) at softmmu/main.c:48 | ||
30 | |||
31 | This is because in frame #2, cpu->kvm_state is still NULL | ||
32 | (the vCPU is not yet realized). | ||
33 | |||
34 | KVM has a hard requirement of all cores supporting the same | ||
35 | feature set. We only need to check if the accelerator supports | ||
36 | a feature, not each vCPU individually. | ||
37 | |||
38 | Fix by removing the 'CPUState *cpu' argument from the | ||
39 | kvm_arm_<FEATURE>_supported() functions. | ||
40 | |||
41 | Fixes: d70c996df23f ('Use CPUState::kvm_state in kvm_arm_pmu_supported') | ||
42 | Reported-by: Haibo Xu <haibo.xu@linaro.org> | ||
43 | Reviewed-by: Andrew Jones <drjones@redhat.com> | ||
44 | Acked-by: Paolo Bonzini <pbonzini@redhat.com> | ||
45 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
46 | Suggested-by: Paolo Bonzini <pbonzini@redhat.com> | ||
47 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
48 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 29 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
49 | --- | 30 | --- |
50 | target/arm/kvm_arm.h | 21 +++++++++------------ | 31 | tests/qtest/stm32l4x5_gpio-test.c | 551 ++++++++++++++++++++++++++++++ |
51 | target/arm/cpu.c | 2 +- | 32 | tests/qtest/meson.build | 3 +- |
52 | target/arm/cpu64.c | 10 +++++----- | 33 | 2 files changed, 553 insertions(+), 1 deletion(-) |
53 | target/arm/kvm.c | 4 ++-- | 34 | create mode 100644 tests/qtest/stm32l4x5_gpio-test.c |
54 | target/arm/kvm64.c | 14 +++++--------- | ||
55 | 5 files changed, 22 insertions(+), 29 deletions(-) | ||
56 | 35 | ||
57 | diff --git a/target/arm/kvm_arm.h b/target/arm/kvm_arm.h | 36 | diff --git a/tests/qtest/stm32l4x5_gpio-test.c b/tests/qtest/stm32l4x5_gpio-test.c |
37 | new file mode 100644 | ||
38 | index XXXXXXX..XXXXXXX | ||
39 | --- /dev/null | ||
40 | +++ b/tests/qtest/stm32l4x5_gpio-test.c | ||
41 | @@ -XXX,XX +XXX,XX @@ | ||
42 | +/* | ||
43 | + * QTest testcase for STM32L4x5_GPIO | ||
44 | + * | ||
45 | + * Copyright (c) 2024 Arnaud Minier <arnaud.minier@telecom-paris.fr> | ||
46 | + * Copyright (c) 2024 Inès Varhol <ines.varhol@telecom-paris.fr> | ||
47 | + * | ||
48 | + * This work is licensed under the terms of the GNU GPL, version 2 or later. | ||
49 | + * See the COPYING file in the top-level directory. | ||
50 | + */ | ||
51 | + | ||
52 | +#include "qemu/osdep.h" | ||
53 | +#include "libqtest-single.h" | ||
54 | + | ||
55 | +#define GPIO_BASE_ADDR 0x48000000 | ||
56 | +#define GPIO_SIZE 0x400 | ||
57 | +#define NUM_GPIOS 8 | ||
58 | +#define NUM_GPIO_PINS 16 | ||
59 | + | ||
60 | +#define GPIO_A 0x48000000 | ||
61 | +#define GPIO_B 0x48000400 | ||
62 | +#define GPIO_C 0x48000800 | ||
63 | +#define GPIO_D 0x48000C00 | ||
64 | +#define GPIO_E 0x48001000 | ||
65 | +#define GPIO_F 0x48001400 | ||
66 | +#define GPIO_G 0x48001800 | ||
67 | +#define GPIO_H 0x48001C00 | ||
68 | + | ||
69 | +#define MODER 0x00 | ||
70 | +#define OTYPER 0x04 | ||
71 | +#define PUPDR 0x0C | ||
72 | +#define IDR 0x10 | ||
73 | +#define ODR 0x14 | ||
74 | +#define BSRR 0x18 | ||
75 | +#define BRR 0x28 | ||
76 | + | ||
77 | +#define MODER_INPUT 0 | ||
78 | +#define MODER_OUTPUT 1 | ||
79 | + | ||
80 | +#define PUPDR_NONE 0 | ||
81 | +#define PUPDR_PULLUP 1 | ||
82 | +#define PUPDR_PULLDOWN 2 | ||
83 | + | ||
84 | +#define OTYPER_PUSH_PULL 0 | ||
85 | +#define OTYPER_OPEN_DRAIN 1 | ||
86 | + | ||
87 | +const uint32_t moder_reset[NUM_GPIOS] = { | ||
88 | + 0xABFFFFFF, | ||
89 | + 0xFFFFFEBF, | ||
90 | + 0xFFFFFFFF, | ||
91 | + 0xFFFFFFFF, | ||
92 | + 0xFFFFFFFF, | ||
93 | + 0xFFFFFFFF, | ||
94 | + 0xFFFFFFFF, | ||
95 | + 0x0000000F | ||
96 | +}; | ||
97 | + | ||
98 | +const uint32_t pupdr_reset[NUM_GPIOS] = { | ||
99 | + 0x64000000, | ||
100 | + 0x00000100, | ||
101 | + 0x00000000, | ||
102 | + 0x00000000, | ||
103 | + 0x00000000, | ||
104 | + 0x00000000, | ||
105 | + 0x00000000, | ||
106 | + 0x00000000 | ||
107 | +}; | ||
108 | + | ||
109 | +const uint32_t idr_reset[NUM_GPIOS] = { | ||
110 | + 0x0000A000, | ||
111 | + 0x00000010, | ||
112 | + 0x00000000, | ||
113 | + 0x00000000, | ||
114 | + 0x00000000, | ||
115 | + 0x00000000, | ||
116 | + 0x00000000, | ||
117 | + 0x00000000 | ||
118 | +}; | ||
119 | + | ||
120 | +static uint32_t gpio_readl(unsigned int gpio, unsigned int offset) | ||
121 | +{ | ||
122 | + return readl(gpio + offset); | ||
123 | +} | ||
124 | + | ||
125 | +static void gpio_writel(unsigned int gpio, unsigned int offset, uint32_t value) | ||
126 | +{ | ||
127 | + writel(gpio + offset, value); | ||
128 | +} | ||
129 | + | ||
130 | +static void gpio_set_bit(unsigned int gpio, unsigned int reg, | ||
131 | + unsigned int pin, uint32_t value) | ||
132 | +{ | ||
133 | + uint32_t mask = 0xFFFFFFFF & ~(0x1 << pin); | ||
134 | + gpio_writel(gpio, reg, (gpio_readl(gpio, reg) & mask) | value << pin); | ||
135 | +} | ||
136 | + | ||
137 | +static void gpio_set_2bits(unsigned int gpio, unsigned int reg, | ||
138 | + unsigned int pin, uint32_t value) | ||
139 | +{ | ||
140 | + uint32_t offset = 2 * pin; | ||
141 | + uint32_t mask = 0xFFFFFFFF & ~(0x3 << offset); | ||
142 | + gpio_writel(gpio, reg, (gpio_readl(gpio, reg) & mask) | value << offset); | ||
143 | +} | ||
144 | + | ||
145 | +static unsigned int get_gpio_id(uint32_t gpio_addr) | ||
146 | +{ | ||
147 | + return (gpio_addr - GPIO_BASE_ADDR) / GPIO_SIZE; | ||
148 | +} | ||
149 | + | ||
150 | +static void gpio_set_irq(unsigned int gpio, int num, int level) | ||
151 | +{ | ||
152 | + g_autofree char *name = g_strdup_printf("/machine/soc/gpio%c", | ||
153 | + get_gpio_id(gpio) + 'a'); | ||
154 | + qtest_set_irq_in(global_qtest, name, NULL, num, level); | ||
155 | +} | ||
156 | + | ||
157 | +static void disconnect_all_pins(unsigned int gpio) | ||
158 | +{ | ||
159 | + g_autofree char *path = g_strdup_printf("/machine/soc/gpio%c", | ||
160 | + get_gpio_id(gpio) + 'a'); | ||
161 | + QDict *r; | ||
162 | + | ||
163 | + r = qtest_qmp(global_qtest, "{ 'execute': 'qom-set', 'arguments': " | ||
164 | + "{ 'path': %s, 'property': 'disconnected-pins', 'value': %d } }", | ||
165 | + path, 0xFFFF); | ||
166 | + g_assert_false(qdict_haskey(r, "error")); | ||
167 | + qobject_unref(r); | ||
168 | +} | ||
169 | + | ||
170 | +static uint32_t get_disconnected_pins(unsigned int gpio) | ||
171 | +{ | ||
172 | + g_autofree char *path = g_strdup_printf("/machine/soc/gpio%c", | ||
173 | + get_gpio_id(gpio) + 'a'); | ||
174 | + uint32_t disconnected_pins = 0; | ||
175 | + QDict *r; | ||
176 | + | ||
177 | + r = qtest_qmp(global_qtest, "{ 'execute': 'qom-get', 'arguments':" | ||
178 | + " { 'path': %s, 'property': 'disconnected-pins'} }", path); | ||
179 | + g_assert_false(qdict_haskey(r, "error")); | ||
180 | + disconnected_pins = qdict_get_int(r, "return"); | ||
181 | + qobject_unref(r); | ||
182 | + return disconnected_pins; | ||
183 | +} | ||
184 | + | ||
185 | +static uint32_t reset(uint32_t gpio, unsigned int offset) | ||
186 | +{ | ||
187 | + switch (offset) { | ||
188 | + case MODER: | ||
189 | + return moder_reset[get_gpio_id(gpio)]; | ||
190 | + case PUPDR: | ||
191 | + return pupdr_reset[get_gpio_id(gpio)]; | ||
192 | + case IDR: | ||
193 | + return idr_reset[get_gpio_id(gpio)]; | ||
194 | + } | ||
195 | + return 0x0; | ||
196 | +} | ||
197 | + | ||
198 | +static void system_reset(void) | ||
199 | +{ | ||
200 | + QDict *r; | ||
201 | + r = qtest_qmp(global_qtest, "{'execute': 'system_reset'}"); | ||
202 | + g_assert_false(qdict_haskey(r, "error")); | ||
203 | + qobject_unref(r); | ||
204 | +} | ||
205 | + | ||
206 | +static void test_idr_reset_value(void) | ||
207 | +{ | ||
208 | + /* | ||
209 | + * Checks that the values in MODER, OTYPER, PUPDR and ODR | ||
210 | + * after reset are correct, and that the value in IDR is | ||
211 | + * coherent. | ||
212 | + * Since AF and analog modes aren't implemented, IDR reset | ||
213 | + * values aren't the same as with a real board. | ||
214 | + * | ||
215 | + * Register IDR contains the actual values of all GPIO pins. | ||
216 | + * Its value depends on the pins' configuration | ||
217 | + * (intput/output/analog : register MODER, push-pull/open-drain : | ||
218 | + * register OTYPER, pull-up/pull-down/none : register PUPDR) | ||
219 | + * and on the values stored in register ODR | ||
220 | + * (in case the pin is in output mode). | ||
221 | + */ | ||
222 | + | ||
223 | + gpio_writel(GPIO_A, MODER, 0xDEADBEEF); | ||
224 | + gpio_writel(GPIO_A, ODR, 0xDEADBEEF); | ||
225 | + gpio_writel(GPIO_A, OTYPER, 0xDEADBEEF); | ||
226 | + gpio_writel(GPIO_A, PUPDR, 0xDEADBEEF); | ||
227 | + | ||
228 | + gpio_writel(GPIO_B, MODER, 0xDEADBEEF); | ||
229 | + gpio_writel(GPIO_B, ODR, 0xDEADBEEF); | ||
230 | + gpio_writel(GPIO_B, OTYPER, 0xDEADBEEF); | ||
231 | + gpio_writel(GPIO_B, PUPDR, 0xDEADBEEF); | ||
232 | + | ||
233 | + gpio_writel(GPIO_C, MODER, 0xDEADBEEF); | ||
234 | + gpio_writel(GPIO_C, ODR, 0xDEADBEEF); | ||
235 | + gpio_writel(GPIO_C, OTYPER, 0xDEADBEEF); | ||
236 | + gpio_writel(GPIO_C, PUPDR, 0xDEADBEEF); | ||
237 | + | ||
238 | + gpio_writel(GPIO_H, MODER, 0xDEADBEEF); | ||
239 | + gpio_writel(GPIO_H, ODR, 0xDEADBEEF); | ||
240 | + gpio_writel(GPIO_H, OTYPER, 0xDEADBEEF); | ||
241 | + gpio_writel(GPIO_H, PUPDR, 0xDEADBEEF); | ||
242 | + | ||
243 | + system_reset(); | ||
244 | + | ||
245 | + uint32_t moder = gpio_readl(GPIO_A, MODER); | ||
246 | + uint32_t odr = gpio_readl(GPIO_A, ODR); | ||
247 | + uint32_t otyper = gpio_readl(GPIO_A, OTYPER); | ||
248 | + uint32_t pupdr = gpio_readl(GPIO_A, PUPDR); | ||
249 | + uint32_t idr = gpio_readl(GPIO_A, IDR); | ||
250 | + /* 15: AF, 14: AF, 13: AF, 12: Analog ... */ | ||
251 | + /* here AF is the same as Analog and Input mode */ | ||
252 | + g_assert_cmphex(moder, ==, reset(GPIO_A, MODER)); | ||
253 | + g_assert_cmphex(odr, ==, reset(GPIO_A, ODR)); | ||
254 | + g_assert_cmphex(otyper, ==, reset(GPIO_A, OTYPER)); | ||
255 | + /* 15: pull-up, 14: pull-down, 13: pull-up, 12: neither ... */ | ||
256 | + g_assert_cmphex(pupdr, ==, reset(GPIO_A, PUPDR)); | ||
257 | + /* 15 : 1, 14: 0, 13: 1, 12 : reset value ... */ | ||
258 | + g_assert_cmphex(idr, ==, reset(GPIO_A, IDR)); | ||
259 | + | ||
260 | + moder = gpio_readl(GPIO_B, MODER); | ||
261 | + odr = gpio_readl(GPIO_B, ODR); | ||
262 | + otyper = gpio_readl(GPIO_B, OTYPER); | ||
263 | + pupdr = gpio_readl(GPIO_B, PUPDR); | ||
264 | + idr = gpio_readl(GPIO_B, IDR); | ||
265 | + /* ... 5: Analog, 4: AF, 3: AF, 2: Analog ... */ | ||
266 | + /* here AF is the same as Analog and Input mode */ | ||
267 | + g_assert_cmphex(moder, ==, reset(GPIO_B, MODER)); | ||
268 | + g_assert_cmphex(odr, ==, reset(GPIO_B, ODR)); | ||
269 | + g_assert_cmphex(otyper, ==, reset(GPIO_B, OTYPER)); | ||
270 | + /* ... 5: neither, 4: pull-up, 3: neither ... */ | ||
271 | + g_assert_cmphex(pupdr, ==, reset(GPIO_B, PUPDR)); | ||
272 | + /* ... 5 : reset value, 4 : 1, 3 : reset value ... */ | ||
273 | + g_assert_cmphex(idr, ==, reset(GPIO_B, IDR)); | ||
274 | + | ||
275 | + moder = gpio_readl(GPIO_C, MODER); | ||
276 | + odr = gpio_readl(GPIO_C, ODR); | ||
277 | + otyper = gpio_readl(GPIO_C, OTYPER); | ||
278 | + pupdr = gpio_readl(GPIO_C, PUPDR); | ||
279 | + idr = gpio_readl(GPIO_C, IDR); | ||
280 | + /* Analog, same as Input mode*/ | ||
281 | + g_assert_cmphex(moder, ==, reset(GPIO_C, MODER)); | ||
282 | + g_assert_cmphex(odr, ==, reset(GPIO_C, ODR)); | ||
283 | + g_assert_cmphex(otyper, ==, reset(GPIO_C, OTYPER)); | ||
284 | + /* no pull-up or pull-down */ | ||
285 | + g_assert_cmphex(pupdr, ==, reset(GPIO_C, PUPDR)); | ||
286 | + /* reset value */ | ||
287 | + g_assert_cmphex(idr, ==, reset(GPIO_C, IDR)); | ||
288 | + | ||
289 | + moder = gpio_readl(GPIO_H, MODER); | ||
290 | + odr = gpio_readl(GPIO_H, ODR); | ||
291 | + otyper = gpio_readl(GPIO_H, OTYPER); | ||
292 | + pupdr = gpio_readl(GPIO_H, PUPDR); | ||
293 | + idr = gpio_readl(GPIO_H, IDR); | ||
294 | + /* Analog, same as Input mode */ | ||
295 | + g_assert_cmphex(moder, ==, reset(GPIO_H, MODER)); | ||
296 | + g_assert_cmphex(odr, ==, reset(GPIO_H, ODR)); | ||
297 | + g_assert_cmphex(otyper, ==, reset(GPIO_H, OTYPER)); | ||
298 | + /* no pull-up or pull-down */ | ||
299 | + g_assert_cmphex(pupdr, ==, reset(GPIO_H, PUPDR)); | ||
300 | + /* reset value */ | ||
301 | + g_assert_cmphex(idr, ==, reset(GPIO_H, IDR)); | ||
302 | +} | ||
303 | + | ||
304 | +static void test_gpio_output_mode(const void *data) | ||
305 | +{ | ||
306 | + /* | ||
307 | + * Checks that setting a bit in ODR sets the corresponding | ||
308 | + * GPIO line high : it should set the right bit in IDR | ||
309 | + * and send an irq to syscfg. | ||
310 | + * Additionally, it checks that values written to ODR | ||
311 | + * when not in output mode are stored and not discarded. | ||
312 | + */ | ||
313 | + unsigned int pin = ((uint64_t)data) & 0xF; | ||
314 | + uint32_t gpio = ((uint64_t)data) >> 32; | ||
315 | + unsigned int gpio_id = get_gpio_id(gpio); | ||
316 | + | ||
317 | + qtest_irq_intercept_in(global_qtest, "/machine/soc/syscfg"); | ||
318 | + | ||
319 | + /* Set a bit in ODR and check nothing happens */ | ||
320 | + gpio_set_bit(gpio, ODR, pin, 1); | ||
321 | + g_assert_cmphex(gpio_readl(gpio, IDR), ==, reset(gpio, IDR)); | ||
322 | + g_assert_false(get_irq(gpio_id * NUM_GPIO_PINS + pin)); | ||
323 | + | ||
324 | + /* Configure the relevant line as output and check the pin is high */ | ||
325 | + gpio_set_2bits(gpio, MODER, pin, MODER_OUTPUT); | ||
326 | + g_assert_cmphex(gpio_readl(gpio, IDR), ==, reset(gpio, IDR) | (1 << pin)); | ||
327 | + g_assert_true(get_irq(gpio_id * NUM_GPIO_PINS + pin)); | ||
328 | + | ||
329 | + /* Reset the bit in ODR and check the pin is low */ | ||
330 | + gpio_set_bit(gpio, ODR, pin, 0); | ||
331 | + g_assert_cmphex(gpio_readl(gpio, IDR), ==, reset(gpio, IDR) & ~(1 << pin)); | ||
332 | + g_assert_false(get_irq(gpio_id * NUM_GPIO_PINS + pin)); | ||
333 | + | ||
334 | + /* Clean the test */ | ||
335 | + gpio_writel(gpio, ODR, reset(gpio, ODR)); | ||
336 | + gpio_writel(gpio, MODER, reset(gpio, MODER)); | ||
337 | + g_assert_cmphex(gpio_readl(gpio, IDR), ==, reset(gpio, IDR)); | ||
338 | + g_assert_false(get_irq(gpio_id * NUM_GPIO_PINS + pin)); | ||
339 | +} | ||
340 | + | ||
341 | +static void test_gpio_input_mode(const void *data) | ||
342 | +{ | ||
343 | + /* | ||
344 | + * Test that setting a line high/low externally sets the | ||
345 | + * corresponding GPIO line high/low : it should set the | ||
346 | + * right bit in IDR and send an irq to syscfg. | ||
347 | + */ | ||
348 | + unsigned int pin = ((uint64_t)data) & 0xF; | ||
349 | + uint32_t gpio = ((uint64_t)data) >> 32; | ||
350 | + unsigned int gpio_id = get_gpio_id(gpio); | ||
351 | + | ||
352 | + qtest_irq_intercept_in(global_qtest, "/machine/soc/syscfg"); | ||
353 | + | ||
354 | + /* Configure a line as input, raise it, and check that the pin is high */ | ||
355 | + gpio_set_2bits(gpio, MODER, pin, MODER_INPUT); | ||
356 | + gpio_set_irq(gpio, pin, 1); | ||
357 | + g_assert_cmphex(gpio_readl(gpio, IDR), ==, reset(gpio, IDR) | (1 << pin)); | ||
358 | + g_assert_true(get_irq(gpio_id * NUM_GPIO_PINS + pin)); | ||
359 | + | ||
360 | + /* Lower the line and check that the pin is low */ | ||
361 | + gpio_set_irq(gpio, pin, 0); | ||
362 | + g_assert_cmphex(gpio_readl(gpio, IDR), ==, reset(gpio, IDR) & ~(1 << pin)); | ||
363 | + g_assert_false(get_irq(gpio_id * NUM_GPIO_PINS + pin)); | ||
364 | + | ||
365 | + /* Clean the test */ | ||
366 | + gpio_writel(gpio, MODER, reset(gpio, MODER)); | ||
367 | + disconnect_all_pins(gpio); | ||
368 | + g_assert_cmphex(gpio_readl(gpio, IDR), ==, reset(gpio, IDR)); | ||
369 | +} | ||
370 | + | ||
371 | +static void test_pull_up_pull_down(const void *data) | ||
372 | +{ | ||
373 | + /* | ||
374 | + * Test that a floating pin with pull-up sets the pin | ||
375 | + * high and vice-versa. | ||
376 | + */ | ||
377 | + unsigned int pin = ((uint64_t)data) & 0xF; | ||
378 | + uint32_t gpio = ((uint64_t)data) >> 32; | ||
379 | + unsigned int gpio_id = get_gpio_id(gpio); | ||
380 | + | ||
381 | + qtest_irq_intercept_in(global_qtest, "/machine/soc/syscfg"); | ||
382 | + | ||
383 | + /* Configure a line as input with pull-up, check the line is set high */ | ||
384 | + gpio_set_2bits(gpio, MODER, pin, MODER_INPUT); | ||
385 | + gpio_set_2bits(gpio, PUPDR, pin, PUPDR_PULLUP); | ||
386 | + g_assert_cmphex(gpio_readl(gpio, IDR), ==, reset(gpio, IDR) | (1 << pin)); | ||
387 | + g_assert_true(get_irq(gpio_id * NUM_GPIO_PINS + pin)); | ||
388 | + | ||
389 | + /* Configure the line with pull-down, check the line is low */ | ||
390 | + gpio_set_2bits(gpio, PUPDR, pin, PUPDR_PULLDOWN); | ||
391 | + g_assert_cmphex(gpio_readl(gpio, IDR), ==, reset(gpio, IDR) & ~(1 << pin)); | ||
392 | + g_assert_false(get_irq(gpio_id * NUM_GPIO_PINS + pin)); | ||
393 | + | ||
394 | + /* Clean the test */ | ||
395 | + gpio_writel(gpio, MODER, reset(gpio, MODER)); | ||
396 | + gpio_writel(gpio, PUPDR, reset(gpio, PUPDR)); | ||
397 | + g_assert_cmphex(gpio_readl(gpio, IDR), ==, reset(gpio, IDR)); | ||
398 | +} | ||
399 | + | ||
400 | +static void test_push_pull(const void *data) | ||
401 | +{ | ||
402 | + /* | ||
403 | + * Test that configuring a line in push-pull output mode | ||
404 | + * disconnects the pin, that the pin can't be set or reset | ||
405 | + * externally afterwards. | ||
406 | + */ | ||
407 | + unsigned int pin = ((uint64_t)data) & 0xF; | ||
408 | + uint32_t gpio = ((uint64_t)data) >> 32; | ||
409 | + uint32_t gpio2 = GPIO_BASE_ADDR + (GPIO_H - gpio); | ||
410 | + | ||
411 | + qtest_irq_intercept_in(global_qtest, "/machine/soc/syscfg"); | ||
412 | + | ||
413 | + /* Setting a line high externally, configuring it in push-pull output */ | ||
414 | + /* And checking the pin was disconnected */ | ||
415 | + gpio_set_irq(gpio, pin, 1); | ||
416 | + gpio_set_2bits(gpio, MODER, pin, MODER_OUTPUT); | ||
417 | + g_assert_cmphex(get_disconnected_pins(gpio), ==, 0xFFFF); | ||
418 | + g_assert_cmphex(gpio_readl(gpio, IDR), ==, reset(gpio, IDR) & ~(1 << pin)); | ||
419 | + | ||
420 | + /* Setting a line low externally, configuring it in push-pull output */ | ||
421 | + /* And checking the pin was disconnected */ | ||
422 | + gpio_set_irq(gpio2, pin, 0); | ||
423 | + gpio_set_bit(gpio2, ODR, pin, 1); | ||
424 | + gpio_set_2bits(gpio2, MODER, pin, MODER_OUTPUT); | ||
425 | + g_assert_cmphex(get_disconnected_pins(gpio2), ==, 0xFFFF); | ||
426 | + g_assert_cmphex(gpio_readl(gpio2, IDR), ==, reset(gpio2, IDR) | (1 << pin)); | ||
427 | + | ||
428 | + /* Trying to set a push-pull output pin, checking it doesn't work */ | ||
429 | + gpio_set_irq(gpio, pin, 1); | ||
430 | + g_assert_cmphex(get_disconnected_pins(gpio), ==, 0xFFFF); | ||
431 | + g_assert_cmphex(gpio_readl(gpio, IDR), ==, reset(gpio, IDR) & ~(1 << pin)); | ||
432 | + | ||
433 | + /* Trying to reset a push-pull output pin, checking it doesn't work */ | ||
434 | + gpio_set_irq(gpio2, pin, 0); | ||
435 | + g_assert_cmphex(get_disconnected_pins(gpio2), ==, 0xFFFF); | ||
436 | + g_assert_cmphex(gpio_readl(gpio2, IDR), ==, reset(gpio2, IDR) | (1 << pin)); | ||
437 | + | ||
438 | + /* Clean the test */ | ||
439 | + gpio_writel(gpio, MODER, reset(gpio, MODER)); | ||
440 | + gpio_writel(gpio2, ODR, reset(gpio2, ODR)); | ||
441 | + gpio_writel(gpio2, MODER, reset(gpio2, MODER)); | ||
442 | +} | ||
443 | + | ||
444 | +static void test_open_drain(const void *data) | ||
445 | +{ | ||
446 | + /* | ||
447 | + * Test that configuring a line in open-drain output mode | ||
448 | + * disconnects a pin set high externally and that the pin | ||
449 | + * can't be set high externally while configured in open-drain. | ||
450 | + * | ||
451 | + * However a pin set low externally shouldn't be disconnected, | ||
452 | + * and it can be set low externally when in open-drain mode. | ||
453 | + */ | ||
454 | + unsigned int pin = ((uint64_t)data) & 0xF; | ||
455 | + uint32_t gpio = ((uint64_t)data) >> 32; | ||
456 | + uint32_t gpio2 = GPIO_BASE_ADDR + (GPIO_H - gpio); | ||
457 | + | ||
458 | + qtest_irq_intercept_in(global_qtest, "/machine/soc/syscfg"); | ||
459 | + | ||
460 | + /* Setting a line high externally, configuring it in open-drain output */ | ||
461 | + /* And checking the pin was disconnected */ | ||
462 | + gpio_set_irq(gpio, pin, 1); | ||
463 | + gpio_set_bit(gpio, OTYPER, pin, OTYPER_OPEN_DRAIN); | ||
464 | + gpio_set_2bits(gpio, MODER, pin, MODER_OUTPUT); | ||
465 | + g_assert_cmphex(get_disconnected_pins(gpio), ==, 0xFFFF); | ||
466 | + g_assert_cmphex(gpio_readl(gpio, IDR), ==, reset(gpio, IDR) & ~(1 << pin)); | ||
467 | + | ||
468 | + /* Setting a line low externally, configuring it in open-drain output */ | ||
469 | + /* And checking the pin wasn't disconnected */ | ||
470 | + gpio_set_irq(gpio2, pin, 0); | ||
471 | + gpio_set_bit(gpio2, ODR, pin, 1); | ||
472 | + gpio_set_bit(gpio2, OTYPER, pin, OTYPER_OPEN_DRAIN); | ||
473 | + gpio_set_2bits(gpio2, MODER, pin, MODER_OUTPUT); | ||
474 | + g_assert_cmphex(get_disconnected_pins(gpio2), ==, 0xFFFF & ~(1 << pin)); | ||
475 | + g_assert_cmphex(gpio_readl(gpio2, IDR), ==, | ||
476 | + reset(gpio2, IDR) & ~(1 << pin)); | ||
477 | + | ||
478 | + /* Trying to set a open-drain output pin, checking it doesn't work */ | ||
479 | + gpio_set_irq(gpio, pin, 1); | ||
480 | + g_assert_cmphex(get_disconnected_pins(gpio), ==, 0xFFFF); | ||
481 | + g_assert_cmphex(gpio_readl(gpio, IDR), ==, reset(gpio, IDR) & ~(1 << pin)); | ||
482 | + | ||
483 | + /* Trying to reset a open-drain output pin, checking it works */ | ||
484 | + gpio_set_bit(gpio, ODR, pin, 1); | ||
485 | + gpio_set_irq(gpio, pin, 0); | ||
486 | + g_assert_cmphex(get_disconnected_pins(gpio2), ==, 0xFFFF & ~(1 << pin)); | ||
487 | + g_assert_cmphex(gpio_readl(gpio2, IDR), ==, | ||
488 | + reset(gpio2, IDR) & ~(1 << pin)); | ||
489 | + | ||
490 | + /* Clean the test */ | ||
491 | + disconnect_all_pins(gpio2); | ||
492 | + gpio_writel(gpio2, OTYPER, reset(gpio2, OTYPER)); | ||
493 | + gpio_writel(gpio2, ODR, reset(gpio2, ODR)); | ||
494 | + gpio_writel(gpio2, MODER, reset(gpio2, MODER)); | ||
495 | + g_assert_cmphex(gpio_readl(gpio2, IDR), ==, reset(gpio2, IDR)); | ||
496 | + disconnect_all_pins(gpio); | ||
497 | + gpio_writel(gpio, OTYPER, reset(gpio, OTYPER)); | ||
498 | + gpio_writel(gpio, ODR, reset(gpio, ODR)); | ||
499 | + gpio_writel(gpio, MODER, reset(gpio, MODER)); | ||
500 | + g_assert_cmphex(gpio_readl(gpio, IDR), ==, reset(gpio, IDR)); | ||
501 | +} | ||
502 | + | ||
503 | +static void test_bsrr_brr(const void *data) | ||
504 | +{ | ||
505 | + /* | ||
506 | + * Test that writing a '1' in BSS and BSRR | ||
507 | + * has the desired effect on ODR. | ||
508 | + * In BSRR, BSx has priority over BRx. | ||
509 | + */ | ||
510 | + unsigned int pin = ((uint64_t)data) & 0xF; | ||
511 | + uint32_t gpio = ((uint64_t)data) >> 32; | ||
512 | + | ||
513 | + gpio_writel(gpio, BSRR, (1 << pin)); | ||
514 | + g_assert_cmphex(gpio_readl(gpio, ODR), ==, reset(gpio, ODR) | (1 << pin)); | ||
515 | + | ||
516 | + gpio_writel(gpio, BSRR, (1 << (pin + NUM_GPIO_PINS))); | ||
517 | + g_assert_cmphex(gpio_readl(gpio, ODR), ==, reset(gpio, ODR)); | ||
518 | + | ||
519 | + gpio_writel(gpio, BSRR, (1 << pin)); | ||
520 | + g_assert_cmphex(gpio_readl(gpio, ODR), ==, reset(gpio, ODR) | (1 << pin)); | ||
521 | + | ||
522 | + gpio_writel(gpio, BRR, (1 << pin)); | ||
523 | + g_assert_cmphex(gpio_readl(gpio, ODR), ==, reset(gpio, ODR)); | ||
524 | + | ||
525 | + /* BSx should have priority over BRx */ | ||
526 | + gpio_writel(gpio, BSRR, (1 << pin) | (1 << (pin + NUM_GPIO_PINS))); | ||
527 | + g_assert_cmphex(gpio_readl(gpio, ODR), ==, reset(gpio, ODR) | (1 << pin)); | ||
528 | + | ||
529 | + gpio_writel(gpio, BRR, (1 << pin)); | ||
530 | + g_assert_cmphex(gpio_readl(gpio, ODR), ==, reset(gpio, ODR)); | ||
531 | + | ||
532 | + gpio_writel(gpio, ODR, reset(gpio, ODR)); | ||
533 | +} | ||
534 | + | ||
535 | +int main(int argc, char **argv) | ||
536 | +{ | ||
537 | + int ret; | ||
538 | + | ||
539 | + g_test_init(&argc, &argv, NULL); | ||
540 | + g_test_set_nonfatal_assertions(); | ||
541 | + qtest_add_func("stm32l4x5/gpio/test_idr_reset_value", | ||
542 | + test_idr_reset_value); | ||
543 | + /* | ||
544 | + * The inputs for the tests (gpio and pin) can be changed, | ||
545 | + * but the tests don't work for pins that are high at reset | ||
546 | + * (GPIOA15, GPIO13 and GPIOB5). | ||
547 | + * Specifically, rising the pin then checking `get_irq()` | ||
548 | + * is problematic since the pin was already high. | ||
549 | + */ | ||
550 | + qtest_add_data_func("stm32l4x5/gpio/test_gpioc5_output_mode", | ||
551 | + (void *)((uint64_t)GPIO_C << 32 | 5), | ||
552 | + test_gpio_output_mode); | ||
553 | + qtest_add_data_func("stm32l4x5/gpio/test_gpioh3_output_mode", | ||
554 | + (void *)((uint64_t)GPIO_H << 32 | 3), | ||
555 | + test_gpio_output_mode); | ||
556 | + qtest_add_data_func("stm32l4x5/gpio/test_gpio_input_mode1", | ||
557 | + (void *)((uint64_t)GPIO_D << 32 | 6), | ||
558 | + test_gpio_input_mode); | ||
559 | + qtest_add_data_func("stm32l4x5/gpio/test_gpio_input_mode2", | ||
560 | + (void *)((uint64_t)GPIO_C << 32 | 10), | ||
561 | + test_gpio_input_mode); | ||
562 | + qtest_add_data_func("stm32l4x5/gpio/test_gpio_pull_up_pull_down1", | ||
563 | + (void *)((uint64_t)GPIO_B << 32 | 5), | ||
564 | + test_pull_up_pull_down); | ||
565 | + qtest_add_data_func("stm32l4x5/gpio/test_gpio_pull_up_pull_down2", | ||
566 | + (void *)((uint64_t)GPIO_F << 32 | 1), | ||
567 | + test_pull_up_pull_down); | ||
568 | + qtest_add_data_func("stm32l4x5/gpio/test_gpio_push_pull1", | ||
569 | + (void *)((uint64_t)GPIO_G << 32 | 6), | ||
570 | + test_push_pull); | ||
571 | + qtest_add_data_func("stm32l4x5/gpio/test_gpio_push_pull2", | ||
572 | + (void *)((uint64_t)GPIO_H << 32 | 3), | ||
573 | + test_push_pull); | ||
574 | + qtest_add_data_func("stm32l4x5/gpio/test_gpio_open_drain1", | ||
575 | + (void *)((uint64_t)GPIO_C << 32 | 4), | ||
576 | + test_open_drain); | ||
577 | + qtest_add_data_func("stm32l4x5/gpio/test_gpio_open_drain2", | ||
578 | + (void *)((uint64_t)GPIO_E << 32 | 11), | ||
579 | + test_open_drain); | ||
580 | + qtest_add_data_func("stm32l4x5/gpio/test_bsrr_brr1", | ||
581 | + (void *)((uint64_t)GPIO_A << 32 | 12), | ||
582 | + test_bsrr_brr); | ||
583 | + qtest_add_data_func("stm32l4x5/gpio/test_bsrr_brr2", | ||
584 | + (void *)((uint64_t)GPIO_D << 32 | 0), | ||
585 | + test_bsrr_brr); | ||
586 | + | ||
587 | + qtest_start("-machine b-l475e-iot01a"); | ||
588 | + ret = g_test_run(); | ||
589 | + qtest_end(); | ||
590 | + | ||
591 | + return ret; | ||
592 | +} | ||
593 | diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build | ||
58 | index XXXXXXX..XXXXXXX 100644 | 594 | index XXXXXXX..XXXXXXX 100644 |
59 | --- a/target/arm/kvm_arm.h | 595 | --- a/tests/qtest/meson.build |
60 | +++ b/target/arm/kvm_arm.h | 596 | +++ b/tests/qtest/meson.build |
61 | @@ -XXX,XX +XXX,XX @@ void kvm_arm_add_vcpu_properties(Object *obj); | 597 | @@ -XXX,XX +XXX,XX @@ qtests_aspeed = \ |
62 | 598 | qtests_stm32l4x5 = \ | |
63 | /** | 599 | ['stm32l4x5_exti-test', |
64 | * kvm_arm_aarch32_supported: | 600 | 'stm32l4x5_syscfg-test', |
65 | - * @cs: CPUState | 601 | - 'stm32l4x5_rcc-test'] |
66 | * | 602 | + 'stm32l4x5_rcc-test', |
67 | - * Returns: true if the KVM VCPU can enable AArch32 mode | 603 | + 'stm32l4x5_gpio-test'] |
68 | + * Returns: true if KVM can enable AArch32 mode | 604 | |
69 | * and false otherwise. | 605 | qtests_arm = \ |
70 | */ | 606 | (config_all_devices.has_key('CONFIG_MPS2') ? ['sse-timer-test'] : []) + \ |
71 | -bool kvm_arm_aarch32_supported(CPUState *cs); | ||
72 | +bool kvm_arm_aarch32_supported(void); | ||
73 | |||
74 | /** | ||
75 | * kvm_arm_pmu_supported: | ||
76 | - * @cs: CPUState | ||
77 | * | ||
78 | - * Returns: true if the KVM VCPU can enable its PMU | ||
79 | + * Returns: true if KVM can enable the PMU | ||
80 | * and false otherwise. | ||
81 | */ | ||
82 | -bool kvm_arm_pmu_supported(CPUState *cs); | ||
83 | +bool kvm_arm_pmu_supported(void); | ||
84 | |||
85 | /** | ||
86 | * kvm_arm_sve_supported: | ||
87 | - * @cs: CPUState | ||
88 | * | ||
89 | - * Returns true if the KVM VCPU can enable SVE and false otherwise. | ||
90 | + * Returns true if KVM can enable SVE and false otherwise. | ||
91 | */ | ||
92 | -bool kvm_arm_sve_supported(CPUState *cs); | ||
93 | +bool kvm_arm_sve_supported(void); | ||
94 | |||
95 | /** | ||
96 | * kvm_arm_get_max_vm_ipa_size: | ||
97 | @@ -XXX,XX +XXX,XX @@ static inline void kvm_arm_set_cpu_features_from_host(ARMCPU *cpu) | ||
98 | |||
99 | static inline void kvm_arm_add_vcpu_properties(Object *obj) {} | ||
100 | |||
101 | -static inline bool kvm_arm_aarch32_supported(CPUState *cs) | ||
102 | +static inline bool kvm_arm_aarch32_supported(void) | ||
103 | { | ||
104 | return false; | ||
105 | } | ||
106 | |||
107 | -static inline bool kvm_arm_pmu_supported(CPUState *cs) | ||
108 | +static inline bool kvm_arm_pmu_supported(void) | ||
109 | { | ||
110 | return false; | ||
111 | } | ||
112 | |||
113 | -static inline bool kvm_arm_sve_supported(CPUState *cs) | ||
114 | +static inline bool kvm_arm_sve_supported(void) | ||
115 | { | ||
116 | return false; | ||
117 | } | ||
118 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | ||
119 | index XXXXXXX..XXXXXXX 100644 | ||
120 | --- a/target/arm/cpu.c | ||
121 | +++ b/target/arm/cpu.c | ||
122 | @@ -XXX,XX +XXX,XX @@ static void arm_set_pmu(Object *obj, bool value, Error **errp) | ||
123 | ARMCPU *cpu = ARM_CPU(obj); | ||
124 | |||
125 | if (value) { | ||
126 | - if (kvm_enabled() && !kvm_arm_pmu_supported(CPU(cpu))) { | ||
127 | + if (kvm_enabled() && !kvm_arm_pmu_supported()) { | ||
128 | error_setg(errp, "'pmu' feature not supported by KVM on this host"); | ||
129 | return; | ||
130 | } | ||
131 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | ||
132 | index XXXXXXX..XXXXXXX 100644 | ||
133 | --- a/target/arm/cpu64.c | ||
134 | +++ b/target/arm/cpu64.c | ||
135 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp) | ||
136 | |||
137 | /* Collect the set of vector lengths supported by KVM. */ | ||
138 | bitmap_zero(kvm_supported, ARM_MAX_VQ); | ||
139 | - if (kvm_enabled() && kvm_arm_sve_supported(CPU(cpu))) { | ||
140 | + if (kvm_enabled() && kvm_arm_sve_supported()) { | ||
141 | kvm_arm_sve_get_vls(CPU(cpu), kvm_supported); | ||
142 | } else if (kvm_enabled()) { | ||
143 | assert(!cpu_isar_feature(aa64_sve, cpu)); | ||
144 | @@ -XXX,XX +XXX,XX @@ static void cpu_max_set_sve_max_vq(Object *obj, Visitor *v, const char *name, | ||
145 | return; | ||
146 | } | ||
147 | |||
148 | - if (kvm_enabled() && !kvm_arm_sve_supported(CPU(cpu))) { | ||
149 | + if (kvm_enabled() && !kvm_arm_sve_supported()) { | ||
150 | error_setg(errp, "cannot set sve-max-vq"); | ||
151 | error_append_hint(errp, "SVE not supported by KVM on this host\n"); | ||
152 | return; | ||
153 | @@ -XXX,XX +XXX,XX @@ static void cpu_arm_set_sve_vq(Object *obj, Visitor *v, const char *name, | ||
154 | return; | ||
155 | } | ||
156 | |||
157 | - if (value && kvm_enabled() && !kvm_arm_sve_supported(CPU(cpu))) { | ||
158 | + if (value && kvm_enabled() && !kvm_arm_sve_supported()) { | ||
159 | error_setg(errp, "cannot enable %s", name); | ||
160 | error_append_hint(errp, "SVE not supported by KVM on this host\n"); | ||
161 | return; | ||
162 | @@ -XXX,XX +XXX,XX @@ static void cpu_arm_set_sve(Object *obj, Visitor *v, const char *name, | ||
163 | return; | ||
164 | } | ||
165 | |||
166 | - if (value && kvm_enabled() && !kvm_arm_sve_supported(CPU(cpu))) { | ||
167 | + if (value && kvm_enabled() && !kvm_arm_sve_supported()) { | ||
168 | error_setg(errp, "'sve' feature not supported by KVM on this host"); | ||
169 | return; | ||
170 | } | ||
171 | @@ -XXX,XX +XXX,XX @@ static void aarch64_cpu_set_aarch64(Object *obj, bool value, Error **errp) | ||
172 | * uniform execution state like do_interrupt. | ||
173 | */ | ||
174 | if (value == false) { | ||
175 | - if (!kvm_enabled() || !kvm_arm_aarch32_supported(CPU(cpu))) { | ||
176 | + if (!kvm_enabled() || !kvm_arm_aarch32_supported()) { | ||
177 | error_setg(errp, "'aarch64' feature cannot be disabled " | ||
178 | "unless KVM is enabled and 32-bit EL1 " | ||
179 | "is supported"); | ||
180 | diff --git a/target/arm/kvm.c b/target/arm/kvm.c | ||
181 | index XXXXXXX..XXXXXXX 100644 | ||
182 | --- a/target/arm/kvm.c | ||
183 | +++ b/target/arm/kvm.c | ||
184 | @@ -XXX,XX +XXX,XX @@ void kvm_arm_add_vcpu_properties(Object *obj) | ||
185 | } | ||
186 | } | ||
187 | |||
188 | -bool kvm_arm_pmu_supported(CPUState *cpu) | ||
189 | +bool kvm_arm_pmu_supported(void) | ||
190 | { | ||
191 | - return kvm_check_extension(cpu->kvm_state, KVM_CAP_ARM_PMU_V3); | ||
192 | + return kvm_check_extension(kvm_state, KVM_CAP_ARM_PMU_V3); | ||
193 | } | ||
194 | |||
195 | int kvm_arm_get_max_vm_ipa_size(MachineState *ms) | ||
196 | diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c | ||
197 | index XXXXXXX..XXXXXXX 100644 | ||
198 | --- a/target/arm/kvm64.c | ||
199 | +++ b/target/arm/kvm64.c | ||
200 | @@ -XXX,XX +XXX,XX @@ bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf) | ||
201 | return true; | ||
202 | } | ||
203 | |||
204 | -bool kvm_arm_aarch32_supported(CPUState *cpu) | ||
205 | +bool kvm_arm_aarch32_supported(void) | ||
206 | { | ||
207 | - KVMState *s = KVM_STATE(current_accel()); | ||
208 | - | ||
209 | - return kvm_check_extension(s, KVM_CAP_ARM_EL1_32BIT); | ||
210 | + return kvm_check_extension(kvm_state, KVM_CAP_ARM_EL1_32BIT); | ||
211 | } | ||
212 | |||
213 | -bool kvm_arm_sve_supported(CPUState *cpu) | ||
214 | +bool kvm_arm_sve_supported(void) | ||
215 | { | ||
216 | - KVMState *s = KVM_STATE(current_accel()); | ||
217 | - | ||
218 | - return kvm_check_extension(s, KVM_CAP_ARM_SVE); | ||
219 | + return kvm_check_extension(kvm_state, KVM_CAP_ARM_SVE); | ||
220 | } | ||
221 | |||
222 | QEMU_BUILD_BUG_ON(KVM_ARM64_SVE_VQ_MIN != 1); | ||
223 | @@ -XXX,XX +XXX,XX @@ int kvm_arch_init_vcpu(CPUState *cs) | ||
224 | env->features &= ~(1ULL << ARM_FEATURE_PMU); | ||
225 | } | ||
226 | if (cpu_isar_feature(aa64_sve, cpu)) { | ||
227 | - assert(kvm_arm_sve_supported(cs)); | ||
228 | + assert(kvm_arm_sve_supported()); | ||
229 | cpu->kvm_init_features[0] |= 1 << KVM_ARM_VCPU_SVE; | ||
230 | } | ||
231 | |||
232 | -- | 607 | -- |
233 | 2.20.1 | 608 | 2.34.1 |
234 | 609 | ||
235 | 610 | diff view generated by jsdifflib |
1 | From: Shameer Kolothum <shameerali.kolothum.thodi@huawei.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | This adds support for memory(pc-dimm) hot remove on arm/virt that | 3 | While the 8-bit input elements are sequential in the input vector, |
4 | uses acpi ged device. | 4 | the 32-bit output elements are not sequential in the output matrix. |
5 | 5 | Do not attempt to compute 2 32-bit outputs at the same time. | |
6 | NVDIMM hot removal is not yet supported. | 6 | |
7 | 7 | Cc: qemu-stable@nongnu.org | |
8 | Signed-off-by: Shameer Kolothum <shameerali.kolothum.thodi@huawei.com> | 8 | Fixes: 23a5e3859f5 ("target/arm: Implement SME integer outer product") |
9 | Message-id: 20200622124157.20360-1-shameerali.kolothum.thodi@huawei.com | 9 | Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2083 |
10 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | 10 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
11 | Tested-by: Eric Auger <eric.auger@redhat.com> | 11 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
12 | Message-id: 20240305163931.242795-1-richard.henderson@linaro.org | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | --- | 14 | --- |
14 | hw/acpi/generic_event_device.c | 29 ++++++++++++++++ | 15 | target/arm/tcg/sme_helper.c | 77 ++++++++++++++++++------------- |
15 | hw/arm/virt.c | 62 ++++++++++++++++++++++++++++++++-- | 16 | tests/tcg/aarch64/sme-smopa-1.c | 47 +++++++++++++++++++ |
16 | 2 files changed, 89 insertions(+), 2 deletions(-) | 17 | tests/tcg/aarch64/sme-smopa-2.c | 54 ++++++++++++++++++++++ |
17 | 18 | tests/tcg/aarch64/Makefile.target | 2 +- | |
18 | diff --git a/hw/acpi/generic_event_device.c b/hw/acpi/generic_event_device.c | 19 | 4 files changed, 147 insertions(+), 33 deletions(-) |
20 | create mode 100644 tests/tcg/aarch64/sme-smopa-1.c | ||
21 | create mode 100644 tests/tcg/aarch64/sme-smopa-2.c | ||
22 | |||
23 | diff --git a/target/arm/tcg/sme_helper.c b/target/arm/tcg/sme_helper.c | ||
19 | index XXXXXXX..XXXXXXX 100644 | 24 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/hw/acpi/generic_event_device.c | 25 | --- a/target/arm/tcg/sme_helper.c |
21 | +++ b/hw/acpi/generic_event_device.c | 26 | +++ b/target/arm/tcg/sme_helper.c |
22 | @@ -XXX,XX +XXX,XX @@ static void acpi_ged_device_plug_cb(HotplugHandler *hotplug_dev, | 27 | @@ -XXX,XX +XXX,XX @@ void HELPER(sme_bfmopa)(void *vza, void *vzn, void *vzm, void *vpn, |
23 | } | 28 | } |
24 | } | 29 | } |
25 | 30 | ||
26 | +static void acpi_ged_unplug_request_cb(HotplugHandler *hotplug_dev, | 31 | -typedef uint64_t IMOPFn(uint64_t, uint64_t, uint64_t, uint8_t, bool); |
27 | + DeviceState *dev, Error **errp) | 32 | +typedef uint32_t IMOPFn32(uint32_t, uint32_t, uint32_t, uint8_t, bool); |
33 | +static inline void do_imopa_s(uint32_t *za, uint32_t *zn, uint32_t *zm, | ||
34 | + uint8_t *pn, uint8_t *pm, | ||
35 | + uint32_t desc, IMOPFn32 *fn) | ||
28 | +{ | 36 | +{ |
29 | + AcpiGedState *s = ACPI_GED(hotplug_dev); | 37 | + intptr_t row, col, oprsz = simd_oprsz(desc) / 4; |
30 | + | 38 | + bool neg = simd_data(desc); |
31 | + if ((object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM) && | 39 | |
32 | + !(object_dynamic_cast(OBJECT(dev), TYPE_NVDIMM)))) { | 40 | -static inline void do_imopa(uint64_t *za, uint64_t *zn, uint64_t *zm, |
33 | + acpi_memory_unplug_request_cb(hotplug_dev, &s->memhp_state, dev, errp); | 41 | - uint8_t *pn, uint8_t *pm, |
34 | + } else { | 42 | - uint32_t desc, IMOPFn *fn) |
35 | + error_setg(errp, "acpi: device unplug request for unsupported device" | 43 | + for (row = 0; row < oprsz; ++row) { |
36 | + " type: %s", object_get_typename(OBJECT(dev))); | 44 | + uint8_t pa = (pn[H1(row >> 1)] >> ((row & 1) * 4)) & 0xf; |
45 | + uint32_t *za_row = &za[tile_vslice_index(row)]; | ||
46 | + uint32_t n = zn[H4(row)]; | ||
47 | + | ||
48 | + for (col = 0; col < oprsz; ++col) { | ||
49 | + uint8_t pb = pm[H1(col >> 1)] >> ((col & 1) * 4); | ||
50 | + uint32_t *a = &za_row[H4(col)]; | ||
51 | + | ||
52 | + *a = fn(n, zm[H4(col)], *a, pa & pb, neg); | ||
53 | + } | ||
37 | + } | 54 | + } |
38 | +} | 55 | +} |
39 | + | 56 | + |
40 | +static void acpi_ged_unplug_cb(HotplugHandler *hotplug_dev, | 57 | +typedef uint64_t IMOPFn64(uint64_t, uint64_t, uint64_t, uint8_t, bool); |
41 | + DeviceState *dev, Error **errp) | 58 | +static inline void do_imopa_d(uint64_t *za, uint64_t *zn, uint64_t *zm, |
59 | + uint8_t *pn, uint8_t *pm, | ||
60 | + uint32_t desc, IMOPFn64 *fn) | ||
61 | { | ||
62 | intptr_t row, col, oprsz = simd_oprsz(desc) / 8; | ||
63 | bool neg = simd_data(desc); | ||
64 | @@ -XXX,XX +XXX,XX @@ static inline void do_imopa(uint64_t *za, uint64_t *zn, uint64_t *zm, | ||
65 | } | ||
66 | |||
67 | #define DEF_IMOP_32(NAME, NTYPE, MTYPE) \ | ||
68 | -static uint64_t NAME(uint64_t n, uint64_t m, uint64_t a, uint8_t p, bool neg) \ | ||
69 | +static uint32_t NAME(uint32_t n, uint32_t m, uint32_t a, uint8_t p, bool neg) \ | ||
70 | { \ | ||
71 | - uint32_t sum0 = 0, sum1 = 0; \ | ||
72 | + uint32_t sum = 0; \ | ||
73 | /* Apply P to N as a mask, making the inactive elements 0. */ \ | ||
74 | n &= expand_pred_b(p); \ | ||
75 | - sum0 += (NTYPE)(n >> 0) * (MTYPE)(m >> 0); \ | ||
76 | - sum0 += (NTYPE)(n >> 8) * (MTYPE)(m >> 8); \ | ||
77 | - sum0 += (NTYPE)(n >> 16) * (MTYPE)(m >> 16); \ | ||
78 | - sum0 += (NTYPE)(n >> 24) * (MTYPE)(m >> 24); \ | ||
79 | - sum1 += (NTYPE)(n >> 32) * (MTYPE)(m >> 32); \ | ||
80 | - sum1 += (NTYPE)(n >> 40) * (MTYPE)(m >> 40); \ | ||
81 | - sum1 += (NTYPE)(n >> 48) * (MTYPE)(m >> 48); \ | ||
82 | - sum1 += (NTYPE)(n >> 56) * (MTYPE)(m >> 56); \ | ||
83 | - if (neg) { \ | ||
84 | - sum0 = (uint32_t)a - sum0, sum1 = (uint32_t)(a >> 32) - sum1; \ | ||
85 | - } else { \ | ||
86 | - sum0 = (uint32_t)a + sum0, sum1 = (uint32_t)(a >> 32) + sum1; \ | ||
87 | - } \ | ||
88 | - return ((uint64_t)sum1 << 32) | sum0; \ | ||
89 | + sum += (NTYPE)(n >> 0) * (MTYPE)(m >> 0); \ | ||
90 | + sum += (NTYPE)(n >> 8) * (MTYPE)(m >> 8); \ | ||
91 | + sum += (NTYPE)(n >> 16) * (MTYPE)(m >> 16); \ | ||
92 | + sum += (NTYPE)(n >> 24) * (MTYPE)(m >> 24); \ | ||
93 | + return neg ? a - sum : a + sum; \ | ||
94 | } | ||
95 | |||
96 | #define DEF_IMOP_64(NAME, NTYPE, MTYPE) \ | ||
97 | @@ -XXX,XX +XXX,XX @@ DEF_IMOP_64(umopa_d, uint16_t, uint16_t) | ||
98 | DEF_IMOP_64(sumopa_d, int16_t, uint16_t) | ||
99 | DEF_IMOP_64(usmopa_d, uint16_t, int16_t) | ||
100 | |||
101 | -#define DEF_IMOPH(NAME) \ | ||
102 | - void HELPER(sme_##NAME)(void *vza, void *vzn, void *vzm, void *vpn, \ | ||
103 | - void *vpm, uint32_t desc) \ | ||
104 | - { do_imopa(vza, vzn, vzm, vpn, vpm, desc, NAME); } | ||
105 | +#define DEF_IMOPH(NAME, S) \ | ||
106 | + void HELPER(sme_##NAME##_##S)(void *vza, void *vzn, void *vzm, \ | ||
107 | + void *vpn, void *vpm, uint32_t desc) \ | ||
108 | + { do_imopa_##S(vza, vzn, vzm, vpn, vpm, desc, NAME##_##S); } | ||
109 | |||
110 | -DEF_IMOPH(smopa_s) | ||
111 | -DEF_IMOPH(umopa_s) | ||
112 | -DEF_IMOPH(sumopa_s) | ||
113 | -DEF_IMOPH(usmopa_s) | ||
114 | -DEF_IMOPH(smopa_d) | ||
115 | -DEF_IMOPH(umopa_d) | ||
116 | -DEF_IMOPH(sumopa_d) | ||
117 | -DEF_IMOPH(usmopa_d) | ||
118 | +DEF_IMOPH(smopa, s) | ||
119 | +DEF_IMOPH(umopa, s) | ||
120 | +DEF_IMOPH(sumopa, s) | ||
121 | +DEF_IMOPH(usmopa, s) | ||
122 | + | ||
123 | +DEF_IMOPH(smopa, d) | ||
124 | +DEF_IMOPH(umopa, d) | ||
125 | +DEF_IMOPH(sumopa, d) | ||
126 | +DEF_IMOPH(usmopa, d) | ||
127 | diff --git a/tests/tcg/aarch64/sme-smopa-1.c b/tests/tcg/aarch64/sme-smopa-1.c | ||
128 | new file mode 100644 | ||
129 | index XXXXXXX..XXXXXXX | ||
130 | --- /dev/null | ||
131 | +++ b/tests/tcg/aarch64/sme-smopa-1.c | ||
132 | @@ -XXX,XX +XXX,XX @@ | ||
133 | +#include <stdio.h> | ||
134 | +#include <string.h> | ||
135 | + | ||
136 | +int main() | ||
42 | +{ | 137 | +{ |
43 | + AcpiGedState *s = ACPI_GED(hotplug_dev); | 138 | + static const int cmp[4][4] = { |
44 | + | 139 | + { 110, 134, 158, 182 }, |
45 | + if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { | 140 | + { 390, 478, 566, 654 }, |
46 | + acpi_memory_unplug_cb(&s->memhp_state, dev, errp); | 141 | + { 670, 822, 974, 1126 }, |
47 | + } else { | 142 | + { 950, 1166, 1382, 1598 } |
48 | + error_setg(errp, "acpi: device unplug for unsupported device" | 143 | + }; |
49 | + " type: %s", object_get_typename(OBJECT(dev))); | 144 | + int dst[4][4]; |
50 | + } | 145 | + int *tmp = &dst[0][0]; |
146 | + | ||
147 | + asm volatile( | ||
148 | + ".arch armv8-r+sme\n\t" | ||
149 | + "smstart\n\t" | ||
150 | + "index z0.b, #0, #1\n\t" | ||
151 | + "movprfx z1, z0\n\t" | ||
152 | + "add z1.b, z1.b, #16\n\t" | ||
153 | + "ptrue p0.b\n\t" | ||
154 | + "smopa za0.s, p0/m, p0/m, z0.b, z1.b\n\t" | ||
155 | + "ptrue p0.s, vl4\n\t" | ||
156 | + "mov w12, #0\n\t" | ||
157 | + "st1w { za0h.s[w12, #0] }, p0, [%0]\n\t" | ||
158 | + "add %0, %0, #16\n\t" | ||
159 | + "st1w { za0h.s[w12, #1] }, p0, [%0]\n\t" | ||
160 | + "add %0, %0, #16\n\t" | ||
161 | + "st1w { za0h.s[w12, #2] }, p0, [%0]\n\t" | ||
162 | + "add %0, %0, #16\n\t" | ||
163 | + "st1w { za0h.s[w12, #3] }, p0, [%0]\n\t" | ||
164 | + "smstop" | ||
165 | + : "+r"(tmp) : : "memory"); | ||
166 | + | ||
167 | + if (memcmp(cmp, dst, sizeof(dst)) == 0) { | ||
168 | + return 0; | ||
169 | + } | ||
170 | + | ||
171 | + /* See above for correct results. */ | ||
172 | + for (int i = 0; i < 4; ++i) { | ||
173 | + for (int j = 0; j < 4; ++j) { | ||
174 | + printf("%6d", dst[i][j]); | ||
175 | + } | ||
176 | + printf("\n"); | ||
177 | + } | ||
178 | + return 1; | ||
51 | +} | 179 | +} |
52 | + | 180 | diff --git a/tests/tcg/aarch64/sme-smopa-2.c b/tests/tcg/aarch64/sme-smopa-2.c |
53 | static void acpi_ged_send_event(AcpiDeviceIf *adev, AcpiEventStatusBits ev) | 181 | new file mode 100644 |
54 | { | 182 | index XXXXXXX..XXXXXXX |
55 | AcpiGedState *s = ACPI_GED(adev); | 183 | --- /dev/null |
56 | @@ -XXX,XX +XXX,XX @@ static void acpi_ged_class_init(ObjectClass *class, void *data) | 184 | +++ b/tests/tcg/aarch64/sme-smopa-2.c |
57 | dc->vmsd = &vmstate_acpi_ged; | 185 | @@ -XXX,XX +XXX,XX @@ |
58 | 186 | +#include <stdio.h> | |
59 | hc->plug = acpi_ged_device_plug_cb; | 187 | +#include <string.h> |
60 | + hc->unplug_request = acpi_ged_unplug_request_cb; | 188 | + |
61 | + hc->unplug = acpi_ged_unplug_cb; | 189 | +int main() |
62 | 190 | +{ | |
63 | adevc->send_event = acpi_ged_send_event; | 191 | + static const long cmp[4][4] = { |
64 | } | 192 | + { 110, 134, 158, 182 }, |
65 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c | 193 | + { 390, 478, 566, 654 }, |
194 | + { 670, 822, 974, 1126 }, | ||
195 | + { 950, 1166, 1382, 1598 } | ||
196 | + }; | ||
197 | + long dst[4][4]; | ||
198 | + long *tmp = &dst[0][0]; | ||
199 | + long svl; | ||
200 | + | ||
201 | + /* Validate that we have a wide enough vector for 4 elements. */ | ||
202 | + asm(".arch armv8-r+sme-i64\n\trdsvl %0, #1" : "=r"(svl)); | ||
203 | + if (svl < 32) { | ||
204 | + return 0; | ||
205 | + } | ||
206 | + | ||
207 | + asm volatile( | ||
208 | + "smstart\n\t" | ||
209 | + "index z0.h, #0, #1\n\t" | ||
210 | + "movprfx z1, z0\n\t" | ||
211 | + "add z1.h, z1.h, #16\n\t" | ||
212 | + "ptrue p0.b\n\t" | ||
213 | + "smopa za0.d, p0/m, p0/m, z0.h, z1.h\n\t" | ||
214 | + "ptrue p0.d, vl4\n\t" | ||
215 | + "mov w12, #0\n\t" | ||
216 | + "st1d { za0h.d[w12, #0] }, p0, [%0]\n\t" | ||
217 | + "add %0, %0, #32\n\t" | ||
218 | + "st1d { za0h.d[w12, #1] }, p0, [%0]\n\t" | ||
219 | + "mov w12, #2\n\t" | ||
220 | + "add %0, %0, #32\n\t" | ||
221 | + "st1d { za0h.d[w12, #0] }, p0, [%0]\n\t" | ||
222 | + "add %0, %0, #32\n\t" | ||
223 | + "st1d { za0h.d[w12, #1] }, p0, [%0]\n\t" | ||
224 | + "smstop" | ||
225 | + : "+r"(tmp) : : "memory"); | ||
226 | + | ||
227 | + if (memcmp(cmp, dst, sizeof(dst)) == 0) { | ||
228 | + return 0; | ||
229 | + } | ||
230 | + | ||
231 | + /* See above for correct results. */ | ||
232 | + for (int i = 0; i < 4; ++i) { | ||
233 | + for (int j = 0; j < 4; ++j) { | ||
234 | + printf("%6ld", dst[i][j]); | ||
235 | + } | ||
236 | + printf("\n"); | ||
237 | + } | ||
238 | + return 1; | ||
239 | +} | ||
240 | diff --git a/tests/tcg/aarch64/Makefile.target b/tests/tcg/aarch64/Makefile.target | ||
66 | index XXXXXXX..XXXXXXX 100644 | 241 | index XXXXXXX..XXXXXXX 100644 |
67 | --- a/hw/arm/virt.c | 242 | --- a/tests/tcg/aarch64/Makefile.target |
68 | +++ b/hw/arm/virt.c | 243 | +++ b/tests/tcg/aarch64/Makefile.target |
69 | @@ -XXX,XX +XXX,XX @@ static void virt_machine_device_plug_cb(HotplugHandler *hotplug_dev, | 244 | @@ -XXX,XX +XXX,XX @@ endif |
70 | } | 245 | |
71 | } | 246 | # SME Tests |
72 | 247 | ifneq ($(CROSS_AS_HAS_ARMV9_SME),) | |
73 | +static void virt_dimm_unplug_request(HotplugHandler *hotplug_dev, | 248 | -AARCH64_TESTS += sme-outprod1 |
74 | + DeviceState *dev, Error **errp) | 249 | +AARCH64_TESTS += sme-outprod1 sme-smopa-1 sme-smopa-2 |
75 | +{ | 250 | endif |
76 | + VirtMachineState *vms = VIRT_MACHINE(hotplug_dev); | 251 | |
77 | + Error *local_err = NULL; | 252 | # System Registers Tests |
78 | + | ||
79 | + if (!vms->acpi_dev) { | ||
80 | + error_setg(&local_err, | ||
81 | + "memory hotplug is not enabled: missing acpi-ged device"); | ||
82 | + goto out; | ||
83 | + } | ||
84 | + | ||
85 | + if (object_dynamic_cast(OBJECT(dev), TYPE_NVDIMM)) { | ||
86 | + error_setg(&local_err, | ||
87 | + "nvdimm device hot unplug is not supported yet."); | ||
88 | + goto out; | ||
89 | + } | ||
90 | + | ||
91 | + hotplug_handler_unplug_request(HOTPLUG_HANDLER(vms->acpi_dev), dev, | ||
92 | + &local_err); | ||
93 | +out: | ||
94 | + error_propagate(errp, local_err); | ||
95 | +} | ||
96 | + | ||
97 | +static void virt_dimm_unplug(HotplugHandler *hotplug_dev, | ||
98 | + DeviceState *dev, Error **errp) | ||
99 | +{ | ||
100 | + VirtMachineState *vms = VIRT_MACHINE(hotplug_dev); | ||
101 | + Error *local_err = NULL; | ||
102 | + | ||
103 | + hotplug_handler_unplug(HOTPLUG_HANDLER(vms->acpi_dev), dev, &local_err); | ||
104 | + if (local_err) { | ||
105 | + goto out; | ||
106 | + } | ||
107 | + | ||
108 | + pc_dimm_unplug(PC_DIMM(dev), MACHINE(vms)); | ||
109 | + qdev_unrealize(dev); | ||
110 | + | ||
111 | +out: | ||
112 | + error_propagate(errp, local_err); | ||
113 | +} | ||
114 | + | ||
115 | static void virt_machine_device_unplug_request_cb(HotplugHandler *hotplug_dev, | ||
116 | DeviceState *dev, Error **errp) | ||
117 | { | ||
118 | - error_setg(errp, "device unplug request for unsupported device" | ||
119 | - " type: %s", object_get_typename(OBJECT(dev))); | ||
120 | + if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { | ||
121 | + virt_dimm_unplug_request(hotplug_dev, dev, errp); | ||
122 | + } else { | ||
123 | + error_setg(errp, "device unplug request for unsupported device" | ||
124 | + " type: %s", object_get_typename(OBJECT(dev))); | ||
125 | + } | ||
126 | +} | ||
127 | + | ||
128 | +static void virt_machine_device_unplug_cb(HotplugHandler *hotplug_dev, | ||
129 | + DeviceState *dev, Error **errp) | ||
130 | +{ | ||
131 | + if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { | ||
132 | + virt_dimm_unplug(hotplug_dev, dev, errp); | ||
133 | + } else { | ||
134 | + error_setg(errp, "virt: device unplug for unsupported device" | ||
135 | + " type: %s", object_get_typename(OBJECT(dev))); | ||
136 | + } | ||
137 | } | ||
138 | |||
139 | static HotplugHandler *virt_machine_get_hotplug_handler(MachineState *machine, | ||
140 | @@ -XXX,XX +XXX,XX @@ static void virt_machine_class_init(ObjectClass *oc, void *data) | ||
141 | hc->pre_plug = virt_machine_device_pre_plug_cb; | ||
142 | hc->plug = virt_machine_device_plug_cb; | ||
143 | hc->unplug_request = virt_machine_device_unplug_request_cb; | ||
144 | + hc->unplug = virt_machine_device_unplug_cb; | ||
145 | mc->numa_mem_supported = true; | ||
146 | mc->nvdimm_supported = true; | ||
147 | mc->auto_enable_numa_with_memhp = true; | ||
148 | -- | 253 | -- |
149 | 2.20.1 | 254 | 2.34.1 |
150 | 255 | ||
151 | 256 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | The sun4v RTC device model added under commit a0e893039cf2ce0 in 2016 |
---|---|---|---|
2 | was unfortunately added with a license of GPL-v3-or-later, which is | ||
3 | not compatible with other QEMU code which has a GPL-v2-only license. | ||
2 | 4 | ||
3 | To differenciate with the CMSDK APB peripheral region, | 5 | Relicense the code in the .c and the .h file to GPL-v2-or-later, |
4 | rename this region 'CMSDK AHB peripheral region'. | 6 | to make it compatible with the rest of QEMU. |
5 | 7 | ||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Cc: qemu-stable@nongnu.org |
7 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Message-id: 20200617072539.32686-8-f4bug@amsat.org | 10 | Signed-off-by: Paolo Bonzini (for Red Hat) <pbonzini@redhat.com> |
11 | Signed-off-by: Artyom Tarasenko <atar4qemu@gmail.com> | ||
12 | Signed-off-by: Markus Armbruster <armbru@redhat.com> | ||
13 | Signed-off-by: Alex Bennée <alex.bennee@linaro.org> | ||
14 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
15 | Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> | ||
16 | Acked-by: Alex Bennée <alex.bennee@linaro.org> | ||
17 | Message-id: 20240223161300.938542-1-peter.maydell@linaro.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 18 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 19 | --- |
11 | hw/arm/mps2.c | 3 ++- | 20 | include/hw/rtc/sun4v-rtc.h | 2 +- |
12 | 1 file changed, 2 insertions(+), 1 deletion(-) | 21 | hw/rtc/sun4v-rtc.c | 2 +- |
22 | 2 files changed, 2 insertions(+), 2 deletions(-) | ||
13 | 23 | ||
14 | diff --git a/hw/arm/mps2.c b/hw/arm/mps2.c | 24 | diff --git a/include/hw/rtc/sun4v-rtc.h b/include/hw/rtc/sun4v-rtc.h |
15 | index XXXXXXX..XXXXXXX 100644 | 25 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/hw/arm/mps2.c | 26 | --- a/include/hw/rtc/sun4v-rtc.h |
17 | +++ b/hw/arm/mps2.c | 27 | +++ b/include/hw/rtc/sun4v-rtc.h |
18 | @@ -XXX,XX +XXX,XX @@ static void mps2_common_init(MachineState *machine) | 28 | @@ -XXX,XX +XXX,XX @@ |
19 | */ | 29 | * |
20 | create_unimplemented_device("CMSDK APB peripheral region @0x40000000", | 30 | * Copyright (c) 2016 Artyom Tarasenko |
21 | 0x40000000, 0x00010000); | 31 | * |
22 | - create_unimplemented_device("CMSDK peripheral region @0x40010000", | 32 | - * This code is licensed under the GNU GPL v3 or (at your option) any later |
23 | + create_unimplemented_device("CMSDK AHB peripheral region @0x40010000", | 33 | + * This code is licensed under the GNU GPL v2 or (at your option) any later |
24 | 0x40010000, 0x00010000); | 34 | * version. |
25 | create_unimplemented_device("Extra peripheral region @0x40020000", | 35 | */ |
26 | 0x40020000, 0x00010000); | 36 | |
27 | + | 37 | diff --git a/hw/rtc/sun4v-rtc.c b/hw/rtc/sun4v-rtc.c |
28 | create_unimplemented_device("RESERVED 4", 0x40030000, 0x001D0000); | 38 | index XXXXXXX..XXXXXXX 100644 |
29 | create_unimplemented_device("VGA", 0x41000000, 0x0200000); | 39 | --- a/hw/rtc/sun4v-rtc.c |
40 | +++ b/hw/rtc/sun4v-rtc.c | ||
41 | @@ -XXX,XX +XXX,XX @@ | ||
42 | * | ||
43 | * Copyright (c) 2016 Artyom Tarasenko | ||
44 | * | ||
45 | - * This code is licensed under the GNU GPL v3 or (at your option) any later | ||
46 | + * This code is licensed under the GNU GPL v2 or (at your option) any later | ||
47 | * version. | ||
48 | */ | ||
30 | 49 | ||
31 | -- | 50 | -- |
32 | 2.20.1 | 51 | 2.34.1 |
33 | 52 | ||
34 | 53 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | From: Thomas Huth <thuth@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | 'ARM SBCon two-wire serial bus interface' is the official | 3 | Move the code to a separate file so that we do not have to compile |
4 | name describing the pair of registers used to bitbanging | 4 | it anymore if CONFIG_ARM_V7M is not set. |
5 | I2C in the Versatile boards. | ||
6 | 5 | ||
7 | Make the private VersatileI2CState structure as public | 6 | Signed-off-by: Thomas Huth <thuth@redhat.com> |
8 | ArmSbconI2CState. | 7 | Message-id: 20240308141051.536599-2-thuth@redhat.com |
9 | Add the TYPE_ARM_SBCON_I2C, alias to our current | ||
10 | TYPE_VERSATILE_I2C model. | ||
11 | Rename the memory region description as 'arm_sbcon_i2c'. | ||
12 | |||
13 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
14 | Message-id: 20200617072539.32686-5-f4bug@amsat.org | ||
15 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
17 | --- | 10 | --- |
18 | include/hw/i2c/arm_sbcon_i2c.h | 35 ++++++++++++++++++++++++++++++++++ | 11 | target/arm/tcg/cpu-v7m.c | 290 +++++++++++++++++++++++++++++++++++++ |
19 | hw/i2c/versatile_i2c.c | 17 +++++------------ | 12 | target/arm/tcg/cpu32.c | 261 --------------------------------- |
20 | MAINTAINERS | 1 + | 13 | target/arm/meson.build | 3 + |
21 | 3 files changed, 41 insertions(+), 12 deletions(-) | 14 | target/arm/tcg/meson.build | 3 + |
22 | create mode 100644 include/hw/i2c/arm_sbcon_i2c.h | 15 | 4 files changed, 296 insertions(+), 261 deletions(-) |
16 | create mode 100644 target/arm/tcg/cpu-v7m.c | ||
23 | 17 | ||
24 | diff --git a/include/hw/i2c/arm_sbcon_i2c.h b/include/hw/i2c/arm_sbcon_i2c.h | 18 | diff --git a/target/arm/tcg/cpu-v7m.c b/target/arm/tcg/cpu-v7m.c |
25 | new file mode 100644 | 19 | new file mode 100644 |
26 | index XXXXXXX..XXXXXXX | 20 | index XXXXXXX..XXXXXXX |
27 | --- /dev/null | 21 | --- /dev/null |
28 | +++ b/include/hw/i2c/arm_sbcon_i2c.h | 22 | +++ b/target/arm/tcg/cpu-v7m.c |
29 | @@ -XXX,XX +XXX,XX @@ | 23 | @@ -XXX,XX +XXX,XX @@ |
30 | +/* | 24 | +/* |
31 | + * ARM SBCon two-wire serial bus interface (I2C bitbang) | 25 | + * QEMU ARMv7-M TCG-only CPUs. |
32 | + * a.k.a. | ||
33 | + * ARM Versatile I2C controller | ||
34 | + * | 26 | + * |
35 | + * Copyright (c) 2006-2007 CodeSourcery. | 27 | + * Copyright (c) 2012 SUSE LINUX Products GmbH |
36 | + * Copyright (c) 2012 Oskar Andero <oskar.andero@gmail.com> | 28 | + * |
37 | + * Copyright (C) 2020 Philippe Mathieu-Daudé <f4bug@amsat.org> | 29 | + * This code is licensed under the GNU GPL v2 or later. |
38 | + * | 30 | + * |
39 | + * SPDX-License-Identifier: GPL-2.0-or-later | 31 | + * SPDX-License-Identifier: GPL-2.0-or-later |
40 | + */ | 32 | + */ |
41 | +#ifndef HW_I2C_ARM_SBCON_H | 33 | + |
42 | +#define HW_I2C_ARM_SBCON_H | 34 | +#include "qemu/osdep.h" |
43 | + | 35 | +#include "cpu.h" |
44 | +#include "hw/sysbus.h" | 36 | +#include "hw/core/tcg-cpu-ops.h" |
45 | +#include "hw/i2c/bitbang_i2c.h" | 37 | +#include "internals.h" |
46 | + | 38 | + |
47 | +#define TYPE_VERSATILE_I2C "versatile_i2c" | 39 | +#if !defined(CONFIG_USER_ONLY) |
48 | +#define TYPE_ARM_SBCON_I2C TYPE_VERSATILE_I2C | 40 | + |
49 | + | 41 | +#include "hw/intc/armv7m_nvic.h" |
50 | +#define ARM_SBCON_I2C(obj) \ | 42 | + |
51 | + OBJECT_CHECK(ArmSbconI2CState, (obj), TYPE_ARM_SBCON_I2C) | 43 | +static bool arm_v7m_cpu_exec_interrupt(CPUState *cs, int interrupt_request) |
52 | + | 44 | +{ |
53 | +typedef struct ArmSbconI2CState { | 45 | + CPUClass *cc = CPU_GET_CLASS(cs); |
54 | + /*< private >*/ | 46 | + ARMCPU *cpu = ARM_CPU(cs); |
55 | + SysBusDevice parent_obj; | 47 | + CPUARMState *env = &cpu->env; |
56 | + /*< public >*/ | 48 | + bool ret = false; |
57 | + | 49 | + |
58 | + MemoryRegion iomem; | 50 | + /* |
59 | + bitbang_i2c_interface bitbang; | 51 | + * ARMv7-M interrupt masking works differently than -A or -R. |
60 | + int out; | 52 | + * There is no FIQ/IRQ distinction. Instead of I and F bits |
61 | + int in; | 53 | + * masking FIQ and IRQ interrupts, an exception is taken only |
62 | +} ArmSbconI2CState; | 54 | + * if it is higher priority than the current execution priority |
63 | + | 55 | + * (which depends on state like BASEPRI, FAULTMASK and the |
64 | +#endif /* HW_I2C_ARM_SBCON_H */ | 56 | + * currently active exception). |
65 | diff --git a/hw/i2c/versatile_i2c.c b/hw/i2c/versatile_i2c.c | 57 | + */ |
58 | + if (interrupt_request & CPU_INTERRUPT_HARD | ||
59 | + && (armv7m_nvic_can_take_pending_exception(env->nvic))) { | ||
60 | + cs->exception_index = EXCP_IRQ; | ||
61 | + cc->tcg_ops->do_interrupt(cs); | ||
62 | + ret = true; | ||
63 | + } | ||
64 | + return ret; | ||
65 | +} | ||
66 | + | ||
67 | +#endif /* !CONFIG_USER_ONLY */ | ||
68 | + | ||
69 | +static void cortex_m0_initfn(Object *obj) | ||
70 | +{ | ||
71 | + ARMCPU *cpu = ARM_CPU(obj); | ||
72 | + set_feature(&cpu->env, ARM_FEATURE_V6); | ||
73 | + set_feature(&cpu->env, ARM_FEATURE_M); | ||
74 | + | ||
75 | + cpu->midr = 0x410cc200; | ||
76 | + | ||
77 | + /* | ||
78 | + * These ID register values are not guest visible, because | ||
79 | + * we do not implement the Main Extension. They must be set | ||
80 | + * to values corresponding to the Cortex-M0's implemented | ||
81 | + * features, because QEMU generally controls its emulation | ||
82 | + * by looking at ID register fields. We use the same values as | ||
83 | + * for the M3. | ||
84 | + */ | ||
85 | + cpu->isar.id_pfr0 = 0x00000030; | ||
86 | + cpu->isar.id_pfr1 = 0x00000200; | ||
87 | + cpu->isar.id_dfr0 = 0x00100000; | ||
88 | + cpu->id_afr0 = 0x00000000; | ||
89 | + cpu->isar.id_mmfr0 = 0x00000030; | ||
90 | + cpu->isar.id_mmfr1 = 0x00000000; | ||
91 | + cpu->isar.id_mmfr2 = 0x00000000; | ||
92 | + cpu->isar.id_mmfr3 = 0x00000000; | ||
93 | + cpu->isar.id_isar0 = 0x01141110; | ||
94 | + cpu->isar.id_isar1 = 0x02111000; | ||
95 | + cpu->isar.id_isar2 = 0x21112231; | ||
96 | + cpu->isar.id_isar3 = 0x01111110; | ||
97 | + cpu->isar.id_isar4 = 0x01310102; | ||
98 | + cpu->isar.id_isar5 = 0x00000000; | ||
99 | + cpu->isar.id_isar6 = 0x00000000; | ||
100 | +} | ||
101 | + | ||
102 | +static void cortex_m3_initfn(Object *obj) | ||
103 | +{ | ||
104 | + ARMCPU *cpu = ARM_CPU(obj); | ||
105 | + set_feature(&cpu->env, ARM_FEATURE_V7); | ||
106 | + set_feature(&cpu->env, ARM_FEATURE_M); | ||
107 | + set_feature(&cpu->env, ARM_FEATURE_M_MAIN); | ||
108 | + cpu->midr = 0x410fc231; | ||
109 | + cpu->pmsav7_dregion = 8; | ||
110 | + cpu->isar.id_pfr0 = 0x00000030; | ||
111 | + cpu->isar.id_pfr1 = 0x00000200; | ||
112 | + cpu->isar.id_dfr0 = 0x00100000; | ||
113 | + cpu->id_afr0 = 0x00000000; | ||
114 | + cpu->isar.id_mmfr0 = 0x00000030; | ||
115 | + cpu->isar.id_mmfr1 = 0x00000000; | ||
116 | + cpu->isar.id_mmfr2 = 0x00000000; | ||
117 | + cpu->isar.id_mmfr3 = 0x00000000; | ||
118 | + cpu->isar.id_isar0 = 0x01141110; | ||
119 | + cpu->isar.id_isar1 = 0x02111000; | ||
120 | + cpu->isar.id_isar2 = 0x21112231; | ||
121 | + cpu->isar.id_isar3 = 0x01111110; | ||
122 | + cpu->isar.id_isar4 = 0x01310102; | ||
123 | + cpu->isar.id_isar5 = 0x00000000; | ||
124 | + cpu->isar.id_isar6 = 0x00000000; | ||
125 | +} | ||
126 | + | ||
127 | +static void cortex_m4_initfn(Object *obj) | ||
128 | +{ | ||
129 | + ARMCPU *cpu = ARM_CPU(obj); | ||
130 | + | ||
131 | + set_feature(&cpu->env, ARM_FEATURE_V7); | ||
132 | + set_feature(&cpu->env, ARM_FEATURE_M); | ||
133 | + set_feature(&cpu->env, ARM_FEATURE_M_MAIN); | ||
134 | + set_feature(&cpu->env, ARM_FEATURE_THUMB_DSP); | ||
135 | + cpu->midr = 0x410fc240; /* r0p0 */ | ||
136 | + cpu->pmsav7_dregion = 8; | ||
137 | + cpu->isar.mvfr0 = 0x10110021; | ||
138 | + cpu->isar.mvfr1 = 0x11000011; | ||
139 | + cpu->isar.mvfr2 = 0x00000000; | ||
140 | + cpu->isar.id_pfr0 = 0x00000030; | ||
141 | + cpu->isar.id_pfr1 = 0x00000200; | ||
142 | + cpu->isar.id_dfr0 = 0x00100000; | ||
143 | + cpu->id_afr0 = 0x00000000; | ||
144 | + cpu->isar.id_mmfr0 = 0x00000030; | ||
145 | + cpu->isar.id_mmfr1 = 0x00000000; | ||
146 | + cpu->isar.id_mmfr2 = 0x00000000; | ||
147 | + cpu->isar.id_mmfr3 = 0x00000000; | ||
148 | + cpu->isar.id_isar0 = 0x01141110; | ||
149 | + cpu->isar.id_isar1 = 0x02111000; | ||
150 | + cpu->isar.id_isar2 = 0x21112231; | ||
151 | + cpu->isar.id_isar3 = 0x01111110; | ||
152 | + cpu->isar.id_isar4 = 0x01310102; | ||
153 | + cpu->isar.id_isar5 = 0x00000000; | ||
154 | + cpu->isar.id_isar6 = 0x00000000; | ||
155 | +} | ||
156 | + | ||
157 | +static void cortex_m7_initfn(Object *obj) | ||
158 | +{ | ||
159 | + ARMCPU *cpu = ARM_CPU(obj); | ||
160 | + | ||
161 | + set_feature(&cpu->env, ARM_FEATURE_V7); | ||
162 | + set_feature(&cpu->env, ARM_FEATURE_M); | ||
163 | + set_feature(&cpu->env, ARM_FEATURE_M_MAIN); | ||
164 | + set_feature(&cpu->env, ARM_FEATURE_THUMB_DSP); | ||
165 | + cpu->midr = 0x411fc272; /* r1p2 */ | ||
166 | + cpu->pmsav7_dregion = 8; | ||
167 | + cpu->isar.mvfr0 = 0x10110221; | ||
168 | + cpu->isar.mvfr1 = 0x12000011; | ||
169 | + cpu->isar.mvfr2 = 0x00000040; | ||
170 | + cpu->isar.id_pfr0 = 0x00000030; | ||
171 | + cpu->isar.id_pfr1 = 0x00000200; | ||
172 | + cpu->isar.id_dfr0 = 0x00100000; | ||
173 | + cpu->id_afr0 = 0x00000000; | ||
174 | + cpu->isar.id_mmfr0 = 0x00100030; | ||
175 | + cpu->isar.id_mmfr1 = 0x00000000; | ||
176 | + cpu->isar.id_mmfr2 = 0x01000000; | ||
177 | + cpu->isar.id_mmfr3 = 0x00000000; | ||
178 | + cpu->isar.id_isar0 = 0x01101110; | ||
179 | + cpu->isar.id_isar1 = 0x02112000; | ||
180 | + cpu->isar.id_isar2 = 0x20232231; | ||
181 | + cpu->isar.id_isar3 = 0x01111131; | ||
182 | + cpu->isar.id_isar4 = 0x01310132; | ||
183 | + cpu->isar.id_isar5 = 0x00000000; | ||
184 | + cpu->isar.id_isar6 = 0x00000000; | ||
185 | +} | ||
186 | + | ||
187 | +static void cortex_m33_initfn(Object *obj) | ||
188 | +{ | ||
189 | + ARMCPU *cpu = ARM_CPU(obj); | ||
190 | + | ||
191 | + set_feature(&cpu->env, ARM_FEATURE_V8); | ||
192 | + set_feature(&cpu->env, ARM_FEATURE_M); | ||
193 | + set_feature(&cpu->env, ARM_FEATURE_M_MAIN); | ||
194 | + set_feature(&cpu->env, ARM_FEATURE_M_SECURITY); | ||
195 | + set_feature(&cpu->env, ARM_FEATURE_THUMB_DSP); | ||
196 | + cpu->midr = 0x410fd213; /* r0p3 */ | ||
197 | + cpu->pmsav7_dregion = 16; | ||
198 | + cpu->sau_sregion = 8; | ||
199 | + cpu->isar.mvfr0 = 0x10110021; | ||
200 | + cpu->isar.mvfr1 = 0x11000011; | ||
201 | + cpu->isar.mvfr2 = 0x00000040; | ||
202 | + cpu->isar.id_pfr0 = 0x00000030; | ||
203 | + cpu->isar.id_pfr1 = 0x00000210; | ||
204 | + cpu->isar.id_dfr0 = 0x00200000; | ||
205 | + cpu->id_afr0 = 0x00000000; | ||
206 | + cpu->isar.id_mmfr0 = 0x00101F40; | ||
207 | + cpu->isar.id_mmfr1 = 0x00000000; | ||
208 | + cpu->isar.id_mmfr2 = 0x01000000; | ||
209 | + cpu->isar.id_mmfr3 = 0x00000000; | ||
210 | + cpu->isar.id_isar0 = 0x01101110; | ||
211 | + cpu->isar.id_isar1 = 0x02212000; | ||
212 | + cpu->isar.id_isar2 = 0x20232232; | ||
213 | + cpu->isar.id_isar3 = 0x01111131; | ||
214 | + cpu->isar.id_isar4 = 0x01310132; | ||
215 | + cpu->isar.id_isar5 = 0x00000000; | ||
216 | + cpu->isar.id_isar6 = 0x00000000; | ||
217 | + cpu->clidr = 0x00000000; | ||
218 | + cpu->ctr = 0x8000c000; | ||
219 | +} | ||
220 | + | ||
221 | +static void cortex_m55_initfn(Object *obj) | ||
222 | +{ | ||
223 | + ARMCPU *cpu = ARM_CPU(obj); | ||
224 | + | ||
225 | + set_feature(&cpu->env, ARM_FEATURE_V8); | ||
226 | + set_feature(&cpu->env, ARM_FEATURE_V8_1M); | ||
227 | + set_feature(&cpu->env, ARM_FEATURE_M); | ||
228 | + set_feature(&cpu->env, ARM_FEATURE_M_MAIN); | ||
229 | + set_feature(&cpu->env, ARM_FEATURE_M_SECURITY); | ||
230 | + set_feature(&cpu->env, ARM_FEATURE_THUMB_DSP); | ||
231 | + cpu->midr = 0x410fd221; /* r0p1 */ | ||
232 | + cpu->revidr = 0; | ||
233 | + cpu->pmsav7_dregion = 16; | ||
234 | + cpu->sau_sregion = 8; | ||
235 | + /* These are the MVFR* values for the FPU + full MVE configuration */ | ||
236 | + cpu->isar.mvfr0 = 0x10110221; | ||
237 | + cpu->isar.mvfr1 = 0x12100211; | ||
238 | + cpu->isar.mvfr2 = 0x00000040; | ||
239 | + cpu->isar.id_pfr0 = 0x20000030; | ||
240 | + cpu->isar.id_pfr1 = 0x00000230; | ||
241 | + cpu->isar.id_dfr0 = 0x10200000; | ||
242 | + cpu->id_afr0 = 0x00000000; | ||
243 | + cpu->isar.id_mmfr0 = 0x00111040; | ||
244 | + cpu->isar.id_mmfr1 = 0x00000000; | ||
245 | + cpu->isar.id_mmfr2 = 0x01000000; | ||
246 | + cpu->isar.id_mmfr3 = 0x00000011; | ||
247 | + cpu->isar.id_isar0 = 0x01103110; | ||
248 | + cpu->isar.id_isar1 = 0x02212000; | ||
249 | + cpu->isar.id_isar2 = 0x20232232; | ||
250 | + cpu->isar.id_isar3 = 0x01111131; | ||
251 | + cpu->isar.id_isar4 = 0x01310132; | ||
252 | + cpu->isar.id_isar5 = 0x00000000; | ||
253 | + cpu->isar.id_isar6 = 0x00000000; | ||
254 | + cpu->clidr = 0x00000000; /* caches not implemented */ | ||
255 | + cpu->ctr = 0x8303c003; | ||
256 | +} | ||
257 | + | ||
258 | +static const TCGCPUOps arm_v7m_tcg_ops = { | ||
259 | + .initialize = arm_translate_init, | ||
260 | + .synchronize_from_tb = arm_cpu_synchronize_from_tb, | ||
261 | + .debug_excp_handler = arm_debug_excp_handler, | ||
262 | + .restore_state_to_opc = arm_restore_state_to_opc, | ||
263 | + | ||
264 | +#ifdef CONFIG_USER_ONLY | ||
265 | + .record_sigsegv = arm_cpu_record_sigsegv, | ||
266 | + .record_sigbus = arm_cpu_record_sigbus, | ||
267 | +#else | ||
268 | + .tlb_fill = arm_cpu_tlb_fill, | ||
269 | + .cpu_exec_interrupt = arm_v7m_cpu_exec_interrupt, | ||
270 | + .do_interrupt = arm_v7m_cpu_do_interrupt, | ||
271 | + .do_transaction_failed = arm_cpu_do_transaction_failed, | ||
272 | + .do_unaligned_access = arm_cpu_do_unaligned_access, | ||
273 | + .adjust_watchpoint_address = arm_adjust_watchpoint_address, | ||
274 | + .debug_check_watchpoint = arm_debug_check_watchpoint, | ||
275 | + .debug_check_breakpoint = arm_debug_check_breakpoint, | ||
276 | +#endif /* !CONFIG_USER_ONLY */ | ||
277 | +}; | ||
278 | + | ||
279 | +static void arm_v7m_class_init(ObjectClass *oc, void *data) | ||
280 | +{ | ||
281 | + ARMCPUClass *acc = ARM_CPU_CLASS(oc); | ||
282 | + CPUClass *cc = CPU_CLASS(oc); | ||
283 | + | ||
284 | + acc->info = data; | ||
285 | + cc->tcg_ops = &arm_v7m_tcg_ops; | ||
286 | + cc->gdb_core_xml_file = "arm-m-profile.xml"; | ||
287 | +} | ||
288 | + | ||
289 | +static const ARMCPUInfo arm_v7m_cpus[] = { | ||
290 | + { .name = "cortex-m0", .initfn = cortex_m0_initfn, | ||
291 | + .class_init = arm_v7m_class_init }, | ||
292 | + { .name = "cortex-m3", .initfn = cortex_m3_initfn, | ||
293 | + .class_init = arm_v7m_class_init }, | ||
294 | + { .name = "cortex-m4", .initfn = cortex_m4_initfn, | ||
295 | + .class_init = arm_v7m_class_init }, | ||
296 | + { .name = "cortex-m7", .initfn = cortex_m7_initfn, | ||
297 | + .class_init = arm_v7m_class_init }, | ||
298 | + { .name = "cortex-m33", .initfn = cortex_m33_initfn, | ||
299 | + .class_init = arm_v7m_class_init }, | ||
300 | + { .name = "cortex-m55", .initfn = cortex_m55_initfn, | ||
301 | + .class_init = arm_v7m_class_init }, | ||
302 | +}; | ||
303 | + | ||
304 | +static void arm_v7m_cpu_register_types(void) | ||
305 | +{ | ||
306 | + size_t i; | ||
307 | + | ||
308 | + for (i = 0; i < ARRAY_SIZE(arm_v7m_cpus); ++i) { | ||
309 | + arm_cpu_register(&arm_v7m_cpus[i]); | ||
310 | + } | ||
311 | +} | ||
312 | + | ||
313 | +type_init(arm_v7m_cpu_register_types) | ||
314 | diff --git a/target/arm/tcg/cpu32.c b/target/arm/tcg/cpu32.c | ||
66 | index XXXXXXX..XXXXXXX 100644 | 315 | index XXXXXXX..XXXXXXX 100644 |
67 | --- a/hw/i2c/versatile_i2c.c | 316 | --- a/target/arm/tcg/cpu32.c |
68 | +++ b/hw/i2c/versatile_i2c.c | 317 | +++ b/target/arm/tcg/cpu32.c |
69 | @@ -XXX,XX +XXX,XX @@ | 318 | @@ -XXX,XX +XXX,XX @@ |
319 | #include "hw/boards.h" | ||
320 | #endif | ||
321 | #include "cpregs.h" | ||
322 | -#if !defined(CONFIG_USER_ONLY) && defined(CONFIG_TCG) | ||
323 | -#include "hw/intc/armv7m_nvic.h" | ||
324 | -#endif | ||
325 | |||
326 | |||
327 | /* Share AArch32 -cpu max features with AArch64. */ | ||
328 | @@ -XXX,XX +XXX,XX @@ void aa32_max_features(ARMCPU *cpu) | ||
329 | /* CPU models. These are not needed for the AArch64 linux-user build. */ | ||
330 | #if !defined(CONFIG_USER_ONLY) || !defined(TARGET_AARCH64) | ||
331 | |||
332 | -#if !defined(CONFIG_USER_ONLY) | ||
333 | -static bool arm_v7m_cpu_exec_interrupt(CPUState *cs, int interrupt_request) | ||
334 | -{ | ||
335 | - CPUClass *cc = CPU_GET_CLASS(cs); | ||
336 | - ARMCPU *cpu = ARM_CPU(cs); | ||
337 | - CPUARMState *env = &cpu->env; | ||
338 | - bool ret = false; | ||
339 | - | ||
340 | - /* | ||
341 | - * ARMv7-M interrupt masking works differently than -A or -R. | ||
342 | - * There is no FIQ/IRQ distinction. Instead of I and F bits | ||
343 | - * masking FIQ and IRQ interrupts, an exception is taken only | ||
344 | - * if it is higher priority than the current execution priority | ||
345 | - * (which depends on state like BASEPRI, FAULTMASK and the | ||
346 | - * currently active exception). | ||
347 | - */ | ||
348 | - if (interrupt_request & CPU_INTERRUPT_HARD | ||
349 | - && (armv7m_nvic_can_take_pending_exception(env->nvic))) { | ||
350 | - cs->exception_index = EXCP_IRQ; | ||
351 | - cc->tcg_ops->do_interrupt(cs); | ||
352 | - ret = true; | ||
353 | - } | ||
354 | - return ret; | ||
355 | -} | ||
356 | -#endif /* !CONFIG_USER_ONLY */ | ||
357 | - | ||
358 | static void arm926_initfn(Object *obj) | ||
359 | { | ||
360 | ARMCPU *cpu = ARM_CPU(obj); | ||
361 | @@ -XXX,XX +XXX,XX @@ static void cortex_a15_initfn(Object *obj) | ||
362 | define_arm_cp_regs(cpu, cortexa15_cp_reginfo); | ||
363 | } | ||
364 | |||
365 | -static void cortex_m0_initfn(Object *obj) | ||
366 | -{ | ||
367 | - ARMCPU *cpu = ARM_CPU(obj); | ||
368 | - set_feature(&cpu->env, ARM_FEATURE_V6); | ||
369 | - set_feature(&cpu->env, ARM_FEATURE_M); | ||
370 | - | ||
371 | - cpu->midr = 0x410cc200; | ||
372 | - | ||
373 | - /* | ||
374 | - * These ID register values are not guest visible, because | ||
375 | - * we do not implement the Main Extension. They must be set | ||
376 | - * to values corresponding to the Cortex-M0's implemented | ||
377 | - * features, because QEMU generally controls its emulation | ||
378 | - * by looking at ID register fields. We use the same values as | ||
379 | - * for the M3. | ||
380 | - */ | ||
381 | - cpu->isar.id_pfr0 = 0x00000030; | ||
382 | - cpu->isar.id_pfr1 = 0x00000200; | ||
383 | - cpu->isar.id_dfr0 = 0x00100000; | ||
384 | - cpu->id_afr0 = 0x00000000; | ||
385 | - cpu->isar.id_mmfr0 = 0x00000030; | ||
386 | - cpu->isar.id_mmfr1 = 0x00000000; | ||
387 | - cpu->isar.id_mmfr2 = 0x00000000; | ||
388 | - cpu->isar.id_mmfr3 = 0x00000000; | ||
389 | - cpu->isar.id_isar0 = 0x01141110; | ||
390 | - cpu->isar.id_isar1 = 0x02111000; | ||
391 | - cpu->isar.id_isar2 = 0x21112231; | ||
392 | - cpu->isar.id_isar3 = 0x01111110; | ||
393 | - cpu->isar.id_isar4 = 0x01310102; | ||
394 | - cpu->isar.id_isar5 = 0x00000000; | ||
395 | - cpu->isar.id_isar6 = 0x00000000; | ||
396 | -} | ||
397 | - | ||
398 | -static void cortex_m3_initfn(Object *obj) | ||
399 | -{ | ||
400 | - ARMCPU *cpu = ARM_CPU(obj); | ||
401 | - set_feature(&cpu->env, ARM_FEATURE_V7); | ||
402 | - set_feature(&cpu->env, ARM_FEATURE_M); | ||
403 | - set_feature(&cpu->env, ARM_FEATURE_M_MAIN); | ||
404 | - cpu->midr = 0x410fc231; | ||
405 | - cpu->pmsav7_dregion = 8; | ||
406 | - cpu->isar.id_pfr0 = 0x00000030; | ||
407 | - cpu->isar.id_pfr1 = 0x00000200; | ||
408 | - cpu->isar.id_dfr0 = 0x00100000; | ||
409 | - cpu->id_afr0 = 0x00000000; | ||
410 | - cpu->isar.id_mmfr0 = 0x00000030; | ||
411 | - cpu->isar.id_mmfr1 = 0x00000000; | ||
412 | - cpu->isar.id_mmfr2 = 0x00000000; | ||
413 | - cpu->isar.id_mmfr3 = 0x00000000; | ||
414 | - cpu->isar.id_isar0 = 0x01141110; | ||
415 | - cpu->isar.id_isar1 = 0x02111000; | ||
416 | - cpu->isar.id_isar2 = 0x21112231; | ||
417 | - cpu->isar.id_isar3 = 0x01111110; | ||
418 | - cpu->isar.id_isar4 = 0x01310102; | ||
419 | - cpu->isar.id_isar5 = 0x00000000; | ||
420 | - cpu->isar.id_isar6 = 0x00000000; | ||
421 | -} | ||
422 | - | ||
423 | -static void cortex_m4_initfn(Object *obj) | ||
424 | -{ | ||
425 | - ARMCPU *cpu = ARM_CPU(obj); | ||
426 | - | ||
427 | - set_feature(&cpu->env, ARM_FEATURE_V7); | ||
428 | - set_feature(&cpu->env, ARM_FEATURE_M); | ||
429 | - set_feature(&cpu->env, ARM_FEATURE_M_MAIN); | ||
430 | - set_feature(&cpu->env, ARM_FEATURE_THUMB_DSP); | ||
431 | - cpu->midr = 0x410fc240; /* r0p0 */ | ||
432 | - cpu->pmsav7_dregion = 8; | ||
433 | - cpu->isar.mvfr0 = 0x10110021; | ||
434 | - cpu->isar.mvfr1 = 0x11000011; | ||
435 | - cpu->isar.mvfr2 = 0x00000000; | ||
436 | - cpu->isar.id_pfr0 = 0x00000030; | ||
437 | - cpu->isar.id_pfr1 = 0x00000200; | ||
438 | - cpu->isar.id_dfr0 = 0x00100000; | ||
439 | - cpu->id_afr0 = 0x00000000; | ||
440 | - cpu->isar.id_mmfr0 = 0x00000030; | ||
441 | - cpu->isar.id_mmfr1 = 0x00000000; | ||
442 | - cpu->isar.id_mmfr2 = 0x00000000; | ||
443 | - cpu->isar.id_mmfr3 = 0x00000000; | ||
444 | - cpu->isar.id_isar0 = 0x01141110; | ||
445 | - cpu->isar.id_isar1 = 0x02111000; | ||
446 | - cpu->isar.id_isar2 = 0x21112231; | ||
447 | - cpu->isar.id_isar3 = 0x01111110; | ||
448 | - cpu->isar.id_isar4 = 0x01310102; | ||
449 | - cpu->isar.id_isar5 = 0x00000000; | ||
450 | - cpu->isar.id_isar6 = 0x00000000; | ||
451 | -} | ||
452 | - | ||
453 | -static void cortex_m7_initfn(Object *obj) | ||
454 | -{ | ||
455 | - ARMCPU *cpu = ARM_CPU(obj); | ||
456 | - | ||
457 | - set_feature(&cpu->env, ARM_FEATURE_V7); | ||
458 | - set_feature(&cpu->env, ARM_FEATURE_M); | ||
459 | - set_feature(&cpu->env, ARM_FEATURE_M_MAIN); | ||
460 | - set_feature(&cpu->env, ARM_FEATURE_THUMB_DSP); | ||
461 | - cpu->midr = 0x411fc272; /* r1p2 */ | ||
462 | - cpu->pmsav7_dregion = 8; | ||
463 | - cpu->isar.mvfr0 = 0x10110221; | ||
464 | - cpu->isar.mvfr1 = 0x12000011; | ||
465 | - cpu->isar.mvfr2 = 0x00000040; | ||
466 | - cpu->isar.id_pfr0 = 0x00000030; | ||
467 | - cpu->isar.id_pfr1 = 0x00000200; | ||
468 | - cpu->isar.id_dfr0 = 0x00100000; | ||
469 | - cpu->id_afr0 = 0x00000000; | ||
470 | - cpu->isar.id_mmfr0 = 0x00100030; | ||
471 | - cpu->isar.id_mmfr1 = 0x00000000; | ||
472 | - cpu->isar.id_mmfr2 = 0x01000000; | ||
473 | - cpu->isar.id_mmfr3 = 0x00000000; | ||
474 | - cpu->isar.id_isar0 = 0x01101110; | ||
475 | - cpu->isar.id_isar1 = 0x02112000; | ||
476 | - cpu->isar.id_isar2 = 0x20232231; | ||
477 | - cpu->isar.id_isar3 = 0x01111131; | ||
478 | - cpu->isar.id_isar4 = 0x01310132; | ||
479 | - cpu->isar.id_isar5 = 0x00000000; | ||
480 | - cpu->isar.id_isar6 = 0x00000000; | ||
481 | -} | ||
482 | - | ||
483 | -static void cortex_m33_initfn(Object *obj) | ||
484 | -{ | ||
485 | - ARMCPU *cpu = ARM_CPU(obj); | ||
486 | - | ||
487 | - set_feature(&cpu->env, ARM_FEATURE_V8); | ||
488 | - set_feature(&cpu->env, ARM_FEATURE_M); | ||
489 | - set_feature(&cpu->env, ARM_FEATURE_M_MAIN); | ||
490 | - set_feature(&cpu->env, ARM_FEATURE_M_SECURITY); | ||
491 | - set_feature(&cpu->env, ARM_FEATURE_THUMB_DSP); | ||
492 | - cpu->midr = 0x410fd213; /* r0p3 */ | ||
493 | - cpu->pmsav7_dregion = 16; | ||
494 | - cpu->sau_sregion = 8; | ||
495 | - cpu->isar.mvfr0 = 0x10110021; | ||
496 | - cpu->isar.mvfr1 = 0x11000011; | ||
497 | - cpu->isar.mvfr2 = 0x00000040; | ||
498 | - cpu->isar.id_pfr0 = 0x00000030; | ||
499 | - cpu->isar.id_pfr1 = 0x00000210; | ||
500 | - cpu->isar.id_dfr0 = 0x00200000; | ||
501 | - cpu->id_afr0 = 0x00000000; | ||
502 | - cpu->isar.id_mmfr0 = 0x00101F40; | ||
503 | - cpu->isar.id_mmfr1 = 0x00000000; | ||
504 | - cpu->isar.id_mmfr2 = 0x01000000; | ||
505 | - cpu->isar.id_mmfr3 = 0x00000000; | ||
506 | - cpu->isar.id_isar0 = 0x01101110; | ||
507 | - cpu->isar.id_isar1 = 0x02212000; | ||
508 | - cpu->isar.id_isar2 = 0x20232232; | ||
509 | - cpu->isar.id_isar3 = 0x01111131; | ||
510 | - cpu->isar.id_isar4 = 0x01310132; | ||
511 | - cpu->isar.id_isar5 = 0x00000000; | ||
512 | - cpu->isar.id_isar6 = 0x00000000; | ||
513 | - cpu->clidr = 0x00000000; | ||
514 | - cpu->ctr = 0x8000c000; | ||
515 | -} | ||
516 | - | ||
517 | -static void cortex_m55_initfn(Object *obj) | ||
518 | -{ | ||
519 | - ARMCPU *cpu = ARM_CPU(obj); | ||
520 | - | ||
521 | - set_feature(&cpu->env, ARM_FEATURE_V8); | ||
522 | - set_feature(&cpu->env, ARM_FEATURE_V8_1M); | ||
523 | - set_feature(&cpu->env, ARM_FEATURE_M); | ||
524 | - set_feature(&cpu->env, ARM_FEATURE_M_MAIN); | ||
525 | - set_feature(&cpu->env, ARM_FEATURE_M_SECURITY); | ||
526 | - set_feature(&cpu->env, ARM_FEATURE_THUMB_DSP); | ||
527 | - cpu->midr = 0x410fd221; /* r0p1 */ | ||
528 | - cpu->revidr = 0; | ||
529 | - cpu->pmsav7_dregion = 16; | ||
530 | - cpu->sau_sregion = 8; | ||
531 | - /* These are the MVFR* values for the FPU + full MVE configuration */ | ||
532 | - cpu->isar.mvfr0 = 0x10110221; | ||
533 | - cpu->isar.mvfr1 = 0x12100211; | ||
534 | - cpu->isar.mvfr2 = 0x00000040; | ||
535 | - cpu->isar.id_pfr0 = 0x20000030; | ||
536 | - cpu->isar.id_pfr1 = 0x00000230; | ||
537 | - cpu->isar.id_dfr0 = 0x10200000; | ||
538 | - cpu->id_afr0 = 0x00000000; | ||
539 | - cpu->isar.id_mmfr0 = 0x00111040; | ||
540 | - cpu->isar.id_mmfr1 = 0x00000000; | ||
541 | - cpu->isar.id_mmfr2 = 0x01000000; | ||
542 | - cpu->isar.id_mmfr3 = 0x00000011; | ||
543 | - cpu->isar.id_isar0 = 0x01103110; | ||
544 | - cpu->isar.id_isar1 = 0x02212000; | ||
545 | - cpu->isar.id_isar2 = 0x20232232; | ||
546 | - cpu->isar.id_isar3 = 0x01111131; | ||
547 | - cpu->isar.id_isar4 = 0x01310132; | ||
548 | - cpu->isar.id_isar5 = 0x00000000; | ||
549 | - cpu->isar.id_isar6 = 0x00000000; | ||
550 | - cpu->clidr = 0x00000000; /* caches not implemented */ | ||
551 | - cpu->ctr = 0x8303c003; | ||
552 | -} | ||
553 | - | ||
554 | static const ARMCPRegInfo cortexr5_cp_reginfo[] = { | ||
555 | /* Dummy the TCM region regs for the moment */ | ||
556 | { .name = "ATCM", .cp = 15, .opc1 = 0, .crn = 9, .crm = 1, .opc2 = 0, | ||
557 | @@ -XXX,XX +XXX,XX @@ static void pxa270c5_initfn(Object *obj) | ||
558 | cpu->reset_sctlr = 0x00000078; | ||
559 | } | ||
560 | |||
561 | -static const TCGCPUOps arm_v7m_tcg_ops = { | ||
562 | - .initialize = arm_translate_init, | ||
563 | - .synchronize_from_tb = arm_cpu_synchronize_from_tb, | ||
564 | - .debug_excp_handler = arm_debug_excp_handler, | ||
565 | - .restore_state_to_opc = arm_restore_state_to_opc, | ||
566 | - | ||
567 | -#ifdef CONFIG_USER_ONLY | ||
568 | - .record_sigsegv = arm_cpu_record_sigsegv, | ||
569 | - .record_sigbus = arm_cpu_record_sigbus, | ||
570 | -#else | ||
571 | - .tlb_fill = arm_cpu_tlb_fill, | ||
572 | - .cpu_exec_interrupt = arm_v7m_cpu_exec_interrupt, | ||
573 | - .do_interrupt = arm_v7m_cpu_do_interrupt, | ||
574 | - .do_transaction_failed = arm_cpu_do_transaction_failed, | ||
575 | - .do_unaligned_access = arm_cpu_do_unaligned_access, | ||
576 | - .adjust_watchpoint_address = arm_adjust_watchpoint_address, | ||
577 | - .debug_check_watchpoint = arm_debug_check_watchpoint, | ||
578 | - .debug_check_breakpoint = arm_debug_check_breakpoint, | ||
579 | -#endif /* !CONFIG_USER_ONLY */ | ||
580 | -}; | ||
581 | - | ||
582 | -static void arm_v7m_class_init(ObjectClass *oc, void *data) | ||
583 | -{ | ||
584 | - ARMCPUClass *acc = ARM_CPU_CLASS(oc); | ||
585 | - CPUClass *cc = CPU_CLASS(oc); | ||
586 | - | ||
587 | - acc->info = data; | ||
588 | - cc->tcg_ops = &arm_v7m_tcg_ops; | ||
589 | - cc->gdb_core_xml_file = "arm-m-profile.xml"; | ||
590 | -} | ||
591 | - | ||
592 | #ifndef TARGET_AARCH64 | ||
70 | /* | 593 | /* |
71 | - * ARM Versatile I2C controller | 594 | * -cpu max: a CPU with as many features enabled as our emulation supports. |
72 | + * ARM SBCon two-wire serial bus interface (I2C bitbang) | 595 | @@ -XXX,XX +XXX,XX @@ static const ARMCPUInfo arm_tcg_cpus[] = { |
73 | + * a.k.a. ARM Versatile I2C controller | 596 | { .name = "cortex-a8", .initfn = cortex_a8_initfn }, |
74 | * | 597 | { .name = "cortex-a9", .initfn = cortex_a9_initfn }, |
75 | * Copyright (c) 2006-2007 CodeSourcery. | 598 | { .name = "cortex-a15", .initfn = cortex_a15_initfn }, |
76 | * Copyright (c) 2012 Oskar Andero <oskar.andero@gmail.com> | 599 | - { .name = "cortex-m0", .initfn = cortex_m0_initfn, |
77 | @@ -XXX,XX +XXX,XX @@ | 600 | - .class_init = arm_v7m_class_init }, |
78 | */ | 601 | - { .name = "cortex-m3", .initfn = cortex_m3_initfn, |
79 | 602 | - .class_init = arm_v7m_class_init }, | |
80 | #include "qemu/osdep.h" | 603 | - { .name = "cortex-m4", .initfn = cortex_m4_initfn, |
81 | -#include "hw/sysbus.h" | 604 | - .class_init = arm_v7m_class_init }, |
82 | -#include "hw/i2c/bitbang_i2c.h" | 605 | - { .name = "cortex-m7", .initfn = cortex_m7_initfn, |
83 | +#include "hw/i2c/arm_sbcon_i2c.h" | 606 | - .class_init = arm_v7m_class_init }, |
84 | #include "hw/registerfields.h" | 607 | - { .name = "cortex-m33", .initfn = cortex_m33_initfn, |
85 | #include "qemu/log.h" | 608 | - .class_init = arm_v7m_class_init }, |
86 | #include "qemu/module.h" | 609 | - { .name = "cortex-m55", .initfn = cortex_m55_initfn, |
87 | 610 | - .class_init = arm_v7m_class_init }, | |
88 | -#define TYPE_VERSATILE_I2C "versatile_i2c" | 611 | { .name = "cortex-r5", .initfn = cortex_r5_initfn }, |
89 | #define VERSATILE_I2C(obj) \ | 612 | { .name = "cortex-r5f", .initfn = cortex_r5f_initfn }, |
90 | OBJECT_CHECK(VersatileI2CState, (obj), TYPE_VERSATILE_I2C) | 613 | { .name = "cortex-r52", .initfn = cortex_r52_initfn }, |
91 | 614 | diff --git a/target/arm/meson.build b/target/arm/meson.build | |
92 | -typedef struct VersatileI2CState { | ||
93 | - SysBusDevice parent_obj; | ||
94 | +typedef ArmSbconI2CState VersatileI2CState; | ||
95 | |||
96 | - MemoryRegion iomem; | ||
97 | - bitbang_i2c_interface bitbang; | ||
98 | - int out; | ||
99 | - int in; | ||
100 | -} VersatileI2CState; | ||
101 | |||
102 | REG32(CONTROL_GET, 0) | ||
103 | REG32(CONTROL_SET, 0) | ||
104 | @@ -XXX,XX +XXX,XX @@ static void versatile_i2c_init(Object *obj) | ||
105 | bus = i2c_init_bus(dev, "i2c"); | ||
106 | bitbang_i2c_init(&s->bitbang, bus); | ||
107 | memory_region_init_io(&s->iomem, obj, &versatile_i2c_ops, s, | ||
108 | - "versatile_i2c", 0x1000); | ||
109 | + "arm_sbcon_i2c", 0x1000); | ||
110 | sysbus_init_mmio(sbd, &s->iomem); | ||
111 | } | ||
112 | |||
113 | diff --git a/MAINTAINERS b/MAINTAINERS | ||
114 | index XXXXXXX..XXXXXXX 100644 | 615 | index XXXXXXX..XXXXXXX 100644 |
115 | --- a/MAINTAINERS | 616 | --- a/target/arm/meson.build |
116 | +++ b/MAINTAINERS | 617 | +++ b/target/arm/meson.build |
117 | @@ -XXX,XX +XXX,XX @@ M: Peter Maydell <peter.maydell@linaro.org> | 618 | @@ -XXX,XX +XXX,XX @@ arm_system_ss.add(files( |
118 | L: qemu-arm@nongnu.org | 619 | 'ptw.c', |
119 | S: Maintained | 620 | )) |
120 | F: hw/*/versatile* | 621 | |
121 | +F: include/hw/i2c/arm_sbcon_i2c.h | 622 | +arm_user_ss = ss.source_set() |
122 | F: hw/misc/arm_sysctl.c | 623 | + |
123 | F: docs/system/arm/versatile.rst | 624 | subdir('hvf') |
124 | 625 | ||
626 | if 'CONFIG_TCG' in config_all_accel | ||
627 | @@ -XXX,XX +XXX,XX @@ endif | ||
628 | |||
629 | target_arch += {'arm': arm_ss} | ||
630 | target_system_arch += {'arm': arm_system_ss} | ||
631 | +target_user_arch += {'arm': arm_user_ss} | ||
632 | diff --git a/target/arm/tcg/meson.build b/target/arm/tcg/meson.build | ||
633 | index XXXXXXX..XXXXXXX 100644 | ||
634 | --- a/target/arm/tcg/meson.build | ||
635 | +++ b/target/arm/tcg/meson.build | ||
636 | @@ -XXX,XX +XXX,XX @@ arm_ss.add(when: 'TARGET_AARCH64', if_true: files( | ||
637 | arm_system_ss.add(files( | ||
638 | 'psci.c', | ||
639 | )) | ||
640 | + | ||
641 | +arm_system_ss.add(when: 'CONFIG_ARM_V7M', if_true: files('cpu-v7m.c')) | ||
642 | +arm_user_ss.add(when: 'TARGET_AARCH64', if_false: files('cpu-v7m.c')) | ||
125 | -- | 643 | -- |
126 | 2.20.1 | 644 | 2.34.1 |
127 | |||
128 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
2 | 1 | ||
3 | By using the TYPE_* definitions for devices, we can: | ||
4 | - quickly find where devices are used with 'git-grep' | ||
5 | - easily rename a device (one-line change). | ||
6 | |||
7 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
8 | Message-id: 20200617072539.32686-6-f4bug@amsat.org | ||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | hw/arm/realview.c | 3 ++- | ||
13 | hw/arm/versatilepb.c | 3 ++- | ||
14 | hw/arm/vexpress.c | 3 ++- | ||
15 | 3 files changed, 6 insertions(+), 3 deletions(-) | ||
16 | |||
17 | diff --git a/hw/arm/realview.c b/hw/arm/realview.c | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/hw/arm/realview.c | ||
20 | +++ b/hw/arm/realview.c | ||
21 | @@ -XXX,XX +XXX,XX @@ | ||
22 | #include "hw/cpu/a9mpcore.h" | ||
23 | #include "hw/intc/realview_gic.h" | ||
24 | #include "hw/irq.h" | ||
25 | +#include "hw/i2c/arm_sbcon_i2c.h" | ||
26 | |||
27 | #define SMP_BOOT_ADDR 0xe0000000 | ||
28 | #define SMP_BOOTREG_ADDR 0x10000030 | ||
29 | @@ -XXX,XX +XXX,XX @@ static void realview_init(MachineState *machine, | ||
30 | } | ||
31 | } | ||
32 | |||
33 | - dev = sysbus_create_simple("versatile_i2c", 0x10002000, NULL); | ||
34 | + dev = sysbus_create_simple(TYPE_VERSATILE_I2C, 0x10002000, NULL); | ||
35 | i2c = (I2CBus *)qdev_get_child_bus(dev, "i2c"); | ||
36 | i2c_create_slave(i2c, "ds1338", 0x68); | ||
37 | |||
38 | diff --git a/hw/arm/versatilepb.c b/hw/arm/versatilepb.c | ||
39 | index XXXXXXX..XXXXXXX 100644 | ||
40 | --- a/hw/arm/versatilepb.c | ||
41 | +++ b/hw/arm/versatilepb.c | ||
42 | @@ -XXX,XX +XXX,XX @@ | ||
43 | #include "sysemu/sysemu.h" | ||
44 | #include "hw/pci/pci.h" | ||
45 | #include "hw/i2c/i2c.h" | ||
46 | +#include "hw/i2c/arm_sbcon_i2c.h" | ||
47 | #include "hw/irq.h" | ||
48 | #include "hw/boards.h" | ||
49 | #include "exec/address-spaces.h" | ||
50 | @@ -XXX,XX +XXX,XX @@ static void versatile_init(MachineState *machine, int board_id) | ||
51 | /* Add PL031 Real Time Clock. */ | ||
52 | sysbus_create_simple("pl031", 0x101e8000, pic[10]); | ||
53 | |||
54 | - dev = sysbus_create_simple("versatile_i2c", 0x10002000, NULL); | ||
55 | + dev = sysbus_create_simple(TYPE_VERSATILE_I2C, 0x10002000, NULL); | ||
56 | i2c = (I2CBus *)qdev_get_child_bus(dev, "i2c"); | ||
57 | i2c_create_slave(i2c, "ds1338", 0x68); | ||
58 | |||
59 | diff --git a/hw/arm/vexpress.c b/hw/arm/vexpress.c | ||
60 | index XXXXXXX..XXXXXXX 100644 | ||
61 | --- a/hw/arm/vexpress.c | ||
62 | +++ b/hw/arm/vexpress.c | ||
63 | @@ -XXX,XX +XXX,XX @@ | ||
64 | #include "hw/char/pl011.h" | ||
65 | #include "hw/cpu/a9mpcore.h" | ||
66 | #include "hw/cpu/a15mpcore.h" | ||
67 | +#include "hw/i2c/arm_sbcon_i2c.h" | ||
68 | |||
69 | #define VEXPRESS_BOARD_ID 0x8e0 | ||
70 | #define VEXPRESS_FLASH_SIZE (64 * 1024 * 1024) | ||
71 | @@ -XXX,XX +XXX,XX @@ static void vexpress_common_init(MachineState *machine) | ||
72 | sysbus_create_simple("sp804", map[VE_TIMER01], pic[2]); | ||
73 | sysbus_create_simple("sp804", map[VE_TIMER23], pic[3]); | ||
74 | |||
75 | - dev = sysbus_create_simple("versatile_i2c", map[VE_SERIALDVI], NULL); | ||
76 | + dev = sysbus_create_simple(TYPE_VERSATILE_I2C, map[VE_SERIALDVI], NULL); | ||
77 | i2c = (I2CBus *)qdev_get_child_bus(dev, "i2c"); | ||
78 | i2c_create_slave(i2c, "sii9022", 0x39); | ||
79 | |||
80 | -- | ||
81 | 2.20.1 | ||
82 | |||
83 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
2 | 1 | ||
3 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
4 | Message-id: 20200617072539.32686-7-f4bug@amsat.org | ||
5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | --- | ||
8 | hw/arm/mps2.c | 5 ++++- | ||
9 | 1 file changed, 4 insertions(+), 1 deletion(-) | ||
10 | |||
11 | diff --git a/hw/arm/mps2.c b/hw/arm/mps2.c | ||
12 | index XXXXXXX..XXXXXXX 100644 | ||
13 | --- a/hw/arm/mps2.c | ||
14 | +++ b/hw/arm/mps2.c | ||
15 | @@ -XXX,XX +XXX,XX @@ typedef struct { | ||
16 | MemoryRegion blockram_m2; | ||
17 | MemoryRegion blockram_m3; | ||
18 | MemoryRegion sram; | ||
19 | + /* FPGA APB subsystem */ | ||
20 | MPS2SCC scc; | ||
21 | + /* CMSDK APB subsystem */ | ||
22 | CMSDKAPBDualTimer dualtimer; | ||
23 | } MPS2MachineState; | ||
24 | |||
25 | @@ -XXX,XX +XXX,XX @@ static void mps2_common_init(MachineState *machine) | ||
26 | g_assert_not_reached(); | ||
27 | } | ||
28 | |||
29 | + /* CMSDK APB subsystem */ | ||
30 | cmsdk_apb_timer_create(0x40000000, qdev_get_gpio_in(armv7m, 8), SYSCLK_FRQ); | ||
31 | cmsdk_apb_timer_create(0x40001000, qdev_get_gpio_in(armv7m, 9), SYSCLK_FRQ); | ||
32 | - | ||
33 | object_initialize_child(OBJECT(mms), "dualtimer", &mms->dualtimer, | ||
34 | TYPE_CMSDK_APB_DUALTIMER); | ||
35 | qdev_prop_set_uint32(DEVICE(&mms->dualtimer), "pclk-frq", SYSCLK_FRQ); | ||
36 | @@ -XXX,XX +XXX,XX @@ static void mps2_common_init(MachineState *machine) | ||
37 | qdev_get_gpio_in(armv7m, 10)); | ||
38 | sysbus_mmio_map(SYS_BUS_DEVICE(&mms->dualtimer), 0, 0x40002000); | ||
39 | |||
40 | + /* FPGA APB subsystem */ | ||
41 | object_initialize_child(OBJECT(mms), "scc", &mms->scc, TYPE_MPS2_SCC); | ||
42 | sccdev = DEVICE(&mms->scc); | ||
43 | qdev_prop_set_uint32(sccdev, "scc-cfg4", 0x2); | ||
44 | -- | ||
45 | 2.20.1 | ||
46 | |||
47 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
2 | 1 | ||
3 | We already model the CMSDK APB watchdog device, let's use it! | ||
4 | |||
5 | Suggested-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
7 | Message-id: 20200617072539.32686-9-f4bug@amsat.org | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | hw/arm/mps2.c | 7 +++++++ | ||
12 | hw/arm/Kconfig | 1 + | ||
13 | 2 files changed, 8 insertions(+) | ||
14 | |||
15 | diff --git a/hw/arm/mps2.c b/hw/arm/mps2.c | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/hw/arm/mps2.c | ||
18 | +++ b/hw/arm/mps2.c | ||
19 | @@ -XXX,XX +XXX,XX @@ static void mps2_common_init(MachineState *machine) | ||
20 | sysbus_connect_irq(SYS_BUS_DEVICE(&mms->dualtimer), 0, | ||
21 | qdev_get_gpio_in(armv7m, 10)); | ||
22 | sysbus_mmio_map(SYS_BUS_DEVICE(&mms->dualtimer), 0, 0x40002000); | ||
23 | + object_initialize_child(OBJECT(mms), "watchdog", &mms->watchdog, | ||
24 | + TYPE_CMSDK_APB_WATCHDOG); | ||
25 | + qdev_prop_set_uint32(DEVICE(&mms->watchdog), "wdogclk-frq", SYSCLK_FRQ); | ||
26 | + sysbus_realize(SYS_BUS_DEVICE(&mms->watchdog), &error_fatal); | ||
27 | + sysbus_connect_irq(SYS_BUS_DEVICE(&mms->watchdog), 0, | ||
28 | + qdev_get_gpio_in_named(armv7m, "NMI", 0)); | ||
29 | + sysbus_mmio_map(SYS_BUS_DEVICE(&mms->watchdog), 0, 0x40008000); | ||
30 | |||
31 | /* FPGA APB subsystem */ | ||
32 | object_initialize_child(OBJECT(mms), "scc", &mms->scc, TYPE_MPS2_SCC); | ||
33 | diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig | ||
34 | index XXXXXXX..XXXXXXX 100644 | ||
35 | --- a/hw/arm/Kconfig | ||
36 | +++ b/hw/arm/Kconfig | ||
37 | @@ -XXX,XX +XXX,XX @@ config MPS2 | ||
38 | select PL080 # DMA controller | ||
39 | select SPLIT_IRQ | ||
40 | select UNIMP | ||
41 | + select CMSDK_APB_WATCHDOG | ||
42 | |||
43 | config FSL_IMX7 | ||
44 | bool | ||
45 | -- | ||
46 | 2.20.1 | ||
47 | |||
48 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
2 | 1 | ||
3 | Register the GPIO peripherals as unimplemented to better | ||
4 | follow their accesses, for example booting Zephyr: | ||
5 | |||
6 | ---------------- | ||
7 | IN: arm_mps2_pinmux_init | ||
8 | 0x00001160: f64f 0231 movw r2, #0xf831 | ||
9 | 0x00001164: 4b06 ldr r3, [pc, #0x18] | ||
10 | 0x00001166: 2000 movs r0, #0 | ||
11 | 0x00001168: 619a str r2, [r3, #0x18] | ||
12 | 0x0000116a: f24c 426f movw r2, #0xc46f | ||
13 | 0x0000116e: f503 5380 add.w r3, r3, #0x1000 | ||
14 | 0x00001172: 619a str r2, [r3, #0x18] | ||
15 | 0x00001174: f44f 529e mov.w r2, #0x13c0 | ||
16 | 0x00001178: f503 5380 add.w r3, r3, #0x1000 | ||
17 | 0x0000117c: 619a str r2, [r3, #0x18] | ||
18 | 0x0000117e: 4770 bx lr | ||
19 | cmsdk-ahb-gpio: unimplemented device write (size 4, value 0xf831, offset 0x18) | ||
20 | cmsdk-ahb-gpio: unimplemented device write (size 4, value 0xc46f, offset 0x18) | ||
21 | cmsdk-ahb-gpio: unimplemented device write (size 4, value 0x13c0, offset 0x18) | ||
22 | |||
23 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
24 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
25 | Message-id: 20200617072539.32686-10-f4bug@amsat.org | ||
26 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
27 | --- | ||
28 | hw/arm/mps2.c | 8 ++++++-- | ||
29 | 1 file changed, 6 insertions(+), 2 deletions(-) | ||
30 | |||
31 | diff --git a/hw/arm/mps2.c b/hw/arm/mps2.c | ||
32 | index XXXXXXX..XXXXXXX 100644 | ||
33 | --- a/hw/arm/mps2.c | ||
34 | +++ b/hw/arm/mps2.c | ||
35 | @@ -XXX,XX +XXX,XX @@ static void mps2_common_init(MachineState *machine) | ||
36 | MemoryRegion *system_memory = get_system_memory(); | ||
37 | MachineClass *mc = MACHINE_GET_CLASS(machine); | ||
38 | DeviceState *armv7m, *sccdev; | ||
39 | + int i; | ||
40 | |||
41 | if (strcmp(machine->cpu_type, mc->default_cpu_type) != 0) { | ||
42 | error_report("This board can only be used with CPU %s", | ||
43 | @@ -XXX,XX +XXX,XX @@ static void mps2_common_init(MachineState *machine) | ||
44 | */ | ||
45 | Object *orgate; | ||
46 | DeviceState *orgate_dev; | ||
47 | - int i; | ||
48 | |||
49 | orgate = object_new(TYPE_OR_IRQ); | ||
50 | object_property_set_int(orgate, 6, "num-lines", &error_fatal); | ||
51 | @@ -XXX,XX +XXX,XX @@ static void mps2_common_init(MachineState *machine) | ||
52 | */ | ||
53 | Object *orgate; | ||
54 | DeviceState *orgate_dev; | ||
55 | - int i; | ||
56 | |||
57 | orgate = object_new(TYPE_OR_IRQ); | ||
58 | object_property_set_int(orgate, 10, "num-lines", &error_fatal); | ||
59 | @@ -XXX,XX +XXX,XX @@ static void mps2_common_init(MachineState *machine) | ||
60 | default: | ||
61 | g_assert_not_reached(); | ||
62 | } | ||
63 | + for (i = 0; i < 4; i++) { | ||
64 | + static const hwaddr gpiobase[] = {0x40010000, 0x40011000, | ||
65 | + 0x40012000, 0x40013000}; | ||
66 | + create_unimplemented_device("cmsdk-ahb-gpio", gpiobase[i], 0x1000); | ||
67 | + } | ||
68 | |||
69 | /* CMSDK APB subsystem */ | ||
70 | cmsdk_apb_timer_create(0x40000000, qdev_get_gpio_in(armv7m, 8), SYSCLK_FRQ); | ||
71 | -- | ||
72 | 2.20.1 | ||
73 | |||
74 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
2 | 1 | ||
3 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
4 | Message-id: 20200617072539.32686-11-f4bug@amsat.org | ||
5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | --- | ||
8 | hw/arm/mps2.c | 9 +++++++++ | ||
9 | 1 file changed, 9 insertions(+) | ||
10 | |||
11 | diff --git a/hw/arm/mps2.c b/hw/arm/mps2.c | ||
12 | index XXXXXXX..XXXXXXX 100644 | ||
13 | --- a/hw/arm/mps2.c | ||
14 | +++ b/hw/arm/mps2.c | ||
15 | @@ -XXX,XX +XXX,XX @@ | ||
16 | #include "hw/timer/cmsdk-apb-timer.h" | ||
17 | #include "hw/timer/cmsdk-apb-dualtimer.h" | ||
18 | #include "hw/misc/mps2-scc.h" | ||
19 | +#include "hw/misc/mps2-fpgaio.h" | ||
20 | #include "hw/net/lan9118.h" | ||
21 | #include "net/net.h" | ||
22 | +#include "hw/watchdog/cmsdk-apb-watchdog.h" | ||
23 | |||
24 | typedef enum MPS2FPGAType { | ||
25 | FPGA_AN385, | ||
26 | @@ -XXX,XX +XXX,XX @@ typedef struct { | ||
27 | MemoryRegion sram; | ||
28 | /* FPGA APB subsystem */ | ||
29 | MPS2SCC scc; | ||
30 | + MPS2FPGAIO fpgaio; | ||
31 | /* CMSDK APB subsystem */ | ||
32 | CMSDKAPBDualTimer dualtimer; | ||
33 | + CMSDKAPBWatchdog watchdog; | ||
34 | } MPS2MachineState; | ||
35 | |||
36 | #define TYPE_MPS2_MACHINE "mps2" | ||
37 | @@ -XXX,XX +XXX,XX @@ static void mps2_common_init(MachineState *machine) | ||
38 | qdev_prop_set_uint32(sccdev, "scc-id", mmc->scc_id); | ||
39 | sysbus_realize(SYS_BUS_DEVICE(&mms->scc), &error_fatal); | ||
40 | sysbus_mmio_map(SYS_BUS_DEVICE(sccdev), 0, 0x4002f000); | ||
41 | + object_initialize_child(OBJECT(mms), "fpgaio", | ||
42 | + &mms->fpgaio, TYPE_MPS2_FPGAIO); | ||
43 | + qdev_prop_set_uint32(DEVICE(&mms->fpgaio), "prescale-clk", 25000000); | ||
44 | + sysbus_realize(SYS_BUS_DEVICE(&mms->fpgaio), &error_fatal); | ||
45 | + sysbus_mmio_map(SYS_BUS_DEVICE(&mms->fpgaio), 0, 0x40028000); | ||
46 | |||
47 | /* In hardware this is a LAN9220; the LAN9118 is software compatible | ||
48 | * except that it doesn't support the checksum-offload feature. | ||
49 | -- | ||
50 | 2.20.1 | ||
51 | |||
52 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
2 | 1 | ||
3 | From 'Application Note AN385', chapter 3.9, SPI: | ||
4 | |||
5 | The SMM implements five PL022 SPI modules. | ||
6 | |||
7 | Two pairs of modules share the same OR-gated IRQ. | ||
8 | |||
9 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
10 | Message-id: 20200617072539.32686-12-f4bug@amsat.org | ||
11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | --- | ||
14 | hw/arm/mps2.c | 24 ++++++++++++++++++++++++ | ||
15 | hw/arm/Kconfig | 6 +++--- | ||
16 | 2 files changed, 27 insertions(+), 3 deletions(-) | ||
17 | |||
18 | diff --git a/hw/arm/mps2.c b/hw/arm/mps2.c | ||
19 | index XXXXXXX..XXXXXXX 100644 | ||
20 | --- a/hw/arm/mps2.c | ||
21 | +++ b/hw/arm/mps2.c | ||
22 | @@ -XXX,XX +XXX,XX @@ | ||
23 | #include "hw/timer/cmsdk-apb-dualtimer.h" | ||
24 | #include "hw/misc/mps2-scc.h" | ||
25 | #include "hw/misc/mps2-fpgaio.h" | ||
26 | +#include "hw/ssi/pl022.h" | ||
27 | #include "hw/net/lan9118.h" | ||
28 | #include "net/net.h" | ||
29 | #include "hw/watchdog/cmsdk-apb-watchdog.h" | ||
30 | @@ -XXX,XX +XXX,XX @@ static void mps2_common_init(MachineState *machine) | ||
31 | qdev_prop_set_uint32(DEVICE(&mms->fpgaio), "prescale-clk", 25000000); | ||
32 | sysbus_realize(SYS_BUS_DEVICE(&mms->fpgaio), &error_fatal); | ||
33 | sysbus_mmio_map(SYS_BUS_DEVICE(&mms->fpgaio), 0, 0x40028000); | ||
34 | + sysbus_create_simple(TYPE_PL022, 0x40025000, /* External ADC */ | ||
35 | + qdev_get_gpio_in(armv7m, 22)); | ||
36 | + for (i = 0; i < 2; i++) { | ||
37 | + static const int spi_irqno[] = {11, 24}; | ||
38 | + static const hwaddr spibase[] = {0x40020000, /* APB */ | ||
39 | + 0x40021000, /* LCD */ | ||
40 | + 0x40026000, /* Shield0 */ | ||
41 | + 0x40027000}; /* Shield1 */ | ||
42 | + DeviceState *orgate_dev; | ||
43 | + Object *orgate; | ||
44 | + int j; | ||
45 | + | ||
46 | + orgate = object_new(TYPE_OR_IRQ); | ||
47 | + object_property_set_int(orgate, 2, "num-lines", &error_fatal); | ||
48 | + orgate_dev = DEVICE(orgate); | ||
49 | + qdev_realize(orgate_dev, NULL, &error_fatal); | ||
50 | + qdev_connect_gpio_out(orgate_dev, 0, | ||
51 | + qdev_get_gpio_in(armv7m, spi_irqno[i])); | ||
52 | + for (j = 0; j < 2; j++) { | ||
53 | + sysbus_create_simple(TYPE_PL022, spibase[2 * i + j], | ||
54 | + qdev_get_gpio_in(orgate_dev, j)); | ||
55 | + } | ||
56 | + } | ||
57 | |||
58 | /* In hardware this is a LAN9220; the LAN9118 is software compatible | ||
59 | * except that it doesn't support the checksum-offload feature. | ||
60 | diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig | ||
61 | index XXXXXXX..XXXXXXX 100644 | ||
62 | --- a/hw/arm/Kconfig | ||
63 | +++ b/hw/arm/Kconfig | ||
64 | @@ -XXX,XX +XXX,XX @@ config HIGHBANK | ||
65 | select ARM_TIMER # sp804 | ||
66 | select ARM_V7M | ||
67 | select PL011 # UART | ||
68 | - select PL022 # Serial port | ||
69 | + select PL022 # SPI | ||
70 | select PL031 # RTC | ||
71 | select PL061 # GPIO | ||
72 | select PL310 # cache controller | ||
73 | @@ -XXX,XX +XXX,XX @@ config STELLARIS | ||
74 | select CMSDK_APB_WATCHDOG | ||
75 | select I2C | ||
76 | select PL011 # UART | ||
77 | - select PL022 # Serial port | ||
78 | + select PL022 # SPI | ||
79 | select PL061 # GPIO | ||
80 | select SSD0303 # OLED display | ||
81 | select SSD0323 # OLED display | ||
82 | @@ -XXX,XX +XXX,XX @@ config MPS2 | ||
83 | select MPS2_FPGAIO | ||
84 | select MPS2_SCC | ||
85 | select OR_IRQ | ||
86 | - select PL022 # Serial port | ||
87 | + select PL022 # SPI | ||
88 | select PL080 # DMA controller | ||
89 | select SPLIT_IRQ | ||
90 | select UNIMP | ||
91 | -- | ||
92 | 2.20.1 | ||
93 | |||
94 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
2 | 1 | ||
3 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
4 | Message-id: 20200617072539.32686-14-f4bug@amsat.org | ||
5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | --- | ||
8 | hw/arm/mps2.c | 1 + | ||
9 | 1 file changed, 1 insertion(+) | ||
10 | |||
11 | diff --git a/hw/arm/mps2.c b/hw/arm/mps2.c | ||
12 | index XXXXXXX..XXXXXXX 100644 | ||
13 | --- a/hw/arm/mps2.c | ||
14 | +++ b/hw/arm/mps2.c | ||
15 | @@ -XXX,XX +XXX,XX @@ static void mps2_common_init(MachineState *machine) | ||
16 | 0x4002a000}; /* Shield1 */ | ||
17 | sysbus_create_simple(TYPE_ARM_SBCON_I2C, i2cbase[i], NULL); | ||
18 | } | ||
19 | + create_unimplemented_device("i2s", 0x40024000, 0x400); | ||
20 | |||
21 | /* In hardware this is a LAN9220; the LAN9118 is software compatible | ||
22 | * except that it doesn't support the checksum-offload feature. | ||
23 | -- | ||
24 | 2.20.1 | ||
25 | |||
26 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
2 | 1 | ||
3 | From 'Application Note AN521', chapter 4.7: | ||
4 | |||
5 | The SMM implements four SBCon serial modules: | ||
6 | |||
7 | One SBCon module for use by the Color LCD touch interface. | ||
8 | One SBCon module to configure the audio controller. | ||
9 | Two general purpose SBCon modules, that connect to the | ||
10 | Expansion headers J7 and J8, are intended for use with the | ||
11 | V2C-Shield1 which provide an I2C interface on the headers. | ||
12 | |||
13 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
14 | Message-id: 20200617072539.32686-15-f4bug@amsat.org | ||
15 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
17 | --- | ||
18 | hw/arm/mps2-tz.c | 23 ++++++++++++++++++----- | ||
19 | 1 file changed, 18 insertions(+), 5 deletions(-) | ||
20 | |||
21 | diff --git a/hw/arm/mps2-tz.c b/hw/arm/mps2-tz.c | ||
22 | index XXXXXXX..XXXXXXX 100644 | ||
23 | --- a/hw/arm/mps2-tz.c | ||
24 | +++ b/hw/arm/mps2-tz.c | ||
25 | @@ -XXX,XX +XXX,XX @@ | ||
26 | #include "hw/arm/armsse.h" | ||
27 | #include "hw/dma/pl080.h" | ||
28 | #include "hw/ssi/pl022.h" | ||
29 | +#include "hw/i2c/arm_sbcon_i2c.h" | ||
30 | #include "hw/net/lan9118.h" | ||
31 | #include "net/net.h" | ||
32 | #include "hw/core/split-irq.h" | ||
33 | @@ -XXX,XX +XXX,XX @@ typedef struct { | ||
34 | TZPPC ppc[5]; | ||
35 | TZMPC ssram_mpc[3]; | ||
36 | PL022State spi[5]; | ||
37 | - UnimplementedDeviceState i2c[4]; | ||
38 | + ArmSbconI2CState i2c[4]; | ||
39 | UnimplementedDeviceState i2s_audio; | ||
40 | UnimplementedDeviceState gpio[4]; | ||
41 | UnimplementedDeviceState gfx; | ||
42 | @@ -XXX,XX +XXX,XX @@ static MemoryRegion *make_spi(MPS2TZMachineState *mms, void *opaque, | ||
43 | return sysbus_mmio_get_region(s, 0); | ||
44 | } | ||
45 | |||
46 | +static MemoryRegion *make_i2c(MPS2TZMachineState *mms, void *opaque, | ||
47 | + const char *name, hwaddr size) | ||
48 | +{ | ||
49 | + ArmSbconI2CState *i2c = opaque; | ||
50 | + SysBusDevice *s; | ||
51 | + | ||
52 | + object_initialize_child(OBJECT(mms), name, i2c, TYPE_ARM_SBCON_I2C); | ||
53 | + s = SYS_BUS_DEVICE(i2c); | ||
54 | + sysbus_realize(s, &error_fatal); | ||
55 | + return sysbus_mmio_get_region(s, 0); | ||
56 | +} | ||
57 | + | ||
58 | static void mps2tz_common_init(MachineState *machine) | ||
59 | { | ||
60 | MPS2TZMachineState *mms = MPS2TZ_MACHINE(machine); | ||
61 | @@ -XXX,XX +XXX,XX @@ static void mps2tz_common_init(MachineState *machine) | ||
62 | { "uart2", make_uart, &mms->uart[2], 0x40202000, 0x1000 }, | ||
63 | { "uart3", make_uart, &mms->uart[3], 0x40203000, 0x1000 }, | ||
64 | { "uart4", make_uart, &mms->uart[4], 0x40204000, 0x1000 }, | ||
65 | - { "i2c0", make_unimp_dev, &mms->i2c[0], 0x40207000, 0x1000 }, | ||
66 | - { "i2c1", make_unimp_dev, &mms->i2c[1], 0x40208000, 0x1000 }, | ||
67 | - { "i2c2", make_unimp_dev, &mms->i2c[2], 0x4020c000, 0x1000 }, | ||
68 | - { "i2c3", make_unimp_dev, &mms->i2c[3], 0x4020d000, 0x1000 }, | ||
69 | + { "i2c0", make_i2c, &mms->i2c[0], 0x40207000, 0x1000 }, | ||
70 | + { "i2c1", make_i2c, &mms->i2c[1], 0x40208000, 0x1000 }, | ||
71 | + { "i2c2", make_i2c, &mms->i2c[2], 0x4020c000, 0x1000 }, | ||
72 | + { "i2c3", make_i2c, &mms->i2c[3], 0x4020d000, 0x1000 }, | ||
73 | }, | ||
74 | }, { | ||
75 | .name = "apb_ppcexp2", | ||
76 | -- | ||
77 | 2.20.1 | ||
78 | |||
79 | diff view generated by jsdifflib |