1 | Arm queue; some of the simpler stuff, things other have reviewed (thanks!), etc. | 1 | The following changes since commit bf4460a8d9a86f6cfe05d7a7f470c48e3a93d8b2: |
---|---|---|---|
2 | 2 | ||
3 | -- PMM | 3 | Merge tag 'pull-tcg-20230123' of https://gitlab.com/rth7680/qemu into staging (2023-02-03 09:30:45 +0000) |
4 | |||
5 | The following changes since commit 5d2f557b47dfbf8f23277a5bdd8473d4607c681a: | ||
6 | |||
7 | Merge remote-tracking branch 'remotes/kraxel/tags/vga-20200605-pull-request' into staging (2020-06-05 13:53:05 +0100) | ||
8 | 4 | ||
9 | are available in the Git repository at: | 5 | are available in the Git repository at: |
10 | 6 | ||
11 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20200605 | 7 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20230203 |
12 | 8 | ||
13 | for you to fetch changes up to 2c35a39eda0b16c2ed85c94cec204bf5efb97812: | 9 | for you to fetch changes up to bb18151d8bd9bedc497ee9d4e8d81b39a4e5bbf6: |
14 | 10 | ||
15 | target/arm: Convert Neon one-register-and-immediate insns to decodetree (2020-06-05 17:23:10 +0100) | 11 | target/arm: Enable FEAT_FGT on '-cpu max' (2023-02-03 12:59:24 +0000) |
16 | 12 | ||
17 | ---------------------------------------------------------------- | 13 | ---------------------------------------------------------------- |
18 | target-arm queue: | 14 | target-arm queue: |
19 | hw/ssi/imx_spi: Handle tx burst lengths other than 8 correctly | 15 | * Fix physical address resolution for Stage2 |
20 | hw/input/pxa2xx_keypad: Replace hw_error() by qemu_log_mask() | 16 | * pl011: refactoring, implement reset method |
21 | hw/arm/pxa2xx: Replace printf() call by qemu_log_mask() | 17 | * Support GICv3 with hvf acceleration |
22 | target/arm: Convert crypto insns to gvec | 18 | * sbsa-ref: remove cortex-a76 from list of supported cpus |
23 | hw/adc/stm32f2xx_adc: Correct memory region size and access size | 19 | * Correct syndrome for ATS12NSO* traps at Secure EL1 |
24 | tests/acceptance: Add a boot test for the xlnx-versal-virt machine | 20 | * Fix priority of HSTR_EL2 traps vs UNDEFs |
25 | docs/system: Document Aspeed boards | 21 | * Implement FEAT_FGT for '-cpu max' |
26 | raspi: Add model of the USB controller | ||
27 | target/arm: Convert 2-reg-and-shift and 1-reg-imm Neon insns to decodetree | ||
28 | 22 | ||
29 | ---------------------------------------------------------------- | 23 | ---------------------------------------------------------------- |
30 | Cédric Le Goater (1): | 24 | Alexander Graf (3): |
31 | docs/system: Document Aspeed boards | 25 | hvf: arm: Add support for GICv3 |
26 | hw/arm/virt: Consolidate GIC finalize logic | ||
27 | hw/arm/virt: Make accels in GIC finalize logic explicit | ||
32 | 28 | ||
33 | Eden Mikitas (2): | 29 | Evgeny Iakovlev (4): |
34 | hw/ssi/imx_spi: changed while statement to prevent underflow | 30 | hw/char/pl011: refactor FIFO depth handling code |
35 | hw/ssi/imx_spi: Removed unnecessary cast of rx data received from slave | 31 | hw/char/pl011: add post_load hook for backwards-compatibility |
32 | hw/char/pl011: implement a reset method | ||
33 | hw/char/pl011: better handling of FIFO flags on LCR reset | ||
36 | 34 | ||
37 | Paul Zimmerman (7): | 35 | Marcin Juszkiewicz (1): |
38 | raspi: add BCM2835 SOC MPHI emulation | 36 | sbsa-ref: remove cortex-a76 from list of supported cpus |
39 | dwc-hsotg (dwc2) USB host controller register definitions | ||
40 | dwc-hsotg (dwc2) USB host controller state definitions | ||
41 | dwc-hsotg (dwc2) USB host controller emulation | ||
42 | usb: add short-packet handling to usb-storage driver | ||
43 | wire in the dwc-hsotg (dwc2) USB host controller emulation | ||
44 | raspi2 acceptance test: add test for dwc-hsotg (dwc2) USB host | ||
45 | 37 | ||
46 | Peter Maydell (9): | 38 | Peter Maydell (23): |
47 | target/arm: Convert Neon VSHL and VSLI 2-reg-shift insn to decodetree | 39 | target/arm: Name AT_S1E1RP and AT_S1E1WP cpregs correctly |
48 | target/arm: Convert Neon VSHR 2-reg-shift insns to decodetree | 40 | target/arm: Correct syndrome for ATS12NSO* at Secure EL1 |
49 | target/arm: Convert Neon VSRA, VSRI, VRSHR, VRSRA 2-reg-shift insns to decodetree | 41 | target/arm: Remove CP_ACCESS_TRAP_UNCATEGORIZED_{EL2, EL3} |
50 | target/arm: Convert VQSHLU, VQSHL 2-reg-shift insns to decodetree | 42 | target/arm: Move do_coproc_insn() syndrome calculation earlier |
51 | target/arm: Convert Neon narrowing shifts with op==8 to decodetree | 43 | target/arm: All UNDEF-at-EL0 traps take priority over HSTR_EL2 traps |
52 | target/arm: Convert Neon narrowing shifts with op==9 to decodetree | 44 | target/arm: Make HSTR_EL2 traps take priority over UNDEF-at-EL1 |
53 | target/arm: Convert Neon VSHLL, VMOVL to decodetree | 45 | target/arm: Disable HSTR_EL2 traps if EL2 is not enabled |
54 | target/arm: Convert VCVT fixed-point ops to decodetree | 46 | target/arm: Define the FEAT_FGT registers |
55 | target/arm: Convert Neon one-register-and-immediate insns to decodetree | 47 | target/arm: Implement FGT trapping infrastructure |
48 | target/arm: Mark up sysregs for HFGRTR bits 0..11 | ||
49 | target/arm: Mark up sysregs for HFGRTR bits 12..23 | ||
50 | target/arm: Mark up sysregs for HFGRTR bits 24..35 | ||
51 | target/arm: Mark up sysregs for HFGRTR bits 36..63 | ||
52 | target/arm: Mark up sysregs for HDFGRTR bits 0..11 | ||
53 | target/arm: Mark up sysregs for HDFGRTR bits 12..63 | ||
54 | target/arm: Mark up sysregs for HFGITR bits 0..11 | ||
55 | target/arm: Mark up sysregs for HFGITR bits 12..17 | ||
56 | target/arm: Mark up sysregs for HFGITR bits 18..47 | ||
57 | target/arm: Mark up sysregs for HFGITR bits 48..63 | ||
58 | target/arm: Implement the HFGITR_EL2.ERET trap | ||
59 | target/arm: Implement the HFGITR_EL2.SVC_EL0 and SVC_EL1 traps | ||
60 | target/arm: Implement MDCR_EL2.TDCC and MDCR_EL3.TDCC traps | ||
61 | target/arm: Enable FEAT_FGT on '-cpu max' | ||
56 | 62 | ||
57 | Philippe Mathieu-Daudé (3): | 63 | Richard Henderson (2): |
58 | hw/input/pxa2xx_keypad: Replace hw_error() by qemu_log_mask() | 64 | hw/arm: Use TYPE_ARM_SMMUV3 |
59 | hw/arm/pxa2xx: Replace printf() call by qemu_log_mask() | 65 | target/arm: Fix physical address resolution for Stage2 |
60 | hw/adc/stm32f2xx_adc: Correct memory region size and access size | ||
61 | 66 | ||
62 | Richard Henderson (6): | 67 | docs/system/arm/emulation.rst | 1 + |
63 | target/arm: Convert aes and sm4 to gvec helpers | 68 | include/hw/arm/virt.h | 15 +- |
64 | target/arm: Convert rax1 to gvec helpers | 69 | include/hw/char/pl011.h | 5 +- |
65 | target/arm: Convert sha512 and sm3 to gvec helpers | 70 | target/arm/cpregs.h | 484 +++++++++++++++++++++++++++++++++++++++++- |
66 | target/arm: Convert sha1 and sha256 to gvec helpers | 71 | target/arm/cpu.h | 18 ++ |
67 | target/arm: Split helper_crypto_sha1_3reg | 72 | target/arm/internals.h | 20 ++ |
68 | target/arm: Split helper_crypto_sm3tt | 73 | target/arm/syndrome.h | 10 + |
69 | 74 | target/arm/translate.h | 6 + | |
70 | Thomas Huth (1): | 75 | hw/arm/sbsa-ref.c | 4 +- |
71 | tests/acceptance: Add a boot test for the xlnx-versal-virt machine | 76 | hw/arm/virt.c | 203 +++++++++--------- |
72 | 77 | hw/char/pl011.c | 93 ++++++-- | |
73 | docs/system/arm/aspeed.rst | 85 ++ | 78 | hw/intc/arm_gicv3_cpuif.c | 18 +- |
74 | docs/system/target-arm.rst | 1 + | 79 | target/arm/cpu64.c | 1 + |
75 | hw/usb/hcd-dwc2.h | 190 +++++ | 80 | target/arm/debug_helper.c | 46 +++- |
76 | include/hw/arm/bcm2835_peripherals.h | 5 +- | 81 | target/arm/helper.c | 245 ++++++++++++++++++++- |
77 | include/hw/misc/bcm2835_mphi.h | 44 + | 82 | target/arm/hvf/hvf.c | 151 +++++++++++++ |
78 | include/hw/usb/dwc2-regs.h | 899 ++++++++++++++++++++ | 83 | target/arm/op_helper.c | 58 ++++- |
79 | target/arm/helper.h | 45 +- | 84 | target/arm/ptw.c | 2 +- |
80 | target/arm/translate-a64.h | 3 + | 85 | target/arm/translate-a64.c | 22 +- |
81 | target/arm/vec_internal.h | 33 + | 86 | target/arm/translate.c | 125 +++++++---- |
82 | target/arm/neon-dp.decode | 214 ++++- | 87 | target/arm/hvf/trace-events | 2 + |
83 | hw/adc/stm32f2xx_adc.c | 4 +- | 88 | 21 files changed, 1340 insertions(+), 189 deletions(-) |
84 | hw/arm/bcm2835_peripherals.c | 38 +- | ||
85 | hw/arm/pxa2xx.c | 66 +- | ||
86 | hw/input/pxa2xx_keypad.c | 10 +- | ||
87 | hw/misc/bcm2835_mphi.c | 191 +++++ | ||
88 | hw/ssi/imx_spi.c | 4 +- | ||
89 | hw/usb/dev-storage.c | 15 +- | ||
90 | hw/usb/hcd-dwc2.c | 1417 ++++++++++++++++++++++++++++++++ | ||
91 | target/arm/crypto_helper.c | 267 ++++-- | ||
92 | target/arm/translate-a64.c | 198 ++--- | ||
93 | target/arm/translate-neon.inc.c | 796 ++++++++++++++---- | ||
94 | target/arm/translate.c | 539 +----------- | ||
95 | target/arm/vec_helper.c | 12 +- | ||
96 | hw/misc/Makefile.objs | 1 + | ||
97 | hw/usb/Kconfig | 5 + | ||
98 | hw/usb/Makefile.objs | 1 + | ||
99 | hw/usb/trace-events | 50 ++ | ||
100 | tests/acceptance/boot_linux_console.py | 35 +- | ||
101 | 28 files changed, 4258 insertions(+), 910 deletions(-) | ||
102 | create mode 100644 docs/system/arm/aspeed.rst | ||
103 | create mode 100644 hw/usb/hcd-dwc2.h | ||
104 | create mode 100644 include/hw/misc/bcm2835_mphi.h | ||
105 | create mode 100644 include/hw/usb/dwc2-regs.h | ||
106 | create mode 100644 target/arm/vec_internal.h | ||
107 | create mode 100644 hw/misc/bcm2835_mphi.c | ||
108 | create mode 100644 hw/usb/hcd-dwc2.c | ||
109 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Rather than passing an opcode to a helper, fully decode the | 3 | Use the macro instead of two explicit string literals. |
4 | operation at translate time. Use clear_tail_16 to zap the | ||
5 | balance of the SVE register with the AdvSIMD write. | ||
6 | 4 | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
8 | Message-id: 20200514212831.31248-7-richard.henderson@linaro.org | 6 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Reviewed-by: Eric Auger <eric.auger@redhat.com> |
8 | Message-id: 20230124232059.4017615-1-richard.henderson@linaro.org | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 10 | --- |
12 | target/arm/helper.h | 5 ++++- | 11 | hw/arm/sbsa-ref.c | 3 ++- |
13 | target/arm/crypto_helper.c | 24 ++++++++++++++++++------ | 12 | hw/arm/virt.c | 2 +- |
14 | target/arm/translate-a64.c | 21 +++++---------------- | 13 | 2 files changed, 3 insertions(+), 2 deletions(-) |
15 | 3 files changed, 27 insertions(+), 23 deletions(-) | ||
16 | 14 | ||
17 | diff --git a/target/arm/helper.h b/target/arm/helper.h | 15 | diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c |
18 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/target/arm/helper.h | 17 | --- a/hw/arm/sbsa-ref.c |
20 | +++ b/target/arm/helper.h | 18 | +++ b/hw/arm/sbsa-ref.c |
21 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(crypto_sha512su0, TCG_CALL_NO_RWG, void, ptr, ptr, i32) | 19 | @@ -XXX,XX +XXX,XX @@ |
22 | DEF_HELPER_FLAGS_4(crypto_sha512su1, TCG_CALL_NO_RWG, | 20 | #include "exec/hwaddr.h" |
23 | void, ptr, ptr, ptr, i32) | 21 | #include "kvm_arm.h" |
24 | 22 | #include "hw/arm/boot.h" | |
25 | -DEF_HELPER_FLAGS_5(crypto_sm3tt, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32, i32) | 23 | +#include "hw/arm/smmuv3.h" |
26 | +DEF_HELPER_FLAGS_4(crypto_sm3tt1a, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | 24 | #include "hw/block/flash.h" |
27 | +DEF_HELPER_FLAGS_4(crypto_sm3tt1b, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | 25 | #include "hw/boards.h" |
28 | +DEF_HELPER_FLAGS_4(crypto_sm3tt2a, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | 26 | #include "hw/ide/internal.h" |
29 | +DEF_HELPER_FLAGS_4(crypto_sm3tt2b, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | 27 | @@ -XXX,XX +XXX,XX @@ static void create_smmu(const SBSAMachineState *sms, PCIBus *bus) |
30 | DEF_HELPER_FLAGS_4(crypto_sm3partw1, TCG_CALL_NO_RWG, | 28 | DeviceState *dev; |
31 | void, ptr, ptr, ptr, i32) | 29 | int i; |
32 | DEF_HELPER_FLAGS_4(crypto_sm3partw2, TCG_CALL_NO_RWG, | 30 | |
33 | diff --git a/target/arm/crypto_helper.c b/target/arm/crypto_helper.c | 31 | - dev = qdev_new("arm-smmuv3"); |
32 | + dev = qdev_new(TYPE_ARM_SMMUV3); | ||
33 | |||
34 | object_property_set_link(OBJECT(dev), "primary-bus", OBJECT(bus), | ||
35 | &error_abort); | ||
36 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c | ||
34 | index XXXXXXX..XXXXXXX 100644 | 37 | index XXXXXXX..XXXXXXX 100644 |
35 | --- a/target/arm/crypto_helper.c | 38 | --- a/hw/arm/virt.c |
36 | +++ b/target/arm/crypto_helper.c | 39 | +++ b/hw/arm/virt.c |
37 | @@ -XXX,XX +XXX,XX @@ void HELPER(crypto_sm3partw2)(void *vd, void *vn, void *vm, uint32_t desc) | 40 | @@ -XXX,XX +XXX,XX @@ static void create_smmu(const VirtMachineState *vms, |
38 | clear_tail_16(vd, desc); | ||
39 | } | ||
40 | |||
41 | -void HELPER(crypto_sm3tt)(void *vd, void *vn, void *vm, uint32_t imm2, | ||
42 | - uint32_t opcode) | ||
43 | +static inline void QEMU_ALWAYS_INLINE | ||
44 | +crypto_sm3tt(uint64_t *rd, uint64_t *rn, uint64_t *rm, | ||
45 | + uint32_t desc, uint32_t opcode) | ||
46 | { | ||
47 | - uint64_t *rd = vd; | ||
48 | - uint64_t *rn = vn; | ||
49 | - uint64_t *rm = vm; | ||
50 | union CRYPTO_STATE d = { .l = { rd[0], rd[1] } }; | ||
51 | union CRYPTO_STATE n = { .l = { rn[0], rn[1] } }; | ||
52 | union CRYPTO_STATE m = { .l = { rm[0], rm[1] } }; | ||
53 | + uint32_t imm2 = simd_data(desc); | ||
54 | uint32_t t; | ||
55 | |||
56 | assert(imm2 < 4); | ||
57 | @@ -XXX,XX +XXX,XX @@ void HELPER(crypto_sm3tt)(void *vd, void *vn, void *vm, uint32_t imm2, | ||
58 | /* SM3TT2B */ | ||
59 | t = cho(CR_ST_WORD(d, 3), CR_ST_WORD(d, 2), CR_ST_WORD(d, 1)); | ||
60 | } else { | ||
61 | - g_assert_not_reached(); | ||
62 | + qemu_build_not_reached(); | ||
63 | } | ||
64 | |||
65 | t += CR_ST_WORD(d, 0) + CR_ST_WORD(m, imm2); | ||
66 | @@ -XXX,XX +XXX,XX @@ void HELPER(crypto_sm3tt)(void *vd, void *vn, void *vm, uint32_t imm2, | ||
67 | |||
68 | rd[0] = d.l[0]; | ||
69 | rd[1] = d.l[1]; | ||
70 | + | ||
71 | + clear_tail_16(rd, desc); | ||
72 | } | ||
73 | |||
74 | +#define DO_SM3TT(NAME, OPCODE) \ | ||
75 | + void HELPER(NAME)(void *vd, void *vn, void *vm, uint32_t desc) \ | ||
76 | + { crypto_sm3tt(vd, vn, vm, desc, OPCODE); } | ||
77 | + | ||
78 | +DO_SM3TT(crypto_sm3tt1a, 0) | ||
79 | +DO_SM3TT(crypto_sm3tt1b, 1) | ||
80 | +DO_SM3TT(crypto_sm3tt2a, 2) | ||
81 | +DO_SM3TT(crypto_sm3tt2b, 3) | ||
82 | + | ||
83 | +#undef DO_SM3TT | ||
84 | + | ||
85 | static uint8_t const sm4_sbox[] = { | ||
86 | 0xd6, 0x90, 0xe9, 0xfe, 0xcc, 0xe1, 0x3d, 0xb7, | ||
87 | 0x16, 0xb6, 0x14, 0xc2, 0x28, 0xfb, 0x2c, 0x05, | ||
88 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
89 | index XXXXXXX..XXXXXXX 100644 | ||
90 | --- a/target/arm/translate-a64.c | ||
91 | +++ b/target/arm/translate-a64.c | ||
92 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_xar(DisasContext *s, uint32_t insn) | ||
93 | */ | ||
94 | static void disas_crypto_three_reg_imm2(DisasContext *s, uint32_t insn) | ||
95 | { | ||
96 | + static gen_helper_gvec_3 * const fns[4] = { | ||
97 | + gen_helper_crypto_sm3tt1a, gen_helper_crypto_sm3tt1b, | ||
98 | + gen_helper_crypto_sm3tt2a, gen_helper_crypto_sm3tt2b, | ||
99 | + }; | ||
100 | int opcode = extract32(insn, 10, 2); | ||
101 | int imm2 = extract32(insn, 12, 2); | ||
102 | int rm = extract32(insn, 16, 5); | ||
103 | int rn = extract32(insn, 5, 5); | ||
104 | int rd = extract32(insn, 0, 5); | ||
105 | - TCGv_ptr tcg_rd_ptr, tcg_rn_ptr, tcg_rm_ptr; | ||
106 | - TCGv_i32 tcg_imm2, tcg_opcode; | ||
107 | |||
108 | if (!dc_isar_feature(aa64_sm3, s)) { | ||
109 | unallocated_encoding(s); | ||
110 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_three_reg_imm2(DisasContext *s, uint32_t insn) | ||
111 | return; | 41 | return; |
112 | } | 42 | } |
113 | 43 | ||
114 | - tcg_rd_ptr = vec_full_reg_ptr(s, rd); | 44 | - dev = qdev_new("arm-smmuv3"); |
115 | - tcg_rn_ptr = vec_full_reg_ptr(s, rn); | 45 | + dev = qdev_new(TYPE_ARM_SMMUV3); |
116 | - tcg_rm_ptr = vec_full_reg_ptr(s, rm); | 46 | |
117 | - tcg_imm2 = tcg_const_i32(imm2); | 47 | object_property_set_link(OBJECT(dev), "primary-bus", OBJECT(bus), |
118 | - tcg_opcode = tcg_const_i32(opcode); | 48 | &error_abort); |
119 | - | ||
120 | - gen_helper_crypto_sm3tt(tcg_rd_ptr, tcg_rn_ptr, tcg_rm_ptr, tcg_imm2, | ||
121 | - tcg_opcode); | ||
122 | - | ||
123 | - tcg_temp_free_ptr(tcg_rd_ptr); | ||
124 | - tcg_temp_free_ptr(tcg_rn_ptr); | ||
125 | - tcg_temp_free_ptr(tcg_rm_ptr); | ||
126 | - tcg_temp_free_i32(tcg_imm2); | ||
127 | - tcg_temp_free_i32(tcg_opcode); | ||
128 | + gen_gvec_op3_ool(s, true, rd, rn, rm, imm2, fns[opcode]); | ||
129 | } | ||
130 | |||
131 | /* C3.6 Data processing - SIMD, inc Crypto | ||
132 | -- | 49 | -- |
133 | 2.20.1 | 50 | 2.34.1 |
134 | 51 | ||
135 | 52 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | With this conversion, we will be able to use the same helpers | 3 | Conversion to probe_access_full missed applying the page offset. |
4 | with sve. This also fixes a bug in which we failed to clear | ||
5 | the high bits of the SVE register after an AdvSIMD operation. | ||
6 | 4 | ||
5 | Cc: qemu-stable@nongnu.org | ||
6 | Reported-by: Sid Manning <sidneym@quicinc.com> | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
8 | Message-id: 20200514212831.31248-3-richard.henderson@linaro.org | 8 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Message-id: 20230126233134.103193-1-richard.henderson@linaro.org |
10 | Fixes: f3639a64f602 ("target/arm: Use softmmu tlbs for page table walking") | ||
11 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 13 | --- |
12 | target/arm/helper.h | 2 ++ | 14 | target/arm/ptw.c | 2 +- |
13 | target/arm/translate-a64.h | 3 ++ | 15 | 1 file changed, 1 insertion(+), 1 deletion(-) |
14 | target/arm/crypto_helper.c | 11 +++++++ | ||
15 | target/arm/translate-a64.c | 59 ++++++++++++++++++++------------------ | ||
16 | 4 files changed, 47 insertions(+), 28 deletions(-) | ||
17 | 16 | ||
18 | diff --git a/target/arm/helper.h b/target/arm/helper.h | 17 | diff --git a/target/arm/ptw.c b/target/arm/ptw.c |
19 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/target/arm/helper.h | 19 | --- a/target/arm/ptw.c |
21 | +++ b/target/arm/helper.h | 20 | +++ b/target/arm/ptw.c |
22 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(crypto_sm3partw2, TCG_CALL_NO_RWG, void, ptr, ptr, ptr) | 21 | @@ -XXX,XX +XXX,XX @@ static bool S1_ptw_translate(CPUARMState *env, S1Translate *ptw, |
23 | DEF_HELPER_FLAGS_4(crypto_sm4e, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | 22 | if (unlikely(flags & TLB_INVALID_MASK)) { |
24 | DEF_HELPER_FLAGS_4(crypto_sm4ekey, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | 23 | goto fail; |
25 | 24 | } | |
26 | +DEF_HELPER_FLAGS_4(crypto_rax1, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | 25 | - ptw->out_phys = full->phys_addr; |
27 | + | 26 | + ptw->out_phys = full->phys_addr | (addr & ~TARGET_PAGE_MASK); |
28 | DEF_HELPER_FLAGS_3(crc32, TCG_CALL_NO_RWG_SE, i32, i32, i32, i32) | 27 | ptw->out_rw = full->prot & PAGE_WRITE; |
29 | DEF_HELPER_FLAGS_3(crc32c, TCG_CALL_NO_RWG_SE, i32, i32, i32, i32) | 28 | pte_attrs = full->pte_attrs; |
30 | 29 | pte_secure = full->attrs.secure; | |
31 | diff --git a/target/arm/translate-a64.h b/target/arm/translate-a64.h | ||
32 | index XXXXXXX..XXXXXXX 100644 | ||
33 | --- a/target/arm/translate-a64.h | ||
34 | +++ b/target/arm/translate-a64.h | ||
35 | @@ -XXX,XX +XXX,XX @@ static inline int vec_full_reg_size(DisasContext *s) | ||
36 | |||
37 | bool disas_sve(DisasContext *, uint32_t); | ||
38 | |||
39 | +void gen_gvec_rax1(unsigned vece, uint32_t rd_ofs, uint32_t rn_ofs, | ||
40 | + uint32_t rm_ofs, uint32_t opr_sz, uint32_t max_sz); | ||
41 | + | ||
42 | #endif /* TARGET_ARM_TRANSLATE_A64_H */ | ||
43 | diff --git a/target/arm/crypto_helper.c b/target/arm/crypto_helper.c | ||
44 | index XXXXXXX..XXXXXXX 100644 | ||
45 | --- a/target/arm/crypto_helper.c | ||
46 | +++ b/target/arm/crypto_helper.c | ||
47 | @@ -XXX,XX +XXX,XX @@ void HELPER(crypto_sm4ekey)(void *vd, void *vn, void* vm, uint32_t desc) | ||
48 | } | ||
49 | clear_tail(vd, opr_sz, simd_maxsz(desc)); | ||
50 | } | ||
51 | + | ||
52 | +void HELPER(crypto_rax1)(void *vd, void *vn, void *vm, uint32_t desc) | ||
53 | +{ | ||
54 | + intptr_t i, opr_sz = simd_oprsz(desc); | ||
55 | + uint64_t *d = vd, *n = vn, *m = vm; | ||
56 | + | ||
57 | + for (i = 0; i < opr_sz / 8; ++i) { | ||
58 | + d[i] = n[i] ^ rol64(m[i], 1); | ||
59 | + } | ||
60 | + clear_tail(vd, opr_sz, simd_maxsz(desc)); | ||
61 | +} | ||
62 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
63 | index XXXXXXX..XXXXXXX 100644 | ||
64 | --- a/target/arm/translate-a64.c | ||
65 | +++ b/target/arm/translate-a64.c | ||
66 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_two_reg_sha(DisasContext *s, uint32_t insn) | ||
67 | tcg_temp_free_ptr(tcg_rn_ptr); | ||
68 | } | ||
69 | |||
70 | +static void gen_rax1_i64(TCGv_i64 d, TCGv_i64 n, TCGv_i64 m) | ||
71 | +{ | ||
72 | + tcg_gen_rotli_i64(d, m, 1); | ||
73 | + tcg_gen_xor_i64(d, d, n); | ||
74 | +} | ||
75 | + | ||
76 | +static void gen_rax1_vec(unsigned vece, TCGv_vec d, TCGv_vec n, TCGv_vec m) | ||
77 | +{ | ||
78 | + tcg_gen_rotli_vec(vece, d, m, 1); | ||
79 | + tcg_gen_xor_vec(vece, d, d, n); | ||
80 | +} | ||
81 | + | ||
82 | +void gen_gvec_rax1(unsigned vece, uint32_t rd_ofs, uint32_t rn_ofs, | ||
83 | + uint32_t rm_ofs, uint32_t opr_sz, uint32_t max_sz) | ||
84 | +{ | ||
85 | + static const TCGOpcode vecop_list[] = { INDEX_op_rotli_vec, 0 }; | ||
86 | + static const GVecGen3 op = { | ||
87 | + .fni8 = gen_rax1_i64, | ||
88 | + .fniv = gen_rax1_vec, | ||
89 | + .opt_opc = vecop_list, | ||
90 | + .fno = gen_helper_crypto_rax1, | ||
91 | + .vece = MO_64, | ||
92 | + }; | ||
93 | + tcg_gen_gvec_3(rd_ofs, rn_ofs, rm_ofs, opr_sz, max_sz, &op); | ||
94 | +} | ||
95 | + | ||
96 | /* Crypto three-reg SHA512 | ||
97 | * 31 21 20 16 15 14 13 12 11 10 9 5 4 0 | ||
98 | * +-----------------------+------+---+---+-----+--------+------+------+ | ||
99 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_three_reg_sha512(DisasContext *s, uint32_t insn) | ||
100 | bool feature; | ||
101 | CryptoThreeOpFn *genfn = NULL; | ||
102 | gen_helper_gvec_3 *oolfn = NULL; | ||
103 | + GVecGen3Fn *gvecfn = NULL; | ||
104 | |||
105 | if (o == 0) { | ||
106 | switch (opcode) { | ||
107 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_three_reg_sha512(DisasContext *s, uint32_t insn) | ||
108 | break; | ||
109 | case 3: /* RAX1 */ | ||
110 | feature = dc_isar_feature(aa64_sha3, s); | ||
111 | - genfn = NULL; | ||
112 | + gvecfn = gen_gvec_rax1; | ||
113 | break; | ||
114 | default: | ||
115 | g_assert_not_reached(); | ||
116 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_three_reg_sha512(DisasContext *s, uint32_t insn) | ||
117 | |||
118 | if (oolfn) { | ||
119 | gen_gvec_op3_ool(s, true, rd, rn, rm, 0, oolfn); | ||
120 | - return; | ||
121 | - } | ||
122 | - | ||
123 | - if (genfn) { | ||
124 | + } else if (gvecfn) { | ||
125 | + gen_gvec_fn3(s, true, rd, rn, rm, gvecfn, MO_64); | ||
126 | + } else { | ||
127 | TCGv_ptr tcg_rd_ptr, tcg_rn_ptr, tcg_rm_ptr; | ||
128 | |||
129 | tcg_rd_ptr = vec_full_reg_ptr(s, rd); | ||
130 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_three_reg_sha512(DisasContext *s, uint32_t insn) | ||
131 | tcg_temp_free_ptr(tcg_rd_ptr); | ||
132 | tcg_temp_free_ptr(tcg_rn_ptr); | ||
133 | tcg_temp_free_ptr(tcg_rm_ptr); | ||
134 | - } else { | ||
135 | - TCGv_i64 tcg_op1, tcg_op2, tcg_res[2]; | ||
136 | - int pass; | ||
137 | - | ||
138 | - tcg_op1 = tcg_temp_new_i64(); | ||
139 | - tcg_op2 = tcg_temp_new_i64(); | ||
140 | - tcg_res[0] = tcg_temp_new_i64(); | ||
141 | - tcg_res[1] = tcg_temp_new_i64(); | ||
142 | - | ||
143 | - for (pass = 0; pass < 2; pass++) { | ||
144 | - read_vec_element(s, tcg_op1, rn, pass, MO_64); | ||
145 | - read_vec_element(s, tcg_op2, rm, pass, MO_64); | ||
146 | - | ||
147 | - tcg_gen_rotli_i64(tcg_res[pass], tcg_op2, 1); | ||
148 | - tcg_gen_xor_i64(tcg_res[pass], tcg_res[pass], tcg_op1); | ||
149 | - } | ||
150 | - write_vec_element(s, tcg_res[0], rd, 0, MO_64); | ||
151 | - write_vec_element(s, tcg_res[1], rd, 1, MO_64); | ||
152 | - | ||
153 | - tcg_temp_free_i64(tcg_op1); | ||
154 | - tcg_temp_free_i64(tcg_op2); | ||
155 | - tcg_temp_free_i64(tcg_res[0]); | ||
156 | - tcg_temp_free_i64(tcg_res[1]); | ||
157 | } | ||
158 | } | ||
159 | |||
160 | -- | 30 | -- |
161 | 2.20.1 | 31 | 2.34.1 |
162 | 32 | ||
163 | 33 | diff view generated by jsdifflib |
1 | From: Paul Zimmerman <pauldzim@gmail.com> | 1 | From: Evgeny Iakovlev <eiakovlev@linux.microsoft.com> |
---|---|---|---|
2 | 2 | ||
3 | Add BCM2835 SOC MPHI (Message-based Parallel Host Interface) | 3 | PL011 can be in either of 2 modes depending guest config: FIFO and |
4 | emulation. It is very basic, only providing the FIQ interrupt | 4 | single register. The last mode could be viewed as a 1-element-deep FIFO. |
5 | needed to allow the dwc-otg USB host controller driver in the | ||
6 | Raspbian kernel to function. | ||
7 | 5 | ||
8 | Signed-off-by: Paul Zimmerman <pauldzim@gmail.com> | 6 | Current code open-codes a bunch of depth-dependent logic. Refactor FIFO |
9 | Acked-by: Philippe Mathieu-Daude <f4bug@amsat.org> | 7 | depth handling code to isolate calculating current FIFO depth. |
8 | |||
9 | One functional (albeit guest-invisible) side-effect of this change is | ||
10 | that previously we would always increment s->read_pos in UARTDR read | ||
11 | handler even if FIFO was disabled, now we are limiting read_pos to not | ||
12 | exceed FIFO depth (read_pos itself is reset to 0 if user disables FIFO). | ||
13 | |||
14 | Signed-off-by: Evgeny Iakovlev <eiakovlev@linux.microsoft.com> | ||
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 15 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
11 | Message-id: 20200520235349.21215-2-pauldzim@gmail.com | 16 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
17 | Message-id: 20230123162304.26254-2-eiakovlev@linux.microsoft.com | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 18 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | --- | 19 | --- |
14 | include/hw/arm/bcm2835_peripherals.h | 2 + | 20 | include/hw/char/pl011.h | 5 ++++- |
15 | include/hw/misc/bcm2835_mphi.h | 44 ++++++ | 21 | hw/char/pl011.c | 30 ++++++++++++++++++------------ |
16 | hw/arm/bcm2835_peripherals.c | 17 +++ | 22 | 2 files changed, 22 insertions(+), 13 deletions(-) |
17 | hw/misc/bcm2835_mphi.c | 191 +++++++++++++++++++++++++++ | ||
18 | hw/misc/Makefile.objs | 1 + | ||
19 | 5 files changed, 255 insertions(+) | ||
20 | create mode 100644 include/hw/misc/bcm2835_mphi.h | ||
21 | create mode 100644 hw/misc/bcm2835_mphi.c | ||
22 | 23 | ||
23 | diff --git a/include/hw/arm/bcm2835_peripherals.h b/include/hw/arm/bcm2835_peripherals.h | 24 | diff --git a/include/hw/char/pl011.h b/include/hw/char/pl011.h |
24 | index XXXXXXX..XXXXXXX 100644 | 25 | index XXXXXXX..XXXXXXX 100644 |
25 | --- a/include/hw/arm/bcm2835_peripherals.h | 26 | --- a/include/hw/char/pl011.h |
26 | +++ b/include/hw/arm/bcm2835_peripherals.h | 27 | +++ b/include/hw/char/pl011.h |
27 | @@ -XXX,XX +XXX,XX @@ | 28 | @@ -XXX,XX +XXX,XX @@ OBJECT_DECLARE_SIMPLE_TYPE(PL011State, PL011) |
28 | #include "hw/misc/bcm2835_property.h" | 29 | /* This shares the same struct (and cast macro) as the base pl011 device */ |
29 | #include "hw/misc/bcm2835_rng.h" | 30 | #define TYPE_PL011_LUMINARY "pl011_luminary" |
30 | #include "hw/misc/bcm2835_mbox.h" | 31 | |
31 | +#include "hw/misc/bcm2835_mphi.h" | 32 | +/* Depth of UART FIFO in bytes, when FIFO mode is enabled (else depth == 1) */ |
32 | #include "hw/misc/bcm2835_thermal.h" | 33 | +#define PL011_FIFO_DEPTH 16 |
33 | #include "hw/sd/sdhci.h" | ||
34 | #include "hw/sd/bcm2835_sdhost.h" | ||
35 | @@ -XXX,XX +XXX,XX @@ typedef struct BCM2835PeripheralState { | ||
36 | qemu_irq irq, fiq; | ||
37 | |||
38 | BCM2835SystemTimerState systmr; | ||
39 | + BCM2835MphiState mphi; | ||
40 | UnimplementedDeviceState armtmr; | ||
41 | UnimplementedDeviceState cprman; | ||
42 | UnimplementedDeviceState a2w; | ||
43 | diff --git a/include/hw/misc/bcm2835_mphi.h b/include/hw/misc/bcm2835_mphi.h | ||
44 | new file mode 100644 | ||
45 | index XXXXXXX..XXXXXXX | ||
46 | --- /dev/null | ||
47 | +++ b/include/hw/misc/bcm2835_mphi.h | ||
48 | @@ -XXX,XX +XXX,XX @@ | ||
49 | +/* | ||
50 | + * BCM2835 SOC MPHI state definitions | ||
51 | + * | ||
52 | + * Copyright (c) 2020 Paul Zimmerman <pauldzim@gmail.com> | ||
53 | + * | ||
54 | + * This program is free software; you can redistribute it and/or modify | ||
55 | + * it under the terms of the GNU General Public License as published by | ||
56 | + * the Free Software Foundation; either version 2 of the License, or | ||
57 | + * (at your option) any later version. | ||
58 | + * | ||
59 | + * This program is distributed in the hope that it will be useful, | ||
60 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
61 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
62 | + * GNU General Public License for more details. | ||
63 | + */ | ||
64 | + | 34 | + |
65 | +#ifndef HW_MISC_BCM2835_MPHI_H | 35 | struct PL011State { |
66 | +#define HW_MISC_BCM2835_MPHI_H | 36 | SysBusDevice parent_obj; |
67 | + | 37 | |
68 | +#include "hw/irq.h" | 38 | @@ -XXX,XX +XXX,XX @@ struct PL011State { |
69 | +#include "hw/sysbus.h" | 39 | uint32_t dmacr; |
70 | + | 40 | uint32_t int_enabled; |
71 | +#define MPHI_MMIO_SIZE 0x1000 | 41 | uint32_t int_level; |
72 | + | 42 | - uint32_t read_fifo[16]; |
73 | +typedef struct BCM2835MphiState BCM2835MphiState; | 43 | + uint32_t read_fifo[PL011_FIFO_DEPTH]; |
74 | + | 44 | uint32_t ilpr; |
75 | +struct BCM2835MphiState { | 45 | uint32_t ibrd; |
76 | + SysBusDevice parent_obj; | 46 | uint32_t fbrd; |
77 | + qemu_irq irq; | 47 | diff --git a/hw/char/pl011.c b/hw/char/pl011.c |
78 | + MemoryRegion iomem; | ||
79 | + | ||
80 | + uint32_t outdda; | ||
81 | + uint32_t outddb; | ||
82 | + uint32_t ctrl; | ||
83 | + uint32_t intstat; | ||
84 | + uint32_t swirq; | ||
85 | +}; | ||
86 | + | ||
87 | +#define TYPE_BCM2835_MPHI "bcm2835-mphi" | ||
88 | + | ||
89 | +#define BCM2835_MPHI(obj) \ | ||
90 | + OBJECT_CHECK(BCM2835MphiState, (obj), TYPE_BCM2835_MPHI) | ||
91 | + | ||
92 | +#endif | ||
93 | diff --git a/hw/arm/bcm2835_peripherals.c b/hw/arm/bcm2835_peripherals.c | ||
94 | index XXXXXXX..XXXXXXX 100644 | 48 | index XXXXXXX..XXXXXXX 100644 |
95 | --- a/hw/arm/bcm2835_peripherals.c | 49 | --- a/hw/char/pl011.c |
96 | +++ b/hw/arm/bcm2835_peripherals.c | 50 | +++ b/hw/char/pl011.c |
97 | @@ -XXX,XX +XXX,XX @@ static void bcm2835_peripherals_init(Object *obj) | 51 | @@ -XXX,XX +XXX,XX @@ static void pl011_update(PL011State *s) |
98 | OBJECT(&s->sdhci.sdbus)); | 52 | } |
99 | object_property_add_const_link(OBJECT(&s->gpio), "sdbus-sdhost", | ||
100 | OBJECT(&s->sdhost.sdbus)); | ||
101 | + | ||
102 | + /* Mphi */ | ||
103 | + sysbus_init_child_obj(obj, "mphi", &s->mphi, sizeof(s->mphi), | ||
104 | + TYPE_BCM2835_MPHI); | ||
105 | } | 53 | } |
106 | 54 | ||
107 | static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp) | 55 | +static bool pl011_is_fifo_enabled(PL011State *s) |
108 | @@ -XXX,XX +XXX,XX @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp) | ||
109 | |||
110 | object_property_add_alias(OBJECT(s), "sd-bus", OBJECT(&s->gpio), "sd-bus"); | ||
111 | |||
112 | + /* Mphi */ | ||
113 | + object_property_set_bool(OBJECT(&s->mphi), true, "realized", &err); | ||
114 | + if (err) { | ||
115 | + error_propagate(errp, err); | ||
116 | + return; | ||
117 | + } | ||
118 | + | ||
119 | + memory_region_add_subregion(&s->peri_mr, MPHI_OFFSET, | ||
120 | + sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->mphi), 0)); | ||
121 | + sysbus_connect_irq(SYS_BUS_DEVICE(&s->mphi), 0, | ||
122 | + qdev_get_gpio_in_named(DEVICE(&s->ic), BCM2835_IC_GPU_IRQ, | ||
123 | + INTERRUPT_HOSTPORT)); | ||
124 | + | ||
125 | create_unimp(s, &s->armtmr, "bcm2835-sp804", ARMCTRL_TIMER0_1_OFFSET, 0x40); | ||
126 | create_unimp(s, &s->cprman, "bcm2835-cprman", CPRMAN_OFFSET, 0x1000); | ||
127 | create_unimp(s, &s->a2w, "bcm2835-a2w", A2W_OFFSET, 0x1000); | ||
128 | diff --git a/hw/misc/bcm2835_mphi.c b/hw/misc/bcm2835_mphi.c | ||
129 | new file mode 100644 | ||
130 | index XXXXXXX..XXXXXXX | ||
131 | --- /dev/null | ||
132 | +++ b/hw/misc/bcm2835_mphi.c | ||
133 | @@ -XXX,XX +XXX,XX @@ | ||
134 | +/* | ||
135 | + * BCM2835 SOC MPHI emulation | ||
136 | + * | ||
137 | + * Very basic emulation, only providing the FIQ interrupt needed to | ||
138 | + * allow the dwc-otg USB host controller driver in the Raspbian kernel | ||
139 | + * to function. | ||
140 | + * | ||
141 | + * Copyright (c) 2020 Paul Zimmerman <pauldzim@gmail.com> | ||
142 | + * | ||
143 | + * This program is free software; you can redistribute it and/or modify | ||
144 | + * it under the terms of the GNU General Public License as published by | ||
145 | + * the Free Software Foundation; either version 2 of the License, or | ||
146 | + * (at your option) any later version. | ||
147 | + * | ||
148 | + * This program is distributed in the hope that it will be useful, | ||
149 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
150 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
151 | + * GNU General Public License for more details. | ||
152 | + */ | ||
153 | + | ||
154 | +#include "qemu/osdep.h" | ||
155 | +#include "qapi/error.h" | ||
156 | +#include "hw/misc/bcm2835_mphi.h" | ||
157 | +#include "migration/vmstate.h" | ||
158 | +#include "qemu/error-report.h" | ||
159 | +#include "qemu/log.h" | ||
160 | +#include "qemu/main-loop.h" | ||
161 | + | ||
162 | +static inline void mphi_raise_irq(BCM2835MphiState *s) | ||
163 | +{ | 56 | +{ |
164 | + qemu_set_irq(s->irq, 1); | 57 | + return (s->lcr & 0x10) != 0; |
165 | +} | 58 | +} |
166 | + | 59 | + |
167 | +static inline void mphi_lower_irq(BCM2835MphiState *s) | 60 | +static inline unsigned pl011_get_fifo_depth(PL011State *s) |
168 | +{ | 61 | +{ |
169 | + qemu_set_irq(s->irq, 0); | 62 | + /* Note: FIFO depth is expected to be power-of-2 */ |
63 | + return pl011_is_fifo_enabled(s) ? PL011_FIFO_DEPTH : 1; | ||
170 | +} | 64 | +} |
171 | + | 65 | + |
172 | +static uint64_t mphi_reg_read(void *ptr, hwaddr addr, unsigned size) | 66 | static uint64_t pl011_read(void *opaque, hwaddr offset, |
173 | +{ | 67 | unsigned size) |
174 | + BCM2835MphiState *s = ptr; | 68 | { |
175 | + uint32_t val = 0; | 69 | @@ -XXX,XX +XXX,XX @@ static uint64_t pl011_read(void *opaque, hwaddr offset, |
176 | + | 70 | c = s->read_fifo[s->read_pos]; |
177 | + switch (addr) { | 71 | if (s->read_count > 0) { |
178 | + case 0x28: /* outdda */ | 72 | s->read_count--; |
179 | + val = s->outdda; | 73 | - if (++s->read_pos == 16) |
180 | + break; | 74 | - s->read_pos = 0; |
181 | + case 0x2c: /* outddb */ | 75 | + s->read_pos = (s->read_pos + 1) & (pl011_get_fifo_depth(s) - 1); |
182 | + val = s->outddb; | 76 | } |
183 | + break; | 77 | if (s->read_count == 0) { |
184 | + case 0x4c: /* ctrl */ | 78 | s->flags |= PL011_FLAG_RXFE; |
185 | + val = s->ctrl; | 79 | @@ -XXX,XX +XXX,XX @@ static int pl011_can_receive(void *opaque) |
186 | + val |= 1 << 17; | 80 | PL011State *s = (PL011State *)opaque; |
187 | + break; | 81 | int r; |
188 | + case 0x50: /* intstat */ | 82 | |
189 | + val = s->intstat; | 83 | - if (s->lcr & 0x10) { |
190 | + break; | 84 | - r = s->read_count < 16; |
191 | + case 0x1f0: /* swirq_set */ | 85 | - } else { |
192 | + val = s->swirq; | 86 | - r = s->read_count < 1; |
193 | + break; | 87 | - } |
194 | + case 0x1f4: /* swirq_clr */ | 88 | + r = s->read_count < pl011_get_fifo_depth(s); |
195 | + val = s->swirq; | 89 | trace_pl011_can_receive(s->lcr, s->read_count, r); |
196 | + break; | 90 | return r; |
197 | + default: | 91 | } |
198 | + qemu_log_mask(LOG_UNIMP, "read from unknown register"); | 92 | @@ -XXX,XX +XXX,XX @@ static void pl011_put_fifo(void *opaque, uint32_t value) |
199 | + break; | 93 | { |
200 | + } | 94 | PL011State *s = (PL011State *)opaque; |
201 | + | 95 | int slot; |
202 | + return val; | 96 | + unsigned pipe_depth; |
203 | +} | 97 | |
204 | + | 98 | - slot = s->read_pos + s->read_count; |
205 | +static void mphi_reg_write(void *ptr, hwaddr addr, uint64_t val, unsigned size) | 99 | - if (slot >= 16) |
206 | +{ | 100 | - slot -= 16; |
207 | + BCM2835MphiState *s = ptr; | 101 | + pipe_depth = pl011_get_fifo_depth(s); |
208 | + int do_irq = 0; | 102 | + slot = (s->read_pos + s->read_count) & (pipe_depth - 1); |
209 | + | 103 | s->read_fifo[slot] = value; |
210 | + switch (addr) { | 104 | s->read_count++; |
211 | + case 0x28: /* outdda */ | 105 | s->flags &= ~PL011_FLAG_RXFE; |
212 | + s->outdda = val; | 106 | trace_pl011_put_fifo(value, s->read_count); |
213 | + break; | 107 | - if (!(s->lcr & 0x10) || s->read_count == 16) { |
214 | + case 0x2c: /* outddb */ | 108 | + if (s->read_count == pipe_depth) { |
215 | + s->outddb = val; | 109 | trace_pl011_put_fifo_full(); |
216 | + if (val & (1 << 29)) { | 110 | s->flags |= PL011_FLAG_RXFF; |
217 | + do_irq = 1; | 111 | } |
218 | + } | 112 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_pl011 = { |
219 | + break; | 113 | VMSTATE_UINT32(dmacr, PL011State), |
220 | + case 0x4c: /* ctrl */ | 114 | VMSTATE_UINT32(int_enabled, PL011State), |
221 | + s->ctrl = val; | 115 | VMSTATE_UINT32(int_level, PL011State), |
222 | + if (val & (1 << 16)) { | 116 | - VMSTATE_UINT32_ARRAY(read_fifo, PL011State, 16), |
223 | + do_irq = -1; | 117 | + VMSTATE_UINT32_ARRAY(read_fifo, PL011State, PL011_FIFO_DEPTH), |
224 | + } | 118 | VMSTATE_UINT32(ilpr, PL011State), |
225 | + break; | 119 | VMSTATE_UINT32(ibrd, PL011State), |
226 | + case 0x50: /* intstat */ | 120 | VMSTATE_UINT32(fbrd, PL011State), |
227 | + s->intstat = val; | ||
228 | + if (val & ((1 << 16) | (1 << 29))) { | ||
229 | + do_irq = -1; | ||
230 | + } | ||
231 | + break; | ||
232 | + case 0x1f0: /* swirq_set */ | ||
233 | + s->swirq |= val; | ||
234 | + do_irq = 1; | ||
235 | + break; | ||
236 | + case 0x1f4: /* swirq_clr */ | ||
237 | + s->swirq &= ~val; | ||
238 | + do_irq = -1; | ||
239 | + break; | ||
240 | + default: | ||
241 | + qemu_log_mask(LOG_UNIMP, "write to unknown register"); | ||
242 | + return; | ||
243 | + } | ||
244 | + | ||
245 | + if (do_irq > 0) { | ||
246 | + mphi_raise_irq(s); | ||
247 | + } else if (do_irq < 0) { | ||
248 | + mphi_lower_irq(s); | ||
249 | + } | ||
250 | +} | ||
251 | + | ||
252 | +static const MemoryRegionOps mphi_mmio_ops = { | ||
253 | + .read = mphi_reg_read, | ||
254 | + .write = mphi_reg_write, | ||
255 | + .impl.min_access_size = 4, | ||
256 | + .impl.max_access_size = 4, | ||
257 | + .endianness = DEVICE_LITTLE_ENDIAN, | ||
258 | +}; | ||
259 | + | ||
260 | +static void mphi_reset(DeviceState *dev) | ||
261 | +{ | ||
262 | + BCM2835MphiState *s = BCM2835_MPHI(dev); | ||
263 | + | ||
264 | + s->outdda = 0; | ||
265 | + s->outddb = 0; | ||
266 | + s->ctrl = 0; | ||
267 | + s->intstat = 0; | ||
268 | + s->swirq = 0; | ||
269 | +} | ||
270 | + | ||
271 | +static void mphi_realize(DeviceState *dev, Error **errp) | ||
272 | +{ | ||
273 | + SysBusDevice *sbd = SYS_BUS_DEVICE(dev); | ||
274 | + BCM2835MphiState *s = BCM2835_MPHI(dev); | ||
275 | + | ||
276 | + sysbus_init_irq(sbd, &s->irq); | ||
277 | +} | ||
278 | + | ||
279 | +static void mphi_init(Object *obj) | ||
280 | +{ | ||
281 | + SysBusDevice *sbd = SYS_BUS_DEVICE(obj); | ||
282 | + BCM2835MphiState *s = BCM2835_MPHI(obj); | ||
283 | + | ||
284 | + memory_region_init_io(&s->iomem, obj, &mphi_mmio_ops, s, "mphi", MPHI_MMIO_SIZE); | ||
285 | + sysbus_init_mmio(sbd, &s->iomem); | ||
286 | +} | ||
287 | + | ||
288 | +const VMStateDescription vmstate_mphi_state = { | ||
289 | + .name = "mphi", | ||
290 | + .version_id = 1, | ||
291 | + .minimum_version_id = 1, | ||
292 | + .fields = (VMStateField[]) { | ||
293 | + VMSTATE_UINT32(outdda, BCM2835MphiState), | ||
294 | + VMSTATE_UINT32(outddb, BCM2835MphiState), | ||
295 | + VMSTATE_UINT32(ctrl, BCM2835MphiState), | ||
296 | + VMSTATE_UINT32(intstat, BCM2835MphiState), | ||
297 | + VMSTATE_UINT32(swirq, BCM2835MphiState), | ||
298 | + VMSTATE_END_OF_LIST() | ||
299 | + } | ||
300 | +}; | ||
301 | + | ||
302 | +static void mphi_class_init(ObjectClass *klass, void *data) | ||
303 | +{ | ||
304 | + DeviceClass *dc = DEVICE_CLASS(klass); | ||
305 | + | ||
306 | + dc->realize = mphi_realize; | ||
307 | + dc->reset = mphi_reset; | ||
308 | + dc->vmsd = &vmstate_mphi_state; | ||
309 | +} | ||
310 | + | ||
311 | +static const TypeInfo bcm2835_mphi_type_info = { | ||
312 | + .name = TYPE_BCM2835_MPHI, | ||
313 | + .parent = TYPE_SYS_BUS_DEVICE, | ||
314 | + .instance_size = sizeof(BCM2835MphiState), | ||
315 | + .instance_init = mphi_init, | ||
316 | + .class_init = mphi_class_init, | ||
317 | +}; | ||
318 | + | ||
319 | +static void bcm2835_mphi_register_types(void) | ||
320 | +{ | ||
321 | + type_register_static(&bcm2835_mphi_type_info); | ||
322 | +} | ||
323 | + | ||
324 | +type_init(bcm2835_mphi_register_types) | ||
325 | diff --git a/hw/misc/Makefile.objs b/hw/misc/Makefile.objs | ||
326 | index XXXXXXX..XXXXXXX 100644 | ||
327 | --- a/hw/misc/Makefile.objs | ||
328 | +++ b/hw/misc/Makefile.objs | ||
329 | @@ -XXX,XX +XXX,XX @@ common-obj-$(CONFIG_OMAP) += omap_l4.o | ||
330 | common-obj-$(CONFIG_OMAP) += omap_sdrc.o | ||
331 | common-obj-$(CONFIG_OMAP) += omap_tap.o | ||
332 | common-obj-$(CONFIG_RASPI) += bcm2835_mbox.o | ||
333 | +common-obj-$(CONFIG_RASPI) += bcm2835_mphi.o | ||
334 | common-obj-$(CONFIG_RASPI) += bcm2835_property.o | ||
335 | common-obj-$(CONFIG_RASPI) += bcm2835_rng.o | ||
336 | common-obj-$(CONFIG_RASPI) += bcm2835_thermal.o | ||
337 | -- | 121 | -- |
338 | 2.20.1 | 122 | 2.34.1 |
339 | 123 | ||
340 | 124 | diff view generated by jsdifflib |
1 | From: Paul Zimmerman <pauldzim@gmail.com> | 1 | From: Evgeny Iakovlev <eiakovlev@linux.microsoft.com> |
---|---|---|---|
2 | 2 | ||
3 | Add the dwc-hsotg (dwc2) USB host controller emulation code. | 3 | Previous change slightly modified the way we handle data writes when |
4 | Based on hw/usb/hcd-ehci.c and hw/usb/hcd-ohci.c. | 4 | FIFO is disabled. Previously we kept incrementing read_pos and were |
5 | storing data at that position, although we only have a | ||
6 | single-register-deep FIFO now. Then we changed it to always store data | ||
7 | at pos 0. | ||
5 | 8 | ||
6 | Note that to use this with the dwc-otg driver in the Raspbian | 9 | If guest disables FIFO and the proceeds to read data, it will work out |
7 | kernel, you must pass the option "dwc_otg.fiq_fsm_enable=0" on | 10 | fine, because we still read from current read_pos before setting it to |
8 | the kernel command line. | 11 | 0. |
9 | 12 | ||
10 | Emulation of slave mode and of descriptor-DMA mode has not been | 13 | However, to make code less fragile, introduce a post_load hook for |
11 | implemented yet. These modes are seldom used. | 14 | PL011State and move fixup read FIFO state when FIFO is disabled. Since |
15 | we are introducing a post_load hook, also do some sanity checking on | ||
16 | untrusted incoming input state. | ||
12 | 17 | ||
13 | I have used some on-line sources of information while developing | 18 | Signed-off-by: Evgeny Iakovlev <eiakovlev@linux.microsoft.com> |
14 | this emulation, including: | 19 | Message-id: 20230123162304.26254-3-eiakovlev@linux.microsoft.com |
15 | |||
16 | http://www.capital-micro.com/PDF/CME-M7_Family_User_Guide_EN.pdf | ||
17 | which has a pretty complete description of the controller starting | ||
18 | on page 370. | ||
19 | |||
20 | https://sourceforge.net/p/wive-ng/wive-ng-mt/ci/master/tree/docs/DataSheets/RT3050_5x_V2.0_081408_0902.pdf | ||
21 | which has a description of the controller registers starting on | ||
22 | page 130. | ||
23 | |||
24 | Thanks to Felippe Mathieu-Daude for providing a cleaner method | ||
25 | of implementing the memory regions for the controller registers. | ||
26 | |||
27 | Signed-off-by: Paul Zimmerman <pauldzim@gmail.com> | ||
28 | Message-id: 20200520235349.21215-5-pauldzim@gmail.com | ||
29 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
30 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 20 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
31 | --- | 21 | --- |
32 | hw/usb/hcd-dwc2.c | 1417 ++++++++++++++++++++++++++++++++++++++++++ | 22 | hw/char/pl011.c | 25 +++++++++++++++++++++++++ |
33 | hw/usb/Kconfig | 5 + | 23 | 1 file changed, 25 insertions(+) |
34 | hw/usb/Makefile.objs | 1 + | ||
35 | hw/usb/trace-events | 50 ++ | ||
36 | 4 files changed, 1473 insertions(+) | ||
37 | create mode 100644 hw/usb/hcd-dwc2.c | ||
38 | 24 | ||
39 | diff --git a/hw/usb/hcd-dwc2.c b/hw/usb/hcd-dwc2.c | 25 | diff --git a/hw/char/pl011.c b/hw/char/pl011.c |
40 | new file mode 100644 | 26 | index XXXXXXX..XXXXXXX 100644 |
41 | index XXXXXXX..XXXXXXX | 27 | --- a/hw/char/pl011.c |
42 | --- /dev/null | 28 | +++ b/hw/char/pl011.c |
43 | +++ b/hw/usb/hcd-dwc2.c | 29 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_pl011_clock = { |
44 | @@ -XXX,XX +XXX,XX @@ | 30 | } |
45 | +/* | 31 | }; |
46 | + * dwc-hsotg (dwc2) USB host controller emulation | 32 | |
47 | + * | 33 | +static int pl011_post_load(void *opaque, int version_id) |
48 | + * Based on hw/usb/hcd-ehci.c and hw/usb/hcd-ohci.c | 34 | +{ |
49 | + * | 35 | + PL011State* s = opaque; |
50 | + * Note that to use this emulation with the dwc-otg driver in the | ||
51 | + * Raspbian kernel, you must pass the option "dwc_otg.fiq_fsm_enable=0" | ||
52 | + * on the kernel command line. | ||
53 | + * | ||
54 | + * Some useful documentation used to develop this emulation can be | ||
55 | + * found online (as of April 2020) at: | ||
56 | + * | ||
57 | + * http://www.capital-micro.com/PDF/CME-M7_Family_User_Guide_EN.pdf | ||
58 | + * which has a pretty complete description of the controller starting | ||
59 | + * on page 370. | ||
60 | + * | ||
61 | + * https://sourceforge.net/p/wive-ng/wive-ng-mt/ci/master/tree/docs/DataSheets/RT3050_5x_V2.0_081408_0902.pdf | ||
62 | + * which has a description of the controller registers starting on | ||
63 | + * page 130. | ||
64 | + * | ||
65 | + * Copyright (c) 2020 Paul Zimmerman <pauldzim@gmail.com> | ||
66 | + * | ||
67 | + * This program is free software; you can redistribute it and/or modify | ||
68 | + * it under the terms of the GNU General Public License as published by | ||
69 | + * the Free Software Foundation; either version 2 of the License, or | ||
70 | + * (at your option) any later version. | ||
71 | + * | ||
72 | + * This program is distributed in the hope that it will be useful, | ||
73 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
74 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
75 | + * GNU General Public License for more details. | ||
76 | + */ | ||
77 | + | 36 | + |
78 | +#include "qemu/osdep.h" | 37 | + /* Sanity-check input state */ |
79 | +#include "qemu/units.h" | 38 | + if (s->read_pos >= ARRAY_SIZE(s->read_fifo) || |
80 | +#include "qapi/error.h" | 39 | + s->read_count > ARRAY_SIZE(s->read_fifo)) { |
81 | +#include "hw/usb/dwc2-regs.h" | 40 | + return -1; |
82 | +#include "hw/usb/hcd-dwc2.h" | ||
83 | +#include "migration/vmstate.h" | ||
84 | +#include "trace.h" | ||
85 | +#include "qemu/log.h" | ||
86 | +#include "qemu/error-report.h" | ||
87 | +#include "qemu/main-loop.h" | ||
88 | +#include "hw/qdev-properties.h" | ||
89 | + | ||
90 | +#define USB_HZ_FS 12000000 | ||
91 | +#define USB_HZ_HS 96000000 | ||
92 | +#define USB_FRMINTVL 12000 | ||
93 | + | ||
94 | +/* nifty macros from Arnon's EHCI version */ | ||
95 | +#define get_field(data, field) \ | ||
96 | + (((data) & field##_MASK) >> field##_SHIFT) | ||
97 | + | ||
98 | +#define set_field(data, newval, field) do { \ | ||
99 | + uint32_t val = *(data); \ | ||
100 | + val &= ~field##_MASK; \ | ||
101 | + val |= ((newval) << field##_SHIFT) & field##_MASK; \ | ||
102 | + *(data) = val; \ | ||
103 | +} while (0) | ||
104 | + | ||
105 | +#define get_bit(data, bitmask) \ | ||
106 | + (!!((data) & (bitmask))) | ||
107 | + | ||
108 | +/* update irq line */ | ||
109 | +static inline void dwc2_update_irq(DWC2State *s) | ||
110 | +{ | ||
111 | + static int oldlevel; | ||
112 | + int level = 0; | ||
113 | + | ||
114 | + if ((s->gintsts & s->gintmsk) && (s->gahbcfg & GAHBCFG_GLBL_INTR_EN)) { | ||
115 | + level = 1; | ||
116 | + } | ||
117 | + if (level != oldlevel) { | ||
118 | + oldlevel = level; | ||
119 | + trace_usb_dwc2_update_irq(level); | ||
120 | + qemu_set_irq(s->irq, level); | ||
121 | + } | ||
122 | +} | ||
123 | + | ||
124 | +/* flag interrupt condition */ | ||
125 | +static inline void dwc2_raise_global_irq(DWC2State *s, uint32_t intr) | ||
126 | +{ | ||
127 | + if (!(s->gintsts & intr)) { | ||
128 | + s->gintsts |= intr; | ||
129 | + trace_usb_dwc2_raise_global_irq(intr); | ||
130 | + dwc2_update_irq(s); | ||
131 | + } | ||
132 | +} | ||
133 | + | ||
134 | +static inline void dwc2_lower_global_irq(DWC2State *s, uint32_t intr) | ||
135 | +{ | ||
136 | + if (s->gintsts & intr) { | ||
137 | + s->gintsts &= ~intr; | ||
138 | + trace_usb_dwc2_lower_global_irq(intr); | ||
139 | + dwc2_update_irq(s); | ||
140 | + } | ||
141 | +} | ||
142 | + | ||
143 | +static inline void dwc2_raise_host_irq(DWC2State *s, uint32_t host_intr) | ||
144 | +{ | ||
145 | + if (!(s->haint & host_intr)) { | ||
146 | + s->haint |= host_intr; | ||
147 | + s->haint &= 0xffff; | ||
148 | + trace_usb_dwc2_raise_host_irq(host_intr); | ||
149 | + if (s->haint & s->haintmsk) { | ||
150 | + dwc2_raise_global_irq(s, GINTSTS_HCHINT); | ||
151 | + } | ||
152 | + } | ||
153 | +} | ||
154 | + | ||
155 | +static inline void dwc2_lower_host_irq(DWC2State *s, uint32_t host_intr) | ||
156 | +{ | ||
157 | + if (s->haint & host_intr) { | ||
158 | + s->haint &= ~host_intr; | ||
159 | + trace_usb_dwc2_lower_host_irq(host_intr); | ||
160 | + if (!(s->haint & s->haintmsk)) { | ||
161 | + dwc2_lower_global_irq(s, GINTSTS_HCHINT); | ||
162 | + } | ||
163 | + } | ||
164 | +} | ||
165 | + | ||
166 | +static inline void dwc2_update_hc_irq(DWC2State *s, int index) | ||
167 | +{ | ||
168 | + uint32_t host_intr = 1 << (index >> 3); | ||
169 | + | ||
170 | + if (s->hreg1[index + 2] & s->hreg1[index + 3]) { | ||
171 | + dwc2_raise_host_irq(s, host_intr); | ||
172 | + } else { | ||
173 | + dwc2_lower_host_irq(s, host_intr); | ||
174 | + } | ||
175 | +} | ||
176 | + | ||
177 | +/* set a timer for EOF */ | ||
178 | +static void dwc2_eof_timer(DWC2State *s) | ||
179 | +{ | ||
180 | + timer_mod(s->eof_timer, s->sof_time + s->usb_frame_time); | ||
181 | +} | ||
182 | + | ||
183 | +/* Set a timer for EOF and generate SOF event */ | ||
184 | +static void dwc2_sof(DWC2State *s) | ||
185 | +{ | ||
186 | + s->sof_time += s->usb_frame_time; | ||
187 | + trace_usb_dwc2_sof(s->sof_time); | ||
188 | + dwc2_eof_timer(s); | ||
189 | + dwc2_raise_global_irq(s, GINTSTS_SOF); | ||
190 | +} | ||
191 | + | ||
192 | +/* Do frame processing on frame boundary */ | ||
193 | +static void dwc2_frame_boundary(void *opaque) | ||
194 | +{ | ||
195 | + DWC2State *s = opaque; | ||
196 | + int64_t now; | ||
197 | + uint16_t frcnt; | ||
198 | + | ||
199 | + now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); | ||
200 | + | ||
201 | + /* Frame boundary, so do EOF stuff here */ | ||
202 | + | ||
203 | + /* Increment frame number */ | ||
204 | + frcnt = (uint16_t)((now - s->sof_time) / s->fi); | ||
205 | + s->frame_number = (s->frame_number + frcnt) & 0xffff; | ||
206 | + s->hfnum = s->frame_number & HFNUM_MAX_FRNUM; | ||
207 | + | ||
208 | + /* Do SOF stuff here */ | ||
209 | + dwc2_sof(s); | ||
210 | +} | ||
211 | + | ||
212 | +/* Start sending SOF tokens on the USB bus */ | ||
213 | +static void dwc2_bus_start(DWC2State *s) | ||
214 | +{ | ||
215 | + trace_usb_dwc2_bus_start(); | ||
216 | + s->sof_time = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); | ||
217 | + dwc2_eof_timer(s); | ||
218 | +} | ||
219 | + | ||
220 | +/* Stop sending SOF tokens on the USB bus */ | ||
221 | +static void dwc2_bus_stop(DWC2State *s) | ||
222 | +{ | ||
223 | + trace_usb_dwc2_bus_stop(); | ||
224 | + timer_del(s->eof_timer); | ||
225 | +} | ||
226 | + | ||
227 | +static USBDevice *dwc2_find_device(DWC2State *s, uint8_t addr) | ||
228 | +{ | ||
229 | + USBDevice *dev; | ||
230 | + | ||
231 | + trace_usb_dwc2_find_device(addr); | ||
232 | + | ||
233 | + if (!(s->hprt0 & HPRT0_ENA)) { | ||
234 | + trace_usb_dwc2_port_disabled(0); | ||
235 | + } else { | ||
236 | + dev = usb_find_device(&s->uport, addr); | ||
237 | + if (dev != NULL) { | ||
238 | + trace_usb_dwc2_device_found(0); | ||
239 | + return dev; | ||
240 | + } | ||
241 | + } | 41 | + } |
242 | + | 42 | + |
243 | + trace_usb_dwc2_device_not_found(); | 43 | + if (!pl011_is_fifo_enabled(s) && s->read_count > 0 && s->read_pos > 0) { |
244 | + return NULL; | 44 | + /* |
245 | +} | 45 | + * Older versions of PL011 didn't ensure that the single |
246 | + | 46 | + * character in the FIFO in FIFO-disabled mode is in |
247 | +static const char *pstatus[] = { | 47 | + * element 0 of the array; convert to follow the current |
248 | + "USB_RET_SUCCESS", "USB_RET_NODEV", "USB_RET_NAK", "USB_RET_STALL", | 48 | + * code's assumptions. |
249 | + "USB_RET_BABBLE", "USB_RET_IOERROR", "USB_RET_ASYNC", | 49 | + */ |
250 | + "USB_RET_ADD_TO_QUEUE", "USB_RET_REMOVE_FROM_QUEUE" | 50 | + s->read_fifo[0] = s->read_fifo[s->read_pos]; |
251 | +}; | 51 | + s->read_pos = 0; |
252 | + | ||
253 | +static uint32_t pintr[] = { | ||
254 | + HCINTMSK_XFERCOMPL, HCINTMSK_XACTERR, HCINTMSK_NAK, HCINTMSK_STALL, | ||
255 | + HCINTMSK_BBLERR, HCINTMSK_XACTERR, HCINTMSK_XACTERR, HCINTMSK_XACTERR, | ||
256 | + HCINTMSK_XACTERR | ||
257 | +}; | ||
258 | + | ||
259 | +static const char *types[] = { | ||
260 | + "Ctrl", "Isoc", "Bulk", "Intr" | ||
261 | +}; | ||
262 | + | ||
263 | +static const char *dirs[] = { | ||
264 | + "Out", "In" | ||
265 | +}; | ||
266 | + | ||
267 | +static void dwc2_handle_packet(DWC2State *s, uint32_t devadr, USBDevice *dev, | ||
268 | + USBEndpoint *ep, uint32_t index, bool send) | ||
269 | +{ | ||
270 | + DWC2Packet *p; | ||
271 | + uint32_t hcchar = s->hreg1[index]; | ||
272 | + uint32_t hctsiz = s->hreg1[index + 4]; | ||
273 | + uint32_t hcdma = s->hreg1[index + 5]; | ||
274 | + uint32_t chan, epnum, epdir, eptype, mps, pid, pcnt, len, tlen, intr = 0; | ||
275 | + uint32_t tpcnt, stsidx, actual = 0; | ||
276 | + bool do_intr = false, done = false; | ||
277 | + | ||
278 | + epnum = get_field(hcchar, HCCHAR_EPNUM); | ||
279 | + epdir = get_bit(hcchar, HCCHAR_EPDIR); | ||
280 | + eptype = get_field(hcchar, HCCHAR_EPTYPE); | ||
281 | + mps = get_field(hcchar, HCCHAR_MPS); | ||
282 | + pid = get_field(hctsiz, TSIZ_SC_MC_PID); | ||
283 | + pcnt = get_field(hctsiz, TSIZ_PKTCNT); | ||
284 | + len = get_field(hctsiz, TSIZ_XFERSIZE); | ||
285 | + assert(len <= DWC2_MAX_XFER_SIZE); | ||
286 | + chan = index >> 3; | ||
287 | + p = &s->packet[chan]; | ||
288 | + | ||
289 | + trace_usb_dwc2_handle_packet(chan, dev, &p->packet, epnum, types[eptype], | ||
290 | + dirs[epdir], mps, len, pcnt); | ||
291 | + | ||
292 | + if (eptype == USB_ENDPOINT_XFER_CONTROL && pid == TSIZ_SC_MC_PID_SETUP) { | ||
293 | + pid = USB_TOKEN_SETUP; | ||
294 | + } else { | ||
295 | + pid = epdir ? USB_TOKEN_IN : USB_TOKEN_OUT; | ||
296 | + } | 52 | + } |
297 | + | 53 | + |
298 | + if (send) { | ||
299 | + tlen = len; | ||
300 | + if (p->small) { | ||
301 | + if (tlen > mps) { | ||
302 | + tlen = mps; | ||
303 | + } | ||
304 | + } | ||
305 | + | ||
306 | + if (pid != USB_TOKEN_IN) { | ||
307 | + trace_usb_dwc2_memory_read(hcdma, tlen); | ||
308 | + if (dma_memory_read(&s->dma_as, hcdma, | ||
309 | + s->usb_buf[chan], tlen) != MEMTX_OK) { | ||
310 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: dma_memory_read failed\n", | ||
311 | + __func__); | ||
312 | + } | ||
313 | + } | ||
314 | + | ||
315 | + usb_packet_init(&p->packet); | ||
316 | + usb_packet_setup(&p->packet, pid, ep, 0, hcdma, | ||
317 | + pid != USB_TOKEN_IN, true); | ||
318 | + usb_packet_addbuf(&p->packet, s->usb_buf[chan], tlen); | ||
319 | + p->async = DWC2_ASYNC_NONE; | ||
320 | + usb_handle_packet(dev, &p->packet); | ||
321 | + } else { | ||
322 | + tlen = p->len; | ||
323 | + } | ||
324 | + | ||
325 | + stsidx = -p->packet.status; | ||
326 | + assert(stsidx < sizeof(pstatus) / sizeof(*pstatus)); | ||
327 | + actual = p->packet.actual_length; | ||
328 | + trace_usb_dwc2_packet_status(pstatus[stsidx], actual); | ||
329 | + | ||
330 | +babble: | ||
331 | + if (p->packet.status != USB_RET_SUCCESS && | ||
332 | + p->packet.status != USB_RET_NAK && | ||
333 | + p->packet.status != USB_RET_STALL && | ||
334 | + p->packet.status != USB_RET_ASYNC) { | ||
335 | + trace_usb_dwc2_packet_error(pstatus[stsidx]); | ||
336 | + } | ||
337 | + | ||
338 | + if (p->packet.status == USB_RET_ASYNC) { | ||
339 | + trace_usb_dwc2_async_packet(&p->packet, chan, dev, epnum, | ||
340 | + dirs[epdir], tlen); | ||
341 | + usb_device_flush_ep_queue(dev, ep); | ||
342 | + assert(p->async != DWC2_ASYNC_INFLIGHT); | ||
343 | + p->devadr = devadr; | ||
344 | + p->epnum = epnum; | ||
345 | + p->epdir = epdir; | ||
346 | + p->mps = mps; | ||
347 | + p->pid = pid; | ||
348 | + p->index = index; | ||
349 | + p->pcnt = pcnt; | ||
350 | + p->len = tlen; | ||
351 | + p->async = DWC2_ASYNC_INFLIGHT; | ||
352 | + p->needs_service = false; | ||
353 | + return; | ||
354 | + } | ||
355 | + | ||
356 | + if (p->packet.status == USB_RET_SUCCESS) { | ||
357 | + if (actual > tlen) { | ||
358 | + p->packet.status = USB_RET_BABBLE; | ||
359 | + goto babble; | ||
360 | + } | ||
361 | + | ||
362 | + if (pid == USB_TOKEN_IN) { | ||
363 | + trace_usb_dwc2_memory_write(hcdma, actual); | ||
364 | + if (dma_memory_write(&s->dma_as, hcdma, s->usb_buf[chan], | ||
365 | + actual) != MEMTX_OK) { | ||
366 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: dma_memory_write failed\n", | ||
367 | + __func__); | ||
368 | + } | ||
369 | + } | ||
370 | + | ||
371 | + tpcnt = actual / mps; | ||
372 | + if (actual % mps) { | ||
373 | + tpcnt++; | ||
374 | + if (pid == USB_TOKEN_IN) { | ||
375 | + done = true; | ||
376 | + } | ||
377 | + } | ||
378 | + | ||
379 | + pcnt -= tpcnt < pcnt ? tpcnt : pcnt; | ||
380 | + set_field(&hctsiz, pcnt, TSIZ_PKTCNT); | ||
381 | + len -= actual < len ? actual : len; | ||
382 | + set_field(&hctsiz, len, TSIZ_XFERSIZE); | ||
383 | + s->hreg1[index + 4] = hctsiz; | ||
384 | + hcdma += actual; | ||
385 | + s->hreg1[index + 5] = hcdma; | ||
386 | + | ||
387 | + if (!pcnt || len == 0 || actual == 0) { | ||
388 | + done = true; | ||
389 | + } | ||
390 | + } else { | ||
391 | + intr |= pintr[stsidx]; | ||
392 | + if (p->packet.status == USB_RET_NAK && | ||
393 | + (eptype == USB_ENDPOINT_XFER_CONTROL || | ||
394 | + eptype == USB_ENDPOINT_XFER_BULK)) { | ||
395 | + /* | ||
396 | + * for ctrl/bulk, automatically retry on NAK, | ||
397 | + * but send the interrupt anyway | ||
398 | + */ | ||
399 | + intr &= ~HCINTMSK_RESERVED14_31; | ||
400 | + s->hreg1[index + 2] |= intr; | ||
401 | + do_intr = true; | ||
402 | + } else { | ||
403 | + intr |= HCINTMSK_CHHLTD; | ||
404 | + done = true; | ||
405 | + } | ||
406 | + } | ||
407 | + | ||
408 | + usb_packet_cleanup(&p->packet); | ||
409 | + | ||
410 | + if (done) { | ||
411 | + hcchar &= ~HCCHAR_CHENA; | ||
412 | + s->hreg1[index] = hcchar; | ||
413 | + if (!(intr & HCINTMSK_CHHLTD)) { | ||
414 | + intr |= HCINTMSK_CHHLTD | HCINTMSK_XFERCOMPL; | ||
415 | + } | ||
416 | + intr &= ~HCINTMSK_RESERVED14_31; | ||
417 | + s->hreg1[index + 2] |= intr; | ||
418 | + p->needs_service = false; | ||
419 | + trace_usb_dwc2_packet_done(pstatus[stsidx], actual, len, pcnt); | ||
420 | + dwc2_update_hc_irq(s, index); | ||
421 | + return; | ||
422 | + } | ||
423 | + | ||
424 | + p->devadr = devadr; | ||
425 | + p->epnum = epnum; | ||
426 | + p->epdir = epdir; | ||
427 | + p->mps = mps; | ||
428 | + p->pid = pid; | ||
429 | + p->index = index; | ||
430 | + p->pcnt = pcnt; | ||
431 | + p->len = len; | ||
432 | + p->needs_service = true; | ||
433 | + trace_usb_dwc2_packet_next(pstatus[stsidx], len, pcnt); | ||
434 | + if (do_intr) { | ||
435 | + dwc2_update_hc_irq(s, index); | ||
436 | + } | ||
437 | +} | ||
438 | + | ||
439 | +/* Attach or detach a device on root hub */ | ||
440 | + | ||
441 | +static const char *speeds[] = { | ||
442 | + "low", "full", "high" | ||
443 | +}; | ||
444 | + | ||
445 | +static void dwc2_attach(USBPort *port) | ||
446 | +{ | ||
447 | + DWC2State *s = port->opaque; | ||
448 | + int hispd = 0; | ||
449 | + | ||
450 | + trace_usb_dwc2_attach(port); | ||
451 | + assert(port->index == 0); | ||
452 | + | ||
453 | + if (!port->dev || !port->dev->attached) { | ||
454 | + return; | ||
455 | + } | ||
456 | + | ||
457 | + assert(port->dev->speed <= USB_SPEED_HIGH); | ||
458 | + trace_usb_dwc2_attach_speed(speeds[port->dev->speed]); | ||
459 | + s->hprt0 &= ~HPRT0_SPD_MASK; | ||
460 | + | ||
461 | + switch (port->dev->speed) { | ||
462 | + case USB_SPEED_LOW: | ||
463 | + s->hprt0 |= HPRT0_SPD_LOW_SPEED << HPRT0_SPD_SHIFT; | ||
464 | + break; | ||
465 | + case USB_SPEED_FULL: | ||
466 | + s->hprt0 |= HPRT0_SPD_FULL_SPEED << HPRT0_SPD_SHIFT; | ||
467 | + break; | ||
468 | + case USB_SPEED_HIGH: | ||
469 | + s->hprt0 |= HPRT0_SPD_HIGH_SPEED << HPRT0_SPD_SHIFT; | ||
470 | + hispd = 1; | ||
471 | + break; | ||
472 | + } | ||
473 | + | ||
474 | + if (hispd) { | ||
475 | + s->usb_frame_time = NANOSECONDS_PER_SECOND / 8000; /* 125000 */ | ||
476 | + if (NANOSECONDS_PER_SECOND >= USB_HZ_HS) { | ||
477 | + s->usb_bit_time = NANOSECONDS_PER_SECOND / USB_HZ_HS; /* 10.4 */ | ||
478 | + } else { | ||
479 | + s->usb_bit_time = 1; | ||
480 | + } | ||
481 | + } else { | ||
482 | + s->usb_frame_time = NANOSECONDS_PER_SECOND / 1000; /* 1000000 */ | ||
483 | + if (NANOSECONDS_PER_SECOND >= USB_HZ_FS) { | ||
484 | + s->usb_bit_time = NANOSECONDS_PER_SECOND / USB_HZ_FS; /* 83.3 */ | ||
485 | + } else { | ||
486 | + s->usb_bit_time = 1; | ||
487 | + } | ||
488 | + } | ||
489 | + | ||
490 | + s->fi = USB_FRMINTVL - 1; | ||
491 | + s->hprt0 |= HPRT0_CONNDET | HPRT0_CONNSTS; | ||
492 | + | ||
493 | + dwc2_bus_start(s); | ||
494 | + dwc2_raise_global_irq(s, GINTSTS_PRTINT); | ||
495 | +} | ||
496 | + | ||
497 | +static void dwc2_detach(USBPort *port) | ||
498 | +{ | ||
499 | + DWC2State *s = port->opaque; | ||
500 | + | ||
501 | + trace_usb_dwc2_detach(port); | ||
502 | + assert(port->index == 0); | ||
503 | + | ||
504 | + dwc2_bus_stop(s); | ||
505 | + | ||
506 | + s->hprt0 &= ~(HPRT0_SPD_MASK | HPRT0_SUSP | HPRT0_ENA | HPRT0_CONNSTS); | ||
507 | + s->hprt0 |= HPRT0_CONNDET | HPRT0_ENACHG; | ||
508 | + | ||
509 | + dwc2_raise_global_irq(s, GINTSTS_PRTINT); | ||
510 | +} | ||
511 | + | ||
512 | +static void dwc2_child_detach(USBPort *port, USBDevice *child) | ||
513 | +{ | ||
514 | + trace_usb_dwc2_child_detach(port, child); | ||
515 | + assert(port->index == 0); | ||
516 | +} | ||
517 | + | ||
518 | +static void dwc2_wakeup(USBPort *port) | ||
519 | +{ | ||
520 | + DWC2State *s = port->opaque; | ||
521 | + | ||
522 | + trace_usb_dwc2_wakeup(port); | ||
523 | + assert(port->index == 0); | ||
524 | + | ||
525 | + if (s->hprt0 & HPRT0_SUSP) { | ||
526 | + s->hprt0 |= HPRT0_RES; | ||
527 | + dwc2_raise_global_irq(s, GINTSTS_PRTINT); | ||
528 | + } | ||
529 | + | ||
530 | + qemu_bh_schedule(s->async_bh); | ||
531 | +} | ||
532 | + | ||
533 | +static void dwc2_async_packet_complete(USBPort *port, USBPacket *packet) | ||
534 | +{ | ||
535 | + DWC2State *s = port->opaque; | ||
536 | + DWC2Packet *p; | ||
537 | + USBDevice *dev; | ||
538 | + USBEndpoint *ep; | ||
539 | + | ||
540 | + assert(port->index == 0); | ||
541 | + p = container_of(packet, DWC2Packet, packet); | ||
542 | + dev = dwc2_find_device(s, p->devadr); | ||
543 | + ep = usb_ep_get(dev, p->pid, p->epnum); | ||
544 | + trace_usb_dwc2_async_packet_complete(port, packet, p->index >> 3, dev, | ||
545 | + p->epnum, dirs[p->epdir], p->len); | ||
546 | + assert(p->async == DWC2_ASYNC_INFLIGHT); | ||
547 | + | ||
548 | + if (packet->status == USB_RET_REMOVE_FROM_QUEUE) { | ||
549 | + usb_cancel_packet(packet); | ||
550 | + usb_packet_cleanup(packet); | ||
551 | + return; | ||
552 | + } | ||
553 | + | ||
554 | + dwc2_handle_packet(s, p->devadr, dev, ep, p->index, false); | ||
555 | + | ||
556 | + p->async = DWC2_ASYNC_FINISHED; | ||
557 | + qemu_bh_schedule(s->async_bh); | ||
558 | +} | ||
559 | + | ||
560 | +static USBPortOps dwc2_port_ops = { | ||
561 | + .attach = dwc2_attach, | ||
562 | + .detach = dwc2_detach, | ||
563 | + .child_detach = dwc2_child_detach, | ||
564 | + .wakeup = dwc2_wakeup, | ||
565 | + .complete = dwc2_async_packet_complete, | ||
566 | +}; | ||
567 | + | ||
568 | +static uint32_t dwc2_get_frame_remaining(DWC2State *s) | ||
569 | +{ | ||
570 | + uint32_t fr = 0; | ||
571 | + int64_t tks; | ||
572 | + | ||
573 | + tks = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) - s->sof_time; | ||
574 | + if (tks < 0) { | ||
575 | + tks = 0; | ||
576 | + } | ||
577 | + | ||
578 | + /* avoid muldiv if possible */ | ||
579 | + if (tks >= s->usb_frame_time) { | ||
580 | + goto out; | ||
581 | + } | ||
582 | + if (tks < s->usb_bit_time) { | ||
583 | + fr = s->fi; | ||
584 | + goto out; | ||
585 | + } | ||
586 | + | ||
587 | + /* tks = number of ns since SOF, divided by 83 (fs) or 10 (hs) */ | ||
588 | + tks = tks / s->usb_bit_time; | ||
589 | + if (tks >= (int64_t)s->fi) { | ||
590 | + goto out; | ||
591 | + } | ||
592 | + | ||
593 | + /* remaining = frame interval minus tks */ | ||
594 | + fr = (uint32_t)((int64_t)s->fi - tks); | ||
595 | + | ||
596 | +out: | ||
597 | + return fr; | ||
598 | +} | ||
599 | + | ||
600 | +static void dwc2_work_bh(void *opaque) | ||
601 | +{ | ||
602 | + DWC2State *s = opaque; | ||
603 | + DWC2Packet *p; | ||
604 | + USBDevice *dev; | ||
605 | + USBEndpoint *ep; | ||
606 | + int64_t t_now, expire_time; | ||
607 | + int chan; | ||
608 | + bool found = false; | ||
609 | + | ||
610 | + trace_usb_dwc2_work_bh(); | ||
611 | + if (s->working) { | ||
612 | + return; | ||
613 | + } | ||
614 | + s->working = true; | ||
615 | + | ||
616 | + t_now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); | ||
617 | + chan = s->next_chan; | ||
618 | + | ||
619 | + do { | ||
620 | + p = &s->packet[chan]; | ||
621 | + if (p->needs_service) { | ||
622 | + dev = dwc2_find_device(s, p->devadr); | ||
623 | + ep = usb_ep_get(dev, p->pid, p->epnum); | ||
624 | + trace_usb_dwc2_work_bh_service(s->next_chan, chan, dev, p->epnum); | ||
625 | + dwc2_handle_packet(s, p->devadr, dev, ep, p->index, true); | ||
626 | + found = true; | ||
627 | + } | ||
628 | + if (++chan == DWC2_NB_CHAN) { | ||
629 | + chan = 0; | ||
630 | + } | ||
631 | + if (found) { | ||
632 | + s->next_chan = chan; | ||
633 | + trace_usb_dwc2_work_bh_next(chan); | ||
634 | + } | ||
635 | + } while (chan != s->next_chan); | ||
636 | + | ||
637 | + if (found) { | ||
638 | + expire_time = t_now + NANOSECONDS_PER_SECOND / 4000; | ||
639 | + timer_mod(s->frame_timer, expire_time); | ||
640 | + } | ||
641 | + s->working = false; | ||
642 | +} | ||
643 | + | ||
644 | +static void dwc2_enable_chan(DWC2State *s, uint32_t index) | ||
645 | +{ | ||
646 | + USBDevice *dev; | ||
647 | + USBEndpoint *ep; | ||
648 | + uint32_t hcchar; | ||
649 | + uint32_t hctsiz; | ||
650 | + uint32_t devadr, epnum, epdir, eptype, pid, len; | ||
651 | + DWC2Packet *p; | ||
652 | + | ||
653 | + assert((index >> 3) < DWC2_NB_CHAN); | ||
654 | + p = &s->packet[index >> 3]; | ||
655 | + hcchar = s->hreg1[index]; | ||
656 | + hctsiz = s->hreg1[index + 4]; | ||
657 | + devadr = get_field(hcchar, HCCHAR_DEVADDR); | ||
658 | + epnum = get_field(hcchar, HCCHAR_EPNUM); | ||
659 | + epdir = get_bit(hcchar, HCCHAR_EPDIR); | ||
660 | + eptype = get_field(hcchar, HCCHAR_EPTYPE); | ||
661 | + pid = get_field(hctsiz, TSIZ_SC_MC_PID); | ||
662 | + len = get_field(hctsiz, TSIZ_XFERSIZE); | ||
663 | + | ||
664 | + dev = dwc2_find_device(s, devadr); | ||
665 | + | ||
666 | + trace_usb_dwc2_enable_chan(index >> 3, dev, &p->packet, epnum); | ||
667 | + if (dev == NULL) { | ||
668 | + return; | ||
669 | + } | ||
670 | + | ||
671 | + if (eptype == USB_ENDPOINT_XFER_CONTROL && pid == TSIZ_SC_MC_PID_SETUP) { | ||
672 | + pid = USB_TOKEN_SETUP; | ||
673 | + } else { | ||
674 | + pid = epdir ? USB_TOKEN_IN : USB_TOKEN_OUT; | ||
675 | + } | ||
676 | + | ||
677 | + ep = usb_ep_get(dev, pid, epnum); | ||
678 | + | ||
679 | + /* | ||
680 | + * Hack: Networking doesn't like us delivering large transfers, it kind | ||
681 | + * of works but the latency is horrible. So if the transfer is <= the mtu | ||
682 | + * size, we take that as a hint that this might be a network transfer, | ||
683 | + * and do the transfer packet-by-packet. | ||
684 | + */ | ||
685 | + if (len > 1536) { | ||
686 | + p->small = false; | ||
687 | + } else { | ||
688 | + p->small = true; | ||
689 | + } | ||
690 | + | ||
691 | + dwc2_handle_packet(s, devadr, dev, ep, index, true); | ||
692 | + qemu_bh_schedule(s->async_bh); | ||
693 | +} | ||
694 | + | ||
695 | +static const char *glbregnm[] = { | ||
696 | + "GOTGCTL ", "GOTGINT ", "GAHBCFG ", "GUSBCFG ", "GRSTCTL ", | ||
697 | + "GINTSTS ", "GINTMSK ", "GRXSTSR ", "GRXSTSP ", "GRXFSIZ ", | ||
698 | + "GNPTXFSIZ", "GNPTXSTS ", "GI2CCTL ", "GPVNDCTL ", "GGPIO ", | ||
699 | + "GUID ", "GSNPSID ", "GHWCFG1 ", "GHWCFG2 ", "GHWCFG3 ", | ||
700 | + "GHWCFG4 ", "GLPMCFG ", "GPWRDN ", "GDFIFOCFG", "GADPCTL ", | ||
701 | + "GREFCLK ", "GINTMSK2 ", "GINTSTS2 " | ||
702 | +}; | ||
703 | + | ||
704 | +static uint64_t dwc2_glbreg_read(void *ptr, hwaddr addr, int index, | ||
705 | + unsigned size) | ||
706 | +{ | ||
707 | + DWC2State *s = ptr; | ||
708 | + uint32_t val; | ||
709 | + | ||
710 | + assert(addr <= GINTSTS2); | ||
711 | + val = s->glbreg[index]; | ||
712 | + | ||
713 | + switch (addr) { | ||
714 | + case GRSTCTL: | ||
715 | + /* clear any self-clearing bits that were set */ | ||
716 | + val &= ~(GRSTCTL_TXFFLSH | GRSTCTL_RXFFLSH | GRSTCTL_IN_TKNQ_FLSH | | ||
717 | + GRSTCTL_FRMCNTRRST | GRSTCTL_HSFTRST | GRSTCTL_CSFTRST); | ||
718 | + s->glbreg[index] = val; | ||
719 | + break; | ||
720 | + default: | ||
721 | + break; | ||
722 | + } | ||
723 | + | ||
724 | + trace_usb_dwc2_glbreg_read(addr, glbregnm[index], val); | ||
725 | + return val; | ||
726 | +} | ||
727 | + | ||
728 | +static void dwc2_glbreg_write(void *ptr, hwaddr addr, int index, uint64_t val, | ||
729 | + unsigned size) | ||
730 | +{ | ||
731 | + DWC2State *s = ptr; | ||
732 | + uint64_t orig = val; | ||
733 | + uint32_t *mmio; | ||
734 | + uint32_t old; | ||
735 | + int iflg = 0; | ||
736 | + | ||
737 | + assert(addr <= GINTSTS2); | ||
738 | + mmio = &s->glbreg[index]; | ||
739 | + old = *mmio; | ||
740 | + | ||
741 | + switch (addr) { | ||
742 | + case GOTGCTL: | ||
743 | + /* don't allow setting of read-only bits */ | ||
744 | + val &= ~(GOTGCTL_MULT_VALID_BC_MASK | GOTGCTL_BSESVLD | | ||
745 | + GOTGCTL_ASESVLD | GOTGCTL_DBNC_SHORT | GOTGCTL_CONID_B | | ||
746 | + GOTGCTL_HSTNEGSCS | GOTGCTL_SESREQSCS); | ||
747 | + /* don't allow clearing of read-only bits */ | ||
748 | + val |= old & (GOTGCTL_MULT_VALID_BC_MASK | GOTGCTL_BSESVLD | | ||
749 | + GOTGCTL_ASESVLD | GOTGCTL_DBNC_SHORT | GOTGCTL_CONID_B | | ||
750 | + GOTGCTL_HSTNEGSCS | GOTGCTL_SESREQSCS); | ||
751 | + break; | ||
752 | + case GAHBCFG: | ||
753 | + if ((val & GAHBCFG_GLBL_INTR_EN) && !(old & GAHBCFG_GLBL_INTR_EN)) { | ||
754 | + iflg = 1; | ||
755 | + } | ||
756 | + break; | ||
757 | + case GRSTCTL: | ||
758 | + val |= GRSTCTL_AHBIDLE; | ||
759 | + val &= ~GRSTCTL_DMAREQ; | ||
760 | + if (!(old & GRSTCTL_TXFFLSH) && (val & GRSTCTL_TXFFLSH)) { | ||
761 | + /* TODO - TX fifo flush */ | ||
762 | + qemu_log_mask(LOG_UNIMP, "Tx FIFO flush not implemented\n"); | ||
763 | + } | ||
764 | + if (!(old & GRSTCTL_RXFFLSH) && (val & GRSTCTL_RXFFLSH)) { | ||
765 | + /* TODO - RX fifo flush */ | ||
766 | + qemu_log_mask(LOG_UNIMP, "Rx FIFO flush not implemented\n"); | ||
767 | + } | ||
768 | + if (!(old & GRSTCTL_IN_TKNQ_FLSH) && (val & GRSTCTL_IN_TKNQ_FLSH)) { | ||
769 | + /* TODO - device IN token queue flush */ | ||
770 | + qemu_log_mask(LOG_UNIMP, "Token queue flush not implemented\n"); | ||
771 | + } | ||
772 | + if (!(old & GRSTCTL_FRMCNTRRST) && (val & GRSTCTL_FRMCNTRRST)) { | ||
773 | + /* TODO - host frame counter reset */ | ||
774 | + qemu_log_mask(LOG_UNIMP, "Frame counter reset not implemented\n"); | ||
775 | + } | ||
776 | + if (!(old & GRSTCTL_HSFTRST) && (val & GRSTCTL_HSFTRST)) { | ||
777 | + /* TODO - host soft reset */ | ||
778 | + qemu_log_mask(LOG_UNIMP, "Host soft reset not implemented\n"); | ||
779 | + } | ||
780 | + if (!(old & GRSTCTL_CSFTRST) && (val & GRSTCTL_CSFTRST)) { | ||
781 | + /* TODO - core soft reset */ | ||
782 | + qemu_log_mask(LOG_UNIMP, "Core soft reset not implemented\n"); | ||
783 | + } | ||
784 | + /* don't allow clearing of self-clearing bits */ | ||
785 | + val |= old & (GRSTCTL_TXFFLSH | GRSTCTL_RXFFLSH | | ||
786 | + GRSTCTL_IN_TKNQ_FLSH | GRSTCTL_FRMCNTRRST | | ||
787 | + GRSTCTL_HSFTRST | GRSTCTL_CSFTRST); | ||
788 | + break; | ||
789 | + case GINTSTS: | ||
790 | + /* clear the write-1-to-clear bits */ | ||
791 | + val |= ~old; | ||
792 | + val = ~val; | ||
793 | + /* don't allow clearing of read-only bits */ | ||
794 | + val |= old & (GINTSTS_PTXFEMP | GINTSTS_HCHINT | GINTSTS_PRTINT | | ||
795 | + GINTSTS_OEPINT | GINTSTS_IEPINT | GINTSTS_GOUTNAKEFF | | ||
796 | + GINTSTS_GINNAKEFF | GINTSTS_NPTXFEMP | GINTSTS_RXFLVL | | ||
797 | + GINTSTS_OTGINT | GINTSTS_CURMODE_HOST); | ||
798 | + iflg = 1; | ||
799 | + break; | ||
800 | + case GINTMSK: | ||
801 | + iflg = 1; | ||
802 | + break; | ||
803 | + default: | ||
804 | + break; | ||
805 | + } | ||
806 | + | ||
807 | + trace_usb_dwc2_glbreg_write(addr, glbregnm[index], orig, old, val); | ||
808 | + *mmio = val; | ||
809 | + | ||
810 | + if (iflg) { | ||
811 | + dwc2_update_irq(s); | ||
812 | + } | ||
813 | +} | ||
814 | + | ||
815 | +static uint64_t dwc2_fszreg_read(void *ptr, hwaddr addr, int index, | ||
816 | + unsigned size) | ||
817 | +{ | ||
818 | + DWC2State *s = ptr; | ||
819 | + uint32_t val; | ||
820 | + | ||
821 | + assert(addr == HPTXFSIZ); | ||
822 | + val = s->fszreg[index]; | ||
823 | + | ||
824 | + trace_usb_dwc2_fszreg_read(addr, val); | ||
825 | + return val; | ||
826 | +} | ||
827 | + | ||
828 | +static void dwc2_fszreg_write(void *ptr, hwaddr addr, int index, uint64_t val, | ||
829 | + unsigned size) | ||
830 | +{ | ||
831 | + DWC2State *s = ptr; | ||
832 | + uint64_t orig = val; | ||
833 | + uint32_t *mmio; | ||
834 | + uint32_t old; | ||
835 | + | ||
836 | + assert(addr == HPTXFSIZ); | ||
837 | + mmio = &s->fszreg[index]; | ||
838 | + old = *mmio; | ||
839 | + | ||
840 | + trace_usb_dwc2_fszreg_write(addr, orig, old, val); | ||
841 | + *mmio = val; | ||
842 | +} | ||
843 | + | ||
844 | +static const char *hreg0nm[] = { | ||
845 | + "HCFG ", "HFIR ", "HFNUM ", "<rsvd> ", "HPTXSTS ", | ||
846 | + "HAINT ", "HAINTMSK ", "HFLBADDR ", "<rsvd> ", "<rsvd> ", | ||
847 | + "<rsvd> ", "<rsvd> ", "<rsvd> ", "<rsvd> ", "<rsvd> ", | ||
848 | + "<rsvd> ", "HPRT0 " | ||
849 | +}; | ||
850 | + | ||
851 | +static uint64_t dwc2_hreg0_read(void *ptr, hwaddr addr, int index, | ||
852 | + unsigned size) | ||
853 | +{ | ||
854 | + DWC2State *s = ptr; | ||
855 | + uint32_t val; | ||
856 | + | ||
857 | + assert(addr >= HCFG && addr <= HPRT0); | ||
858 | + val = s->hreg0[index]; | ||
859 | + | ||
860 | + switch (addr) { | ||
861 | + case HFNUM: | ||
862 | + val = (dwc2_get_frame_remaining(s) << HFNUM_FRREM_SHIFT) | | ||
863 | + (s->hfnum << HFNUM_FRNUM_SHIFT); | ||
864 | + break; | ||
865 | + default: | ||
866 | + break; | ||
867 | + } | ||
868 | + | ||
869 | + trace_usb_dwc2_hreg0_read(addr, hreg0nm[index], val); | ||
870 | + return val; | ||
871 | +} | ||
872 | + | ||
873 | +static void dwc2_hreg0_write(void *ptr, hwaddr addr, int index, uint64_t val, | ||
874 | + unsigned size) | ||
875 | +{ | ||
876 | + DWC2State *s = ptr; | ||
877 | + USBDevice *dev = s->uport.dev; | ||
878 | + uint64_t orig = val; | ||
879 | + uint32_t *mmio; | ||
880 | + uint32_t tval, told, old; | ||
881 | + int prst = 0; | ||
882 | + int iflg = 0; | ||
883 | + | ||
884 | + assert(addr >= HCFG && addr <= HPRT0); | ||
885 | + mmio = &s->hreg0[index]; | ||
886 | + old = *mmio; | ||
887 | + | ||
888 | + switch (addr) { | ||
889 | + case HFIR: | ||
890 | + break; | ||
891 | + case HFNUM: | ||
892 | + case HPTXSTS: | ||
893 | + case HAINT: | ||
894 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: write to read-only register\n", | ||
895 | + __func__); | ||
896 | + return; | ||
897 | + case HAINTMSK: | ||
898 | + val &= 0xffff; | ||
899 | + break; | ||
900 | + case HPRT0: | ||
901 | + /* don't allow clearing of read-only bits */ | ||
902 | + val |= old & (HPRT0_SPD_MASK | HPRT0_LNSTS_MASK | HPRT0_OVRCURRACT | | ||
903 | + HPRT0_CONNSTS); | ||
904 | + /* don't allow clearing of self-clearing bits */ | ||
905 | + val |= old & (HPRT0_SUSP | HPRT0_RES); | ||
906 | + /* don't allow setting of self-setting bits */ | ||
907 | + if (!(old & HPRT0_ENA) && (val & HPRT0_ENA)) { | ||
908 | + val &= ~HPRT0_ENA; | ||
909 | + } | ||
910 | + /* clear the write-1-to-clear bits */ | ||
911 | + tval = val & (HPRT0_OVRCURRCHG | HPRT0_ENACHG | HPRT0_ENA | | ||
912 | + HPRT0_CONNDET); | ||
913 | + told = old & (HPRT0_OVRCURRCHG | HPRT0_ENACHG | HPRT0_ENA | | ||
914 | + HPRT0_CONNDET); | ||
915 | + tval |= ~told; | ||
916 | + tval = ~tval; | ||
917 | + tval &= (HPRT0_OVRCURRCHG | HPRT0_ENACHG | HPRT0_ENA | | ||
918 | + HPRT0_CONNDET); | ||
919 | + val &= ~(HPRT0_OVRCURRCHG | HPRT0_ENACHG | HPRT0_ENA | | ||
920 | + HPRT0_CONNDET); | ||
921 | + val |= tval; | ||
922 | + if (!(val & HPRT0_RST) && (old & HPRT0_RST)) { | ||
923 | + if (dev && dev->attached) { | ||
924 | + val |= HPRT0_ENA | HPRT0_ENACHG; | ||
925 | + prst = 1; | ||
926 | + } | ||
927 | + } | ||
928 | + if (val & (HPRT0_OVRCURRCHG | HPRT0_ENACHG | HPRT0_CONNDET)) { | ||
929 | + iflg = 1; | ||
930 | + } else { | ||
931 | + iflg = -1; | ||
932 | + } | ||
933 | + break; | ||
934 | + default: | ||
935 | + break; | ||
936 | + } | ||
937 | + | ||
938 | + if (prst) { | ||
939 | + trace_usb_dwc2_hreg0_write(addr, hreg0nm[index], orig, old, | ||
940 | + val & ~HPRT0_CONNDET); | ||
941 | + trace_usb_dwc2_hreg0_action("call usb_port_reset"); | ||
942 | + usb_port_reset(&s->uport); | ||
943 | + val &= ~HPRT0_CONNDET; | ||
944 | + } else { | ||
945 | + trace_usb_dwc2_hreg0_write(addr, hreg0nm[index], orig, old, val); | ||
946 | + } | ||
947 | + | ||
948 | + *mmio = val; | ||
949 | + | ||
950 | + if (iflg > 0) { | ||
951 | + trace_usb_dwc2_hreg0_action("enable PRTINT"); | ||
952 | + dwc2_raise_global_irq(s, GINTSTS_PRTINT); | ||
953 | + } else if (iflg < 0) { | ||
954 | + trace_usb_dwc2_hreg0_action("disable PRTINT"); | ||
955 | + dwc2_lower_global_irq(s, GINTSTS_PRTINT); | ||
956 | + } | ||
957 | +} | ||
958 | + | ||
959 | +static const char *hreg1nm[] = { | ||
960 | + "HCCHAR ", "HCSPLT ", "HCINT ", "HCINTMSK", "HCTSIZ ", "HCDMA ", | ||
961 | + "<rsvd> ", "HCDMAB " | ||
962 | +}; | ||
963 | + | ||
964 | +static uint64_t dwc2_hreg1_read(void *ptr, hwaddr addr, int index, | ||
965 | + unsigned size) | ||
966 | +{ | ||
967 | + DWC2State *s = ptr; | ||
968 | + uint32_t val; | ||
969 | + | ||
970 | + assert(addr >= HCCHAR(0) && addr <= HCDMAB(DWC2_NB_CHAN - 1)); | ||
971 | + val = s->hreg1[index]; | ||
972 | + | ||
973 | + trace_usb_dwc2_hreg1_read(addr, hreg1nm[index & 7], addr >> 5, val); | ||
974 | + return val; | ||
975 | +} | ||
976 | + | ||
977 | +static void dwc2_hreg1_write(void *ptr, hwaddr addr, int index, uint64_t val, | ||
978 | + unsigned size) | ||
979 | +{ | ||
980 | + DWC2State *s = ptr; | ||
981 | + uint64_t orig = val; | ||
982 | + uint32_t *mmio; | ||
983 | + uint32_t old; | ||
984 | + int iflg = 0; | ||
985 | + int enflg = 0; | ||
986 | + int disflg = 0; | ||
987 | + | ||
988 | + assert(addr >= HCCHAR(0) && addr <= HCDMAB(DWC2_NB_CHAN - 1)); | ||
989 | + mmio = &s->hreg1[index]; | ||
990 | + old = *mmio; | ||
991 | + | ||
992 | + switch (HSOTG_REG(0x500) + (addr & 0x1c)) { | ||
993 | + case HCCHAR(0): | ||
994 | + if ((val & HCCHAR_CHDIS) && !(old & HCCHAR_CHDIS)) { | ||
995 | + val &= ~(HCCHAR_CHENA | HCCHAR_CHDIS); | ||
996 | + disflg = 1; | ||
997 | + } else { | ||
998 | + val |= old & HCCHAR_CHDIS; | ||
999 | + if ((val & HCCHAR_CHENA) && !(old & HCCHAR_CHENA)) { | ||
1000 | + val &= ~HCCHAR_CHDIS; | ||
1001 | + enflg = 1; | ||
1002 | + } else { | ||
1003 | + val |= old & HCCHAR_CHENA; | ||
1004 | + } | ||
1005 | + } | ||
1006 | + break; | ||
1007 | + case HCINT(0): | ||
1008 | + /* clear the write-1-to-clear bits */ | ||
1009 | + val |= ~old; | ||
1010 | + val = ~val; | ||
1011 | + val &= ~HCINTMSK_RESERVED14_31; | ||
1012 | + iflg = 1; | ||
1013 | + break; | ||
1014 | + case HCINTMSK(0): | ||
1015 | + val &= ~HCINTMSK_RESERVED14_31; | ||
1016 | + iflg = 1; | ||
1017 | + break; | ||
1018 | + case HCDMAB(0): | ||
1019 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: write to read-only register\n", | ||
1020 | + __func__); | ||
1021 | + return; | ||
1022 | + default: | ||
1023 | + break; | ||
1024 | + } | ||
1025 | + | ||
1026 | + trace_usb_dwc2_hreg1_write(addr, hreg1nm[index & 7], index >> 3, orig, | ||
1027 | + old, val); | ||
1028 | + *mmio = val; | ||
1029 | + | ||
1030 | + if (disflg) { | ||
1031 | + /* set ChHltd in HCINT */ | ||
1032 | + s->hreg1[(index & ~7) + 2] |= HCINTMSK_CHHLTD; | ||
1033 | + iflg = 1; | ||
1034 | + } | ||
1035 | + | ||
1036 | + if (enflg) { | ||
1037 | + dwc2_enable_chan(s, index & ~7); | ||
1038 | + } | ||
1039 | + | ||
1040 | + if (iflg) { | ||
1041 | + dwc2_update_hc_irq(s, index & ~7); | ||
1042 | + } | ||
1043 | +} | ||
1044 | + | ||
1045 | +static const char *pcgregnm[] = { | ||
1046 | + "PCGCTL ", "PCGCCTL1 " | ||
1047 | +}; | ||
1048 | + | ||
1049 | +static uint64_t dwc2_pcgreg_read(void *ptr, hwaddr addr, int index, | ||
1050 | + unsigned size) | ||
1051 | +{ | ||
1052 | + DWC2State *s = ptr; | ||
1053 | + uint32_t val; | ||
1054 | + | ||
1055 | + assert(addr >= PCGCTL && addr <= PCGCCTL1); | ||
1056 | + val = s->pcgreg[index]; | ||
1057 | + | ||
1058 | + trace_usb_dwc2_pcgreg_read(addr, pcgregnm[index], val); | ||
1059 | + return val; | ||
1060 | +} | ||
1061 | + | ||
1062 | +static void dwc2_pcgreg_write(void *ptr, hwaddr addr, int index, | ||
1063 | + uint64_t val, unsigned size) | ||
1064 | +{ | ||
1065 | + DWC2State *s = ptr; | ||
1066 | + uint64_t orig = val; | ||
1067 | + uint32_t *mmio; | ||
1068 | + uint32_t old; | ||
1069 | + | ||
1070 | + assert(addr >= PCGCTL && addr <= PCGCCTL1); | ||
1071 | + mmio = &s->pcgreg[index]; | ||
1072 | + old = *mmio; | ||
1073 | + | ||
1074 | + trace_usb_dwc2_pcgreg_write(addr, pcgregnm[index], orig, old, val); | ||
1075 | + *mmio = val; | ||
1076 | +} | ||
1077 | + | ||
1078 | +static uint64_t dwc2_hsotg_read(void *ptr, hwaddr addr, unsigned size) | ||
1079 | +{ | ||
1080 | + uint64_t val; | ||
1081 | + | ||
1082 | + switch (addr) { | ||
1083 | + case HSOTG_REG(0x000) ... HSOTG_REG(0x0fc): | ||
1084 | + val = dwc2_glbreg_read(ptr, addr, (addr - HSOTG_REG(0x000)) >> 2, size); | ||
1085 | + break; | ||
1086 | + case HSOTG_REG(0x100): | ||
1087 | + val = dwc2_fszreg_read(ptr, addr, (addr - HSOTG_REG(0x100)) >> 2, size); | ||
1088 | + break; | ||
1089 | + case HSOTG_REG(0x104) ... HSOTG_REG(0x3fc): | ||
1090 | + /* Gadget-mode registers, just return 0 for now */ | ||
1091 | + val = 0; | ||
1092 | + break; | ||
1093 | + case HSOTG_REG(0x400) ... HSOTG_REG(0x4fc): | ||
1094 | + val = dwc2_hreg0_read(ptr, addr, (addr - HSOTG_REG(0x400)) >> 2, size); | ||
1095 | + break; | ||
1096 | + case HSOTG_REG(0x500) ... HSOTG_REG(0x7fc): | ||
1097 | + val = dwc2_hreg1_read(ptr, addr, (addr - HSOTG_REG(0x500)) >> 2, size); | ||
1098 | + break; | ||
1099 | + case HSOTG_REG(0x800) ... HSOTG_REG(0xdfc): | ||
1100 | + /* Gadget-mode registers, just return 0 for now */ | ||
1101 | + val = 0; | ||
1102 | + break; | ||
1103 | + case HSOTG_REG(0xe00) ... HSOTG_REG(0xffc): | ||
1104 | + val = dwc2_pcgreg_read(ptr, addr, (addr - HSOTG_REG(0xe00)) >> 2, size); | ||
1105 | + break; | ||
1106 | + default: | ||
1107 | + g_assert_not_reached(); | ||
1108 | + } | ||
1109 | + | ||
1110 | + return val; | ||
1111 | +} | ||
1112 | + | ||
1113 | +static void dwc2_hsotg_write(void *ptr, hwaddr addr, uint64_t val, | ||
1114 | + unsigned size) | ||
1115 | +{ | ||
1116 | + switch (addr) { | ||
1117 | + case HSOTG_REG(0x000) ... HSOTG_REG(0x0fc): | ||
1118 | + dwc2_glbreg_write(ptr, addr, (addr - HSOTG_REG(0x000)) >> 2, val, size); | ||
1119 | + break; | ||
1120 | + case HSOTG_REG(0x100): | ||
1121 | + dwc2_fszreg_write(ptr, addr, (addr - HSOTG_REG(0x100)) >> 2, val, size); | ||
1122 | + break; | ||
1123 | + case HSOTG_REG(0x104) ... HSOTG_REG(0x3fc): | ||
1124 | + /* Gadget-mode registers, do nothing for now */ | ||
1125 | + break; | ||
1126 | + case HSOTG_REG(0x400) ... HSOTG_REG(0x4fc): | ||
1127 | + dwc2_hreg0_write(ptr, addr, (addr - HSOTG_REG(0x400)) >> 2, val, size); | ||
1128 | + break; | ||
1129 | + case HSOTG_REG(0x500) ... HSOTG_REG(0x7fc): | ||
1130 | + dwc2_hreg1_write(ptr, addr, (addr - HSOTG_REG(0x500)) >> 2, val, size); | ||
1131 | + break; | ||
1132 | + case HSOTG_REG(0x800) ... HSOTG_REG(0xdfc): | ||
1133 | + /* Gadget-mode registers, do nothing for now */ | ||
1134 | + break; | ||
1135 | + case HSOTG_REG(0xe00) ... HSOTG_REG(0xffc): | ||
1136 | + dwc2_pcgreg_write(ptr, addr, (addr - HSOTG_REG(0xe00)) >> 2, val, size); | ||
1137 | + break; | ||
1138 | + default: | ||
1139 | + g_assert_not_reached(); | ||
1140 | + } | ||
1141 | +} | ||
1142 | + | ||
1143 | +static const MemoryRegionOps dwc2_mmio_hsotg_ops = { | ||
1144 | + .read = dwc2_hsotg_read, | ||
1145 | + .write = dwc2_hsotg_write, | ||
1146 | + .impl.min_access_size = 4, | ||
1147 | + .impl.max_access_size = 4, | ||
1148 | + .endianness = DEVICE_LITTLE_ENDIAN, | ||
1149 | +}; | ||
1150 | + | ||
1151 | +static uint64_t dwc2_hreg2_read(void *ptr, hwaddr addr, unsigned size) | ||
1152 | +{ | ||
1153 | + /* TODO - implement FIFOs to support slave mode */ | ||
1154 | + trace_usb_dwc2_hreg2_read(addr, addr >> 12, 0); | ||
1155 | + qemu_log_mask(LOG_UNIMP, "FIFO read not implemented\n"); | ||
1156 | + return 0; | 54 | + return 0; |
1157 | +} | 55 | +} |
1158 | + | 56 | + |
1159 | +static void dwc2_hreg2_write(void *ptr, hwaddr addr, uint64_t val, | 57 | static const VMStateDescription vmstate_pl011 = { |
1160 | + unsigned size) | 58 | .name = "pl011", |
1161 | +{ | 59 | .version_id = 2, |
1162 | + uint64_t orig = val; | 60 | .minimum_version_id = 2, |
1163 | + | 61 | + .post_load = pl011_post_load, |
1164 | + /* TODO - implement FIFOs to support slave mode */ | 62 | .fields = (VMStateField[]) { |
1165 | + trace_usb_dwc2_hreg2_write(addr, addr >> 12, orig, 0, val); | 63 | VMSTATE_UINT32(readbuff, PL011State), |
1166 | + qemu_log_mask(LOG_UNIMP, "FIFO write not implemented\n"); | 64 | VMSTATE_UINT32(flags, PL011State), |
1167 | +} | ||
1168 | + | ||
1169 | +static const MemoryRegionOps dwc2_mmio_hreg2_ops = { | ||
1170 | + .read = dwc2_hreg2_read, | ||
1171 | + .write = dwc2_hreg2_write, | ||
1172 | + .impl.min_access_size = 4, | ||
1173 | + .impl.max_access_size = 4, | ||
1174 | + .endianness = DEVICE_LITTLE_ENDIAN, | ||
1175 | +}; | ||
1176 | + | ||
1177 | +static void dwc2_wakeup_endpoint(USBBus *bus, USBEndpoint *ep, | ||
1178 | + unsigned int stream) | ||
1179 | +{ | ||
1180 | + DWC2State *s = container_of(bus, DWC2State, bus); | ||
1181 | + | ||
1182 | + trace_usb_dwc2_wakeup_endpoint(ep, stream); | ||
1183 | + | ||
1184 | + /* TODO - do something here? */ | ||
1185 | + qemu_bh_schedule(s->async_bh); | ||
1186 | +} | ||
1187 | + | ||
1188 | +static USBBusOps dwc2_bus_ops = { | ||
1189 | + .wakeup_endpoint = dwc2_wakeup_endpoint, | ||
1190 | +}; | ||
1191 | + | ||
1192 | +static void dwc2_work_timer(void *opaque) | ||
1193 | +{ | ||
1194 | + DWC2State *s = opaque; | ||
1195 | + | ||
1196 | + trace_usb_dwc2_work_timer(); | ||
1197 | + qemu_bh_schedule(s->async_bh); | ||
1198 | +} | ||
1199 | + | ||
1200 | +static void dwc2_reset_enter(Object *obj, ResetType type) | ||
1201 | +{ | ||
1202 | + DWC2Class *c = DWC2_GET_CLASS(obj); | ||
1203 | + DWC2State *s = DWC2_USB(obj); | ||
1204 | + int i; | ||
1205 | + | ||
1206 | + trace_usb_dwc2_reset_enter(); | ||
1207 | + | ||
1208 | + if (c->parent_phases.enter) { | ||
1209 | + c->parent_phases.enter(obj, type); | ||
1210 | + } | ||
1211 | + | ||
1212 | + timer_del(s->frame_timer); | ||
1213 | + qemu_bh_cancel(s->async_bh); | ||
1214 | + | ||
1215 | + if (s->uport.dev && s->uport.dev->attached) { | ||
1216 | + usb_detach(&s->uport); | ||
1217 | + } | ||
1218 | + | ||
1219 | + dwc2_bus_stop(s); | ||
1220 | + | ||
1221 | + s->gotgctl = GOTGCTL_BSESVLD | GOTGCTL_ASESVLD | GOTGCTL_CONID_B; | ||
1222 | + s->gotgint = 0; | ||
1223 | + s->gahbcfg = 0; | ||
1224 | + s->gusbcfg = 5 << GUSBCFG_USBTRDTIM_SHIFT; | ||
1225 | + s->grstctl = GRSTCTL_AHBIDLE; | ||
1226 | + s->gintsts = GINTSTS_CONIDSTSCHNG | GINTSTS_PTXFEMP | GINTSTS_NPTXFEMP | | ||
1227 | + GINTSTS_CURMODE_HOST; | ||
1228 | + s->gintmsk = 0; | ||
1229 | + s->grxstsr = 0; | ||
1230 | + s->grxstsp = 0; | ||
1231 | + s->grxfsiz = 1024; | ||
1232 | + s->gnptxfsiz = 1024 << FIFOSIZE_DEPTH_SHIFT; | ||
1233 | + s->gnptxsts = (4 << FIFOSIZE_DEPTH_SHIFT) | 1024; | ||
1234 | + s->gi2cctl = GI2CCTL_I2CDATSE0 | GI2CCTL_ACK; | ||
1235 | + s->gpvndctl = 0; | ||
1236 | + s->ggpio = 0; | ||
1237 | + s->guid = 0; | ||
1238 | + s->gsnpsid = 0x4f54294a; | ||
1239 | + s->ghwcfg1 = 0; | ||
1240 | + s->ghwcfg2 = (8 << GHWCFG2_DEV_TOKEN_Q_DEPTH_SHIFT) | | ||
1241 | + (4 << GHWCFG2_HOST_PERIO_TX_Q_DEPTH_SHIFT) | | ||
1242 | + (4 << GHWCFG2_NONPERIO_TX_Q_DEPTH_SHIFT) | | ||
1243 | + GHWCFG2_DYNAMIC_FIFO | | ||
1244 | + GHWCFG2_PERIO_EP_SUPPORTED | | ||
1245 | + ((DWC2_NB_CHAN - 1) << GHWCFG2_NUM_HOST_CHAN_SHIFT) | | ||
1246 | + (GHWCFG2_INT_DMA_ARCH << GHWCFG2_ARCHITECTURE_SHIFT) | | ||
1247 | + (GHWCFG2_OP_MODE_NO_SRP_CAPABLE_HOST << GHWCFG2_OP_MODE_SHIFT); | ||
1248 | + s->ghwcfg3 = (4096 << GHWCFG3_DFIFO_DEPTH_SHIFT) | | ||
1249 | + (4 << GHWCFG3_PACKET_SIZE_CNTR_WIDTH_SHIFT) | | ||
1250 | + (4 << GHWCFG3_XFER_SIZE_CNTR_WIDTH_SHIFT); | ||
1251 | + s->ghwcfg4 = 0; | ||
1252 | + s->glpmcfg = 0; | ||
1253 | + s->gpwrdn = GPWRDN_PWRDNRSTN; | ||
1254 | + s->gdfifocfg = 0; | ||
1255 | + s->gadpctl = 0; | ||
1256 | + s->grefclk = 0; | ||
1257 | + s->gintmsk2 = 0; | ||
1258 | + s->gintsts2 = 0; | ||
1259 | + | ||
1260 | + s->hptxfsiz = 500 << FIFOSIZE_DEPTH_SHIFT; | ||
1261 | + | ||
1262 | + s->hcfg = 2 << HCFG_RESVALID_SHIFT; | ||
1263 | + s->hfir = 60000; | ||
1264 | + s->hfnum = 0x3fff; | ||
1265 | + s->hptxsts = (16 << TXSTS_QSPCAVAIL_SHIFT) | 32768; | ||
1266 | + s->haint = 0; | ||
1267 | + s->haintmsk = 0; | ||
1268 | + s->hprt0 = 0; | ||
1269 | + | ||
1270 | + memset(s->hreg1, 0, sizeof(s->hreg1)); | ||
1271 | + memset(s->pcgreg, 0, sizeof(s->pcgreg)); | ||
1272 | + | ||
1273 | + s->sof_time = 0; | ||
1274 | + s->frame_number = 0; | ||
1275 | + s->fi = USB_FRMINTVL - 1; | ||
1276 | + s->next_chan = 0; | ||
1277 | + s->working = false; | ||
1278 | + | ||
1279 | + for (i = 0; i < DWC2_NB_CHAN; i++) { | ||
1280 | + s->packet[i].needs_service = false; | ||
1281 | + } | ||
1282 | +} | ||
1283 | + | ||
1284 | +static void dwc2_reset_hold(Object *obj) | ||
1285 | +{ | ||
1286 | + DWC2Class *c = DWC2_GET_CLASS(obj); | ||
1287 | + DWC2State *s = DWC2_USB(obj); | ||
1288 | + | ||
1289 | + trace_usb_dwc2_reset_hold(); | ||
1290 | + | ||
1291 | + if (c->parent_phases.hold) { | ||
1292 | + c->parent_phases.hold(obj); | ||
1293 | + } | ||
1294 | + | ||
1295 | + dwc2_update_irq(s); | ||
1296 | +} | ||
1297 | + | ||
1298 | +static void dwc2_reset_exit(Object *obj) | ||
1299 | +{ | ||
1300 | + DWC2Class *c = DWC2_GET_CLASS(obj); | ||
1301 | + DWC2State *s = DWC2_USB(obj); | ||
1302 | + | ||
1303 | + trace_usb_dwc2_reset_exit(); | ||
1304 | + | ||
1305 | + if (c->parent_phases.exit) { | ||
1306 | + c->parent_phases.exit(obj); | ||
1307 | + } | ||
1308 | + | ||
1309 | + s->hprt0 = HPRT0_PWR; | ||
1310 | + if (s->uport.dev && s->uport.dev->attached) { | ||
1311 | + usb_attach(&s->uport); | ||
1312 | + usb_device_reset(s->uport.dev); | ||
1313 | + } | ||
1314 | +} | ||
1315 | + | ||
1316 | +static void dwc2_realize(DeviceState *dev, Error **errp) | ||
1317 | +{ | ||
1318 | + SysBusDevice *sbd = SYS_BUS_DEVICE(dev); | ||
1319 | + DWC2State *s = DWC2_USB(dev); | ||
1320 | + Object *obj; | ||
1321 | + Error *err = NULL; | ||
1322 | + | ||
1323 | + obj = object_property_get_link(OBJECT(dev), "dma-mr", &err); | ||
1324 | + if (err) { | ||
1325 | + error_setg(errp, "dwc2: required dma-mr link not found: %s", | ||
1326 | + error_get_pretty(err)); | ||
1327 | + return; | ||
1328 | + } | ||
1329 | + assert(obj != NULL); | ||
1330 | + | ||
1331 | + s->dma_mr = MEMORY_REGION(obj); | ||
1332 | + address_space_init(&s->dma_as, s->dma_mr, "dwc2"); | ||
1333 | + | ||
1334 | + usb_bus_new(&s->bus, sizeof(s->bus), &dwc2_bus_ops, dev); | ||
1335 | + usb_register_port(&s->bus, &s->uport, s, 0, &dwc2_port_ops, | ||
1336 | + USB_SPEED_MASK_LOW | USB_SPEED_MASK_FULL | | ||
1337 | + (s->usb_version == 2 ? USB_SPEED_MASK_HIGH : 0)); | ||
1338 | + s->uport.dev = 0; | ||
1339 | + | ||
1340 | + s->usb_frame_time = NANOSECONDS_PER_SECOND / 1000; /* 1000000 */ | ||
1341 | + if (NANOSECONDS_PER_SECOND >= USB_HZ_FS) { | ||
1342 | + s->usb_bit_time = NANOSECONDS_PER_SECOND / USB_HZ_FS; /* 83.3 */ | ||
1343 | + } else { | ||
1344 | + s->usb_bit_time = 1; | ||
1345 | + } | ||
1346 | + | ||
1347 | + s->fi = USB_FRMINTVL - 1; | ||
1348 | + s->eof_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, dwc2_frame_boundary, s); | ||
1349 | + s->frame_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, dwc2_work_timer, s); | ||
1350 | + s->async_bh = qemu_bh_new(dwc2_work_bh, s); | ||
1351 | + | ||
1352 | + sysbus_init_irq(sbd, &s->irq); | ||
1353 | +} | ||
1354 | + | ||
1355 | +static void dwc2_init(Object *obj) | ||
1356 | +{ | ||
1357 | + SysBusDevice *sbd = SYS_BUS_DEVICE(obj); | ||
1358 | + DWC2State *s = DWC2_USB(obj); | ||
1359 | + | ||
1360 | + memory_region_init(&s->container, obj, "dwc2", DWC2_MMIO_SIZE); | ||
1361 | + sysbus_init_mmio(sbd, &s->container); | ||
1362 | + | ||
1363 | + memory_region_init_io(&s->hsotg, obj, &dwc2_mmio_hsotg_ops, s, | ||
1364 | + "dwc2-io", 4 * KiB); | ||
1365 | + memory_region_add_subregion(&s->container, 0x0000, &s->hsotg); | ||
1366 | + | ||
1367 | + memory_region_init_io(&s->fifos, obj, &dwc2_mmio_hreg2_ops, s, | ||
1368 | + "dwc2-fifo", 64 * KiB); | ||
1369 | + memory_region_add_subregion(&s->container, 0x1000, &s->fifos); | ||
1370 | +} | ||
1371 | + | ||
1372 | +static const VMStateDescription vmstate_dwc2_state_packet = { | ||
1373 | + .name = "dwc2/packet", | ||
1374 | + .version_id = 1, | ||
1375 | + .minimum_version_id = 1, | ||
1376 | + .fields = (VMStateField[]) { | ||
1377 | + VMSTATE_UINT32(devadr, DWC2Packet), | ||
1378 | + VMSTATE_UINT32(epnum, DWC2Packet), | ||
1379 | + VMSTATE_UINT32(epdir, DWC2Packet), | ||
1380 | + VMSTATE_UINT32(mps, DWC2Packet), | ||
1381 | + VMSTATE_UINT32(pid, DWC2Packet), | ||
1382 | + VMSTATE_UINT32(index, DWC2Packet), | ||
1383 | + VMSTATE_UINT32(pcnt, DWC2Packet), | ||
1384 | + VMSTATE_UINT32(len, DWC2Packet), | ||
1385 | + VMSTATE_INT32(async, DWC2Packet), | ||
1386 | + VMSTATE_BOOL(small, DWC2Packet), | ||
1387 | + VMSTATE_BOOL(needs_service, DWC2Packet), | ||
1388 | + VMSTATE_END_OF_LIST() | ||
1389 | + }, | ||
1390 | +}; | ||
1391 | + | ||
1392 | +const VMStateDescription vmstate_dwc2_state = { | ||
1393 | + .name = "dwc2", | ||
1394 | + .version_id = 1, | ||
1395 | + .minimum_version_id = 1, | ||
1396 | + .fields = (VMStateField[]) { | ||
1397 | + VMSTATE_UINT32_ARRAY(glbreg, DWC2State, | ||
1398 | + DWC2_GLBREG_SIZE / sizeof(uint32_t)), | ||
1399 | + VMSTATE_UINT32_ARRAY(fszreg, DWC2State, | ||
1400 | + DWC2_FSZREG_SIZE / sizeof(uint32_t)), | ||
1401 | + VMSTATE_UINT32_ARRAY(hreg0, DWC2State, | ||
1402 | + DWC2_HREG0_SIZE / sizeof(uint32_t)), | ||
1403 | + VMSTATE_UINT32_ARRAY(hreg1, DWC2State, | ||
1404 | + DWC2_HREG1_SIZE / sizeof(uint32_t)), | ||
1405 | + VMSTATE_UINT32_ARRAY(pcgreg, DWC2State, | ||
1406 | + DWC2_PCGREG_SIZE / sizeof(uint32_t)), | ||
1407 | + | ||
1408 | + VMSTATE_TIMER_PTR(eof_timer, DWC2State), | ||
1409 | + VMSTATE_TIMER_PTR(frame_timer, DWC2State), | ||
1410 | + VMSTATE_INT64(sof_time, DWC2State), | ||
1411 | + VMSTATE_INT64(usb_frame_time, DWC2State), | ||
1412 | + VMSTATE_INT64(usb_bit_time, DWC2State), | ||
1413 | + VMSTATE_UINT32(usb_version, DWC2State), | ||
1414 | + VMSTATE_UINT16(frame_number, DWC2State), | ||
1415 | + VMSTATE_UINT16(fi, DWC2State), | ||
1416 | + VMSTATE_UINT16(next_chan, DWC2State), | ||
1417 | + VMSTATE_BOOL(working, DWC2State), | ||
1418 | + | ||
1419 | + VMSTATE_STRUCT_ARRAY(packet, DWC2State, DWC2_NB_CHAN, 1, | ||
1420 | + vmstate_dwc2_state_packet, DWC2Packet), | ||
1421 | + VMSTATE_UINT8_2DARRAY(usb_buf, DWC2State, DWC2_NB_CHAN, | ||
1422 | + DWC2_MAX_XFER_SIZE), | ||
1423 | + | ||
1424 | + VMSTATE_END_OF_LIST() | ||
1425 | + } | ||
1426 | +}; | ||
1427 | + | ||
1428 | +static Property dwc2_usb_properties[] = { | ||
1429 | + DEFINE_PROP_UINT32("usb_version", DWC2State, usb_version, 2), | ||
1430 | + DEFINE_PROP_END_OF_LIST(), | ||
1431 | +}; | ||
1432 | + | ||
1433 | +static void dwc2_class_init(ObjectClass *klass, void *data) | ||
1434 | +{ | ||
1435 | + DeviceClass *dc = DEVICE_CLASS(klass); | ||
1436 | + DWC2Class *c = DWC2_CLASS(klass); | ||
1437 | + ResettableClass *rc = RESETTABLE_CLASS(klass); | ||
1438 | + | ||
1439 | + dc->realize = dwc2_realize; | ||
1440 | + dc->vmsd = &vmstate_dwc2_state; | ||
1441 | + set_bit(DEVICE_CATEGORY_USB, dc->categories); | ||
1442 | + device_class_set_props(dc, dwc2_usb_properties); | ||
1443 | + resettable_class_set_parent_phases(rc, dwc2_reset_enter, dwc2_reset_hold, | ||
1444 | + dwc2_reset_exit, &c->parent_phases); | ||
1445 | +} | ||
1446 | + | ||
1447 | +static const TypeInfo dwc2_usb_type_info = { | ||
1448 | + .name = TYPE_DWC2_USB, | ||
1449 | + .parent = TYPE_SYS_BUS_DEVICE, | ||
1450 | + .instance_size = sizeof(DWC2State), | ||
1451 | + .instance_init = dwc2_init, | ||
1452 | + .class_size = sizeof(DWC2Class), | ||
1453 | + .class_init = dwc2_class_init, | ||
1454 | +}; | ||
1455 | + | ||
1456 | +static void dwc2_usb_register_types(void) | ||
1457 | +{ | ||
1458 | + type_register_static(&dwc2_usb_type_info); | ||
1459 | +} | ||
1460 | + | ||
1461 | +type_init(dwc2_usb_register_types) | ||
1462 | diff --git a/hw/usb/Kconfig b/hw/usb/Kconfig | ||
1463 | index XXXXXXX..XXXXXXX 100644 | ||
1464 | --- a/hw/usb/Kconfig | ||
1465 | +++ b/hw/usb/Kconfig | ||
1466 | @@ -XXX,XX +XXX,XX @@ config USB_MUSB | ||
1467 | bool | ||
1468 | select USB | ||
1469 | |||
1470 | +config USB_DWC2 | ||
1471 | + bool | ||
1472 | + default y | ||
1473 | + select USB | ||
1474 | + | ||
1475 | config TUSB6010 | ||
1476 | bool | ||
1477 | select USB_MUSB | ||
1478 | diff --git a/hw/usb/Makefile.objs b/hw/usb/Makefile.objs | ||
1479 | index XXXXXXX..XXXXXXX 100644 | ||
1480 | --- a/hw/usb/Makefile.objs | ||
1481 | +++ b/hw/usb/Makefile.objs | ||
1482 | @@ -XXX,XX +XXX,XX @@ common-obj-$(CONFIG_USB_EHCI_SYSBUS) += hcd-ehci-sysbus.o | ||
1483 | common-obj-$(CONFIG_USB_XHCI) += hcd-xhci.o | ||
1484 | common-obj-$(CONFIG_USB_XHCI_NEC) += hcd-xhci-nec.o | ||
1485 | common-obj-$(CONFIG_USB_MUSB) += hcd-musb.o | ||
1486 | +common-obj-$(CONFIG_USB_DWC2) += hcd-dwc2.o | ||
1487 | |||
1488 | common-obj-$(CONFIG_TUSB6010) += tusb6010.o | ||
1489 | common-obj-$(CONFIG_IMX) += chipidea.o | ||
1490 | diff --git a/hw/usb/trace-events b/hw/usb/trace-events | ||
1491 | index XXXXXXX..XXXXXXX 100644 | ||
1492 | --- a/hw/usb/trace-events | ||
1493 | +++ b/hw/usb/trace-events | ||
1494 | @@ -XXX,XX +XXX,XX @@ usb_xhci_xfer_error(void *xfer, uint32_t ret) "%p: ret %d" | ||
1495 | usb_xhci_unimplemented(const char *item, int nr) "%s (0x%x)" | ||
1496 | usb_xhci_enforced_limit(const char *item) "%s" | ||
1497 | |||
1498 | +# hcd-dwc2.c | ||
1499 | +usb_dwc2_update_irq(uint32_t level) "level=%d" | ||
1500 | +usb_dwc2_raise_global_irq(uint32_t intr) "0x%08x" | ||
1501 | +usb_dwc2_lower_global_irq(uint32_t intr) "0x%08x" | ||
1502 | +usb_dwc2_raise_host_irq(uint32_t intr) "0x%04x" | ||
1503 | +usb_dwc2_lower_host_irq(uint32_t intr) "0x%04x" | ||
1504 | +usb_dwc2_sof(int64_t next) "next SOF %" PRId64 | ||
1505 | +usb_dwc2_bus_start(void) "start SOFs" | ||
1506 | +usb_dwc2_bus_stop(void) "stop SOFs" | ||
1507 | +usb_dwc2_find_device(uint8_t addr) "%d" | ||
1508 | +usb_dwc2_port_disabled(uint32_t pnum) "port %d disabled" | ||
1509 | +usb_dwc2_device_found(uint32_t pnum) "device found on port %d" | ||
1510 | +usb_dwc2_device_not_found(void) "device not found" | ||
1511 | +usb_dwc2_handle_packet(uint32_t chan, void *dev, void *pkt, uint32_t ep, const char *type, const char *dir, uint32_t mps, uint32_t len, uint32_t pcnt) "ch %d dev %p pkt %p ep %d type %s dir %s mps %d len %d pcnt %d" | ||
1512 | +usb_dwc2_memory_read(uint32_t addr, uint32_t len) "addr %d len %d" | ||
1513 | +usb_dwc2_packet_status(const char *status, uint32_t len) "status %s len %d" | ||
1514 | +usb_dwc2_packet_error(const char *status) "ERROR %s" | ||
1515 | +usb_dwc2_async_packet(void *pkt, uint32_t chan, void *dev, uint32_t ep, const char *dir, uint32_t len) "pkt %p ch %d dev %p ep %d %s len %d" | ||
1516 | +usb_dwc2_memory_write(uint32_t addr, uint32_t len) "addr %d len %d" | ||
1517 | +usb_dwc2_packet_done(const char *status, uint32_t actual, uint32_t len, uint32_t pcnt) "status %s actual %d len %d pcnt %d" | ||
1518 | +usb_dwc2_packet_next(const char *status, uint32_t len, uint32_t pcnt) "status %s len %d pcnt %d" | ||
1519 | +usb_dwc2_attach(void *port) "port %p" | ||
1520 | +usb_dwc2_attach_speed(const char *speed) "%s-speed device attached" | ||
1521 | +usb_dwc2_detach(void *port) "port %p" | ||
1522 | +usb_dwc2_child_detach(void *port, void *child) "port %p child %p" | ||
1523 | +usb_dwc2_wakeup(void *port) "port %p" | ||
1524 | +usb_dwc2_async_packet_complete(void *port, void *pkt, uint32_t chan, void *dev, uint32_t ep, const char *dir, uint32_t len) "port %p packet %p ch %d dev %p ep %d %s len %d" | ||
1525 | +usb_dwc2_work_bh(void) "" | ||
1526 | +usb_dwc2_work_bh_service(uint32_t first, uint32_t current, void *dev, uint32_t ep) "first %d servicing %d dev %p ep %d" | ||
1527 | +usb_dwc2_work_bh_next(uint32_t chan) "next %d" | ||
1528 | +usb_dwc2_enable_chan(uint32_t chan, void *dev, void *pkt, uint32_t ep) "ch %d dev %p pkt %p ep %d" | ||
1529 | +usb_dwc2_glbreg_read(uint64_t addr, const char *reg, uint32_t val) " 0x%04" PRIx64 " %s val 0x%08x" | ||
1530 | +usb_dwc2_glbreg_write(uint64_t addr, const char *reg, uint64_t val, uint32_t old, uint64_t result) "0x%04" PRIx64 " %s val 0x%08" PRIx64 " old 0x%08x result 0x%08" PRIx64 | ||
1531 | +usb_dwc2_fszreg_read(uint64_t addr, uint32_t val) " 0x%04" PRIx64 " HPTXFSIZ val 0x%08x" | ||
1532 | +usb_dwc2_fszreg_write(uint64_t addr, uint64_t val, uint32_t old, uint64_t result) "0x%04" PRIx64 " HPTXFSIZ val 0x%08" PRIx64 " old 0x%08x result 0x%08" PRIx64 | ||
1533 | +usb_dwc2_hreg0_read(uint64_t addr, const char *reg, uint32_t val) " 0x%04" PRIx64 " %s val 0x%08x" | ||
1534 | +usb_dwc2_hreg0_write(uint64_t addr, const char *reg, uint64_t val, uint32_t old, uint64_t result) " 0x%04" PRIx64 " %s val 0x%08" PRIx64 " old 0x%08x result 0x%08" PRIx64 | ||
1535 | +usb_dwc2_hreg1_read(uint64_t addr, const char *reg, uint64_t chan, uint32_t val) " 0x%04" PRIx64 " %s%" PRId64 " val 0x%08x" | ||
1536 | +usb_dwc2_hreg1_write(uint64_t addr, const char *reg, uint64_t chan, uint64_t val, uint32_t old, uint64_t result) " 0x%04" PRIx64 " %s%" PRId64 " val 0x%08" PRIx64 " old 0x%08x result 0x%08" PRIx64 | ||
1537 | +usb_dwc2_pcgreg_read(uint64_t addr, const char *reg, uint32_t val) " 0x%04" PRIx64 " %s val 0x%08x" | ||
1538 | +usb_dwc2_pcgreg_write(uint64_t addr, const char *reg, uint64_t val, uint32_t old, uint64_t result) "0x%04" PRIx64 " %s val 0x%08" PRIx64 " old 0x%08x result 0x%08" PRIx64 | ||
1539 | +usb_dwc2_hreg2_read(uint64_t addr, uint64_t fifo, uint32_t val) " 0x%04" PRIx64 " FIFO%" PRId64 " val 0x%08x" | ||
1540 | +usb_dwc2_hreg2_write(uint64_t addr, uint64_t fifo, uint64_t val, uint32_t old, uint64_t result) " 0x%04" PRIx64 " FIFO%" PRId64 " val 0x%08" PRIx64 " old 0x%08x result 0x%08" PRIx64 | ||
1541 | +usb_dwc2_hreg0_action(const char *s) "%s" | ||
1542 | +usb_dwc2_wakeup_endpoint(void *ep, uint32_t stream) "endp %p stream %d" | ||
1543 | +usb_dwc2_work_timer(void) "" | ||
1544 | +usb_dwc2_reset_enter(void) "=== RESET enter ===" | ||
1545 | +usb_dwc2_reset_hold(void) "=== RESET hold ===" | ||
1546 | +usb_dwc2_reset_exit(void) "=== RESET exit ===" | ||
1547 | + | ||
1548 | # desc.c | ||
1549 | usb_desc_device(int addr, int len, int ret) "dev %d query device, len %d, ret %d" | ||
1550 | usb_desc_device_qualifier(int addr, int len, int ret) "dev %d query device qualifier, len %d, ret %d" | ||
1551 | -- | 65 | -- |
1552 | 2.20.1 | 66 | 2.34.1 |
1553 | |||
1554 | diff view generated by jsdifflib |
1 | From: Paul Zimmerman <pauldzim@gmail.com> | 1 | From: Evgeny Iakovlev <eiakovlev@linux.microsoft.com> |
---|---|---|---|
2 | 2 | ||
3 | Add a check for functional dwc-hsotg (dwc2) USB host emulation to | 3 | PL011 currently lacks a reset method. Implement it. |
4 | the Raspi 2 acceptance test | ||
5 | 4 | ||
6 | Signed-off-by: Paul Zimmerman <pauldzim@gmail.com> | 5 | Signed-off-by: Evgeny Iakovlev <eiakovlev@linux.microsoft.com> |
7 | Reviewed-by: Philippe Mathieu-Daude <f4bug@amsat.org> | 6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Message-id: 20200520235349.21215-8-pauldzim@gmail.com | 7 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
8 | Message-id: 20230123162304.26254-4-eiakovlev@linux.microsoft.com | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 10 | --- |
11 | tests/acceptance/boot_linux_console.py | 9 +++++++-- | 11 | hw/char/pl011.c | 26 +++++++++++++++++++++----- |
12 | 1 file changed, 7 insertions(+), 2 deletions(-) | 12 | 1 file changed, 21 insertions(+), 5 deletions(-) |
13 | 13 | ||
14 | diff --git a/tests/acceptance/boot_linux_console.py b/tests/acceptance/boot_linux_console.py | 14 | diff --git a/hw/char/pl011.c b/hw/char/pl011.c |
15 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/tests/acceptance/boot_linux_console.py | 16 | --- a/hw/char/pl011.c |
17 | +++ b/tests/acceptance/boot_linux_console.py | 17 | +++ b/hw/char/pl011.c |
18 | @@ -XXX,XX +XXX,XX @@ class BootLinuxConsole(LinuxKernelTest): | 18 | @@ -XXX,XX +XXX,XX @@ static void pl011_init(Object *obj) |
19 | 19 | s->clk = qdev_init_clock_in(DEVICE(obj), "clk", pl011_clock_update, s, | |
20 | self.vm.set_console() | 20 | ClockUpdate); |
21 | kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE + | 21 | |
22 | - serial_kernel_cmdline[uart_id]) | 22 | - s->read_trigger = 1; |
23 | + serial_kernel_cmdline[uart_id] + | 23 | - s->ifl = 0x12; |
24 | + ' root=/dev/mmcblk0p2 rootwait ' + | 24 | - s->cr = 0x300; |
25 | + 'dwc_otg.fiq_fsm_enable=0') | 25 | - s->flags = 0x90; |
26 | self.vm.add_args('-kernel', kernel_path, | 26 | - |
27 | '-dtb', dtb_path, | 27 | s->id = pl011_id_arm; |
28 | - '-append', kernel_command_line) | 28 | } |
29 | + '-append', kernel_command_line, | 29 | |
30 | + '-device', 'usb-kbd') | 30 | @@ -XXX,XX +XXX,XX @@ static void pl011_realize(DeviceState *dev, Error **errp) |
31 | self.vm.launch() | 31 | pl011_event, NULL, s, NULL, true); |
32 | console_pattern = 'Kernel command line: %s' % kernel_command_line | 32 | } |
33 | self.wait_for_console_pattern(console_pattern) | 33 | |
34 | + console_pattern = 'Product: QEMU USB Keyboard' | 34 | +static void pl011_reset(DeviceState *dev) |
35 | + self.wait_for_console_pattern(console_pattern) | 35 | +{ |
36 | 36 | + PL011State *s = PL011(dev); | |
37 | def test_arm_raspi2_uart0(self): | 37 | + |
38 | """ | 38 | + s->lcr = 0; |
39 | + s->rsr = 0; | ||
40 | + s->dmacr = 0; | ||
41 | + s->int_enabled = 0; | ||
42 | + s->int_level = 0; | ||
43 | + s->ilpr = 0; | ||
44 | + s->ibrd = 0; | ||
45 | + s->fbrd = 0; | ||
46 | + s->read_pos = 0; | ||
47 | + s->read_count = 0; | ||
48 | + s->read_trigger = 1; | ||
49 | + s->ifl = 0x12; | ||
50 | + s->cr = 0x300; | ||
51 | + s->flags = 0x90; | ||
52 | +} | ||
53 | + | ||
54 | static void pl011_class_init(ObjectClass *oc, void *data) | ||
55 | { | ||
56 | DeviceClass *dc = DEVICE_CLASS(oc); | ||
57 | |||
58 | dc->realize = pl011_realize; | ||
59 | + dc->reset = pl011_reset; | ||
60 | dc->vmsd = &vmstate_pl011; | ||
61 | device_class_set_props(dc, pl011_properties); | ||
62 | } | ||
39 | -- | 63 | -- |
40 | 2.20.1 | 64 | 2.34.1 |
41 | 65 | ||
42 | 66 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Evgeny Iakovlev <eiakovlev@linux.microsoft.com> |
---|---|---|---|
2 | 2 | ||
3 | Rather than passing an opcode to a helper, fully decode the | 3 | Current FIFO handling code does not reset RXFE/RXFF flags when guest |
4 | operation at translate time. Use clear_tail_16 to zap the | 4 | resets FIFO by writing to UARTLCR register, although internal FIFO state |
5 | balance of the SVE register with the AdvSIMD write. | 5 | is reset to 0 read count. Actual guest-visible flag update will happen |
6 | only on next data read or write attempt. As a result of that any guest | ||
7 | that expects RXFE flag to be set (and RXFF to be cleared) after resetting | ||
8 | FIFO will never see that happen. | ||
6 | 9 | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 10 | Signed-off-by: Evgeny Iakovlev <eiakovlev@linux.microsoft.com> |
8 | Message-id: 20200514212831.31248-6-richard.henderson@linaro.org | ||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
12 | Message-id: 20230123162304.26254-5-eiakovlev@linux.microsoft.com | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 14 | --- |
12 | target/arm/helper.h | 5 +- | 15 | hw/char/pl011.c | 18 +++++++++++++----- |
13 | target/arm/neon-dp.decode | 6 +- | 16 | 1 file changed, 13 insertions(+), 5 deletions(-) |
14 | target/arm/crypto_helper.c | 99 +++++++++++++++++++++------------ | ||
15 | target/arm/translate-a64.c | 29 ++++------ | ||
16 | target/arm/translate-neon.inc.c | 46 ++++----------- | ||
17 | 5 files changed, 93 insertions(+), 92 deletions(-) | ||
18 | 17 | ||
19 | diff --git a/target/arm/helper.h b/target/arm/helper.h | 18 | diff --git a/hw/char/pl011.c b/hw/char/pl011.c |
20 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/target/arm/helper.h | 20 | --- a/hw/char/pl011.c |
22 | +++ b/target/arm/helper.h | 21 | +++ b/hw/char/pl011.c |
23 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_2(neon_qzip32, TCG_CALL_NO_RWG, void, ptr, ptr) | 22 | @@ -XXX,XX +XXX,XX @@ static inline unsigned pl011_get_fifo_depth(PL011State *s) |
24 | DEF_HELPER_FLAGS_4(crypto_aese, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | 23 | return pl011_is_fifo_enabled(s) ? PL011_FIFO_DEPTH : 1; |
25 | DEF_HELPER_FLAGS_3(crypto_aesmc, TCG_CALL_NO_RWG, void, ptr, ptr, i32) | ||
26 | |||
27 | -DEF_HELPER_FLAGS_4(crypto_sha1_3reg, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | ||
28 | +DEF_HELPER_FLAGS_4(crypto_sha1su0, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | ||
29 | +DEF_HELPER_FLAGS_4(crypto_sha1c, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | ||
30 | +DEF_HELPER_FLAGS_4(crypto_sha1p, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | ||
31 | +DEF_HELPER_FLAGS_4(crypto_sha1m, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | ||
32 | DEF_HELPER_FLAGS_3(crypto_sha1h, TCG_CALL_NO_RWG, void, ptr, ptr, i32) | ||
33 | DEF_HELPER_FLAGS_3(crypto_sha1su1, TCG_CALL_NO_RWG, void, ptr, ptr, i32) | ||
34 | |||
35 | diff --git a/target/arm/neon-dp.decode b/target/arm/neon-dp.decode | ||
36 | index XXXXXXX..XXXXXXX 100644 | ||
37 | --- a/target/arm/neon-dp.decode | ||
38 | +++ b/target/arm/neon-dp.decode | ||
39 | @@ -XXX,XX +XXX,XX @@ VQRDMLAH_3s 1111 001 1 0 . .. .... .... 1011 ... 1 .... @3same | ||
40 | @3same_crypto .... .... .... .... .... .... .... .... \ | ||
41 | &3same vm=%vm_dp vn=%vn_dp vd=%vd_dp size=0 q=1 | ||
42 | |||
43 | -SHA1_3s 1111 001 0 0 . optype:2 .... .... 1100 . 1 . 0 .... \ | ||
44 | - vm=%vm_dp vn=%vn_dp vd=%vd_dp | ||
45 | +SHA1C_3s 1111 001 0 0 . 00 .... .... 1100 . 1 . 0 .... @3same_crypto | ||
46 | +SHA1P_3s 1111 001 0 0 . 01 .... .... 1100 . 1 . 0 .... @3same_crypto | ||
47 | +SHA1M_3s 1111 001 0 0 . 10 .... .... 1100 . 1 . 0 .... @3same_crypto | ||
48 | +SHA1SU0_3s 1111 001 0 0 . 11 .... .... 1100 . 1 . 0 .... @3same_crypto | ||
49 | SHA256H_3s 1111 001 1 0 . 00 .... .... 1100 . 1 . 0 .... @3same_crypto | ||
50 | SHA256H2_3s 1111 001 1 0 . 01 .... .... 1100 . 1 . 0 .... @3same_crypto | ||
51 | SHA256SU1_3s 1111 001 1 0 . 10 .... .... 1100 . 1 . 0 .... @3same_crypto | ||
52 | diff --git a/target/arm/crypto_helper.c b/target/arm/crypto_helper.c | ||
53 | index XXXXXXX..XXXXXXX 100644 | ||
54 | --- a/target/arm/crypto_helper.c | ||
55 | +++ b/target/arm/crypto_helper.c | ||
56 | @@ -XXX,XX +XXX,XX @@ union CRYPTO_STATE { | ||
57 | }; | ||
58 | |||
59 | #ifdef HOST_WORDS_BIGENDIAN | ||
60 | -#define CR_ST_BYTE(state, i) (state.bytes[(15 - (i)) ^ 8]) | ||
61 | -#define CR_ST_WORD(state, i) (state.words[(3 - (i)) ^ 2]) | ||
62 | +#define CR_ST_BYTE(state, i) ((state).bytes[(15 - (i)) ^ 8]) | ||
63 | +#define CR_ST_WORD(state, i) ((state).words[(3 - (i)) ^ 2]) | ||
64 | #else | ||
65 | -#define CR_ST_BYTE(state, i) (state.bytes[i]) | ||
66 | -#define CR_ST_WORD(state, i) (state.words[i]) | ||
67 | +#define CR_ST_BYTE(state, i) ((state).bytes[i]) | ||
68 | +#define CR_ST_WORD(state, i) ((state).words[i]) | ||
69 | #endif | ||
70 | |||
71 | /* | ||
72 | @@ -XXX,XX +XXX,XX @@ static uint32_t maj(uint32_t x, uint32_t y, uint32_t z) | ||
73 | return (x & y) | ((x | y) & z); | ||
74 | } | 24 | } |
75 | 25 | ||
76 | -void HELPER(crypto_sha1_3reg)(void *vd, void *vn, void *vm, uint32_t op) | 26 | +static inline void pl011_reset_fifo(PL011State *s) |
77 | +void HELPER(crypto_sha1su0)(void *vd, void *vn, void *vm, uint32_t desc) | ||
78 | +{ | 27 | +{ |
79 | + uint64_t *d = vd, *n = vn, *m = vm; | 28 | + s->read_count = 0; |
80 | + uint64_t d0, d1; | 29 | + s->read_pos = 0; |
81 | + | 30 | + |
82 | + d0 = d[1] ^ d[0] ^ m[0]; | 31 | + /* Reset FIFO flags */ |
83 | + d1 = n[0] ^ d[1] ^ m[1]; | 32 | + s->flags &= ~(PL011_FLAG_RXFF | PL011_FLAG_TXFF); |
84 | + d[0] = d0; | 33 | + s->flags |= PL011_FLAG_RXFE | PL011_FLAG_TXFE; |
85 | + d[1] = d1; | ||
86 | + | ||
87 | + clear_tail_16(vd, desc); | ||
88 | +} | 34 | +} |
89 | + | 35 | + |
90 | +static inline void crypto_sha1_3reg(uint64_t *rd, uint64_t *rn, | 36 | static uint64_t pl011_read(void *opaque, hwaddr offset, |
91 | + uint64_t *rm, uint32_t desc, | 37 | unsigned size) |
92 | + uint32_t (*fn)(union CRYPTO_STATE *d)) | ||
93 | { | 38 | { |
94 | - uint64_t *rd = vd; | 39 | @@ -XXX,XX +XXX,XX @@ static void pl011_write(void *opaque, hwaddr offset, |
95 | - uint64_t *rn = vn; | 40 | case 11: /* UARTLCR_H */ |
96 | - uint64_t *rm = vm; | 41 | /* Reset the FIFO state on FIFO enable or disable */ |
97 | union CRYPTO_STATE d = { .l = { rd[0], rd[1] } }; | 42 | if ((s->lcr ^ value) & 0x10) { |
98 | union CRYPTO_STATE n = { .l = { rn[0], rn[1] } }; | 43 | - s->read_count = 0; |
99 | union CRYPTO_STATE m = { .l = { rm[0], rm[1] } }; | 44 | - s->read_pos = 0; |
100 | + int i; | 45 | + pl011_reset_fifo(s); |
101 | 46 | } | |
102 | - if (op == 3) { /* sha1su0 */ | 47 | if ((s->lcr ^ value) & 0x1) { |
103 | - d.l[0] ^= d.l[1] ^ m.l[0]; | 48 | int break_enable = value & 0x1; |
104 | - d.l[1] ^= n.l[0] ^ m.l[1]; | 49 | @@ -XXX,XX +XXX,XX @@ static void pl011_reset(DeviceState *dev) |
105 | - } else { | 50 | s->ilpr = 0; |
106 | - int i; | 51 | s->ibrd = 0; |
107 | + for (i = 0; i < 4; i++) { | 52 | s->fbrd = 0; |
108 | + uint32_t t = fn(&d); | 53 | - s->read_pos = 0; |
109 | 54 | - s->read_count = 0; | |
110 | - for (i = 0; i < 4; i++) { | 55 | s->read_trigger = 1; |
111 | - uint32_t t; | 56 | s->ifl = 0x12; |
112 | + t += rol32(CR_ST_WORD(d, 0), 5) + CR_ST_WORD(n, 0) | 57 | s->cr = 0x300; |
113 | + + CR_ST_WORD(m, i); | 58 | - s->flags = 0x90; |
114 | 59 | + s->flags = 0; | |
115 | - switch (op) { | 60 | + pl011_reset_fifo(s); |
116 | - case 0: /* sha1c */ | ||
117 | - t = cho(CR_ST_WORD(d, 1), CR_ST_WORD(d, 2), CR_ST_WORD(d, 3)); | ||
118 | - break; | ||
119 | - case 1: /* sha1p */ | ||
120 | - t = par(CR_ST_WORD(d, 1), CR_ST_WORD(d, 2), CR_ST_WORD(d, 3)); | ||
121 | - break; | ||
122 | - case 2: /* sha1m */ | ||
123 | - t = maj(CR_ST_WORD(d, 1), CR_ST_WORD(d, 2), CR_ST_WORD(d, 3)); | ||
124 | - break; | ||
125 | - default: | ||
126 | - g_assert_not_reached(); | ||
127 | - } | ||
128 | - t += rol32(CR_ST_WORD(d, 0), 5) + CR_ST_WORD(n, 0) | ||
129 | - + CR_ST_WORD(m, i); | ||
130 | - | ||
131 | - CR_ST_WORD(n, 0) = CR_ST_WORD(d, 3); | ||
132 | - CR_ST_WORD(d, 3) = CR_ST_WORD(d, 2); | ||
133 | - CR_ST_WORD(d, 2) = ror32(CR_ST_WORD(d, 1), 2); | ||
134 | - CR_ST_WORD(d, 1) = CR_ST_WORD(d, 0); | ||
135 | - CR_ST_WORD(d, 0) = t; | ||
136 | - } | ||
137 | + CR_ST_WORD(n, 0) = CR_ST_WORD(d, 3); | ||
138 | + CR_ST_WORD(d, 3) = CR_ST_WORD(d, 2); | ||
139 | + CR_ST_WORD(d, 2) = ror32(CR_ST_WORD(d, 1), 2); | ||
140 | + CR_ST_WORD(d, 1) = CR_ST_WORD(d, 0); | ||
141 | + CR_ST_WORD(d, 0) = t; | ||
142 | } | ||
143 | rd[0] = d.l[0]; | ||
144 | rd[1] = d.l[1]; | ||
145 | + | ||
146 | + clear_tail_16(rd, desc); | ||
147 | +} | ||
148 | + | ||
149 | +static uint32_t do_sha1c(union CRYPTO_STATE *d) | ||
150 | +{ | ||
151 | + return cho(CR_ST_WORD(*d, 1), CR_ST_WORD(*d, 2), CR_ST_WORD(*d, 3)); | ||
152 | +} | ||
153 | + | ||
154 | +void HELPER(crypto_sha1c)(void *vd, void *vn, void *vm, uint32_t desc) | ||
155 | +{ | ||
156 | + crypto_sha1_3reg(vd, vn, vm, desc, do_sha1c); | ||
157 | +} | ||
158 | + | ||
159 | +static uint32_t do_sha1p(union CRYPTO_STATE *d) | ||
160 | +{ | ||
161 | + return par(CR_ST_WORD(*d, 1), CR_ST_WORD(*d, 2), CR_ST_WORD(*d, 3)); | ||
162 | +} | ||
163 | + | ||
164 | +void HELPER(crypto_sha1p)(void *vd, void *vn, void *vm, uint32_t desc) | ||
165 | +{ | ||
166 | + crypto_sha1_3reg(vd, vn, vm, desc, do_sha1p); | ||
167 | +} | ||
168 | + | ||
169 | +static uint32_t do_sha1m(union CRYPTO_STATE *d) | ||
170 | +{ | ||
171 | + return maj(CR_ST_WORD(*d, 1), CR_ST_WORD(*d, 2), CR_ST_WORD(*d, 3)); | ||
172 | +} | ||
173 | + | ||
174 | +void HELPER(crypto_sha1m)(void *vd, void *vn, void *vm, uint32_t desc) | ||
175 | +{ | ||
176 | + crypto_sha1_3reg(vd, vn, vm, desc, do_sha1m); | ||
177 | } | 61 | } |
178 | 62 | ||
179 | void HELPER(crypto_sha1h)(void *vd, void *vm, uint32_t desc) | 63 | static void pl011_class_init(ObjectClass *oc, void *data) |
180 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
181 | index XXXXXXX..XXXXXXX 100644 | ||
182 | --- a/target/arm/translate-a64.c | ||
183 | +++ b/target/arm/translate-a64.c | ||
184 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_three_reg_sha(DisasContext *s, uint32_t insn) | ||
185 | |||
186 | switch (opcode) { | ||
187 | case 0: /* SHA1C */ | ||
188 | + genfn = gen_helper_crypto_sha1c; | ||
189 | + feature = dc_isar_feature(aa64_sha1, s); | ||
190 | + break; | ||
191 | case 1: /* SHA1P */ | ||
192 | + genfn = gen_helper_crypto_sha1p; | ||
193 | + feature = dc_isar_feature(aa64_sha1, s); | ||
194 | + break; | ||
195 | case 2: /* SHA1M */ | ||
196 | + genfn = gen_helper_crypto_sha1m; | ||
197 | + feature = dc_isar_feature(aa64_sha1, s); | ||
198 | + break; | ||
199 | case 3: /* SHA1SU0 */ | ||
200 | - genfn = NULL; | ||
201 | + genfn = gen_helper_crypto_sha1su0; | ||
202 | feature = dc_isar_feature(aa64_sha1, s); | ||
203 | break; | ||
204 | case 4: /* SHA256H */ | ||
205 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_three_reg_sha(DisasContext *s, uint32_t insn) | ||
206 | if (!fp_access_check(s)) { | ||
207 | return; | ||
208 | } | ||
209 | - | ||
210 | - if (genfn) { | ||
211 | - gen_gvec_op3_ool(s, true, rd, rn, rm, 0, genfn); | ||
212 | - } else { | ||
213 | - TCGv_i32 tcg_opcode = tcg_const_i32(opcode); | ||
214 | - TCGv_ptr tcg_rd_ptr = vec_full_reg_ptr(s, rd); | ||
215 | - TCGv_ptr tcg_rn_ptr = vec_full_reg_ptr(s, rn); | ||
216 | - TCGv_ptr tcg_rm_ptr = vec_full_reg_ptr(s, rm); | ||
217 | - | ||
218 | - gen_helper_crypto_sha1_3reg(tcg_rd_ptr, tcg_rn_ptr, | ||
219 | - tcg_rm_ptr, tcg_opcode); | ||
220 | - | ||
221 | - tcg_temp_free_i32(tcg_opcode); | ||
222 | - tcg_temp_free_ptr(tcg_rd_ptr); | ||
223 | - tcg_temp_free_ptr(tcg_rn_ptr); | ||
224 | - tcg_temp_free_ptr(tcg_rm_ptr); | ||
225 | - } | ||
226 | + gen_gvec_op3_ool(s, true, rd, rn, rm, 0, genfn); | ||
227 | } | ||
228 | |||
229 | /* Crypto two-reg SHA | ||
230 | diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c | ||
231 | index XXXXXXX..XXXXXXX 100644 | ||
232 | --- a/target/arm/translate-neon.inc.c | ||
233 | +++ b/target/arm/translate-neon.inc.c | ||
234 | @@ -XXX,XX +XXX,XX @@ static bool trans_VMUL_p_3s(DisasContext *s, arg_3same *a) | ||
235 | DO_VQRDMLAH(VQRDMLAH, gen_gvec_sqrdmlah_qc) | ||
236 | DO_VQRDMLAH(VQRDMLSH, gen_gvec_sqrdmlsh_qc) | ||
237 | |||
238 | -static bool trans_SHA1_3s(DisasContext *s, arg_SHA1_3s *a) | ||
239 | -{ | ||
240 | - TCGv_ptr ptr1, ptr2, ptr3; | ||
241 | - TCGv_i32 tmp; | ||
242 | - | ||
243 | - if (!arm_dc_feature(s, ARM_FEATURE_NEON) || | ||
244 | - !dc_isar_feature(aa32_sha1, s)) { | ||
245 | - return false; | ||
246 | +#define DO_SHA1(NAME, FUNC) \ | ||
247 | + WRAP_OOL_FN(gen_##NAME##_3s, FUNC) \ | ||
248 | + static bool trans_##NAME##_3s(DisasContext *s, arg_3same *a) \ | ||
249 | + { \ | ||
250 | + if (!dc_isar_feature(aa32_sha1, s)) { \ | ||
251 | + return false; \ | ||
252 | + } \ | ||
253 | + return do_3same(s, a, gen_##NAME##_3s); \ | ||
254 | } | ||
255 | |||
256 | - /* UNDEF accesses to D16-D31 if they don't exist. */ | ||
257 | - if (!dc_isar_feature(aa32_simd_r32, s) && | ||
258 | - ((a->vd | a->vn | a->vm) & 0x10)) { | ||
259 | - return false; | ||
260 | - } | ||
261 | - | ||
262 | - if ((a->vn | a->vm | a->vd) & 1) { | ||
263 | - return false; | ||
264 | - } | ||
265 | - | ||
266 | - if (!vfp_access_check(s)) { | ||
267 | - return true; | ||
268 | - } | ||
269 | - | ||
270 | - ptr1 = vfp_reg_ptr(true, a->vd); | ||
271 | - ptr2 = vfp_reg_ptr(true, a->vn); | ||
272 | - ptr3 = vfp_reg_ptr(true, a->vm); | ||
273 | - tmp = tcg_const_i32(a->optype); | ||
274 | - gen_helper_crypto_sha1_3reg(ptr1, ptr2, ptr3, tmp); | ||
275 | - tcg_temp_free_i32(tmp); | ||
276 | - tcg_temp_free_ptr(ptr1); | ||
277 | - tcg_temp_free_ptr(ptr2); | ||
278 | - tcg_temp_free_ptr(ptr3); | ||
279 | - | ||
280 | - return true; | ||
281 | -} | ||
282 | +DO_SHA1(SHA1C, gen_helper_crypto_sha1c) | ||
283 | +DO_SHA1(SHA1P, gen_helper_crypto_sha1p) | ||
284 | +DO_SHA1(SHA1M, gen_helper_crypto_sha1m) | ||
285 | +DO_SHA1(SHA1SU0, gen_helper_crypto_sha1su0) | ||
286 | |||
287 | #define DO_SHA2(NAME, FUNC) \ | ||
288 | WRAP_OOL_FN(gen_##NAME##_3s, FUNC) \ | ||
289 | -- | 64 | -- |
290 | 2.20.1 | 65 | 2.34.1 |
291 | |||
292 | diff view generated by jsdifflib |
1 | Convert the VQSHLU and QVSHL 2-reg-shift insns to decodetree. | 1 | From: Alexander Graf <agraf@csgraf.de> |
---|---|---|---|
2 | These are the last of the simple shift-by-immediate insns. | 2 | |
3 | 3 | We currently only support GICv2 emulation. To also support GICv3, we will | |
4 | need to pass a few system registers into their respective handler functions. | ||
5 | |||
6 | This patch adds support for HVF to call into the TCG callbacks for GICv3 | ||
7 | system register handlers. This is safe because the GICv3 TCG code is generic | ||
8 | as long as we limit ourselves to EL0 and EL1 - which are the only modes | ||
9 | supported by HVF. | ||
10 | |||
11 | To make sure nobody trips over that, we also annotate callbacks that don't | ||
12 | work in HVF mode, such as EL state change hooks. | ||
13 | |||
14 | With GICv3 support in place, we can run with more than 8 vCPUs. | ||
15 | |||
16 | Signed-off-by: Alexander Graf <agraf@csgraf.de> | ||
17 | Message-id: 20230128224459.70676-1-agraf@csgraf.de | ||
18 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 19 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20200522145520.6778-5-peter.maydell@linaro.org | ||
7 | --- | 20 | --- |
8 | target/arm/neon-dp.decode | 15 +++++ | 21 | hw/intc/arm_gicv3_cpuif.c | 16 +++- |
9 | target/arm/translate-neon.inc.c | 108 +++++++++++++++++++++++++++++++ | 22 | target/arm/hvf/hvf.c | 151 ++++++++++++++++++++++++++++++++++++ |
10 | target/arm/translate.c | 110 +------------------------------- | 23 | target/arm/hvf/trace-events | 2 + |
11 | 3 files changed, 126 insertions(+), 107 deletions(-) | 24 | 3 files changed, 168 insertions(+), 1 deletion(-) |
12 | 25 | ||
13 | diff --git a/target/arm/neon-dp.decode b/target/arm/neon-dp.decode | 26 | diff --git a/hw/intc/arm_gicv3_cpuif.c b/hw/intc/arm_gicv3_cpuif.c |
14 | index XXXXXXX..XXXXXXX 100644 | 27 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/neon-dp.decode | 28 | --- a/hw/intc/arm_gicv3_cpuif.c |
16 | +++ b/target/arm/neon-dp.decode | 29 | +++ b/hw/intc/arm_gicv3_cpuif.c |
17 | @@ -XXX,XX +XXX,XX @@ VSLI_2sh 1111 001 1 1 . ...... .... 0101 . . . 1 .... @2reg_shl_d | 30 | @@ -XXX,XX +XXX,XX @@ |
18 | VSLI_2sh 1111 001 1 1 . ...... .... 0101 . . . 1 .... @2reg_shl_s | 31 | #include "hw/irq.h" |
19 | VSLI_2sh 1111 001 1 1 . ...... .... 0101 . . . 1 .... @2reg_shl_h | 32 | #include "cpu.h" |
20 | VSLI_2sh 1111 001 1 1 . ...... .... 0101 . . . 1 .... @2reg_shl_b | 33 | #include "target/arm/cpregs.h" |
21 | + | 34 | +#include "sysemu/tcg.h" |
22 | +VQSHLU_64_2sh 1111 001 1 1 . ...... .... 0110 . . . 1 .... @2reg_shl_d | 35 | +#include "sysemu/qtest.h" |
23 | +VQSHLU_2sh 1111 001 1 1 . ...... .... 0110 . . . 1 .... @2reg_shl_s | 36 | |
24 | +VQSHLU_2sh 1111 001 1 1 . ...... .... 0110 . . . 1 .... @2reg_shl_h | 37 | /* |
25 | +VQSHLU_2sh 1111 001 1 1 . ...... .... 0110 . . . 1 .... @2reg_shl_b | 38 | * Special case return value from hppvi_index(); must be larger than |
26 | + | 39 | @@ -XXX,XX +XXX,XX @@ void gicv3_init_cpuif(GICv3State *s) |
27 | +VQSHL_S_64_2sh 1111 001 0 1 . ...... .... 0111 . . . 1 .... @2reg_shl_d | 40 | * which case we'd get the wrong value. |
28 | +VQSHL_S_2sh 1111 001 0 1 . ...... .... 0111 . . . 1 .... @2reg_shl_s | 41 | * So instead we define the regs with no ri->opaque info, and |
29 | +VQSHL_S_2sh 1111 001 0 1 . ...... .... 0111 . . . 1 .... @2reg_shl_h | 42 | * get back to the GICv3CPUState from the CPUARMState. |
30 | +VQSHL_S_2sh 1111 001 0 1 . ...... .... 0111 . . . 1 .... @2reg_shl_b | 43 | + * |
31 | + | 44 | + * These CP regs callbacks can be called from either TCG or HVF code. |
32 | +VQSHL_U_64_2sh 1111 001 1 1 . ...... .... 0111 . . . 1 .... @2reg_shl_d | 45 | */ |
33 | +VQSHL_U_2sh 1111 001 1 1 . ...... .... 0111 . . . 1 .... @2reg_shl_s | 46 | define_arm_cp_regs(cpu, gicv3_cpuif_reginfo); |
34 | +VQSHL_U_2sh 1111 001 1 1 . ...... .... 0111 . . . 1 .... @2reg_shl_h | 47 | |
35 | +VQSHL_U_2sh 1111 001 1 1 . ...... .... 0111 . . . 1 .... @2reg_shl_b | 48 | @@ -XXX,XX +XXX,XX @@ void gicv3_init_cpuif(GICv3State *s) |
36 | diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c | 49 | define_arm_cp_regs(cpu, gicv3_cpuif_ich_apxr23_reginfo); |
37 | index XXXXXXX..XXXXXXX 100644 | 50 | } |
38 | --- a/target/arm/translate-neon.inc.c | 51 | } |
39 | +++ b/target/arm/translate-neon.inc.c | 52 | - arm_register_el_change_hook(cpu, gicv3_cpuif_el_change_hook, cs); |
40 | @@ -XXX,XX +XXX,XX @@ static bool trans_VSHR_U_2sh(DisasContext *s, arg_2reg_shift *a) | 53 | + if (tcg_enabled() || qtest_enabled()) { |
41 | return do_vector_2sh(s, a, tcg_gen_gvec_shri); | 54 | + /* |
55 | + * We can only trap EL changes with TCG. However the GIC interrupt | ||
56 | + * state only changes on EL changes involving EL2 or EL3, so for | ||
57 | + * the non-TCG case this is OK, as EL2 and EL3 can't exist. | ||
58 | + */ | ||
59 | + arm_register_el_change_hook(cpu, gicv3_cpuif_el_change_hook, cs); | ||
60 | + } else { | ||
61 | + assert(!arm_feature(&cpu->env, ARM_FEATURE_EL2)); | ||
62 | + assert(!arm_feature(&cpu->env, ARM_FEATURE_EL3)); | ||
63 | + } | ||
42 | } | 64 | } |
43 | } | 65 | } |
44 | + | 66 | diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c |
45 | +static bool do_2shift_env_64(DisasContext *s, arg_2reg_shift *a, | 67 | index XXXXXXX..XXXXXXX 100644 |
46 | + NeonGenTwo64OpEnvFn *fn) | 68 | --- a/target/arm/hvf/hvf.c |
69 | +++ b/target/arm/hvf/hvf.c | ||
70 | @@ -XXX,XX +XXX,XX @@ | ||
71 | #define SYSREG_PMCCNTR_EL0 SYSREG(3, 3, 9, 13, 0) | ||
72 | #define SYSREG_PMCCFILTR_EL0 SYSREG(3, 3, 14, 15, 7) | ||
73 | |||
74 | +#define SYSREG_ICC_AP0R0_EL1 SYSREG(3, 0, 12, 8, 4) | ||
75 | +#define SYSREG_ICC_AP0R1_EL1 SYSREG(3, 0, 12, 8, 5) | ||
76 | +#define SYSREG_ICC_AP0R2_EL1 SYSREG(3, 0, 12, 8, 6) | ||
77 | +#define SYSREG_ICC_AP0R3_EL1 SYSREG(3, 0, 12, 8, 7) | ||
78 | +#define SYSREG_ICC_AP1R0_EL1 SYSREG(3, 0, 12, 9, 0) | ||
79 | +#define SYSREG_ICC_AP1R1_EL1 SYSREG(3, 0, 12, 9, 1) | ||
80 | +#define SYSREG_ICC_AP1R2_EL1 SYSREG(3, 0, 12, 9, 2) | ||
81 | +#define SYSREG_ICC_AP1R3_EL1 SYSREG(3, 0, 12, 9, 3) | ||
82 | +#define SYSREG_ICC_ASGI1R_EL1 SYSREG(3, 0, 12, 11, 6) | ||
83 | +#define SYSREG_ICC_BPR0_EL1 SYSREG(3, 0, 12, 8, 3) | ||
84 | +#define SYSREG_ICC_BPR1_EL1 SYSREG(3, 0, 12, 12, 3) | ||
85 | +#define SYSREG_ICC_CTLR_EL1 SYSREG(3, 0, 12, 12, 4) | ||
86 | +#define SYSREG_ICC_DIR_EL1 SYSREG(3, 0, 12, 11, 1) | ||
87 | +#define SYSREG_ICC_EOIR0_EL1 SYSREG(3, 0, 12, 8, 1) | ||
88 | +#define SYSREG_ICC_EOIR1_EL1 SYSREG(3, 0, 12, 12, 1) | ||
89 | +#define SYSREG_ICC_HPPIR0_EL1 SYSREG(3, 0, 12, 8, 2) | ||
90 | +#define SYSREG_ICC_HPPIR1_EL1 SYSREG(3, 0, 12, 12, 2) | ||
91 | +#define SYSREG_ICC_IAR0_EL1 SYSREG(3, 0, 12, 8, 0) | ||
92 | +#define SYSREG_ICC_IAR1_EL1 SYSREG(3, 0, 12, 12, 0) | ||
93 | +#define SYSREG_ICC_IGRPEN0_EL1 SYSREG(3, 0, 12, 12, 6) | ||
94 | +#define SYSREG_ICC_IGRPEN1_EL1 SYSREG(3, 0, 12, 12, 7) | ||
95 | +#define SYSREG_ICC_PMR_EL1 SYSREG(3, 0, 4, 6, 0) | ||
96 | +#define SYSREG_ICC_RPR_EL1 SYSREG(3, 0, 12, 11, 3) | ||
97 | +#define SYSREG_ICC_SGI0R_EL1 SYSREG(3, 0, 12, 11, 7) | ||
98 | +#define SYSREG_ICC_SGI1R_EL1 SYSREG(3, 0, 12, 11, 5) | ||
99 | +#define SYSREG_ICC_SRE_EL1 SYSREG(3, 0, 12, 12, 5) | ||
100 | + | ||
101 | #define WFX_IS_WFE (1 << 0) | ||
102 | |||
103 | #define TMR_CTL_ENABLE (1 << 0) | ||
104 | @@ -XXX,XX +XXX,XX @@ static bool is_id_sysreg(uint32_t reg) | ||
105 | SYSREG_CRM(reg) < 8; | ||
106 | } | ||
107 | |||
108 | +static uint32_t hvf_reg2cp_reg(uint32_t reg) | ||
47 | +{ | 109 | +{ |
48 | + /* | 110 | + return ENCODE_AA64_CP_REG(CP_REG_ARM64_SYSREG_CP, |
49 | + * 2-reg-and-shift operations, size == 3 case, where the | 111 | + (reg >> SYSREG_CRN_SHIFT) & SYSREG_CRN_MASK, |
50 | + * function needs to be passed cpu_env. | 112 | + (reg >> SYSREG_CRM_SHIFT) & SYSREG_CRM_MASK, |
51 | + */ | 113 | + (reg >> SYSREG_OP0_SHIFT) & SYSREG_OP0_MASK, |
52 | + TCGv_i64 constimm; | 114 | + (reg >> SYSREG_OP1_SHIFT) & SYSREG_OP1_MASK, |
53 | + int pass; | 115 | + (reg >> SYSREG_OP2_SHIFT) & SYSREG_OP2_MASK); |
54 | + | 116 | +} |
55 | + if (!arm_dc_feature(s, ARM_FEATURE_NEON)) { | 117 | + |
56 | + return false; | 118 | +static bool hvf_sysreg_read_cp(CPUState *cpu, uint32_t reg, uint64_t *val) |
57 | + } | 119 | +{ |
58 | + | 120 | + ARMCPU *arm_cpu = ARM_CPU(cpu); |
59 | + /* UNDEF accesses to D16-D31 if they don't exist. */ | 121 | + CPUARMState *env = &arm_cpu->env; |
60 | + if (!dc_isar_feature(aa32_simd_r32, s) && | 122 | + const ARMCPRegInfo *ri; |
61 | + ((a->vd | a->vm) & 0x10)) { | 123 | + |
62 | + return false; | 124 | + ri = get_arm_cp_reginfo(arm_cpu->cp_regs, hvf_reg2cp_reg(reg)); |
63 | + } | 125 | + if (ri) { |
64 | + | 126 | + if (ri->accessfn) { |
65 | + if ((a->vm | a->vd) & a->q) { | 127 | + if (ri->accessfn(env, ri, true) != CP_ACCESS_OK) { |
66 | + return false; | 128 | + return false; |
67 | + } | 129 | + } |
68 | + | 130 | + } |
69 | + if (!vfp_access_check(s)) { | 131 | + if (ri->type & ARM_CP_CONST) { |
132 | + *val = ri->resetvalue; | ||
133 | + } else if (ri->readfn) { | ||
134 | + *val = ri->readfn(env, ri); | ||
135 | + } else { | ||
136 | + *val = CPREG_FIELD64(env, ri); | ||
137 | + } | ||
138 | + trace_hvf_vgic_read(ri->name, *val); | ||
70 | + return true; | 139 | + return true; |
71 | + } | 140 | + } |
72 | + | 141 | + |
73 | + /* | 142 | + return false; |
74 | + * To avoid excessive duplication of ops we implement shift | ||
75 | + * by immediate using the variable shift operations. | ||
76 | + */ | ||
77 | + constimm = tcg_const_i64(dup_const(a->size, a->shift)); | ||
78 | + | ||
79 | + for (pass = 0; pass < a->q + 1; pass++) { | ||
80 | + TCGv_i64 tmp = tcg_temp_new_i64(); | ||
81 | + | ||
82 | + neon_load_reg64(tmp, a->vm + pass); | ||
83 | + fn(tmp, cpu_env, tmp, constimm); | ||
84 | + neon_store_reg64(tmp, a->vd + pass); | ||
85 | + } | ||
86 | + tcg_temp_free_i64(constimm); | ||
87 | + return true; | ||
88 | +} | 143 | +} |
89 | + | 144 | + |
90 | +static bool do_2shift_env_32(DisasContext *s, arg_2reg_shift *a, | 145 | static int hvf_sysreg_read(CPUState *cpu, uint32_t reg, uint32_t rt) |
91 | + NeonGenTwoOpEnvFn *fn) | 146 | { |
147 | ARMCPU *arm_cpu = ARM_CPU(cpu); | ||
148 | @@ -XXX,XX +XXX,XX @@ static int hvf_sysreg_read(CPUState *cpu, uint32_t reg, uint32_t rt) | ||
149 | case SYSREG_OSDLR_EL1: | ||
150 | /* Dummy register */ | ||
151 | break; | ||
152 | + case SYSREG_ICC_AP0R0_EL1: | ||
153 | + case SYSREG_ICC_AP0R1_EL1: | ||
154 | + case SYSREG_ICC_AP0R2_EL1: | ||
155 | + case SYSREG_ICC_AP0R3_EL1: | ||
156 | + case SYSREG_ICC_AP1R0_EL1: | ||
157 | + case SYSREG_ICC_AP1R1_EL1: | ||
158 | + case SYSREG_ICC_AP1R2_EL1: | ||
159 | + case SYSREG_ICC_AP1R3_EL1: | ||
160 | + case SYSREG_ICC_ASGI1R_EL1: | ||
161 | + case SYSREG_ICC_BPR0_EL1: | ||
162 | + case SYSREG_ICC_BPR1_EL1: | ||
163 | + case SYSREG_ICC_DIR_EL1: | ||
164 | + case SYSREG_ICC_EOIR0_EL1: | ||
165 | + case SYSREG_ICC_EOIR1_EL1: | ||
166 | + case SYSREG_ICC_HPPIR0_EL1: | ||
167 | + case SYSREG_ICC_HPPIR1_EL1: | ||
168 | + case SYSREG_ICC_IAR0_EL1: | ||
169 | + case SYSREG_ICC_IAR1_EL1: | ||
170 | + case SYSREG_ICC_IGRPEN0_EL1: | ||
171 | + case SYSREG_ICC_IGRPEN1_EL1: | ||
172 | + case SYSREG_ICC_PMR_EL1: | ||
173 | + case SYSREG_ICC_SGI0R_EL1: | ||
174 | + case SYSREG_ICC_SGI1R_EL1: | ||
175 | + case SYSREG_ICC_SRE_EL1: | ||
176 | + case SYSREG_ICC_CTLR_EL1: | ||
177 | + /* Call the TCG sysreg handler. This is only safe for GICv3 regs. */ | ||
178 | + if (!hvf_sysreg_read_cp(cpu, reg, &val)) { | ||
179 | + hvf_raise_exception(cpu, EXCP_UDEF, syn_uncategorized()); | ||
180 | + } | ||
181 | + break; | ||
182 | default: | ||
183 | if (is_id_sysreg(reg)) { | ||
184 | /* ID system registers read as RES0 */ | ||
185 | @@ -XXX,XX +XXX,XX @@ static void pmswinc_write(CPUARMState *env, uint64_t value) | ||
186 | } | ||
187 | } | ||
188 | |||
189 | +static bool hvf_sysreg_write_cp(CPUState *cpu, uint32_t reg, uint64_t val) | ||
92 | +{ | 190 | +{ |
93 | + /* | 191 | + ARMCPU *arm_cpu = ARM_CPU(cpu); |
94 | + * 2-reg-and-shift operations, size < 3 case, where the | 192 | + CPUARMState *env = &arm_cpu->env; |
95 | + * helper needs to be passed cpu_env. | 193 | + const ARMCPRegInfo *ri; |
96 | + */ | 194 | + |
97 | + TCGv_i32 constimm; | 195 | + ri = get_arm_cp_reginfo(arm_cpu->cp_regs, hvf_reg2cp_reg(reg)); |
98 | + int pass; | 196 | + |
99 | + | 197 | + if (ri) { |
100 | + if (!arm_dc_feature(s, ARM_FEATURE_NEON)) { | 198 | + if (ri->accessfn) { |
101 | + return false; | 199 | + if (ri->accessfn(env, ri, false) != CP_ACCESS_OK) { |
102 | + } | 200 | + return false; |
103 | + | 201 | + } |
104 | + /* UNDEF accesses to D16-D31 if they don't exist. */ | 202 | + } |
105 | + if (!dc_isar_feature(aa32_simd_r32, s) && | 203 | + if (ri->writefn) { |
106 | + ((a->vd | a->vm) & 0x10)) { | 204 | + ri->writefn(env, ri, val); |
107 | + return false; | 205 | + } else { |
108 | + } | 206 | + CPREG_FIELD64(env, ri) = val; |
109 | + | 207 | + } |
110 | + if ((a->vm | a->vd) & a->q) { | 208 | + |
111 | + return false; | 209 | + trace_hvf_vgic_write(ri->name, val); |
112 | + } | ||
113 | + | ||
114 | + if (!vfp_access_check(s)) { | ||
115 | + return true; | 210 | + return true; |
116 | + } | 211 | + } |
117 | + | 212 | + |
118 | + /* | 213 | + return false; |
119 | + * To avoid excessive duplication of ops we implement shift | ||
120 | + * by immediate using the variable shift operations. | ||
121 | + */ | ||
122 | + constimm = tcg_const_i32(dup_const(a->size, a->shift)); | ||
123 | + | ||
124 | + for (pass = 0; pass < (a->q ? 4 : 2); pass++) { | ||
125 | + TCGv_i32 tmp = neon_load_reg(a->vm, pass); | ||
126 | + fn(tmp, cpu_env, tmp, constimm); | ||
127 | + neon_store_reg(a->vd, pass, tmp); | ||
128 | + } | ||
129 | + tcg_temp_free_i32(constimm); | ||
130 | + return true; | ||
131 | +} | 214 | +} |
132 | + | 215 | + |
133 | +#define DO_2SHIFT_ENV(INSN, FUNC) \ | 216 | static int hvf_sysreg_write(CPUState *cpu, uint32_t reg, uint64_t val) |
134 | + static bool trans_##INSN##_64_2sh(DisasContext *s, arg_2reg_shift *a) \ | 217 | { |
135 | + { \ | 218 | ARMCPU *arm_cpu = ARM_CPU(cpu); |
136 | + return do_2shift_env_64(s, a, gen_helper_neon_##FUNC##64); \ | 219 | @@ -XXX,XX +XXX,XX @@ static int hvf_sysreg_write(CPUState *cpu, uint32_t reg, uint64_t val) |
137 | + } \ | 220 | case SYSREG_OSDLR_EL1: |
138 | + static bool trans_##INSN##_2sh(DisasContext *s, arg_2reg_shift *a) \ | 221 | /* Dummy register */ |
139 | + { \ | 222 | break; |
140 | + static NeonGenTwoOpEnvFn * const fns[] = { \ | 223 | + case SYSREG_ICC_AP0R0_EL1: |
141 | + gen_helper_neon_##FUNC##8, \ | 224 | + case SYSREG_ICC_AP0R1_EL1: |
142 | + gen_helper_neon_##FUNC##16, \ | 225 | + case SYSREG_ICC_AP0R2_EL1: |
143 | + gen_helper_neon_##FUNC##32, \ | 226 | + case SYSREG_ICC_AP0R3_EL1: |
144 | + }; \ | 227 | + case SYSREG_ICC_AP1R0_EL1: |
145 | + assert(a->size < ARRAY_SIZE(fns)); \ | 228 | + case SYSREG_ICC_AP1R1_EL1: |
146 | + return do_2shift_env_32(s, a, fns[a->size]); \ | 229 | + case SYSREG_ICC_AP1R2_EL1: |
147 | + } | 230 | + case SYSREG_ICC_AP1R3_EL1: |
148 | + | 231 | + case SYSREG_ICC_ASGI1R_EL1: |
149 | +DO_2SHIFT_ENV(VQSHLU, qshlu_s) | 232 | + case SYSREG_ICC_BPR0_EL1: |
150 | +DO_2SHIFT_ENV(VQSHL_U, qshl_u) | 233 | + case SYSREG_ICC_BPR1_EL1: |
151 | +DO_2SHIFT_ENV(VQSHL_S, qshl_s) | 234 | + case SYSREG_ICC_CTLR_EL1: |
152 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 235 | + case SYSREG_ICC_DIR_EL1: |
236 | + case SYSREG_ICC_EOIR0_EL1: | ||
237 | + case SYSREG_ICC_EOIR1_EL1: | ||
238 | + case SYSREG_ICC_HPPIR0_EL1: | ||
239 | + case SYSREG_ICC_HPPIR1_EL1: | ||
240 | + case SYSREG_ICC_IAR0_EL1: | ||
241 | + case SYSREG_ICC_IAR1_EL1: | ||
242 | + case SYSREG_ICC_IGRPEN0_EL1: | ||
243 | + case SYSREG_ICC_IGRPEN1_EL1: | ||
244 | + case SYSREG_ICC_PMR_EL1: | ||
245 | + case SYSREG_ICC_SGI0R_EL1: | ||
246 | + case SYSREG_ICC_SGI1R_EL1: | ||
247 | + case SYSREG_ICC_SRE_EL1: | ||
248 | + /* Call the TCG sysreg handler. This is only safe for GICv3 regs. */ | ||
249 | + if (!hvf_sysreg_write_cp(cpu, reg, val)) { | ||
250 | + hvf_raise_exception(cpu, EXCP_UDEF, syn_uncategorized()); | ||
251 | + } | ||
252 | + break; | ||
253 | default: | ||
254 | cpu_synchronize_state(cpu); | ||
255 | trace_hvf_unhandled_sysreg_write(env->pc, reg, | ||
256 | diff --git a/target/arm/hvf/trace-events b/target/arm/hvf/trace-events | ||
153 | index XXXXXXX..XXXXXXX 100644 | 257 | index XXXXXXX..XXXXXXX 100644 |
154 | --- a/target/arm/translate.c | 258 | --- a/target/arm/hvf/trace-events |
155 | +++ b/target/arm/translate.c | 259 | +++ b/target/arm/hvf/trace-events |
156 | @@ -XXX,XX +XXX,XX @@ static inline void gen_neon_rsb(int size, TCGv_i32 t0, TCGv_i32 t1) | 260 | @@ -XXX,XX +XXX,XX @@ hvf_unknown_hvc(uint64_t x0) "unknown HVC! 0x%016"PRIx64 |
157 | } | 261 | hvf_unknown_smc(uint64_t x0) "unknown SMC! 0x%016"PRIx64 |
158 | } | 262 | hvf_exit(uint64_t syndrome, uint32_t ec, uint64_t pc) "exit: 0x%"PRIx64" [ec=0x%x pc=0x%"PRIx64"]" |
159 | 263 | hvf_psci_call(uint64_t x0, uint64_t x1, uint64_t x2, uint64_t x3, uint32_t cpuid) "PSCI Call x0=0x%016"PRIx64" x1=0x%016"PRIx64" x2=0x%016"PRIx64" x3=0x%016"PRIx64" cpu=0x%x" | |
160 | -#define GEN_NEON_INTEGER_OP_ENV(name) do { \ | 264 | +hvf_vgic_write(const char *name, uint64_t val) "vgic write to %s [val=0x%016"PRIx64"]" |
161 | - switch ((size << 1) | u) { \ | 265 | +hvf_vgic_read(const char *name, uint64_t val) "vgic read from %s [val=0x%016"PRIx64"]" |
162 | - case 0: \ | ||
163 | - gen_helper_neon_##name##_s8(tmp, cpu_env, tmp, tmp2); \ | ||
164 | - break; \ | ||
165 | - case 1: \ | ||
166 | - gen_helper_neon_##name##_u8(tmp, cpu_env, tmp, tmp2); \ | ||
167 | - break; \ | ||
168 | - case 2: \ | ||
169 | - gen_helper_neon_##name##_s16(tmp, cpu_env, tmp, tmp2); \ | ||
170 | - break; \ | ||
171 | - case 3: \ | ||
172 | - gen_helper_neon_##name##_u16(tmp, cpu_env, tmp, tmp2); \ | ||
173 | - break; \ | ||
174 | - case 4: \ | ||
175 | - gen_helper_neon_##name##_s32(tmp, cpu_env, tmp, tmp2); \ | ||
176 | - break; \ | ||
177 | - case 5: \ | ||
178 | - gen_helper_neon_##name##_u32(tmp, cpu_env, tmp, tmp2); \ | ||
179 | - break; \ | ||
180 | - default: return 1; \ | ||
181 | - }} while (0) | ||
182 | - | ||
183 | static TCGv_i32 neon_load_scratch(int scratch) | ||
184 | { | ||
185 | TCGv_i32 tmp = tcg_temp_new_i32(); | ||
186 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
187 | int size; | ||
188 | int shift; | ||
189 | int pass; | ||
190 | - int count; | ||
191 | int u; | ||
192 | int vec_size; | ||
193 | uint32_t imm; | ||
194 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
195 | case 3: /* VRSRA */ | ||
196 | case 4: /* VSRI */ | ||
197 | case 5: /* VSHL, VSLI */ | ||
198 | + case 6: /* VQSHLU */ | ||
199 | + case 7: /* VQSHL */ | ||
200 | return 1; /* handled by decodetree */ | ||
201 | default: | ||
202 | break; | ||
203 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
204 | size--; | ||
205 | } | ||
206 | shift = (insn >> 16) & ((1 << (3 + size)) - 1); | ||
207 | - if (op < 8) { | ||
208 | - /* Shift by immediate: | ||
209 | - VSHR, VSRA, VRSHR, VRSRA, VSRI, VSHL, VQSHL, VQSHLU. */ | ||
210 | - if (q && ((rd | rm) & 1)) { | ||
211 | - return 1; | ||
212 | - } | ||
213 | - if (!u && (op == 4 || op == 6)) { | ||
214 | - return 1; | ||
215 | - } | ||
216 | - /* Right shifts are encoded as N - shift, where N is the | ||
217 | - element size in bits. */ | ||
218 | - if (op <= 4) { | ||
219 | - shift = shift - (1 << (size + 3)); | ||
220 | - } | ||
221 | - | ||
222 | - if (size == 3) { | ||
223 | - count = q + 1; | ||
224 | - } else { | ||
225 | - count = q ? 4: 2; | ||
226 | - } | ||
227 | - | ||
228 | - /* To avoid excessive duplication of ops we implement shift | ||
229 | - * by immediate using the variable shift operations. | ||
230 | - */ | ||
231 | - imm = dup_const(size, shift); | ||
232 | - | ||
233 | - for (pass = 0; pass < count; pass++) { | ||
234 | - if (size == 3) { | ||
235 | - neon_load_reg64(cpu_V0, rm + pass); | ||
236 | - tcg_gen_movi_i64(cpu_V1, imm); | ||
237 | - switch (op) { | ||
238 | - case 6: /* VQSHLU */ | ||
239 | - gen_helper_neon_qshlu_s64(cpu_V0, cpu_env, | ||
240 | - cpu_V0, cpu_V1); | ||
241 | - break; | ||
242 | - case 7: /* VQSHL */ | ||
243 | - if (u) { | ||
244 | - gen_helper_neon_qshl_u64(cpu_V0, cpu_env, | ||
245 | - cpu_V0, cpu_V1); | ||
246 | - } else { | ||
247 | - gen_helper_neon_qshl_s64(cpu_V0, cpu_env, | ||
248 | - cpu_V0, cpu_V1); | ||
249 | - } | ||
250 | - break; | ||
251 | - default: | ||
252 | - g_assert_not_reached(); | ||
253 | - } | ||
254 | - neon_store_reg64(cpu_V0, rd + pass); | ||
255 | - } else { /* size < 3 */ | ||
256 | - /* Operands in T0 and T1. */ | ||
257 | - tmp = neon_load_reg(rm, pass); | ||
258 | - tmp2 = tcg_temp_new_i32(); | ||
259 | - tcg_gen_movi_i32(tmp2, imm); | ||
260 | - switch (op) { | ||
261 | - case 6: /* VQSHLU */ | ||
262 | - switch (size) { | ||
263 | - case 0: | ||
264 | - gen_helper_neon_qshlu_s8(tmp, cpu_env, | ||
265 | - tmp, tmp2); | ||
266 | - break; | ||
267 | - case 1: | ||
268 | - gen_helper_neon_qshlu_s16(tmp, cpu_env, | ||
269 | - tmp, tmp2); | ||
270 | - break; | ||
271 | - case 2: | ||
272 | - gen_helper_neon_qshlu_s32(tmp, cpu_env, | ||
273 | - tmp, tmp2); | ||
274 | - break; | ||
275 | - default: | ||
276 | - abort(); | ||
277 | - } | ||
278 | - break; | ||
279 | - case 7: /* VQSHL */ | ||
280 | - GEN_NEON_INTEGER_OP_ENV(qshl); | ||
281 | - break; | ||
282 | - default: | ||
283 | - g_assert_not_reached(); | ||
284 | - } | ||
285 | - tcg_temp_free_i32(tmp2); | ||
286 | - neon_store_reg(rd, pass, tmp); | ||
287 | - } | ||
288 | - } /* for pass */ | ||
289 | - } else if (op < 10) { | ||
290 | + if (op < 10) { | ||
291 | /* Shift by immediate and narrow: | ||
292 | VSHRN, VRSHRN, VQSHRN, VQRSHRN. */ | ||
293 | int input_unsigned = (op == 8) ? !u : u; | ||
294 | -- | 266 | -- |
295 | 2.20.1 | 267 | 2.34.1 |
296 | |||
297 | diff view generated by jsdifflib |
1 | From: Paul Zimmerman <pauldzim@gmail.com> | 1 | From: Alexander Graf <agraf@csgraf.de> |
---|---|---|---|
2 | 2 | ||
3 | Wire the dwc-hsotg (dwc2) emulation into Qemu | 3 | Up to now, the finalize_gic_version() code open coded what is essentially |
4 | 4 | a support bitmap match between host/emulation environment and desired | |
5 | Signed-off-by: Paul Zimmerman <pauldzim@gmail.com> | 5 | target GIC type. |
6 | Reviewed-by: Philippe Mathieu-Daude <f4bug@amsat.org> | 6 | |
7 | Message-id: 20200520235349.21215-7-pauldzim@gmail.com | 7 | This open coding leads to undesirable side effects. For example, a VM with |
8 | KVM and -smp 10 will automatically choose GICv3 while the same command | ||
9 | line with TCG will stay on GICv2 and fail the launch. | ||
10 | |||
11 | This patch combines the TCG and KVM matching code paths by making | ||
12 | everything a 2 pass process. First, we determine which GIC versions the | ||
13 | current environment is able to support, then we go through a single | ||
14 | state machine to determine which target GIC mode that means for us. | ||
15 | |||
16 | After this patch, the only user noticable changes should be consolidated | ||
17 | error messages as well as TCG -M virt supporting -smp > 8 automatically. | ||
18 | |||
19 | Signed-off-by: Alexander Graf <agraf@csgraf.de> | ||
20 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
21 | Reviewed-by: Cornelia Huck <cohuck@redhat.com> | ||
22 | Reviewed-by: Zenghui Yu <yuzenghui@huawei.com> | ||
23 | Message-id: 20221223090107.98888-2-agraf@csgraf.de | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 24 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | --- | 25 | --- |
10 | include/hw/arm/bcm2835_peripherals.h | 3 ++- | 26 | include/hw/arm/virt.h | 15 ++-- |
11 | hw/arm/bcm2835_peripherals.c | 21 ++++++++++++++++++++- | 27 | hw/arm/virt.c | 198 ++++++++++++++++++++++-------------------- |
12 | 2 files changed, 22 insertions(+), 2 deletions(-) | 28 | 2 files changed, 112 insertions(+), 101 deletions(-) |
13 | 29 | ||
14 | diff --git a/include/hw/arm/bcm2835_peripherals.h b/include/hw/arm/bcm2835_peripherals.h | 30 | diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h |
15 | index XXXXXXX..XXXXXXX 100644 | 31 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/include/hw/arm/bcm2835_peripherals.h | 32 | --- a/include/hw/arm/virt.h |
17 | +++ b/include/hw/arm/bcm2835_peripherals.h | 33 | +++ b/include/hw/arm/virt.h |
18 | @@ -XXX,XX +XXX,XX @@ | 34 | @@ -XXX,XX +XXX,XX @@ typedef enum VirtMSIControllerType { |
19 | #include "hw/sd/bcm2835_sdhost.h" | 35 | } VirtMSIControllerType; |
20 | #include "hw/gpio/bcm2835_gpio.h" | 36 | |
21 | #include "hw/timer/bcm2835_systmr.h" | 37 | typedef enum VirtGICType { |
22 | +#include "hw/usb/hcd-dwc2.h" | 38 | - VIRT_GIC_VERSION_MAX, |
23 | #include "hw/misc/unimp.h" | 39 | - VIRT_GIC_VERSION_HOST, |
24 | 40 | - VIRT_GIC_VERSION_2, | |
25 | #define TYPE_BCM2835_PERIPHERALS "bcm2835-peripherals" | 41 | - VIRT_GIC_VERSION_3, |
26 | @@ -XXX,XX +XXX,XX @@ typedef struct BCM2835PeripheralState { | 42 | - VIRT_GIC_VERSION_4, |
27 | UnimplementedDeviceState ave0; | 43 | + VIRT_GIC_VERSION_MAX = 0, |
28 | UnimplementedDeviceState bscsl; | 44 | + VIRT_GIC_VERSION_HOST = 1, |
29 | UnimplementedDeviceState smi; | 45 | + /* The concrete GIC values have to match the GIC version number */ |
30 | - UnimplementedDeviceState dwc2; | 46 | + VIRT_GIC_VERSION_2 = 2, |
31 | + DWC2State dwc2; | 47 | + VIRT_GIC_VERSION_3 = 3, |
32 | UnimplementedDeviceState sdramc; | 48 | + VIRT_GIC_VERSION_4 = 4, |
33 | } BCM2835PeripheralState; | 49 | VIRT_GIC_VERSION_NOSEL, |
34 | 50 | } VirtGICType; | |
35 | diff --git a/hw/arm/bcm2835_peripherals.c b/hw/arm/bcm2835_peripherals.c | 51 | |
52 | +#define VIRT_GIC_VERSION_2_MASK BIT(VIRT_GIC_VERSION_2) | ||
53 | +#define VIRT_GIC_VERSION_3_MASK BIT(VIRT_GIC_VERSION_3) | ||
54 | +#define VIRT_GIC_VERSION_4_MASK BIT(VIRT_GIC_VERSION_4) | ||
55 | + | ||
56 | struct VirtMachineClass { | ||
57 | MachineClass parent; | ||
58 | bool disallow_affinity_adjustment; | ||
59 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c | ||
36 | index XXXXXXX..XXXXXXX 100644 | 60 | index XXXXXXX..XXXXXXX 100644 |
37 | --- a/hw/arm/bcm2835_peripherals.c | 61 | --- a/hw/arm/virt.c |
38 | +++ b/hw/arm/bcm2835_peripherals.c | 62 | +++ b/hw/arm/virt.c |
39 | @@ -XXX,XX +XXX,XX @@ static void bcm2835_peripherals_init(Object *obj) | 63 | @@ -XXX,XX +XXX,XX @@ static void virt_set_memmap(VirtMachineState *vms, int pa_bits) |
40 | /* Mphi */ | 64 | } |
41 | sysbus_init_child_obj(obj, "mphi", &s->mphi, sizeof(s->mphi), | ||
42 | TYPE_BCM2835_MPHI); | ||
43 | + | ||
44 | + /* DWC2 */ | ||
45 | + sysbus_init_child_obj(obj, "dwc2", &s->dwc2, sizeof(s->dwc2), | ||
46 | + TYPE_DWC2_USB); | ||
47 | + | ||
48 | + object_property_add_const_link(OBJECT(&s->dwc2), "dma-mr", | ||
49 | + OBJECT(&s->gpu_bus_mr)); | ||
50 | } | 65 | } |
51 | 66 | ||
52 | static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp) | 67 | +static VirtGICType finalize_gic_version_do(const char *accel_name, |
53 | @@ -XXX,XX +XXX,XX @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp) | 68 | + VirtGICType gic_version, |
54 | qdev_get_gpio_in_named(DEVICE(&s->ic), BCM2835_IC_GPU_IRQ, | 69 | + int gics_supported, |
55 | INTERRUPT_HOSTPORT)); | 70 | + unsigned int max_cpus) |
56 | 71 | +{ | |
57 | + /* DWC2 */ | 72 | + /* Convert host/max/nosel to GIC version number */ |
58 | + object_property_set_bool(OBJECT(&s->dwc2), true, "realized", &err); | 73 | + switch (gic_version) { |
59 | + if (err) { | 74 | + case VIRT_GIC_VERSION_HOST: |
60 | + error_propagate(errp, err); | 75 | + if (!kvm_enabled()) { |
61 | + return; | 76 | + error_report("gic-version=host requires KVM"); |
77 | + exit(1); | ||
78 | + } | ||
79 | + | ||
80 | + /* For KVM, gic-version=host means gic-version=max */ | ||
81 | + return finalize_gic_version_do(accel_name, VIRT_GIC_VERSION_MAX, | ||
82 | + gics_supported, max_cpus); | ||
83 | + case VIRT_GIC_VERSION_MAX: | ||
84 | + if (gics_supported & VIRT_GIC_VERSION_4_MASK) { | ||
85 | + gic_version = VIRT_GIC_VERSION_4; | ||
86 | + } else if (gics_supported & VIRT_GIC_VERSION_3_MASK) { | ||
87 | + gic_version = VIRT_GIC_VERSION_3; | ||
88 | + } else { | ||
89 | + gic_version = VIRT_GIC_VERSION_2; | ||
90 | + } | ||
91 | + break; | ||
92 | + case VIRT_GIC_VERSION_NOSEL: | ||
93 | + if ((gics_supported & VIRT_GIC_VERSION_2_MASK) && | ||
94 | + max_cpus <= GIC_NCPU) { | ||
95 | + gic_version = VIRT_GIC_VERSION_2; | ||
96 | + } else if (gics_supported & VIRT_GIC_VERSION_3_MASK) { | ||
97 | + /* | ||
98 | + * in case the host does not support v2 emulation or | ||
99 | + * the end-user requested more than 8 VCPUs we now default | ||
100 | + * to v3. In any case defaulting to v2 would be broken. | ||
101 | + */ | ||
102 | + gic_version = VIRT_GIC_VERSION_3; | ||
103 | + } else if (max_cpus > GIC_NCPU) { | ||
104 | + error_report("%s only supports GICv2 emulation but more than 8 " | ||
105 | + "vcpus are requested", accel_name); | ||
106 | + exit(1); | ||
107 | + } | ||
108 | + break; | ||
109 | + case VIRT_GIC_VERSION_2: | ||
110 | + case VIRT_GIC_VERSION_3: | ||
111 | + case VIRT_GIC_VERSION_4: | ||
112 | + break; | ||
62 | + } | 113 | + } |
63 | + | 114 | + |
64 | + memory_region_add_subregion(&s->peri_mr, USB_OTG_OFFSET, | 115 | + /* Check chosen version is effectively supported */ |
65 | + sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->dwc2), 0)); | 116 | + switch (gic_version) { |
66 | + sysbus_connect_irq(SYS_BUS_DEVICE(&s->dwc2), 0, | 117 | + case VIRT_GIC_VERSION_2: |
67 | + qdev_get_gpio_in_named(DEVICE(&s->ic), BCM2835_IC_GPU_IRQ, | 118 | + if (!(gics_supported & VIRT_GIC_VERSION_2_MASK)) { |
68 | + INTERRUPT_USB)); | 119 | + error_report("%s does not support GICv2 emulation", accel_name); |
69 | + | 120 | + exit(1); |
70 | create_unimp(s, &s->armtmr, "bcm2835-sp804", ARMCTRL_TIMER0_1_OFFSET, 0x40); | 121 | + } |
71 | create_unimp(s, &s->cprman, "bcm2835-cprman", CPRMAN_OFFSET, 0x1000); | 122 | + break; |
72 | create_unimp(s, &s->a2w, "bcm2835-a2w", A2W_OFFSET, 0x1000); | 123 | + case VIRT_GIC_VERSION_3: |
73 | @@ -XXX,XX +XXX,XX @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp) | 124 | + if (!(gics_supported & VIRT_GIC_VERSION_3_MASK)) { |
74 | create_unimp(s, &s->otp, "bcm2835-otp", OTP_OFFSET, 0x80); | 125 | + error_report("%s does not support GICv3 emulation", accel_name); |
75 | create_unimp(s, &s->dbus, "bcm2835-dbus", DBUS_OFFSET, 0x8000); | 126 | + exit(1); |
76 | create_unimp(s, &s->ave0, "bcm2835-ave0", AVE0_OFFSET, 0x8000); | 127 | + } |
77 | - create_unimp(s, &s->dwc2, "dwc-usb2", USB_OTG_OFFSET, 0x1000); | 128 | + break; |
78 | create_unimp(s, &s->sdramc, "bcm2835-sdramc", SDRAMC_OFFSET, 0x100); | 129 | + case VIRT_GIC_VERSION_4: |
130 | + if (!(gics_supported & VIRT_GIC_VERSION_4_MASK)) { | ||
131 | + error_report("%s does not support GICv4 emulation, is virtualization=on?", | ||
132 | + accel_name); | ||
133 | + exit(1); | ||
134 | + } | ||
135 | + break; | ||
136 | + default: | ||
137 | + error_report("logic error in finalize_gic_version"); | ||
138 | + exit(1); | ||
139 | + break; | ||
140 | + } | ||
141 | + | ||
142 | + return gic_version; | ||
143 | +} | ||
144 | + | ||
145 | /* | ||
146 | * finalize_gic_version - Determines the final gic_version | ||
147 | * according to the gic-version property | ||
148 | @@ -XXX,XX +XXX,XX @@ static void virt_set_memmap(VirtMachineState *vms, int pa_bits) | ||
149 | */ | ||
150 | static void finalize_gic_version(VirtMachineState *vms) | ||
151 | { | ||
152 | + const char *accel_name = current_accel_name(); | ||
153 | unsigned int max_cpus = MACHINE(vms)->smp.max_cpus; | ||
154 | + int gics_supported = 0; | ||
155 | |||
156 | - if (kvm_enabled()) { | ||
157 | - int probe_bitmap; | ||
158 | + /* Determine which GIC versions the current environment supports */ | ||
159 | + if (kvm_enabled() && kvm_irqchip_in_kernel()) { | ||
160 | + int probe_bitmap = kvm_arm_vgic_probe(); | ||
161 | |||
162 | - if (!kvm_irqchip_in_kernel()) { | ||
163 | - switch (vms->gic_version) { | ||
164 | - case VIRT_GIC_VERSION_HOST: | ||
165 | - warn_report( | ||
166 | - "gic-version=host not relevant with kernel-irqchip=off " | ||
167 | - "as only userspace GICv2 is supported. Using v2 ..."); | ||
168 | - return; | ||
169 | - case VIRT_GIC_VERSION_MAX: | ||
170 | - case VIRT_GIC_VERSION_NOSEL: | ||
171 | - vms->gic_version = VIRT_GIC_VERSION_2; | ||
172 | - return; | ||
173 | - case VIRT_GIC_VERSION_2: | ||
174 | - return; | ||
175 | - case VIRT_GIC_VERSION_3: | ||
176 | - error_report( | ||
177 | - "gic-version=3 is not supported with kernel-irqchip=off"); | ||
178 | - exit(1); | ||
179 | - case VIRT_GIC_VERSION_4: | ||
180 | - error_report( | ||
181 | - "gic-version=4 is not supported with kernel-irqchip=off"); | ||
182 | - exit(1); | ||
183 | - } | ||
184 | - } | ||
185 | - | ||
186 | - probe_bitmap = kvm_arm_vgic_probe(); | ||
187 | if (!probe_bitmap) { | ||
188 | error_report("Unable to determine GIC version supported by host"); | ||
189 | exit(1); | ||
190 | } | ||
191 | |||
192 | - switch (vms->gic_version) { | ||
193 | - case VIRT_GIC_VERSION_HOST: | ||
194 | - case VIRT_GIC_VERSION_MAX: | ||
195 | - if (probe_bitmap & KVM_ARM_VGIC_V3) { | ||
196 | - vms->gic_version = VIRT_GIC_VERSION_3; | ||
197 | - } else { | ||
198 | - vms->gic_version = VIRT_GIC_VERSION_2; | ||
199 | - } | ||
200 | - return; | ||
201 | - case VIRT_GIC_VERSION_NOSEL: | ||
202 | - if ((probe_bitmap & KVM_ARM_VGIC_V2) && max_cpus <= GIC_NCPU) { | ||
203 | - vms->gic_version = VIRT_GIC_VERSION_2; | ||
204 | - } else if (probe_bitmap & KVM_ARM_VGIC_V3) { | ||
205 | - /* | ||
206 | - * in case the host does not support v2 in-kernel emulation or | ||
207 | - * the end-user requested more than 8 VCPUs we now default | ||
208 | - * to v3. In any case defaulting to v2 would be broken. | ||
209 | - */ | ||
210 | - vms->gic_version = VIRT_GIC_VERSION_3; | ||
211 | - } else if (max_cpus > GIC_NCPU) { | ||
212 | - error_report("host only supports in-kernel GICv2 emulation " | ||
213 | - "but more than 8 vcpus are requested"); | ||
214 | - exit(1); | ||
215 | - } | ||
216 | - break; | ||
217 | - case VIRT_GIC_VERSION_2: | ||
218 | - case VIRT_GIC_VERSION_3: | ||
219 | - break; | ||
220 | - case VIRT_GIC_VERSION_4: | ||
221 | - error_report("gic-version=4 is not supported with KVM"); | ||
222 | - exit(1); | ||
223 | + if (probe_bitmap & KVM_ARM_VGIC_V2) { | ||
224 | + gics_supported |= VIRT_GIC_VERSION_2_MASK; | ||
225 | } | ||
226 | - | ||
227 | - /* Check chosen version is effectively supported by the host */ | ||
228 | - if (vms->gic_version == VIRT_GIC_VERSION_2 && | ||
229 | - !(probe_bitmap & KVM_ARM_VGIC_V2)) { | ||
230 | - error_report("host does not support in-kernel GICv2 emulation"); | ||
231 | - exit(1); | ||
232 | - } else if (vms->gic_version == VIRT_GIC_VERSION_3 && | ||
233 | - !(probe_bitmap & KVM_ARM_VGIC_V3)) { | ||
234 | - error_report("host does not support in-kernel GICv3 emulation"); | ||
235 | - exit(1); | ||
236 | + if (probe_bitmap & KVM_ARM_VGIC_V3) { | ||
237 | + gics_supported |= VIRT_GIC_VERSION_3_MASK; | ||
238 | } | ||
239 | - return; | ||
240 | - } | ||
241 | - | ||
242 | - /* TCG mode */ | ||
243 | - switch (vms->gic_version) { | ||
244 | - case VIRT_GIC_VERSION_NOSEL: | ||
245 | - vms->gic_version = VIRT_GIC_VERSION_2; | ||
246 | - break; | ||
247 | - case VIRT_GIC_VERSION_MAX: | ||
248 | + } else if (kvm_enabled() && !kvm_irqchip_in_kernel()) { | ||
249 | + /* KVM w/o kernel irqchip can only deal with GICv2 */ | ||
250 | + gics_supported |= VIRT_GIC_VERSION_2_MASK; | ||
251 | + accel_name = "KVM with kernel-irqchip=off"; | ||
252 | + } else { | ||
253 | + gics_supported |= VIRT_GIC_VERSION_2_MASK; | ||
254 | if (module_object_class_by_name("arm-gicv3")) { | ||
255 | - /* CONFIG_ARM_GICV3_TCG was set */ | ||
256 | + gics_supported |= VIRT_GIC_VERSION_3_MASK; | ||
257 | if (vms->virt) { | ||
258 | /* GICv4 only makes sense if CPU has EL2 */ | ||
259 | - vms->gic_version = VIRT_GIC_VERSION_4; | ||
260 | - } else { | ||
261 | - vms->gic_version = VIRT_GIC_VERSION_3; | ||
262 | + gics_supported |= VIRT_GIC_VERSION_4_MASK; | ||
263 | } | ||
264 | - } else { | ||
265 | - vms->gic_version = VIRT_GIC_VERSION_2; | ||
266 | } | ||
267 | - break; | ||
268 | - case VIRT_GIC_VERSION_HOST: | ||
269 | - error_report("gic-version=host requires KVM"); | ||
270 | - exit(1); | ||
271 | - case VIRT_GIC_VERSION_4: | ||
272 | - if (!vms->virt) { | ||
273 | - error_report("gic-version=4 requires virtualization enabled"); | ||
274 | - exit(1); | ||
275 | - } | ||
276 | - break; | ||
277 | - case VIRT_GIC_VERSION_2: | ||
278 | - case VIRT_GIC_VERSION_3: | ||
279 | - break; | ||
280 | } | ||
281 | + | ||
282 | + /* | ||
283 | + * Then convert helpers like host/max to concrete GIC versions and ensure | ||
284 | + * the desired version is supported | ||
285 | + */ | ||
286 | + vms->gic_version = finalize_gic_version_do(accel_name, vms->gic_version, | ||
287 | + gics_supported, max_cpus); | ||
79 | } | 288 | } |
80 | 289 | ||
290 | /* | ||
81 | -- | 291 | -- |
82 | 2.20.1 | 292 | 2.34.1 |
83 | |||
84 | diff view generated by jsdifflib |
1 | From: Paul Zimmerman <pauldzim@gmail.com> | 1 | From: Alexander Graf <agraf@csgraf.de> |
---|---|---|---|
2 | 2 | ||
3 | The dwc-hsotg (dwc2) USB host depends on a short packet to | 3 | Let's explicitly list out all accelerators that we support when trying to |
4 | indicate the end of an IN transfer. The usb-storage driver | 4 | determine the supported set of GIC versions. KVM was already separate, so |
5 | currently doesn't provide this, so fix it. | 5 | the only missing one is HVF which simply reuses all of TCG's emulation |
6 | code and thus has the same compatibility matrix. | ||
6 | 7 | ||
7 | I have tested this change rather extensively using a PC | 8 | Signed-off-by: Alexander Graf <agraf@csgraf.de> |
8 | emulation with xhci, ehci, and uhci controllers, and have | 9 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
9 | not observed any regressions. | 10 | Reviewed-by: Cornelia Huck <cohuck@redhat.com> |
10 | 11 | Reviewed-by: Zenghui Yu <yuzenghui@huawei.com> | |
11 | Signed-off-by: Paul Zimmerman <pauldzim@gmail.com> | 12 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
12 | Message-id: 20200520235349.21215-6-pauldzim@gmail.com | 13 | Message-id: 20221223090107.98888-3-agraf@csgraf.de |
14 | [PMM: Added qtest to the list of accelerators] | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | --- | 16 | --- |
15 | hw/usb/dev-storage.c | 15 ++++++++++++++- | 17 | hw/arm/virt.c | 7 ++++++- |
16 | 1 file changed, 14 insertions(+), 1 deletion(-) | 18 | 1 file changed, 6 insertions(+), 1 deletion(-) |
17 | 19 | ||
18 | diff --git a/hw/usb/dev-storage.c b/hw/usb/dev-storage.c | 20 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c |
19 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/hw/usb/dev-storage.c | 22 | --- a/hw/arm/virt.c |
21 | +++ b/hw/usb/dev-storage.c | 23 | +++ b/hw/arm/virt.c |
22 | @@ -XXX,XX +XXX,XX @@ static void usb_msd_copy_data(MSDState *s, USBPacket *p) | 24 | @@ -XXX,XX +XXX,XX @@ |
23 | usb_packet_copy(p, scsi_req_get_buf(s->req) + s->scsi_off, len); | 25 | #include "sysemu/numa.h" |
24 | s->scsi_len -= len; | 26 | #include "sysemu/runstate.h" |
25 | s->scsi_off += len; | 27 | #include "sysemu/tpm.h" |
26 | + if (len > s->data_len) { | 28 | +#include "sysemu/tcg.h" |
27 | + len = s->data_len; | 29 | #include "sysemu/kvm.h" |
28 | + } | 30 | #include "sysemu/hvf.h" |
29 | s->data_len -= len; | 31 | +#include "sysemu/qtest.h" |
30 | if (s->scsi_len == 0 || s->data_len == 0) { | 32 | #include "hw/loader.h" |
31 | scsi_req_continue(s->req); | 33 | #include "qapi/error.h" |
32 | @@ -XXX,XX +XXX,XX @@ static void usb_msd_command_complete(SCSIRequest *req, uint32_t status, size_t r | 34 | #include "qemu/bitops.h" |
33 | if (s->data_len) { | 35 | @@ -XXX,XX +XXX,XX @@ static void finalize_gic_version(VirtMachineState *vms) |
34 | int len = (p->iov.size - p->actual_length); | 36 | /* KVM w/o kernel irqchip can only deal with GICv2 */ |
35 | usb_packet_skip(p, len); | 37 | gics_supported |= VIRT_GIC_VERSION_2_MASK; |
36 | + if (len > s->data_len) { | 38 | accel_name = "KVM with kernel-irqchip=off"; |
37 | + len = s->data_len; | 39 | - } else { |
38 | + } | 40 | + } else if (tcg_enabled() || hvf_enabled() || qtest_enabled()) { |
39 | s->data_len -= len; | 41 | gics_supported |= VIRT_GIC_VERSION_2_MASK; |
42 | if (module_object_class_by_name("arm-gicv3")) { | ||
43 | gics_supported |= VIRT_GIC_VERSION_3_MASK; | ||
44 | @@ -XXX,XX +XXX,XX @@ static void finalize_gic_version(VirtMachineState *vms) | ||
45 | gics_supported |= VIRT_GIC_VERSION_4_MASK; | ||
40 | } | 46 | } |
41 | if (s->data_len == 0) { | 47 | } |
42 | @@ -XXX,XX +XXX,XX @@ static void usb_msd_handle_data(USBDevice *dev, USBPacket *p) | 48 | + } else { |
43 | int len = p->iov.size - p->actual_length; | 49 | + error_report("Unsupported accelerator, can not determine GIC support"); |
44 | if (len) { | 50 | + exit(1); |
45 | usb_packet_skip(p, len); | 51 | } |
46 | + if (len > s->data_len) { | 52 | |
47 | + len = s->data_len; | 53 | /* |
48 | + } | ||
49 | s->data_len -= len; | ||
50 | if (s->data_len == 0) { | ||
51 | s->mode = USB_MSDM_CSW; | ||
52 | @@ -XXX,XX +XXX,XX @@ static void usb_msd_handle_data(USBDevice *dev, USBPacket *p) | ||
53 | int len = p->iov.size - p->actual_length; | ||
54 | if (len) { | ||
55 | usb_packet_skip(p, len); | ||
56 | + if (len > s->data_len) { | ||
57 | + len = s->data_len; | ||
58 | + } | ||
59 | s->data_len -= len; | ||
60 | if (s->data_len == 0) { | ||
61 | s->mode = USB_MSDM_CSW; | ||
62 | } | ||
63 | } | ||
64 | } | ||
65 | - if (p->actual_length < p->iov.size) { | ||
66 | + if (p->actual_length < p->iov.size && (p->short_not_ok || | ||
67 | + s->scsi_len >= p->ep->max_packet_size)) { | ||
68 | DPRINTF("Deferring packet %p [wait data-in]\n", p); | ||
69 | s->packet = p; | ||
70 | p->status = USB_RET_ASYNC; | ||
71 | -- | 54 | -- |
72 | 2.20.1 | 55 | 2.34.1 |
73 | 56 | ||
74 | 57 | diff view generated by jsdifflib |
1 | From: Paul Zimmerman <pauldzim@gmail.com> | 1 | From: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Add the dwc-hsotg (dwc2) USB host controller state definitions. | 3 | Cortex-A76 supports 40bits of address space. sbsa-ref's memory |
4 | Mostly based on hw/usb/hcd-ehci.h. | 4 | starts above this limit. |
5 | 5 | ||
6 | Signed-off-by: Paul Zimmerman <pauldzim@gmail.com> | 6 | Signed-off-by: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org> |
7 | Message-id: 20200520235349.21215-4-pauldzim@gmail.com | 7 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> |
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
9 | Message-id: 20230126114416.2447685-1-marcin.juszkiewicz@linaro.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 11 | --- |
11 | hw/usb/hcd-dwc2.h | 190 ++++++++++++++++++++++++++++++++++++++++++++++ | 12 | hw/arm/sbsa-ref.c | 1 - |
12 | 1 file changed, 190 insertions(+) | 13 | 1 file changed, 1 deletion(-) |
13 | create mode 100644 hw/usb/hcd-dwc2.h | ||
14 | 14 | ||
15 | diff --git a/hw/usb/hcd-dwc2.h b/hw/usb/hcd-dwc2.h | 15 | diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c |
16 | new file mode 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
17 | index XXXXXXX..XXXXXXX | 17 | --- a/hw/arm/sbsa-ref.c |
18 | --- /dev/null | 18 | +++ b/hw/arm/sbsa-ref.c |
19 | +++ b/hw/usb/hcd-dwc2.h | 19 | @@ -XXX,XX +XXX,XX @@ static const int sbsa_ref_irqmap[] = { |
20 | @@ -XXX,XX +XXX,XX @@ | 20 | static const char * const valid_cpus[] = { |
21 | +/* | 21 | ARM_CPU_TYPE_NAME("cortex-a57"), |
22 | + * dwc-hsotg (dwc2) USB host controller state definitions | 22 | ARM_CPU_TYPE_NAME("cortex-a72"), |
23 | + * | 23 | - ARM_CPU_TYPE_NAME("cortex-a76"), |
24 | + * Based on hw/usb/hcd-ehci.h | 24 | ARM_CPU_TYPE_NAME("neoverse-n1"), |
25 | + * | 25 | ARM_CPU_TYPE_NAME("max"), |
26 | + * Copyright (c) 2020 Paul Zimmerman <pauldzim@gmail.com> | 26 | }; |
27 | + * | ||
28 | + * This program is free software; you can redistribute it and/or modify | ||
29 | + * it under the terms of the GNU General Public License as published by | ||
30 | + * the Free Software Foundation; either version 2 of the License, or | ||
31 | + * (at your option) any later version. | ||
32 | + * | ||
33 | + * This program is distributed in the hope that it will be useful, | ||
34 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
35 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
36 | + * GNU General Public License for more details. | ||
37 | + */ | ||
38 | + | ||
39 | +#ifndef HW_USB_DWC2_H | ||
40 | +#define HW_USB_DWC2_H | ||
41 | + | ||
42 | +#include "qemu/timer.h" | ||
43 | +#include "hw/irq.h" | ||
44 | +#include "hw/sysbus.h" | ||
45 | +#include "hw/usb.h" | ||
46 | +#include "sysemu/dma.h" | ||
47 | + | ||
48 | +#define DWC2_MMIO_SIZE 0x11000 | ||
49 | + | ||
50 | +#define DWC2_NB_CHAN 8 /* Number of host channels */ | ||
51 | +#define DWC2_MAX_XFER_SIZE 65536 /* Max transfer size expected in HCTSIZ */ | ||
52 | + | ||
53 | +typedef struct DWC2Packet DWC2Packet; | ||
54 | +typedef struct DWC2State DWC2State; | ||
55 | +typedef struct DWC2Class DWC2Class; | ||
56 | + | ||
57 | +enum async_state { | ||
58 | + DWC2_ASYNC_NONE = 0, | ||
59 | + DWC2_ASYNC_INITIALIZED, | ||
60 | + DWC2_ASYNC_INFLIGHT, | ||
61 | + DWC2_ASYNC_FINISHED, | ||
62 | +}; | ||
63 | + | ||
64 | +struct DWC2Packet { | ||
65 | + USBPacket packet; | ||
66 | + uint32_t devadr; | ||
67 | + uint32_t epnum; | ||
68 | + uint32_t epdir; | ||
69 | + uint32_t mps; | ||
70 | + uint32_t pid; | ||
71 | + uint32_t index; | ||
72 | + uint32_t pcnt; | ||
73 | + uint32_t len; | ||
74 | + int32_t async; | ||
75 | + bool small; | ||
76 | + bool needs_service; | ||
77 | +}; | ||
78 | + | ||
79 | +struct DWC2State { | ||
80 | + /*< private >*/ | ||
81 | + SysBusDevice parent_obj; | ||
82 | + | ||
83 | + /*< public >*/ | ||
84 | + USBBus bus; | ||
85 | + qemu_irq irq; | ||
86 | + MemoryRegion *dma_mr; | ||
87 | + AddressSpace dma_as; | ||
88 | + MemoryRegion container; | ||
89 | + MemoryRegion hsotg; | ||
90 | + MemoryRegion fifos; | ||
91 | + | ||
92 | + union { | ||
93 | +#define DWC2_GLBREG_SIZE 0x70 | ||
94 | + uint32_t glbreg[DWC2_GLBREG_SIZE / sizeof(uint32_t)]; | ||
95 | + struct { | ||
96 | + uint32_t gotgctl; /* 00 */ | ||
97 | + uint32_t gotgint; /* 04 */ | ||
98 | + uint32_t gahbcfg; /* 08 */ | ||
99 | + uint32_t gusbcfg; /* 0c */ | ||
100 | + uint32_t grstctl; /* 10 */ | ||
101 | + uint32_t gintsts; /* 14 */ | ||
102 | + uint32_t gintmsk; /* 18 */ | ||
103 | + uint32_t grxstsr; /* 1c */ | ||
104 | + uint32_t grxstsp; /* 20 */ | ||
105 | + uint32_t grxfsiz; /* 24 */ | ||
106 | + uint32_t gnptxfsiz; /* 28 */ | ||
107 | + uint32_t gnptxsts; /* 2c */ | ||
108 | + uint32_t gi2cctl; /* 30 */ | ||
109 | + uint32_t gpvndctl; /* 34 */ | ||
110 | + uint32_t ggpio; /* 38 */ | ||
111 | + uint32_t guid; /* 3c */ | ||
112 | + uint32_t gsnpsid; /* 40 */ | ||
113 | + uint32_t ghwcfg1; /* 44 */ | ||
114 | + uint32_t ghwcfg2; /* 48 */ | ||
115 | + uint32_t ghwcfg3; /* 4c */ | ||
116 | + uint32_t ghwcfg4; /* 50 */ | ||
117 | + uint32_t glpmcfg; /* 54 */ | ||
118 | + uint32_t gpwrdn; /* 58 */ | ||
119 | + uint32_t gdfifocfg; /* 5c */ | ||
120 | + uint32_t gadpctl; /* 60 */ | ||
121 | + uint32_t grefclk; /* 64 */ | ||
122 | + uint32_t gintmsk2; /* 68 */ | ||
123 | + uint32_t gintsts2; /* 6c */ | ||
124 | + }; | ||
125 | + }; | ||
126 | + | ||
127 | + union { | ||
128 | +#define DWC2_FSZREG_SIZE 0x04 | ||
129 | + uint32_t fszreg[DWC2_FSZREG_SIZE / sizeof(uint32_t)]; | ||
130 | + struct { | ||
131 | + uint32_t hptxfsiz; /* 100 */ | ||
132 | + }; | ||
133 | + }; | ||
134 | + | ||
135 | + union { | ||
136 | +#define DWC2_HREG0_SIZE 0x44 | ||
137 | + uint32_t hreg0[DWC2_HREG0_SIZE / sizeof(uint32_t)]; | ||
138 | + struct { | ||
139 | + uint32_t hcfg; /* 400 */ | ||
140 | + uint32_t hfir; /* 404 */ | ||
141 | + uint32_t hfnum; /* 408 */ | ||
142 | + uint32_t rsvd0; /* 40c */ | ||
143 | + uint32_t hptxsts; /* 410 */ | ||
144 | + uint32_t haint; /* 414 */ | ||
145 | + uint32_t haintmsk; /* 418 */ | ||
146 | + uint32_t hflbaddr; /* 41c */ | ||
147 | + uint32_t rsvd1[8]; /* 420-43c */ | ||
148 | + uint32_t hprt0; /* 440 */ | ||
149 | + }; | ||
150 | + }; | ||
151 | + | ||
152 | +#define DWC2_HREG1_SIZE (0x20 * DWC2_NB_CHAN) | ||
153 | + uint32_t hreg1[DWC2_HREG1_SIZE / sizeof(uint32_t)]; | ||
154 | + | ||
155 | +#define hcchar(_ch) hreg1[((_ch) << 3) + 0] /* 500, 520, ... */ | ||
156 | +#define hcsplt(_ch) hreg1[((_ch) << 3) + 1] /* 504, 524, ... */ | ||
157 | +#define hcint(_ch) hreg1[((_ch) << 3) + 2] /* 508, 528, ... */ | ||
158 | +#define hcintmsk(_ch) hreg1[((_ch) << 3) + 3] /* 50c, 52c, ... */ | ||
159 | +#define hctsiz(_ch) hreg1[((_ch) << 3) + 4] /* 510, 530, ... */ | ||
160 | +#define hcdma(_ch) hreg1[((_ch) << 3) + 5] /* 514, 534, ... */ | ||
161 | +#define hcdmab(_ch) hreg1[((_ch) << 3) + 7] /* 51c, 53c, ... */ | ||
162 | + | ||
163 | + union { | ||
164 | +#define DWC2_PCGREG_SIZE 0x08 | ||
165 | + uint32_t pcgreg[DWC2_PCGREG_SIZE / sizeof(uint32_t)]; | ||
166 | + struct { | ||
167 | + uint32_t pcgctl; /* e00 */ | ||
168 | + uint32_t pcgcctl1; /* e04 */ | ||
169 | + }; | ||
170 | + }; | ||
171 | + | ||
172 | + /* TODO - implement FIFO registers for slave mode */ | ||
173 | +#define DWC2_HFIFO_SIZE (0x1000 * DWC2_NB_CHAN) | ||
174 | + | ||
175 | + /* | ||
176 | + * Internal state | ||
177 | + */ | ||
178 | + QEMUTimer *eof_timer; | ||
179 | + QEMUTimer *frame_timer; | ||
180 | + QEMUBH *async_bh; | ||
181 | + int64_t sof_time; | ||
182 | + int64_t usb_frame_time; | ||
183 | + int64_t usb_bit_time; | ||
184 | + uint32_t usb_version; | ||
185 | + uint16_t frame_number; | ||
186 | + uint16_t fi; | ||
187 | + uint16_t next_chan; | ||
188 | + bool working; | ||
189 | + USBPort uport; | ||
190 | + DWC2Packet packet[DWC2_NB_CHAN]; /* one packet per chan */ | ||
191 | + uint8_t usb_buf[DWC2_NB_CHAN][DWC2_MAX_XFER_SIZE]; /* one buffer per chan */ | ||
192 | +}; | ||
193 | + | ||
194 | +struct DWC2Class { | ||
195 | + /*< private >*/ | ||
196 | + SysBusDeviceClass parent_class; | ||
197 | + ResettablePhases parent_phases; | ||
198 | + | ||
199 | + /*< public >*/ | ||
200 | +}; | ||
201 | + | ||
202 | +#define TYPE_DWC2_USB "dwc2-usb" | ||
203 | +#define DWC2_USB(obj) \ | ||
204 | + OBJECT_CHECK(DWC2State, (obj), TYPE_DWC2_USB) | ||
205 | +#define DWC2_CLASS(klass) \ | ||
206 | + OBJECT_CLASS_CHECK(DWC2Class, (klass), TYPE_DWC2_USB) | ||
207 | +#define DWC2_GET_CLASS(obj) \ | ||
208 | + OBJECT_GET_CLASS(DWC2Class, (obj), TYPE_DWC2_USB) | ||
209 | + | ||
210 | +#endif | ||
211 | -- | 27 | -- |
212 | 2.20.1 | 28 | 2.34.1 |
213 | 29 | ||
214 | 30 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | The encodings 0,0,C7,C9,0 and 0,0,C7,C9,1 are AT SP1E1RP and AT | ||
2 | S1E1WP, but our ARMCPRegInfo definitions for them incorrectly name | ||
3 | them AT S1E1R and AT S1E1W (which are entirely different | ||
4 | instructions). Fix the names. | ||
1 | 5 | ||
6 | (This has no guest-visible effect as the names are for debug purposes | ||
7 | only.) | ||
8 | |||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
11 | Tested-by: Fuad Tabba <tabba@google.com> | ||
12 | Message-id: 20230130182459.3309057-2-peter.maydell@linaro.org | ||
13 | Message-id: 20230127175507.2895013-2-peter.maydell@linaro.org | ||
14 | --- | ||
15 | target/arm/helper.c | 4 ++-- | ||
16 | 1 file changed, 2 insertions(+), 2 deletions(-) | ||
17 | |||
18 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
19 | index XXXXXXX..XXXXXXX 100644 | ||
20 | --- a/target/arm/helper.c | ||
21 | +++ b/target/arm/helper.c | ||
22 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo vhe_reginfo[] = { | ||
23 | |||
24 | #ifndef CONFIG_USER_ONLY | ||
25 | static const ARMCPRegInfo ats1e1_reginfo[] = { | ||
26 | - { .name = "AT_S1E1R", .state = ARM_CP_STATE_AA64, | ||
27 | + { .name = "AT_S1E1RP", .state = ARM_CP_STATE_AA64, | ||
28 | .opc0 = 1, .opc1 = 0, .crn = 7, .crm = 9, .opc2 = 0, | ||
29 | .access = PL1_W, .type = ARM_CP_NO_RAW | ARM_CP_RAISES_EXC, | ||
30 | .writefn = ats_write64 }, | ||
31 | - { .name = "AT_S1E1W", .state = ARM_CP_STATE_AA64, | ||
32 | + { .name = "AT_S1E1WP", .state = ARM_CP_STATE_AA64, | ||
33 | .opc0 = 1, .opc1 = 0, .crn = 7, .crm = 9, .opc2 = 1, | ||
34 | .access = PL1_W, .type = ARM_CP_NO_RAW | ARM_CP_RAISES_EXC, | ||
35 | .writefn = ats_write64 }, | ||
36 | -- | ||
37 | 2.34.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | The AArch32 ATS12NSO* address translation operations are supposed to | ||
2 | trap to either EL2 or EL3 if they're executed at Secure EL1 (which | ||
3 | can only happen if EL3 is AArch64). We implement this, but we got | ||
4 | the syndrome value wrong: like other traps to EL2 or EL3 on an | ||
5 | AArch32 cpreg access, they should report the 0x3 syndrome, not the | ||
6 | 0x0 'uncategorized' syndrome. This is clear in the access pseudocode | ||
7 | for these instructions. | ||
1 | 8 | ||
9 | Fix the syndrome value for these operations by correcting the | ||
10 | returned value from the ats_access() function. | ||
11 | |||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
14 | Tested-by: Fuad Tabba <tabba@google.com> | ||
15 | Message-id: 20230130182459.3309057-3-peter.maydell@linaro.org | ||
16 | Message-id: 20230127175507.2895013-3-peter.maydell@linaro.org | ||
17 | --- | ||
18 | target/arm/helper.c | 4 ++-- | ||
19 | 1 file changed, 2 insertions(+), 2 deletions(-) | ||
20 | |||
21 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
22 | index XXXXXXX..XXXXXXX 100644 | ||
23 | --- a/target/arm/helper.c | ||
24 | +++ b/target/arm/helper.c | ||
25 | @@ -XXX,XX +XXX,XX @@ static CPAccessResult ats_access(CPUARMState *env, const ARMCPRegInfo *ri, | ||
26 | if (arm_current_el(env) == 1) { | ||
27 | if (arm_is_secure_below_el3(env)) { | ||
28 | if (env->cp15.scr_el3 & SCR_EEL2) { | ||
29 | - return CP_ACCESS_TRAP_UNCATEGORIZED_EL2; | ||
30 | + return CP_ACCESS_TRAP_EL2; | ||
31 | } | ||
32 | - return CP_ACCESS_TRAP_UNCATEGORIZED_EL3; | ||
33 | + return CP_ACCESS_TRAP_EL3; | ||
34 | } | ||
35 | return CP_ACCESS_TRAP_UNCATEGORIZED; | ||
36 | } | ||
37 | -- | ||
38 | 2.34.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | We added the CPAccessResult values CP_ACCESS_TRAP_UNCATEGORIZED_EL2 | ||
2 | and CP_ACCESS_TRAP_UNCATEGORIZED_EL3 purely in order to use them in | ||
3 | the ats_access() function, but doing so was incorrect (a bug fixed in | ||
4 | a previous commit). There aren't any cases where we want an access | ||
5 | function to be able to request a trap to EL2 or EL3 with a zero | ||
6 | syndrome value, so remove these enum values. | ||
1 | 7 | ||
8 | As well as cleaning up dead code, the motivation here is that | ||
9 | we'd like to implement fine-grained-trap handling in | ||
10 | helper_access_check_cp_reg(). Although the fine-grained traps | ||
11 | to EL2 are always lower priority than trap-to-same-EL and | ||
12 | higher priority than trap-to-EL3, they are in the middle of | ||
13 | various other kinds of trap-to-EL2. Knowing that a trap-to-EL2 | ||
14 | must always for us have the same syndrome (ie that an access | ||
15 | function will return CP_ACCESS_TRAP_EL2 and there is no other | ||
16 | kind of trap-to-EL2 enum value) means we don't have to try | ||
17 | to choose which of the two syndrome values to report if the | ||
18 | access would trap to EL2 both for the fine-grained-trap and | ||
19 | because the access function requires it. | ||
20 | |||
21 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
22 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
23 | Tested-by: Fuad Tabba <tabba@google.com> | ||
24 | Message-id: 20230130182459.3309057-4-peter.maydell@linaro.org | ||
25 | Message-id: 20230127175507.2895013-4-peter.maydell@linaro.org | ||
26 | --- | ||
27 | target/arm/cpregs.h | 4 ++-- | ||
28 | target/arm/op_helper.c | 2 ++ | ||
29 | 2 files changed, 4 insertions(+), 2 deletions(-) | ||
30 | |||
31 | diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h | ||
32 | index XXXXXXX..XXXXXXX 100644 | ||
33 | --- a/target/arm/cpregs.h | ||
34 | +++ b/target/arm/cpregs.h | ||
35 | @@ -XXX,XX +XXX,XX @@ typedef enum CPAccessResult { | ||
36 | * Access fails and results in an exception syndrome 0x0 ("uncategorized"). | ||
37 | * Note that this is not a catch-all case -- the set of cases which may | ||
38 | * result in this failure is specifically defined by the architecture. | ||
39 | + * This trap is always to the usual target EL, never directly to a | ||
40 | + * specified target EL. | ||
41 | */ | ||
42 | CP_ACCESS_TRAP_UNCATEGORIZED = (2 << 2), | ||
43 | - CP_ACCESS_TRAP_UNCATEGORIZED_EL2 = CP_ACCESS_TRAP_UNCATEGORIZED | 2, | ||
44 | - CP_ACCESS_TRAP_UNCATEGORIZED_EL3 = CP_ACCESS_TRAP_UNCATEGORIZED | 3, | ||
45 | } CPAccessResult; | ||
46 | |||
47 | typedef struct ARMCPRegInfo ARMCPRegInfo; | ||
48 | diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c | ||
49 | index XXXXXXX..XXXXXXX 100644 | ||
50 | --- a/target/arm/op_helper.c | ||
51 | +++ b/target/arm/op_helper.c | ||
52 | @@ -XXX,XX +XXX,XX @@ const void *HELPER(access_check_cp_reg)(CPUARMState *env, uint32_t key, | ||
53 | case CP_ACCESS_TRAP: | ||
54 | break; | ||
55 | case CP_ACCESS_TRAP_UNCATEGORIZED: | ||
56 | + /* Only CP_ACCESS_TRAP traps are direct to a specified EL */ | ||
57 | + assert((res & CP_ACCESS_EL_MASK) == 0); | ||
58 | if (cpu_isar_feature(aa64_ids, cpu) && isread && | ||
59 | arm_cpreg_in_idspace(ri)) { | ||
60 | /* | ||
61 | -- | ||
62 | 2.34.1 | diff view generated by jsdifflib |
1 | Convert the VSHLL and VMOVL insns from the 2-reg-shift group | 1 | Rearrange the code in do_coproc_insn() so that we calculate the |
---|---|---|---|
2 | to decodetree. Since the loop always has two passes, we unroll | 2 | syndrome value for a potential trap early; we're about to add a |
3 | it to avoid the awkward reassignment of one TCGv to another. | 3 | second check that wants this value earlier than where it is currently |
4 | determined. | ||
5 | |||
6 | (Specifically, a trap to EL2 because of HSTR_EL2 should take | ||
7 | priority over an UNDEF to EL1, even when the UNDEF is because | ||
8 | the register does not exist at all or because its ri->access | ||
9 | bits non-configurably fail the access. So the check we put in | ||
10 | for HSTR_EL2 trapping at EL1 (which needs the syndrome) is | ||
11 | going to have to be done before the check "is the ARMCPRegInfo | ||
12 | pointer NULL".) | ||
13 | |||
14 | This commit is just code motion; the change to HSTR_EL2 | ||
15 | handling that will use the 'syndrome' variable is in a | ||
16 | subsequent commit. | ||
4 | 17 | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 18 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 19 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
7 | Message-id: 20200522145520.6778-8-peter.maydell@linaro.org | 20 | Tested-by: Fuad Tabba <tabba@google.com> |
21 | Message-id: 20230130182459.3309057-5-peter.maydell@linaro.org | ||
22 | Message-id: 20230127175507.2895013-5-peter.maydell@linaro.org | ||
8 | --- | 23 | --- |
9 | target/arm/neon-dp.decode | 16 +++++++ | 24 | target/arm/translate.c | 83 +++++++++++++++++++++--------------------- |
10 | target/arm/translate-neon.inc.c | 81 +++++++++++++++++++++++++++++++++ | 25 | 1 file changed, 41 insertions(+), 42 deletions(-) |
11 | target/arm/translate.c | 46 +------------------ | ||
12 | 3 files changed, 99 insertions(+), 44 deletions(-) | ||
13 | 26 | ||
14 | diff --git a/target/arm/neon-dp.decode b/target/arm/neon-dp.decode | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/target/arm/neon-dp.decode | ||
17 | +++ b/target/arm/neon-dp.decode | ||
18 | @@ -XXX,XX +XXX,XX @@ VMINNM_fp_3s 1111 001 1 0 . 1 . .... .... 1111 ... 1 .... @3same_fp | ||
19 | &2reg_shift vm=%vm_dp vd=%vd_dp size=1 q=0 \ | ||
20 | shift=%neon_rshift_i3 | ||
21 | |||
22 | +# Long left shifts: again Q is part of opcode decode | ||
23 | +@2reg_shll_s .... ... . . . 1 shift:5 .... .... 0 . . . .... \ | ||
24 | + &2reg_shift vm=%vm_dp vd=%vd_dp size=2 q=0 | ||
25 | +@2reg_shll_h .... ... . . . 01 shift:4 .... .... 0 . . . .... \ | ||
26 | + &2reg_shift vm=%vm_dp vd=%vd_dp size=1 q=0 | ||
27 | +@2reg_shll_b .... ... . . . 001 shift:3 .... .... 0 . . . .... \ | ||
28 | + &2reg_shift vm=%vm_dp vd=%vd_dp size=0 q=0 | ||
29 | + | ||
30 | VSHR_S_2sh 1111 001 0 1 . ...... .... 0000 . . . 1 .... @2reg_shr_d | ||
31 | VSHR_S_2sh 1111 001 0 1 . ...... .... 0000 . . . 1 .... @2reg_shr_s | ||
32 | VSHR_S_2sh 1111 001 0 1 . ...... .... 0000 . . . 1 .... @2reg_shr_h | ||
33 | @@ -XXX,XX +XXX,XX @@ VQSHRN_U16_2sh 1111 001 1 1 . ...... .... 1001 . 0 . 1 .... @2reg_shrn_h | ||
34 | VQRSHRN_U64_2sh 1111 001 1 1 . ...... .... 1001 . 1 . 1 .... @2reg_shrn_d | ||
35 | VQRSHRN_U32_2sh 1111 001 1 1 . ...... .... 1001 . 1 . 1 .... @2reg_shrn_s | ||
36 | VQRSHRN_U16_2sh 1111 001 1 1 . ...... .... 1001 . 1 . 1 .... @2reg_shrn_h | ||
37 | + | ||
38 | +VSHLL_S_2sh 1111 001 0 1 . ...... .... 1010 . 0 . 1 .... @2reg_shll_s | ||
39 | +VSHLL_S_2sh 1111 001 0 1 . ...... .... 1010 . 0 . 1 .... @2reg_shll_h | ||
40 | +VSHLL_S_2sh 1111 001 0 1 . ...... .... 1010 . 0 . 1 .... @2reg_shll_b | ||
41 | + | ||
42 | +VSHLL_U_2sh 1111 001 1 1 . ...... .... 1010 . 0 . 1 .... @2reg_shll_s | ||
43 | +VSHLL_U_2sh 1111 001 1 1 . ...... .... 1010 . 0 . 1 .... @2reg_shll_h | ||
44 | +VSHLL_U_2sh 1111 001 1 1 . ...... .... 1010 . 0 . 1 .... @2reg_shll_b | ||
45 | diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c | ||
46 | index XXXXXXX..XXXXXXX 100644 | ||
47 | --- a/target/arm/translate-neon.inc.c | ||
48 | +++ b/target/arm/translate-neon.inc.c | ||
49 | @@ -XXX,XX +XXX,XX @@ DO_2SN_32(VQSHRN_U16, gen_helper_neon_shl_u16, gen_helper_neon_narrow_sat_u8) | ||
50 | DO_2SN_64(VQRSHRN_U64, gen_helper_neon_rshl_u64, gen_helper_neon_narrow_sat_u32) | ||
51 | DO_2SN_32(VQRSHRN_U32, gen_helper_neon_rshl_u32, gen_helper_neon_narrow_sat_u16) | ||
52 | DO_2SN_32(VQRSHRN_U16, gen_helper_neon_rshl_u16, gen_helper_neon_narrow_sat_u8) | ||
53 | + | ||
54 | +static bool do_vshll_2sh(DisasContext *s, arg_2reg_shift *a, | ||
55 | + NeonGenWidenFn *widenfn, bool u) | ||
56 | +{ | ||
57 | + TCGv_i64 tmp; | ||
58 | + TCGv_i32 rm0, rm1; | ||
59 | + uint64_t widen_mask = 0; | ||
60 | + | ||
61 | + if (!arm_dc_feature(s, ARM_FEATURE_NEON)) { | ||
62 | + return false; | ||
63 | + } | ||
64 | + | ||
65 | + /* UNDEF accesses to D16-D31 if they don't exist. */ | ||
66 | + if (!dc_isar_feature(aa32_simd_r32, s) && | ||
67 | + ((a->vd | a->vm) & 0x10)) { | ||
68 | + return false; | ||
69 | + } | ||
70 | + | ||
71 | + if (a->vd & 1) { | ||
72 | + return false; | ||
73 | + } | ||
74 | + | ||
75 | + if (!vfp_access_check(s)) { | ||
76 | + return true; | ||
77 | + } | ||
78 | + | ||
79 | + /* | ||
80 | + * This is a widen-and-shift operation. The shift is always less | ||
81 | + * than the width of the source type, so after widening the input | ||
82 | + * vector we can simply shift the whole 64-bit widened register, | ||
83 | + * and then clear the potential overflow bits resulting from left | ||
84 | + * bits of the narrow input appearing as right bits of the left | ||
85 | + * neighbour narrow input. Calculate a mask of bits to clear. | ||
86 | + */ | ||
87 | + if ((a->shift != 0) && (a->size < 2 || u)) { | ||
88 | + int esize = 8 << a->size; | ||
89 | + widen_mask = MAKE_64BIT_MASK(0, esize); | ||
90 | + widen_mask >>= esize - a->shift; | ||
91 | + widen_mask = dup_const(a->size + 1, widen_mask); | ||
92 | + } | ||
93 | + | ||
94 | + rm0 = neon_load_reg(a->vm, 0); | ||
95 | + rm1 = neon_load_reg(a->vm, 1); | ||
96 | + tmp = tcg_temp_new_i64(); | ||
97 | + | ||
98 | + widenfn(tmp, rm0); | ||
99 | + if (a->shift != 0) { | ||
100 | + tcg_gen_shli_i64(tmp, tmp, a->shift); | ||
101 | + tcg_gen_andi_i64(tmp, tmp, ~widen_mask); | ||
102 | + } | ||
103 | + neon_store_reg64(tmp, a->vd); | ||
104 | + | ||
105 | + widenfn(tmp, rm1); | ||
106 | + if (a->shift != 0) { | ||
107 | + tcg_gen_shli_i64(tmp, tmp, a->shift); | ||
108 | + tcg_gen_andi_i64(tmp, tmp, ~widen_mask); | ||
109 | + } | ||
110 | + neon_store_reg64(tmp, a->vd + 1); | ||
111 | + tcg_temp_free_i64(tmp); | ||
112 | + return true; | ||
113 | +} | ||
114 | + | ||
115 | +static bool trans_VSHLL_S_2sh(DisasContext *s, arg_2reg_shift *a) | ||
116 | +{ | ||
117 | + NeonGenWidenFn *widenfn[] = { | ||
118 | + gen_helper_neon_widen_s8, | ||
119 | + gen_helper_neon_widen_s16, | ||
120 | + tcg_gen_ext_i32_i64, | ||
121 | + }; | ||
122 | + return do_vshll_2sh(s, a, widenfn[a->size], false); | ||
123 | +} | ||
124 | + | ||
125 | +static bool trans_VSHLL_U_2sh(DisasContext *s, arg_2reg_shift *a) | ||
126 | +{ | ||
127 | + NeonGenWidenFn *widenfn[] = { | ||
128 | + gen_helper_neon_widen_u8, | ||
129 | + gen_helper_neon_widen_u16, | ||
130 | + tcg_gen_extu_i32_i64, | ||
131 | + }; | ||
132 | + return do_vshll_2sh(s, a, widenfn[a->size], true); | ||
133 | +} | ||
134 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 27 | diff --git a/target/arm/translate.c b/target/arm/translate.c |
135 | index XXXXXXX..XXXXXXX 100644 | 28 | index XXXXXXX..XXXXXXX 100644 |
136 | --- a/target/arm/translate.c | 29 | --- a/target/arm/translate.c |
137 | +++ b/target/arm/translate.c | 30 | +++ b/target/arm/translate.c |
138 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | 31 | @@ -XXX,XX +XXX,XX @@ static void do_coproc_insn(DisasContext *s, int cpnum, int is64, |
139 | case 7: /* VQSHL */ | 32 | const ARMCPRegInfo *ri = get_arm_cp_reginfo(s->cp_regs, key); |
140 | case 8: /* VSHRN, VRSHRN, VQSHRUN, VQRSHRUN */ | 33 | TCGv_ptr tcg_ri = NULL; |
141 | case 9: /* VQSHRN, VQRSHRN */ | 34 | bool need_exit_tb; |
142 | + case 10: /* VSHLL, including VMOVL */ | 35 | + uint32_t syndrome; |
143 | return 1; /* handled by decodetree */ | 36 | + |
144 | default: | 37 | + /* |
145 | break; | 38 | + * Note that since we are an implementation which takes an |
146 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | 39 | + * exception on a trapped conditional instruction only if the |
147 | size--; | 40 | + * instruction passes its condition code check, we can take |
148 | } | 41 | + * advantage of the clause in the ARM ARM that allows us to set |
149 | shift = (insn >> 16) & ((1 << (3 + size)) - 1); | 42 | + * the COND field in the instruction to 0xE in all cases. |
150 | - if (op == 10) { | 43 | + * We could fish the actual condition out of the insn (ARM) |
151 | - /* VSHLL, VMOVL */ | 44 | + * or the condexec bits (Thumb) but it isn't necessary. |
152 | - if (q || (rd & 1)) { | 45 | + */ |
153 | - return 1; | 46 | + switch (cpnum) { |
154 | - } | 47 | + case 14: |
155 | - tmp = neon_load_reg(rm, 0); | 48 | + if (is64) { |
156 | - tmp2 = neon_load_reg(rm, 1); | 49 | + syndrome = syn_cp14_rrt_trap(1, 0xe, opc1, crm, rt, rt2, |
157 | - for (pass = 0; pass < 2; pass++) { | 50 | + isread, false); |
158 | - if (pass == 1) | 51 | + } else { |
159 | - tmp = tmp2; | 52 | + syndrome = syn_cp14_rt_trap(1, 0xe, opc1, opc2, crn, crm, |
53 | + rt, isread, false); | ||
54 | + } | ||
55 | + break; | ||
56 | + case 15: | ||
57 | + if (is64) { | ||
58 | + syndrome = syn_cp15_rrt_trap(1, 0xe, opc1, crm, rt, rt2, | ||
59 | + isread, false); | ||
60 | + } else { | ||
61 | + syndrome = syn_cp15_rt_trap(1, 0xe, opc1, opc2, crn, crm, | ||
62 | + rt, isread, false); | ||
63 | + } | ||
64 | + break; | ||
65 | + default: | ||
66 | + /* | ||
67 | + * ARMv8 defines that only coprocessors 14 and 15 exist, | ||
68 | + * so this can only happen if this is an ARMv7 or earlier CPU, | ||
69 | + * in which case the syndrome information won't actually be | ||
70 | + * guest visible. | ||
71 | + */ | ||
72 | + assert(!arm_dc_feature(s, ARM_FEATURE_V8)); | ||
73 | + syndrome = syn_uncategorized(); | ||
74 | + break; | ||
75 | + } | ||
76 | |||
77 | if (!ri) { | ||
78 | /* | ||
79 | @@ -XXX,XX +XXX,XX @@ static void do_coproc_insn(DisasContext *s, int cpnum, int is64, | ||
80 | * Note that on XScale all cp0..c13 registers do an access check | ||
81 | * call in order to handle c15_cpar. | ||
82 | */ | ||
83 | - uint32_t syndrome; | ||
160 | - | 84 | - |
161 | - gen_neon_widen(cpu_V0, tmp, size, u); | 85 | - /* |
86 | - * Note that since we are an implementation which takes an | ||
87 | - * exception on a trapped conditional instruction only if the | ||
88 | - * instruction passes its condition code check, we can take | ||
89 | - * advantage of the clause in the ARM ARM that allows us to set | ||
90 | - * the COND field in the instruction to 0xE in all cases. | ||
91 | - * We could fish the actual condition out of the insn (ARM) | ||
92 | - * or the condexec bits (Thumb) but it isn't necessary. | ||
93 | - */ | ||
94 | - switch (cpnum) { | ||
95 | - case 14: | ||
96 | - if (is64) { | ||
97 | - syndrome = syn_cp14_rrt_trap(1, 0xe, opc1, crm, rt, rt2, | ||
98 | - isread, false); | ||
99 | - } else { | ||
100 | - syndrome = syn_cp14_rt_trap(1, 0xe, opc1, opc2, crn, crm, | ||
101 | - rt, isread, false); | ||
102 | - } | ||
103 | - break; | ||
104 | - case 15: | ||
105 | - if (is64) { | ||
106 | - syndrome = syn_cp15_rrt_trap(1, 0xe, opc1, crm, rt, rt2, | ||
107 | - isread, false); | ||
108 | - } else { | ||
109 | - syndrome = syn_cp15_rt_trap(1, 0xe, opc1, opc2, crn, crm, | ||
110 | - rt, isread, false); | ||
111 | - } | ||
112 | - break; | ||
113 | - default: | ||
114 | - /* | ||
115 | - * ARMv8 defines that only coprocessors 14 and 15 exist, | ||
116 | - * so this can only happen if this is an ARMv7 or earlier CPU, | ||
117 | - * in which case the syndrome information won't actually be | ||
118 | - * guest visible. | ||
119 | - */ | ||
120 | - assert(!arm_dc_feature(s, ARM_FEATURE_V8)); | ||
121 | - syndrome = syn_uncategorized(); | ||
122 | - break; | ||
123 | - } | ||
162 | - | 124 | - |
163 | - if (shift != 0) { | 125 | gen_set_condexec(s); |
164 | - /* The shift is less than the width of the source | 126 | gen_update_pc(s, 0); |
165 | - type, so we can just shift the whole register. */ | 127 | tcg_ri = tcg_temp_new_ptr(); |
166 | - tcg_gen_shli_i64(cpu_V0, cpu_V0, shift); | ||
167 | - /* Widen the result of shift: we need to clear | ||
168 | - * the potential overflow bits resulting from | ||
169 | - * left bits of the narrow input appearing as | ||
170 | - * right bits of left the neighbour narrow | ||
171 | - * input. */ | ||
172 | - if (size < 2 || !u) { | ||
173 | - uint64_t imm64; | ||
174 | - if (size == 0) { | ||
175 | - imm = (0xffu >> (8 - shift)); | ||
176 | - imm |= imm << 16; | ||
177 | - } else if (size == 1) { | ||
178 | - imm = 0xffff >> (16 - shift); | ||
179 | - } else { | ||
180 | - /* size == 2 */ | ||
181 | - imm = 0xffffffff >> (32 - shift); | ||
182 | - } | ||
183 | - if (size < 2) { | ||
184 | - imm64 = imm | (((uint64_t)imm) << 32); | ||
185 | - } else { | ||
186 | - imm64 = imm; | ||
187 | - } | ||
188 | - tcg_gen_andi_i64(cpu_V0, cpu_V0, ~imm64); | ||
189 | - } | ||
190 | - } | ||
191 | - neon_store_reg64(cpu_V0, rd + pass); | ||
192 | - } | ||
193 | - } else if (op >= 14) { | ||
194 | + if (op >= 14) { | ||
195 | /* VCVT fixed-point. */ | ||
196 | TCGv_ptr fpst; | ||
197 | TCGv_i32 shiftv; | ||
198 | -- | 128 | -- |
199 | 2.20.1 | 129 | 2.34.1 |
200 | |||
201 | diff view generated by jsdifflib |
1 | Convert the insns in the one-register-and-immediate group to decodetree. | 1 | The HSTR_EL2 register has a collection of trap bits which allow |
---|---|---|---|
2 | trapping to EL2 for AArch32 EL0 or EL1 accesses to coprocessor | ||
3 | registers. The specification of these bits is that when the bit is | ||
4 | set we should trap | ||
5 | * EL1 accesses | ||
6 | * EL0 accesses, if the access is not UNDEFINED when the | ||
7 | trap bit is 0 | ||
2 | 8 | ||
3 | In the new decode, our asimd_imm_const() function returns a 64-bit value | 9 | In other words, all UNDEF traps from EL0 to EL1 take precedence over |
4 | rather than a 32-bit one, which means we don't need to treat cmode=14 op=1 | 10 | the HSTR_EL2 trap to EL2. (Since this is all AArch32, the only kind |
5 | as a special case in the decoder (it is the only encoding where the two | 11 | of trap-to-EL1 is the UNDEF.) |
6 | halves of the 64-bit value are different). | 12 | |
13 | Our implementation doesn't quite get this right -- we check for traps | ||
14 | in the order: | ||
15 | * no such register | ||
16 | * ARMCPRegInfo::access bits | ||
17 | * HSTR_EL2 trap bits | ||
18 | * ARMCPRegInfo::accessfn | ||
19 | |||
20 | So UNDEFs that happen because of the access bits or because the | ||
21 | register doesn't exist at all correctly take priority over the | ||
22 | HSTR_EL2 trap, but where a register can UNDEF at EL0 because of the | ||
23 | accessfn we are incorrectly always taking the HSTR_EL2 trap. There | ||
24 | aren't many of these, but one example is the PMCR; if you look at the | ||
25 | access pseudocode for this register you can see that UNDEFs taken | ||
26 | because of the value of PMUSERENR.EN are checked before the HSTR_EL2 | ||
27 | bit. | ||
28 | |||
29 | Rearrange helper_access_check_cp_reg() so that we always call the | ||
30 | accessfn, and use its return value if it indicates that the access | ||
31 | traps to EL0 rather than continuing to do the HSTR_EL2 check. | ||
7 | 32 | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 33 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 34 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
10 | Message-id: 20200522145520.6778-10-peter.maydell@linaro.org | 35 | Tested-by: Fuad Tabba <tabba@google.com> |
36 | Message-id: 20230130182459.3309057-6-peter.maydell@linaro.org | ||
37 | Message-id: 20230127175507.2895013-6-peter.maydell@linaro.org | ||
11 | --- | 38 | --- |
12 | target/arm/neon-dp.decode | 22 ++++++ | 39 | target/arm/op_helper.c | 21 ++++++++++++++++----- |
13 | target/arm/translate-neon.inc.c | 118 ++++++++++++++++++++++++++++++++ | 40 | 1 file changed, 16 insertions(+), 5 deletions(-) |
14 | target/arm/translate.c | 101 +-------------------------- | ||
15 | 3 files changed, 142 insertions(+), 99 deletions(-) | ||
16 | 41 | ||
17 | diff --git a/target/arm/neon-dp.decode b/target/arm/neon-dp.decode | 42 | diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c |
18 | index XXXXXXX..XXXXXXX 100644 | 43 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/target/arm/neon-dp.decode | 44 | --- a/target/arm/op_helper.c |
20 | +++ b/target/arm/neon-dp.decode | 45 | +++ b/target/arm/op_helper.c |
21 | @@ -XXX,XX +XXX,XX @@ VCVT_SF_2sh 1111 001 0 1 . ...... .... 1110 0 . . 1 .... @2reg_vcvt | 46 | @@ -XXX,XX +XXX,XX @@ const void *HELPER(access_check_cp_reg)(CPUARMState *env, uint32_t key, |
22 | VCVT_UF_2sh 1111 001 1 1 . ...... .... 1110 0 . . 1 .... @2reg_vcvt | 47 | goto fail; |
23 | VCVT_FS_2sh 1111 001 0 1 . ...... .... 1111 0 . . 1 .... @2reg_vcvt | 48 | } |
24 | VCVT_FU_2sh 1111 001 1 1 . ...... .... 1111 0 . . 1 .... @2reg_vcvt | 49 | |
25 | + | 50 | + if (ri->accessfn) { |
26 | +###################################################################### | 51 | + res = ri->accessfn(env, ri, isread); |
27 | +# 1-reg-and-modified-immediate grouping: | ||
28 | +# 1111 001 i 1 D 000 imm:3 Vd:4 cmode:4 0 Q op 1 Vm:4 | ||
29 | +###################################################################### | ||
30 | + | ||
31 | +&1reg_imm vd q imm cmode op | ||
32 | + | ||
33 | +%asimd_imm_value 24:1 16:3 0:4 | ||
34 | + | ||
35 | +@1reg_imm .... ... . . . ... ... .... .... . q:1 . . .... \ | ||
36 | + &1reg_imm imm=%asimd_imm_value vd=%vd_dp | ||
37 | + | ||
38 | +# The cmode/op bits here decode VORR/VBIC/VMOV/VMNV, but | ||
39 | +# not in a way we can conveniently represent in decodetree without | ||
40 | +# a lot of repetition: | ||
41 | +# VORR: op=0, (cmode & 1) && cmode < 12 | ||
42 | +# VBIC: op=1, (cmode & 1) && cmode < 12 | ||
43 | +# VMOV: everything else | ||
44 | +# So we have a single decode line and check the cmode/op in the | ||
45 | +# trans function. | ||
46 | +Vimm_1r 1111 001 . 1 . 000 ... .... cmode:4 0 . op:1 1 .... @1reg_imm | ||
47 | diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c | ||
48 | index XXXXXXX..XXXXXXX 100644 | ||
49 | --- a/target/arm/translate-neon.inc.c | ||
50 | +++ b/target/arm/translate-neon.inc.c | ||
51 | @@ -XXX,XX +XXX,XX @@ DO_FP_2SH(VCVT_SF, gen_helper_vfp_sltos) | ||
52 | DO_FP_2SH(VCVT_UF, gen_helper_vfp_ultos) | ||
53 | DO_FP_2SH(VCVT_FS, gen_helper_vfp_tosls_round_to_zero) | ||
54 | DO_FP_2SH(VCVT_FU, gen_helper_vfp_touls_round_to_zero) | ||
55 | + | ||
56 | +static uint64_t asimd_imm_const(uint32_t imm, int cmode, int op) | ||
57 | +{ | ||
58 | + /* | ||
59 | + * Expand the encoded constant. | ||
60 | + * Note that cmode = 2,3,4,5,6,7,10,11,12,13 imm=0 is UNPREDICTABLE. | ||
61 | + * We choose to not special-case this and will behave as if a | ||
62 | + * valid constant encoding of 0 had been given. | ||
63 | + * cmode = 15 op = 1 must UNDEF; we assume decode has handled that. | ||
64 | + */ | ||
65 | + switch (cmode) { | ||
66 | + case 0: case 1: | ||
67 | + /* no-op */ | ||
68 | + break; | ||
69 | + case 2: case 3: | ||
70 | + imm <<= 8; | ||
71 | + break; | ||
72 | + case 4: case 5: | ||
73 | + imm <<= 16; | ||
74 | + break; | ||
75 | + case 6: case 7: | ||
76 | + imm <<= 24; | ||
77 | + break; | ||
78 | + case 8: case 9: | ||
79 | + imm |= imm << 16; | ||
80 | + break; | ||
81 | + case 10: case 11: | ||
82 | + imm = (imm << 8) | (imm << 24); | ||
83 | + break; | ||
84 | + case 12: | ||
85 | + imm = (imm << 8) | 0xff; | ||
86 | + break; | ||
87 | + case 13: | ||
88 | + imm = (imm << 16) | 0xffff; | ||
89 | + break; | ||
90 | + case 14: | ||
91 | + if (op) { | ||
92 | + /* | ||
93 | + * This is the only case where the top and bottom 32 bits | ||
94 | + * of the encoded constant differ. | ||
95 | + */ | ||
96 | + uint64_t imm64 = 0; | ||
97 | + int n; | ||
98 | + | ||
99 | + for (n = 0; n < 8; n++) { | ||
100 | + if (imm & (1 << n)) { | ||
101 | + imm64 |= (0xffULL << (n * 8)); | ||
102 | + } | ||
103 | + } | ||
104 | + return imm64; | ||
105 | + } | ||
106 | + imm |= (imm << 8) | (imm << 16) | (imm << 24); | ||
107 | + break; | ||
108 | + case 15: | ||
109 | + imm = ((imm & 0x80) << 24) | ((imm & 0x3f) << 19) | ||
110 | + | ((imm & 0x40) ? (0x1f << 25) : (1 << 30)); | ||
111 | + break; | ||
112 | + } | ||
113 | + if (op) { | ||
114 | + imm = ~imm; | ||
115 | + } | ||
116 | + return dup_const(MO_32, imm); | ||
117 | +} | ||
118 | + | ||
119 | +static bool do_1reg_imm(DisasContext *s, arg_1reg_imm *a, | ||
120 | + GVecGen2iFn *fn) | ||
121 | +{ | ||
122 | + uint64_t imm; | ||
123 | + int reg_ofs, vec_size; | ||
124 | + | ||
125 | + if (!arm_dc_feature(s, ARM_FEATURE_NEON)) { | ||
126 | + return false; | ||
127 | + } | 52 | + } |
128 | + | 53 | + |
129 | + /* UNDEF accesses to D16-D31 if they don't exist. */ | 54 | /* |
130 | + if (!dc_isar_feature(aa32_simd_r32, s) && (a->vd & 0x10)) { | 55 | - * Check for an EL2 trap due to HSTR_EL2. We expect EL0 accesses |
131 | + return false; | 56 | - * to sysregs non accessible at EL0 to have UNDEF-ed already. |
57 | + * If the access function indicates a trap from EL0 to EL1 then | ||
58 | + * that always takes priority over the HSTR_EL2 trap. (If it indicates | ||
59 | + * a trap to EL3, then the HSTR_EL2 trap takes priority; if it indicates | ||
60 | + * a trap to EL2, then the syndrome is the same either way so we don't | ||
61 | + * care whether technically the architecture says that HSTR_EL2 trap or | ||
62 | + * the other trap takes priority. So we take the "check HSTR_EL2" path | ||
63 | + * for all of those cases.) | ||
64 | */ | ||
65 | + if (res != CP_ACCESS_OK && ((res & CP_ACCESS_EL_MASK) == 0) && | ||
66 | + arm_current_el(env) == 0) { | ||
67 | + goto fail; | ||
132 | + } | 68 | + } |
133 | + | 69 | + |
134 | + if (a->vd & a->q) { | 70 | if (!is_a64(env) && arm_current_el(env) < 2 && ri->cp == 15 && |
135 | + return false; | 71 | (arm_hcr_el2_eff(env) & (HCR_E2H | HCR_TGE)) != (HCR_E2H | HCR_TGE)) { |
136 | + } | 72 | uint32_t mask = 1 << ri->crn; |
137 | + | 73 | @@ -XXX,XX +XXX,XX @@ const void *HELPER(access_check_cp_reg)(CPUARMState *env, uint32_t key, |
138 | + if (!vfp_access_check(s)) { | 74 | } |
139 | + return true; | 75 | } |
140 | + } | 76 | |
141 | + | 77 | - if (ri->accessfn) { |
142 | + reg_ofs = neon_reg_offset(a->vd, 0); | 78 | - res = ri->accessfn(env, ri, isread); |
143 | + vec_size = a->q ? 16 : 8; | 79 | - } |
144 | + imm = asimd_imm_const(a->imm, a->cmode, a->op); | 80 | if (likely(res == CP_ACCESS_OK)) { |
145 | + | 81 | return ri; |
146 | + fn(MO_64, reg_ofs, reg_ofs, imm, vec_size, vec_size); | 82 | } |
147 | + return true; | ||
148 | +} | ||
149 | + | ||
150 | +static void gen_VMOV_1r(unsigned vece, uint32_t dofs, uint32_t aofs, | ||
151 | + int64_t c, uint32_t oprsz, uint32_t maxsz) | ||
152 | +{ | ||
153 | + tcg_gen_gvec_dup_imm(MO_64, dofs, oprsz, maxsz, c); | ||
154 | +} | ||
155 | + | ||
156 | +static bool trans_Vimm_1r(DisasContext *s, arg_1reg_imm *a) | ||
157 | +{ | ||
158 | + /* Handle decode of cmode/op here between VORR/VBIC/VMOV */ | ||
159 | + GVecGen2iFn *fn; | ||
160 | + | ||
161 | + if ((a->cmode & 1) && a->cmode < 12) { | ||
162 | + /* for op=1, the imm will be inverted, so BIC becomes AND. */ | ||
163 | + fn = a->op ? tcg_gen_gvec_andi : tcg_gen_gvec_ori; | ||
164 | + } else { | ||
165 | + /* There is one unallocated cmode/op combination in this space */ | ||
166 | + if (a->cmode == 15 && a->op == 1) { | ||
167 | + return false; | ||
168 | + } | ||
169 | + fn = gen_VMOV_1r; | ||
170 | + } | ||
171 | + return do_1reg_imm(s, a, fn); | ||
172 | +} | ||
173 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
174 | index XXXXXXX..XXXXXXX 100644 | ||
175 | --- a/target/arm/translate.c | ||
176 | +++ b/target/arm/translate.c | ||
177 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
178 | /* Three register same length: handled by decodetree */ | ||
179 | return 1; | ||
180 | } else if (insn & (1 << 4)) { | ||
181 | - if ((insn & 0x00380080) != 0) { | ||
182 | - /* Two registers and shift: handled by decodetree */ | ||
183 | - return 1; | ||
184 | - } else { /* (insn & 0x00380080) == 0 */ | ||
185 | - int invert, reg_ofs, vec_size; | ||
186 | - | ||
187 | - if (q && (rd & 1)) { | ||
188 | - return 1; | ||
189 | - } | ||
190 | - | ||
191 | - op = (insn >> 8) & 0xf; | ||
192 | - /* One register and immediate. */ | ||
193 | - imm = (u << 7) | ((insn >> 12) & 0x70) | (insn & 0xf); | ||
194 | - invert = (insn & (1 << 5)) != 0; | ||
195 | - /* Note that op = 2,3,4,5,6,7,10,11,12,13 imm=0 is UNPREDICTABLE. | ||
196 | - * We choose to not special-case this and will behave as if a | ||
197 | - * valid constant encoding of 0 had been given. | ||
198 | - */ | ||
199 | - switch (op) { | ||
200 | - case 0: case 1: | ||
201 | - /* no-op */ | ||
202 | - break; | ||
203 | - case 2: case 3: | ||
204 | - imm <<= 8; | ||
205 | - break; | ||
206 | - case 4: case 5: | ||
207 | - imm <<= 16; | ||
208 | - break; | ||
209 | - case 6: case 7: | ||
210 | - imm <<= 24; | ||
211 | - break; | ||
212 | - case 8: case 9: | ||
213 | - imm |= imm << 16; | ||
214 | - break; | ||
215 | - case 10: case 11: | ||
216 | - imm = (imm << 8) | (imm << 24); | ||
217 | - break; | ||
218 | - case 12: | ||
219 | - imm = (imm << 8) | 0xff; | ||
220 | - break; | ||
221 | - case 13: | ||
222 | - imm = (imm << 16) | 0xffff; | ||
223 | - break; | ||
224 | - case 14: | ||
225 | - imm |= (imm << 8) | (imm << 16) | (imm << 24); | ||
226 | - if (invert) { | ||
227 | - imm = ~imm; | ||
228 | - } | ||
229 | - break; | ||
230 | - case 15: | ||
231 | - if (invert) { | ||
232 | - return 1; | ||
233 | - } | ||
234 | - imm = ((imm & 0x80) << 24) | ((imm & 0x3f) << 19) | ||
235 | - | ((imm & 0x40) ? (0x1f << 25) : (1 << 30)); | ||
236 | - break; | ||
237 | - } | ||
238 | - if (invert) { | ||
239 | - imm = ~imm; | ||
240 | - } | ||
241 | - | ||
242 | - reg_ofs = neon_reg_offset(rd, 0); | ||
243 | - vec_size = q ? 16 : 8; | ||
244 | - | ||
245 | - if (op & 1 && op < 12) { | ||
246 | - if (invert) { | ||
247 | - /* The immediate value has already been inverted, | ||
248 | - * so BIC becomes AND. | ||
249 | - */ | ||
250 | - tcg_gen_gvec_andi(MO_32, reg_ofs, reg_ofs, imm, | ||
251 | - vec_size, vec_size); | ||
252 | - } else { | ||
253 | - tcg_gen_gvec_ori(MO_32, reg_ofs, reg_ofs, imm, | ||
254 | - vec_size, vec_size); | ||
255 | - } | ||
256 | - } else { | ||
257 | - /* VMOV, VMVN. */ | ||
258 | - if (op == 14 && invert) { | ||
259 | - TCGv_i64 t64 = tcg_temp_new_i64(); | ||
260 | - | ||
261 | - for (pass = 0; pass <= q; ++pass) { | ||
262 | - uint64_t val = 0; | ||
263 | - int n; | ||
264 | - | ||
265 | - for (n = 0; n < 8; n++) { | ||
266 | - if (imm & (1 << (n + pass * 8))) { | ||
267 | - val |= 0xffull << (n * 8); | ||
268 | - } | ||
269 | - } | ||
270 | - tcg_gen_movi_i64(t64, val); | ||
271 | - neon_store_reg64(t64, rd + pass); | ||
272 | - } | ||
273 | - tcg_temp_free_i64(t64); | ||
274 | - } else { | ||
275 | - tcg_gen_gvec_dup_imm(MO_32, reg_ofs, vec_size, | ||
276 | - vec_size, imm); | ||
277 | - } | ||
278 | - } | ||
279 | - } | ||
280 | + /* Two registers and shift or reg and imm: handled by decodetree */ | ||
281 | + return 1; | ||
282 | } else { /* (insn & 0x00800010 == 0x00800000) */ | ||
283 | if (size != 3) { | ||
284 | op = (insn >> 8) & 0xf; | ||
285 | -- | 83 | -- |
286 | 2.20.1 | 84 | 2.34.1 |
287 | |||
288 | diff view generated by jsdifflib |
1 | Convert the VSRA, VSRI, VRSHR, VRSRA 2-reg-shift insns to decodetree. | 1 | The semantics of HSTR_EL2 require that it traps cpreg accesses |
---|---|---|---|
2 | (These are the last instructions in the group that are vectorized; | 2 | to EL2 for: |
3 | the rest all require looping over each element.) | 3 | * EL1 accesses |
4 | * EL0 accesses, if the access is not UNDEFINED when the | ||
5 | trap bit is 0 | ||
6 | |||
7 | (You can see this in the I_ZFGJP priority ordering, where HSTR_EL2 | ||
8 | traps from EL1 to EL2 are priority 12, UNDEFs are priority 13, and | ||
9 | HSTR_EL2 traps from EL0 are priority 15.) | ||
10 | |||
11 | However, we don't get this right for EL1 accesses which UNDEF because | ||
12 | the register doesn't exist at all or because its ri->access bits | ||
13 | non-configurably forbid the access. At EL1, check for the HSTR_EL2 | ||
14 | trap early, before either of these UNDEF reasons. | ||
15 | |||
16 | We have to retain the HSTR_EL2 check in access_check_cp_reg(), | ||
17 | because at EL0 any kind of UNDEF-to-EL1 (including "no such | ||
18 | register", "bad ri->access" and "ri->accessfn returns 'trap to EL1'") | ||
19 | takes precedence over the trap to EL2. But we only need to do that | ||
20 | check for EL0 now. | ||
4 | 21 | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 22 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
23 | Tested-by: Fuad Tabba <tabba@google.com> | ||
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 24 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
7 | Message-id: 20200522145520.6778-4-peter.maydell@linaro.org | 25 | Message-id: 20230130182459.3309057-7-peter.maydell@linaro.org |
26 | Message-id: 20230127175507.2895013-7-peter.maydell@linaro.org | ||
8 | --- | 27 | --- |
9 | target/arm/neon-dp.decode | 35 ++++++++++++++++++++++ | 28 | target/arm/op_helper.c | 6 +++++- |
10 | target/arm/translate-neon.inc.c | 7 +++++ | 29 | target/arm/translate.c | 28 +++++++++++++++++++++++++++- |
11 | target/arm/translate.c | 52 +++------------------------------ | 30 | 2 files changed, 32 insertions(+), 2 deletions(-) |
12 | 3 files changed, 46 insertions(+), 48 deletions(-) | ||
13 | 31 | ||
14 | diff --git a/target/arm/neon-dp.decode b/target/arm/neon-dp.decode | 32 | diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c |
15 | index XXXXXXX..XXXXXXX 100644 | 33 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/neon-dp.decode | 34 | --- a/target/arm/op_helper.c |
17 | +++ b/target/arm/neon-dp.decode | 35 | +++ b/target/arm/op_helper.c |
18 | @@ -XXX,XX +XXX,XX @@ VSHR_U_2sh 1111 001 1 1 . ...... .... 0000 . . . 1 .... @2reg_shr_s | 36 | @@ -XXX,XX +XXX,XX @@ const void *HELPER(access_check_cp_reg)(CPUARMState *env, uint32_t key, |
19 | VSHR_U_2sh 1111 001 1 1 . ...... .... 0000 . . . 1 .... @2reg_shr_h | 37 | goto fail; |
20 | VSHR_U_2sh 1111 001 1 1 . ...... .... 0000 . . . 1 .... @2reg_shr_b | 38 | } |
21 | 39 | ||
22 | +VSRA_S_2sh 1111 001 0 1 . ...... .... 0001 . . . 1 .... @2reg_shr_d | 40 | - if (!is_a64(env) && arm_current_el(env) < 2 && ri->cp == 15 && |
23 | +VSRA_S_2sh 1111 001 0 1 . ...... .... 0001 . . . 1 .... @2reg_shr_s | 41 | + /* |
24 | +VSRA_S_2sh 1111 001 0 1 . ...... .... 0001 . . . 1 .... @2reg_shr_h | 42 | + * HSTR_EL2 traps from EL1 are checked earlier, in generated code; |
25 | +VSRA_S_2sh 1111 001 0 1 . ...... .... 0001 . . . 1 .... @2reg_shr_b | 43 | + * we only need to check here for traps from EL0. |
26 | + | 44 | + */ |
27 | +VSRA_U_2sh 1111 001 1 1 . ...... .... 0001 . . . 1 .... @2reg_shr_d | 45 | + if (!is_a64(env) && arm_current_el(env) == 0 && ri->cp == 15 && |
28 | +VSRA_U_2sh 1111 001 1 1 . ...... .... 0001 . . . 1 .... @2reg_shr_s | 46 | (arm_hcr_el2_eff(env) & (HCR_E2H | HCR_TGE)) != (HCR_E2H | HCR_TGE)) { |
29 | +VSRA_U_2sh 1111 001 1 1 . ...... .... 0001 . . . 1 .... @2reg_shr_h | 47 | uint32_t mask = 1 << ri->crn; |
30 | +VSRA_U_2sh 1111 001 1 1 . ...... .... 0001 . . . 1 .... @2reg_shr_b | 48 | |
31 | + | ||
32 | +VRSHR_S_2sh 1111 001 0 1 . ...... .... 0010 . . . 1 .... @2reg_shr_d | ||
33 | +VRSHR_S_2sh 1111 001 0 1 . ...... .... 0010 . . . 1 .... @2reg_shr_s | ||
34 | +VRSHR_S_2sh 1111 001 0 1 . ...... .... 0010 . . . 1 .... @2reg_shr_h | ||
35 | +VRSHR_S_2sh 1111 001 0 1 . ...... .... 0010 . . . 1 .... @2reg_shr_b | ||
36 | + | ||
37 | +VRSHR_U_2sh 1111 001 1 1 . ...... .... 0010 . . . 1 .... @2reg_shr_d | ||
38 | +VRSHR_U_2sh 1111 001 1 1 . ...... .... 0010 . . . 1 .... @2reg_shr_s | ||
39 | +VRSHR_U_2sh 1111 001 1 1 . ...... .... 0010 . . . 1 .... @2reg_shr_h | ||
40 | +VRSHR_U_2sh 1111 001 1 1 . ...... .... 0010 . . . 1 .... @2reg_shr_b | ||
41 | + | ||
42 | +VRSRA_S_2sh 1111 001 0 1 . ...... .... 0011 . . . 1 .... @2reg_shr_d | ||
43 | +VRSRA_S_2sh 1111 001 0 1 . ...... .... 0011 . . . 1 .... @2reg_shr_s | ||
44 | +VRSRA_S_2sh 1111 001 0 1 . ...... .... 0011 . . . 1 .... @2reg_shr_h | ||
45 | +VRSRA_S_2sh 1111 001 0 1 . ...... .... 0011 . . . 1 .... @2reg_shr_b | ||
46 | + | ||
47 | +VRSRA_U_2sh 1111 001 1 1 . ...... .... 0011 . . . 1 .... @2reg_shr_d | ||
48 | +VRSRA_U_2sh 1111 001 1 1 . ...... .... 0011 . . . 1 .... @2reg_shr_s | ||
49 | +VRSRA_U_2sh 1111 001 1 1 . ...... .... 0011 . . . 1 .... @2reg_shr_h | ||
50 | +VRSRA_U_2sh 1111 001 1 1 . ...... .... 0011 . . . 1 .... @2reg_shr_b | ||
51 | + | ||
52 | +VSRI_2sh 1111 001 1 1 . ...... .... 0100 . . . 1 .... @2reg_shr_d | ||
53 | +VSRI_2sh 1111 001 1 1 . ...... .... 0100 . . . 1 .... @2reg_shr_s | ||
54 | +VSRI_2sh 1111 001 1 1 . ...... .... 0100 . . . 1 .... @2reg_shr_h | ||
55 | +VSRI_2sh 1111 001 1 1 . ...... .... 0100 . . . 1 .... @2reg_shr_b | ||
56 | + | ||
57 | VSHL_2sh 1111 001 0 1 . ...... .... 0101 . . . 1 .... @2reg_shl_d | ||
58 | VSHL_2sh 1111 001 0 1 . ...... .... 0101 . . . 1 .... @2reg_shl_s | ||
59 | VSHL_2sh 1111 001 0 1 . ...... .... 0101 . . . 1 .... @2reg_shl_h | ||
60 | diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c | ||
61 | index XXXXXXX..XXXXXXX 100644 | ||
62 | --- a/target/arm/translate-neon.inc.c | ||
63 | +++ b/target/arm/translate-neon.inc.c | ||
64 | @@ -XXX,XX +XXX,XX @@ static bool do_vector_2sh(DisasContext *s, arg_2reg_shift *a, GVecGen2iFn *fn) | ||
65 | |||
66 | DO_2SH(VSHL, tcg_gen_gvec_shli) | ||
67 | DO_2SH(VSLI, gen_gvec_sli) | ||
68 | +DO_2SH(VSRI, gen_gvec_sri) | ||
69 | +DO_2SH(VSRA_S, gen_gvec_ssra) | ||
70 | +DO_2SH(VSRA_U, gen_gvec_usra) | ||
71 | +DO_2SH(VRSHR_S, gen_gvec_srshr) | ||
72 | +DO_2SH(VRSHR_U, gen_gvec_urshr) | ||
73 | +DO_2SH(VRSRA_S, gen_gvec_srsra) | ||
74 | +DO_2SH(VRSRA_U, gen_gvec_ursra) | ||
75 | |||
76 | static bool trans_VSHR_S_2sh(DisasContext *s, arg_2reg_shift *a) | ||
77 | { | ||
78 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 49 | diff --git a/target/arm/translate.c b/target/arm/translate.c |
79 | index XXXXXXX..XXXXXXX 100644 | 50 | index XXXXXXX..XXXXXXX 100644 |
80 | --- a/target/arm/translate.c | 51 | --- a/target/arm/translate.c |
81 | +++ b/target/arm/translate.c | 52 | +++ b/target/arm/translate.c |
82 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | 53 | @@ -XXX,XX +XXX,XX @@ static void do_coproc_insn(DisasContext *s, int cpnum, int is64, |
83 | 54 | break; | |
84 | switch (op) { | 55 | } |
85 | case 0: /* VSHR */ | 56 | |
86 | + case 1: /* VSRA */ | 57 | + if (s->hstr_active && cpnum == 15 && s->current_el == 1) { |
87 | + case 2: /* VRSHR */ | 58 | + /* |
88 | + case 3: /* VRSRA */ | 59 | + * At EL1, check for a HSTR_EL2 trap, which must take precedence |
89 | + case 4: /* VSRI */ | 60 | + * over the UNDEF for "no such register" or the UNDEF for "access |
90 | case 5: /* VSHL, VSLI */ | 61 | + * permissions forbid this EL1 access". HSTR_EL2 traps from EL0 |
91 | return 1; /* handled by decodetree */ | 62 | + * only happen if the cpreg doesn't UNDEF at EL0, so we do those in |
92 | default: | 63 | + * access_check_cp_reg(), after the checks for whether the access |
93 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | 64 | + * configurably trapped to EL1. |
94 | shift = shift - (1 << (size + 3)); | 65 | + */ |
95 | } | 66 | + uint32_t maskbit = is64 ? crm : crn; |
96 | 67 | + | |
97 | - switch (op) { | 68 | + if (maskbit != 4 && maskbit != 14) { |
98 | - case 1: /* VSRA */ | 69 | + /* T4 and T14 are RES0 so never cause traps */ |
99 | - /* Right shift comes here negative. */ | 70 | + TCGv_i32 t; |
100 | - shift = -shift; | 71 | + DisasLabel over = gen_disas_label(s); |
101 | - if (u) { | 72 | + |
102 | - gen_gvec_usra(size, rd_ofs, rm_ofs, shift, | 73 | + t = load_cpu_offset(offsetoflow32(CPUARMState, cp15.hstr_el2)); |
103 | - vec_size, vec_size); | 74 | + tcg_gen_andi_i32(t, t, 1u << maskbit); |
104 | - } else { | 75 | + tcg_gen_brcondi_i32(TCG_COND_EQ, t, 0, over.label); |
105 | - gen_gvec_ssra(size, rd_ofs, rm_ofs, shift, | 76 | + tcg_temp_free_i32(t); |
106 | - vec_size, vec_size); | 77 | + |
107 | - } | 78 | + gen_exception_insn(s, 0, EXCP_UDEF, syndrome); |
108 | - return 0; | 79 | + set_disas_label(s, over); |
109 | - | 80 | + } |
110 | - case 2: /* VRSHR */ | 81 | + } |
111 | - /* Right shift comes here negative. */ | 82 | + |
112 | - shift = -shift; | 83 | if (!ri) { |
113 | - if (u) { | 84 | /* |
114 | - gen_gvec_urshr(size, rd_ofs, rm_ofs, shift, | 85 | * Unknown register; this might be a guest error or a QEMU |
115 | - vec_size, vec_size); | 86 | @@ -XXX,XX +XXX,XX @@ static void do_coproc_insn(DisasContext *s, int cpnum, int is64, |
116 | - } else { | 87 | return; |
117 | - gen_gvec_srshr(size, rd_ofs, rm_ofs, shift, | 88 | } |
118 | - vec_size, vec_size); | 89 | |
119 | - } | 90 | - if (s->hstr_active || ri->accessfn || |
120 | - return 0; | 91 | + if ((s->hstr_active && s->current_el == 0) || ri->accessfn || |
121 | - | 92 | (arm_dc_feature(s, ARM_FEATURE_XSCALE) && cpnum < 14)) { |
122 | - case 3: /* VRSRA */ | 93 | /* |
123 | - /* Right shift comes here negative. */ | 94 | * Emit code to perform further access permissions checks at |
124 | - shift = -shift; | ||
125 | - if (u) { | ||
126 | - gen_gvec_ursra(size, rd_ofs, rm_ofs, shift, | ||
127 | - vec_size, vec_size); | ||
128 | - } else { | ||
129 | - gen_gvec_srsra(size, rd_ofs, rm_ofs, shift, | ||
130 | - vec_size, vec_size); | ||
131 | - } | ||
132 | - return 0; | ||
133 | - | ||
134 | - case 4: /* VSRI */ | ||
135 | - if (!u) { | ||
136 | - return 1; | ||
137 | - } | ||
138 | - /* Right shift comes here negative. */ | ||
139 | - shift = -shift; | ||
140 | - gen_gvec_sri(size, rd_ofs, rm_ofs, shift, | ||
141 | - vec_size, vec_size); | ||
142 | - return 0; | ||
143 | - } | ||
144 | - | ||
145 | if (size == 3) { | ||
146 | count = q + 1; | ||
147 | } else { | ||
148 | -- | 95 | -- |
149 | 2.20.1 | 96 | 2.34.1 |
150 | |||
151 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | The HSTR_EL2 register is not supposed to have an effect unless EL2 is |
---|---|---|---|
2 | enabled in the current security state. We weren't checking for this, | ||
3 | which meant that if the guest set up the HSTR_EL2 register we would | ||
4 | incorrectly trap even for accesses from Secure EL0 and EL1. | ||
2 | 5 | ||
3 | hw_error() calls exit(). This a bit overkill when we can log | 6 | Add the missing checks. (Other places where we look at HSTR_EL2 |
4 | the accesses as unimplemented or guest error. | 7 | for the not-in-v8A bits TTEE and TJDBX are already checking that |
8 | we are in NS EL0 or EL1, so there we alredy know EL2 is enabled.) | ||
5 | 9 | ||
6 | When fuzzing the devices, we don't want the whole process to | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | exit. Replace some hw_error() calls by qemu_log_mask() | 11 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
8 | (missed in commit 5a0001ec7e). | 12 | Tested-by: Fuad Tabba <tabba@google.com> |
13 | Message-id: 20230130182459.3309057-8-peter.maydell@linaro.org | ||
14 | Message-id: 20230127175507.2895013-8-peter.maydell@linaro.org | ||
15 | --- | ||
16 | target/arm/helper.c | 2 +- | ||
17 | target/arm/op_helper.c | 1 + | ||
18 | 2 files changed, 2 insertions(+), 1 deletion(-) | ||
9 | 19 | ||
10 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 20 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
11 | Message-id: 20200525114123.21317-2-f4bug@amsat.org | ||
12 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
14 | --- | ||
15 | hw/input/pxa2xx_keypad.c | 10 +++++++--- | ||
16 | 1 file changed, 7 insertions(+), 3 deletions(-) | ||
17 | |||
18 | diff --git a/hw/input/pxa2xx_keypad.c b/hw/input/pxa2xx_keypad.c | ||
19 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/hw/input/pxa2xx_keypad.c | 22 | --- a/target/arm/helper.c |
21 | +++ b/hw/input/pxa2xx_keypad.c | 23 | +++ b/target/arm/helper.c |
22 | @@ -XXX,XX +XXX,XX @@ | 24 | @@ -XXX,XX +XXX,XX @@ static CPUARMTBFlags rebuild_hflags_a32(CPUARMState *env, int fp_el, |
23 | */ | 25 | DP_TBFLAG_A32(flags, VFPEN, 1); |
24 | |||
25 | #include "qemu/osdep.h" | ||
26 | -#include "hw/hw.h" | ||
27 | +#include "qemu/log.h" | ||
28 | #include "hw/irq.h" | ||
29 | #include "migration/vmstate.h" | ||
30 | #include "hw/arm/pxa.h" | ||
31 | @@ -XXX,XX +XXX,XX @@ static uint64_t pxa2xx_keypad_read(void *opaque, hwaddr offset, | ||
32 | return s->kpkdi; | ||
33 | break; | ||
34 | default: | ||
35 | - hw_error("%s: Bad offset " REG_FMT "\n", __func__, offset); | ||
36 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
37 | + "%s: Bad read offset 0x%"HWADDR_PRIx"\n", | ||
38 | + __func__, offset); | ||
39 | } | 26 | } |
40 | 27 | ||
41 | return 0; | 28 | - if (el < 2 && env->cp15.hstr_el2 && |
42 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_keypad_write(void *opaque, hwaddr offset, | 29 | + if (el < 2 && env->cp15.hstr_el2 && arm_is_el2_enabled(env) && |
43 | break; | 30 | (arm_hcr_el2_eff(env) & (HCR_E2H | HCR_TGE)) != (HCR_E2H | HCR_TGE)) { |
44 | 31 | DP_TBFLAG_A32(flags, HSTR_ACTIVE, 1); | |
45 | default: | ||
46 | - hw_error("%s: Bad offset " REG_FMT "\n", __func__, offset); | ||
47 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
48 | + "%s: Bad write offset 0x%"HWADDR_PRIx"\n", | ||
49 | + __func__, offset); | ||
50 | } | 32 | } |
51 | } | 33 | diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c |
34 | index XXXXXXX..XXXXXXX 100644 | ||
35 | --- a/target/arm/op_helper.c | ||
36 | +++ b/target/arm/op_helper.c | ||
37 | @@ -XXX,XX +XXX,XX @@ const void *HELPER(access_check_cp_reg)(CPUARMState *env, uint32_t key, | ||
38 | * we only need to check here for traps from EL0. | ||
39 | */ | ||
40 | if (!is_a64(env) && arm_current_el(env) == 0 && ri->cp == 15 && | ||
41 | + arm_is_el2_enabled(env) && | ||
42 | (arm_hcr_el2_eff(env) & (HCR_E2H | HCR_TGE)) != (HCR_E2H | HCR_TGE)) { | ||
43 | uint32_t mask = 1 << ri->crn; | ||
52 | 44 | ||
53 | -- | 45 | -- |
54 | 2.20.1 | 46 | 2.34.1 |
55 | |||
56 | diff view generated by jsdifflib |
1 | Convert the VSHR 2-reg-shift insns to decodetree. | 1 | Define the system registers which are provided by the |
---|---|---|---|
2 | 2 | FEAT_FGT fine-grained trap architectural feature: | |
3 | Note that unlike the legacy decoder, we present the right shift | 3 | HFGRTR_EL2, HFGWTR_EL2, HDFGRTR_EL2, HDFGWTR_EL2, HFGITR_EL2 |
4 | amount to the trans_ function as a positive integer. | 4 | |
5 | All these registers are a set of bit fields, where each bit is set | ||
6 | for a trap and clear to not trap on a particular system register | ||
7 | access. The R and W register pairs are for system registers, | ||
8 | allowing trapping to be done separately for reads and writes; the I | ||
9 | register is for system instructions where trapping is on instruction | ||
10 | execution. | ||
11 | |||
12 | The data storage in the CPU state struct is arranged as a set of | ||
13 | arrays rather than separate fields so that when we're looking up the | ||
14 | bits for a system register access we can just index into the array | ||
15 | rather than having to use a switch to select a named struct member. | ||
16 | The later FEAT_FGT2 will add extra elements to these arrays. | ||
17 | |||
18 | The field definitions for the new registers are in cpregs.h because | ||
19 | in practice the code that needs them is code that also needs | ||
20 | the cpregs information; cpu.h is included in a lot more files. | ||
21 | We're also going to add some FGT-specific definitions to cpregs.h | ||
22 | in the next commit. | ||
23 | |||
24 | We do not implement HAFGRTR_EL2, because we don't implement | ||
25 | FEAT_AMUv1. | ||
5 | 26 | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 27 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 28 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
8 | Message-id: 20200522145520.6778-3-peter.maydell@linaro.org | 29 | Tested-by: Fuad Tabba <tabba@google.com> |
30 | Message-id: 20230130182459.3309057-9-peter.maydell@linaro.org | ||
31 | Message-id: 20230127175507.2895013-9-peter.maydell@linaro.org | ||
9 | --- | 32 | --- |
10 | target/arm/neon-dp.decode | 25 ++++++++++++++++++++ | 33 | target/arm/cpregs.h | 285 ++++++++++++++++++++++++++++++++++++++++++++ |
11 | target/arm/translate-neon.inc.c | 41 +++++++++++++++++++++++++++++++++ | 34 | target/arm/cpu.h | 15 +++ |
12 | target/arm/translate.c | 21 +---------------- | 35 | target/arm/helper.c | 40 +++++++ |
13 | 3 files changed, 67 insertions(+), 20 deletions(-) | 36 | 3 files changed, 340 insertions(+) |
14 | 37 | ||
15 | diff --git a/target/arm/neon-dp.decode b/target/arm/neon-dp.decode | 38 | diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h |
16 | index XXXXXXX..XXXXXXX 100644 | 39 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/neon-dp.decode | 40 | --- a/target/arm/cpregs.h |
18 | +++ b/target/arm/neon-dp.decode | 41 | +++ b/target/arm/cpregs.h |
19 | @@ -XXX,XX +XXX,XX @@ VMINNM_fp_3s 1111 001 1 0 . 1 . .... .... 1111 ... 1 .... @3same_fp | 42 | @@ -XXX,XX +XXX,XX @@ typedef enum CPAccessResult { |
20 | ###################################################################### | 43 | CP_ACCESS_TRAP_UNCATEGORIZED = (2 << 2), |
21 | &2reg_shift vm vd q shift size | 44 | } CPAccessResult; |
22 | 45 | ||
23 | +# Right shifts are encoded as N - shift, where N is the element size in bits. | 46 | +/* Indexes into fgt_read[] */ |
24 | +%neon_rshift_i6 16:6 !function=rsub_64 | 47 | +#define FGTREG_HFGRTR 0 |
25 | +%neon_rshift_i5 16:5 !function=rsub_32 | 48 | +#define FGTREG_HDFGRTR 1 |
26 | +%neon_rshift_i4 16:4 !function=rsub_16 | 49 | +/* Indexes into fgt_write[] */ |
27 | +%neon_rshift_i3 16:3 !function=rsub_8 | 50 | +#define FGTREG_HFGWTR 0 |
28 | + | 51 | +#define FGTREG_HDFGWTR 1 |
29 | +@2reg_shr_d .... ... . . . ...... .... .... 1 q:1 . . .... \ | 52 | +/* Indexes into fgt_exec[] */ |
30 | + &2reg_shift vm=%vm_dp vd=%vd_dp size=3 shift=%neon_rshift_i6 | 53 | +#define FGTREG_HFGITR 0 |
31 | +@2reg_shr_s .... ... . . . 1 ..... .... .... 0 q:1 . . .... \ | 54 | + |
32 | + &2reg_shift vm=%vm_dp vd=%vd_dp size=2 shift=%neon_rshift_i5 | 55 | +FIELD(HFGRTR_EL2, AFSR0_EL1, 0, 1) |
33 | +@2reg_shr_h .... ... . . . 01 .... .... .... 0 q:1 . . .... \ | 56 | +FIELD(HFGRTR_EL2, AFSR1_EL1, 1, 1) |
34 | + &2reg_shift vm=%vm_dp vd=%vd_dp size=1 shift=%neon_rshift_i4 | 57 | +FIELD(HFGRTR_EL2, AIDR_EL1, 2, 1) |
35 | +@2reg_shr_b .... ... . . . 001 ... .... .... 0 q:1 . . .... \ | 58 | +FIELD(HFGRTR_EL2, AMAIR_EL1, 3, 1) |
36 | + &2reg_shift vm=%vm_dp vd=%vd_dp size=0 shift=%neon_rshift_i3 | 59 | +FIELD(HFGRTR_EL2, APDAKEY, 4, 1) |
37 | + | 60 | +FIELD(HFGRTR_EL2, APDBKEY, 5, 1) |
38 | @2reg_shl_d .... ... . . . shift:6 .... .... 1 q:1 . . .... \ | 61 | +FIELD(HFGRTR_EL2, APGAKEY, 6, 1) |
39 | &2reg_shift vm=%vm_dp vd=%vd_dp size=3 | 62 | +FIELD(HFGRTR_EL2, APIAKEY, 7, 1) |
40 | @2reg_shl_s .... ... . . . 1 shift:5 .... .... 0 q:1 . . .... \ | 63 | +FIELD(HFGRTR_EL2, APIBKEY, 8, 1) |
41 | @@ -XXX,XX +XXX,XX @@ VMINNM_fp_3s 1111 001 1 0 . 1 . .... .... 1111 ... 1 .... @3same_fp | 64 | +FIELD(HFGRTR_EL2, CCSIDR_EL1, 9, 1) |
42 | @2reg_shl_b .... ... . . . 001 shift:3 .... .... 0 q:1 . . .... \ | 65 | +FIELD(HFGRTR_EL2, CLIDR_EL1, 10, 1) |
43 | &2reg_shift vm=%vm_dp vd=%vd_dp size=0 | 66 | +FIELD(HFGRTR_EL2, CONTEXTIDR_EL1, 11, 1) |
44 | 67 | +FIELD(HFGRTR_EL2, CPACR_EL1, 12, 1) | |
45 | +VSHR_S_2sh 1111 001 0 1 . ...... .... 0000 . . . 1 .... @2reg_shr_d | 68 | +FIELD(HFGRTR_EL2, CSSELR_EL1, 13, 1) |
46 | +VSHR_S_2sh 1111 001 0 1 . ...... .... 0000 . . . 1 .... @2reg_shr_s | 69 | +FIELD(HFGRTR_EL2, CTR_EL0, 14, 1) |
47 | +VSHR_S_2sh 1111 001 0 1 . ...... .... 0000 . . . 1 .... @2reg_shr_h | 70 | +FIELD(HFGRTR_EL2, DCZID_EL0, 15, 1) |
48 | +VSHR_S_2sh 1111 001 0 1 . ...... .... 0000 . . . 1 .... @2reg_shr_b | 71 | +FIELD(HFGRTR_EL2, ESR_EL1, 16, 1) |
49 | + | 72 | +FIELD(HFGRTR_EL2, FAR_EL1, 17, 1) |
50 | +VSHR_U_2sh 1111 001 1 1 . ...... .... 0000 . . . 1 .... @2reg_shr_d | 73 | +FIELD(HFGRTR_EL2, ISR_EL1, 18, 1) |
51 | +VSHR_U_2sh 1111 001 1 1 . ...... .... 0000 . . . 1 .... @2reg_shr_s | 74 | +FIELD(HFGRTR_EL2, LORC_EL1, 19, 1) |
52 | +VSHR_U_2sh 1111 001 1 1 . ...... .... 0000 . . . 1 .... @2reg_shr_h | 75 | +FIELD(HFGRTR_EL2, LOREA_EL1, 20, 1) |
53 | +VSHR_U_2sh 1111 001 1 1 . ...... .... 0000 . . . 1 .... @2reg_shr_b | 76 | +FIELD(HFGRTR_EL2, LORID_EL1, 21, 1) |
54 | + | 77 | +FIELD(HFGRTR_EL2, LORN_EL1, 22, 1) |
55 | VSHL_2sh 1111 001 0 1 . ...... .... 0101 . . . 1 .... @2reg_shl_d | 78 | +FIELD(HFGRTR_EL2, LORSA_EL1, 23, 1) |
56 | VSHL_2sh 1111 001 0 1 . ...... .... 0101 . . . 1 .... @2reg_shl_s | 79 | +FIELD(HFGRTR_EL2, MAIR_EL1, 24, 1) |
57 | VSHL_2sh 1111 001 0 1 . ...... .... 0101 . . . 1 .... @2reg_shl_h | 80 | +FIELD(HFGRTR_EL2, MIDR_EL1, 25, 1) |
58 | diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c | 81 | +FIELD(HFGRTR_EL2, MPIDR_EL1, 26, 1) |
82 | +FIELD(HFGRTR_EL2, PAR_EL1, 27, 1) | ||
83 | +FIELD(HFGRTR_EL2, REVIDR_EL1, 28, 1) | ||
84 | +FIELD(HFGRTR_EL2, SCTLR_EL1, 29, 1) | ||
85 | +FIELD(HFGRTR_EL2, SCXTNUM_EL1, 30, 1) | ||
86 | +FIELD(HFGRTR_EL2, SCXTNUM_EL0, 31, 1) | ||
87 | +FIELD(HFGRTR_EL2, TCR_EL1, 32, 1) | ||
88 | +FIELD(HFGRTR_EL2, TPIDR_EL1, 33, 1) | ||
89 | +FIELD(HFGRTR_EL2, TPIDRRO_EL0, 34, 1) | ||
90 | +FIELD(HFGRTR_EL2, TPIDR_EL0, 35, 1) | ||
91 | +FIELD(HFGRTR_EL2, TTBR0_EL1, 36, 1) | ||
92 | +FIELD(HFGRTR_EL2, TTBR1_EL1, 37, 1) | ||
93 | +FIELD(HFGRTR_EL2, VBAR_EL1, 38, 1) | ||
94 | +FIELD(HFGRTR_EL2, ICC_IGRPENN_EL1, 39, 1) | ||
95 | +FIELD(HFGRTR_EL2, ERRIDR_EL1, 40, 1) | ||
96 | +FIELD(HFGRTR_EL2, ERRSELR_EL1, 41, 1) | ||
97 | +FIELD(HFGRTR_EL2, ERXFR_EL1, 42, 1) | ||
98 | +FIELD(HFGRTR_EL2, ERXCTLR_EL1, 43, 1) | ||
99 | +FIELD(HFGRTR_EL2, ERXSTATUS_EL1, 44, 1) | ||
100 | +FIELD(HFGRTR_EL2, ERXMISCN_EL1, 45, 1) | ||
101 | +FIELD(HFGRTR_EL2, ERXPFGF_EL1, 46, 1) | ||
102 | +FIELD(HFGRTR_EL2, ERXPFGCTL_EL1, 47, 1) | ||
103 | +FIELD(HFGRTR_EL2, ERXPFGCDN_EL1, 48, 1) | ||
104 | +FIELD(HFGRTR_EL2, ERXADDR_EL1, 49, 1) | ||
105 | +FIELD(HFGRTR_EL2, NACCDATA_EL1, 50, 1) | ||
106 | +/* 51-53: RES0 */ | ||
107 | +FIELD(HFGRTR_EL2, NSMPRI_EL1, 54, 1) | ||
108 | +FIELD(HFGRTR_EL2, NTPIDR2_EL0, 55, 1) | ||
109 | +/* 56-63: RES0 */ | ||
110 | + | ||
111 | +/* These match HFGRTR but bits for RO registers are RES0 */ | ||
112 | +FIELD(HFGWTR_EL2, AFSR0_EL1, 0, 1) | ||
113 | +FIELD(HFGWTR_EL2, AFSR1_EL1, 1, 1) | ||
114 | +FIELD(HFGWTR_EL2, AMAIR_EL1, 3, 1) | ||
115 | +FIELD(HFGWTR_EL2, APDAKEY, 4, 1) | ||
116 | +FIELD(HFGWTR_EL2, APDBKEY, 5, 1) | ||
117 | +FIELD(HFGWTR_EL2, APGAKEY, 6, 1) | ||
118 | +FIELD(HFGWTR_EL2, APIAKEY, 7, 1) | ||
119 | +FIELD(HFGWTR_EL2, APIBKEY, 8, 1) | ||
120 | +FIELD(HFGWTR_EL2, CONTEXTIDR_EL1, 11, 1) | ||
121 | +FIELD(HFGWTR_EL2, CPACR_EL1, 12, 1) | ||
122 | +FIELD(HFGWTR_EL2, CSSELR_EL1, 13, 1) | ||
123 | +FIELD(HFGWTR_EL2, ESR_EL1, 16, 1) | ||
124 | +FIELD(HFGWTR_EL2, FAR_EL1, 17, 1) | ||
125 | +FIELD(HFGWTR_EL2, LORC_EL1, 19, 1) | ||
126 | +FIELD(HFGWTR_EL2, LOREA_EL1, 20, 1) | ||
127 | +FIELD(HFGWTR_EL2, LORN_EL1, 22, 1) | ||
128 | +FIELD(HFGWTR_EL2, LORSA_EL1, 23, 1) | ||
129 | +FIELD(HFGWTR_EL2, MAIR_EL1, 24, 1) | ||
130 | +FIELD(HFGWTR_EL2, PAR_EL1, 27, 1) | ||
131 | +FIELD(HFGWTR_EL2, SCTLR_EL1, 29, 1) | ||
132 | +FIELD(HFGWTR_EL2, SCXTNUM_EL1, 30, 1) | ||
133 | +FIELD(HFGWTR_EL2, SCXTNUM_EL0, 31, 1) | ||
134 | +FIELD(HFGWTR_EL2, TCR_EL1, 32, 1) | ||
135 | +FIELD(HFGWTR_EL2, TPIDR_EL1, 33, 1) | ||
136 | +FIELD(HFGWTR_EL2, TPIDRRO_EL0, 34, 1) | ||
137 | +FIELD(HFGWTR_EL2, TPIDR_EL0, 35, 1) | ||
138 | +FIELD(HFGWTR_EL2, TTBR0_EL1, 36, 1) | ||
139 | +FIELD(HFGWTR_EL2, TTBR1_EL1, 37, 1) | ||
140 | +FIELD(HFGWTR_EL2, VBAR_EL1, 38, 1) | ||
141 | +FIELD(HFGWTR_EL2, ICC_IGRPENN_EL1, 39, 1) | ||
142 | +FIELD(HFGWTR_EL2, ERRSELR_EL1, 41, 1) | ||
143 | +FIELD(HFGWTR_EL2, ERXCTLR_EL1, 43, 1) | ||
144 | +FIELD(HFGWTR_EL2, ERXSTATUS_EL1, 44, 1) | ||
145 | +FIELD(HFGWTR_EL2, ERXMISCN_EL1, 45, 1) | ||
146 | +FIELD(HFGWTR_EL2, ERXPFGCTL_EL1, 47, 1) | ||
147 | +FIELD(HFGWTR_EL2, ERXPFGCDN_EL1, 48, 1) | ||
148 | +FIELD(HFGWTR_EL2, ERXADDR_EL1, 49, 1) | ||
149 | +FIELD(HFGWTR_EL2, NACCDATA_EL1, 50, 1) | ||
150 | +FIELD(HFGWTR_EL2, NSMPRI_EL1, 54, 1) | ||
151 | +FIELD(HFGWTR_EL2, NTPIDR2_EL0, 55, 1) | ||
152 | + | ||
153 | +FIELD(HFGITR_EL2, ICIALLUIS, 0, 1) | ||
154 | +FIELD(HFGITR_EL2, ICIALLU, 1, 1) | ||
155 | +FIELD(HFGITR_EL2, ICIVAU, 2, 1) | ||
156 | +FIELD(HFGITR_EL2, DCIVAC, 3, 1) | ||
157 | +FIELD(HFGITR_EL2, DCISW, 4, 1) | ||
158 | +FIELD(HFGITR_EL2, DCCSW, 5, 1) | ||
159 | +FIELD(HFGITR_EL2, DCCISW, 6, 1) | ||
160 | +FIELD(HFGITR_EL2, DCCVAU, 7, 1) | ||
161 | +FIELD(HFGITR_EL2, DCCVAP, 8, 1) | ||
162 | +FIELD(HFGITR_EL2, DCCVADP, 9, 1) | ||
163 | +FIELD(HFGITR_EL2, DCCIVAC, 10, 1) | ||
164 | +FIELD(HFGITR_EL2, DCZVA, 11, 1) | ||
165 | +FIELD(HFGITR_EL2, ATS1E1R, 12, 1) | ||
166 | +FIELD(HFGITR_EL2, ATS1E1W, 13, 1) | ||
167 | +FIELD(HFGITR_EL2, ATS1E0R, 14, 1) | ||
168 | +FIELD(HFGITR_EL2, ATS1E0W, 15, 1) | ||
169 | +FIELD(HFGITR_EL2, ATS1E1RP, 16, 1) | ||
170 | +FIELD(HFGITR_EL2, ATS1E1WP, 17, 1) | ||
171 | +FIELD(HFGITR_EL2, TLBIVMALLE1OS, 18, 1) | ||
172 | +FIELD(HFGITR_EL2, TLBIVAE1OS, 19, 1) | ||
173 | +FIELD(HFGITR_EL2, TLBIASIDE1OS, 20, 1) | ||
174 | +FIELD(HFGITR_EL2, TLBIVAAE1OS, 21, 1) | ||
175 | +FIELD(HFGITR_EL2, TLBIVALE1OS, 22, 1) | ||
176 | +FIELD(HFGITR_EL2, TLBIVAALE1OS, 23, 1) | ||
177 | +FIELD(HFGITR_EL2, TLBIRVAE1OS, 24, 1) | ||
178 | +FIELD(HFGITR_EL2, TLBIRVAAE1OS, 25, 1) | ||
179 | +FIELD(HFGITR_EL2, TLBIRVALE1OS, 26, 1) | ||
180 | +FIELD(HFGITR_EL2, TLBIRVAALE1OS, 27, 1) | ||
181 | +FIELD(HFGITR_EL2, TLBIVMALLE1IS, 28, 1) | ||
182 | +FIELD(HFGITR_EL2, TLBIVAE1IS, 29, 1) | ||
183 | +FIELD(HFGITR_EL2, TLBIASIDE1IS, 30, 1) | ||
184 | +FIELD(HFGITR_EL2, TLBIVAAE1IS, 31, 1) | ||
185 | +FIELD(HFGITR_EL2, TLBIVALE1IS, 32, 1) | ||
186 | +FIELD(HFGITR_EL2, TLBIVAALE1IS, 33, 1) | ||
187 | +FIELD(HFGITR_EL2, TLBIRVAE1IS, 34, 1) | ||
188 | +FIELD(HFGITR_EL2, TLBIRVAAE1IS, 35, 1) | ||
189 | +FIELD(HFGITR_EL2, TLBIRVALE1IS, 36, 1) | ||
190 | +FIELD(HFGITR_EL2, TLBIRVAALE1IS, 37, 1) | ||
191 | +FIELD(HFGITR_EL2, TLBIRVAE1, 38, 1) | ||
192 | +FIELD(HFGITR_EL2, TLBIRVAAE1, 39, 1) | ||
193 | +FIELD(HFGITR_EL2, TLBIRVALE1, 40, 1) | ||
194 | +FIELD(HFGITR_EL2, TLBIRVAALE1, 41, 1) | ||
195 | +FIELD(HFGITR_EL2, TLBIVMALLE1, 42, 1) | ||
196 | +FIELD(HFGITR_EL2, TLBIVAE1, 43, 1) | ||
197 | +FIELD(HFGITR_EL2, TLBIASIDE1, 44, 1) | ||
198 | +FIELD(HFGITR_EL2, TLBIVAAE1, 45, 1) | ||
199 | +FIELD(HFGITR_EL2, TLBIVALE1, 46, 1) | ||
200 | +FIELD(HFGITR_EL2, TLBIVAALE1, 47, 1) | ||
201 | +FIELD(HFGITR_EL2, CFPRCTX, 48, 1) | ||
202 | +FIELD(HFGITR_EL2, DVPRCTX, 49, 1) | ||
203 | +FIELD(HFGITR_EL2, CPPRCTX, 50, 1) | ||
204 | +FIELD(HFGITR_EL2, ERET, 51, 1) | ||
205 | +FIELD(HFGITR_EL2, SVC_EL0, 52, 1) | ||
206 | +FIELD(HFGITR_EL2, SVC_EL1, 53, 1) | ||
207 | +FIELD(HFGITR_EL2, DCCVAC, 54, 1) | ||
208 | +FIELD(HFGITR_EL2, NBRBINJ, 55, 1) | ||
209 | +FIELD(HFGITR_EL2, NBRBIALL, 56, 1) | ||
210 | + | ||
211 | +FIELD(HDFGRTR_EL2, DBGBCRN_EL1, 0, 1) | ||
212 | +FIELD(HDFGRTR_EL2, DBGBVRN_EL1, 1, 1) | ||
213 | +FIELD(HDFGRTR_EL2, DBGWCRN_EL1, 2, 1) | ||
214 | +FIELD(HDFGRTR_EL2, DBGWVRN_EL1, 3, 1) | ||
215 | +FIELD(HDFGRTR_EL2, MDSCR_EL1, 4, 1) | ||
216 | +FIELD(HDFGRTR_EL2, DBGCLAIM, 5, 1) | ||
217 | +FIELD(HDFGRTR_EL2, DBGAUTHSTATUS_EL1, 6, 1) | ||
218 | +FIELD(HDFGRTR_EL2, DBGPRCR_EL1, 7, 1) | ||
219 | +/* 8: RES0: OSLAR_EL1 is WO */ | ||
220 | +FIELD(HDFGRTR_EL2, OSLSR_EL1, 9, 1) | ||
221 | +FIELD(HDFGRTR_EL2, OSECCR_EL1, 10, 1) | ||
222 | +FIELD(HDFGRTR_EL2, OSDLR_EL1, 11, 1) | ||
223 | +FIELD(HDFGRTR_EL2, PMEVCNTRN_EL0, 12, 1) | ||
224 | +FIELD(HDFGRTR_EL2, PMEVTYPERN_EL0, 13, 1) | ||
225 | +FIELD(HDFGRTR_EL2, PMCCFILTR_EL0, 14, 1) | ||
226 | +FIELD(HDFGRTR_EL2, PMCCNTR_EL0, 15, 1) | ||
227 | +FIELD(HDFGRTR_EL2, PMCNTEN, 16, 1) | ||
228 | +FIELD(HDFGRTR_EL2, PMINTEN, 17, 1) | ||
229 | +FIELD(HDFGRTR_EL2, PMOVS, 18, 1) | ||
230 | +FIELD(HDFGRTR_EL2, PMSELR_EL0, 19, 1) | ||
231 | +/* 20: RES0: PMSWINC_EL0 is WO */ | ||
232 | +/* 21: RES0: PMCR_EL0 is WO */ | ||
233 | +FIELD(HDFGRTR_EL2, PMMIR_EL1, 22, 1) | ||
234 | +FIELD(HDFGRTR_EL2, PMBLIMITR_EL1, 23, 1) | ||
235 | +FIELD(HDFGRTR_EL2, PMBPTR_EL1, 24, 1) | ||
236 | +FIELD(HDFGRTR_EL2, PMBSR_EL1, 25, 1) | ||
237 | +FIELD(HDFGRTR_EL2, PMSCR_EL1, 26, 1) | ||
238 | +FIELD(HDFGRTR_EL2, PMSEVFR_EL1, 27, 1) | ||
239 | +FIELD(HDFGRTR_EL2, PMSFCR_EL1, 28, 1) | ||
240 | +FIELD(HDFGRTR_EL2, PMSICR_EL1, 29, 1) | ||
241 | +FIELD(HDFGRTR_EL2, PMSIDR_EL1, 30, 1) | ||
242 | +FIELD(HDFGRTR_EL2, PMSIRR_EL1, 31, 1) | ||
243 | +FIELD(HDFGRTR_EL2, PMSLATFR_EL1, 32, 1) | ||
244 | +FIELD(HDFGRTR_EL2, TRC, 33, 1) | ||
245 | +FIELD(HDFGRTR_EL2, TRCAUTHSTATUS, 34, 1) | ||
246 | +FIELD(HDFGRTR_EL2, TRCAUXCTLR, 35, 1) | ||
247 | +FIELD(HDFGRTR_EL2, TRCCLAIM, 36, 1) | ||
248 | +FIELD(HDFGRTR_EL2, TRCCNTVRn, 37, 1) | ||
249 | +/* 38, 39: RES0 */ | ||
250 | +FIELD(HDFGRTR_EL2, TRCID, 40, 1) | ||
251 | +FIELD(HDFGRTR_EL2, TRCIMSPECN, 41, 1) | ||
252 | +/* 42: RES0: TRCOSLAR is WO */ | ||
253 | +FIELD(HDFGRTR_EL2, TRCOSLSR, 43, 1) | ||
254 | +FIELD(HDFGRTR_EL2, TRCPRGCTLR, 44, 1) | ||
255 | +FIELD(HDFGRTR_EL2, TRCSEQSTR, 45, 1) | ||
256 | +FIELD(HDFGRTR_EL2, TRCSSCSRN, 46, 1) | ||
257 | +FIELD(HDFGRTR_EL2, TRCSTATR, 47, 1) | ||
258 | +FIELD(HDFGRTR_EL2, TRCVICTLR, 48, 1) | ||
259 | +/* 49: RES0: TRFCR_EL1 is WO */ | ||
260 | +FIELD(HDFGRTR_EL2, TRBBASER_EL1, 50, 1) | ||
261 | +FIELD(HDFGRTR_EL2, TRBIDR_EL1, 51, 1) | ||
262 | +FIELD(HDFGRTR_EL2, TRBLIMITR_EL1, 52, 1) | ||
263 | +FIELD(HDFGRTR_EL2, TRBMAR_EL1, 53, 1) | ||
264 | +FIELD(HDFGRTR_EL2, TRBPTR_EL1, 54, 1) | ||
265 | +FIELD(HDFGRTR_EL2, TRBSR_EL1, 55, 1) | ||
266 | +FIELD(HDFGRTR_EL2, TRBTRG_EL1, 56, 1) | ||
267 | +FIELD(HDFGRTR_EL2, PMUSERENR_EL0, 57, 1) | ||
268 | +FIELD(HDFGRTR_EL2, PMCEIDN_EL0, 58, 1) | ||
269 | +FIELD(HDFGRTR_EL2, NBRBIDR, 59, 1) | ||
270 | +FIELD(HDFGRTR_EL2, NBRBCTL, 60, 1) | ||
271 | +FIELD(HDFGRTR_EL2, NBRBDATA, 61, 1) | ||
272 | +FIELD(HDFGRTR_EL2, NPMSNEVFR_EL1, 62, 1) | ||
273 | +FIELD(HDFGRTR_EL2, PMBIDR_EL1, 63, 1) | ||
274 | + | ||
275 | +/* | ||
276 | + * These match HDFGRTR_EL2, but bits for RO registers are RES0. | ||
277 | + * A few bits are for WO registers, where the HDFGRTR_EL2 bit is RES0. | ||
278 | + */ | ||
279 | +FIELD(HDFGWTR_EL2, DBGBCRN_EL1, 0, 1) | ||
280 | +FIELD(HDFGWTR_EL2, DBGBVRN_EL1, 1, 1) | ||
281 | +FIELD(HDFGWTR_EL2, DBGWCRN_EL1, 2, 1) | ||
282 | +FIELD(HDFGWTR_EL2, DBGWVRN_EL1, 3, 1) | ||
283 | +FIELD(HDFGWTR_EL2, MDSCR_EL1, 4, 1) | ||
284 | +FIELD(HDFGWTR_EL2, DBGCLAIM, 5, 1) | ||
285 | +FIELD(HDFGWTR_EL2, DBGPRCR_EL1, 7, 1) | ||
286 | +FIELD(HDFGWTR_EL2, OSLAR_EL1, 8, 1) | ||
287 | +FIELD(HDFGWTR_EL2, OSLSR_EL1, 9, 1) | ||
288 | +FIELD(HDFGWTR_EL2, OSECCR_EL1, 10, 1) | ||
289 | +FIELD(HDFGWTR_EL2, OSDLR_EL1, 11, 1) | ||
290 | +FIELD(HDFGWTR_EL2, PMEVCNTRN_EL0, 12, 1) | ||
291 | +FIELD(HDFGWTR_EL2, PMEVTYPERN_EL0, 13, 1) | ||
292 | +FIELD(HDFGWTR_EL2, PMCCFILTR_EL0, 14, 1) | ||
293 | +FIELD(HDFGWTR_EL2, PMCCNTR_EL0, 15, 1) | ||
294 | +FIELD(HDFGWTR_EL2, PMCNTEN, 16, 1) | ||
295 | +FIELD(HDFGWTR_EL2, PMINTEN, 17, 1) | ||
296 | +FIELD(HDFGWTR_EL2, PMOVS, 18, 1) | ||
297 | +FIELD(HDFGWTR_EL2, PMSELR_EL0, 19, 1) | ||
298 | +FIELD(HDFGWTR_EL2, PMSWINC_EL0, 20, 1) | ||
299 | +FIELD(HDFGWTR_EL2, PMCR_EL0, 21, 1) | ||
300 | +FIELD(HDFGWTR_EL2, PMBLIMITR_EL1, 23, 1) | ||
301 | +FIELD(HDFGWTR_EL2, PMBPTR_EL1, 24, 1) | ||
302 | +FIELD(HDFGWTR_EL2, PMBSR_EL1, 25, 1) | ||
303 | +FIELD(HDFGWTR_EL2, PMSCR_EL1, 26, 1) | ||
304 | +FIELD(HDFGWTR_EL2, PMSEVFR_EL1, 27, 1) | ||
305 | +FIELD(HDFGWTR_EL2, PMSFCR_EL1, 28, 1) | ||
306 | +FIELD(HDFGWTR_EL2, PMSICR_EL1, 29, 1) | ||
307 | +FIELD(HDFGWTR_EL2, PMSIRR_EL1, 31, 1) | ||
308 | +FIELD(HDFGWTR_EL2, PMSLATFR_EL1, 32, 1) | ||
309 | +FIELD(HDFGWTR_EL2, TRC, 33, 1) | ||
310 | +FIELD(HDFGWTR_EL2, TRCAUXCTLR, 35, 1) | ||
311 | +FIELD(HDFGWTR_EL2, TRCCLAIM, 36, 1) | ||
312 | +FIELD(HDFGWTR_EL2, TRCCNTVRn, 37, 1) | ||
313 | +FIELD(HDFGWTR_EL2, TRCIMSPECN, 41, 1) | ||
314 | +FIELD(HDFGWTR_EL2, TRCOSLAR, 42, 1) | ||
315 | +FIELD(HDFGWTR_EL2, TRCPRGCTLR, 44, 1) | ||
316 | +FIELD(HDFGWTR_EL2, TRCSEQSTR, 45, 1) | ||
317 | +FIELD(HDFGWTR_EL2, TRCSSCSRN, 46, 1) | ||
318 | +FIELD(HDFGWTR_EL2, TRCVICTLR, 48, 1) | ||
319 | +FIELD(HDFGWTR_EL2, TRFCR_EL1, 49, 1) | ||
320 | +FIELD(HDFGWTR_EL2, TRBBASER_EL1, 50, 1) | ||
321 | +FIELD(HDFGWTR_EL2, TRBLIMITR_EL1, 52, 1) | ||
322 | +FIELD(HDFGWTR_EL2, TRBMAR_EL1, 53, 1) | ||
323 | +FIELD(HDFGWTR_EL2, TRBPTR_EL1, 54, 1) | ||
324 | +FIELD(HDFGWTR_EL2, TRBSR_EL1, 55, 1) | ||
325 | +FIELD(HDFGWTR_EL2, TRBTRG_EL1, 56, 1) | ||
326 | +FIELD(HDFGWTR_EL2, PMUSERENR_EL0, 57, 1) | ||
327 | +FIELD(HDFGWTR_EL2, NBRBCTL, 60, 1) | ||
328 | +FIELD(HDFGWTR_EL2, NBRBDATA, 61, 1) | ||
329 | +FIELD(HDFGWTR_EL2, NPMSNEVFR_EL1, 62, 1) | ||
330 | + | ||
331 | typedef struct ARMCPRegInfo ARMCPRegInfo; | ||
332 | |||
333 | /* | ||
334 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
59 | index XXXXXXX..XXXXXXX 100644 | 335 | index XXXXXXX..XXXXXXX 100644 |
60 | --- a/target/arm/translate-neon.inc.c | 336 | --- a/target/arm/cpu.h |
61 | +++ b/target/arm/translate-neon.inc.c | 337 | +++ b/target/arm/cpu.h |
62 | @@ -XXX,XX +XXX,XX @@ static inline int plus1(DisasContext *s, int x) | 338 | @@ -XXX,XX +XXX,XX @@ typedef struct CPUArchState { |
63 | return x + 1; | 339 | uint64_t disr_el1; |
340 | uint64_t vdisr_el2; | ||
341 | uint64_t vsesr_el2; | ||
342 | + | ||
343 | + /* | ||
344 | + * Fine-Grained Trap registers. We store these as arrays so the | ||
345 | + * access checking code doesn't have to manually select | ||
346 | + * HFGRTR_EL2 vs HFDFGRTR_EL2 etc when looking up the bit to test. | ||
347 | + * FEAT_FGT2 will add more elements to these arrays. | ||
348 | + */ | ||
349 | + uint64_t fgt_read[2]; /* HFGRTR, HDFGRTR */ | ||
350 | + uint64_t fgt_write[2]; /* HFGWTR, HDFGWTR */ | ||
351 | + uint64_t fgt_exec[1]; /* HFGITR */ | ||
352 | } cp15; | ||
353 | |||
354 | struct { | ||
355 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa64_tgran64_2(const ARMISARegisters *id) | ||
356 | return t >= 2 || (t == 0 && isar_feature_aa64_tgran64(id)); | ||
64 | } | 357 | } |
65 | 358 | ||
66 | +static inline int rsub_64(DisasContext *s, int x) | 359 | +static inline bool isar_feature_aa64_fgt(const ARMISARegisters *id) |
67 | +{ | 360 | +{ |
68 | + return 64 - x; | 361 | + return FIELD_EX64(id->id_aa64mmfr0, ID_AA64MMFR0, FGT) != 0; |
69 | +} | 362 | +} |
70 | + | 363 | + |
71 | +static inline int rsub_32(DisasContext *s, int x) | 364 | static inline bool isar_feature_aa64_ccidx(const ARMISARegisters *id) |
365 | { | ||
366 | return FIELD_EX64(id->id_aa64mmfr2, ID_AA64MMFR2, CCIDX) != 0; | ||
367 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
368 | index XXXXXXX..XXXXXXX 100644 | ||
369 | --- a/target/arm/helper.c | ||
370 | +++ b/target/arm/helper.c | ||
371 | @@ -XXX,XX +XXX,XX @@ static void scr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) | ||
372 | if (cpu_isar_feature(aa64_hcx, cpu)) { | ||
373 | valid_mask |= SCR_HXEN; | ||
374 | } | ||
375 | + if (cpu_isar_feature(aa64_fgt, cpu)) { | ||
376 | + valid_mask |= SCR_FGTEN; | ||
377 | + } | ||
378 | } else { | ||
379 | valid_mask &= ~(SCR_RW | SCR_ST); | ||
380 | if (cpu_isar_feature(aa32_ras, cpu)) { | ||
381 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo scxtnum_reginfo[] = { | ||
382 | .access = PL3_RW, | ||
383 | .fieldoffset = offsetof(CPUARMState, scxtnum_el[3]) }, | ||
384 | }; | ||
385 | + | ||
386 | +static CPAccessResult access_fgt(CPUARMState *env, const ARMCPRegInfo *ri, | ||
387 | + bool isread) | ||
72 | +{ | 388 | +{ |
73 | + return 32 - x; | 389 | + if (arm_current_el(env) == 2 && |
390 | + arm_feature(env, ARM_FEATURE_EL3) && !(env->cp15.scr_el3 & SCR_FGTEN)) { | ||
391 | + return CP_ACCESS_TRAP_EL3; | ||
392 | + } | ||
393 | + return CP_ACCESS_OK; | ||
74 | +} | 394 | +} |
75 | +static inline int rsub_16(DisasContext *s, int x) | 395 | + |
76 | +{ | 396 | +static const ARMCPRegInfo fgt_reginfo[] = { |
77 | + return 16 - x; | 397 | + { .name = "HFGRTR_EL2", .state = ARM_CP_STATE_AA64, |
78 | +} | 398 | + .opc0 = 3, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 4, |
79 | +static inline int rsub_8(DisasContext *s, int x) | 399 | + .access = PL2_RW, .accessfn = access_fgt, |
80 | +{ | 400 | + .fieldoffset = offsetof(CPUARMState, cp15.fgt_read[FGTREG_HFGRTR]) }, |
81 | + return 8 - x; | 401 | + { .name = "HFGWTR_EL2", .state = ARM_CP_STATE_AA64, |
82 | +} | 402 | + .opc0 = 3, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 5, |
83 | + | 403 | + .access = PL2_RW, .accessfn = access_fgt, |
84 | /* Include the generated Neon decoder */ | 404 | + .fieldoffset = offsetof(CPUARMState, cp15.fgt_write[FGTREG_HFGWTR]) }, |
85 | #include "decode-neon-dp.inc.c" | 405 | + { .name = "HDFGRTR_EL2", .state = ARM_CP_STATE_AA64, |
86 | #include "decode-neon-ls.inc.c" | 406 | + .opc0 = 3, .opc1 = 4, .crn = 3, .crm = 1, .opc2 = 4, |
87 | @@ -XXX,XX +XXX,XX @@ static bool do_vector_2sh(DisasContext *s, arg_2reg_shift *a, GVecGen2iFn *fn) | 407 | + .access = PL2_RW, .accessfn = access_fgt, |
88 | 408 | + .fieldoffset = offsetof(CPUARMState, cp15.fgt_read[FGTREG_HDFGRTR]) }, | |
89 | DO_2SH(VSHL, tcg_gen_gvec_shli) | 409 | + { .name = "HDFGWTR_EL2", .state = ARM_CP_STATE_AA64, |
90 | DO_2SH(VSLI, gen_gvec_sli) | 410 | + .opc0 = 3, .opc1 = 4, .crn = 3, .crm = 1, .opc2 = 5, |
91 | + | 411 | + .access = PL2_RW, .accessfn = access_fgt, |
92 | +static bool trans_VSHR_S_2sh(DisasContext *s, arg_2reg_shift *a) | 412 | + .fieldoffset = offsetof(CPUARMState, cp15.fgt_write[FGTREG_HDFGWTR]) }, |
93 | +{ | 413 | + { .name = "HFGITR_EL2", .state = ARM_CP_STATE_AA64, |
94 | + /* Signed shift out of range results in all-sign-bits */ | 414 | + .opc0 = 3, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 6, |
95 | + a->shift = MIN(a->shift, (8 << a->size) - 1); | 415 | + .access = PL2_RW, .accessfn = access_fgt, |
96 | + return do_vector_2sh(s, a, tcg_gen_gvec_sari); | 416 | + .fieldoffset = offsetof(CPUARMState, cp15.fgt_exec[FGTREG_HFGITR]) }, |
97 | +} | 417 | +}; |
98 | + | 418 | #endif /* TARGET_AARCH64 */ |
99 | +static void gen_zero_rd_2sh(unsigned vece, uint32_t rd_ofs, uint32_t rm_ofs, | 419 | |
100 | + int64_t shift, uint32_t oprsz, uint32_t maxsz) | 420 | static CPAccessResult access_predinv(CPUARMState *env, const ARMCPRegInfo *ri, |
101 | +{ | 421 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) |
102 | + tcg_gen_gvec_dup_imm(vece, rd_ofs, oprsz, maxsz, 0); | 422 | if (cpu_isar_feature(aa64_scxtnum, cpu)) { |
103 | +} | 423 | define_arm_cp_regs(cpu, scxtnum_reginfo); |
104 | + | 424 | } |
105 | +static bool trans_VSHR_U_2sh(DisasContext *s, arg_2reg_shift *a) | 425 | + |
106 | +{ | 426 | + if (cpu_isar_feature(aa64_fgt, cpu)) { |
107 | + /* Shift out of range is architecturally valid and results in zero. */ | 427 | + define_arm_cp_regs(cpu, fgt_reginfo); |
108 | + if (a->shift >= (8 << a->size)) { | ||
109 | + return do_vector_2sh(s, a, gen_zero_rd_2sh); | ||
110 | + } else { | ||
111 | + return do_vector_2sh(s, a, tcg_gen_gvec_shri); | ||
112 | + } | 428 | + } |
113 | +} | 429 | #endif |
114 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 430 | |
115 | index XXXXXXX..XXXXXXX 100644 | 431 | if (cpu_isar_feature(any_predinv, cpu)) { |
116 | --- a/target/arm/translate.c | ||
117 | +++ b/target/arm/translate.c | ||
118 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
119 | op = (insn >> 8) & 0xf; | ||
120 | |||
121 | switch (op) { | ||
122 | + case 0: /* VSHR */ | ||
123 | case 5: /* VSHL, VSLI */ | ||
124 | return 1; /* handled by decodetree */ | ||
125 | default: | ||
126 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
127 | } | ||
128 | |||
129 | switch (op) { | ||
130 | - case 0: /* VSHR */ | ||
131 | - /* Right shift comes here negative. */ | ||
132 | - shift = -shift; | ||
133 | - /* Shifts larger than the element size are architecturally | ||
134 | - * valid. Unsigned results in all zeros; signed results | ||
135 | - * in all sign bits. | ||
136 | - */ | ||
137 | - if (!u) { | ||
138 | - tcg_gen_gvec_sari(size, rd_ofs, rm_ofs, | ||
139 | - MIN(shift, (8 << size) - 1), | ||
140 | - vec_size, vec_size); | ||
141 | - } else if (shift >= 8 << size) { | ||
142 | - tcg_gen_gvec_dup_imm(MO_8, rd_ofs, vec_size, | ||
143 | - vec_size, 0); | ||
144 | - } else { | ||
145 | - tcg_gen_gvec_shri(size, rd_ofs, rm_ofs, shift, | ||
146 | - vec_size, vec_size); | ||
147 | - } | ||
148 | - return 0; | ||
149 | - | ||
150 | case 1: /* VSRA */ | ||
151 | /* Right shift comes here negative. */ | ||
152 | shift = -shift; | ||
153 | -- | 432 | -- |
154 | 2.20.1 | 433 | 2.34.1 |
155 | |||
156 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | Implement the machinery for fine-grained traps on normal sysregs. |
---|---|---|---|
2 | 2 | Any sysreg with a fine-grained trap will set the new field to | |
3 | Do not yet convert the helpers to loop over opr_sz, but the | 3 | indicate which FGT register bit it should trap on. |
4 | descriptor allows the vector tail to be cleared. Which fixes | 4 | |
5 | an existing bug vs SVE. | 5 | FGT traps only happen when an AArch64 EL2 enables them for |
6 | 6 | an AArch64 EL1. They therefore are only relevant for AArch32 | |
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 7 | cpregs when the cpreg can be accessed from EL0. The logic |
8 | Message-id: 20200514212831.31248-5-richard.henderson@linaro.org | 8 | in access_check_cp_reg() will check this, so it is safe to |
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 9 | add a .fgt marking to an ARM_CP_STATE_BOTH ARMCPRegInfo. |
10 | |||
11 | The DO_BIT and DO_REV_BIT macros define enum constants FGT_##bitname | ||
12 | which can be used to specify the FGT bit, eg | ||
13 | .fgt = FGT_AFSR0_EL1 | ||
14 | (We assume that there is no bit name duplication across the FGT | ||
15 | registers, for brevity's sake.) | ||
16 | |||
17 | Subsequent commits will add the .fgt fields to the relevant register | ||
18 | definitions and define the FGT_nnn values for them. | ||
19 | |||
20 | Note that some of the FGT traps are for instructions that we don't | ||
21 | handle via the cpregs mechanisms (mostly these are instruction traps). | ||
22 | Those we will have to handle separately. | ||
23 | |||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 24 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
25 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
26 | Tested-by: Fuad Tabba <tabba@google.com> | ||
27 | Message-id: 20230130182459.3309057-10-peter.maydell@linaro.org | ||
28 | Message-id: 20230127175507.2895013-10-peter.maydell@linaro.org | ||
11 | --- | 29 | --- |
12 | target/arm/helper.h | 12 ++-- | 30 | target/arm/cpregs.h | 72 ++++++++++++++++++++++++++++++++++++++ |
13 | target/arm/neon-dp.decode | 12 ++-- | 31 | target/arm/cpu.h | 1 + |
14 | target/arm/crypto_helper.c | 24 +++++-- | 32 | target/arm/internals.h | 20 +++++++++++ |
15 | target/arm/translate-a64.c | 34 ++++----- | 33 | target/arm/translate.h | 2 ++ |
16 | target/arm/translate-neon.inc.c | 124 +++++--------------------------- | 34 | target/arm/helper.c | 9 +++++ |
17 | target/arm/translate.c | 24 ++----- | 35 | target/arm/op_helper.c | 30 ++++++++++++++++ |
18 | 6 files changed, 67 insertions(+), 163 deletions(-) | 36 | target/arm/translate-a64.c | 3 +- |
19 | 37 | target/arm/translate.c | 2 ++ | |
20 | diff --git a/target/arm/helper.h b/target/arm/helper.h | 38 | 8 files changed, 138 insertions(+), 1 deletion(-) |
21 | index XXXXXXX..XXXXXXX 100644 | 39 | |
22 | --- a/target/arm/helper.h | 40 | diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h |
23 | +++ b/target/arm/helper.h | 41 | index XXXXXXX..XXXXXXX 100644 |
24 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(crypto_aese, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | 42 | --- a/target/arm/cpregs.h |
25 | DEF_HELPER_FLAGS_3(crypto_aesmc, TCG_CALL_NO_RWG, void, ptr, ptr, i32) | 43 | +++ b/target/arm/cpregs.h |
26 | 44 | @@ -XXX,XX +XXX,XX @@ FIELD(HDFGWTR_EL2, NBRBCTL, 60, 1) | |
27 | DEF_HELPER_FLAGS_4(crypto_sha1_3reg, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | 45 | FIELD(HDFGWTR_EL2, NBRBDATA, 61, 1) |
28 | -DEF_HELPER_FLAGS_2(crypto_sha1h, TCG_CALL_NO_RWG, void, ptr, ptr) | 46 | FIELD(HDFGWTR_EL2, NPMSNEVFR_EL1, 62, 1) |
29 | -DEF_HELPER_FLAGS_2(crypto_sha1su1, TCG_CALL_NO_RWG, void, ptr, ptr) | 47 | |
30 | +DEF_HELPER_FLAGS_3(crypto_sha1h, TCG_CALL_NO_RWG, void, ptr, ptr, i32) | 48 | +/* Which fine-grained trap bit register to check, if any */ |
31 | +DEF_HELPER_FLAGS_3(crypto_sha1su1, TCG_CALL_NO_RWG, void, ptr, ptr, i32) | 49 | +FIELD(FGT, TYPE, 10, 3) |
32 | 50 | +FIELD(FGT, REV, 9, 1) /* Is bit sense reversed? */ | |
33 | -DEF_HELPER_FLAGS_3(crypto_sha256h, TCG_CALL_NO_RWG, void, ptr, ptr, ptr) | 51 | +FIELD(FGT, IDX, 6, 3) /* Index within a uint64_t[] array */ |
34 | -DEF_HELPER_FLAGS_3(crypto_sha256h2, TCG_CALL_NO_RWG, void, ptr, ptr, ptr) | 52 | +FIELD(FGT, BITPOS, 0, 6) /* Bit position within the uint64_t */ |
35 | -DEF_HELPER_FLAGS_2(crypto_sha256su0, TCG_CALL_NO_RWG, void, ptr, ptr) | 53 | + |
36 | -DEF_HELPER_FLAGS_3(crypto_sha256su1, TCG_CALL_NO_RWG, void, ptr, ptr, ptr) | 54 | +/* |
37 | +DEF_HELPER_FLAGS_4(crypto_sha256h, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | 55 | + * Macros to define FGT_##bitname enum constants to use in ARMCPRegInfo::fgt |
38 | +DEF_HELPER_FLAGS_4(crypto_sha256h2, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | 56 | + * fields. We assume for brevity's sake that there are no duplicated |
39 | +DEF_HELPER_FLAGS_3(crypto_sha256su0, TCG_CALL_NO_RWG, void, ptr, ptr, i32) | 57 | + * bit names across the various FGT registers. |
40 | +DEF_HELPER_FLAGS_4(crypto_sha256su1, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | 58 | + */ |
41 | 59 | +#define DO_BIT(REG, BITNAME) \ | |
42 | DEF_HELPER_FLAGS_4(crypto_sha512h, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | 60 | + FGT_##BITNAME = FGT_##REG | R_##REG##_EL2_##BITNAME##_SHIFT |
43 | DEF_HELPER_FLAGS_4(crypto_sha512h2, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | 61 | + |
44 | diff --git a/target/arm/neon-dp.decode b/target/arm/neon-dp.decode | 62 | +/* Some bits have reversed sense, so 0 means trap and 1 means not */ |
45 | index XXXXXXX..XXXXXXX 100644 | 63 | +#define DO_REV_BIT(REG, BITNAME) \ |
46 | --- a/target/arm/neon-dp.decode | 64 | + FGT_##BITNAME = FGT_##REG | FGT_REV | R_##REG##_EL2_##BITNAME##_SHIFT |
47 | +++ b/target/arm/neon-dp.decode | 65 | + |
48 | @@ -XXX,XX +XXX,XX @@ VPADD_3s 1111 001 0 0 . .. .... .... 1011 . . . 1 .... @3same_q0 | 66 | +typedef enum FGTBit { |
49 | 67 | + /* | |
50 | VQRDMLAH_3s 1111 001 1 0 . .. .... .... 1011 ... 1 .... @3same | 68 | + * These bits tell us which register arrays to use: |
51 | 69 | + * if FGT_R is set then reads are checked against fgt_read[]; | |
52 | +@3same_crypto .... .... .... .... .... .... .... .... \ | 70 | + * if FGT_W is set then writes are checked against fgt_write[]; |
53 | + &3same vm=%vm_dp vn=%vn_dp vd=%vd_dp size=0 q=1 | 71 | + * if FGT_EXEC is set then all accesses are checked against fgt_exec[]. |
54 | + | 72 | + * |
55 | SHA1_3s 1111 001 0 0 . optype:2 .... .... 1100 . 1 . 0 .... \ | 73 | + * For almost all bits in the R/W register pairs, the bit exists in |
56 | vm=%vm_dp vn=%vn_dp vd=%vd_dp | 74 | + * both registers for a RW register, in HFGRTR/HDFGRTR for a RO register |
57 | -SHA256H_3s 1111 001 1 0 . 00 .... .... 1100 . 1 . 0 .... \ | 75 | + * with the corresponding HFGWTR/HDFGTWTR bit being RES0, and vice-versa |
58 | - vm=%vm_dp vn=%vn_dp vd=%vd_dp | 76 | + * for a WO register. There are unfortunately a couple of exceptions |
59 | -SHA256H2_3s 1111 001 1 0 . 01 .... .... 1100 . 1 . 0 .... \ | 77 | + * (PMCR_EL0, TRFCR_EL1) where the register being trapped is RW but |
60 | - vm=%vm_dp vn=%vn_dp vd=%vd_dp | 78 | + * the FGT system only allows trapping of writes, not reads. |
61 | -SHA256SU1_3s 1111 001 1 0 . 10 .... .... 1100 . 1 . 0 .... \ | 79 | + * |
62 | - vm=%vm_dp vn=%vn_dp vd=%vd_dp | 80 | + * Note that we arrange these bits so that a 0 FGTBit means "no trap". |
63 | +SHA256H_3s 1111 001 1 0 . 00 .... .... 1100 . 1 . 0 .... @3same_crypto | 81 | + */ |
64 | +SHA256H2_3s 1111 001 1 0 . 01 .... .... 1100 . 1 . 0 .... @3same_crypto | 82 | + FGT_R = 1 << R_FGT_TYPE_SHIFT, |
65 | +SHA256SU1_3s 1111 001 1 0 . 10 .... .... 1100 . 1 . 0 .... @3same_crypto | 83 | + FGT_W = 2 << R_FGT_TYPE_SHIFT, |
66 | 84 | + FGT_EXEC = 4 << R_FGT_TYPE_SHIFT, | |
67 | VFMA_fp_3s 1111 001 0 0 . 0 . .... .... 1100 ... 1 .... @3same_fp | 85 | + FGT_RW = FGT_R | FGT_W, |
68 | VFMS_fp_3s 1111 001 0 0 . 1 . .... .... 1100 ... 1 .... @3same_fp | 86 | + /* Bit to identify whether trap bit is reversed sense */ |
69 | diff --git a/target/arm/crypto_helper.c b/target/arm/crypto_helper.c | 87 | + FGT_REV = R_FGT_REV_MASK, |
70 | index XXXXXXX..XXXXXXX 100644 | 88 | + |
71 | --- a/target/arm/crypto_helper.c | 89 | + /* |
72 | +++ b/target/arm/crypto_helper.c | 90 | + * If a bit exists in HFGRTR/HDFGRTR then either the register being |
73 | @@ -XXX,XX +XXX,XX @@ void HELPER(crypto_sha1_3reg)(void *vd, void *vn, void *vm, uint32_t op) | 91 | + * trapped is RO or the bit also exists in HFGWTR/HDFGWTR, so we either |
74 | rd[1] = d.l[1]; | 92 | + * want to trap for both reads and writes or else it's harmless to mark |
93 | + * it as trap-on-writes. | ||
94 | + * If a bit exists only in HFGWTR/HDFGWTR then either the register being | ||
95 | + * trapped is WO, or else it is one of the two oddball special cases | ||
96 | + * which are RW but have only a write trap. We mark these as only | ||
97 | + * FGT_W so we get the right behaviour for those special cases. | ||
98 | + * (If a bit was added in future that provided only a read trap for an | ||
99 | + * RW register we'd need to do something special to get the FGT_R bit | ||
100 | + * only. But this seems unlikely to happen.) | ||
101 | + * | ||
102 | + * So for the DO_BIT/DO_REV_BIT macros: use FGT_HFGRTR/FGT_HDFGRTR if | ||
103 | + * the bit exists in that register. Otherwise use FGT_HFGWTR/FGT_HDFGWTR. | ||
104 | + */ | ||
105 | + FGT_HFGRTR = FGT_RW | (FGTREG_HFGRTR << R_FGT_IDX_SHIFT), | ||
106 | + FGT_HFGWTR = FGT_W | (FGTREG_HFGWTR << R_FGT_IDX_SHIFT), | ||
107 | + FGT_HDFGRTR = FGT_RW | (FGTREG_HDFGRTR << R_FGT_IDX_SHIFT), | ||
108 | + FGT_HDFGWTR = FGT_W | (FGTREG_HDFGWTR << R_FGT_IDX_SHIFT), | ||
109 | + FGT_HFGITR = FGT_EXEC | (FGTREG_HFGITR << R_FGT_IDX_SHIFT), | ||
110 | +} FGTBit; | ||
111 | + | ||
112 | +#undef DO_BIT | ||
113 | +#undef DO_REV_BIT | ||
114 | + | ||
115 | typedef struct ARMCPRegInfo ARMCPRegInfo; | ||
116 | |||
117 | /* | ||
118 | @@ -XXX,XX +XXX,XX @@ struct ARMCPRegInfo { | ||
119 | CPAccessRights access; | ||
120 | /* Security state: ARM_CP_SECSTATE_* bits/values */ | ||
121 | CPSecureState secure; | ||
122 | + /* | ||
123 | + * Which fine-grained trap register bit to check, if any. This | ||
124 | + * value encodes both the trap register and bit within it. | ||
125 | + */ | ||
126 | + FGTBit fgt; | ||
127 | /* | ||
128 | * The opaque pointer passed to define_arm_cp_regs_with_opaque() when | ||
129 | * this register was defined: can be used to hand data through to the | ||
130 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
131 | index XXXXXXX..XXXXXXX 100644 | ||
132 | --- a/target/arm/cpu.h | ||
133 | +++ b/target/arm/cpu.h | ||
134 | @@ -XXX,XX +XXX,XX @@ FIELD(TBFLAG_ANY, FPEXC_EL, 8, 2) | ||
135 | /* Memory operations require alignment: SCTLR_ELx.A or CCR.UNALIGN_TRP */ | ||
136 | FIELD(TBFLAG_ANY, ALIGN_MEM, 10, 1) | ||
137 | FIELD(TBFLAG_ANY, PSTATE__IL, 11, 1) | ||
138 | +FIELD(TBFLAG_ANY, FGT_ACTIVE, 12, 1) | ||
139 | |||
140 | /* | ||
141 | * Bit usage when in AArch32 state, both A- and M-profile. | ||
142 | diff --git a/target/arm/internals.h b/target/arm/internals.h | ||
143 | index XXXXXXX..XXXXXXX 100644 | ||
144 | --- a/target/arm/internals.h | ||
145 | +++ b/target/arm/internals.h | ||
146 | @@ -XXX,XX +XXX,XX @@ static inline uint64_t arm_mdcr_el2_eff(CPUARMState *env) | ||
147 | ((1 << (1 - 1)) | (1 << (2 - 1)) | \ | ||
148 | (1 << (4 - 1)) | (1 << (8 - 1)) | (1 << (16 - 1))) | ||
149 | |||
150 | +/* | ||
151 | + * Return true if it is possible to take a fine-grained-trap to EL2. | ||
152 | + */ | ||
153 | +static inline bool arm_fgt_active(CPUARMState *env, int el) | ||
154 | +{ | ||
155 | + /* | ||
156 | + * The Arm ARM only requires the "{E2H,TGE} != {1,1}" test for traps | ||
157 | + * that can affect EL0, but it is harmless to do the test also for | ||
158 | + * traps on registers that are only accessible at EL1 because if the test | ||
159 | + * returns true then we can't be executing at EL1 anyway. | ||
160 | + * FGT traps only happen when EL2 is enabled and EL1 is AArch64; | ||
161 | + * traps from AArch32 only happen for the EL0 is AArch32 case. | ||
162 | + */ | ||
163 | + return cpu_isar_feature(aa64_fgt, env_archcpu(env)) && | ||
164 | + el < 2 && arm_is_el2_enabled(env) && | ||
165 | + arm_el_is_aa64(env, 1) && | ||
166 | + (arm_hcr_el2_eff(env) & (HCR_E2H | HCR_TGE)) != (HCR_E2H | HCR_TGE) && | ||
167 | + (!arm_feature(env, ARM_FEATURE_EL3) || (env->cp15.scr_el3 & SCR_FGTEN)); | ||
168 | +} | ||
169 | + | ||
170 | #endif | ||
171 | diff --git a/target/arm/translate.h b/target/arm/translate.h | ||
172 | index XXXXXXX..XXXXXXX 100644 | ||
173 | --- a/target/arm/translate.h | ||
174 | +++ b/target/arm/translate.h | ||
175 | @@ -XXX,XX +XXX,XX @@ typedef struct DisasContext { | ||
176 | bool is_nonstreaming; | ||
177 | /* True if MVE insns are definitely not predicated by VPR or LTPSIZE */ | ||
178 | bool mve_no_pred; | ||
179 | + /* True if fine-grained traps are active */ | ||
180 | + bool fgt_active; | ||
181 | /* | ||
182 | * >= 0, a copy of PSTATE.BTYPE, which will be 0 without v8.5-BTI. | ||
183 | * < 0, set by the current instruction. | ||
184 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
185 | index XXXXXXX..XXXXXXX 100644 | ||
186 | --- a/target/arm/helper.c | ||
187 | +++ b/target/arm/helper.c | ||
188 | @@ -XXX,XX +XXX,XX @@ static CPUARMTBFlags rebuild_hflags_common(CPUARMState *env, int fp_el, | ||
189 | if (arm_singlestep_active(env)) { | ||
190 | DP_TBFLAG_ANY(flags, SS_ACTIVE, 1); | ||
191 | } | ||
192 | + | ||
193 | return flags; | ||
75 | } | 194 | } |
76 | 195 | ||
77 | -void HELPER(crypto_sha1h)(void *vd, void *vm) | 196 | @@ -XXX,XX +XXX,XX @@ static CPUARMTBFlags rebuild_hflags_a32(CPUARMState *env, int fp_el, |
78 | +void HELPER(crypto_sha1h)(void *vd, void *vm, uint32_t desc) | 197 | DP_TBFLAG_A32(flags, HSTR_ACTIVE, 1); |
79 | { | 198 | } |
80 | uint64_t *rd = vd; | 199 | |
81 | uint64_t *rm = vm; | 200 | + if (arm_fgt_active(env, el)) { |
82 | @@ -XXX,XX +XXX,XX @@ void HELPER(crypto_sha1h)(void *vd, void *vm) | 201 | + DP_TBFLAG_ANY(flags, FGT_ACTIVE, 1); |
83 | 202 | + } | |
84 | rd[0] = m.l[0]; | 203 | + |
85 | rd[1] = m.l[1]; | 204 | if (env->uncached_cpsr & CPSR_IL) { |
86 | + | 205 | DP_TBFLAG_ANY(flags, PSTATE__IL, 1); |
87 | + clear_tail_16(vd, desc); | 206 | } |
88 | } | 207 | @@ -XXX,XX +XXX,XX @@ static CPUARMTBFlags rebuild_hflags_a64(CPUARMState *env, int el, int fp_el, |
89 | 208 | DP_TBFLAG_ANY(flags, PSTATE__IL, 1); | |
90 | -void HELPER(crypto_sha1su1)(void *vd, void *vm) | 209 | } |
91 | +void HELPER(crypto_sha1su1)(void *vd, void *vm, uint32_t desc) | 210 | |
92 | { | 211 | + if (arm_fgt_active(env, el)) { |
93 | uint64_t *rd = vd; | 212 | + DP_TBFLAG_ANY(flags, FGT_ACTIVE, 1); |
94 | uint64_t *rm = vm; | 213 | + } |
95 | @@ -XXX,XX +XXX,XX @@ void HELPER(crypto_sha1su1)(void *vd, void *vm) | 214 | + |
96 | 215 | if (cpu_isar_feature(aa64_mte, env_archcpu(env))) { | |
97 | rd[0] = d.l[0]; | 216 | /* |
98 | rd[1] = d.l[1]; | 217 | * Set MTE_ACTIVE if any access may be Checked, and leave clear |
99 | + | 218 | diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c |
100 | + clear_tail_16(vd, desc); | 219 | index XXXXXXX..XXXXXXX 100644 |
101 | } | 220 | --- a/target/arm/op_helper.c |
102 | 221 | +++ b/target/arm/op_helper.c | |
103 | /* | 222 | @@ -XXX,XX +XXX,XX @@ const void *HELPER(access_check_cp_reg)(CPUARMState *env, uint32_t key, |
104 | @@ -XXX,XX +XXX,XX @@ static uint32_t s1(uint32_t x) | 223 | } |
105 | return ror32(x, 17) ^ ror32(x, 19) ^ (x >> 10); | 224 | } |
106 | } | 225 | |
107 | 226 | + /* | |
108 | -void HELPER(crypto_sha256h)(void *vd, void *vn, void *vm) | 227 | + * Fine-grained traps also are lower priority than undef-to-EL1, |
109 | +void HELPER(crypto_sha256h)(void *vd, void *vn, void *vm, uint32_t desc) | 228 | + * higher priority than trap-to-EL3, and we don't care about priority |
110 | { | 229 | + * order with other EL2 traps because the syndrome value is the same. |
111 | uint64_t *rd = vd; | 230 | + */ |
112 | uint64_t *rn = vn; | 231 | + if (arm_fgt_active(env, arm_current_el(env))) { |
113 | @@ -XXX,XX +XXX,XX @@ void HELPER(crypto_sha256h)(void *vd, void *vn, void *vm) | 232 | + uint64_t trapword = 0; |
114 | 233 | + unsigned int idx = FIELD_EX32(ri->fgt, FGT, IDX); | |
115 | rd[0] = d.l[0]; | 234 | + unsigned int bitpos = FIELD_EX32(ri->fgt, FGT, BITPOS); |
116 | rd[1] = d.l[1]; | 235 | + bool rev = FIELD_EX32(ri->fgt, FGT, REV); |
117 | + | 236 | + bool trapbit; |
118 | + clear_tail_16(vd, desc); | 237 | + |
119 | } | 238 | + if (ri->fgt & FGT_EXEC) { |
120 | 239 | + assert(idx < ARRAY_SIZE(env->cp15.fgt_exec)); | |
121 | -void HELPER(crypto_sha256h2)(void *vd, void *vn, void *vm) | 240 | + trapword = env->cp15.fgt_exec[idx]; |
122 | +void HELPER(crypto_sha256h2)(void *vd, void *vn, void *vm, uint32_t desc) | 241 | + } else if (isread && (ri->fgt & FGT_R)) { |
123 | { | 242 | + assert(idx < ARRAY_SIZE(env->cp15.fgt_read)); |
124 | uint64_t *rd = vd; | 243 | + trapword = env->cp15.fgt_read[idx]; |
125 | uint64_t *rn = vn; | 244 | + } else if (!isread && (ri->fgt & FGT_W)) { |
126 | @@ -XXX,XX +XXX,XX @@ void HELPER(crypto_sha256h2)(void *vd, void *vn, void *vm) | 245 | + assert(idx < ARRAY_SIZE(env->cp15.fgt_write)); |
127 | 246 | + trapword = env->cp15.fgt_write[idx]; | |
128 | rd[0] = d.l[0]; | 247 | + } |
129 | rd[1] = d.l[1]; | 248 | + |
130 | + | 249 | + trapbit = extract64(trapword, bitpos, 1); |
131 | + clear_tail_16(vd, desc); | 250 | + if (trapbit != rev) { |
132 | } | 251 | + res = CP_ACCESS_TRAP_EL2; |
133 | 252 | + goto fail; | |
134 | -void HELPER(crypto_sha256su0)(void *vd, void *vm) | 253 | + } |
135 | +void HELPER(crypto_sha256su0)(void *vd, void *vm, uint32_t desc) | 254 | + } |
136 | { | 255 | + |
137 | uint64_t *rd = vd; | 256 | if (likely(res == CP_ACCESS_OK)) { |
138 | uint64_t *rm = vm; | 257 | return ri; |
139 | @@ -XXX,XX +XXX,XX @@ void HELPER(crypto_sha256su0)(void *vd, void *vm) | 258 | } |
140 | |||
141 | rd[0] = d.l[0]; | ||
142 | rd[1] = d.l[1]; | ||
143 | + | ||
144 | + clear_tail_16(vd, desc); | ||
145 | } | ||
146 | |||
147 | -void HELPER(crypto_sha256su1)(void *vd, void *vn, void *vm) | ||
148 | +void HELPER(crypto_sha256su1)(void *vd, void *vn, void *vm, uint32_t desc) | ||
149 | { | ||
150 | uint64_t *rd = vd; | ||
151 | uint64_t *rn = vn; | ||
152 | @@ -XXX,XX +XXX,XX @@ void HELPER(crypto_sha256su1)(void *vd, void *vn, void *vm) | ||
153 | |||
154 | rd[0] = d.l[0]; | ||
155 | rd[1] = d.l[1]; | ||
156 | + | ||
157 | + clear_tail_16(vd, desc); | ||
158 | } | ||
159 | |||
160 | /* | ||
161 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 259 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c |
162 | index XXXXXXX..XXXXXXX 100644 | 260 | index XXXXXXX..XXXXXXX 100644 |
163 | --- a/target/arm/translate-a64.c | 261 | --- a/target/arm/translate-a64.c |
164 | +++ b/target/arm/translate-a64.c | 262 | +++ b/target/arm/translate-a64.c |
165 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_three_reg_sha(DisasContext *s, uint32_t insn) | 263 | @@ -XXX,XX +XXX,XX @@ static void handle_sys(DisasContext *s, uint32_t insn, bool isread, |
166 | int rm = extract32(insn, 16, 5); | ||
167 | int rn = extract32(insn, 5, 5); | ||
168 | int rd = extract32(insn, 0, 5); | ||
169 | - CryptoThreeOpFn *genfn; | ||
170 | - TCGv_ptr tcg_rd_ptr, tcg_rn_ptr, tcg_rm_ptr; | ||
171 | + gen_helper_gvec_3 *genfn; | ||
172 | bool feature; | ||
173 | |||
174 | if (size != 0) { | ||
175 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_three_reg_sha(DisasContext *s, uint32_t insn) | ||
176 | return; | 264 | return; |
177 | } | 265 | } |
178 | 266 | ||
179 | - tcg_rd_ptr = vec_full_reg_ptr(s, rd); | 267 | - if (ri->accessfn) { |
180 | - tcg_rn_ptr = vec_full_reg_ptr(s, rn); | 268 | + if (ri->accessfn || (ri->fgt && s->fgt_active)) { |
181 | - tcg_rm_ptr = vec_full_reg_ptr(s, rm); | 269 | /* Emit code to perform further access permissions checks at |
182 | - | 270 | * runtime; this may result in an exception. |
183 | if (genfn) { | 271 | */ |
184 | - genfn(tcg_rd_ptr, tcg_rn_ptr, tcg_rm_ptr); | 272 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_init_disas_context(DisasContextBase *dcbase, |
185 | + gen_gvec_op3_ool(s, true, rd, rn, rm, 0, genfn); | 273 | dc->fp_excp_el = EX_TBFLAG_ANY(tb_flags, FPEXC_EL); |
186 | } else { | 274 | dc->align_mem = EX_TBFLAG_ANY(tb_flags, ALIGN_MEM); |
187 | TCGv_i32 tcg_opcode = tcg_const_i32(opcode); | 275 | dc->pstate_il = EX_TBFLAG_ANY(tb_flags, PSTATE__IL); |
188 | + TCGv_ptr tcg_rd_ptr = vec_full_reg_ptr(s, rd); | 276 | + dc->fgt_active = EX_TBFLAG_ANY(tb_flags, FGT_ACTIVE); |
189 | + TCGv_ptr tcg_rn_ptr = vec_full_reg_ptr(s, rn); | 277 | dc->sve_excp_el = EX_TBFLAG_A64(tb_flags, SVEEXC_EL); |
190 | + TCGv_ptr tcg_rm_ptr = vec_full_reg_ptr(s, rm); | 278 | dc->sme_excp_el = EX_TBFLAG_A64(tb_flags, SMEEXC_EL); |
191 | 279 | dc->vl = (EX_TBFLAG_A64(tb_flags, VL) + 1) * 16; | |
192 | gen_helper_crypto_sha1_3reg(tcg_rd_ptr, tcg_rn_ptr, | ||
193 | tcg_rm_ptr, tcg_opcode); | ||
194 | - tcg_temp_free_i32(tcg_opcode); | ||
195 | - } | ||
196 | |||
197 | - tcg_temp_free_ptr(tcg_rd_ptr); | ||
198 | - tcg_temp_free_ptr(tcg_rn_ptr); | ||
199 | - tcg_temp_free_ptr(tcg_rm_ptr); | ||
200 | + tcg_temp_free_i32(tcg_opcode); | ||
201 | + tcg_temp_free_ptr(tcg_rd_ptr); | ||
202 | + tcg_temp_free_ptr(tcg_rn_ptr); | ||
203 | + tcg_temp_free_ptr(tcg_rm_ptr); | ||
204 | + } | ||
205 | } | ||
206 | |||
207 | /* Crypto two-reg SHA | ||
208 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_two_reg_sha(DisasContext *s, uint32_t insn) | ||
209 | int opcode = extract32(insn, 12, 5); | ||
210 | int rn = extract32(insn, 5, 5); | ||
211 | int rd = extract32(insn, 0, 5); | ||
212 | - CryptoTwoOpFn *genfn; | ||
213 | + gen_helper_gvec_2 *genfn; | ||
214 | bool feature; | ||
215 | - TCGv_ptr tcg_rd_ptr, tcg_rn_ptr; | ||
216 | |||
217 | if (size != 0) { | ||
218 | unallocated_encoding(s); | ||
219 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_two_reg_sha(DisasContext *s, uint32_t insn) | ||
220 | if (!fp_access_check(s)) { | ||
221 | return; | ||
222 | } | ||
223 | - | ||
224 | - tcg_rd_ptr = vec_full_reg_ptr(s, rd); | ||
225 | - tcg_rn_ptr = vec_full_reg_ptr(s, rn); | ||
226 | - | ||
227 | - genfn(tcg_rd_ptr, tcg_rn_ptr); | ||
228 | - | ||
229 | - tcg_temp_free_ptr(tcg_rd_ptr); | ||
230 | - tcg_temp_free_ptr(tcg_rn_ptr); | ||
231 | + gen_gvec_op2_ool(s, true, rd, rn, 0, genfn); | ||
232 | } | ||
233 | |||
234 | static void gen_rax1_i64(TCGv_i64 d, TCGv_i64 n, TCGv_i64 m) | ||
235 | diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c | ||
236 | index XXXXXXX..XXXXXXX 100644 | ||
237 | --- a/target/arm/translate-neon.inc.c | ||
238 | +++ b/target/arm/translate-neon.inc.c | ||
239 | @@ -XXX,XX +XXX,XX @@ DO_3SAME_CMP(VCGE_S, TCG_COND_GE) | ||
240 | DO_3SAME_CMP(VCGE_U, TCG_COND_GEU) | ||
241 | DO_3SAME_CMP(VCEQ, TCG_COND_EQ) | ||
242 | |||
243 | -static void gen_VMUL_p_3s(unsigned vece, uint32_t rd_ofs, uint32_t rn_ofs, | ||
244 | - uint32_t rm_ofs, uint32_t oprsz, uint32_t maxsz) | ||
245 | -{ | ||
246 | - tcg_gen_gvec_3_ool(rd_ofs, rn_ofs, rm_ofs, oprsz, maxsz, | ||
247 | - 0, gen_helper_gvec_pmul_b); | ||
248 | -} | ||
249 | +#define WRAP_OOL_FN(WRAPNAME, FUNC) \ | ||
250 | + static void WRAPNAME(unsigned vece, uint32_t rd_ofs, uint32_t rn_ofs, \ | ||
251 | + uint32_t rm_ofs, uint32_t oprsz, uint32_t maxsz) \ | ||
252 | + { \ | ||
253 | + tcg_gen_gvec_3_ool(rd_ofs, rn_ofs, rm_ofs, oprsz, maxsz, 0, FUNC); \ | ||
254 | + } | ||
255 | + | ||
256 | +WRAP_OOL_FN(gen_VMUL_p_3s, gen_helper_gvec_pmul_b) | ||
257 | |||
258 | static bool trans_VMUL_p_3s(DisasContext *s, arg_3same *a) | ||
259 | { | ||
260 | @@ -XXX,XX +XXX,XX @@ static bool trans_SHA1_3s(DisasContext *s, arg_SHA1_3s *a) | ||
261 | return true; | ||
262 | } | ||
263 | |||
264 | -static bool trans_SHA256H_3s(DisasContext *s, arg_SHA256H_3s *a) | ||
265 | -{ | ||
266 | - TCGv_ptr ptr1, ptr2, ptr3; | ||
267 | - | ||
268 | - if (!arm_dc_feature(s, ARM_FEATURE_NEON) || | ||
269 | - !dc_isar_feature(aa32_sha2, s)) { | ||
270 | - return false; | ||
271 | +#define DO_SHA2(NAME, FUNC) \ | ||
272 | + WRAP_OOL_FN(gen_##NAME##_3s, FUNC) \ | ||
273 | + static bool trans_##NAME##_3s(DisasContext *s, arg_3same *a) \ | ||
274 | + { \ | ||
275 | + if (!dc_isar_feature(aa32_sha2, s)) { \ | ||
276 | + return false; \ | ||
277 | + } \ | ||
278 | + return do_3same(s, a, gen_##NAME##_3s); \ | ||
279 | } | ||
280 | |||
281 | - /* UNDEF accesses to D16-D31 if they don't exist. */ | ||
282 | - if (!dc_isar_feature(aa32_simd_r32, s) && | ||
283 | - ((a->vd | a->vn | a->vm) & 0x10)) { | ||
284 | - return false; | ||
285 | - } | ||
286 | - | ||
287 | - if ((a->vn | a->vm | a->vd) & 1) { | ||
288 | - return false; | ||
289 | - } | ||
290 | - | ||
291 | - if (!vfp_access_check(s)) { | ||
292 | - return true; | ||
293 | - } | ||
294 | - | ||
295 | - ptr1 = vfp_reg_ptr(true, a->vd); | ||
296 | - ptr2 = vfp_reg_ptr(true, a->vn); | ||
297 | - ptr3 = vfp_reg_ptr(true, a->vm); | ||
298 | - gen_helper_crypto_sha256h(ptr1, ptr2, ptr3); | ||
299 | - tcg_temp_free_ptr(ptr1); | ||
300 | - tcg_temp_free_ptr(ptr2); | ||
301 | - tcg_temp_free_ptr(ptr3); | ||
302 | - | ||
303 | - return true; | ||
304 | -} | ||
305 | - | ||
306 | -static bool trans_SHA256H2_3s(DisasContext *s, arg_SHA256H2_3s *a) | ||
307 | -{ | ||
308 | - TCGv_ptr ptr1, ptr2, ptr3; | ||
309 | - | ||
310 | - if (!arm_dc_feature(s, ARM_FEATURE_NEON) || | ||
311 | - !dc_isar_feature(aa32_sha2, s)) { | ||
312 | - return false; | ||
313 | - } | ||
314 | - | ||
315 | - /* UNDEF accesses to D16-D31 if they don't exist. */ | ||
316 | - if (!dc_isar_feature(aa32_simd_r32, s) && | ||
317 | - ((a->vd | a->vn | a->vm) & 0x10)) { | ||
318 | - return false; | ||
319 | - } | ||
320 | - | ||
321 | - if ((a->vn | a->vm | a->vd) & 1) { | ||
322 | - return false; | ||
323 | - } | ||
324 | - | ||
325 | - if (!vfp_access_check(s)) { | ||
326 | - return true; | ||
327 | - } | ||
328 | - | ||
329 | - ptr1 = vfp_reg_ptr(true, a->vd); | ||
330 | - ptr2 = vfp_reg_ptr(true, a->vn); | ||
331 | - ptr3 = vfp_reg_ptr(true, a->vm); | ||
332 | - gen_helper_crypto_sha256h2(ptr1, ptr2, ptr3); | ||
333 | - tcg_temp_free_ptr(ptr1); | ||
334 | - tcg_temp_free_ptr(ptr2); | ||
335 | - tcg_temp_free_ptr(ptr3); | ||
336 | - | ||
337 | - return true; | ||
338 | -} | ||
339 | - | ||
340 | -static bool trans_SHA256SU1_3s(DisasContext *s, arg_SHA256SU1_3s *a) | ||
341 | -{ | ||
342 | - TCGv_ptr ptr1, ptr2, ptr3; | ||
343 | - | ||
344 | - if (!arm_dc_feature(s, ARM_FEATURE_NEON) || | ||
345 | - !dc_isar_feature(aa32_sha2, s)) { | ||
346 | - return false; | ||
347 | - } | ||
348 | - | ||
349 | - /* UNDEF accesses to D16-D31 if they don't exist. */ | ||
350 | - if (!dc_isar_feature(aa32_simd_r32, s) && | ||
351 | - ((a->vd | a->vn | a->vm) & 0x10)) { | ||
352 | - return false; | ||
353 | - } | ||
354 | - | ||
355 | - if ((a->vn | a->vm | a->vd) & 1) { | ||
356 | - return false; | ||
357 | - } | ||
358 | - | ||
359 | - if (!vfp_access_check(s)) { | ||
360 | - return true; | ||
361 | - } | ||
362 | - | ||
363 | - ptr1 = vfp_reg_ptr(true, a->vd); | ||
364 | - ptr2 = vfp_reg_ptr(true, a->vn); | ||
365 | - ptr3 = vfp_reg_ptr(true, a->vm); | ||
366 | - gen_helper_crypto_sha256su1(ptr1, ptr2, ptr3); | ||
367 | - tcg_temp_free_ptr(ptr1); | ||
368 | - tcg_temp_free_ptr(ptr2); | ||
369 | - tcg_temp_free_ptr(ptr3); | ||
370 | - | ||
371 | - return true; | ||
372 | -} | ||
373 | +DO_SHA2(SHA256H, gen_helper_crypto_sha256h) | ||
374 | +DO_SHA2(SHA256H2, gen_helper_crypto_sha256h2) | ||
375 | +DO_SHA2(SHA256SU1, gen_helper_crypto_sha256su1) | ||
376 | |||
377 | #define DO_3SAME_64(INSN, FUNC) \ | ||
378 | static void gen_##INSN##_3s(unsigned vece, uint32_t rd_ofs, \ | ||
379 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 280 | diff --git a/target/arm/translate.c b/target/arm/translate.c |
380 | index XXXXXXX..XXXXXXX 100644 | 281 | index XXXXXXX..XXXXXXX 100644 |
381 | --- a/target/arm/translate.c | 282 | --- a/target/arm/translate.c |
382 | +++ b/target/arm/translate.c | 283 | +++ b/target/arm/translate.c |
383 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | 284 | @@ -XXX,XX +XXX,XX @@ static void do_coproc_insn(DisasContext *s, int cpnum, int is64, |
384 | int vec_size; | 285 | } |
385 | uint32_t imm; | 286 | |
386 | TCGv_i32 tmp, tmp2, tmp3, tmp4, tmp5; | 287 | if ((s->hstr_active && s->current_el == 0) || ri->accessfn || |
387 | - TCGv_ptr ptr1, ptr2; | 288 | + (ri->fgt && s->fgt_active) || |
388 | + TCGv_ptr ptr1; | 289 | (arm_dc_feature(s, ARM_FEATURE_XSCALE) && cpnum < 14)) { |
389 | TCGv_i64 tmp64; | 290 | /* |
390 | 291 | * Emit code to perform further access permissions checks at | |
391 | if (!arm_dc_feature(s, ARM_FEATURE_NEON)) { | 292 | @@ -XXX,XX +XXX,XX @@ static void arm_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) |
392 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | 293 | dc->fp_excp_el = EX_TBFLAG_ANY(tb_flags, FPEXC_EL); |
393 | if (!dc_isar_feature(aa32_sha1, s) || ((rm | rd) & 1)) { | 294 | dc->align_mem = EX_TBFLAG_ANY(tb_flags, ALIGN_MEM); |
394 | return 1; | 295 | dc->pstate_il = EX_TBFLAG_ANY(tb_flags, PSTATE__IL); |
395 | } | 296 | + dc->fgt_active = EX_TBFLAG_ANY(tb_flags, FGT_ACTIVE); |
396 | - ptr1 = vfp_reg_ptr(true, rd); | 297 | |
397 | - ptr2 = vfp_reg_ptr(true, rm); | 298 | if (arm_feature(env, ARM_FEATURE_M)) { |
398 | - | 299 | dc->vfp_enabled = 1; |
399 | - gen_helper_crypto_sha1h(ptr1, ptr2); | ||
400 | - | ||
401 | - tcg_temp_free_ptr(ptr1); | ||
402 | - tcg_temp_free_ptr(ptr2); | ||
403 | + tcg_gen_gvec_2_ool(rd_ofs, rm_ofs, 16, 16, 0, | ||
404 | + gen_helper_crypto_sha1h); | ||
405 | break; | ||
406 | case NEON_2RM_SHA1SU1: | ||
407 | if ((rm | rd) & 1) { | ||
408 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
409 | } else if (!dc_isar_feature(aa32_sha1, s)) { | ||
410 | return 1; | ||
411 | } | ||
412 | - ptr1 = vfp_reg_ptr(true, rd); | ||
413 | - ptr2 = vfp_reg_ptr(true, rm); | ||
414 | - if (q) { | ||
415 | - gen_helper_crypto_sha256su0(ptr1, ptr2); | ||
416 | - } else { | ||
417 | - gen_helper_crypto_sha1su1(ptr1, ptr2); | ||
418 | - } | ||
419 | - tcg_temp_free_ptr(ptr1); | ||
420 | - tcg_temp_free_ptr(ptr2); | ||
421 | + tcg_gen_gvec_2_ool(rd_ofs, rm_ofs, 16, 16, 0, | ||
422 | + q ? gen_helper_crypto_sha256su0 | ||
423 | + : gen_helper_crypto_sha1su1); | ||
424 | break; | ||
425 | - | ||
426 | case NEON_2RM_VMVN: | ||
427 | tcg_gen_gvec_not(0, rd_ofs, rm_ofs, vec_size, vec_size); | ||
428 | break; | ||
429 | -- | 300 | -- |
430 | 2.20.1 | 301 | 2.34.1 |
431 | |||
432 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | Mark up the sysreg definitions for the registers trapped |
---|---|---|---|
2 | by HFGRTR/HFGWTR bits 0..11. | ||
2 | 3 | ||
3 | The ADC region size is 256B, split as: | 4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | - [0x00 - 0x4f] defined | 5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
5 | - [0x50 - 0xff] reserved | 6 | Tested-by: Fuad Tabba <tabba@google.com> |
7 | Message-id: 20230130182459.3309057-11-peter.maydell@linaro.org | ||
8 | Message-id: 20230127175507.2895013-11-peter.maydell@linaro.org | ||
9 | --- | ||
10 | target/arm/cpregs.h | 14 ++++++++++++++ | ||
11 | target/arm/helper.c | 17 +++++++++++++++++ | ||
12 | 2 files changed, 31 insertions(+) | ||
6 | 13 | ||
7 | All registers are 32-bit (thus when the datasheet mentions the | 14 | diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h |
8 | last defined register is 0x4c, it means its address range is | ||
9 | 0x4c .. 0x4f. | ||
10 | |||
11 | This model implementation is also 32-bit. Set MemoryRegionOps | ||
12 | 'impl' fields. | ||
13 | |||
14 | See: | ||
15 | 'RM0033 Reference manual Rev 8', Table 10.13.18 "ADC register map". | ||
16 | |||
17 | Reported-by: Seth Kintigh <skintigh@gmail.com> | ||
18 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
19 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
20 | Message-id: 20200603055915.17678-1-f4bug@amsat.org | ||
21 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
22 | --- | ||
23 | hw/adc/stm32f2xx_adc.c | 4 +++- | ||
24 | 1 file changed, 3 insertions(+), 1 deletion(-) | ||
25 | |||
26 | diff --git a/hw/adc/stm32f2xx_adc.c b/hw/adc/stm32f2xx_adc.c | ||
27 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
28 | --- a/hw/adc/stm32f2xx_adc.c | 16 | --- a/target/arm/cpregs.h |
29 | +++ b/hw/adc/stm32f2xx_adc.c | 17 | +++ b/target/arm/cpregs.h |
30 | @@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps stm32f2xx_adc_ops = { | 18 | @@ -XXX,XX +XXX,XX @@ typedef enum FGTBit { |
31 | .read = stm32f2xx_adc_read, | 19 | FGT_HDFGRTR = FGT_RW | (FGTREG_HDFGRTR << R_FGT_IDX_SHIFT), |
32 | .write = stm32f2xx_adc_write, | 20 | FGT_HDFGWTR = FGT_W | (FGTREG_HDFGWTR << R_FGT_IDX_SHIFT), |
33 | .endianness = DEVICE_NATIVE_ENDIAN, | 21 | FGT_HFGITR = FGT_EXEC | (FGTREG_HFGITR << R_FGT_IDX_SHIFT), |
34 | + .impl.min_access_size = 4, | 22 | + |
35 | + .impl.max_access_size = 4, | 23 | + /* Trap bits in HFGRTR_EL2 / HFGWTR_EL2, starting from bit 0. */ |
24 | + DO_BIT(HFGRTR, AFSR0_EL1), | ||
25 | + DO_BIT(HFGRTR, AFSR1_EL1), | ||
26 | + DO_BIT(HFGRTR, AIDR_EL1), | ||
27 | + DO_BIT(HFGRTR, AMAIR_EL1), | ||
28 | + DO_BIT(HFGRTR, APDAKEY), | ||
29 | + DO_BIT(HFGRTR, APDBKEY), | ||
30 | + DO_BIT(HFGRTR, APGAKEY), | ||
31 | + DO_BIT(HFGRTR, APIAKEY), | ||
32 | + DO_BIT(HFGRTR, APIBKEY), | ||
33 | + DO_BIT(HFGRTR, CCSIDR_EL1), | ||
34 | + DO_BIT(HFGRTR, CLIDR_EL1), | ||
35 | + DO_BIT(HFGRTR, CONTEXTIDR_EL1), | ||
36 | } FGTBit; | ||
37 | |||
38 | #undef DO_BIT | ||
39 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
40 | index XXXXXXX..XXXXXXX 100644 | ||
41 | --- a/target/arm/helper.c | ||
42 | +++ b/target/arm/helper.c | ||
43 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo cp_reginfo[] = { | ||
44 | { .name = "CONTEXTIDR_EL1", .state = ARM_CP_STATE_BOTH, | ||
45 | .opc0 = 3, .opc1 = 0, .crn = 13, .crm = 0, .opc2 = 1, | ||
46 | .access = PL1_RW, .accessfn = access_tvm_trvm, | ||
47 | + .fgt = FGT_CONTEXTIDR_EL1, | ||
48 | .secure = ARM_CP_SECSTATE_NS, | ||
49 | .fieldoffset = offsetof(CPUARMState, cp15.contextidr_el[1]), | ||
50 | .resetvalue = 0, .writefn = contextidr_write, .raw_writefn = raw_write, }, | ||
51 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v7_cp_reginfo[] = { | ||
52 | .opc0 = 3, .crn = 0, .crm = 0, .opc1 = 1, .opc2 = 0, | ||
53 | .access = PL1_R, | ||
54 | .accessfn = access_tid4, | ||
55 | + .fgt = FGT_CCSIDR_EL1, | ||
56 | .readfn = ccsidr_read, .type = ARM_CP_NO_RAW }, | ||
57 | { .name = "CSSELR", .state = ARM_CP_STATE_BOTH, | ||
58 | .opc0 = 3, .crn = 0, .crm = 0, .opc1 = 2, .opc2 = 0, | ||
59 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v7_cp_reginfo[] = { | ||
60 | .opc0 = 3, .opc1 = 1, .crn = 0, .crm = 0, .opc2 = 7, | ||
61 | .access = PL1_R, .type = ARM_CP_CONST, | ||
62 | .accessfn = access_aa64_tid1, | ||
63 | + .fgt = FGT_AIDR_EL1, | ||
64 | .resetvalue = 0 }, | ||
65 | /* | ||
66 | * Auxiliary fault status registers: these also are IMPDEF, and we | ||
67 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v7_cp_reginfo[] = { | ||
68 | { .name = "AFSR0_EL1", .state = ARM_CP_STATE_BOTH, | ||
69 | .opc0 = 3, .opc1 = 0, .crn = 5, .crm = 1, .opc2 = 0, | ||
70 | .access = PL1_RW, .accessfn = access_tvm_trvm, | ||
71 | + .fgt = FGT_AFSR0_EL1, | ||
72 | .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
73 | { .name = "AFSR1_EL1", .state = ARM_CP_STATE_BOTH, | ||
74 | .opc0 = 3, .opc1 = 0, .crn = 5, .crm = 1, .opc2 = 1, | ||
75 | .access = PL1_RW, .accessfn = access_tvm_trvm, | ||
76 | + .fgt = FGT_AFSR1_EL1, | ||
77 | .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
78 | /* | ||
79 | * MAIR can just read-as-written because we don't implement caches | ||
80 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo lpae_cp_reginfo[] = { | ||
81 | { .name = "AMAIR0", .state = ARM_CP_STATE_BOTH, | ||
82 | .opc0 = 3, .crn = 10, .crm = 3, .opc1 = 0, .opc2 = 0, | ||
83 | .access = PL1_RW, .accessfn = access_tvm_trvm, | ||
84 | + .fgt = FGT_AMAIR_EL1, | ||
85 | .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
86 | /* AMAIR1 is mapped to AMAIR_EL1[63:32] */ | ||
87 | { .name = "AMAIR1", .cp = 15, .crn = 10, .crm = 3, .opc1 = 0, .opc2 = 1, | ||
88 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo pauth_reginfo[] = { | ||
89 | { .name = "APDAKEYLO_EL1", .state = ARM_CP_STATE_AA64, | ||
90 | .opc0 = 3, .opc1 = 0, .crn = 2, .crm = 2, .opc2 = 0, | ||
91 | .access = PL1_RW, .accessfn = access_pauth, | ||
92 | + .fgt = FGT_APDAKEY, | ||
93 | .fieldoffset = offsetof(CPUARMState, keys.apda.lo) }, | ||
94 | { .name = "APDAKEYHI_EL1", .state = ARM_CP_STATE_AA64, | ||
95 | .opc0 = 3, .opc1 = 0, .crn = 2, .crm = 2, .opc2 = 1, | ||
96 | .access = PL1_RW, .accessfn = access_pauth, | ||
97 | + .fgt = FGT_APDAKEY, | ||
98 | .fieldoffset = offsetof(CPUARMState, keys.apda.hi) }, | ||
99 | { .name = "APDBKEYLO_EL1", .state = ARM_CP_STATE_AA64, | ||
100 | .opc0 = 3, .opc1 = 0, .crn = 2, .crm = 2, .opc2 = 2, | ||
101 | .access = PL1_RW, .accessfn = access_pauth, | ||
102 | + .fgt = FGT_APDBKEY, | ||
103 | .fieldoffset = offsetof(CPUARMState, keys.apdb.lo) }, | ||
104 | { .name = "APDBKEYHI_EL1", .state = ARM_CP_STATE_AA64, | ||
105 | .opc0 = 3, .opc1 = 0, .crn = 2, .crm = 2, .opc2 = 3, | ||
106 | .access = PL1_RW, .accessfn = access_pauth, | ||
107 | + .fgt = FGT_APDBKEY, | ||
108 | .fieldoffset = offsetof(CPUARMState, keys.apdb.hi) }, | ||
109 | { .name = "APGAKEYLO_EL1", .state = ARM_CP_STATE_AA64, | ||
110 | .opc0 = 3, .opc1 = 0, .crn = 2, .crm = 3, .opc2 = 0, | ||
111 | .access = PL1_RW, .accessfn = access_pauth, | ||
112 | + .fgt = FGT_APGAKEY, | ||
113 | .fieldoffset = offsetof(CPUARMState, keys.apga.lo) }, | ||
114 | { .name = "APGAKEYHI_EL1", .state = ARM_CP_STATE_AA64, | ||
115 | .opc0 = 3, .opc1 = 0, .crn = 2, .crm = 3, .opc2 = 1, | ||
116 | .access = PL1_RW, .accessfn = access_pauth, | ||
117 | + .fgt = FGT_APGAKEY, | ||
118 | .fieldoffset = offsetof(CPUARMState, keys.apga.hi) }, | ||
119 | { .name = "APIAKEYLO_EL1", .state = ARM_CP_STATE_AA64, | ||
120 | .opc0 = 3, .opc1 = 0, .crn = 2, .crm = 1, .opc2 = 0, | ||
121 | .access = PL1_RW, .accessfn = access_pauth, | ||
122 | + .fgt = FGT_APIAKEY, | ||
123 | .fieldoffset = offsetof(CPUARMState, keys.apia.lo) }, | ||
124 | { .name = "APIAKEYHI_EL1", .state = ARM_CP_STATE_AA64, | ||
125 | .opc0 = 3, .opc1 = 0, .crn = 2, .crm = 1, .opc2 = 1, | ||
126 | .access = PL1_RW, .accessfn = access_pauth, | ||
127 | + .fgt = FGT_APIAKEY, | ||
128 | .fieldoffset = offsetof(CPUARMState, keys.apia.hi) }, | ||
129 | { .name = "APIBKEYLO_EL1", .state = ARM_CP_STATE_AA64, | ||
130 | .opc0 = 3, .opc1 = 0, .crn = 2, .crm = 1, .opc2 = 2, | ||
131 | .access = PL1_RW, .accessfn = access_pauth, | ||
132 | + .fgt = FGT_APIBKEY, | ||
133 | .fieldoffset = offsetof(CPUARMState, keys.apib.lo) }, | ||
134 | { .name = "APIBKEYHI_EL1", .state = ARM_CP_STATE_AA64, | ||
135 | .opc0 = 3, .opc1 = 0, .crn = 2, .crm = 1, .opc2 = 3, | ||
136 | .access = PL1_RW, .accessfn = access_pauth, | ||
137 | + .fgt = FGT_APIBKEY, | ||
138 | .fieldoffset = offsetof(CPUARMState, keys.apib.hi) }, | ||
36 | }; | 139 | }; |
37 | 140 | ||
38 | static const VMStateDescription vmstate_stm32f2xx_adc = { | 141 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) |
39 | @@ -XXX,XX +XXX,XX @@ static void stm32f2xx_adc_init(Object *obj) | 142 | .opc0 = 3, .crn = 0, .crm = 0, .opc1 = 1, .opc2 = 1, |
40 | sysbus_init_irq(SYS_BUS_DEVICE(obj), &s->irq); | 143 | .access = PL1_R, .type = ARM_CP_CONST, |
41 | 144 | .accessfn = access_tid4, | |
42 | memory_region_init_io(&s->mmio, obj, &stm32f2xx_adc_ops, s, | 145 | + .fgt = FGT_CLIDR_EL1, |
43 | - TYPE_STM32F2XX_ADC, 0xFF); | 146 | .resetvalue = cpu->clidr |
44 | + TYPE_STM32F2XX_ADC, 0x100); | 147 | }; |
45 | sysbus_init_mmio(SYS_BUS_DEVICE(obj), &s->mmio); | 148 | define_one_arm_cp_reg(cpu, &clidr); |
46 | } | ||
47 | |||
48 | -- | 149 | -- |
49 | 2.20.1 | 150 | 2.34.1 |
50 | |||
51 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Mark up the sysreg definitions for the registers trapped | ||
2 | by HFGRTR/HFGWTR bits 12..23. | ||
1 | 3 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Tested-by: Fuad Tabba <tabba@google.com> | ||
7 | Message-id: 20230130182459.3309057-12-peter.maydell@linaro.org | ||
8 | Message-id: 20230127175507.2895013-12-peter.maydell@linaro.org | ||
9 | --- | ||
10 | target/arm/cpregs.h | 12 ++++++++++++ | ||
11 | target/arm/helper.c | 12 ++++++++++++ | ||
12 | 2 files changed, 24 insertions(+) | ||
13 | |||
14 | diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/target/arm/cpregs.h | ||
17 | +++ b/target/arm/cpregs.h | ||
18 | @@ -XXX,XX +XXX,XX @@ typedef enum FGTBit { | ||
19 | DO_BIT(HFGRTR, CCSIDR_EL1), | ||
20 | DO_BIT(HFGRTR, CLIDR_EL1), | ||
21 | DO_BIT(HFGRTR, CONTEXTIDR_EL1), | ||
22 | + DO_BIT(HFGRTR, CPACR_EL1), | ||
23 | + DO_BIT(HFGRTR, CSSELR_EL1), | ||
24 | + DO_BIT(HFGRTR, CTR_EL0), | ||
25 | + DO_BIT(HFGRTR, DCZID_EL0), | ||
26 | + DO_BIT(HFGRTR, ESR_EL1), | ||
27 | + DO_BIT(HFGRTR, FAR_EL1), | ||
28 | + DO_BIT(HFGRTR, ISR_EL1), | ||
29 | + DO_BIT(HFGRTR, LORC_EL1), | ||
30 | + DO_BIT(HFGRTR, LOREA_EL1), | ||
31 | + DO_BIT(HFGRTR, LORID_EL1), | ||
32 | + DO_BIT(HFGRTR, LORN_EL1), | ||
33 | + DO_BIT(HFGRTR, LORSA_EL1), | ||
34 | } FGTBit; | ||
35 | |||
36 | #undef DO_BIT | ||
37 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
38 | index XXXXXXX..XXXXXXX 100644 | ||
39 | --- a/target/arm/helper.c | ||
40 | +++ b/target/arm/helper.c | ||
41 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v6_cp_reginfo[] = { | ||
42 | .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0, }, | ||
43 | { .name = "CPACR", .state = ARM_CP_STATE_BOTH, .opc0 = 3, | ||
44 | .crn = 1, .crm = 0, .opc1 = 0, .opc2 = 2, .accessfn = cpacr_access, | ||
45 | + .fgt = FGT_CPACR_EL1, | ||
46 | .access = PL1_RW, .fieldoffset = offsetof(CPUARMState, cp15.cpacr_el1), | ||
47 | .resetfn = cpacr_reset, .writefn = cpacr_write, .readfn = cpacr_read }, | ||
48 | }; | ||
49 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v7_cp_reginfo[] = { | ||
50 | .opc0 = 3, .crn = 0, .crm = 0, .opc1 = 2, .opc2 = 0, | ||
51 | .access = PL1_RW, | ||
52 | .accessfn = access_tid4, | ||
53 | + .fgt = FGT_CSSELR_EL1, | ||
54 | .writefn = csselr_write, .resetvalue = 0, | ||
55 | .bank_fieldoffsets = { offsetof(CPUARMState, cp15.csselr_s), | ||
56 | offsetof(CPUARMState, cp15.csselr_ns) } }, | ||
57 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v7_cp_reginfo[] = { | ||
58 | .resetfn = arm_cp_reset_ignore }, | ||
59 | { .name = "ISR_EL1", .state = ARM_CP_STATE_BOTH, | ||
60 | .opc0 = 3, .opc1 = 0, .crn = 12, .crm = 1, .opc2 = 0, | ||
61 | + .fgt = FGT_ISR_EL1, | ||
62 | .type = ARM_CP_NO_RAW, .access = PL1_R, .readfn = isr_read }, | ||
63 | /* 32 bit ITLB invalidates */ | ||
64 | { .name = "ITLBIALL", .cp = 15, .opc1 = 0, .crn = 8, .crm = 5, .opc2 = 0, | ||
65 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo vmsa_pmsa_cp_reginfo[] = { | ||
66 | { .name = "FAR_EL1", .state = ARM_CP_STATE_AA64, | ||
67 | .opc0 = 3, .crn = 6, .crm = 0, .opc1 = 0, .opc2 = 0, | ||
68 | .access = PL1_RW, .accessfn = access_tvm_trvm, | ||
69 | + .fgt = FGT_FAR_EL1, | ||
70 | .fieldoffset = offsetof(CPUARMState, cp15.far_el[1]), | ||
71 | .resetvalue = 0, }, | ||
72 | }; | ||
73 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo vmsa_cp_reginfo[] = { | ||
74 | { .name = "ESR_EL1", .state = ARM_CP_STATE_AA64, | ||
75 | .opc0 = 3, .crn = 5, .crm = 2, .opc1 = 0, .opc2 = 0, | ||
76 | .access = PL1_RW, .accessfn = access_tvm_trvm, | ||
77 | + .fgt = FGT_ESR_EL1, | ||
78 | .fieldoffset = offsetof(CPUARMState, cp15.esr_el[1]), .resetvalue = 0, }, | ||
79 | { .name = "TTBR0_EL1", .state = ARM_CP_STATE_BOTH, | ||
80 | .opc0 = 3, .opc1 = 0, .crn = 2, .crm = 0, .opc2 = 0, | ||
81 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v8_cp_reginfo[] = { | ||
82 | { .name = "DCZID_EL0", .state = ARM_CP_STATE_AA64, | ||
83 | .opc0 = 3, .opc1 = 3, .opc2 = 7, .crn = 0, .crm = 0, | ||
84 | .access = PL0_R, .type = ARM_CP_NO_RAW, | ||
85 | + .fgt = FGT_DCZID_EL0, | ||
86 | .readfn = aa64_dczid_read }, | ||
87 | { .name = "DC_ZVA", .state = ARM_CP_STATE_AA64, | ||
88 | .opc0 = 1, .opc1 = 3, .crn = 7, .crm = 4, .opc2 = 1, | ||
89 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo lor_reginfo[] = { | ||
90 | { .name = "LORSA_EL1", .state = ARM_CP_STATE_AA64, | ||
91 | .opc0 = 3, .opc1 = 0, .crn = 10, .crm = 4, .opc2 = 0, | ||
92 | .access = PL1_RW, .accessfn = access_lor_other, | ||
93 | + .fgt = FGT_LORSA_EL1, | ||
94 | .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
95 | { .name = "LOREA_EL1", .state = ARM_CP_STATE_AA64, | ||
96 | .opc0 = 3, .opc1 = 0, .crn = 10, .crm = 4, .opc2 = 1, | ||
97 | .access = PL1_RW, .accessfn = access_lor_other, | ||
98 | + .fgt = FGT_LOREA_EL1, | ||
99 | .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
100 | { .name = "LORN_EL1", .state = ARM_CP_STATE_AA64, | ||
101 | .opc0 = 3, .opc1 = 0, .crn = 10, .crm = 4, .opc2 = 2, | ||
102 | .access = PL1_RW, .accessfn = access_lor_other, | ||
103 | + .fgt = FGT_LORN_EL1, | ||
104 | .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
105 | { .name = "LORC_EL1", .state = ARM_CP_STATE_AA64, | ||
106 | .opc0 = 3, .opc1 = 0, .crn = 10, .crm = 4, .opc2 = 3, | ||
107 | .access = PL1_RW, .accessfn = access_lor_other, | ||
108 | + .fgt = FGT_LORC_EL1, | ||
109 | .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
110 | { .name = "LORID_EL1", .state = ARM_CP_STATE_AA64, | ||
111 | .opc0 = 3, .opc1 = 0, .crn = 10, .crm = 4, .opc2 = 7, | ||
112 | .access = PL1_R, .accessfn = access_lor_ns, | ||
113 | + .fgt = FGT_LORID_EL1, | ||
114 | .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
115 | }; | ||
116 | |||
117 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
118 | { .name = "CTR_EL0", .state = ARM_CP_STATE_AA64, | ||
119 | .opc0 = 3, .opc1 = 3, .opc2 = 1, .crn = 0, .crm = 0, | ||
120 | .access = PL0_R, .accessfn = ctr_el0_access, | ||
121 | + .fgt = FGT_CTR_EL0, | ||
122 | .type = ARM_CP_CONST, .resetvalue = cpu->ctr }, | ||
123 | /* TCMTR and TLBTR exist in v8 but have no 64-bit versions */ | ||
124 | { .name = "TCMTR", | ||
125 | -- | ||
126 | 2.34.1 | diff view generated by jsdifflib |
1 | Convert the remaining Neon narrowing shifts to decodetree: | 1 | Mark up the sysreg definitions for the registers trapped |
---|---|---|---|
2 | * VQSHRN | 2 | by HFGRTR/HFGWTR bits 24..35. |
3 | * VQRSHRN | ||
4 | 3 | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
7 | Message-id: 20200522145520.6778-7-peter.maydell@linaro.org | 6 | Tested-by: Fuad Tabba <tabba@google.com> |
7 | Message-id: 20230130182459.3309057-13-peter.maydell@linaro.org | ||
8 | Message-id: 20230127175507.2895013-13-peter.maydell@linaro.org | ||
8 | --- | 9 | --- |
9 | target/arm/neon-dp.decode | 20 ++++++ | 10 | target/arm/cpregs.h | 12 ++++++++++++ |
10 | target/arm/translate-neon.inc.c | 15 +++++ | 11 | target/arm/helper.c | 14 ++++++++++++++ |
11 | target/arm/translate.c | 110 +------------------------------- | 12 | 2 files changed, 26 insertions(+) |
12 | 3 files changed, 37 insertions(+), 108 deletions(-) | ||
13 | 13 | ||
14 | diff --git a/target/arm/neon-dp.decode b/target/arm/neon-dp.decode | 14 | diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h |
15 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/neon-dp.decode | 16 | --- a/target/arm/cpregs.h |
17 | +++ b/target/arm/neon-dp.decode | 17 | +++ b/target/arm/cpregs.h |
18 | @@ -XXX,XX +XXX,XX @@ VQSHRUN_16_2sh 1111 001 1 1 . ...... .... 1000 . 0 . 1 .... @2reg_shrn_h | 18 | @@ -XXX,XX +XXX,XX @@ typedef enum FGTBit { |
19 | VQRSHRUN_64_2sh 1111 001 1 1 . ...... .... 1000 . 1 . 1 .... @2reg_shrn_d | 19 | DO_BIT(HFGRTR, LORID_EL1), |
20 | VQRSHRUN_32_2sh 1111 001 1 1 . ...... .... 1000 . 1 . 1 .... @2reg_shrn_s | 20 | DO_BIT(HFGRTR, LORN_EL1), |
21 | VQRSHRUN_16_2sh 1111 001 1 1 . ...... .... 1000 . 1 . 1 .... @2reg_shrn_h | 21 | DO_BIT(HFGRTR, LORSA_EL1), |
22 | + | 22 | + DO_BIT(HFGRTR, MAIR_EL1), |
23 | +# VQSHRN with signed input | 23 | + DO_BIT(HFGRTR, MIDR_EL1), |
24 | +VQSHRN_S64_2sh 1111 001 0 1 . ...... .... 1001 . 0 . 1 .... @2reg_shrn_d | 24 | + DO_BIT(HFGRTR, MPIDR_EL1), |
25 | +VQSHRN_S32_2sh 1111 001 0 1 . ...... .... 1001 . 0 . 1 .... @2reg_shrn_s | 25 | + DO_BIT(HFGRTR, PAR_EL1), |
26 | +VQSHRN_S16_2sh 1111 001 0 1 . ...... .... 1001 . 0 . 1 .... @2reg_shrn_h | 26 | + DO_BIT(HFGRTR, REVIDR_EL1), |
27 | + | 27 | + DO_BIT(HFGRTR, SCTLR_EL1), |
28 | +# VQRSHRN with signed input | 28 | + DO_BIT(HFGRTR, SCXTNUM_EL1), |
29 | +VQRSHRN_S64_2sh 1111 001 0 1 . ...... .... 1001 . 1 . 1 .... @2reg_shrn_d | 29 | + DO_BIT(HFGRTR, SCXTNUM_EL0), |
30 | +VQRSHRN_S32_2sh 1111 001 0 1 . ...... .... 1001 . 1 . 1 .... @2reg_shrn_s | 30 | + DO_BIT(HFGRTR, TCR_EL1), |
31 | +VQRSHRN_S16_2sh 1111 001 0 1 . ...... .... 1001 . 1 . 1 .... @2reg_shrn_h | 31 | + DO_BIT(HFGRTR, TPIDR_EL1), |
32 | + | 32 | + DO_BIT(HFGRTR, TPIDRRO_EL0), |
33 | +# VQSHRN with unsigned input | 33 | + DO_BIT(HFGRTR, TPIDR_EL0), |
34 | +VQSHRN_U64_2sh 1111 001 1 1 . ...... .... 1001 . 0 . 1 .... @2reg_shrn_d | 34 | } FGTBit; |
35 | +VQSHRN_U32_2sh 1111 001 1 1 . ...... .... 1001 . 0 . 1 .... @2reg_shrn_s | 35 | |
36 | +VQSHRN_U16_2sh 1111 001 1 1 . ...... .... 1001 . 0 . 1 .... @2reg_shrn_h | 36 | #undef DO_BIT |
37 | + | 37 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
38 | +# VQRSHRN with unsigned input | ||
39 | +VQRSHRN_U64_2sh 1111 001 1 1 . ...... .... 1001 . 1 . 1 .... @2reg_shrn_d | ||
40 | +VQRSHRN_U32_2sh 1111 001 1 1 . ...... .... 1001 . 1 . 1 .... @2reg_shrn_s | ||
41 | +VQRSHRN_U16_2sh 1111 001 1 1 . ...... .... 1001 . 1 . 1 .... @2reg_shrn_h | ||
42 | diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c | ||
43 | index XXXXXXX..XXXXXXX 100644 | 38 | index XXXXXXX..XXXXXXX 100644 |
44 | --- a/target/arm/translate-neon.inc.c | 39 | --- a/target/arm/helper.c |
45 | +++ b/target/arm/translate-neon.inc.c | 40 | +++ b/target/arm/helper.c |
46 | @@ -XXX,XX +XXX,XX @@ DO_2SN_32(VQSHRUN_16, gen_helper_neon_shl_s16, gen_helper_neon_unarrow_sat8) | 41 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v7_cp_reginfo[] = { |
47 | DO_2SN_64(VQRSHRUN_64, gen_helper_neon_rshl_s64, gen_helper_neon_unarrow_sat32) | 42 | { .name = "MAIR_EL1", .state = ARM_CP_STATE_AA64, |
48 | DO_2SN_32(VQRSHRUN_32, gen_helper_neon_rshl_s32, gen_helper_neon_unarrow_sat16) | 43 | .opc0 = 3, .opc1 = 0, .crn = 10, .crm = 2, .opc2 = 0, |
49 | DO_2SN_32(VQRSHRUN_16, gen_helper_neon_rshl_s16, gen_helper_neon_unarrow_sat8) | 44 | .access = PL1_RW, .accessfn = access_tvm_trvm, |
50 | +DO_2SN_64(VQSHRN_S64, gen_sshl_i64, gen_helper_neon_narrow_sat_s32) | 45 | + .fgt = FGT_MAIR_EL1, |
51 | +DO_2SN_32(VQSHRN_S32, gen_sshl_i32, gen_helper_neon_narrow_sat_s16) | 46 | .fieldoffset = offsetof(CPUARMState, cp15.mair_el[1]), |
52 | +DO_2SN_32(VQSHRN_S16, gen_helper_neon_shl_s16, gen_helper_neon_narrow_sat_s8) | 47 | .resetvalue = 0 }, |
53 | + | 48 | { .name = "MAIR_EL3", .state = ARM_CP_STATE_AA64, |
54 | +DO_2SN_64(VQRSHRN_S64, gen_helper_neon_rshl_s64, gen_helper_neon_narrow_sat_s32) | 49 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v6k_cp_reginfo[] = { |
55 | +DO_2SN_32(VQRSHRN_S32, gen_helper_neon_rshl_s32, gen_helper_neon_narrow_sat_s16) | 50 | { .name = "TPIDR_EL0", .state = ARM_CP_STATE_AA64, |
56 | +DO_2SN_32(VQRSHRN_S16, gen_helper_neon_rshl_s16, gen_helper_neon_narrow_sat_s8) | 51 | .opc0 = 3, .opc1 = 3, .opc2 = 2, .crn = 13, .crm = 0, |
57 | + | 52 | .access = PL0_RW, |
58 | +DO_2SN_64(VQSHRN_U64, gen_ushl_i64, gen_helper_neon_narrow_sat_u32) | 53 | + .fgt = FGT_TPIDR_EL0, |
59 | +DO_2SN_32(VQSHRN_U32, gen_ushl_i32, gen_helper_neon_narrow_sat_u16) | 54 | .fieldoffset = offsetof(CPUARMState, cp15.tpidr_el[0]), .resetvalue = 0 }, |
60 | +DO_2SN_32(VQSHRN_U16, gen_helper_neon_shl_u16, gen_helper_neon_narrow_sat_u8) | 55 | { .name = "TPIDRURW", .cp = 15, .crn = 13, .crm = 0, .opc1 = 0, .opc2 = 2, |
61 | + | 56 | .access = PL0_RW, |
62 | +DO_2SN_64(VQRSHRN_U64, gen_helper_neon_rshl_u64, gen_helper_neon_narrow_sat_u32) | 57 | + .fgt = FGT_TPIDR_EL0, |
63 | +DO_2SN_32(VQRSHRN_U32, gen_helper_neon_rshl_u32, gen_helper_neon_narrow_sat_u16) | 58 | .bank_fieldoffsets = { offsetoflow32(CPUARMState, cp15.tpidrurw_s), |
64 | +DO_2SN_32(VQRSHRN_U16, gen_helper_neon_rshl_u16, gen_helper_neon_narrow_sat_u8) | 59 | offsetoflow32(CPUARMState, cp15.tpidrurw_ns) }, |
65 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 60 | .resetfn = arm_cp_reset_ignore }, |
66 | index XXXXXXX..XXXXXXX 100644 | 61 | { .name = "TPIDRRO_EL0", .state = ARM_CP_STATE_AA64, |
67 | --- a/target/arm/translate.c | 62 | .opc0 = 3, .opc1 = 3, .opc2 = 3, .crn = 13, .crm = 0, |
68 | +++ b/target/arm/translate.c | 63 | .access = PL0_R | PL1_W, |
69 | @@ -XXX,XX +XXX,XX @@ static inline void gen_neon_unarrow_sats(int size, TCGv_i32 dest, TCGv_i64 src) | 64 | + .fgt = FGT_TPIDRRO_EL0, |
70 | } | 65 | .fieldoffset = offsetof(CPUARMState, cp15.tpidrro_el[0]), |
71 | } | 66 | .resetvalue = 0}, |
72 | 67 | { .name = "TPIDRURO", .cp = 15, .crn = 13, .crm = 0, .opc1 = 0, .opc2 = 3, | |
73 | -static inline void gen_neon_shift_narrow(int size, TCGv_i32 var, TCGv_i32 shift, | 68 | .access = PL0_R | PL1_W, |
74 | - int q, int u) | 69 | + .fgt = FGT_TPIDRRO_EL0, |
75 | -{ | 70 | .bank_fieldoffsets = { offsetoflow32(CPUARMState, cp15.tpidruro_s), |
76 | - if (q) { | 71 | offsetoflow32(CPUARMState, cp15.tpidruro_ns) }, |
77 | - if (u) { | 72 | .resetfn = arm_cp_reset_ignore }, |
78 | - switch (size) { | 73 | { .name = "TPIDR_EL1", .state = ARM_CP_STATE_AA64, |
79 | - case 1: gen_helper_neon_rshl_u16(var, var, shift); break; | 74 | .opc0 = 3, .opc1 = 0, .opc2 = 4, .crn = 13, .crm = 0, |
80 | - case 2: gen_helper_neon_rshl_u32(var, var, shift); break; | 75 | .access = PL1_RW, |
81 | - default: abort(); | 76 | + .fgt = FGT_TPIDR_EL1, |
82 | - } | 77 | .fieldoffset = offsetof(CPUARMState, cp15.tpidr_el[1]), .resetvalue = 0 }, |
83 | - } else { | 78 | { .name = "TPIDRPRW", .opc1 = 0, .cp = 15, .crn = 13, .crm = 0, .opc2 = 4, |
84 | - switch (size) { | 79 | .access = PL1_RW, |
85 | - case 1: gen_helper_neon_rshl_s16(var, var, shift); break; | 80 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo vmsa_cp_reginfo[] = { |
86 | - case 2: gen_helper_neon_rshl_s32(var, var, shift); break; | 81 | { .name = "TCR_EL1", .state = ARM_CP_STATE_AA64, |
87 | - default: abort(); | 82 | .opc0 = 3, .crn = 2, .crm = 0, .opc1 = 0, .opc2 = 2, |
88 | - } | 83 | .access = PL1_RW, .accessfn = access_tvm_trvm, |
89 | - } | 84 | + .fgt = FGT_TCR_EL1, |
90 | - } else { | 85 | .writefn = vmsa_tcr_el12_write, |
91 | - if (u) { | 86 | .raw_writefn = raw_write, |
92 | - switch (size) { | 87 | .resetvalue = 0, |
93 | - case 1: gen_helper_neon_shl_u16(var, var, shift); break; | 88 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v8_cp_reginfo[] = { |
94 | - case 2: gen_ushl_i32(var, var, shift); break; | 89 | .type = ARM_CP_ALIAS, |
95 | - default: abort(); | 90 | .opc0 = 3, .opc1 = 0, .crn = 7, .crm = 4, .opc2 = 0, |
96 | - } | 91 | .access = PL1_RW, .resetvalue = 0, |
97 | - } else { | 92 | + .fgt = FGT_PAR_EL1, |
98 | - switch (size) { | 93 | .fieldoffset = offsetof(CPUARMState, cp15.par_el[1]), |
99 | - case 1: gen_helper_neon_shl_s16(var, var, shift); break; | 94 | .writefn = par_write }, |
100 | - case 2: gen_sshl_i32(var, var, shift); break; | 95 | #endif |
101 | - default: abort(); | 96 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo scxtnum_reginfo[] = { |
102 | - } | 97 | { .name = "SCXTNUM_EL0", .state = ARM_CP_STATE_AA64, |
103 | - } | 98 | .opc0 = 3, .opc1 = 3, .crn = 13, .crm = 0, .opc2 = 7, |
104 | - } | 99 | .access = PL0_RW, .accessfn = access_scxtnum, |
105 | -} | 100 | + .fgt = FGT_SCXTNUM_EL0, |
106 | - | 101 | .fieldoffset = offsetof(CPUARMState, scxtnum_el[0]) }, |
107 | static inline void gen_neon_widen(TCGv_i64 dest, TCGv_i32 src, int size, int u) | 102 | { .name = "SCXTNUM_EL1", .state = ARM_CP_STATE_AA64, |
108 | { | 103 | .opc0 = 3, .opc1 = 0, .crn = 13, .crm = 0, .opc2 = 7, |
109 | if (u) { | 104 | .access = PL1_RW, .accessfn = access_scxtnum, |
110 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | 105 | + .fgt = FGT_SCXTNUM_EL1, |
111 | case 6: /* VQSHLU */ | 106 | .fieldoffset = offsetof(CPUARMState, scxtnum_el[1]) }, |
112 | case 7: /* VQSHL */ | 107 | { .name = "SCXTNUM_EL2", .state = ARM_CP_STATE_AA64, |
113 | case 8: /* VSHRN, VRSHRN, VQSHRUN, VQRSHRUN */ | 108 | .opc0 = 3, .opc1 = 4, .crn = 13, .crm = 0, .opc2 = 7, |
114 | + case 9: /* VQSHRN, VQRSHRN */ | 109 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) |
115 | return 1; /* handled by decodetree */ | 110 | { .name = "MIDR_EL1", .state = ARM_CP_STATE_BOTH, |
116 | default: | 111 | .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 0, .opc2 = 0, |
117 | break; | 112 | .access = PL1_R, .type = ARM_CP_NO_RAW, .resetvalue = cpu->midr, |
118 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | 113 | + .fgt = FGT_MIDR_EL1, |
119 | size--; | 114 | .fieldoffset = offsetof(CPUARMState, cp15.c0_cpuid), |
120 | } | 115 | .readfn = midr_read }, |
121 | shift = (insn >> 16) & ((1 << (3 + size)) - 1); | 116 | /* crn = 0 op1 = 0 crm = 0 op2 = 7 : AArch32 aliases of MIDR */ |
122 | - if (op < 10) { | 117 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) |
123 | - /* Shift by immediate and narrow: | 118 | .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 0, .opc2 = 6, |
124 | - VSHRN, VRSHRN, VQSHRN, VQRSHRN. */ | 119 | .access = PL1_R, |
125 | - int input_unsigned = (op == 8) ? !u : u; | 120 | .accessfn = access_aa64_tid1, |
126 | - if (rm & 1) { | 121 | + .fgt = FGT_REVIDR_EL1, |
127 | - return 1; | 122 | .type = ARM_CP_CONST, .resetvalue = cpu->revidr }, |
128 | - } | 123 | }; |
129 | - shift = shift - (1 << (size + 3)); | 124 | ARMCPRegInfo id_v8_midr_alias_cp_reginfo = { |
130 | - size++; | 125 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) |
131 | - if (size == 3) { | 126 | ARMCPRegInfo mpidr_cp_reginfo[] = { |
132 | - tmp64 = tcg_const_i64(shift); | 127 | { .name = "MPIDR_EL1", .state = ARM_CP_STATE_BOTH, |
133 | - neon_load_reg64(cpu_V0, rm); | 128 | .opc0 = 3, .crn = 0, .crm = 0, .opc1 = 0, .opc2 = 5, |
134 | - neon_load_reg64(cpu_V1, rm + 1); | 129 | + .fgt = FGT_MPIDR_EL1, |
135 | - for (pass = 0; pass < 2; pass++) { | 130 | .access = PL1_R, .readfn = mpidr_read, .type = ARM_CP_NO_RAW }, |
136 | - TCGv_i64 in; | 131 | }; |
137 | - if (pass == 0) { | 132 | #ifdef CONFIG_USER_ONLY |
138 | - in = cpu_V0; | 133 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) |
139 | - } else { | 134 | .name = "SCTLR", .state = ARM_CP_STATE_BOTH, |
140 | - in = cpu_V1; | 135 | .opc0 = 3, .opc1 = 0, .crn = 1, .crm = 0, .opc2 = 0, |
141 | - } | 136 | .access = PL1_RW, .accessfn = access_tvm_trvm, |
142 | - if (q) { | 137 | + .fgt = FGT_SCTLR_EL1, |
143 | - if (input_unsigned) { | 138 | .bank_fieldoffsets = { offsetof(CPUARMState, cp15.sctlr_s), |
144 | - gen_helper_neon_rshl_u64(cpu_V0, in, tmp64); | 139 | offsetof(CPUARMState, cp15.sctlr_ns) }, |
145 | - } else { | 140 | .writefn = sctlr_write, .resetvalue = cpu->reset_sctlr, |
146 | - gen_helper_neon_rshl_s64(cpu_V0, in, tmp64); | ||
147 | - } | ||
148 | - } else { | ||
149 | - if (input_unsigned) { | ||
150 | - gen_ushl_i64(cpu_V0, in, tmp64); | ||
151 | - } else { | ||
152 | - gen_sshl_i64(cpu_V0, in, tmp64); | ||
153 | - } | ||
154 | - } | ||
155 | - tmp = tcg_temp_new_i32(); | ||
156 | - gen_neon_narrow_op(op == 8, u, size - 1, tmp, cpu_V0); | ||
157 | - neon_store_reg(rd, pass, tmp); | ||
158 | - } /* for pass */ | ||
159 | - tcg_temp_free_i64(tmp64); | ||
160 | - } else { | ||
161 | - if (size == 1) { | ||
162 | - imm = (uint16_t)shift; | ||
163 | - imm |= imm << 16; | ||
164 | - } else { | ||
165 | - /* size == 2 */ | ||
166 | - imm = (uint32_t)shift; | ||
167 | - } | ||
168 | - tmp2 = tcg_const_i32(imm); | ||
169 | - tmp4 = neon_load_reg(rm + 1, 0); | ||
170 | - tmp5 = neon_load_reg(rm + 1, 1); | ||
171 | - for (pass = 0; pass < 2; pass++) { | ||
172 | - if (pass == 0) { | ||
173 | - tmp = neon_load_reg(rm, 0); | ||
174 | - } else { | ||
175 | - tmp = tmp4; | ||
176 | - } | ||
177 | - gen_neon_shift_narrow(size, tmp, tmp2, q, | ||
178 | - input_unsigned); | ||
179 | - if (pass == 0) { | ||
180 | - tmp3 = neon_load_reg(rm, 1); | ||
181 | - } else { | ||
182 | - tmp3 = tmp5; | ||
183 | - } | ||
184 | - gen_neon_shift_narrow(size, tmp3, tmp2, q, | ||
185 | - input_unsigned); | ||
186 | - tcg_gen_concat_i32_i64(cpu_V0, tmp, tmp3); | ||
187 | - tcg_temp_free_i32(tmp); | ||
188 | - tcg_temp_free_i32(tmp3); | ||
189 | - tmp = tcg_temp_new_i32(); | ||
190 | - gen_neon_narrow_op(op == 8, u, size - 1, tmp, cpu_V0); | ||
191 | - neon_store_reg(rd, pass, tmp); | ||
192 | - } /* for pass */ | ||
193 | - tcg_temp_free_i32(tmp2); | ||
194 | - } | ||
195 | - } else if (op == 10) { | ||
196 | + if (op == 10) { | ||
197 | /* VSHLL, VMOVL */ | ||
198 | if (q || (rd & 1)) { | ||
199 | return 1; | ||
200 | -- | 141 | -- |
201 | 2.20.1 | 142 | 2.34.1 |
202 | |||
203 | diff view generated by jsdifflib |
1 | From: Paul Zimmerman <pauldzim@gmail.com> | 1 | Mark up the sysreg definitions for the registers trapped |
---|---|---|---|
2 | by HFGRTR/HFGWTR bits 36..63. | ||
2 | 3 | ||
3 | Import the dwc-hsotg (dwc2) register definitions file from the | 4 | Of these, some correspond to RAS registers which we implement as |
4 | Linux kernel. This is a copy of drivers/usb/dwc2/hw.h from the | 5 | always-UNDEF: these don't need any extra handling for FGT because the |
5 | mainline Linux kernel, the only changes being to the header, and | 6 | UNDEF-to-EL1 always takes priority over any theoretical |
6 | two instances of 'u32' changed to 'uint32_t' to allow it to | 7 | FGT-trap-to-EL2. |
7 | compile. Checkpatch throws a boatload of errors due to the tab | ||
8 | indentation, but I would rather import it as-is than reformat it. | ||
9 | 8 | ||
10 | Signed-off-by: Paul Zimmerman <pauldzim@gmail.com> | 9 | Bit 50 (NACCDATA_EL1) is for the ACCDATA_EL1 register which is part |
11 | Message-id: 20200520235349.21215-3-pauldzim@gmail.com | 10 | of the FEAT_LS64_ACCDATA feature which we don't yet implement. |
12 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 11 | |
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
14 | Tested-by: Fuad Tabba <tabba@google.com> | ||
15 | Message-id: 20230130182459.3309057-14-peter.maydell@linaro.org | ||
16 | Message-id: 20230127175507.2895013-14-peter.maydell@linaro.org | ||
14 | --- | 17 | --- |
15 | include/hw/usb/dwc2-regs.h | 899 +++++++++++++++++++++++++++++++++++++ | 18 | target/arm/cpregs.h | 7 +++++++ |
16 | 1 file changed, 899 insertions(+) | 19 | hw/intc/arm_gicv3_cpuif.c | 2 ++ |
17 | create mode 100644 include/hw/usb/dwc2-regs.h | 20 | target/arm/helper.c | 10 ++++++++++ |
21 | 3 files changed, 19 insertions(+) | ||
18 | 22 | ||
19 | diff --git a/include/hw/usb/dwc2-regs.h b/include/hw/usb/dwc2-regs.h | 23 | diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h |
20 | new file mode 100644 | 24 | index XXXXXXX..XXXXXXX 100644 |
21 | index XXXXXXX..XXXXXXX | 25 | --- a/target/arm/cpregs.h |
22 | --- /dev/null | 26 | +++ b/target/arm/cpregs.h |
23 | +++ b/include/hw/usb/dwc2-regs.h | 27 | @@ -XXX,XX +XXX,XX @@ typedef enum FGTBit { |
24 | @@ -XXX,XX +XXX,XX @@ | 28 | DO_BIT(HFGRTR, TPIDR_EL1), |
25 | +/* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */ | 29 | DO_BIT(HFGRTR, TPIDRRO_EL0), |
26 | +/* | 30 | DO_BIT(HFGRTR, TPIDR_EL0), |
27 | + * Imported from the Linux kernel file drivers/usb/dwc2/hw.h, commit | 31 | + DO_BIT(HFGRTR, TTBR0_EL1), |
28 | + * a89bae709b3492b478480a2c9734e7e9393b279c ("usb: dwc2: Move | 32 | + DO_BIT(HFGRTR, TTBR1_EL1), |
29 | + * UTMI_PHY_DATA defines closer") | 33 | + DO_BIT(HFGRTR, VBAR_EL1), |
34 | + DO_BIT(HFGRTR, ICC_IGRPENN_EL1), | ||
35 | + DO_BIT(HFGRTR, ERRIDR_EL1), | ||
36 | + DO_REV_BIT(HFGRTR, NSMPRI_EL1), | ||
37 | + DO_REV_BIT(HFGRTR, NTPIDR2_EL0), | ||
38 | } FGTBit; | ||
39 | |||
40 | #undef DO_BIT | ||
41 | diff --git a/hw/intc/arm_gicv3_cpuif.c b/hw/intc/arm_gicv3_cpuif.c | ||
42 | index XXXXXXX..XXXXXXX 100644 | ||
43 | --- a/hw/intc/arm_gicv3_cpuif.c | ||
44 | +++ b/hw/intc/arm_gicv3_cpuif.c | ||
45 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo gicv3_cpuif_reginfo[] = { | ||
46 | .opc0 = 3, .opc1 = 0, .crn = 12, .crm = 12, .opc2 = 6, | ||
47 | .type = ARM_CP_IO | ARM_CP_NO_RAW, | ||
48 | .access = PL1_RW, .accessfn = gicv3_fiq_access, | ||
49 | + .fgt = FGT_ICC_IGRPENN_EL1, | ||
50 | .readfn = icc_igrpen_read, | ||
51 | .writefn = icc_igrpen_write, | ||
52 | }, | ||
53 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo gicv3_cpuif_reginfo[] = { | ||
54 | .opc0 = 3, .opc1 = 0, .crn = 12, .crm = 12, .opc2 = 7, | ||
55 | .type = ARM_CP_IO | ARM_CP_NO_RAW, | ||
56 | .access = PL1_RW, .accessfn = gicv3_irq_access, | ||
57 | + .fgt = FGT_ICC_IGRPENN_EL1, | ||
58 | .readfn = icc_igrpen_read, | ||
59 | .writefn = icc_igrpen_write, | ||
60 | }, | ||
61 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
62 | index XXXXXXX..XXXXXXX 100644 | ||
63 | --- a/target/arm/helper.c | ||
64 | +++ b/target/arm/helper.c | ||
65 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo vmsa_cp_reginfo[] = { | ||
66 | { .name = "TTBR0_EL1", .state = ARM_CP_STATE_BOTH, | ||
67 | .opc0 = 3, .opc1 = 0, .crn = 2, .crm = 0, .opc2 = 0, | ||
68 | .access = PL1_RW, .accessfn = access_tvm_trvm, | ||
69 | + .fgt = FGT_TTBR0_EL1, | ||
70 | .writefn = vmsa_ttbr_write, .resetvalue = 0, | ||
71 | .bank_fieldoffsets = { offsetof(CPUARMState, cp15.ttbr0_s), | ||
72 | offsetof(CPUARMState, cp15.ttbr0_ns) } }, | ||
73 | { .name = "TTBR1_EL1", .state = ARM_CP_STATE_BOTH, | ||
74 | .opc0 = 3, .opc1 = 0, .crn = 2, .crm = 0, .opc2 = 1, | ||
75 | .access = PL1_RW, .accessfn = access_tvm_trvm, | ||
76 | + .fgt = FGT_TTBR1_EL1, | ||
77 | .writefn = vmsa_ttbr_write, .resetvalue = 0, | ||
78 | .bank_fieldoffsets = { offsetof(CPUARMState, cp15.ttbr1_s), | ||
79 | offsetof(CPUARMState, cp15.ttbr1_ns) } }, | ||
80 | @@ -XXX,XX +XXX,XX @@ static void disr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t val) | ||
81 | * ERRSELR_EL1 | ||
82 | * may generate UNDEFINED, which is the effect we get by not | ||
83 | * listing them at all. | ||
30 | + * | 84 | + * |
31 | + * hw.h - DesignWare HS OTG Controller hardware definitions | 85 | + * These registers have fine-grained trap bits, but UNDEF-to-EL1 |
32 | + * | 86 | + * is higher priority than FGT-to-EL2 so we do not need to list them |
33 | + * Copyright 2004-2013 Synopsys, Inc. | 87 | + * in order to check for an FGT. |
34 | + * | 88 | */ |
35 | + * Redistribution and use in source and binary forms, with or without | 89 | static const ARMCPRegInfo minimal_ras_reginfo[] = { |
36 | + * modification, are permitted provided that the following conditions | 90 | { .name = "DISR_EL1", .state = ARM_CP_STATE_BOTH, |
37 | + * are met: | 91 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo minimal_ras_reginfo[] = { |
38 | + * 1. Redistributions of source code must retain the above copyright | 92 | { .name = "ERRIDR_EL1", .state = ARM_CP_STATE_BOTH, |
39 | + * notice, this list of conditions, and the following disclaimer, | 93 | .opc0 = 3, .opc1 = 0, .crn = 5, .crm = 3, .opc2 = 0, |
40 | + * without modification. | 94 | .access = PL1_R, .accessfn = access_terr, |
41 | + * 2. Redistributions in binary form must reproduce the above copyright | 95 | + .fgt = FGT_ERRIDR_EL1, |
42 | + * notice, this list of conditions and the following disclaimer in the | 96 | .type = ARM_CP_CONST, .resetvalue = 0 }, |
43 | + * documentation and/or other materials provided with the distribution. | 97 | { .name = "VDISR_EL2", .state = ARM_CP_STATE_BOTH, |
44 | + * 3. The names of the above-listed copyright holders may not be used | 98 | .opc0 = 3, .opc1 = 4, .crn = 12, .crm = 1, .opc2 = 1, |
45 | + * to endorse or promote products derived from this software without | 99 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo sme_reginfo[] = { |
46 | + * specific prior written permission. | 100 | { .name = "TPIDR2_EL0", .state = ARM_CP_STATE_AA64, |
47 | + * | 101 | .opc0 = 3, .opc1 = 3, .crn = 13, .crm = 0, .opc2 = 5, |
48 | + * ALTERNATIVELY, this software may be distributed under the terms of the | 102 | .access = PL0_RW, .accessfn = access_tpidr2, |
49 | + * GNU General Public License ("GPL") as published by the Free Software | 103 | + .fgt = FGT_NTPIDR2_EL0, |
50 | + * Foundation; either version 2 of the License, or (at your option) any | 104 | .fieldoffset = offsetof(CPUARMState, cp15.tpidr2_el0) }, |
51 | + * later version. | 105 | { .name = "SVCR", .state = ARM_CP_STATE_AA64, |
52 | + * | 106 | .opc0 = 3, .opc1 = 3, .crn = 4, .crm = 2, .opc2 = 2, |
53 | + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS | 107 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo sme_reginfo[] = { |
54 | + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | 108 | { .name = "SMPRI_EL1", .state = ARM_CP_STATE_AA64, |
55 | + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 109 | .opc0 = 3, .opc1 = 0, .crn = 1, .crm = 2, .opc2 = 4, |
56 | + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | 110 | .access = PL1_RW, .accessfn = access_esm, |
57 | + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 111 | + .fgt = FGT_NSMPRI_EL1, |
58 | + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 112 | .type = ARM_CP_CONST, .resetvalue = 0 }, |
59 | + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 113 | { .name = "SMPRIMAP_EL2", .state = ARM_CP_STATE_AA64, |
60 | + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | 114 | .opc0 = 3, .opc1 = 4, .crn = 1, .crm = 2, .opc2 = 5, |
61 | + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | 115 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) |
62 | + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 116 | { .name = "VBAR", .state = ARM_CP_STATE_BOTH, |
63 | + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 117 | .opc0 = 3, .crn = 12, .crm = 0, .opc1 = 0, .opc2 = 0, |
64 | + */ | 118 | .access = PL1_RW, .writefn = vbar_write, |
65 | + | 119 | + .fgt = FGT_VBAR_EL1, |
66 | +#ifndef __DWC2_HW_H__ | 120 | .bank_fieldoffsets = { offsetof(CPUARMState, cp15.vbar_s), |
67 | +#define __DWC2_HW_H__ | 121 | offsetof(CPUARMState, cp15.vbar_ns) }, |
68 | + | 122 | .resetvalue = 0 }, |
69 | +#define HSOTG_REG(x) (x) | ||
70 | + | ||
71 | +#define GOTGCTL HSOTG_REG(0x000) | ||
72 | +#define GOTGCTL_CHIRPEN BIT(27) | ||
73 | +#define GOTGCTL_MULT_VALID_BC_MASK (0x1f << 22) | ||
74 | +#define GOTGCTL_MULT_VALID_BC_SHIFT 22 | ||
75 | +#define GOTGCTL_OTGVER BIT(20) | ||
76 | +#define GOTGCTL_BSESVLD BIT(19) | ||
77 | +#define GOTGCTL_ASESVLD BIT(18) | ||
78 | +#define GOTGCTL_DBNC_SHORT BIT(17) | ||
79 | +#define GOTGCTL_CONID_B BIT(16) | ||
80 | +#define GOTGCTL_DBNCE_FLTR_BYPASS BIT(15) | ||
81 | +#define GOTGCTL_DEVHNPEN BIT(11) | ||
82 | +#define GOTGCTL_HSTSETHNPEN BIT(10) | ||
83 | +#define GOTGCTL_HNPREQ BIT(9) | ||
84 | +#define GOTGCTL_HSTNEGSCS BIT(8) | ||
85 | +#define GOTGCTL_SESREQ BIT(1) | ||
86 | +#define GOTGCTL_SESREQSCS BIT(0) | ||
87 | + | ||
88 | +#define GOTGINT HSOTG_REG(0x004) | ||
89 | +#define GOTGINT_DBNCE_DONE BIT(19) | ||
90 | +#define GOTGINT_A_DEV_TOUT_CHG BIT(18) | ||
91 | +#define GOTGINT_HST_NEG_DET BIT(17) | ||
92 | +#define GOTGINT_HST_NEG_SUC_STS_CHNG BIT(9) | ||
93 | +#define GOTGINT_SES_REQ_SUC_STS_CHNG BIT(8) | ||
94 | +#define GOTGINT_SES_END_DET BIT(2) | ||
95 | + | ||
96 | +#define GAHBCFG HSOTG_REG(0x008) | ||
97 | +#define GAHBCFG_AHB_SINGLE BIT(23) | ||
98 | +#define GAHBCFG_NOTI_ALL_DMA_WRIT BIT(22) | ||
99 | +#define GAHBCFG_REM_MEM_SUPP BIT(21) | ||
100 | +#define GAHBCFG_P_TXF_EMP_LVL BIT(8) | ||
101 | +#define GAHBCFG_NP_TXF_EMP_LVL BIT(7) | ||
102 | +#define GAHBCFG_DMA_EN BIT(5) | ||
103 | +#define GAHBCFG_HBSTLEN_MASK (0xf << 1) | ||
104 | +#define GAHBCFG_HBSTLEN_SHIFT 1 | ||
105 | +#define GAHBCFG_HBSTLEN_SINGLE 0 | ||
106 | +#define GAHBCFG_HBSTLEN_INCR 1 | ||
107 | +#define GAHBCFG_HBSTLEN_INCR4 3 | ||
108 | +#define GAHBCFG_HBSTLEN_INCR8 5 | ||
109 | +#define GAHBCFG_HBSTLEN_INCR16 7 | ||
110 | +#define GAHBCFG_GLBL_INTR_EN BIT(0) | ||
111 | +#define GAHBCFG_CTRL_MASK (GAHBCFG_P_TXF_EMP_LVL | \ | ||
112 | + GAHBCFG_NP_TXF_EMP_LVL | \ | ||
113 | + GAHBCFG_DMA_EN | \ | ||
114 | + GAHBCFG_GLBL_INTR_EN) | ||
115 | + | ||
116 | +#define GUSBCFG HSOTG_REG(0x00C) | ||
117 | +#define GUSBCFG_FORCEDEVMODE BIT(30) | ||
118 | +#define GUSBCFG_FORCEHOSTMODE BIT(29) | ||
119 | +#define GUSBCFG_TXENDDELAY BIT(28) | ||
120 | +#define GUSBCFG_ICTRAFFICPULLREMOVE BIT(27) | ||
121 | +#define GUSBCFG_ICUSBCAP BIT(26) | ||
122 | +#define GUSBCFG_ULPI_INT_PROT_DIS BIT(25) | ||
123 | +#define GUSBCFG_INDICATORPASSTHROUGH BIT(24) | ||
124 | +#define GUSBCFG_INDICATORCOMPLEMENT BIT(23) | ||
125 | +#define GUSBCFG_TERMSELDLPULSE BIT(22) | ||
126 | +#define GUSBCFG_ULPI_INT_VBUS_IND BIT(21) | ||
127 | +#define GUSBCFG_ULPI_EXT_VBUS_DRV BIT(20) | ||
128 | +#define GUSBCFG_ULPI_CLK_SUSP_M BIT(19) | ||
129 | +#define GUSBCFG_ULPI_AUTO_RES BIT(18) | ||
130 | +#define GUSBCFG_ULPI_FS_LS BIT(17) | ||
131 | +#define GUSBCFG_OTG_UTMI_FS_SEL BIT(16) | ||
132 | +#define GUSBCFG_PHY_LP_CLK_SEL BIT(15) | ||
133 | +#define GUSBCFG_USBTRDTIM_MASK (0xf << 10) | ||
134 | +#define GUSBCFG_USBTRDTIM_SHIFT 10 | ||
135 | +#define GUSBCFG_HNPCAP BIT(9) | ||
136 | +#define GUSBCFG_SRPCAP BIT(8) | ||
137 | +#define GUSBCFG_DDRSEL BIT(7) | ||
138 | +#define GUSBCFG_PHYSEL BIT(6) | ||
139 | +#define GUSBCFG_FSINTF BIT(5) | ||
140 | +#define GUSBCFG_ULPI_UTMI_SEL BIT(4) | ||
141 | +#define GUSBCFG_PHYIF16 BIT(3) | ||
142 | +#define GUSBCFG_PHYIF8 (0 << 3) | ||
143 | +#define GUSBCFG_TOUTCAL_MASK (0x7 << 0) | ||
144 | +#define GUSBCFG_TOUTCAL_SHIFT 0 | ||
145 | +#define GUSBCFG_TOUTCAL_LIMIT 0x7 | ||
146 | +#define GUSBCFG_TOUTCAL(_x) ((_x) << 0) | ||
147 | + | ||
148 | +#define GRSTCTL HSOTG_REG(0x010) | ||
149 | +#define GRSTCTL_AHBIDLE BIT(31) | ||
150 | +#define GRSTCTL_DMAREQ BIT(30) | ||
151 | +#define GRSTCTL_TXFNUM_MASK (0x1f << 6) | ||
152 | +#define GRSTCTL_TXFNUM_SHIFT 6 | ||
153 | +#define GRSTCTL_TXFNUM_LIMIT 0x1f | ||
154 | +#define GRSTCTL_TXFNUM(_x) ((_x) << 6) | ||
155 | +#define GRSTCTL_TXFFLSH BIT(5) | ||
156 | +#define GRSTCTL_RXFFLSH BIT(4) | ||
157 | +#define GRSTCTL_IN_TKNQ_FLSH BIT(3) | ||
158 | +#define GRSTCTL_FRMCNTRRST BIT(2) | ||
159 | +#define GRSTCTL_HSFTRST BIT(1) | ||
160 | +#define GRSTCTL_CSFTRST BIT(0) | ||
161 | + | ||
162 | +#define GINTSTS HSOTG_REG(0x014) | ||
163 | +#define GINTMSK HSOTG_REG(0x018) | ||
164 | +#define GINTSTS_WKUPINT BIT(31) | ||
165 | +#define GINTSTS_SESSREQINT BIT(30) | ||
166 | +#define GINTSTS_DISCONNINT BIT(29) | ||
167 | +#define GINTSTS_CONIDSTSCHNG BIT(28) | ||
168 | +#define GINTSTS_LPMTRANRCVD BIT(27) | ||
169 | +#define GINTSTS_PTXFEMP BIT(26) | ||
170 | +#define GINTSTS_HCHINT BIT(25) | ||
171 | +#define GINTSTS_PRTINT BIT(24) | ||
172 | +#define GINTSTS_RESETDET BIT(23) | ||
173 | +#define GINTSTS_FET_SUSP BIT(22) | ||
174 | +#define GINTSTS_INCOMPL_IP BIT(21) | ||
175 | +#define GINTSTS_INCOMPL_SOOUT BIT(21) | ||
176 | +#define GINTSTS_INCOMPL_SOIN BIT(20) | ||
177 | +#define GINTSTS_OEPINT BIT(19) | ||
178 | +#define GINTSTS_IEPINT BIT(18) | ||
179 | +#define GINTSTS_EPMIS BIT(17) | ||
180 | +#define GINTSTS_RESTOREDONE BIT(16) | ||
181 | +#define GINTSTS_EOPF BIT(15) | ||
182 | +#define GINTSTS_ISOUTDROP BIT(14) | ||
183 | +#define GINTSTS_ENUMDONE BIT(13) | ||
184 | +#define GINTSTS_USBRST BIT(12) | ||
185 | +#define GINTSTS_USBSUSP BIT(11) | ||
186 | +#define GINTSTS_ERLYSUSP BIT(10) | ||
187 | +#define GINTSTS_I2CINT BIT(9) | ||
188 | +#define GINTSTS_ULPI_CK_INT BIT(8) | ||
189 | +#define GINTSTS_GOUTNAKEFF BIT(7) | ||
190 | +#define GINTSTS_GINNAKEFF BIT(6) | ||
191 | +#define GINTSTS_NPTXFEMP BIT(5) | ||
192 | +#define GINTSTS_RXFLVL BIT(4) | ||
193 | +#define GINTSTS_SOF BIT(3) | ||
194 | +#define GINTSTS_OTGINT BIT(2) | ||
195 | +#define GINTSTS_MODEMIS BIT(1) | ||
196 | +#define GINTSTS_CURMODE_HOST BIT(0) | ||
197 | + | ||
198 | +#define GRXSTSR HSOTG_REG(0x01C) | ||
199 | +#define GRXSTSP HSOTG_REG(0x020) | ||
200 | +#define GRXSTS_FN_MASK (0x7f << 25) | ||
201 | +#define GRXSTS_FN_SHIFT 25 | ||
202 | +#define GRXSTS_PKTSTS_MASK (0xf << 17) | ||
203 | +#define GRXSTS_PKTSTS_SHIFT 17 | ||
204 | +#define GRXSTS_PKTSTS_GLOBALOUTNAK 1 | ||
205 | +#define GRXSTS_PKTSTS_OUTRX 2 | ||
206 | +#define GRXSTS_PKTSTS_HCHIN 2 | ||
207 | +#define GRXSTS_PKTSTS_OUTDONE 3 | ||
208 | +#define GRXSTS_PKTSTS_HCHIN_XFER_COMP 3 | ||
209 | +#define GRXSTS_PKTSTS_SETUPDONE 4 | ||
210 | +#define GRXSTS_PKTSTS_DATATOGGLEERR 5 | ||
211 | +#define GRXSTS_PKTSTS_SETUPRX 6 | ||
212 | +#define GRXSTS_PKTSTS_HCHHALTED 7 | ||
213 | +#define GRXSTS_HCHNUM_MASK (0xf << 0) | ||
214 | +#define GRXSTS_HCHNUM_SHIFT 0 | ||
215 | +#define GRXSTS_DPID_MASK (0x3 << 15) | ||
216 | +#define GRXSTS_DPID_SHIFT 15 | ||
217 | +#define GRXSTS_BYTECNT_MASK (0x7ff << 4) | ||
218 | +#define GRXSTS_BYTECNT_SHIFT 4 | ||
219 | +#define GRXSTS_EPNUM_MASK (0xf << 0) | ||
220 | +#define GRXSTS_EPNUM_SHIFT 0 | ||
221 | + | ||
222 | +#define GRXFSIZ HSOTG_REG(0x024) | ||
223 | +#define GRXFSIZ_DEPTH_MASK (0xffff << 0) | ||
224 | +#define GRXFSIZ_DEPTH_SHIFT 0 | ||
225 | + | ||
226 | +#define GNPTXFSIZ HSOTG_REG(0x028) | ||
227 | +/* Use FIFOSIZE_* constants to access this register */ | ||
228 | + | ||
229 | +#define GNPTXSTS HSOTG_REG(0x02C) | ||
230 | +#define GNPTXSTS_NP_TXQ_TOP_MASK (0x7f << 24) | ||
231 | +#define GNPTXSTS_NP_TXQ_TOP_SHIFT 24 | ||
232 | +#define GNPTXSTS_NP_TXQ_SPC_AVAIL_MASK (0xff << 16) | ||
233 | +#define GNPTXSTS_NP_TXQ_SPC_AVAIL_SHIFT 16 | ||
234 | +#define GNPTXSTS_NP_TXQ_SPC_AVAIL_GET(_v) (((_v) >> 16) & 0xff) | ||
235 | +#define GNPTXSTS_NP_TXF_SPC_AVAIL_MASK (0xffff << 0) | ||
236 | +#define GNPTXSTS_NP_TXF_SPC_AVAIL_SHIFT 0 | ||
237 | +#define GNPTXSTS_NP_TXF_SPC_AVAIL_GET(_v) (((_v) >> 0) & 0xffff) | ||
238 | + | ||
239 | +#define GI2CCTL HSOTG_REG(0x0030) | ||
240 | +#define GI2CCTL_BSYDNE BIT(31) | ||
241 | +#define GI2CCTL_RW BIT(30) | ||
242 | +#define GI2CCTL_I2CDATSE0 BIT(28) | ||
243 | +#define GI2CCTL_I2CDEVADDR_MASK (0x3 << 26) | ||
244 | +#define GI2CCTL_I2CDEVADDR_SHIFT 26 | ||
245 | +#define GI2CCTL_I2CSUSPCTL BIT(25) | ||
246 | +#define GI2CCTL_ACK BIT(24) | ||
247 | +#define GI2CCTL_I2CEN BIT(23) | ||
248 | +#define GI2CCTL_ADDR_MASK (0x7f << 16) | ||
249 | +#define GI2CCTL_ADDR_SHIFT 16 | ||
250 | +#define GI2CCTL_REGADDR_MASK (0xff << 8) | ||
251 | +#define GI2CCTL_REGADDR_SHIFT 8 | ||
252 | +#define GI2CCTL_RWDATA_MASK (0xff << 0) | ||
253 | +#define GI2CCTL_RWDATA_SHIFT 0 | ||
254 | + | ||
255 | +#define GPVNDCTL HSOTG_REG(0x0034) | ||
256 | +#define GGPIO HSOTG_REG(0x0038) | ||
257 | +#define GGPIO_STM32_OTG_GCCFG_PWRDWN BIT(16) | ||
258 | + | ||
259 | +#define GUID HSOTG_REG(0x003c) | ||
260 | +#define GSNPSID HSOTG_REG(0x0040) | ||
261 | +#define GHWCFG1 HSOTG_REG(0x0044) | ||
262 | +#define GSNPSID_ID_MASK GENMASK(31, 16) | ||
263 | + | ||
264 | +#define GHWCFG2 HSOTG_REG(0x0048) | ||
265 | +#define GHWCFG2_OTG_ENABLE_IC_USB BIT(31) | ||
266 | +#define GHWCFG2_DEV_TOKEN_Q_DEPTH_MASK (0x1f << 26) | ||
267 | +#define GHWCFG2_DEV_TOKEN_Q_DEPTH_SHIFT 26 | ||
268 | +#define GHWCFG2_HOST_PERIO_TX_Q_DEPTH_MASK (0x3 << 24) | ||
269 | +#define GHWCFG2_HOST_PERIO_TX_Q_DEPTH_SHIFT 24 | ||
270 | +#define GHWCFG2_NONPERIO_TX_Q_DEPTH_MASK (0x3 << 22) | ||
271 | +#define GHWCFG2_NONPERIO_TX_Q_DEPTH_SHIFT 22 | ||
272 | +#define GHWCFG2_MULTI_PROC_INT BIT(20) | ||
273 | +#define GHWCFG2_DYNAMIC_FIFO BIT(19) | ||
274 | +#define GHWCFG2_PERIO_EP_SUPPORTED BIT(18) | ||
275 | +#define GHWCFG2_NUM_HOST_CHAN_MASK (0xf << 14) | ||
276 | +#define GHWCFG2_NUM_HOST_CHAN_SHIFT 14 | ||
277 | +#define GHWCFG2_NUM_DEV_EP_MASK (0xf << 10) | ||
278 | +#define GHWCFG2_NUM_DEV_EP_SHIFT 10 | ||
279 | +#define GHWCFG2_FS_PHY_TYPE_MASK (0x3 << 8) | ||
280 | +#define GHWCFG2_FS_PHY_TYPE_SHIFT 8 | ||
281 | +#define GHWCFG2_FS_PHY_TYPE_NOT_SUPPORTED 0 | ||
282 | +#define GHWCFG2_FS_PHY_TYPE_DEDICATED 1 | ||
283 | +#define GHWCFG2_FS_PHY_TYPE_SHARED_UTMI 2 | ||
284 | +#define GHWCFG2_FS_PHY_TYPE_SHARED_ULPI 3 | ||
285 | +#define GHWCFG2_HS_PHY_TYPE_MASK (0x3 << 6) | ||
286 | +#define GHWCFG2_HS_PHY_TYPE_SHIFT 6 | ||
287 | +#define GHWCFG2_HS_PHY_TYPE_NOT_SUPPORTED 0 | ||
288 | +#define GHWCFG2_HS_PHY_TYPE_UTMI 1 | ||
289 | +#define GHWCFG2_HS_PHY_TYPE_ULPI 2 | ||
290 | +#define GHWCFG2_HS_PHY_TYPE_UTMI_ULPI 3 | ||
291 | +#define GHWCFG2_POINT2POINT BIT(5) | ||
292 | +#define GHWCFG2_ARCHITECTURE_MASK (0x3 << 3) | ||
293 | +#define GHWCFG2_ARCHITECTURE_SHIFT 3 | ||
294 | +#define GHWCFG2_SLAVE_ONLY_ARCH 0 | ||
295 | +#define GHWCFG2_EXT_DMA_ARCH 1 | ||
296 | +#define GHWCFG2_INT_DMA_ARCH 2 | ||
297 | +#define GHWCFG2_OP_MODE_MASK (0x7 << 0) | ||
298 | +#define GHWCFG2_OP_MODE_SHIFT 0 | ||
299 | +#define GHWCFG2_OP_MODE_HNP_SRP_CAPABLE 0 | ||
300 | +#define GHWCFG2_OP_MODE_SRP_ONLY_CAPABLE 1 | ||
301 | +#define GHWCFG2_OP_MODE_NO_HNP_SRP_CAPABLE 2 | ||
302 | +#define GHWCFG2_OP_MODE_SRP_CAPABLE_DEVICE 3 | ||
303 | +#define GHWCFG2_OP_MODE_NO_SRP_CAPABLE_DEVICE 4 | ||
304 | +#define GHWCFG2_OP_MODE_SRP_CAPABLE_HOST 5 | ||
305 | +#define GHWCFG2_OP_MODE_NO_SRP_CAPABLE_HOST 6 | ||
306 | +#define GHWCFG2_OP_MODE_UNDEFINED 7 | ||
307 | + | ||
308 | +#define GHWCFG3 HSOTG_REG(0x004c) | ||
309 | +#define GHWCFG3_DFIFO_DEPTH_MASK (0xffff << 16) | ||
310 | +#define GHWCFG3_DFIFO_DEPTH_SHIFT 16 | ||
311 | +#define GHWCFG3_OTG_LPM_EN BIT(15) | ||
312 | +#define GHWCFG3_BC_SUPPORT BIT(14) | ||
313 | +#define GHWCFG3_OTG_ENABLE_HSIC BIT(13) | ||
314 | +#define GHWCFG3_ADP_SUPP BIT(12) | ||
315 | +#define GHWCFG3_SYNCH_RESET_TYPE BIT(11) | ||
316 | +#define GHWCFG3_OPTIONAL_FEATURES BIT(10) | ||
317 | +#define GHWCFG3_VENDOR_CTRL_IF BIT(9) | ||
318 | +#define GHWCFG3_I2C BIT(8) | ||
319 | +#define GHWCFG3_OTG_FUNC BIT(7) | ||
320 | +#define GHWCFG3_PACKET_SIZE_CNTR_WIDTH_MASK (0x7 << 4) | ||
321 | +#define GHWCFG3_PACKET_SIZE_CNTR_WIDTH_SHIFT 4 | ||
322 | +#define GHWCFG3_XFER_SIZE_CNTR_WIDTH_MASK (0xf << 0) | ||
323 | +#define GHWCFG3_XFER_SIZE_CNTR_WIDTH_SHIFT 0 | ||
324 | + | ||
325 | +#define GHWCFG4 HSOTG_REG(0x0050) | ||
326 | +#define GHWCFG4_DESC_DMA_DYN BIT(31) | ||
327 | +#define GHWCFG4_DESC_DMA BIT(30) | ||
328 | +#define GHWCFG4_NUM_IN_EPS_MASK (0xf << 26) | ||
329 | +#define GHWCFG4_NUM_IN_EPS_SHIFT 26 | ||
330 | +#define GHWCFG4_DED_FIFO_EN BIT(25) | ||
331 | +#define GHWCFG4_DED_FIFO_SHIFT 25 | ||
332 | +#define GHWCFG4_SESSION_END_FILT_EN BIT(24) | ||
333 | +#define GHWCFG4_B_VALID_FILT_EN BIT(23) | ||
334 | +#define GHWCFG4_A_VALID_FILT_EN BIT(22) | ||
335 | +#define GHWCFG4_VBUS_VALID_FILT_EN BIT(21) | ||
336 | +#define GHWCFG4_IDDIG_FILT_EN BIT(20) | ||
337 | +#define GHWCFG4_NUM_DEV_MODE_CTRL_EP_MASK (0xf << 16) | ||
338 | +#define GHWCFG4_NUM_DEV_MODE_CTRL_EP_SHIFT 16 | ||
339 | +#define GHWCFG4_UTMI_PHY_DATA_WIDTH_MASK (0x3 << 14) | ||
340 | +#define GHWCFG4_UTMI_PHY_DATA_WIDTH_SHIFT 14 | ||
341 | +#define GHWCFG4_UTMI_PHY_DATA_WIDTH_8 0 | ||
342 | +#define GHWCFG4_UTMI_PHY_DATA_WIDTH_16 1 | ||
343 | +#define GHWCFG4_UTMI_PHY_DATA_WIDTH_8_OR_16 2 | ||
344 | +#define GHWCFG4_ACG_SUPPORTED BIT(12) | ||
345 | +#define GHWCFG4_IPG_ISOC_SUPPORTED BIT(11) | ||
346 | +#define GHWCFG4_SERVICE_INTERVAL_SUPPORTED BIT(10) | ||
347 | +#define GHWCFG4_XHIBER BIT(7) | ||
348 | +#define GHWCFG4_HIBER BIT(6) | ||
349 | +#define GHWCFG4_MIN_AHB_FREQ BIT(5) | ||
350 | +#define GHWCFG4_POWER_OPTIMIZ BIT(4) | ||
351 | +#define GHWCFG4_NUM_DEV_PERIO_IN_EP_MASK (0xf << 0) | ||
352 | +#define GHWCFG4_NUM_DEV_PERIO_IN_EP_SHIFT 0 | ||
353 | + | ||
354 | +#define GLPMCFG HSOTG_REG(0x0054) | ||
355 | +#define GLPMCFG_INVSELHSIC BIT(31) | ||
356 | +#define GLPMCFG_HSICCON BIT(30) | ||
357 | +#define GLPMCFG_RSTRSLPSTS BIT(29) | ||
358 | +#define GLPMCFG_ENBESL BIT(28) | ||
359 | +#define GLPMCFG_LPM_RETRYCNT_STS_MASK (0x7 << 25) | ||
360 | +#define GLPMCFG_LPM_RETRYCNT_STS_SHIFT 25 | ||
361 | +#define GLPMCFG_SNDLPM BIT(24) | ||
362 | +#define GLPMCFG_RETRY_CNT_MASK (0x7 << 21) | ||
363 | +#define GLPMCFG_RETRY_CNT_SHIFT 21 | ||
364 | +#define GLPMCFG_LPM_REJECT_CTRL_CONTROL BIT(21) | ||
365 | +#define GLPMCFG_LPM_ACCEPT_CTRL_ISOC BIT(22) | ||
366 | +#define GLPMCFG_LPM_CHNL_INDX_MASK (0xf << 17) | ||
367 | +#define GLPMCFG_LPM_CHNL_INDX_SHIFT 17 | ||
368 | +#define GLPMCFG_L1RESUMEOK BIT(16) | ||
369 | +#define GLPMCFG_SLPSTS BIT(15) | ||
370 | +#define GLPMCFG_COREL1RES_MASK (0x3 << 13) | ||
371 | +#define GLPMCFG_COREL1RES_SHIFT 13 | ||
372 | +#define GLPMCFG_HIRD_THRES_MASK (0x1f << 8) | ||
373 | +#define GLPMCFG_HIRD_THRES_SHIFT 8 | ||
374 | +#define GLPMCFG_HIRD_THRES_EN (0x10 << 8) | ||
375 | +#define GLPMCFG_ENBLSLPM BIT(7) | ||
376 | +#define GLPMCFG_BREMOTEWAKE BIT(6) | ||
377 | +#define GLPMCFG_HIRD_MASK (0xf << 2) | ||
378 | +#define GLPMCFG_HIRD_SHIFT 2 | ||
379 | +#define GLPMCFG_APPL1RES BIT(1) | ||
380 | +#define GLPMCFG_LPMCAP BIT(0) | ||
381 | + | ||
382 | +#define GPWRDN HSOTG_REG(0x0058) | ||
383 | +#define GPWRDN_MULT_VAL_ID_BC_MASK (0x1f << 24) | ||
384 | +#define GPWRDN_MULT_VAL_ID_BC_SHIFT 24 | ||
385 | +#define GPWRDN_ADP_INT BIT(23) | ||
386 | +#define GPWRDN_BSESSVLD BIT(22) | ||
387 | +#define GPWRDN_IDSTS BIT(21) | ||
388 | +#define GPWRDN_LINESTATE_MASK (0x3 << 19) | ||
389 | +#define GPWRDN_LINESTATE_SHIFT 19 | ||
390 | +#define GPWRDN_STS_CHGINT_MSK BIT(18) | ||
391 | +#define GPWRDN_STS_CHGINT BIT(17) | ||
392 | +#define GPWRDN_SRP_DET_MSK BIT(16) | ||
393 | +#define GPWRDN_SRP_DET BIT(15) | ||
394 | +#define GPWRDN_CONNECT_DET_MSK BIT(14) | ||
395 | +#define GPWRDN_CONNECT_DET BIT(13) | ||
396 | +#define GPWRDN_DISCONN_DET_MSK BIT(12) | ||
397 | +#define GPWRDN_DISCONN_DET BIT(11) | ||
398 | +#define GPWRDN_RST_DET_MSK BIT(10) | ||
399 | +#define GPWRDN_RST_DET BIT(9) | ||
400 | +#define GPWRDN_LNSTSCHG_MSK BIT(8) | ||
401 | +#define GPWRDN_LNSTSCHG BIT(7) | ||
402 | +#define GPWRDN_DIS_VBUS BIT(6) | ||
403 | +#define GPWRDN_PWRDNSWTCH BIT(5) | ||
404 | +#define GPWRDN_PWRDNRSTN BIT(4) | ||
405 | +#define GPWRDN_PWRDNCLMP BIT(3) | ||
406 | +#define GPWRDN_RESTORE BIT(2) | ||
407 | +#define GPWRDN_PMUACTV BIT(1) | ||
408 | +#define GPWRDN_PMUINTSEL BIT(0) | ||
409 | + | ||
410 | +#define GDFIFOCFG HSOTG_REG(0x005c) | ||
411 | +#define GDFIFOCFG_EPINFOBASE_MASK (0xffff << 16) | ||
412 | +#define GDFIFOCFG_EPINFOBASE_SHIFT 16 | ||
413 | +#define GDFIFOCFG_GDFIFOCFG_MASK (0xffff << 0) | ||
414 | +#define GDFIFOCFG_GDFIFOCFG_SHIFT 0 | ||
415 | + | ||
416 | +#define ADPCTL HSOTG_REG(0x0060) | ||
417 | +#define ADPCTL_AR_MASK (0x3 << 27) | ||
418 | +#define ADPCTL_AR_SHIFT 27 | ||
419 | +#define ADPCTL_ADP_TMOUT_INT_MSK BIT(26) | ||
420 | +#define ADPCTL_ADP_SNS_INT_MSK BIT(25) | ||
421 | +#define ADPCTL_ADP_PRB_INT_MSK BIT(24) | ||
422 | +#define ADPCTL_ADP_TMOUT_INT BIT(23) | ||
423 | +#define ADPCTL_ADP_SNS_INT BIT(22) | ||
424 | +#define ADPCTL_ADP_PRB_INT BIT(21) | ||
425 | +#define ADPCTL_ADPENA BIT(20) | ||
426 | +#define ADPCTL_ADPRES BIT(19) | ||
427 | +#define ADPCTL_ENASNS BIT(18) | ||
428 | +#define ADPCTL_ENAPRB BIT(17) | ||
429 | +#define ADPCTL_RTIM_MASK (0x7ff << 6) | ||
430 | +#define ADPCTL_RTIM_SHIFT 6 | ||
431 | +#define ADPCTL_PRB_PER_MASK (0x3 << 4) | ||
432 | +#define ADPCTL_PRB_PER_SHIFT 4 | ||
433 | +#define ADPCTL_PRB_DELTA_MASK (0x3 << 2) | ||
434 | +#define ADPCTL_PRB_DELTA_SHIFT 2 | ||
435 | +#define ADPCTL_PRB_DSCHRG_MASK (0x3 << 0) | ||
436 | +#define ADPCTL_PRB_DSCHRG_SHIFT 0 | ||
437 | + | ||
438 | +#define GREFCLK HSOTG_REG(0x0064) | ||
439 | +#define GREFCLK_REFCLKPER_MASK (0x1ffff << 15) | ||
440 | +#define GREFCLK_REFCLKPER_SHIFT 15 | ||
441 | +#define GREFCLK_REF_CLK_MODE BIT(14) | ||
442 | +#define GREFCLK_SOF_CNT_WKUP_ALERT_MASK (0x3ff) | ||
443 | +#define GREFCLK_SOF_CNT_WKUP_ALERT_SHIFT 0 | ||
444 | + | ||
445 | +#define GINTMSK2 HSOTG_REG(0x0068) | ||
446 | +#define GINTMSK2_WKUP_ALERT_INT_MSK BIT(0) | ||
447 | + | ||
448 | +#define GINTSTS2 HSOTG_REG(0x006c) | ||
449 | +#define GINTSTS2_WKUP_ALERT_INT BIT(0) | ||
450 | + | ||
451 | +#define HPTXFSIZ HSOTG_REG(0x100) | ||
452 | +/* Use FIFOSIZE_* constants to access this register */ | ||
453 | + | ||
454 | +#define DPTXFSIZN(_a) HSOTG_REG(0x104 + (((_a) - 1) * 4)) | ||
455 | +/* Use FIFOSIZE_* constants to access this register */ | ||
456 | + | ||
457 | +/* These apply to the GNPTXFSIZ, HPTXFSIZ and DPTXFSIZN registers */ | ||
458 | +#define FIFOSIZE_DEPTH_MASK (0xffff << 16) | ||
459 | +#define FIFOSIZE_DEPTH_SHIFT 16 | ||
460 | +#define FIFOSIZE_STARTADDR_MASK (0xffff << 0) | ||
461 | +#define FIFOSIZE_STARTADDR_SHIFT 0 | ||
462 | +#define FIFOSIZE_DEPTH_GET(_x) (((_x) >> 16) & 0xffff) | ||
463 | + | ||
464 | +/* Device mode registers */ | ||
465 | + | ||
466 | +#define DCFG HSOTG_REG(0x800) | ||
467 | +#define DCFG_DESCDMA_EN BIT(23) | ||
468 | +#define DCFG_EPMISCNT_MASK (0x1f << 18) | ||
469 | +#define DCFG_EPMISCNT_SHIFT 18 | ||
470 | +#define DCFG_EPMISCNT_LIMIT 0x1f | ||
471 | +#define DCFG_EPMISCNT(_x) ((_x) << 18) | ||
472 | +#define DCFG_IPG_ISOC_SUPPORDED BIT(17) | ||
473 | +#define DCFG_PERFRINT_MASK (0x3 << 11) | ||
474 | +#define DCFG_PERFRINT_SHIFT 11 | ||
475 | +#define DCFG_PERFRINT_LIMIT 0x3 | ||
476 | +#define DCFG_PERFRINT(_x) ((_x) << 11) | ||
477 | +#define DCFG_DEVADDR_MASK (0x7f << 4) | ||
478 | +#define DCFG_DEVADDR_SHIFT 4 | ||
479 | +#define DCFG_DEVADDR_LIMIT 0x7f | ||
480 | +#define DCFG_DEVADDR(_x) ((_x) << 4) | ||
481 | +#define DCFG_NZ_STS_OUT_HSHK BIT(2) | ||
482 | +#define DCFG_DEVSPD_MASK (0x3 << 0) | ||
483 | +#define DCFG_DEVSPD_SHIFT 0 | ||
484 | +#define DCFG_DEVSPD_HS 0 | ||
485 | +#define DCFG_DEVSPD_FS 1 | ||
486 | +#define DCFG_DEVSPD_LS 2 | ||
487 | +#define DCFG_DEVSPD_FS48 3 | ||
488 | + | ||
489 | +#define DCTL HSOTG_REG(0x804) | ||
490 | +#define DCTL_SERVICE_INTERVAL_SUPPORTED BIT(19) | ||
491 | +#define DCTL_PWRONPRGDONE BIT(11) | ||
492 | +#define DCTL_CGOUTNAK BIT(10) | ||
493 | +#define DCTL_SGOUTNAK BIT(9) | ||
494 | +#define DCTL_CGNPINNAK BIT(8) | ||
495 | +#define DCTL_SGNPINNAK BIT(7) | ||
496 | +#define DCTL_TSTCTL_MASK (0x7 << 4) | ||
497 | +#define DCTL_TSTCTL_SHIFT 4 | ||
498 | +#define DCTL_GOUTNAKSTS BIT(3) | ||
499 | +#define DCTL_GNPINNAKSTS BIT(2) | ||
500 | +#define DCTL_SFTDISCON BIT(1) | ||
501 | +#define DCTL_RMTWKUPSIG BIT(0) | ||
502 | + | ||
503 | +#define DSTS HSOTG_REG(0x808) | ||
504 | +#define DSTS_SOFFN_MASK (0x3fff << 8) | ||
505 | +#define DSTS_SOFFN_SHIFT 8 | ||
506 | +#define DSTS_SOFFN_LIMIT 0x3fff | ||
507 | +#define DSTS_SOFFN(_x) ((_x) << 8) | ||
508 | +#define DSTS_ERRATICERR BIT(3) | ||
509 | +#define DSTS_ENUMSPD_MASK (0x3 << 1) | ||
510 | +#define DSTS_ENUMSPD_SHIFT 1 | ||
511 | +#define DSTS_ENUMSPD_HS 0 | ||
512 | +#define DSTS_ENUMSPD_FS 1 | ||
513 | +#define DSTS_ENUMSPD_LS 2 | ||
514 | +#define DSTS_ENUMSPD_FS48 3 | ||
515 | +#define DSTS_SUSPSTS BIT(0) | ||
516 | + | ||
517 | +#define DIEPMSK HSOTG_REG(0x810) | ||
518 | +#define DIEPMSK_NAKMSK BIT(13) | ||
519 | +#define DIEPMSK_BNAININTRMSK BIT(9) | ||
520 | +#define DIEPMSK_TXFIFOUNDRNMSK BIT(8) | ||
521 | +#define DIEPMSK_TXFIFOEMPTY BIT(7) | ||
522 | +#define DIEPMSK_INEPNAKEFFMSK BIT(6) | ||
523 | +#define DIEPMSK_INTKNEPMISMSK BIT(5) | ||
524 | +#define DIEPMSK_INTKNTXFEMPMSK BIT(4) | ||
525 | +#define DIEPMSK_TIMEOUTMSK BIT(3) | ||
526 | +#define DIEPMSK_AHBERRMSK BIT(2) | ||
527 | +#define DIEPMSK_EPDISBLDMSK BIT(1) | ||
528 | +#define DIEPMSK_XFERCOMPLMSK BIT(0) | ||
529 | + | ||
530 | +#define DOEPMSK HSOTG_REG(0x814) | ||
531 | +#define DOEPMSK_BNAMSK BIT(9) | ||
532 | +#define DOEPMSK_BACK2BACKSETUP BIT(6) | ||
533 | +#define DOEPMSK_STSPHSERCVDMSK BIT(5) | ||
534 | +#define DOEPMSK_OUTTKNEPDISMSK BIT(4) | ||
535 | +#define DOEPMSK_SETUPMSK BIT(3) | ||
536 | +#define DOEPMSK_AHBERRMSK BIT(2) | ||
537 | +#define DOEPMSK_EPDISBLDMSK BIT(1) | ||
538 | +#define DOEPMSK_XFERCOMPLMSK BIT(0) | ||
539 | + | ||
540 | +#define DAINT HSOTG_REG(0x818) | ||
541 | +#define DAINTMSK HSOTG_REG(0x81C) | ||
542 | +#define DAINT_OUTEP_SHIFT 16 | ||
543 | +#define DAINT_OUTEP(_x) (1 << ((_x) + 16)) | ||
544 | +#define DAINT_INEP(_x) (1 << (_x)) | ||
545 | + | ||
546 | +#define DTKNQR1 HSOTG_REG(0x820) | ||
547 | +#define DTKNQR2 HSOTG_REG(0x824) | ||
548 | +#define DTKNQR3 HSOTG_REG(0x830) | ||
549 | +#define DTKNQR4 HSOTG_REG(0x834) | ||
550 | +#define DIEPEMPMSK HSOTG_REG(0x834) | ||
551 | + | ||
552 | +#define DVBUSDIS HSOTG_REG(0x828) | ||
553 | +#define DVBUSPULSE HSOTG_REG(0x82C) | ||
554 | + | ||
555 | +#define DIEPCTL0 HSOTG_REG(0x900) | ||
556 | +#define DIEPCTL(_a) HSOTG_REG(0x900 + ((_a) * 0x20)) | ||
557 | + | ||
558 | +#define DOEPCTL0 HSOTG_REG(0xB00) | ||
559 | +#define DOEPCTL(_a) HSOTG_REG(0xB00 + ((_a) * 0x20)) | ||
560 | + | ||
561 | +/* EP0 specialness: | ||
562 | + * bits[29..28] - reserved (no SetD0PID, SetD1PID) | ||
563 | + * bits[25..22] - should always be zero, this isn't a periodic endpoint | ||
564 | + * bits[10..0] - MPS setting different for EP0 | ||
565 | + */ | ||
566 | +#define D0EPCTL_MPS_MASK (0x3 << 0) | ||
567 | +#define D0EPCTL_MPS_SHIFT 0 | ||
568 | +#define D0EPCTL_MPS_64 0 | ||
569 | +#define D0EPCTL_MPS_32 1 | ||
570 | +#define D0EPCTL_MPS_16 2 | ||
571 | +#define D0EPCTL_MPS_8 3 | ||
572 | + | ||
573 | +#define DXEPCTL_EPENA BIT(31) | ||
574 | +#define DXEPCTL_EPDIS BIT(30) | ||
575 | +#define DXEPCTL_SETD1PID BIT(29) | ||
576 | +#define DXEPCTL_SETODDFR BIT(29) | ||
577 | +#define DXEPCTL_SETD0PID BIT(28) | ||
578 | +#define DXEPCTL_SETEVENFR BIT(28) | ||
579 | +#define DXEPCTL_SNAK BIT(27) | ||
580 | +#define DXEPCTL_CNAK BIT(26) | ||
581 | +#define DXEPCTL_TXFNUM_MASK (0xf << 22) | ||
582 | +#define DXEPCTL_TXFNUM_SHIFT 22 | ||
583 | +#define DXEPCTL_TXFNUM_LIMIT 0xf | ||
584 | +#define DXEPCTL_TXFNUM(_x) ((_x) << 22) | ||
585 | +#define DXEPCTL_STALL BIT(21) | ||
586 | +#define DXEPCTL_SNP BIT(20) | ||
587 | +#define DXEPCTL_EPTYPE_MASK (0x3 << 18) | ||
588 | +#define DXEPCTL_EPTYPE_CONTROL (0x0 << 18) | ||
589 | +#define DXEPCTL_EPTYPE_ISO (0x1 << 18) | ||
590 | +#define DXEPCTL_EPTYPE_BULK (0x2 << 18) | ||
591 | +#define DXEPCTL_EPTYPE_INTERRUPT (0x3 << 18) | ||
592 | + | ||
593 | +#define DXEPCTL_NAKSTS BIT(17) | ||
594 | +#define DXEPCTL_DPID BIT(16) | ||
595 | +#define DXEPCTL_EOFRNUM BIT(16) | ||
596 | +#define DXEPCTL_USBACTEP BIT(15) | ||
597 | +#define DXEPCTL_NEXTEP_MASK (0xf << 11) | ||
598 | +#define DXEPCTL_NEXTEP_SHIFT 11 | ||
599 | +#define DXEPCTL_NEXTEP_LIMIT 0xf | ||
600 | +#define DXEPCTL_NEXTEP(_x) ((_x) << 11) | ||
601 | +#define DXEPCTL_MPS_MASK (0x7ff << 0) | ||
602 | +#define DXEPCTL_MPS_SHIFT 0 | ||
603 | +#define DXEPCTL_MPS_LIMIT 0x7ff | ||
604 | +#define DXEPCTL_MPS(_x) ((_x) << 0) | ||
605 | + | ||
606 | +#define DIEPINT(_a) HSOTG_REG(0x908 + ((_a) * 0x20)) | ||
607 | +#define DOEPINT(_a) HSOTG_REG(0xB08 + ((_a) * 0x20)) | ||
608 | +#define DXEPINT_SETUP_RCVD BIT(15) | ||
609 | +#define DXEPINT_NYETINTRPT BIT(14) | ||
610 | +#define DXEPINT_NAKINTRPT BIT(13) | ||
611 | +#define DXEPINT_BBLEERRINTRPT BIT(12) | ||
612 | +#define DXEPINT_PKTDRPSTS BIT(11) | ||
613 | +#define DXEPINT_BNAINTR BIT(9) | ||
614 | +#define DXEPINT_TXFIFOUNDRN BIT(8) | ||
615 | +#define DXEPINT_OUTPKTERR BIT(8) | ||
616 | +#define DXEPINT_TXFEMP BIT(7) | ||
617 | +#define DXEPINT_INEPNAKEFF BIT(6) | ||
618 | +#define DXEPINT_BACK2BACKSETUP BIT(6) | ||
619 | +#define DXEPINT_INTKNEPMIS BIT(5) | ||
620 | +#define DXEPINT_STSPHSERCVD BIT(5) | ||
621 | +#define DXEPINT_INTKNTXFEMP BIT(4) | ||
622 | +#define DXEPINT_OUTTKNEPDIS BIT(4) | ||
623 | +#define DXEPINT_TIMEOUT BIT(3) | ||
624 | +#define DXEPINT_SETUP BIT(3) | ||
625 | +#define DXEPINT_AHBERR BIT(2) | ||
626 | +#define DXEPINT_EPDISBLD BIT(1) | ||
627 | +#define DXEPINT_XFERCOMPL BIT(0) | ||
628 | + | ||
629 | +#define DIEPTSIZ0 HSOTG_REG(0x910) | ||
630 | +#define DIEPTSIZ0_PKTCNT_MASK (0x3 << 19) | ||
631 | +#define DIEPTSIZ0_PKTCNT_SHIFT 19 | ||
632 | +#define DIEPTSIZ0_PKTCNT_LIMIT 0x3 | ||
633 | +#define DIEPTSIZ0_PKTCNT(_x) ((_x) << 19) | ||
634 | +#define DIEPTSIZ0_XFERSIZE_MASK (0x7f << 0) | ||
635 | +#define DIEPTSIZ0_XFERSIZE_SHIFT 0 | ||
636 | +#define DIEPTSIZ0_XFERSIZE_LIMIT 0x7f | ||
637 | +#define DIEPTSIZ0_XFERSIZE(_x) ((_x) << 0) | ||
638 | + | ||
639 | +#define DOEPTSIZ0 HSOTG_REG(0xB10) | ||
640 | +#define DOEPTSIZ0_SUPCNT_MASK (0x3 << 29) | ||
641 | +#define DOEPTSIZ0_SUPCNT_SHIFT 29 | ||
642 | +#define DOEPTSIZ0_SUPCNT_LIMIT 0x3 | ||
643 | +#define DOEPTSIZ0_SUPCNT(_x) ((_x) << 29) | ||
644 | +#define DOEPTSIZ0_PKTCNT BIT(19) | ||
645 | +#define DOEPTSIZ0_XFERSIZE_MASK (0x7f << 0) | ||
646 | +#define DOEPTSIZ0_XFERSIZE_SHIFT 0 | ||
647 | + | ||
648 | +#define DIEPTSIZ(_a) HSOTG_REG(0x910 + ((_a) * 0x20)) | ||
649 | +#define DOEPTSIZ(_a) HSOTG_REG(0xB10 + ((_a) * 0x20)) | ||
650 | +#define DXEPTSIZ_MC_MASK (0x3 << 29) | ||
651 | +#define DXEPTSIZ_MC_SHIFT 29 | ||
652 | +#define DXEPTSIZ_MC_LIMIT 0x3 | ||
653 | +#define DXEPTSIZ_MC(_x) ((_x) << 29) | ||
654 | +#define DXEPTSIZ_PKTCNT_MASK (0x3ff << 19) | ||
655 | +#define DXEPTSIZ_PKTCNT_SHIFT 19 | ||
656 | +#define DXEPTSIZ_PKTCNT_LIMIT 0x3ff | ||
657 | +#define DXEPTSIZ_PKTCNT_GET(_v) (((_v) >> 19) & 0x3ff) | ||
658 | +#define DXEPTSIZ_PKTCNT(_x) ((_x) << 19) | ||
659 | +#define DXEPTSIZ_XFERSIZE_MASK (0x7ffff << 0) | ||
660 | +#define DXEPTSIZ_XFERSIZE_SHIFT 0 | ||
661 | +#define DXEPTSIZ_XFERSIZE_LIMIT 0x7ffff | ||
662 | +#define DXEPTSIZ_XFERSIZE_GET(_v) (((_v) >> 0) & 0x7ffff) | ||
663 | +#define DXEPTSIZ_XFERSIZE(_x) ((_x) << 0) | ||
664 | + | ||
665 | +#define DIEPDMA(_a) HSOTG_REG(0x914 + ((_a) * 0x20)) | ||
666 | +#define DOEPDMA(_a) HSOTG_REG(0xB14 + ((_a) * 0x20)) | ||
667 | + | ||
668 | +#define DTXFSTS(_a) HSOTG_REG(0x918 + ((_a) * 0x20)) | ||
669 | + | ||
670 | +#define PCGCTL HSOTG_REG(0x0e00) | ||
671 | +#define PCGCTL_IF_DEV_MODE BIT(31) | ||
672 | +#define PCGCTL_P2HD_PRT_SPD_MASK (0x3 << 29) | ||
673 | +#define PCGCTL_P2HD_PRT_SPD_SHIFT 29 | ||
674 | +#define PCGCTL_P2HD_DEV_ENUM_SPD_MASK (0x3 << 27) | ||
675 | +#define PCGCTL_P2HD_DEV_ENUM_SPD_SHIFT 27 | ||
676 | +#define PCGCTL_MAC_DEV_ADDR_MASK (0x7f << 20) | ||
677 | +#define PCGCTL_MAC_DEV_ADDR_SHIFT 20 | ||
678 | +#define PCGCTL_MAX_TERMSEL BIT(19) | ||
679 | +#define PCGCTL_MAX_XCVRSELECT_MASK (0x3 << 17) | ||
680 | +#define PCGCTL_MAX_XCVRSELECT_SHIFT 17 | ||
681 | +#define PCGCTL_PORT_POWER BIT(16) | ||
682 | +#define PCGCTL_PRT_CLK_SEL_MASK (0x3 << 14) | ||
683 | +#define PCGCTL_PRT_CLK_SEL_SHIFT 14 | ||
684 | +#define PCGCTL_ESS_REG_RESTORED BIT(13) | ||
685 | +#define PCGCTL_EXTND_HIBER_SWITCH BIT(12) | ||
686 | +#define PCGCTL_EXTND_HIBER_PWRCLMP BIT(11) | ||
687 | +#define PCGCTL_ENBL_EXTND_HIBER BIT(10) | ||
688 | +#define PCGCTL_RESTOREMODE BIT(9) | ||
689 | +#define PCGCTL_RESETAFTSUSP BIT(8) | ||
690 | +#define PCGCTL_DEEP_SLEEP BIT(7) | ||
691 | +#define PCGCTL_PHY_IN_SLEEP BIT(6) | ||
692 | +#define PCGCTL_ENBL_SLEEP_GATING BIT(5) | ||
693 | +#define PCGCTL_RSTPDWNMODULE BIT(3) | ||
694 | +#define PCGCTL_PWRCLMP BIT(2) | ||
695 | +#define PCGCTL_GATEHCLK BIT(1) | ||
696 | +#define PCGCTL_STOPPCLK BIT(0) | ||
697 | + | ||
698 | +#define PCGCCTL1 HSOTG_REG(0xe04) | ||
699 | +#define PCGCCTL1_TIMER (0x3 << 1) | ||
700 | +#define PCGCCTL1_GATEEN BIT(0) | ||
701 | + | ||
702 | +#define EPFIFO(_a) HSOTG_REG(0x1000 + ((_a) * 0x1000)) | ||
703 | + | ||
704 | +/* Host Mode Registers */ | ||
705 | + | ||
706 | +#define HCFG HSOTG_REG(0x0400) | ||
707 | +#define HCFG_MODECHTIMEN BIT(31) | ||
708 | +#define HCFG_PERSCHEDENA BIT(26) | ||
709 | +#define HCFG_FRLISTEN_MASK (0x3 << 24) | ||
710 | +#define HCFG_FRLISTEN_SHIFT 24 | ||
711 | +#define HCFG_FRLISTEN_8 (0 << 24) | ||
712 | +#define FRLISTEN_8_SIZE 8 | ||
713 | +#define HCFG_FRLISTEN_16 BIT(24) | ||
714 | +#define FRLISTEN_16_SIZE 16 | ||
715 | +#define HCFG_FRLISTEN_32 (2 << 24) | ||
716 | +#define FRLISTEN_32_SIZE 32 | ||
717 | +#define HCFG_FRLISTEN_64 (3 << 24) | ||
718 | +#define FRLISTEN_64_SIZE 64 | ||
719 | +#define HCFG_DESCDMA BIT(23) | ||
720 | +#define HCFG_RESVALID_MASK (0xff << 8) | ||
721 | +#define HCFG_RESVALID_SHIFT 8 | ||
722 | +#define HCFG_ENA32KHZ BIT(7) | ||
723 | +#define HCFG_FSLSSUPP BIT(2) | ||
724 | +#define HCFG_FSLSPCLKSEL_MASK (0x3 << 0) | ||
725 | +#define HCFG_FSLSPCLKSEL_SHIFT 0 | ||
726 | +#define HCFG_FSLSPCLKSEL_30_60_MHZ 0 | ||
727 | +#define HCFG_FSLSPCLKSEL_48_MHZ 1 | ||
728 | +#define HCFG_FSLSPCLKSEL_6_MHZ 2 | ||
729 | + | ||
730 | +#define HFIR HSOTG_REG(0x0404) | ||
731 | +#define HFIR_FRINT_MASK (0xffff << 0) | ||
732 | +#define HFIR_FRINT_SHIFT 0 | ||
733 | +#define HFIR_RLDCTRL BIT(16) | ||
734 | + | ||
735 | +#define HFNUM HSOTG_REG(0x0408) | ||
736 | +#define HFNUM_FRREM_MASK (0xffff << 16) | ||
737 | +#define HFNUM_FRREM_SHIFT 16 | ||
738 | +#define HFNUM_FRNUM_MASK (0xffff << 0) | ||
739 | +#define HFNUM_FRNUM_SHIFT 0 | ||
740 | +#define HFNUM_MAX_FRNUM 0x3fff | ||
741 | + | ||
742 | +#define HPTXSTS HSOTG_REG(0x0410) | ||
743 | +#define TXSTS_QTOP_ODD BIT(31) | ||
744 | +#define TXSTS_QTOP_CHNEP_MASK (0xf << 27) | ||
745 | +#define TXSTS_QTOP_CHNEP_SHIFT 27 | ||
746 | +#define TXSTS_QTOP_TOKEN_MASK (0x3 << 25) | ||
747 | +#define TXSTS_QTOP_TOKEN_SHIFT 25 | ||
748 | +#define TXSTS_QTOP_TERMINATE BIT(24) | ||
749 | +#define TXSTS_QSPCAVAIL_MASK (0xff << 16) | ||
750 | +#define TXSTS_QSPCAVAIL_SHIFT 16 | ||
751 | +#define TXSTS_FSPCAVAIL_MASK (0xffff << 0) | ||
752 | +#define TXSTS_FSPCAVAIL_SHIFT 0 | ||
753 | + | ||
754 | +#define HAINT HSOTG_REG(0x0414) | ||
755 | +#define HAINTMSK HSOTG_REG(0x0418) | ||
756 | +#define HFLBADDR HSOTG_REG(0x041c) | ||
757 | + | ||
758 | +#define HPRT0 HSOTG_REG(0x0440) | ||
759 | +#define HPRT0_SPD_MASK (0x3 << 17) | ||
760 | +#define HPRT0_SPD_SHIFT 17 | ||
761 | +#define HPRT0_SPD_HIGH_SPEED 0 | ||
762 | +#define HPRT0_SPD_FULL_SPEED 1 | ||
763 | +#define HPRT0_SPD_LOW_SPEED 2 | ||
764 | +#define HPRT0_TSTCTL_MASK (0xf << 13) | ||
765 | +#define HPRT0_TSTCTL_SHIFT 13 | ||
766 | +#define HPRT0_PWR BIT(12) | ||
767 | +#define HPRT0_LNSTS_MASK (0x3 << 10) | ||
768 | +#define HPRT0_LNSTS_SHIFT 10 | ||
769 | +#define HPRT0_RST BIT(8) | ||
770 | +#define HPRT0_SUSP BIT(7) | ||
771 | +#define HPRT0_RES BIT(6) | ||
772 | +#define HPRT0_OVRCURRCHG BIT(5) | ||
773 | +#define HPRT0_OVRCURRACT BIT(4) | ||
774 | +#define HPRT0_ENACHG BIT(3) | ||
775 | +#define HPRT0_ENA BIT(2) | ||
776 | +#define HPRT0_CONNDET BIT(1) | ||
777 | +#define HPRT0_CONNSTS BIT(0) | ||
778 | + | ||
779 | +#define HCCHAR(_ch) HSOTG_REG(0x0500 + 0x20 * (_ch)) | ||
780 | +#define HCCHAR_CHENA BIT(31) | ||
781 | +#define HCCHAR_CHDIS BIT(30) | ||
782 | +#define HCCHAR_ODDFRM BIT(29) | ||
783 | +#define HCCHAR_DEVADDR_MASK (0x7f << 22) | ||
784 | +#define HCCHAR_DEVADDR_SHIFT 22 | ||
785 | +#define HCCHAR_MULTICNT_MASK (0x3 << 20) | ||
786 | +#define HCCHAR_MULTICNT_SHIFT 20 | ||
787 | +#define HCCHAR_EPTYPE_MASK (0x3 << 18) | ||
788 | +#define HCCHAR_EPTYPE_SHIFT 18 | ||
789 | +#define HCCHAR_LSPDDEV BIT(17) | ||
790 | +#define HCCHAR_EPDIR BIT(15) | ||
791 | +#define HCCHAR_EPNUM_MASK (0xf << 11) | ||
792 | +#define HCCHAR_EPNUM_SHIFT 11 | ||
793 | +#define HCCHAR_MPS_MASK (0x7ff << 0) | ||
794 | +#define HCCHAR_MPS_SHIFT 0 | ||
795 | + | ||
796 | +#define HCSPLT(_ch) HSOTG_REG(0x0504 + 0x20 * (_ch)) | ||
797 | +#define HCSPLT_SPLTENA BIT(31) | ||
798 | +#define HCSPLT_COMPSPLT BIT(16) | ||
799 | +#define HCSPLT_XACTPOS_MASK (0x3 << 14) | ||
800 | +#define HCSPLT_XACTPOS_SHIFT 14 | ||
801 | +#define HCSPLT_XACTPOS_MID 0 | ||
802 | +#define HCSPLT_XACTPOS_END 1 | ||
803 | +#define HCSPLT_XACTPOS_BEGIN 2 | ||
804 | +#define HCSPLT_XACTPOS_ALL 3 | ||
805 | +#define HCSPLT_HUBADDR_MASK (0x7f << 7) | ||
806 | +#define HCSPLT_HUBADDR_SHIFT 7 | ||
807 | +#define HCSPLT_PRTADDR_MASK (0x7f << 0) | ||
808 | +#define HCSPLT_PRTADDR_SHIFT 0 | ||
809 | + | ||
810 | +#define HCINT(_ch) HSOTG_REG(0x0508 + 0x20 * (_ch)) | ||
811 | +#define HCINTMSK(_ch) HSOTG_REG(0x050c + 0x20 * (_ch)) | ||
812 | +#define HCINTMSK_RESERVED14_31 (0x3ffff << 14) | ||
813 | +#define HCINTMSK_FRM_LIST_ROLL BIT(13) | ||
814 | +#define HCINTMSK_XCS_XACT BIT(12) | ||
815 | +#define HCINTMSK_BNA BIT(11) | ||
816 | +#define HCINTMSK_DATATGLERR BIT(10) | ||
817 | +#define HCINTMSK_FRMOVRUN BIT(9) | ||
818 | +#define HCINTMSK_BBLERR BIT(8) | ||
819 | +#define HCINTMSK_XACTERR BIT(7) | ||
820 | +#define HCINTMSK_NYET BIT(6) | ||
821 | +#define HCINTMSK_ACK BIT(5) | ||
822 | +#define HCINTMSK_NAK BIT(4) | ||
823 | +#define HCINTMSK_STALL BIT(3) | ||
824 | +#define HCINTMSK_AHBERR BIT(2) | ||
825 | +#define HCINTMSK_CHHLTD BIT(1) | ||
826 | +#define HCINTMSK_XFERCOMPL BIT(0) | ||
827 | + | ||
828 | +#define HCTSIZ(_ch) HSOTG_REG(0x0510 + 0x20 * (_ch)) | ||
829 | +#define TSIZ_DOPNG BIT(31) | ||
830 | +#define TSIZ_SC_MC_PID_MASK (0x3 << 29) | ||
831 | +#define TSIZ_SC_MC_PID_SHIFT 29 | ||
832 | +#define TSIZ_SC_MC_PID_DATA0 0 | ||
833 | +#define TSIZ_SC_MC_PID_DATA2 1 | ||
834 | +#define TSIZ_SC_MC_PID_DATA1 2 | ||
835 | +#define TSIZ_SC_MC_PID_MDATA 3 | ||
836 | +#define TSIZ_SC_MC_PID_SETUP 3 | ||
837 | +#define TSIZ_PKTCNT_MASK (0x3ff << 19) | ||
838 | +#define TSIZ_PKTCNT_SHIFT 19 | ||
839 | +#define TSIZ_NTD_MASK (0xff << 8) | ||
840 | +#define TSIZ_NTD_SHIFT 8 | ||
841 | +#define TSIZ_SCHINFO_MASK (0xff << 0) | ||
842 | +#define TSIZ_SCHINFO_SHIFT 0 | ||
843 | +#define TSIZ_XFERSIZE_MASK (0x7ffff << 0) | ||
844 | +#define TSIZ_XFERSIZE_SHIFT 0 | ||
845 | + | ||
846 | +#define HCDMA(_ch) HSOTG_REG(0x0514 + 0x20 * (_ch)) | ||
847 | + | ||
848 | +#define HCDMAB(_ch) HSOTG_REG(0x051c + 0x20 * (_ch)) | ||
849 | + | ||
850 | +#define HCFIFO(_ch) HSOTG_REG(0x1000 + 0x1000 * (_ch)) | ||
851 | + | ||
852 | +/** | ||
853 | + * struct dwc2_dma_desc - DMA descriptor structure, | ||
854 | + * used for both host and gadget modes | ||
855 | + * | ||
856 | + * @status: DMA descriptor status quadlet | ||
857 | + * @buf: DMA descriptor data buffer pointer | ||
858 | + * | ||
859 | + * DMA Descriptor structure contains two quadlets: | ||
860 | + * Status quadlet and Data buffer pointer. | ||
861 | + */ | ||
862 | +struct dwc2_dma_desc { | ||
863 | + uint32_t status; | ||
864 | + uint32_t buf; | ||
865 | +} __packed; | ||
866 | + | ||
867 | +/* Host Mode DMA descriptor status quadlet */ | ||
868 | + | ||
869 | +#define HOST_DMA_A BIT(31) | ||
870 | +#define HOST_DMA_STS_MASK (0x3 << 28) | ||
871 | +#define HOST_DMA_STS_SHIFT 28 | ||
872 | +#define HOST_DMA_STS_PKTERR BIT(28) | ||
873 | +#define HOST_DMA_EOL BIT(26) | ||
874 | +#define HOST_DMA_IOC BIT(25) | ||
875 | +#define HOST_DMA_SUP BIT(24) | ||
876 | +#define HOST_DMA_ALT_QTD BIT(23) | ||
877 | +#define HOST_DMA_QTD_OFFSET_MASK (0x3f << 17) | ||
878 | +#define HOST_DMA_QTD_OFFSET_SHIFT 17 | ||
879 | +#define HOST_DMA_ISOC_NBYTES_MASK (0xfff << 0) | ||
880 | +#define HOST_DMA_ISOC_NBYTES_SHIFT 0 | ||
881 | +#define HOST_DMA_NBYTES_MASK (0x1ffff << 0) | ||
882 | +#define HOST_DMA_NBYTES_SHIFT 0 | ||
883 | +#define HOST_DMA_NBYTES_LIMIT 131071 | ||
884 | + | ||
885 | +/* Device Mode DMA descriptor status quadlet */ | ||
886 | + | ||
887 | +#define DEV_DMA_BUFF_STS_MASK (0x3 << 30) | ||
888 | +#define DEV_DMA_BUFF_STS_SHIFT 30 | ||
889 | +#define DEV_DMA_BUFF_STS_HREADY 0 | ||
890 | +#define DEV_DMA_BUFF_STS_DMABUSY 1 | ||
891 | +#define DEV_DMA_BUFF_STS_DMADONE 2 | ||
892 | +#define DEV_DMA_BUFF_STS_HBUSY 3 | ||
893 | +#define DEV_DMA_STS_MASK (0x3 << 28) | ||
894 | +#define DEV_DMA_STS_SHIFT 28 | ||
895 | +#define DEV_DMA_STS_SUCC 0 | ||
896 | +#define DEV_DMA_STS_BUFF_FLUSH 1 | ||
897 | +#define DEV_DMA_STS_BUFF_ERR 3 | ||
898 | +#define DEV_DMA_L BIT(27) | ||
899 | +#define DEV_DMA_SHORT BIT(26) | ||
900 | +#define DEV_DMA_IOC BIT(25) | ||
901 | +#define DEV_DMA_SR BIT(24) | ||
902 | +#define DEV_DMA_MTRF BIT(23) | ||
903 | +#define DEV_DMA_ISOC_PID_MASK (0x3 << 23) | ||
904 | +#define DEV_DMA_ISOC_PID_SHIFT 23 | ||
905 | +#define DEV_DMA_ISOC_PID_DATA0 0 | ||
906 | +#define DEV_DMA_ISOC_PID_DATA2 1 | ||
907 | +#define DEV_DMA_ISOC_PID_DATA1 2 | ||
908 | +#define DEV_DMA_ISOC_PID_MDATA 3 | ||
909 | +#define DEV_DMA_ISOC_FRNUM_MASK (0x7ff << 12) | ||
910 | +#define DEV_DMA_ISOC_FRNUM_SHIFT 12 | ||
911 | +#define DEV_DMA_ISOC_TX_NBYTES_MASK (0xfff << 0) | ||
912 | +#define DEV_DMA_ISOC_TX_NBYTES_LIMIT 0xfff | ||
913 | +#define DEV_DMA_ISOC_RX_NBYTES_MASK (0x7ff << 0) | ||
914 | +#define DEV_DMA_ISOC_RX_NBYTES_LIMIT 0x7ff | ||
915 | +#define DEV_DMA_ISOC_NBYTES_SHIFT 0 | ||
916 | +#define DEV_DMA_NBYTES_MASK (0xffff << 0) | ||
917 | +#define DEV_DMA_NBYTES_SHIFT 0 | ||
918 | +#define DEV_DMA_NBYTES_LIMIT 0xffff | ||
919 | + | ||
920 | +#define MAX_DMA_DESC_NUM_GENERIC 64 | ||
921 | +#define MAX_DMA_DESC_NUM_HS_ISOC 256 | ||
922 | + | ||
923 | +#endif /* __DWC2_HW_H__ */ | ||
924 | -- | 123 | -- |
925 | 2.20.1 | 124 | 2.34.1 |
926 | |||
927 | diff view generated by jsdifflib |
1 | Convert the Neon narrowing shifts where op==8 to decodetree: | 1 | Mark up the sysreg definitons for the registers trapped |
---|---|---|---|
2 | * VSHRN | 2 | by HDFGRTR/HDFGWTR bits 0..11. These cover various debug |
3 | * VRSHRN | 3 | related registers. |
4 | * VQSHRUN | ||
5 | * VQRSHRUN | ||
6 | 4 | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
9 | Message-id: 20200522145520.6778-6-peter.maydell@linaro.org | 7 | Tested-by: Fuad Tabba <tabba@google.com> |
8 | Message-id: 20230130182459.3309057-15-peter.maydell@linaro.org | ||
9 | Message-id: 20230127175507.2895013-15-peter.maydell@linaro.org | ||
10 | --- | 10 | --- |
11 | target/arm/neon-dp.decode | 27 ++++++ | 11 | target/arm/cpregs.h | 12 ++++++++++++ |
12 | target/arm/translate-neon.inc.c | 167 ++++++++++++++++++++++++++++++++ | 12 | target/arm/debug_helper.c | 11 +++++++++++ |
13 | target/arm/translate.c | 1 + | 13 | 2 files changed, 23 insertions(+) |
14 | 3 files changed, 195 insertions(+) | ||
15 | 14 | ||
16 | diff --git a/target/arm/neon-dp.decode b/target/arm/neon-dp.decode | 15 | diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h |
17 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/target/arm/neon-dp.decode | 17 | --- a/target/arm/cpregs.h |
19 | +++ b/target/arm/neon-dp.decode | 18 | +++ b/target/arm/cpregs.h |
20 | @@ -XXX,XX +XXX,XX @@ VMINNM_fp_3s 1111 001 1 0 . 1 . .... .... 1111 ... 1 .... @3same_fp | 19 | @@ -XXX,XX +XXX,XX @@ typedef enum FGTBit { |
21 | @2reg_shl_b .... ... . . . 001 shift:3 .... .... 0 q:1 . . .... \ | 20 | DO_BIT(HFGRTR, ERRIDR_EL1), |
22 | &2reg_shift vm=%vm_dp vd=%vd_dp size=0 | 21 | DO_REV_BIT(HFGRTR, NSMPRI_EL1), |
23 | 22 | DO_REV_BIT(HFGRTR, NTPIDR2_EL0), | |
24 | +# Narrowing right shifts: here the Q bit is part of the opcode decode | ||
25 | +@2reg_shrn_d .... ... . . . 1 ..... .... .... 0 . . . .... \ | ||
26 | + &2reg_shift vm=%vm_dp vd=%vd_dp size=3 q=0 \ | ||
27 | + shift=%neon_rshift_i5 | ||
28 | +@2reg_shrn_s .... ... . . . 01 .... .... .... 0 . . . .... \ | ||
29 | + &2reg_shift vm=%vm_dp vd=%vd_dp size=2 q=0 \ | ||
30 | + shift=%neon_rshift_i4 | ||
31 | +@2reg_shrn_h .... ... . . . 001 ... .... .... 0 . . . .... \ | ||
32 | + &2reg_shift vm=%vm_dp vd=%vd_dp size=1 q=0 \ | ||
33 | + shift=%neon_rshift_i3 | ||
34 | + | 23 | + |
35 | VSHR_S_2sh 1111 001 0 1 . ...... .... 0000 . . . 1 .... @2reg_shr_d | 24 | + /* Trap bits in HDFGRTR_EL2 / HDFGWTR_EL2, starting from bit 0. */ |
36 | VSHR_S_2sh 1111 001 0 1 . ...... .... 0000 . . . 1 .... @2reg_shr_s | 25 | + DO_BIT(HDFGRTR, DBGBCRN_EL1), |
37 | VSHR_S_2sh 1111 001 0 1 . ...... .... 0000 . . . 1 .... @2reg_shr_h | 26 | + DO_BIT(HDFGRTR, DBGBVRN_EL1), |
38 | @@ -XXX,XX +XXX,XX @@ VQSHL_U_64_2sh 1111 001 1 1 . ...... .... 0111 . . . 1 .... @2reg_shl_d | 27 | + DO_BIT(HDFGRTR, DBGWCRN_EL1), |
39 | VQSHL_U_2sh 1111 001 1 1 . ...... .... 0111 . . . 1 .... @2reg_shl_s | 28 | + DO_BIT(HDFGRTR, DBGWVRN_EL1), |
40 | VQSHL_U_2sh 1111 001 1 1 . ...... .... 0111 . . . 1 .... @2reg_shl_h | 29 | + DO_BIT(HDFGRTR, MDSCR_EL1), |
41 | VQSHL_U_2sh 1111 001 1 1 . ...... .... 0111 . . . 1 .... @2reg_shl_b | 30 | + DO_BIT(HDFGRTR, DBGCLAIM), |
42 | + | 31 | + DO_BIT(HDFGWTR, OSLAR_EL1), |
43 | +VSHRN_64_2sh 1111 001 0 1 . ...... .... 1000 . 0 . 1 .... @2reg_shrn_d | 32 | + DO_BIT(HDFGRTR, OSLSR_EL1), |
44 | +VSHRN_32_2sh 1111 001 0 1 . ...... .... 1000 . 0 . 1 .... @2reg_shrn_s | 33 | + DO_BIT(HDFGRTR, OSECCR_EL1), |
45 | +VSHRN_16_2sh 1111 001 0 1 . ...... .... 1000 . 0 . 1 .... @2reg_shrn_h | 34 | + DO_BIT(HDFGRTR, OSDLR_EL1), |
46 | + | 35 | } FGTBit; |
47 | +VRSHRN_64_2sh 1111 001 0 1 . ...... .... 1000 . 1 . 1 .... @2reg_shrn_d | 36 | |
48 | +VRSHRN_32_2sh 1111 001 0 1 . ...... .... 1000 . 1 . 1 .... @2reg_shrn_s | 37 | #undef DO_BIT |
49 | +VRSHRN_16_2sh 1111 001 0 1 . ...... .... 1000 . 1 . 1 .... @2reg_shrn_h | 38 | diff --git a/target/arm/debug_helper.c b/target/arm/debug_helper.c |
50 | + | ||
51 | +VQSHRUN_64_2sh 1111 001 1 1 . ...... .... 1000 . 0 . 1 .... @2reg_shrn_d | ||
52 | +VQSHRUN_32_2sh 1111 001 1 1 . ...... .... 1000 . 0 . 1 .... @2reg_shrn_s | ||
53 | +VQSHRUN_16_2sh 1111 001 1 1 . ...... .... 1000 . 0 . 1 .... @2reg_shrn_h | ||
54 | + | ||
55 | +VQRSHRUN_64_2sh 1111 001 1 1 . ...... .... 1000 . 1 . 1 .... @2reg_shrn_d | ||
56 | +VQRSHRUN_32_2sh 1111 001 1 1 . ...... .... 1000 . 1 . 1 .... @2reg_shrn_s | ||
57 | +VQRSHRUN_16_2sh 1111 001 1 1 . ...... .... 1000 . 1 . 1 .... @2reg_shrn_h | ||
58 | diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c | ||
59 | index XXXXXXX..XXXXXXX 100644 | 39 | index XXXXXXX..XXXXXXX 100644 |
60 | --- a/target/arm/translate-neon.inc.c | 40 | --- a/target/arm/debug_helper.c |
61 | +++ b/target/arm/translate-neon.inc.c | 41 | +++ b/target/arm/debug_helper.c |
62 | @@ -XXX,XX +XXX,XX @@ static bool do_2shift_env_32(DisasContext *s, arg_2reg_shift *a, | 42 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo debug_cp_reginfo[] = { |
63 | DO_2SHIFT_ENV(VQSHLU, qshlu_s) | 43 | { .name = "MDSCR_EL1", .state = ARM_CP_STATE_BOTH, |
64 | DO_2SHIFT_ENV(VQSHL_U, qshl_u) | 44 | .cp = 14, .opc0 = 2, .opc1 = 0, .crn = 0, .crm = 2, .opc2 = 2, |
65 | DO_2SHIFT_ENV(VQSHL_S, qshl_s) | 45 | .access = PL1_RW, .accessfn = access_tda, |
66 | + | 46 | + .fgt = FGT_MDSCR_EL1, |
67 | +static bool do_2shift_narrow_64(DisasContext *s, arg_2reg_shift *a, | 47 | .fieldoffset = offsetof(CPUARMState, cp15.mdscr_el1), |
68 | + NeonGenTwo64OpFn *shiftfn, | 48 | .resetvalue = 0 }, |
69 | + NeonGenNarrowEnvFn *narrowfn) | 49 | /* |
70 | +{ | 50 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo debug_cp_reginfo[] = { |
71 | + /* 2-reg-and-shift narrowing-shift operations, size == 3 case */ | 51 | { .name = "OSECCR_EL1", .state = ARM_CP_STATE_BOTH, .cp = 14, |
72 | + TCGv_i64 constimm, rm1, rm2; | 52 | .opc0 = 2, .opc1 = 0, .crn = 0, .crm = 6, .opc2 = 2, |
73 | + TCGv_i32 rd; | 53 | .access = PL1_RW, .accessfn = access_tda, |
74 | + | 54 | + .fgt = FGT_OSECCR_EL1, |
75 | + if (!arm_dc_feature(s, ARM_FEATURE_NEON)) { | 55 | .type = ARM_CP_CONST, .resetvalue = 0 }, |
76 | + return false; | 56 | /* |
77 | + } | 57 | * DBGDSCRint[15,12,5:2] map to MDSCR_EL1[15,12,5:2]. Map all bits as |
78 | + | 58 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo debug_cp_reginfo[] = { |
79 | + /* UNDEF accesses to D16-D31 if they don't exist. */ | 59 | .cp = 14, .opc0 = 2, .opc1 = 0, .crn = 1, .crm = 0, .opc2 = 4, |
80 | + if (!dc_isar_feature(aa32_simd_r32, s) && | 60 | .access = PL1_W, .type = ARM_CP_NO_RAW, |
81 | + ((a->vd | a->vm) & 0x10)) { | 61 | .accessfn = access_tdosa, |
82 | + return false; | 62 | + .fgt = FGT_OSLAR_EL1, |
83 | + } | 63 | .writefn = oslar_write }, |
84 | + | 64 | { .name = "OSLSR_EL1", .state = ARM_CP_STATE_BOTH, |
85 | + if (a->vm & 1) { | 65 | .cp = 14, .opc0 = 2, .opc1 = 0, .crn = 1, .crm = 1, .opc2 = 4, |
86 | + return false; | 66 | .access = PL1_R, .resetvalue = 10, |
87 | + } | 67 | .accessfn = access_tdosa, |
88 | + | 68 | + .fgt = FGT_OSLSR_EL1, |
89 | + if (!vfp_access_check(s)) { | 69 | .fieldoffset = offsetof(CPUARMState, cp15.oslsr_el1) }, |
90 | + return true; | 70 | /* Dummy OSDLR_EL1: 32-bit Linux will read this */ |
91 | + } | 71 | { .name = "OSDLR_EL1", .state = ARM_CP_STATE_BOTH, |
92 | + | 72 | .cp = 14, .opc0 = 2, .opc1 = 0, .crn = 1, .crm = 3, .opc2 = 4, |
93 | + /* | 73 | .access = PL1_RW, .accessfn = access_tdosa, |
94 | + * This is always a right shift, and the shiftfn is always a | 74 | + .fgt = FGT_OSDLR_EL1, |
95 | + * left-shift helper, which thus needs the negated shift count. | 75 | .writefn = osdlr_write, |
96 | + */ | 76 | .fieldoffset = offsetof(CPUARMState, cp15.osdlr_el1) }, |
97 | + constimm = tcg_const_i64(-a->shift); | 77 | /* |
98 | + rm1 = tcg_temp_new_i64(); | 78 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo debug_cp_reginfo[] = { |
99 | + rm2 = tcg_temp_new_i64(); | 79 | .cp = 14, .opc0 = 2, .opc1 = 0, .crn = 7, .crm = 8, .opc2 = 6, |
100 | + | 80 | .type = ARM_CP_ALIAS, |
101 | + /* Load both inputs first to avoid potential overwrite if rm == rd */ | 81 | .access = PL1_RW, .accessfn = access_tda, |
102 | + neon_load_reg64(rm1, a->vm); | 82 | + .fgt = FGT_DBGCLAIM, |
103 | + neon_load_reg64(rm2, a->vm + 1); | 83 | .writefn = dbgclaimset_write, .readfn = dbgclaimset_read }, |
104 | + | 84 | { .name = "DBGCLAIMCLR_EL1", .state = ARM_CP_STATE_BOTH, |
105 | + shiftfn(rm1, rm1, constimm); | 85 | .cp = 14, .opc0 = 2, .opc1 = 0, .crn = 7, .crm = 9, .opc2 = 6, |
106 | + rd = tcg_temp_new_i32(); | 86 | .access = PL1_RW, .accessfn = access_tda, |
107 | + narrowfn(rd, cpu_env, rm1); | 87 | + .fgt = FGT_DBGCLAIM, |
108 | + neon_store_reg(a->vd, 0, rd); | 88 | .writefn = dbgclaimclr_write, .raw_writefn = raw_write, |
109 | + | 89 | .fieldoffset = offsetof(CPUARMState, cp15.dbgclaim) }, |
110 | + shiftfn(rm2, rm2, constimm); | 90 | }; |
111 | + rd = tcg_temp_new_i32(); | 91 | @@ -XXX,XX +XXX,XX @@ void define_debug_regs(ARMCPU *cpu) |
112 | + narrowfn(rd, cpu_env, rm2); | 92 | { .name = dbgbvr_el1_name, .state = ARM_CP_STATE_BOTH, |
113 | + neon_store_reg(a->vd, 1, rd); | 93 | .cp = 14, .opc0 = 2, .opc1 = 0, .crn = 0, .crm = i, .opc2 = 4, |
114 | + | 94 | .access = PL1_RW, .accessfn = access_tda, |
115 | + tcg_temp_free_i64(rm1); | 95 | + .fgt = FGT_DBGBVRN_EL1, |
116 | + tcg_temp_free_i64(rm2); | 96 | .fieldoffset = offsetof(CPUARMState, cp15.dbgbvr[i]), |
117 | + tcg_temp_free_i64(constimm); | 97 | .writefn = dbgbvr_write, .raw_writefn = raw_write |
118 | + | 98 | }, |
119 | + return true; | 99 | { .name = dbgbcr_el1_name, .state = ARM_CP_STATE_BOTH, |
120 | +} | 100 | .cp = 14, .opc0 = 2, .opc1 = 0, .crn = 0, .crm = i, .opc2 = 5, |
121 | + | 101 | .access = PL1_RW, .accessfn = access_tda, |
122 | +static bool do_2shift_narrow_32(DisasContext *s, arg_2reg_shift *a, | 102 | + .fgt = FGT_DBGBCRN_EL1, |
123 | + NeonGenTwoOpFn *shiftfn, | 103 | .fieldoffset = offsetof(CPUARMState, cp15.dbgbcr[i]), |
124 | + NeonGenNarrowEnvFn *narrowfn) | 104 | .writefn = dbgbcr_write, .raw_writefn = raw_write |
125 | +{ | 105 | }, |
126 | + /* 2-reg-and-shift narrowing-shift operations, size < 3 case */ | 106 | @@ -XXX,XX +XXX,XX @@ void define_debug_regs(ARMCPU *cpu) |
127 | + TCGv_i32 constimm, rm1, rm2, rm3, rm4; | 107 | { .name = dbgwvr_el1_name, .state = ARM_CP_STATE_BOTH, |
128 | + TCGv_i64 rtmp; | 108 | .cp = 14, .opc0 = 2, .opc1 = 0, .crn = 0, .crm = i, .opc2 = 6, |
129 | + uint32_t imm; | 109 | .access = PL1_RW, .accessfn = access_tda, |
130 | + | 110 | + .fgt = FGT_DBGWVRN_EL1, |
131 | + if (!arm_dc_feature(s, ARM_FEATURE_NEON)) { | 111 | .fieldoffset = offsetof(CPUARMState, cp15.dbgwvr[i]), |
132 | + return false; | 112 | .writefn = dbgwvr_write, .raw_writefn = raw_write |
133 | + } | 113 | }, |
134 | + | 114 | { .name = dbgwcr_el1_name, .state = ARM_CP_STATE_BOTH, |
135 | + /* UNDEF accesses to D16-D31 if they don't exist. */ | 115 | .cp = 14, .opc0 = 2, .opc1 = 0, .crn = 0, .crm = i, .opc2 = 7, |
136 | + if (!dc_isar_feature(aa32_simd_r32, s) && | 116 | .access = PL1_RW, .accessfn = access_tda, |
137 | + ((a->vd | a->vm) & 0x10)) { | 117 | + .fgt = FGT_DBGWCRN_EL1, |
138 | + return false; | 118 | .fieldoffset = offsetof(CPUARMState, cp15.dbgwcr[i]), |
139 | + } | 119 | .writefn = dbgwcr_write, .raw_writefn = raw_write |
140 | + | 120 | }, |
141 | + if (a->vm & 1) { | ||
142 | + return false; | ||
143 | + } | ||
144 | + | ||
145 | + if (!vfp_access_check(s)) { | ||
146 | + return true; | ||
147 | + } | ||
148 | + | ||
149 | + /* | ||
150 | + * This is always a right shift, and the shiftfn is always a | ||
151 | + * left-shift helper, which thus needs the negated shift count | ||
152 | + * duplicated into each lane of the immediate value. | ||
153 | + */ | ||
154 | + if (a->size == 1) { | ||
155 | + imm = (uint16_t)(-a->shift); | ||
156 | + imm |= imm << 16; | ||
157 | + } else { | ||
158 | + /* size == 2 */ | ||
159 | + imm = -a->shift; | ||
160 | + } | ||
161 | + constimm = tcg_const_i32(imm); | ||
162 | + | ||
163 | + /* Load all inputs first to avoid potential overwrite */ | ||
164 | + rm1 = neon_load_reg(a->vm, 0); | ||
165 | + rm2 = neon_load_reg(a->vm, 1); | ||
166 | + rm3 = neon_load_reg(a->vm + 1, 0); | ||
167 | + rm4 = neon_load_reg(a->vm + 1, 1); | ||
168 | + rtmp = tcg_temp_new_i64(); | ||
169 | + | ||
170 | + shiftfn(rm1, rm1, constimm); | ||
171 | + shiftfn(rm2, rm2, constimm); | ||
172 | + | ||
173 | + tcg_gen_concat_i32_i64(rtmp, rm1, rm2); | ||
174 | + tcg_temp_free_i32(rm2); | ||
175 | + | ||
176 | + narrowfn(rm1, cpu_env, rtmp); | ||
177 | + neon_store_reg(a->vd, 0, rm1); | ||
178 | + | ||
179 | + shiftfn(rm3, rm3, constimm); | ||
180 | + shiftfn(rm4, rm4, constimm); | ||
181 | + tcg_temp_free_i32(constimm); | ||
182 | + | ||
183 | + tcg_gen_concat_i32_i64(rtmp, rm3, rm4); | ||
184 | + tcg_temp_free_i32(rm4); | ||
185 | + | ||
186 | + narrowfn(rm3, cpu_env, rtmp); | ||
187 | + tcg_temp_free_i64(rtmp); | ||
188 | + neon_store_reg(a->vd, 1, rm3); | ||
189 | + return true; | ||
190 | +} | ||
191 | + | ||
192 | +#define DO_2SN_64(INSN, FUNC, NARROWFUNC) \ | ||
193 | + static bool trans_##INSN##_2sh(DisasContext *s, arg_2reg_shift *a) \ | ||
194 | + { \ | ||
195 | + return do_2shift_narrow_64(s, a, FUNC, NARROWFUNC); \ | ||
196 | + } | ||
197 | +#define DO_2SN_32(INSN, FUNC, NARROWFUNC) \ | ||
198 | + static bool trans_##INSN##_2sh(DisasContext *s, arg_2reg_shift *a) \ | ||
199 | + { \ | ||
200 | + return do_2shift_narrow_32(s, a, FUNC, NARROWFUNC); \ | ||
201 | + } | ||
202 | + | ||
203 | +static void gen_neon_narrow_u32(TCGv_i32 dest, TCGv_ptr env, TCGv_i64 src) | ||
204 | +{ | ||
205 | + tcg_gen_extrl_i64_i32(dest, src); | ||
206 | +} | ||
207 | + | ||
208 | +static void gen_neon_narrow_u16(TCGv_i32 dest, TCGv_ptr env, TCGv_i64 src) | ||
209 | +{ | ||
210 | + gen_helper_neon_narrow_u16(dest, src); | ||
211 | +} | ||
212 | + | ||
213 | +static void gen_neon_narrow_u8(TCGv_i32 dest, TCGv_ptr env, TCGv_i64 src) | ||
214 | +{ | ||
215 | + gen_helper_neon_narrow_u8(dest, src); | ||
216 | +} | ||
217 | + | ||
218 | +DO_2SN_64(VSHRN_64, gen_ushl_i64, gen_neon_narrow_u32) | ||
219 | +DO_2SN_32(VSHRN_32, gen_ushl_i32, gen_neon_narrow_u16) | ||
220 | +DO_2SN_32(VSHRN_16, gen_helper_neon_shl_u16, gen_neon_narrow_u8) | ||
221 | + | ||
222 | +DO_2SN_64(VRSHRN_64, gen_helper_neon_rshl_u64, gen_neon_narrow_u32) | ||
223 | +DO_2SN_32(VRSHRN_32, gen_helper_neon_rshl_u32, gen_neon_narrow_u16) | ||
224 | +DO_2SN_32(VRSHRN_16, gen_helper_neon_rshl_u16, gen_neon_narrow_u8) | ||
225 | + | ||
226 | +DO_2SN_64(VQSHRUN_64, gen_sshl_i64, gen_helper_neon_unarrow_sat32) | ||
227 | +DO_2SN_32(VQSHRUN_32, gen_sshl_i32, gen_helper_neon_unarrow_sat16) | ||
228 | +DO_2SN_32(VQSHRUN_16, gen_helper_neon_shl_s16, gen_helper_neon_unarrow_sat8) | ||
229 | + | ||
230 | +DO_2SN_64(VQRSHRUN_64, gen_helper_neon_rshl_s64, gen_helper_neon_unarrow_sat32) | ||
231 | +DO_2SN_32(VQRSHRUN_32, gen_helper_neon_rshl_s32, gen_helper_neon_unarrow_sat16) | ||
232 | +DO_2SN_32(VQRSHRUN_16, gen_helper_neon_rshl_s16, gen_helper_neon_unarrow_sat8) | ||
233 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
234 | index XXXXXXX..XXXXXXX 100644 | ||
235 | --- a/target/arm/translate.c | ||
236 | +++ b/target/arm/translate.c | ||
237 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
238 | case 5: /* VSHL, VSLI */ | ||
239 | case 6: /* VQSHLU */ | ||
240 | case 7: /* VQSHL */ | ||
241 | + case 8: /* VSHRN, VRSHRN, VQSHRUN, VQRSHRUN */ | ||
242 | return 1; /* handled by decodetree */ | ||
243 | default: | ||
244 | break; | ||
245 | -- | 121 | -- |
246 | 2.20.1 | 122 | 2.34.1 |
247 | |||
248 | diff view generated by jsdifflib |
1 | From: Cédric Le Goater <clg@kaod.org> | 1 | Mark up the sysreg definitions for the registers trapped |
---|---|---|---|
2 | 2 | by HDFGRTR/HDFGWTR bits 12..x. | |
3 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | 3 | |
4 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 4 | Bits 12..22 and bit 58 are for PMU registers. |
5 | Message-id: 20200602135050.593692-1-clg@kaod.org | 5 | |
6 | The remaining bits in HDFGRTR/HDFGWTR are for traps on | ||
7 | registers that are part of features we don't implement: | ||
8 | |||
9 | Bits 23..32 and 63 : FEAT_SPE | ||
10 | Bits 33..48 : FEAT_ETE | ||
11 | Bits 50..56 : FEAT_TRBE | ||
12 | Bits 59..61 : FEAT_BRBE | ||
13 | Bit 62 : FEAT_SPEv1p2. | ||
14 | |||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
16 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
17 | Tested-by: Fuad Tabba <tabba@google.com> | ||
18 | Message-id: 20230130182459.3309057-16-peter.maydell@linaro.org | ||
19 | Message-id: 20230127175507.2895013-16-peter.maydell@linaro.org | ||
7 | --- | 20 | --- |
8 | docs/system/arm/aspeed.rst | 85 ++++++++++++++++++++++++++++++++++++++ | 21 | target/arm/cpregs.h | 12 ++++++++++++ |
9 | docs/system/target-arm.rst | 1 + | 22 | target/arm/helper.c | 37 +++++++++++++++++++++++++++++++++++++ |
10 | 2 files changed, 86 insertions(+) | 23 | 2 files changed, 49 insertions(+) |
11 | create mode 100644 docs/system/arm/aspeed.rst | 24 | |
12 | 25 | diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h | |
13 | diff --git a/docs/system/arm/aspeed.rst b/docs/system/arm/aspeed.rst | ||
14 | new file mode 100644 | ||
15 | index XXXXXXX..XXXXXXX | ||
16 | --- /dev/null | ||
17 | +++ b/docs/system/arm/aspeed.rst | ||
18 | @@ -XXX,XX +XXX,XX @@ | ||
19 | +Aspeed family boards (``*-bmc``, ``ast2500-evb``, ``ast2600-evb``) | ||
20 | +================================================================== | ||
21 | + | ||
22 | +The QEMU Aspeed machines model BMCs of various OpenPOWER systems and | ||
23 | +Aspeed evaluation boards. They are based on different releases of the | ||
24 | +Aspeed SoC : the AST2400 integrating an ARM926EJ-S CPU (400MHz), the | ||
25 | +AST2500 with an ARM1176JZS CPU (800MHz) and more recently the AST2600 | ||
26 | +with dual cores ARM Cortex A7 CPUs (1.2GHz). | ||
27 | + | ||
28 | +The SoC comes with RAM, Gigabit ethernet, USB, SD/MMC, USB, SPI, I2C, | ||
29 | +etc. | ||
30 | + | ||
31 | +AST2400 SoC based machines : | ||
32 | + | ||
33 | +- ``palmetto-bmc`` OpenPOWER Palmetto POWER8 BMC | ||
34 | + | ||
35 | +AST2500 SoC based machines : | ||
36 | + | ||
37 | +- ``ast2500-evb`` Aspeed AST2500 Evaluation board | ||
38 | +- ``romulus-bmc`` OpenPOWER Romulus POWER9 BMC | ||
39 | +- ``witherspoon-bmc`` OpenPOWER Witherspoon POWER9 BMC | ||
40 | +- ``sonorapass-bmc`` OCP SonoraPass BMC | ||
41 | +- ``swift-bmc`` OpenPOWER Swift BMC POWER9 | ||
42 | + | ||
43 | +AST2600 SoC based machines : | ||
44 | + | ||
45 | +- ``ast2600-evb`` Aspeed AST2600 Evaluation board (Cortex A7) | ||
46 | +- ``tacoma-bmc`` OpenPOWER Witherspoon POWER9 AST2600 BMC | ||
47 | + | ||
48 | +Supported devices | ||
49 | +----------------- | ||
50 | + | ||
51 | + * SMP (for the AST2600 Cortex-A7) | ||
52 | + * Interrupt Controller (VIC) | ||
53 | + * Timer Controller | ||
54 | + * RTC Controller | ||
55 | + * I2C Controller | ||
56 | + * System Control Unit (SCU) | ||
57 | + * SRAM mapping | ||
58 | + * X-DMA Controller (basic interface) | ||
59 | + * Static Memory Controller (SMC or FMC) - Only SPI Flash support | ||
60 | + * SPI Memory Controller | ||
61 | + * USB 2.0 Controller | ||
62 | + * SD/MMC storage controllers | ||
63 | + * SDRAM controller (dummy interface for basic settings and training) | ||
64 | + * Watchdog Controller | ||
65 | + * GPIO Controller (Master only) | ||
66 | + * UART | ||
67 | + * Ethernet controllers | ||
68 | + | ||
69 | + | ||
70 | +Missing devices | ||
71 | +--------------- | ||
72 | + | ||
73 | + * Coprocessor support | ||
74 | + * ADC (out of tree implementation) | ||
75 | + * PWM and Fan Controller | ||
76 | + * LPC Bus Controller | ||
77 | + * Slave GPIO Controller | ||
78 | + * Super I/O Controller | ||
79 | + * Hash/Crypto Engine | ||
80 | + * PCI-Express 1 Controller | ||
81 | + * Graphic Display Controller | ||
82 | + * PECI Controller | ||
83 | + * MCTP Controller | ||
84 | + * Mailbox Controller | ||
85 | + * Virtual UART | ||
86 | + * eSPI Controller | ||
87 | + * I3C Controller | ||
88 | + | ||
89 | +Boot options | ||
90 | +------------ | ||
91 | + | ||
92 | +The Aspeed machines can be started using the -kernel option to load a | ||
93 | +Linux kernel or from a firmare image which can be downloaded from the | ||
94 | +OpenPOWER jenkins : | ||
95 | + | ||
96 | + https://openpower.xyz/ | ||
97 | + | ||
98 | +The image should be attached as an MTD drive. Run : | ||
99 | + | ||
100 | +.. code-block:: bash | ||
101 | + | ||
102 | + $ qemu-system-arm -M romulus-bmc -nic user \ | ||
103 | + -drive file=flash-romulus,format=raw,if=mtd -nographic | ||
104 | diff --git a/docs/system/target-arm.rst b/docs/system/target-arm.rst | ||
105 | index XXXXXXX..XXXXXXX 100644 | 26 | index XXXXXXX..XXXXXXX 100644 |
106 | --- a/docs/system/target-arm.rst | 27 | --- a/target/arm/cpregs.h |
107 | +++ b/docs/system/target-arm.rst | 28 | +++ b/target/arm/cpregs.h |
108 | @@ -XXX,XX +XXX,XX @@ undocumented; you can get a complete list by running | 29 | @@ -XXX,XX +XXX,XX @@ typedef enum FGTBit { |
109 | arm/realview | 30 | DO_BIT(HDFGRTR, OSLSR_EL1), |
110 | arm/versatile | 31 | DO_BIT(HDFGRTR, OSECCR_EL1), |
111 | arm/vexpress | 32 | DO_BIT(HDFGRTR, OSDLR_EL1), |
112 | + arm/aspeed | 33 | + DO_BIT(HDFGRTR, PMEVCNTRN_EL0), |
113 | arm/musicpal | 34 | + DO_BIT(HDFGRTR, PMEVTYPERN_EL0), |
114 | arm/nseries | 35 | + DO_BIT(HDFGRTR, PMCCFILTR_EL0), |
115 | arm/orangepi | 36 | + DO_BIT(HDFGRTR, PMCCNTR_EL0), |
37 | + DO_BIT(HDFGRTR, PMCNTEN), | ||
38 | + DO_BIT(HDFGRTR, PMINTEN), | ||
39 | + DO_BIT(HDFGRTR, PMOVS), | ||
40 | + DO_BIT(HDFGRTR, PMSELR_EL0), | ||
41 | + DO_BIT(HDFGWTR, PMSWINC_EL0), | ||
42 | + DO_BIT(HDFGWTR, PMCR_EL0), | ||
43 | + DO_BIT(HDFGRTR, PMMIR_EL1), | ||
44 | + DO_BIT(HDFGRTR, PMCEIDN_EL0), | ||
45 | } FGTBit; | ||
46 | |||
47 | #undef DO_BIT | ||
48 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
49 | index XXXXXXX..XXXXXXX 100644 | ||
50 | --- a/target/arm/helper.c | ||
51 | +++ b/target/arm/helper.c | ||
52 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v7_cp_reginfo[] = { | ||
53 | .fieldoffset = offsetoflow32(CPUARMState, cp15.c9_pmcnten), | ||
54 | .writefn = pmcntenset_write, | ||
55 | .accessfn = pmreg_access, | ||
56 | + .fgt = FGT_PMCNTEN, | ||
57 | .raw_writefn = raw_write }, | ||
58 | { .name = "PMCNTENSET_EL0", .state = ARM_CP_STATE_AA64, .type = ARM_CP_IO, | ||
59 | .opc0 = 3, .opc1 = 3, .crn = 9, .crm = 12, .opc2 = 1, | ||
60 | .access = PL0_RW, .accessfn = pmreg_access, | ||
61 | + .fgt = FGT_PMCNTEN, | ||
62 | .fieldoffset = offsetof(CPUARMState, cp15.c9_pmcnten), .resetvalue = 0, | ||
63 | .writefn = pmcntenset_write, .raw_writefn = raw_write }, | ||
64 | { .name = "PMCNTENCLR", .cp = 15, .crn = 9, .crm = 12, .opc1 = 0, .opc2 = 2, | ||
65 | .access = PL0_RW, | ||
66 | .fieldoffset = offsetoflow32(CPUARMState, cp15.c9_pmcnten), | ||
67 | .accessfn = pmreg_access, | ||
68 | + .fgt = FGT_PMCNTEN, | ||
69 | .writefn = pmcntenclr_write, | ||
70 | .type = ARM_CP_ALIAS | ARM_CP_IO }, | ||
71 | { .name = "PMCNTENCLR_EL0", .state = ARM_CP_STATE_AA64, | ||
72 | .opc0 = 3, .opc1 = 3, .crn = 9, .crm = 12, .opc2 = 2, | ||
73 | .access = PL0_RW, .accessfn = pmreg_access, | ||
74 | + .fgt = FGT_PMCNTEN, | ||
75 | .type = ARM_CP_ALIAS | ARM_CP_IO, | ||
76 | .fieldoffset = offsetof(CPUARMState, cp15.c9_pmcnten), | ||
77 | .writefn = pmcntenclr_write }, | ||
78 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v7_cp_reginfo[] = { | ||
79 | .access = PL0_RW, .type = ARM_CP_IO, | ||
80 | .fieldoffset = offsetoflow32(CPUARMState, cp15.c9_pmovsr), | ||
81 | .accessfn = pmreg_access, | ||
82 | + .fgt = FGT_PMOVS, | ||
83 | .writefn = pmovsr_write, | ||
84 | .raw_writefn = raw_write }, | ||
85 | { .name = "PMOVSCLR_EL0", .state = ARM_CP_STATE_AA64, | ||
86 | .opc0 = 3, .opc1 = 3, .crn = 9, .crm = 12, .opc2 = 3, | ||
87 | .access = PL0_RW, .accessfn = pmreg_access, | ||
88 | + .fgt = FGT_PMOVS, | ||
89 | .type = ARM_CP_ALIAS | ARM_CP_IO, | ||
90 | .fieldoffset = offsetof(CPUARMState, cp15.c9_pmovsr), | ||
91 | .writefn = pmovsr_write, | ||
92 | .raw_writefn = raw_write }, | ||
93 | { .name = "PMSWINC", .cp = 15, .crn = 9, .crm = 12, .opc1 = 0, .opc2 = 4, | ||
94 | .access = PL0_W, .accessfn = pmreg_access_swinc, | ||
95 | + .fgt = FGT_PMSWINC_EL0, | ||
96 | .type = ARM_CP_NO_RAW | ARM_CP_IO, | ||
97 | .writefn = pmswinc_write }, | ||
98 | { .name = "PMSWINC_EL0", .state = ARM_CP_STATE_AA64, | ||
99 | .opc0 = 3, .opc1 = 3, .crn = 9, .crm = 12, .opc2 = 4, | ||
100 | .access = PL0_W, .accessfn = pmreg_access_swinc, | ||
101 | + .fgt = FGT_PMSWINC_EL0, | ||
102 | .type = ARM_CP_NO_RAW | ARM_CP_IO, | ||
103 | .writefn = pmswinc_write }, | ||
104 | { .name = "PMSELR", .cp = 15, .crn = 9, .crm = 12, .opc1 = 0, .opc2 = 5, | ||
105 | .access = PL0_RW, .type = ARM_CP_ALIAS, | ||
106 | + .fgt = FGT_PMSELR_EL0, | ||
107 | .fieldoffset = offsetoflow32(CPUARMState, cp15.c9_pmselr), | ||
108 | .accessfn = pmreg_access_selr, .writefn = pmselr_write, | ||
109 | .raw_writefn = raw_write}, | ||
110 | { .name = "PMSELR_EL0", .state = ARM_CP_STATE_AA64, | ||
111 | .opc0 = 3, .opc1 = 3, .crn = 9, .crm = 12, .opc2 = 5, | ||
112 | .access = PL0_RW, .accessfn = pmreg_access_selr, | ||
113 | + .fgt = FGT_PMSELR_EL0, | ||
114 | .fieldoffset = offsetof(CPUARMState, cp15.c9_pmselr), | ||
115 | .writefn = pmselr_write, .raw_writefn = raw_write, }, | ||
116 | { .name = "PMCCNTR", .cp = 15, .crn = 9, .crm = 13, .opc1 = 0, .opc2 = 0, | ||
117 | .access = PL0_RW, .resetvalue = 0, .type = ARM_CP_ALIAS | ARM_CP_IO, | ||
118 | + .fgt = FGT_PMCCNTR_EL0, | ||
119 | .readfn = pmccntr_read, .writefn = pmccntr_write32, | ||
120 | .accessfn = pmreg_access_ccntr }, | ||
121 | { .name = "PMCCNTR_EL0", .state = ARM_CP_STATE_AA64, | ||
122 | .opc0 = 3, .opc1 = 3, .crn = 9, .crm = 13, .opc2 = 0, | ||
123 | .access = PL0_RW, .accessfn = pmreg_access_ccntr, | ||
124 | + .fgt = FGT_PMCCNTR_EL0, | ||
125 | .type = ARM_CP_IO, | ||
126 | .fieldoffset = offsetof(CPUARMState, cp15.c15_ccnt), | ||
127 | .readfn = pmccntr_read, .writefn = pmccntr_write, | ||
128 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v7_cp_reginfo[] = { | ||
129 | { .name = "PMCCFILTR", .cp = 15, .opc1 = 0, .crn = 14, .crm = 15, .opc2 = 7, | ||
130 | .writefn = pmccfiltr_write_a32, .readfn = pmccfiltr_read_a32, | ||
131 | .access = PL0_RW, .accessfn = pmreg_access, | ||
132 | + .fgt = FGT_PMCCFILTR_EL0, | ||
133 | .type = ARM_CP_ALIAS | ARM_CP_IO, | ||
134 | .resetvalue = 0, }, | ||
135 | { .name = "PMCCFILTR_EL0", .state = ARM_CP_STATE_AA64, | ||
136 | .opc0 = 3, .opc1 = 3, .crn = 14, .crm = 15, .opc2 = 7, | ||
137 | .writefn = pmccfiltr_write, .raw_writefn = raw_write, | ||
138 | .access = PL0_RW, .accessfn = pmreg_access, | ||
139 | + .fgt = FGT_PMCCFILTR_EL0, | ||
140 | .type = ARM_CP_IO, | ||
141 | .fieldoffset = offsetof(CPUARMState, cp15.pmccfiltr_el0), | ||
142 | .resetvalue = 0, }, | ||
143 | { .name = "PMXEVTYPER", .cp = 15, .crn = 9, .crm = 13, .opc1 = 0, .opc2 = 1, | ||
144 | .access = PL0_RW, .type = ARM_CP_NO_RAW | ARM_CP_IO, | ||
145 | .accessfn = pmreg_access, | ||
146 | + .fgt = FGT_PMEVTYPERN_EL0, | ||
147 | .writefn = pmxevtyper_write, .readfn = pmxevtyper_read }, | ||
148 | { .name = "PMXEVTYPER_EL0", .state = ARM_CP_STATE_AA64, | ||
149 | .opc0 = 3, .opc1 = 3, .crn = 9, .crm = 13, .opc2 = 1, | ||
150 | .access = PL0_RW, .type = ARM_CP_NO_RAW | ARM_CP_IO, | ||
151 | .accessfn = pmreg_access, | ||
152 | + .fgt = FGT_PMEVTYPERN_EL0, | ||
153 | .writefn = pmxevtyper_write, .readfn = pmxevtyper_read }, | ||
154 | { .name = "PMXEVCNTR", .cp = 15, .crn = 9, .crm = 13, .opc1 = 0, .opc2 = 2, | ||
155 | .access = PL0_RW, .type = ARM_CP_NO_RAW | ARM_CP_IO, | ||
156 | .accessfn = pmreg_access_xevcntr, | ||
157 | + .fgt = FGT_PMEVCNTRN_EL0, | ||
158 | .writefn = pmxevcntr_write, .readfn = pmxevcntr_read }, | ||
159 | { .name = "PMXEVCNTR_EL0", .state = ARM_CP_STATE_AA64, | ||
160 | .opc0 = 3, .opc1 = 3, .crn = 9, .crm = 13, .opc2 = 2, | ||
161 | .access = PL0_RW, .type = ARM_CP_NO_RAW | ARM_CP_IO, | ||
162 | .accessfn = pmreg_access_xevcntr, | ||
163 | + .fgt = FGT_PMEVCNTRN_EL0, | ||
164 | .writefn = pmxevcntr_write, .readfn = pmxevcntr_read }, | ||
165 | { .name = "PMUSERENR", .cp = 15, .crn = 9, .crm = 14, .opc1 = 0, .opc2 = 0, | ||
166 | .access = PL0_R | PL1_RW, .accessfn = access_tpm, | ||
167 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v7_cp_reginfo[] = { | ||
168 | .writefn = pmuserenr_write, .raw_writefn = raw_write }, | ||
169 | { .name = "PMINTENSET", .cp = 15, .crn = 9, .crm = 14, .opc1 = 0, .opc2 = 1, | ||
170 | .access = PL1_RW, .accessfn = access_tpm, | ||
171 | + .fgt = FGT_PMINTEN, | ||
172 | .type = ARM_CP_ALIAS | ARM_CP_IO, | ||
173 | .fieldoffset = offsetoflow32(CPUARMState, cp15.c9_pminten), | ||
174 | .resetvalue = 0, | ||
175 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v7_cp_reginfo[] = { | ||
176 | { .name = "PMINTENSET_EL1", .state = ARM_CP_STATE_AA64, | ||
177 | .opc0 = 3, .opc1 = 0, .crn = 9, .crm = 14, .opc2 = 1, | ||
178 | .access = PL1_RW, .accessfn = access_tpm, | ||
179 | + .fgt = FGT_PMINTEN, | ||
180 | .type = ARM_CP_IO, | ||
181 | .fieldoffset = offsetof(CPUARMState, cp15.c9_pminten), | ||
182 | .writefn = pmintenset_write, .raw_writefn = raw_write, | ||
183 | .resetvalue = 0x0 }, | ||
184 | { .name = "PMINTENCLR", .cp = 15, .crn = 9, .crm = 14, .opc1 = 0, .opc2 = 2, | ||
185 | .access = PL1_RW, .accessfn = access_tpm, | ||
186 | + .fgt = FGT_PMINTEN, | ||
187 | .type = ARM_CP_ALIAS | ARM_CP_IO | ARM_CP_NO_RAW, | ||
188 | .fieldoffset = offsetof(CPUARMState, cp15.c9_pminten), | ||
189 | .writefn = pmintenclr_write, }, | ||
190 | { .name = "PMINTENCLR_EL1", .state = ARM_CP_STATE_AA64, | ||
191 | .opc0 = 3, .opc1 = 0, .crn = 9, .crm = 14, .opc2 = 2, | ||
192 | .access = PL1_RW, .accessfn = access_tpm, | ||
193 | + .fgt = FGT_PMINTEN, | ||
194 | .type = ARM_CP_ALIAS | ARM_CP_IO | ARM_CP_NO_RAW, | ||
195 | .fieldoffset = offsetof(CPUARMState, cp15.c9_pminten), | ||
196 | .writefn = pmintenclr_write }, | ||
197 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo pmovsset_cp_reginfo[] = { | ||
198 | /* PMOVSSET is not implemented in v7 before v7ve */ | ||
199 | { .name = "PMOVSSET", .cp = 15, .opc1 = 0, .crn = 9, .crm = 14, .opc2 = 3, | ||
200 | .access = PL0_RW, .accessfn = pmreg_access, | ||
201 | + .fgt = FGT_PMOVS, | ||
202 | .type = ARM_CP_ALIAS | ARM_CP_IO, | ||
203 | .fieldoffset = offsetoflow32(CPUARMState, cp15.c9_pmovsr), | ||
204 | .writefn = pmovsset_write, | ||
205 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo pmovsset_cp_reginfo[] = { | ||
206 | { .name = "PMOVSSET_EL0", .state = ARM_CP_STATE_AA64, | ||
207 | .opc0 = 3, .opc1 = 3, .crn = 9, .crm = 14, .opc2 = 3, | ||
208 | .access = PL0_RW, .accessfn = pmreg_access, | ||
209 | + .fgt = FGT_PMOVS, | ||
210 | .type = ARM_CP_ALIAS | ARM_CP_IO, | ||
211 | .fieldoffset = offsetof(CPUARMState, cp15.c9_pmovsr), | ||
212 | .writefn = pmovsset_write, | ||
213 | @@ -XXX,XX +XXX,XX @@ static void define_pmu_regs(ARMCPU *cpu) | ||
214 | ARMCPRegInfo pmcr = { | ||
215 | .name = "PMCR", .cp = 15, .crn = 9, .crm = 12, .opc1 = 0, .opc2 = 0, | ||
216 | .access = PL0_RW, | ||
217 | + .fgt = FGT_PMCR_EL0, | ||
218 | .type = ARM_CP_IO | ARM_CP_ALIAS, | ||
219 | .fieldoffset = offsetoflow32(CPUARMState, cp15.c9_pmcr), | ||
220 | .accessfn = pmreg_access, .writefn = pmcr_write, | ||
221 | @@ -XXX,XX +XXX,XX @@ static void define_pmu_regs(ARMCPU *cpu) | ||
222 | .name = "PMCR_EL0", .state = ARM_CP_STATE_AA64, | ||
223 | .opc0 = 3, .opc1 = 3, .crn = 9, .crm = 12, .opc2 = 0, | ||
224 | .access = PL0_RW, .accessfn = pmreg_access, | ||
225 | + .fgt = FGT_PMCR_EL0, | ||
226 | .type = ARM_CP_IO, | ||
227 | .fieldoffset = offsetof(CPUARMState, cp15.c9_pmcr), | ||
228 | .resetvalue = cpu->isar.reset_pmcr_el0, | ||
229 | @@ -XXX,XX +XXX,XX @@ static void define_pmu_regs(ARMCPU *cpu) | ||
230 | { .name = pmevcntr_name, .cp = 15, .crn = 14, | ||
231 | .crm = 8 | (3 & (i >> 3)), .opc1 = 0, .opc2 = i & 7, | ||
232 | .access = PL0_RW, .type = ARM_CP_IO | ARM_CP_ALIAS, | ||
233 | + .fgt = FGT_PMEVCNTRN_EL0, | ||
234 | .readfn = pmevcntr_readfn, .writefn = pmevcntr_writefn, | ||
235 | .accessfn = pmreg_access_xevcntr }, | ||
236 | { .name = pmevcntr_el0_name, .state = ARM_CP_STATE_AA64, | ||
237 | .opc0 = 3, .opc1 = 3, .crn = 14, .crm = 8 | (3 & (i >> 3)), | ||
238 | .opc2 = i & 7, .access = PL0_RW, .accessfn = pmreg_access_xevcntr, | ||
239 | .type = ARM_CP_IO, | ||
240 | + .fgt = FGT_PMEVCNTRN_EL0, | ||
241 | .readfn = pmevcntr_readfn, .writefn = pmevcntr_writefn, | ||
242 | .raw_readfn = pmevcntr_rawread, | ||
243 | .raw_writefn = pmevcntr_rawwrite }, | ||
244 | { .name = pmevtyper_name, .cp = 15, .crn = 14, | ||
245 | .crm = 12 | (3 & (i >> 3)), .opc1 = 0, .opc2 = i & 7, | ||
246 | .access = PL0_RW, .type = ARM_CP_IO | ARM_CP_ALIAS, | ||
247 | + .fgt = FGT_PMEVTYPERN_EL0, | ||
248 | .readfn = pmevtyper_readfn, .writefn = pmevtyper_writefn, | ||
249 | .accessfn = pmreg_access }, | ||
250 | { .name = pmevtyper_el0_name, .state = ARM_CP_STATE_AA64, | ||
251 | .opc0 = 3, .opc1 = 3, .crn = 14, .crm = 12 | (3 & (i >> 3)), | ||
252 | .opc2 = i & 7, .access = PL0_RW, .accessfn = pmreg_access, | ||
253 | + .fgt = FGT_PMEVTYPERN_EL0, | ||
254 | .type = ARM_CP_IO, | ||
255 | .readfn = pmevtyper_readfn, .writefn = pmevtyper_writefn, | ||
256 | .raw_writefn = pmevtyper_rawwrite }, | ||
257 | @@ -XXX,XX +XXX,XX @@ static void define_pmu_regs(ARMCPU *cpu) | ||
258 | { .name = "PMCEID2", .state = ARM_CP_STATE_AA32, | ||
259 | .cp = 15, .opc1 = 0, .crn = 9, .crm = 14, .opc2 = 4, | ||
260 | .access = PL0_R, .accessfn = pmreg_access, .type = ARM_CP_CONST, | ||
261 | + .fgt = FGT_PMCEIDN_EL0, | ||
262 | .resetvalue = extract64(cpu->pmceid0, 32, 32) }, | ||
263 | { .name = "PMCEID3", .state = ARM_CP_STATE_AA32, | ||
264 | .cp = 15, .opc1 = 0, .crn = 9, .crm = 14, .opc2 = 5, | ||
265 | .access = PL0_R, .accessfn = pmreg_access, .type = ARM_CP_CONST, | ||
266 | + .fgt = FGT_PMCEIDN_EL0, | ||
267 | .resetvalue = extract64(cpu->pmceid1, 32, 32) }, | ||
268 | }; | ||
269 | define_arm_cp_regs(cpu, v81_pmu_regs); | ||
270 | @@ -XXX,XX +XXX,XX @@ static void define_pmu_regs(ARMCPU *cpu) | ||
271 | .name = "PMMIR_EL1", .state = ARM_CP_STATE_BOTH, | ||
272 | .opc0 = 3, .opc1 = 0, .crn = 9, .crm = 14, .opc2 = 6, | ||
273 | .access = PL1_R, .accessfn = pmreg_access, .type = ARM_CP_CONST, | ||
274 | + .fgt = FGT_PMMIR_EL1, | ||
275 | .resetvalue = 0 | ||
276 | }; | ||
277 | define_one_arm_cp_reg(cpu, &v84_pmmir); | ||
278 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
279 | { .name = "PMCEID0", .state = ARM_CP_STATE_AA32, | ||
280 | .cp = 15, .opc1 = 0, .crn = 9, .crm = 12, .opc2 = 6, | ||
281 | .access = PL0_R, .accessfn = pmreg_access, .type = ARM_CP_CONST, | ||
282 | + .fgt = FGT_PMCEIDN_EL0, | ||
283 | .resetvalue = extract64(cpu->pmceid0, 0, 32) }, | ||
284 | { .name = "PMCEID0_EL0", .state = ARM_CP_STATE_AA64, | ||
285 | .opc0 = 3, .opc1 = 3, .crn = 9, .crm = 12, .opc2 = 6, | ||
286 | .access = PL0_R, .accessfn = pmreg_access, .type = ARM_CP_CONST, | ||
287 | + .fgt = FGT_PMCEIDN_EL0, | ||
288 | .resetvalue = cpu->pmceid0 }, | ||
289 | { .name = "PMCEID1", .state = ARM_CP_STATE_AA32, | ||
290 | .cp = 15, .opc1 = 0, .crn = 9, .crm = 12, .opc2 = 7, | ||
291 | .access = PL0_R, .accessfn = pmreg_access, .type = ARM_CP_CONST, | ||
292 | + .fgt = FGT_PMCEIDN_EL0, | ||
293 | .resetvalue = extract64(cpu->pmceid1, 0, 32) }, | ||
294 | { .name = "PMCEID1_EL0", .state = ARM_CP_STATE_AA64, | ||
295 | .opc0 = 3, .opc1 = 3, .crn = 9, .crm = 12, .opc2 = 7, | ||
296 | .access = PL0_R, .accessfn = pmreg_access, .type = ARM_CP_CONST, | ||
297 | + .fgt = FGT_PMCEIDN_EL0, | ||
298 | .resetvalue = cpu->pmceid1 }, | ||
299 | }; | ||
300 | #ifdef CONFIG_USER_ONLY | ||
116 | -- | 301 | -- |
117 | 2.20.1 | 302 | 2.34.1 |
118 | |||
119 | diff view generated by jsdifflib |
1 | From: Thomas Huth <thuth@redhat.com> | 1 | Mark up the sysreg definitions for the system instructions |
---|---|---|---|
2 | trapped by HFGITR bits 0..11. These bits cover various | ||
3 | cache maintenance operations. | ||
2 | 4 | ||
3 | As described by Edgar here: | 5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Tested-by: Fuad Tabba <tabba@google.com> | ||
8 | Message-id: 20230130182459.3309057-17-peter.maydell@linaro.org | ||
9 | Message-id: 20230127175507.2895013-17-peter.maydell@linaro.org | ||
10 | --- | ||
11 | target/arm/cpregs.h | 14 ++++++++++++++ | ||
12 | target/arm/helper.c | 28 ++++++++++++++++++++++++++++ | ||
13 | 2 files changed, 42 insertions(+) | ||
4 | 14 | ||
5 | https://www.mail-archive.com/qemu-devel@nongnu.org/msg605124.html | 15 | diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h |
6 | |||
7 | we can use the Ubuntu kernel for testing the xlnx-versal-virt machine. | ||
8 | So let's add a boot test for this now. | ||
9 | |||
10 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
11 | Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
12 | Signed-off-by: Thomas Huth <thuth@redhat.com> | ||
13 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
14 | Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> | ||
15 | Message-id: 20200525141237.15243-1-thuth@redhat.com | ||
16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
17 | --- | ||
18 | tests/acceptance/boot_linux_console.py | 26 ++++++++++++++++++++++++++ | ||
19 | 1 file changed, 26 insertions(+) | ||
20 | |||
21 | diff --git a/tests/acceptance/boot_linux_console.py b/tests/acceptance/boot_linux_console.py | ||
22 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
23 | --- a/tests/acceptance/boot_linux_console.py | 17 | --- a/target/arm/cpregs.h |
24 | +++ b/tests/acceptance/boot_linux_console.py | 18 | +++ b/target/arm/cpregs.h |
25 | @@ -XXX,XX +XXX,XX @@ class BootLinuxConsole(LinuxKernelTest): | 19 | @@ -XXX,XX +XXX,XX @@ typedef enum FGTBit { |
26 | console_pattern = 'Kernel command line: %s' % kernel_command_line | 20 | DO_BIT(HDFGWTR, PMCR_EL0), |
27 | self.wait_for_console_pattern(console_pattern) | 21 | DO_BIT(HDFGRTR, PMMIR_EL1), |
28 | 22 | DO_BIT(HDFGRTR, PMCEIDN_EL0), | |
29 | + def test_aarch64_xlnx_versal_virt(self): | ||
30 | + """ | ||
31 | + :avocado: tags=arch:aarch64 | ||
32 | + :avocado: tags=machine:xlnx-versal-virt | ||
33 | + :avocado: tags=device:pl011 | ||
34 | + :avocado: tags=device:arm_gicv3 | ||
35 | + """ | ||
36 | + kernel_url = ('http://ports.ubuntu.com/ubuntu-ports/dists/' | ||
37 | + 'bionic-updates/main/installer-arm64/current/images/' | ||
38 | + 'netboot/ubuntu-installer/arm64/linux') | ||
39 | + kernel_hash = '5bfc54cf7ed8157d93f6e5b0241e727b6dc22c50' | ||
40 | + kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash) | ||
41 | + | 23 | + |
42 | + initrd_url = ('http://ports.ubuntu.com/ubuntu-ports/dists/' | 24 | + /* Trap bits in HFGITR_EL2, starting from bit 0 */ |
43 | + 'bionic-updates/main/installer-arm64/current/images/' | 25 | + DO_BIT(HFGITR, ICIALLUIS), |
44 | + 'netboot/ubuntu-installer/arm64/initrd.gz') | 26 | + DO_BIT(HFGITR, ICIALLU), |
45 | + initrd_hash = 'd385d3e88d53e2004c5d43cbe668b458a094f772' | 27 | + DO_BIT(HFGITR, ICIVAU), |
46 | + initrd_path = self.fetch_asset(initrd_url, asset_hash=initrd_hash) | 28 | + DO_BIT(HFGITR, DCIVAC), |
47 | + | 29 | + DO_BIT(HFGITR, DCISW), |
48 | + self.vm.set_console() | 30 | + DO_BIT(HFGITR, DCCSW), |
49 | + self.vm.add_args('-m', '2G', | 31 | + DO_BIT(HFGITR, DCCISW), |
50 | + '-kernel', kernel_path, | 32 | + DO_BIT(HFGITR, DCCVAU), |
51 | + '-initrd', initrd_path) | 33 | + DO_BIT(HFGITR, DCCVAP), |
52 | + self.vm.launch() | 34 | + DO_BIT(HFGITR, DCCVADP), |
53 | + self.wait_for_console_pattern('Checked W+X mappings: passed') | 35 | + DO_BIT(HFGITR, DCCIVAC), |
54 | + | 36 | + DO_BIT(HFGITR, DCZVA), |
55 | def test_arm_virt(self): | 37 | } FGTBit; |
56 | """ | 38 | |
57 | :avocado: tags=arch:arm | 39 | #undef DO_BIT |
40 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
41 | index XXXXXXX..XXXXXXX 100644 | ||
42 | --- a/target/arm/helper.c | ||
43 | +++ b/target/arm/helper.c | ||
44 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v8_cp_reginfo[] = { | ||
45 | #ifndef CONFIG_USER_ONLY | ||
46 | /* Avoid overhead of an access check that always passes in user-mode */ | ||
47 | .accessfn = aa64_zva_access, | ||
48 | + .fgt = FGT_DCZVA, | ||
49 | #endif | ||
50 | }, | ||
51 | { .name = "CURRENTEL", .state = ARM_CP_STATE_AA64, | ||
52 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v8_cp_reginfo[] = { | ||
53 | { .name = "IC_IALLUIS", .state = ARM_CP_STATE_AA64, | ||
54 | .opc0 = 1, .opc1 = 0, .crn = 7, .crm = 1, .opc2 = 0, | ||
55 | .access = PL1_W, .type = ARM_CP_NOP, | ||
56 | + .fgt = FGT_ICIALLUIS, | ||
57 | .accessfn = access_ticab }, | ||
58 | { .name = "IC_IALLU", .state = ARM_CP_STATE_AA64, | ||
59 | .opc0 = 1, .opc1 = 0, .crn = 7, .crm = 5, .opc2 = 0, | ||
60 | .access = PL1_W, .type = ARM_CP_NOP, | ||
61 | + .fgt = FGT_ICIALLU, | ||
62 | .accessfn = access_tocu }, | ||
63 | { .name = "IC_IVAU", .state = ARM_CP_STATE_AA64, | ||
64 | .opc0 = 1, .opc1 = 3, .crn = 7, .crm = 5, .opc2 = 1, | ||
65 | .access = PL0_W, .type = ARM_CP_NOP, | ||
66 | + .fgt = FGT_ICIVAU, | ||
67 | .accessfn = access_tocu }, | ||
68 | { .name = "DC_IVAC", .state = ARM_CP_STATE_AA64, | ||
69 | .opc0 = 1, .opc1 = 0, .crn = 7, .crm = 6, .opc2 = 1, | ||
70 | .access = PL1_W, .accessfn = aa64_cacheop_poc_access, | ||
71 | + .fgt = FGT_DCIVAC, | ||
72 | .type = ARM_CP_NOP }, | ||
73 | { .name = "DC_ISW", .state = ARM_CP_STATE_AA64, | ||
74 | .opc0 = 1, .opc1 = 0, .crn = 7, .crm = 6, .opc2 = 2, | ||
75 | + .fgt = FGT_DCISW, | ||
76 | .access = PL1_W, .accessfn = access_tsw, .type = ARM_CP_NOP }, | ||
77 | { .name = "DC_CVAC", .state = ARM_CP_STATE_AA64, | ||
78 | .opc0 = 1, .opc1 = 3, .crn = 7, .crm = 10, .opc2 = 1, | ||
79 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v8_cp_reginfo[] = { | ||
80 | .accessfn = aa64_cacheop_poc_access }, | ||
81 | { .name = "DC_CSW", .state = ARM_CP_STATE_AA64, | ||
82 | .opc0 = 1, .opc1 = 0, .crn = 7, .crm = 10, .opc2 = 2, | ||
83 | + .fgt = FGT_DCCSW, | ||
84 | .access = PL1_W, .accessfn = access_tsw, .type = ARM_CP_NOP }, | ||
85 | { .name = "DC_CVAU", .state = ARM_CP_STATE_AA64, | ||
86 | .opc0 = 1, .opc1 = 3, .crn = 7, .crm = 11, .opc2 = 1, | ||
87 | .access = PL0_W, .type = ARM_CP_NOP, | ||
88 | + .fgt = FGT_DCCVAU, | ||
89 | .accessfn = access_tocu }, | ||
90 | { .name = "DC_CIVAC", .state = ARM_CP_STATE_AA64, | ||
91 | .opc0 = 1, .opc1 = 3, .crn = 7, .crm = 14, .opc2 = 1, | ||
92 | .access = PL0_W, .type = ARM_CP_NOP, | ||
93 | + .fgt = FGT_DCCIVAC, | ||
94 | .accessfn = aa64_cacheop_poc_access }, | ||
95 | { .name = "DC_CISW", .state = ARM_CP_STATE_AA64, | ||
96 | .opc0 = 1, .opc1 = 0, .crn = 7, .crm = 14, .opc2 = 2, | ||
97 | + .fgt = FGT_DCCISW, | ||
98 | .access = PL1_W, .accessfn = access_tsw, .type = ARM_CP_NOP }, | ||
99 | /* TLBI operations */ | ||
100 | { .name = "TLBI_VMALLE1IS", .state = ARM_CP_STATE_AA64, | ||
101 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo dcpop_reg[] = { | ||
102 | { .name = "DC_CVAP", .state = ARM_CP_STATE_AA64, | ||
103 | .opc0 = 1, .opc1 = 3, .crn = 7, .crm = 12, .opc2 = 1, | ||
104 | .access = PL0_W, .type = ARM_CP_NO_RAW | ARM_CP_SUPPRESS_TB_END, | ||
105 | + .fgt = FGT_DCCVAP, | ||
106 | .accessfn = aa64_cacheop_poc_access, .writefn = dccvap_writefn }, | ||
107 | }; | ||
108 | |||
109 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo dcpodp_reg[] = { | ||
110 | { .name = "DC_CVADP", .state = ARM_CP_STATE_AA64, | ||
111 | .opc0 = 1, .opc1 = 3, .crn = 7, .crm = 13, .opc2 = 1, | ||
112 | .access = PL0_W, .type = ARM_CP_NO_RAW | ARM_CP_SUPPRESS_TB_END, | ||
113 | + .fgt = FGT_DCCVADP, | ||
114 | .accessfn = aa64_cacheop_poc_access, .writefn = dccvap_writefn }, | ||
115 | }; | ||
116 | #endif /*CONFIG_USER_ONLY*/ | ||
117 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo mte_reginfo[] = { | ||
118 | { .name = "DC_IGVAC", .state = ARM_CP_STATE_AA64, | ||
119 | .opc0 = 1, .opc1 = 0, .crn = 7, .crm = 6, .opc2 = 3, | ||
120 | .type = ARM_CP_NOP, .access = PL1_W, | ||
121 | + .fgt = FGT_DCIVAC, | ||
122 | .accessfn = aa64_cacheop_poc_access }, | ||
123 | { .name = "DC_IGSW", .state = ARM_CP_STATE_AA64, | ||
124 | .opc0 = 1, .opc1 = 0, .crn = 7, .crm = 6, .opc2 = 4, | ||
125 | + .fgt = FGT_DCISW, | ||
126 | .type = ARM_CP_NOP, .access = PL1_W, .accessfn = access_tsw }, | ||
127 | { .name = "DC_IGDVAC", .state = ARM_CP_STATE_AA64, | ||
128 | .opc0 = 1, .opc1 = 0, .crn = 7, .crm = 6, .opc2 = 5, | ||
129 | .type = ARM_CP_NOP, .access = PL1_W, | ||
130 | + .fgt = FGT_DCIVAC, | ||
131 | .accessfn = aa64_cacheop_poc_access }, | ||
132 | { .name = "DC_IGDSW", .state = ARM_CP_STATE_AA64, | ||
133 | .opc0 = 1, .opc1 = 0, .crn = 7, .crm = 6, .opc2 = 6, | ||
134 | + .fgt = FGT_DCISW, | ||
135 | .type = ARM_CP_NOP, .access = PL1_W, .accessfn = access_tsw }, | ||
136 | { .name = "DC_CGSW", .state = ARM_CP_STATE_AA64, | ||
137 | .opc0 = 1, .opc1 = 0, .crn = 7, .crm = 10, .opc2 = 4, | ||
138 | + .fgt = FGT_DCCSW, | ||
139 | .type = ARM_CP_NOP, .access = PL1_W, .accessfn = access_tsw }, | ||
140 | { .name = "DC_CGDSW", .state = ARM_CP_STATE_AA64, | ||
141 | .opc0 = 1, .opc1 = 0, .crn = 7, .crm = 10, .opc2 = 6, | ||
142 | + .fgt = FGT_DCCSW, | ||
143 | .type = ARM_CP_NOP, .access = PL1_W, .accessfn = access_tsw }, | ||
144 | { .name = "DC_CIGSW", .state = ARM_CP_STATE_AA64, | ||
145 | .opc0 = 1, .opc1 = 0, .crn = 7, .crm = 14, .opc2 = 4, | ||
146 | + .fgt = FGT_DCCISW, | ||
147 | .type = ARM_CP_NOP, .access = PL1_W, .accessfn = access_tsw }, | ||
148 | { .name = "DC_CIGDSW", .state = ARM_CP_STATE_AA64, | ||
149 | .opc0 = 1, .opc1 = 0, .crn = 7, .crm = 14, .opc2 = 6, | ||
150 | + .fgt = FGT_DCCISW, | ||
151 | .type = ARM_CP_NOP, .access = PL1_W, .accessfn = access_tsw }, | ||
152 | }; | ||
153 | |||
154 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo mte_el0_cacheop_reginfo[] = { | ||
155 | { .name = "DC_CGVAP", .state = ARM_CP_STATE_AA64, | ||
156 | .opc0 = 1, .opc1 = 3, .crn = 7, .crm = 12, .opc2 = 3, | ||
157 | .type = ARM_CP_NOP, .access = PL0_W, | ||
158 | + .fgt = FGT_DCCVAP, | ||
159 | .accessfn = aa64_cacheop_poc_access }, | ||
160 | { .name = "DC_CGDVAP", .state = ARM_CP_STATE_AA64, | ||
161 | .opc0 = 1, .opc1 = 3, .crn = 7, .crm = 12, .opc2 = 5, | ||
162 | .type = ARM_CP_NOP, .access = PL0_W, | ||
163 | + .fgt = FGT_DCCVAP, | ||
164 | .accessfn = aa64_cacheop_poc_access }, | ||
165 | { .name = "DC_CGVADP", .state = ARM_CP_STATE_AA64, | ||
166 | .opc0 = 1, .opc1 = 3, .crn = 7, .crm = 13, .opc2 = 3, | ||
167 | .type = ARM_CP_NOP, .access = PL0_W, | ||
168 | + .fgt = FGT_DCCVADP, | ||
169 | .accessfn = aa64_cacheop_poc_access }, | ||
170 | { .name = "DC_CGDVADP", .state = ARM_CP_STATE_AA64, | ||
171 | .opc0 = 1, .opc1 = 3, .crn = 7, .crm = 13, .opc2 = 5, | ||
172 | .type = ARM_CP_NOP, .access = PL0_W, | ||
173 | + .fgt = FGT_DCCVADP, | ||
174 | .accessfn = aa64_cacheop_poc_access }, | ||
175 | { .name = "DC_CIGVAC", .state = ARM_CP_STATE_AA64, | ||
176 | .opc0 = 1, .opc1 = 3, .crn = 7, .crm = 14, .opc2 = 3, | ||
177 | .type = ARM_CP_NOP, .access = PL0_W, | ||
178 | + .fgt = FGT_DCCIVAC, | ||
179 | .accessfn = aa64_cacheop_poc_access }, | ||
180 | { .name = "DC_CIGDVAC", .state = ARM_CP_STATE_AA64, | ||
181 | .opc0 = 1, .opc1 = 3, .crn = 7, .crm = 14, .opc2 = 5, | ||
182 | .type = ARM_CP_NOP, .access = PL0_W, | ||
183 | + .fgt = FGT_DCCIVAC, | ||
184 | .accessfn = aa64_cacheop_poc_access }, | ||
185 | { .name = "DC_GVA", .state = ARM_CP_STATE_AA64, | ||
186 | .opc0 = 1, .opc1 = 3, .crn = 7, .crm = 4, .opc2 = 3, | ||
187 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo mte_el0_cacheop_reginfo[] = { | ||
188 | #ifndef CONFIG_USER_ONLY | ||
189 | /* Avoid overhead of an access check that always passes in user-mode */ | ||
190 | .accessfn = aa64_zva_access, | ||
191 | + .fgt = FGT_DCZVA, | ||
192 | #endif | ||
193 | }, | ||
194 | { .name = "DC_GZVA", .state = ARM_CP_STATE_AA64, | ||
195 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo mte_el0_cacheop_reginfo[] = { | ||
196 | #ifndef CONFIG_USER_ONLY | ||
197 | /* Avoid overhead of an access check that always passes in user-mode */ | ||
198 | .accessfn = aa64_zva_access, | ||
199 | + .fgt = FGT_DCZVA, | ||
200 | #endif | ||
201 | }, | ||
202 | }; | ||
58 | -- | 203 | -- |
59 | 2.20.1 | 204 | 2.34.1 |
60 | |||
61 | diff view generated by jsdifflib |
1 | Convert the VCVT fixed-point conversion operations in the | 1 | Mark up the sysreg definitions for the system instructions |
---|---|---|---|
2 | Neon 2-regs-and-shift group to decodetree. | 2 | trapped by HFGITR bits 12..17. These bits cover AT address |
3 | translation instructions. | ||
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: 20200522145520.6778-9-peter.maydell@linaro.org | 7 | Tested-by: Fuad Tabba <tabba@google.com> |
8 | Message-id: 20230130182459.3309057-18-peter.maydell@linaro.org | ||
9 | Message-id: 20230127175507.2895013-18-peter.maydell@linaro.org | ||
7 | --- | 10 | --- |
8 | target/arm/neon-dp.decode | 11 +++++ | 11 | target/arm/cpregs.h | 6 ++++++ |
9 | target/arm/translate-neon.inc.c | 49 +++++++++++++++++++++ | 12 | target/arm/helper.c | 6 ++++++ |
10 | target/arm/translate.c | 75 +-------------------------------- | 13 | 2 files changed, 12 insertions(+) |
11 | 3 files changed, 62 insertions(+), 73 deletions(-) | ||
12 | 14 | ||
13 | diff --git a/target/arm/neon-dp.decode b/target/arm/neon-dp.decode | 15 | diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h |
14 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/neon-dp.decode | 17 | --- a/target/arm/cpregs.h |
16 | +++ b/target/arm/neon-dp.decode | 18 | +++ b/target/arm/cpregs.h |
17 | @@ -XXX,XX +XXX,XX @@ VMINNM_fp_3s 1111 001 1 0 . 1 . .... .... 1111 ... 1 .... @3same_fp | 19 | @@ -XXX,XX +XXX,XX @@ typedef enum FGTBit { |
18 | @2reg_shll_b .... ... . . . 001 shift:3 .... .... 0 . . . .... \ | 20 | DO_BIT(HFGITR, DCCVADP), |
19 | &2reg_shift vm=%vm_dp vd=%vd_dp size=0 q=0 | 21 | DO_BIT(HFGITR, DCCIVAC), |
20 | 22 | DO_BIT(HFGITR, DCZVA), | |
21 | +# We use size=0 for fp32 and size=1 for fp16 to match the 3-same encodings. | 23 | + DO_BIT(HFGITR, ATS1E1R), |
22 | +@2reg_vcvt .... ... . . . 1 ..... .... .... . q:1 . . .... \ | 24 | + DO_BIT(HFGITR, ATS1E1W), |
23 | + &2reg_shift vm=%vm_dp vd=%vd_dp size=0 shift=%neon_rshift_i5 | 25 | + DO_BIT(HFGITR, ATS1E0R), |
24 | + | 26 | + DO_BIT(HFGITR, ATS1E0W), |
25 | VSHR_S_2sh 1111 001 0 1 . ...... .... 0000 . . . 1 .... @2reg_shr_d | 27 | + DO_BIT(HFGITR, ATS1E1RP), |
26 | VSHR_S_2sh 1111 001 0 1 . ...... .... 0000 . . . 1 .... @2reg_shr_s | 28 | + DO_BIT(HFGITR, ATS1E1WP), |
27 | VSHR_S_2sh 1111 001 0 1 . ...... .... 0000 . . . 1 .... @2reg_shr_h | 29 | } FGTBit; |
28 | @@ -XXX,XX +XXX,XX @@ VSHLL_S_2sh 1111 001 0 1 . ...... .... 1010 . 0 . 1 .... @2reg_shll_b | 30 | |
29 | VSHLL_U_2sh 1111 001 1 1 . ...... .... 1010 . 0 . 1 .... @2reg_shll_s | 31 | #undef DO_BIT |
30 | VSHLL_U_2sh 1111 001 1 1 . ...... .... 1010 . 0 . 1 .... @2reg_shll_h | 32 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
31 | VSHLL_U_2sh 1111 001 1 1 . ...... .... 1010 . 0 . 1 .... @2reg_shll_b | ||
32 | + | ||
33 | +# VCVT fixed<->float conversions | ||
34 | +# TODO: FP16 fixed<->float conversions are opc==0b1100 and 0b1101 | ||
35 | +VCVT_SF_2sh 1111 001 0 1 . ...... .... 1110 0 . . 1 .... @2reg_vcvt | ||
36 | +VCVT_UF_2sh 1111 001 1 1 . ...... .... 1110 0 . . 1 .... @2reg_vcvt | ||
37 | +VCVT_FS_2sh 1111 001 0 1 . ...... .... 1111 0 . . 1 .... @2reg_vcvt | ||
38 | +VCVT_FU_2sh 1111 001 1 1 . ...... .... 1111 0 . . 1 .... @2reg_vcvt | ||
39 | diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c | ||
40 | index XXXXXXX..XXXXXXX 100644 | 33 | index XXXXXXX..XXXXXXX 100644 |
41 | --- a/target/arm/translate-neon.inc.c | 34 | --- a/target/arm/helper.c |
42 | +++ b/target/arm/translate-neon.inc.c | 35 | +++ b/target/arm/helper.c |
43 | @@ -XXX,XX +XXX,XX @@ static bool trans_VSHLL_U_2sh(DisasContext *s, arg_2reg_shift *a) | 36 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v8_cp_reginfo[] = { |
44 | }; | 37 | { .name = "AT_S1E1R", .state = ARM_CP_STATE_AA64, |
45 | return do_vshll_2sh(s, a, widenfn[a->size], true); | 38 | .opc0 = 1, .opc1 = 0, .crn = 7, .crm = 8, .opc2 = 0, |
46 | } | 39 | .access = PL1_W, .type = ARM_CP_NO_RAW | ARM_CP_RAISES_EXC, |
47 | + | 40 | + .fgt = FGT_ATS1E1R, |
48 | +static bool do_fp_2sh(DisasContext *s, arg_2reg_shift *a, | 41 | .writefn = ats_write64 }, |
49 | + NeonGenTwoSingleOPFn *fn) | 42 | { .name = "AT_S1E1W", .state = ARM_CP_STATE_AA64, |
50 | +{ | 43 | .opc0 = 1, .opc1 = 0, .crn = 7, .crm = 8, .opc2 = 1, |
51 | + /* FP operations in 2-reg-and-shift group */ | 44 | .access = PL1_W, .type = ARM_CP_NO_RAW | ARM_CP_RAISES_EXC, |
52 | + TCGv_i32 tmp, shiftv; | 45 | + .fgt = FGT_ATS1E1W, |
53 | + TCGv_ptr fpstatus; | 46 | .writefn = ats_write64 }, |
54 | + int pass; | 47 | { .name = "AT_S1E0R", .state = ARM_CP_STATE_AA64, |
55 | + | 48 | .opc0 = 1, .opc1 = 0, .crn = 7, .crm = 8, .opc2 = 2, |
56 | + if (!arm_dc_feature(s, ARM_FEATURE_NEON)) { | 49 | .access = PL1_W, .type = ARM_CP_NO_RAW | ARM_CP_RAISES_EXC, |
57 | + return false; | 50 | + .fgt = FGT_ATS1E0R, |
58 | + } | 51 | .writefn = ats_write64 }, |
59 | + | 52 | { .name = "AT_S1E0W", .state = ARM_CP_STATE_AA64, |
60 | + /* UNDEF accesses to D16-D31 if they don't exist. */ | 53 | .opc0 = 1, .opc1 = 0, .crn = 7, .crm = 8, .opc2 = 3, |
61 | + if (!dc_isar_feature(aa32_simd_r32, s) && | 54 | .access = PL1_W, .type = ARM_CP_NO_RAW | ARM_CP_RAISES_EXC, |
62 | + ((a->vd | a->vm) & 0x10)) { | 55 | + .fgt = FGT_ATS1E0W, |
63 | + return false; | 56 | .writefn = ats_write64 }, |
64 | + } | 57 | { .name = "AT_S12E1R", .state = ARM_CP_STATE_AA64, |
65 | + | 58 | .opc0 = 1, .opc1 = 4, .crn = 7, .crm = 8, .opc2 = 4, |
66 | + if ((a->vm | a->vd) & a->q) { | 59 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo ats1e1_reginfo[] = { |
67 | + return false; | 60 | { .name = "AT_S1E1RP", .state = ARM_CP_STATE_AA64, |
68 | + } | 61 | .opc0 = 1, .opc1 = 0, .crn = 7, .crm = 9, .opc2 = 0, |
69 | + | 62 | .access = PL1_W, .type = ARM_CP_NO_RAW | ARM_CP_RAISES_EXC, |
70 | + if (!vfp_access_check(s)) { | 63 | + .fgt = FGT_ATS1E1RP, |
71 | + return true; | 64 | .writefn = ats_write64 }, |
72 | + } | 65 | { .name = "AT_S1E1WP", .state = ARM_CP_STATE_AA64, |
73 | + | 66 | .opc0 = 1, .opc1 = 0, .crn = 7, .crm = 9, .opc2 = 1, |
74 | + fpstatus = get_fpstatus_ptr(1); | 67 | .access = PL1_W, .type = ARM_CP_NO_RAW | ARM_CP_RAISES_EXC, |
75 | + shiftv = tcg_const_i32(a->shift); | 68 | + .fgt = FGT_ATS1E1WP, |
76 | + for (pass = 0; pass < (a->q ? 4 : 2); pass++) { | 69 | .writefn = ats_write64 }, |
77 | + tmp = neon_load_reg(a->vm, pass); | 70 | }; |
78 | + fn(tmp, tmp, shiftv, fpstatus); | ||
79 | + neon_store_reg(a->vd, pass, tmp); | ||
80 | + } | ||
81 | + tcg_temp_free_ptr(fpstatus); | ||
82 | + tcg_temp_free_i32(shiftv); | ||
83 | + return true; | ||
84 | +} | ||
85 | + | ||
86 | +#define DO_FP_2SH(INSN, FUNC) \ | ||
87 | + static bool trans_##INSN##_2sh(DisasContext *s, arg_2reg_shift *a) \ | ||
88 | + { \ | ||
89 | + return do_fp_2sh(s, a, FUNC); \ | ||
90 | + } | ||
91 | + | ||
92 | +DO_FP_2SH(VCVT_SF, gen_helper_vfp_sltos) | ||
93 | +DO_FP_2SH(VCVT_UF, gen_helper_vfp_ultos) | ||
94 | +DO_FP_2SH(VCVT_FS, gen_helper_vfp_tosls_round_to_zero) | ||
95 | +DO_FP_2SH(VCVT_FU, gen_helper_vfp_touls_round_to_zero) | ||
96 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
97 | index XXXXXXX..XXXXXXX 100644 | ||
98 | --- a/target/arm/translate.c | ||
99 | +++ b/target/arm/translate.c | ||
100 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
101 | int q; | ||
102 | int rd, rn, rm, rd_ofs, rn_ofs, rm_ofs; | ||
103 | int size; | ||
104 | - int shift; | ||
105 | int pass; | ||
106 | int u; | ||
107 | int vec_size; | ||
108 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
109 | return 1; | ||
110 | } else if (insn & (1 << 4)) { | ||
111 | if ((insn & 0x00380080) != 0) { | ||
112 | - /* Two registers and shift. */ | ||
113 | - op = (insn >> 8) & 0xf; | ||
114 | - | ||
115 | - switch (op) { | ||
116 | - case 0: /* VSHR */ | ||
117 | - case 1: /* VSRA */ | ||
118 | - case 2: /* VRSHR */ | ||
119 | - case 3: /* VRSRA */ | ||
120 | - case 4: /* VSRI */ | ||
121 | - case 5: /* VSHL, VSLI */ | ||
122 | - case 6: /* VQSHLU */ | ||
123 | - case 7: /* VQSHL */ | ||
124 | - case 8: /* VSHRN, VRSHRN, VQSHRUN, VQRSHRUN */ | ||
125 | - case 9: /* VQSHRN, VQRSHRN */ | ||
126 | - case 10: /* VSHLL, including VMOVL */ | ||
127 | - return 1; /* handled by decodetree */ | ||
128 | - default: | ||
129 | - break; | ||
130 | - } | ||
131 | - | ||
132 | - if (insn & (1 << 7)) { | ||
133 | - /* 64-bit shift. */ | ||
134 | - if (op > 7) { | ||
135 | - return 1; | ||
136 | - } | ||
137 | - size = 3; | ||
138 | - } else { | ||
139 | - size = 2; | ||
140 | - while ((insn & (1 << (size + 19))) == 0) | ||
141 | - size--; | ||
142 | - } | ||
143 | - shift = (insn >> 16) & ((1 << (3 + size)) - 1); | ||
144 | - if (op >= 14) { | ||
145 | - /* VCVT fixed-point. */ | ||
146 | - TCGv_ptr fpst; | ||
147 | - TCGv_i32 shiftv; | ||
148 | - VFPGenFixPointFn *fn; | ||
149 | - | ||
150 | - if (!(insn & (1 << 21)) || (q && ((rd | rm) & 1))) { | ||
151 | - return 1; | ||
152 | - } | ||
153 | - | ||
154 | - if (!(op & 1)) { | ||
155 | - if (u) { | ||
156 | - fn = gen_helper_vfp_ultos; | ||
157 | - } else { | ||
158 | - fn = gen_helper_vfp_sltos; | ||
159 | - } | ||
160 | - } else { | ||
161 | - if (u) { | ||
162 | - fn = gen_helper_vfp_touls_round_to_zero; | ||
163 | - } else { | ||
164 | - fn = gen_helper_vfp_tosls_round_to_zero; | ||
165 | - } | ||
166 | - } | ||
167 | - | ||
168 | - /* We have already masked out the must-be-1 top bit of imm6, | ||
169 | - * hence this 32-shift where the ARM ARM has 64-imm6. | ||
170 | - */ | ||
171 | - shift = 32 - shift; | ||
172 | - fpst = get_fpstatus_ptr(1); | ||
173 | - shiftv = tcg_const_i32(shift); | ||
174 | - for (pass = 0; pass < (q ? 4 : 2); pass++) { | ||
175 | - TCGv_i32 tmpf = neon_load_reg(rm, pass); | ||
176 | - fn(tmpf, tmpf, shiftv, fpst); | ||
177 | - neon_store_reg(rd, pass, tmpf); | ||
178 | - } | ||
179 | - tcg_temp_free_ptr(fpst); | ||
180 | - tcg_temp_free_i32(shiftv); | ||
181 | - } else { | ||
182 | - return 1; | ||
183 | - } | ||
184 | + /* Two registers and shift: handled by decodetree */ | ||
185 | + return 1; | ||
186 | } else { /* (insn & 0x00380080) == 0 */ | ||
187 | int invert, reg_ofs, vec_size; | ||
188 | 71 | ||
189 | -- | 72 | -- |
190 | 2.20.1 | 73 | 2.34.1 |
191 | |||
192 | diff view generated by jsdifflib |
1 | From: Eden Mikitas <e.mikitas@gmail.com> | 1 | Mark up the sysreg definitions for the system instructions |
---|---|---|---|
2 | trapped by HFGITR bits 18..47. These bits cover TLBI | ||
3 | TLB maintenance instructions. | ||
2 | 4 | ||
3 | When inserting the value retrieved (rx) from the spi slave, rx is pushed to | 5 | (If we implemented FEAT_XS we would need to trap some of the |
4 | rx_fifo after being cast to uint8_t. rx_fifo is a fifo32, and the rx | 6 | instructions added by that feature using these bits; but we don't |
5 | register the driver uses is also 32 bit. This zeroes the 24 most | 7 | yet, so will need to add the .fgt markup when we do.) |
6 | significant bits of rx. This proved problematic with devices that expect to | ||
7 | use the whole 32 bits of the rx register. | ||
8 | 8 | ||
9 | Signed-off-by: Eden Mikitas <e.mikitas@gmail.com> | ||
10 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
11 | Tested-by: Fuad Tabba <tabba@google.com> | ||
12 | Message-id: 20230130182459.3309057-19-peter.maydell@linaro.org | ||
13 | Message-id: 20230127175507.2895013-19-peter.maydell@linaro.org | ||
12 | --- | 14 | --- |
13 | hw/ssi/imx_spi.c | 2 +- | 15 | target/arm/cpregs.h | 30 ++++++++++++++++++++++++++++++ |
14 | 1 file changed, 1 insertion(+), 1 deletion(-) | 16 | target/arm/helper.c | 30 ++++++++++++++++++++++++++++++ |
17 | 2 files changed, 60 insertions(+) | ||
15 | 18 | ||
16 | diff --git a/hw/ssi/imx_spi.c b/hw/ssi/imx_spi.c | 19 | diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h |
17 | index XXXXXXX..XXXXXXX 100644 | 20 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/hw/ssi/imx_spi.c | 21 | --- a/target/arm/cpregs.h |
19 | +++ b/hw/ssi/imx_spi.c | 22 | +++ b/target/arm/cpregs.h |
20 | @@ -XXX,XX +XXX,XX @@ static void imx_spi_flush_txfifo(IMXSPIState *s) | 23 | @@ -XXX,XX +XXX,XX @@ typedef enum FGTBit { |
21 | if (fifo32_is_full(&s->rx_fifo)) { | 24 | DO_BIT(HFGITR, ATS1E0W), |
22 | s->regs[ECSPI_STATREG] |= ECSPI_STATREG_RO; | 25 | DO_BIT(HFGITR, ATS1E1RP), |
23 | } else { | 26 | DO_BIT(HFGITR, ATS1E1WP), |
24 | - fifo32_push(&s->rx_fifo, (uint8_t)rx); | 27 | + DO_BIT(HFGITR, TLBIVMALLE1OS), |
25 | + fifo32_push(&s->rx_fifo, rx); | 28 | + DO_BIT(HFGITR, TLBIVAE1OS), |
26 | } | 29 | + DO_BIT(HFGITR, TLBIASIDE1OS), |
27 | 30 | + DO_BIT(HFGITR, TLBIVAAE1OS), | |
28 | if (s->burst_length <= 0) { | 31 | + DO_BIT(HFGITR, TLBIVALE1OS), |
32 | + DO_BIT(HFGITR, TLBIVAALE1OS), | ||
33 | + DO_BIT(HFGITR, TLBIRVAE1OS), | ||
34 | + DO_BIT(HFGITR, TLBIRVAAE1OS), | ||
35 | + DO_BIT(HFGITR, TLBIRVALE1OS), | ||
36 | + DO_BIT(HFGITR, TLBIRVAALE1OS), | ||
37 | + DO_BIT(HFGITR, TLBIVMALLE1IS), | ||
38 | + DO_BIT(HFGITR, TLBIVAE1IS), | ||
39 | + DO_BIT(HFGITR, TLBIASIDE1IS), | ||
40 | + DO_BIT(HFGITR, TLBIVAAE1IS), | ||
41 | + DO_BIT(HFGITR, TLBIVALE1IS), | ||
42 | + DO_BIT(HFGITR, TLBIVAALE1IS), | ||
43 | + DO_BIT(HFGITR, TLBIRVAE1IS), | ||
44 | + DO_BIT(HFGITR, TLBIRVAAE1IS), | ||
45 | + DO_BIT(HFGITR, TLBIRVALE1IS), | ||
46 | + DO_BIT(HFGITR, TLBIRVAALE1IS), | ||
47 | + DO_BIT(HFGITR, TLBIRVAE1), | ||
48 | + DO_BIT(HFGITR, TLBIRVAAE1), | ||
49 | + DO_BIT(HFGITR, TLBIRVALE1), | ||
50 | + DO_BIT(HFGITR, TLBIRVAALE1), | ||
51 | + DO_BIT(HFGITR, TLBIVMALLE1), | ||
52 | + DO_BIT(HFGITR, TLBIVAE1), | ||
53 | + DO_BIT(HFGITR, TLBIASIDE1), | ||
54 | + DO_BIT(HFGITR, TLBIVAAE1), | ||
55 | + DO_BIT(HFGITR, TLBIVALE1), | ||
56 | + DO_BIT(HFGITR, TLBIVAALE1), | ||
57 | } FGTBit; | ||
58 | |||
59 | #undef DO_BIT | ||
60 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
61 | index XXXXXXX..XXXXXXX 100644 | ||
62 | --- a/target/arm/helper.c | ||
63 | +++ b/target/arm/helper.c | ||
64 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v8_cp_reginfo[] = { | ||
65 | { .name = "TLBI_VMALLE1IS", .state = ARM_CP_STATE_AA64, | ||
66 | .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 3, .opc2 = 0, | ||
67 | .access = PL1_W, .accessfn = access_ttlbis, .type = ARM_CP_NO_RAW, | ||
68 | + .fgt = FGT_TLBIVMALLE1IS, | ||
69 | .writefn = tlbi_aa64_vmalle1is_write }, | ||
70 | { .name = "TLBI_VAE1IS", .state = ARM_CP_STATE_AA64, | ||
71 | .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 3, .opc2 = 1, | ||
72 | .access = PL1_W, .accessfn = access_ttlbis, .type = ARM_CP_NO_RAW, | ||
73 | + .fgt = FGT_TLBIVAE1IS, | ||
74 | .writefn = tlbi_aa64_vae1is_write }, | ||
75 | { .name = "TLBI_ASIDE1IS", .state = ARM_CP_STATE_AA64, | ||
76 | .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 3, .opc2 = 2, | ||
77 | .access = PL1_W, .accessfn = access_ttlbis, .type = ARM_CP_NO_RAW, | ||
78 | + .fgt = FGT_TLBIASIDE1IS, | ||
79 | .writefn = tlbi_aa64_vmalle1is_write }, | ||
80 | { .name = "TLBI_VAAE1IS", .state = ARM_CP_STATE_AA64, | ||
81 | .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 3, .opc2 = 3, | ||
82 | .access = PL1_W, .accessfn = access_ttlbis, .type = ARM_CP_NO_RAW, | ||
83 | + .fgt = FGT_TLBIVAAE1IS, | ||
84 | .writefn = tlbi_aa64_vae1is_write }, | ||
85 | { .name = "TLBI_VALE1IS", .state = ARM_CP_STATE_AA64, | ||
86 | .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 3, .opc2 = 5, | ||
87 | .access = PL1_W, .accessfn = access_ttlbis, .type = ARM_CP_NO_RAW, | ||
88 | + .fgt = FGT_TLBIVALE1IS, | ||
89 | .writefn = tlbi_aa64_vae1is_write }, | ||
90 | { .name = "TLBI_VAALE1IS", .state = ARM_CP_STATE_AA64, | ||
91 | .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 3, .opc2 = 7, | ||
92 | .access = PL1_W, .accessfn = access_ttlbis, .type = ARM_CP_NO_RAW, | ||
93 | + .fgt = FGT_TLBIVAALE1IS, | ||
94 | .writefn = tlbi_aa64_vae1is_write }, | ||
95 | { .name = "TLBI_VMALLE1", .state = ARM_CP_STATE_AA64, | ||
96 | .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 7, .opc2 = 0, | ||
97 | .access = PL1_W, .accessfn = access_ttlb, .type = ARM_CP_NO_RAW, | ||
98 | + .fgt = FGT_TLBIVMALLE1, | ||
99 | .writefn = tlbi_aa64_vmalle1_write }, | ||
100 | { .name = "TLBI_VAE1", .state = ARM_CP_STATE_AA64, | ||
101 | .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 7, .opc2 = 1, | ||
102 | .access = PL1_W, .accessfn = access_ttlb, .type = ARM_CP_NO_RAW, | ||
103 | + .fgt = FGT_TLBIVAE1, | ||
104 | .writefn = tlbi_aa64_vae1_write }, | ||
105 | { .name = "TLBI_ASIDE1", .state = ARM_CP_STATE_AA64, | ||
106 | .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 7, .opc2 = 2, | ||
107 | .access = PL1_W, .accessfn = access_ttlb, .type = ARM_CP_NO_RAW, | ||
108 | + .fgt = FGT_TLBIASIDE1, | ||
109 | .writefn = tlbi_aa64_vmalle1_write }, | ||
110 | { .name = "TLBI_VAAE1", .state = ARM_CP_STATE_AA64, | ||
111 | .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 7, .opc2 = 3, | ||
112 | .access = PL1_W, .accessfn = access_ttlb, .type = ARM_CP_NO_RAW, | ||
113 | + .fgt = FGT_TLBIVAAE1, | ||
114 | .writefn = tlbi_aa64_vae1_write }, | ||
115 | { .name = "TLBI_VALE1", .state = ARM_CP_STATE_AA64, | ||
116 | .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 7, .opc2 = 5, | ||
117 | .access = PL1_W, .accessfn = access_ttlb, .type = ARM_CP_NO_RAW, | ||
118 | + .fgt = FGT_TLBIVALE1, | ||
119 | .writefn = tlbi_aa64_vae1_write }, | ||
120 | { .name = "TLBI_VAALE1", .state = ARM_CP_STATE_AA64, | ||
121 | .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 7, .opc2 = 7, | ||
122 | .access = PL1_W, .accessfn = access_ttlb, .type = ARM_CP_NO_RAW, | ||
123 | + .fgt = FGT_TLBIVAALE1, | ||
124 | .writefn = tlbi_aa64_vae1_write }, | ||
125 | { .name = "TLBI_IPAS2E1IS", .state = ARM_CP_STATE_AA64, | ||
126 | .opc0 = 1, .opc1 = 4, .crn = 8, .crm = 0, .opc2 = 1, | ||
127 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo tlbirange_reginfo[] = { | ||
128 | { .name = "TLBI_RVAE1IS", .state = ARM_CP_STATE_AA64, | ||
129 | .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 2, .opc2 = 1, | ||
130 | .access = PL1_W, .accessfn = access_ttlbis, .type = ARM_CP_NO_RAW, | ||
131 | + .fgt = FGT_TLBIRVAE1IS, | ||
132 | .writefn = tlbi_aa64_rvae1is_write }, | ||
133 | { .name = "TLBI_RVAAE1IS", .state = ARM_CP_STATE_AA64, | ||
134 | .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 2, .opc2 = 3, | ||
135 | .access = PL1_W, .accessfn = access_ttlbis, .type = ARM_CP_NO_RAW, | ||
136 | + .fgt = FGT_TLBIRVAAE1IS, | ||
137 | .writefn = tlbi_aa64_rvae1is_write }, | ||
138 | { .name = "TLBI_RVALE1IS", .state = ARM_CP_STATE_AA64, | ||
139 | .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 2, .opc2 = 5, | ||
140 | .access = PL1_W, .accessfn = access_ttlbis, .type = ARM_CP_NO_RAW, | ||
141 | + .fgt = FGT_TLBIRVALE1IS, | ||
142 | .writefn = tlbi_aa64_rvae1is_write }, | ||
143 | { .name = "TLBI_RVAALE1IS", .state = ARM_CP_STATE_AA64, | ||
144 | .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 2, .opc2 = 7, | ||
145 | .access = PL1_W, .accessfn = access_ttlbis, .type = ARM_CP_NO_RAW, | ||
146 | + .fgt = FGT_TLBIRVAALE1IS, | ||
147 | .writefn = tlbi_aa64_rvae1is_write }, | ||
148 | { .name = "TLBI_RVAE1OS", .state = ARM_CP_STATE_AA64, | ||
149 | .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 5, .opc2 = 1, | ||
150 | .access = PL1_W, .accessfn = access_ttlbos, .type = ARM_CP_NO_RAW, | ||
151 | + .fgt = FGT_TLBIRVAE1OS, | ||
152 | .writefn = tlbi_aa64_rvae1is_write }, | ||
153 | { .name = "TLBI_RVAAE1OS", .state = ARM_CP_STATE_AA64, | ||
154 | .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 5, .opc2 = 3, | ||
155 | .access = PL1_W, .accessfn = access_ttlbos, .type = ARM_CP_NO_RAW, | ||
156 | + .fgt = FGT_TLBIRVAAE1OS, | ||
157 | .writefn = tlbi_aa64_rvae1is_write }, | ||
158 | { .name = "TLBI_RVALE1OS", .state = ARM_CP_STATE_AA64, | ||
159 | .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 5, .opc2 = 5, | ||
160 | .access = PL1_W, .accessfn = access_ttlbos, .type = ARM_CP_NO_RAW, | ||
161 | + .fgt = FGT_TLBIRVALE1OS, | ||
162 | .writefn = tlbi_aa64_rvae1is_write }, | ||
163 | { .name = "TLBI_RVAALE1OS", .state = ARM_CP_STATE_AA64, | ||
164 | .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 5, .opc2 = 7, | ||
165 | .access = PL1_W, .accessfn = access_ttlbos, .type = ARM_CP_NO_RAW, | ||
166 | + .fgt = FGT_TLBIRVAALE1OS, | ||
167 | .writefn = tlbi_aa64_rvae1is_write }, | ||
168 | { .name = "TLBI_RVAE1", .state = ARM_CP_STATE_AA64, | ||
169 | .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 6, .opc2 = 1, | ||
170 | .access = PL1_W, .accessfn = access_ttlb, .type = ARM_CP_NO_RAW, | ||
171 | + .fgt = FGT_TLBIRVAE1, | ||
172 | .writefn = tlbi_aa64_rvae1_write }, | ||
173 | { .name = "TLBI_RVAAE1", .state = ARM_CP_STATE_AA64, | ||
174 | .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 6, .opc2 = 3, | ||
175 | .access = PL1_W, .accessfn = access_ttlb, .type = ARM_CP_NO_RAW, | ||
176 | + .fgt = FGT_TLBIRVAAE1, | ||
177 | .writefn = tlbi_aa64_rvae1_write }, | ||
178 | { .name = "TLBI_RVALE1", .state = ARM_CP_STATE_AA64, | ||
179 | .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 6, .opc2 = 5, | ||
180 | .access = PL1_W, .accessfn = access_ttlb, .type = ARM_CP_NO_RAW, | ||
181 | + .fgt = FGT_TLBIRVALE1, | ||
182 | .writefn = tlbi_aa64_rvae1_write }, | ||
183 | { .name = "TLBI_RVAALE1", .state = ARM_CP_STATE_AA64, | ||
184 | .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 6, .opc2 = 7, | ||
185 | .access = PL1_W, .accessfn = access_ttlb, .type = ARM_CP_NO_RAW, | ||
186 | + .fgt = FGT_TLBIRVAALE1, | ||
187 | .writefn = tlbi_aa64_rvae1_write }, | ||
188 | { .name = "TLBI_RIPAS2E1IS", .state = ARM_CP_STATE_AA64, | ||
189 | .opc0 = 1, .opc1 = 4, .crn = 8, .crm = 0, .opc2 = 2, | ||
190 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo tlbios_reginfo[] = { | ||
191 | { .name = "TLBI_VMALLE1OS", .state = ARM_CP_STATE_AA64, | ||
192 | .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 1, .opc2 = 0, | ||
193 | .access = PL1_W, .accessfn = access_ttlbos, .type = ARM_CP_NO_RAW, | ||
194 | + .fgt = FGT_TLBIVMALLE1OS, | ||
195 | .writefn = tlbi_aa64_vmalle1is_write }, | ||
196 | { .name = "TLBI_VAE1OS", .state = ARM_CP_STATE_AA64, | ||
197 | .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 1, .opc2 = 1, | ||
198 | + .fgt = FGT_TLBIVAE1OS, | ||
199 | .access = PL1_W, .accessfn = access_ttlbos, .type = ARM_CP_NO_RAW, | ||
200 | .writefn = tlbi_aa64_vae1is_write }, | ||
201 | { .name = "TLBI_ASIDE1OS", .state = ARM_CP_STATE_AA64, | ||
202 | .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 1, .opc2 = 2, | ||
203 | .access = PL1_W, .accessfn = access_ttlbos, .type = ARM_CP_NO_RAW, | ||
204 | + .fgt = FGT_TLBIASIDE1OS, | ||
205 | .writefn = tlbi_aa64_vmalle1is_write }, | ||
206 | { .name = "TLBI_VAAE1OS", .state = ARM_CP_STATE_AA64, | ||
207 | .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 1, .opc2 = 3, | ||
208 | .access = PL1_W, .accessfn = access_ttlbos, .type = ARM_CP_NO_RAW, | ||
209 | + .fgt = FGT_TLBIVAAE1OS, | ||
210 | .writefn = tlbi_aa64_vae1is_write }, | ||
211 | { .name = "TLBI_VALE1OS", .state = ARM_CP_STATE_AA64, | ||
212 | .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 1, .opc2 = 5, | ||
213 | .access = PL1_W, .accessfn = access_ttlbos, .type = ARM_CP_NO_RAW, | ||
214 | + .fgt = FGT_TLBIVALE1OS, | ||
215 | .writefn = tlbi_aa64_vae1is_write }, | ||
216 | { .name = "TLBI_VAALE1OS", .state = ARM_CP_STATE_AA64, | ||
217 | .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 1, .opc2 = 7, | ||
218 | .access = PL1_W, .accessfn = access_ttlbos, .type = ARM_CP_NO_RAW, | ||
219 | + .fgt = FGT_TLBIVAALE1OS, | ||
220 | .writefn = tlbi_aa64_vae1is_write }, | ||
221 | { .name = "TLBI_ALLE2OS", .state = ARM_CP_STATE_AA64, | ||
222 | .opc0 = 1, .opc1 = 4, .crn = 8, .crm = 1, .opc2 = 0, | ||
29 | -- | 223 | -- |
30 | 2.20.1 | 224 | 2.34.1 |
31 | |||
32 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | Mark up the sysreg definitions for the system instructions |
---|---|---|---|
2 | trapped by HFGITR bits 48..63. | ||
2 | 3 | ||
3 | Replace printf() calls by qemu_log_mask(), which is disabled | 4 | Some of these bits are for trapping instructions which are |
4 | by default. This avoid flooding the terminal when fuzzing the | 5 | not in the system instruction encoding (i.e. which are |
5 | device. | 6 | not handled by the ARMCPRegInfo mechanism): |
7 | * ERET, ERETAA, ERETAB | ||
8 | * SVC | ||
6 | 9 | ||
7 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 10 | We will have to handle those separately and manually. |
8 | Message-id: 20200525114123.21317-3-f4bug@amsat.org | 11 | |
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
14 | Tested-by: Fuad Tabba <tabba@google.com> | ||
15 | Message-id: 20230130182459.3309057-20-peter.maydell@linaro.org | ||
16 | Message-id: 20230127175507.2895013-20-peter.maydell@linaro.org | ||
11 | --- | 17 | --- |
12 | hw/arm/pxa2xx.c | 66 ++++++++++++++++++++++++++++++++++++------------- | 18 | target/arm/cpregs.h | 4 ++++ |
13 | 1 file changed, 49 insertions(+), 17 deletions(-) | 19 | target/arm/helper.c | 9 +++++++++ |
20 | 2 files changed, 13 insertions(+) | ||
14 | 21 | ||
15 | diff --git a/hw/arm/pxa2xx.c b/hw/arm/pxa2xx.c | 22 | diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h |
16 | index XXXXXXX..XXXXXXX 100644 | 23 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/hw/arm/pxa2xx.c | 24 | --- a/target/arm/cpregs.h |
18 | +++ b/hw/arm/pxa2xx.c | 25 | +++ b/target/arm/cpregs.h |
19 | @@ -XXX,XX +XXX,XX @@ | 26 | @@ -XXX,XX +XXX,XX @@ typedef enum FGTBit { |
20 | #include "sysemu/blockdev.h" | 27 | DO_BIT(HFGITR, TLBIVAAE1), |
21 | #include "sysemu/qtest.h" | 28 | DO_BIT(HFGITR, TLBIVALE1), |
22 | #include "qemu/cutils.h" | 29 | DO_BIT(HFGITR, TLBIVAALE1), |
23 | +#include "qemu/log.h" | 30 | + DO_BIT(HFGITR, CFPRCTX), |
24 | 31 | + DO_BIT(HFGITR, DVPRCTX), | |
25 | static struct { | 32 | + DO_BIT(HFGITR, CPPRCTX), |
26 | hwaddr io_base; | 33 | + DO_BIT(HFGITR, DCCVAC), |
27 | @@ -XXX,XX +XXX,XX @@ static uint64_t pxa2xx_pm_read(void *opaque, hwaddr addr, | 34 | } FGTBit; |
28 | return s->pm_regs[addr >> 2]; | 35 | |
29 | default: | 36 | #undef DO_BIT |
30 | fail: | 37 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
31 | - printf("%s: Bad register " REG_FMT "\n", __func__, addr); | 38 | index XXXXXXX..XXXXXXX 100644 |
32 | + qemu_log_mask(LOG_GUEST_ERROR, | 39 | --- a/target/arm/helper.c |
33 | + "%s: Bad read offset 0x%"HWADDR_PRIx"\n", | 40 | +++ b/target/arm/helper.c |
34 | + __func__, addr); | 41 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v8_cp_reginfo[] = { |
35 | break; | 42 | { .name = "DC_CVAC", .state = ARM_CP_STATE_AA64, |
36 | } | 43 | .opc0 = 1, .opc1 = 3, .crn = 7, .crm = 10, .opc2 = 1, |
37 | return 0; | 44 | .access = PL0_W, .type = ARM_CP_NOP, |
38 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_pm_write(void *opaque, hwaddr addr, | 45 | + .fgt = FGT_DCCVAC, |
39 | s->pm_regs[addr >> 2] = value; | 46 | .accessfn = aa64_cacheop_poc_access }, |
40 | break; | 47 | { .name = "DC_CSW", .state = ARM_CP_STATE_AA64, |
41 | } | 48 | .opc0 = 1, .opc1 = 0, .crn = 7, .crm = 10, .opc2 = 2, |
42 | - | 49 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo mte_el0_cacheop_reginfo[] = { |
43 | - printf("%s: Bad register " REG_FMT "\n", __func__, addr); | 50 | { .name = "DC_CGVAC", .state = ARM_CP_STATE_AA64, |
44 | + qemu_log_mask(LOG_GUEST_ERROR, | 51 | .opc0 = 1, .opc1 = 3, .crn = 7, .crm = 10, .opc2 = 3, |
45 | + "%s: Bad write offset 0x%"HWADDR_PRIx"\n", | 52 | .type = ARM_CP_NOP, .access = PL0_W, |
46 | + __func__, addr); | 53 | + .fgt = FGT_DCCVAC, |
47 | break; | 54 | .accessfn = aa64_cacheop_poc_access }, |
48 | } | 55 | { .name = "DC_CGDVAC", .state = ARM_CP_STATE_AA64, |
49 | } | 56 | .opc0 = 1, .opc1 = 3, .crn = 7, .crm = 10, .opc2 = 5, |
50 | @@ -XXX,XX +XXX,XX @@ static uint64_t pxa2xx_cm_read(void *opaque, hwaddr addr, | 57 | .type = ARM_CP_NOP, .access = PL0_W, |
51 | return s->cm_regs[CCCR >> 2] | (3 << 28); | 58 | + .fgt = FGT_DCCVAC, |
52 | 59 | .accessfn = aa64_cacheop_poc_access }, | |
53 | default: | 60 | { .name = "DC_CGVAP", .state = ARM_CP_STATE_AA64, |
54 | - printf("%s: Bad register " REG_FMT "\n", __func__, addr); | 61 | .opc0 = 1, .opc1 = 3, .crn = 7, .crm = 12, .opc2 = 3, |
55 | + qemu_log_mask(LOG_GUEST_ERROR, | 62 | @@ -XXX,XX +XXX,XX @@ static CPAccessResult access_predinv(CPUARMState *env, const ARMCPRegInfo *ri, |
56 | + "%s: Bad read offset 0x%"HWADDR_PRIx"\n", | 63 | static const ARMCPRegInfo predinv_reginfo[] = { |
57 | + __func__, addr); | 64 | { .name = "CFP_RCTX", .state = ARM_CP_STATE_AA64, |
58 | break; | 65 | .opc0 = 1, .opc1 = 3, .crn = 7, .crm = 3, .opc2 = 4, |
59 | } | 66 | + .fgt = FGT_CFPRCTX, |
60 | return 0; | 67 | .type = ARM_CP_NOP, .access = PL0_W, .accessfn = access_predinv }, |
61 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_cm_write(void *opaque, hwaddr addr, | 68 | { .name = "DVP_RCTX", .state = ARM_CP_STATE_AA64, |
62 | break; | 69 | .opc0 = 1, .opc1 = 3, .crn = 7, .crm = 3, .opc2 = 5, |
63 | 70 | + .fgt = FGT_DVPRCTX, | |
64 | default: | 71 | .type = ARM_CP_NOP, .access = PL0_W, .accessfn = access_predinv }, |
65 | - printf("%s: Bad register " REG_FMT "\n", __func__, addr); | 72 | { .name = "CPP_RCTX", .state = ARM_CP_STATE_AA64, |
66 | + qemu_log_mask(LOG_GUEST_ERROR, | 73 | .opc0 = 1, .opc1 = 3, .crn = 7, .crm = 3, .opc2 = 7, |
67 | + "%s: Bad write offset 0x%"HWADDR_PRIx"\n", | 74 | + .fgt = FGT_CPPRCTX, |
68 | + __func__, addr); | 75 | .type = ARM_CP_NOP, .access = PL0_W, .accessfn = access_predinv }, |
69 | break; | 76 | /* |
70 | } | 77 | * Note the AArch32 opcodes have a different OPC1. |
71 | } | 78 | */ |
72 | @@ -XXX,XX +XXX,XX @@ static uint64_t pxa2xx_mm_read(void *opaque, hwaddr addr, | 79 | { .name = "CFPRCTX", .state = ARM_CP_STATE_AA32, |
73 | return s->mm_regs[addr >> 2]; | 80 | .cp = 15, .opc1 = 0, .crn = 7, .crm = 3, .opc2 = 4, |
74 | /* fall through */ | 81 | + .fgt = FGT_CFPRCTX, |
75 | default: | 82 | .type = ARM_CP_NOP, .access = PL0_W, .accessfn = access_predinv }, |
76 | - printf("%s: Bad register " REG_FMT "\n", __func__, addr); | 83 | { .name = "DVPRCTX", .state = ARM_CP_STATE_AA32, |
77 | + qemu_log_mask(LOG_GUEST_ERROR, | 84 | .cp = 15, .opc1 = 0, .crn = 7, .crm = 3, .opc2 = 5, |
78 | + "%s: Bad read offset 0x%"HWADDR_PRIx"\n", | 85 | + .fgt = FGT_DVPRCTX, |
79 | + __func__, addr); | 86 | .type = ARM_CP_NOP, .access = PL0_W, .accessfn = access_predinv }, |
80 | break; | 87 | { .name = "CPPRCTX", .state = ARM_CP_STATE_AA32, |
81 | } | 88 | .cp = 15, .opc1 = 0, .crn = 7, .crm = 3, .opc2 = 7, |
82 | return 0; | 89 | + .fgt = FGT_CPPRCTX, |
83 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_mm_write(void *opaque, hwaddr addr, | 90 | .type = ARM_CP_NOP, .access = PL0_W, .accessfn = access_predinv }, |
84 | } | 91 | }; |
85 | |||
86 | default: | ||
87 | - printf("%s: Bad register " REG_FMT "\n", __func__, addr); | ||
88 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
89 | + "%s: Bad write offset 0x%"HWADDR_PRIx"\n", | ||
90 | + __func__, addr); | ||
91 | break; | ||
92 | } | ||
93 | } | ||
94 | @@ -XXX,XX +XXX,XX @@ static uint64_t pxa2xx_ssp_read(void *opaque, hwaddr addr, | ||
95 | case SSACD: | ||
96 | return s->ssacd; | ||
97 | default: | ||
98 | - printf("%s: Bad register " REG_FMT "\n", __func__, addr); | ||
99 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
100 | + "%s: Bad read offset 0x%"HWADDR_PRIx"\n", | ||
101 | + __func__, addr); | ||
102 | break; | ||
103 | } | ||
104 | return 0; | ||
105 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_ssp_write(void *opaque, hwaddr addr, | ||
106 | break; | ||
107 | |||
108 | default: | ||
109 | - printf("%s: Bad register " REG_FMT "\n", __func__, addr); | ||
110 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
111 | + "%s: Bad write offset 0x%"HWADDR_PRIx"\n", | ||
112 | + __func__, addr); | ||
113 | break; | ||
114 | } | ||
115 | } | ||
116 | @@ -XXX,XX +XXX,XX @@ static uint64_t pxa2xx_rtc_read(void *opaque, hwaddr addr, | ||
117 | else | ||
118 | return s->last_swcr; | ||
119 | default: | ||
120 | - printf("%s: Bad register " REG_FMT "\n", __func__, addr); | ||
121 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
122 | + "%s: Bad read offset 0x%"HWADDR_PRIx"\n", | ||
123 | + __func__, addr); | ||
124 | break; | ||
125 | } | ||
126 | return 0; | ||
127 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_rtc_write(void *opaque, hwaddr addr, | ||
128 | break; | ||
129 | |||
130 | default: | ||
131 | - printf("%s: Bad register " REG_FMT "\n", __func__, addr); | ||
132 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
133 | + "%s: Bad write offset 0x%"HWADDR_PRIx"\n", | ||
134 | + __func__, addr); | ||
135 | } | ||
136 | } | ||
137 | |||
138 | @@ -XXX,XX +XXX,XX @@ static uint64_t pxa2xx_i2c_read(void *opaque, hwaddr addr, | ||
139 | s->ibmr = 0; | ||
140 | return s->ibmr; | ||
141 | default: | ||
142 | - printf("%s: Bad register " REG_FMT "\n", __func__, addr); | ||
143 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
144 | + "%s: Bad read offset 0x%"HWADDR_PRIx"\n", | ||
145 | + __func__, addr); | ||
146 | break; | ||
147 | } | ||
148 | return 0; | ||
149 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_i2c_write(void *opaque, hwaddr addr, | ||
150 | break; | ||
151 | |||
152 | default: | ||
153 | - printf("%s: Bad register " REG_FMT "\n", __func__, addr); | ||
154 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
155 | + "%s: Bad write offset 0x%"HWADDR_PRIx"\n", | ||
156 | + __func__, addr); | ||
157 | } | ||
158 | } | ||
159 | |||
160 | @@ -XXX,XX +XXX,XX @@ static uint64_t pxa2xx_i2s_read(void *opaque, hwaddr addr, | ||
161 | } | ||
162 | return 0; | ||
163 | default: | ||
164 | - printf("%s: Bad register " REG_FMT "\n", __func__, addr); | ||
165 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
166 | + "%s: Bad read offset 0x%"HWADDR_PRIx"\n", | ||
167 | + __func__, addr); | ||
168 | break; | ||
169 | } | ||
170 | return 0; | ||
171 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_i2s_write(void *opaque, hwaddr addr, | ||
172 | } | ||
173 | break; | ||
174 | default: | ||
175 | - printf("%s: Bad register " REG_FMT "\n", __func__, addr); | ||
176 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
177 | + "%s: Bad write offset 0x%"HWADDR_PRIx"\n", | ||
178 | + __func__, addr); | ||
179 | } | ||
180 | } | ||
181 | |||
182 | @@ -XXX,XX +XXX,XX @@ static uint64_t pxa2xx_fir_read(void *opaque, hwaddr addr, | ||
183 | case ICFOR: | ||
184 | return s->rx_len; | ||
185 | default: | ||
186 | - printf("%s: Bad register " REG_FMT "\n", __func__, addr); | ||
187 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
188 | + "%s: Bad read offset 0x%"HWADDR_PRIx"\n", | ||
189 | + __func__, addr); | ||
190 | break; | ||
191 | } | ||
192 | return 0; | ||
193 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_fir_write(void *opaque, hwaddr addr, | ||
194 | case ICFOR: | ||
195 | break; | ||
196 | default: | ||
197 | - printf("%s: Bad register " REG_FMT "\n", __func__, addr); | ||
198 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
199 | + "%s: Bad write offset 0x%"HWADDR_PRIx"\n", | ||
200 | + __func__, addr); | ||
201 | } | ||
202 | } | ||
203 | 92 | ||
204 | -- | 93 | -- |
205 | 2.20.1 | 94 | 2.34.1 |
206 | |||
207 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | Implement the HFGITR_EL2.ERET fine-grained trap. This traps |
---|---|---|---|
2 | execution from AArch64 EL1 of ERET, ERETAA and ERETAB. The trap is | ||
3 | reported with a syndrome value of 0x1a. | ||
2 | 4 | ||
3 | Do not yet convert the helpers to loop over opr_sz, but the | 5 | The trap must take precedence over a possible pointer-authentication |
4 | descriptor allows the vector tail to be cleared. Which fixes | 6 | trap for ERETAA and ERETAB. |
5 | an existing bug vs SVE. | ||
6 | 7 | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20200514212831.31248-4-richard.henderson@linaro.org | ||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
10 | Tested-by: Fuad Tabba <tabba@google.com> | ||
11 | Message-id: 20230130182459.3309057-21-peter.maydell@linaro.org | ||
12 | Message-id: 20230127175507.2895013-21-peter.maydell@linaro.org | ||
11 | --- | 13 | --- |
12 | target/arm/helper.h | 15 +++++++----- | 14 | target/arm/cpu.h | 1 + |
13 | target/arm/crypto_helper.c | 37 +++++++++++++++++++++++----- | 15 | target/arm/syndrome.h | 10 ++++++++++ |
14 | target/arm/translate-a64.c | 50 ++++++++++++-------------------------- | 16 | target/arm/translate.h | 2 ++ |
15 | 3 files changed, 55 insertions(+), 47 deletions(-) | 17 | target/arm/helper.c | 3 +++ |
18 | target/arm/translate-a64.c | 10 ++++++++++ | ||
19 | 5 files changed, 26 insertions(+) | ||
16 | 20 | ||
17 | diff --git a/target/arm/helper.h b/target/arm/helper.h | 21 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
18 | index XXXXXXX..XXXXXXX 100644 | 22 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/target/arm/helper.h | 23 | --- a/target/arm/cpu.h |
20 | +++ b/target/arm/helper.h | 24 | +++ b/target/arm/cpu.h |
21 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(crypto_sha256h2, TCG_CALL_NO_RWG, void, ptr, ptr, ptr) | 25 | @@ -XXX,XX +XXX,XX @@ FIELD(TBFLAG_A64, PSTATE_ZA, 23, 1) |
22 | DEF_HELPER_FLAGS_2(crypto_sha256su0, TCG_CALL_NO_RWG, void, ptr, ptr) | 26 | FIELD(TBFLAG_A64, SVL, 24, 4) |
23 | DEF_HELPER_FLAGS_3(crypto_sha256su1, TCG_CALL_NO_RWG, void, ptr, ptr, ptr) | 27 | /* Indicates that SME Streaming mode is active, and SMCR_ELx.FA64 is not. */ |
24 | 28 | FIELD(TBFLAG_A64, SME_TRAP_NONSTREAMING, 28, 1) | |
25 | -DEF_HELPER_FLAGS_3(crypto_sha512h, TCG_CALL_NO_RWG, void, ptr, ptr, ptr) | 29 | +FIELD(TBFLAG_A64, FGT_ERET, 29, 1) |
26 | -DEF_HELPER_FLAGS_3(crypto_sha512h2, TCG_CALL_NO_RWG, void, ptr, ptr, ptr) | 30 | |
27 | -DEF_HELPER_FLAGS_2(crypto_sha512su0, TCG_CALL_NO_RWG, void, ptr, ptr) | 31 | /* |
28 | -DEF_HELPER_FLAGS_3(crypto_sha512su1, TCG_CALL_NO_RWG, void, ptr, ptr, ptr) | 32 | * Helpers for using the above. |
29 | +DEF_HELPER_FLAGS_4(crypto_sha512h, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | 33 | diff --git a/target/arm/syndrome.h b/target/arm/syndrome.h |
30 | +DEF_HELPER_FLAGS_4(crypto_sha512h2, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | ||
31 | +DEF_HELPER_FLAGS_3(crypto_sha512su0, TCG_CALL_NO_RWG, void, ptr, ptr, i32) | ||
32 | +DEF_HELPER_FLAGS_4(crypto_sha512su1, TCG_CALL_NO_RWG, | ||
33 | + void, ptr, ptr, ptr, i32) | ||
34 | |||
35 | DEF_HELPER_FLAGS_5(crypto_sm3tt, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32, i32) | ||
36 | -DEF_HELPER_FLAGS_3(crypto_sm3partw1, TCG_CALL_NO_RWG, void, ptr, ptr, ptr) | ||
37 | -DEF_HELPER_FLAGS_3(crypto_sm3partw2, TCG_CALL_NO_RWG, void, ptr, ptr, ptr) | ||
38 | +DEF_HELPER_FLAGS_4(crypto_sm3partw1, TCG_CALL_NO_RWG, | ||
39 | + void, ptr, ptr, ptr, i32) | ||
40 | +DEF_HELPER_FLAGS_4(crypto_sm3partw2, TCG_CALL_NO_RWG, | ||
41 | + void, ptr, ptr, ptr, i32) | ||
42 | |||
43 | DEF_HELPER_FLAGS_4(crypto_sm4e, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | ||
44 | DEF_HELPER_FLAGS_4(crypto_sm4ekey, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | ||
45 | diff --git a/target/arm/crypto_helper.c b/target/arm/crypto_helper.c | ||
46 | index XXXXXXX..XXXXXXX 100644 | 34 | index XXXXXXX..XXXXXXX 100644 |
47 | --- a/target/arm/crypto_helper.c | 35 | --- a/target/arm/syndrome.h |
48 | +++ b/target/arm/crypto_helper.c | 36 | +++ b/target/arm/syndrome.h |
49 | @@ -XXX,XX +XXX,XX @@ union CRYPTO_STATE { | 37 | @@ -XXX,XX +XXX,XX @@ enum arm_exception_class { |
50 | #define CR_ST_WORD(state, i) (state.words[i]) | 38 | EC_AA64_SMC = 0x17, |
51 | #endif | 39 | EC_SYSTEMREGISTERTRAP = 0x18, |
40 | EC_SVEACCESSTRAP = 0x19, | ||
41 | + EC_ERETTRAP = 0x1a, | ||
42 | EC_SMETRAP = 0x1d, | ||
43 | EC_INSNABORT = 0x20, | ||
44 | EC_INSNABORT_SAME_EL = 0x21, | ||
45 | @@ -XXX,XX +XXX,XX @@ static inline uint32_t syn_sve_access_trap(void) | ||
46 | return EC_SVEACCESSTRAP << ARM_EL_EC_SHIFT; | ||
47 | } | ||
52 | 48 | ||
53 | +/* | 49 | +/* |
54 | + * The caller has not been converted to full gvec, and so only | 50 | + * eret_op is bits [1:0] of the ERET instruction, so: |
55 | + * modifies the low 16 bytes of the vector register. | 51 | + * 0 for ERET, 2 for ERETAA, 3 for ERETAB. |
56 | + */ | 52 | + */ |
57 | +static void clear_tail_16(void *vd, uint32_t desc) | 53 | +static inline uint32_t syn_erettrap(int eret_op) |
58 | +{ | 54 | +{ |
59 | + int opr_sz = simd_oprsz(desc); | 55 | + return (EC_ERETTRAP << ARM_EL_EC_SHIFT) | ARM_EL_IL | eret_op; |
60 | + int max_sz = simd_maxsz(desc); | ||
61 | + | ||
62 | + assert(opr_sz == 16); | ||
63 | + clear_tail(vd, opr_sz, max_sz); | ||
64 | +} | 56 | +} |
65 | + | 57 | + |
66 | static void do_crypto_aese(uint64_t *rd, uint64_t *rn, | 58 | static inline uint32_t syn_smetrap(SMEExceptionType etype, bool is_16bit) |
67 | uint64_t *rm, bool decrypt) | ||
68 | { | 59 | { |
69 | @@ -XXX,XX +XXX,XX @@ static uint64_t s1_512(uint64_t x) | 60 | return (EC_SMETRAP << ARM_EL_EC_SHIFT) |
70 | return ror64(x, 19) ^ ror64(x, 61) ^ (x >> 6); | 61 | diff --git a/target/arm/translate.h b/target/arm/translate.h |
71 | } | 62 | index XXXXXXX..XXXXXXX 100644 |
72 | 63 | --- a/target/arm/translate.h | |
73 | -void HELPER(crypto_sha512h)(void *vd, void *vn, void *vm) | 64 | +++ b/target/arm/translate.h |
74 | +void HELPER(crypto_sha512h)(void *vd, void *vn, void *vm, uint32_t desc) | 65 | @@ -XXX,XX +XXX,XX @@ typedef struct DisasContext { |
75 | { | 66 | bool mve_no_pred; |
76 | uint64_t *rd = vd; | 67 | /* True if fine-grained traps are active */ |
77 | uint64_t *rn = vn; | 68 | bool fgt_active; |
78 | @@ -XXX,XX +XXX,XX @@ void HELPER(crypto_sha512h)(void *vd, void *vn, void *vm) | 69 | + /* True if fine-grained trap on ERET is enabled */ |
79 | 70 | + bool fgt_eret; | |
80 | rd[0] = d0; | 71 | /* |
81 | rd[1] = d1; | 72 | * >= 0, a copy of PSTATE.BTYPE, which will be 0 without v8.5-BTI. |
82 | + | 73 | * < 0, set by the current instruction. |
83 | + clear_tail_16(vd, desc); | 74 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
84 | } | 75 | index XXXXXXX..XXXXXXX 100644 |
85 | 76 | --- a/target/arm/helper.c | |
86 | -void HELPER(crypto_sha512h2)(void *vd, void *vn, void *vm) | 77 | +++ b/target/arm/helper.c |
87 | +void HELPER(crypto_sha512h2)(void *vd, void *vn, void *vm, uint32_t desc) | 78 | @@ -XXX,XX +XXX,XX @@ static CPUARMTBFlags rebuild_hflags_a64(CPUARMState *env, int el, int fp_el, |
88 | { | 79 | |
89 | uint64_t *rd = vd; | 80 | if (arm_fgt_active(env, el)) { |
90 | uint64_t *rn = vn; | 81 | DP_TBFLAG_ANY(flags, FGT_ACTIVE, 1); |
91 | @@ -XXX,XX +XXX,XX @@ void HELPER(crypto_sha512h2)(void *vd, void *vn, void *vm) | 82 | + if (FIELD_EX64(env->cp15.fgt_exec[FGTREG_HFGITR], HFGITR_EL2, ERET)) { |
92 | 83 | + DP_TBFLAG_A64(flags, FGT_ERET, 1); | |
93 | rd[0] = d0; | 84 | + } |
94 | rd[1] = d1; | 85 | } |
95 | + | 86 | |
96 | + clear_tail_16(vd, desc); | 87 | if (cpu_isar_feature(aa64_mte, env_archcpu(env))) { |
97 | } | ||
98 | |||
99 | -void HELPER(crypto_sha512su0)(void *vd, void *vn) | ||
100 | +void HELPER(crypto_sha512su0)(void *vd, void *vn, uint32_t desc) | ||
101 | { | ||
102 | uint64_t *rd = vd; | ||
103 | uint64_t *rn = vn; | ||
104 | @@ -XXX,XX +XXX,XX @@ void HELPER(crypto_sha512su0)(void *vd, void *vn) | ||
105 | |||
106 | rd[0] = d0; | ||
107 | rd[1] = d1; | ||
108 | + | ||
109 | + clear_tail_16(vd, desc); | ||
110 | } | ||
111 | |||
112 | -void HELPER(crypto_sha512su1)(void *vd, void *vn, void *vm) | ||
113 | +void HELPER(crypto_sha512su1)(void *vd, void *vn, void *vm, uint32_t desc) | ||
114 | { | ||
115 | uint64_t *rd = vd; | ||
116 | uint64_t *rn = vn; | ||
117 | @@ -XXX,XX +XXX,XX @@ void HELPER(crypto_sha512su1)(void *vd, void *vn, void *vm) | ||
118 | |||
119 | rd[0] += s1_512(rn[0]) + rm[0]; | ||
120 | rd[1] += s1_512(rn[1]) + rm[1]; | ||
121 | + | ||
122 | + clear_tail_16(vd, desc); | ||
123 | } | ||
124 | |||
125 | -void HELPER(crypto_sm3partw1)(void *vd, void *vn, void *vm) | ||
126 | +void HELPER(crypto_sm3partw1)(void *vd, void *vn, void *vm, uint32_t desc) | ||
127 | { | ||
128 | uint64_t *rd = vd; | ||
129 | uint64_t *rn = vn; | ||
130 | @@ -XXX,XX +XXX,XX @@ void HELPER(crypto_sm3partw1)(void *vd, void *vn, void *vm) | ||
131 | |||
132 | rd[0] = d.l[0]; | ||
133 | rd[1] = d.l[1]; | ||
134 | + | ||
135 | + clear_tail_16(vd, desc); | ||
136 | } | ||
137 | |||
138 | -void HELPER(crypto_sm3partw2)(void *vd, void *vn, void *vm) | ||
139 | +void HELPER(crypto_sm3partw2)(void *vd, void *vn, void *vm, uint32_t desc) | ||
140 | { | ||
141 | uint64_t *rd = vd; | ||
142 | uint64_t *rn = vn; | ||
143 | @@ -XXX,XX +XXX,XX @@ void HELPER(crypto_sm3partw2)(void *vd, void *vn, void *vm) | ||
144 | |||
145 | rd[0] = d.l[0]; | ||
146 | rd[1] = d.l[1]; | ||
147 | + | ||
148 | + clear_tail_16(vd, desc); | ||
149 | } | ||
150 | |||
151 | void HELPER(crypto_sm3tt)(void *vd, void *vn, void *vm, uint32_t imm2, | ||
152 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 88 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c |
153 | index XXXXXXX..XXXXXXX 100644 | 89 | index XXXXXXX..XXXXXXX 100644 |
154 | --- a/target/arm/translate-a64.c | 90 | --- a/target/arm/translate-a64.c |
155 | +++ b/target/arm/translate-a64.c | 91 | +++ b/target/arm/translate-a64.c |
156 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_three_reg_sha512(DisasContext *s, uint32_t insn) | 92 | @@ -XXX,XX +XXX,XX @@ static void disas_uncond_b_reg(DisasContext *s, uint32_t insn) |
157 | int rn = extract32(insn, 5, 5); | 93 | if (op4 != 0) { |
158 | int rd = extract32(insn, 0, 5); | 94 | goto do_unallocated; |
159 | bool feature; | 95 | } |
160 | - CryptoThreeOpFn *genfn = NULL; | 96 | + if (s->fgt_eret) { |
161 | gen_helper_gvec_3 *oolfn = NULL; | 97 | + gen_exception_insn_el(s, 0, EXCP_UDEF, syn_erettrap(op3), 2); |
162 | GVecGen3Fn *gvecfn = NULL; | 98 | + return; |
163 | 99 | + } | |
164 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_three_reg_sha512(DisasContext *s, uint32_t insn) | 100 | dst = tcg_temp_new_i64(); |
165 | switch (opcode) { | 101 | tcg_gen_ld_i64(dst, cpu_env, |
166 | case 0: /* SHA512H */ | 102 | offsetof(CPUARMState, elr_el[s->current_el])); |
167 | feature = dc_isar_feature(aa64_sha512, s); | 103 | @@ -XXX,XX +XXX,XX @@ static void disas_uncond_b_reg(DisasContext *s, uint32_t insn) |
168 | - genfn = gen_helper_crypto_sha512h; | 104 | if (rn != 0x1f || op4 != 0x1f) { |
169 | + oolfn = gen_helper_crypto_sha512h; | 105 | goto do_unallocated; |
170 | break; | 106 | } |
171 | case 1: /* SHA512H2 */ | 107 | + /* The FGT trap takes precedence over an auth trap. */ |
172 | feature = dc_isar_feature(aa64_sha512, s); | 108 | + if (s->fgt_eret) { |
173 | - genfn = gen_helper_crypto_sha512h2; | 109 | + gen_exception_insn_el(s, 0, EXCP_UDEF, syn_erettrap(op3), 2); |
174 | + oolfn = gen_helper_crypto_sha512h2; | 110 | + return; |
175 | break; | 111 | + } |
176 | case 2: /* SHA512SU1 */ | 112 | dst = tcg_temp_new_i64(); |
177 | feature = dc_isar_feature(aa64_sha512, s); | 113 | tcg_gen_ld_i64(dst, cpu_env, |
178 | - genfn = gen_helper_crypto_sha512su1; | 114 | offsetof(CPUARMState, elr_el[s->current_el])); |
179 | + oolfn = gen_helper_crypto_sha512su1; | 115 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_init_disas_context(DisasContextBase *dcbase, |
180 | break; | 116 | dc->align_mem = EX_TBFLAG_ANY(tb_flags, ALIGN_MEM); |
181 | case 3: /* RAX1 */ | 117 | dc->pstate_il = EX_TBFLAG_ANY(tb_flags, PSTATE__IL); |
182 | feature = dc_isar_feature(aa64_sha3, s); | 118 | dc->fgt_active = EX_TBFLAG_ANY(tb_flags, FGT_ACTIVE); |
183 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_three_reg_sha512(DisasContext *s, uint32_t insn) | 119 | + dc->fgt_eret = EX_TBFLAG_A64(tb_flags, FGT_ERET); |
184 | switch (opcode) { | 120 | dc->sve_excp_el = EX_TBFLAG_A64(tb_flags, SVEEXC_EL); |
185 | case 0: /* SM3PARTW1 */ | 121 | dc->sme_excp_el = EX_TBFLAG_A64(tb_flags, SMEEXC_EL); |
186 | feature = dc_isar_feature(aa64_sm3, s); | 122 | dc->vl = (EX_TBFLAG_A64(tb_flags, VL) + 1) * 16; |
187 | - genfn = gen_helper_crypto_sm3partw1; | ||
188 | + oolfn = gen_helper_crypto_sm3partw1; | ||
189 | break; | ||
190 | case 1: /* SM3PARTW2 */ | ||
191 | feature = dc_isar_feature(aa64_sm3, s); | ||
192 | - genfn = gen_helper_crypto_sm3partw2; | ||
193 | + oolfn = gen_helper_crypto_sm3partw2; | ||
194 | break; | ||
195 | case 2: /* SM4EKEY */ | ||
196 | feature = dc_isar_feature(aa64_sm4, s); | ||
197 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_three_reg_sha512(DisasContext *s, uint32_t insn) | ||
198 | |||
199 | if (oolfn) { | ||
200 | gen_gvec_op3_ool(s, true, rd, rn, rm, 0, oolfn); | ||
201 | - } else if (gvecfn) { | ||
202 | - gen_gvec_fn3(s, true, rd, rn, rm, gvecfn, MO_64); | ||
203 | } else { | ||
204 | - TCGv_ptr tcg_rd_ptr, tcg_rn_ptr, tcg_rm_ptr; | ||
205 | - | ||
206 | - tcg_rd_ptr = vec_full_reg_ptr(s, rd); | ||
207 | - tcg_rn_ptr = vec_full_reg_ptr(s, rn); | ||
208 | - tcg_rm_ptr = vec_full_reg_ptr(s, rm); | ||
209 | - | ||
210 | - genfn(tcg_rd_ptr, tcg_rn_ptr, tcg_rm_ptr); | ||
211 | - | ||
212 | - tcg_temp_free_ptr(tcg_rd_ptr); | ||
213 | - tcg_temp_free_ptr(tcg_rn_ptr); | ||
214 | - tcg_temp_free_ptr(tcg_rm_ptr); | ||
215 | + gen_gvec_fn3(s, true, rd, rn, rm, gvecfn, MO_64); | ||
216 | } | ||
217 | } | ||
218 | |||
219 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_two_reg_sha512(DisasContext *s, uint32_t insn) | ||
220 | int opcode = extract32(insn, 10, 2); | ||
221 | int rn = extract32(insn, 5, 5); | ||
222 | int rd = extract32(insn, 0, 5); | ||
223 | - TCGv_ptr tcg_rd_ptr, tcg_rn_ptr; | ||
224 | bool feature; | ||
225 | - CryptoTwoOpFn *genfn; | ||
226 | - gen_helper_gvec_3 *oolfn = NULL; | ||
227 | |||
228 | switch (opcode) { | ||
229 | case 0: /* SHA512SU0 */ | ||
230 | feature = dc_isar_feature(aa64_sha512, s); | ||
231 | - genfn = gen_helper_crypto_sha512su0; | ||
232 | break; | ||
233 | case 1: /* SM4E */ | ||
234 | feature = dc_isar_feature(aa64_sm4, s); | ||
235 | - oolfn = gen_helper_crypto_sm4e; | ||
236 | break; | ||
237 | default: | ||
238 | unallocated_encoding(s); | ||
239 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_two_reg_sha512(DisasContext *s, uint32_t insn) | ||
240 | return; | ||
241 | } | ||
242 | |||
243 | - if (oolfn) { | ||
244 | - gen_gvec_op3_ool(s, true, rd, rd, rn, 0, oolfn); | ||
245 | - return; | ||
246 | + switch (opcode) { | ||
247 | + case 0: /* SHA512SU0 */ | ||
248 | + gen_gvec_op2_ool(s, true, rd, rn, 0, gen_helper_crypto_sha512su0); | ||
249 | + break; | ||
250 | + case 1: /* SM4E */ | ||
251 | + gen_gvec_op3_ool(s, true, rd, rd, rn, 0, gen_helper_crypto_sm4e); | ||
252 | + break; | ||
253 | + default: | ||
254 | + g_assert_not_reached(); | ||
255 | } | ||
256 | - | ||
257 | - tcg_rd_ptr = vec_full_reg_ptr(s, rd); | ||
258 | - tcg_rn_ptr = vec_full_reg_ptr(s, rn); | ||
259 | - | ||
260 | - genfn(tcg_rd_ptr, tcg_rn_ptr); | ||
261 | - | ||
262 | - tcg_temp_free_ptr(tcg_rd_ptr); | ||
263 | - tcg_temp_free_ptr(tcg_rn_ptr); | ||
264 | } | ||
265 | |||
266 | /* Crypto four-register | ||
267 | -- | 123 | -- |
268 | 2.20.1 | 124 | 2.34.1 |
269 | |||
270 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | Implement the HFGITR_EL2.SVC_EL0 and SVC_EL1 fine-grained traps. |
---|---|---|---|
2 | These trap execution of the SVC instruction from AArch32 and AArch64. | ||
3 | (As usual, AArch32 can only trap from EL0, as fine grained traps are | ||
4 | disabled with an AArch32 EL1.) | ||
2 | 5 | ||
3 | With this conversion, we will be able to use the same helpers | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | with sve. In particular, pass 3 vector parameters for the | 7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
5 | 3-operand operations; for advsimd the destination register | 8 | Tested-by: Fuad Tabba <tabba@google.com> |
6 | is also an input. | 9 | Message-id: 20230130182459.3309057-22-peter.maydell@linaro.org |
10 | Message-id: 20230127175507.2895013-22-peter.maydell@linaro.org | ||
11 | --- | ||
12 | target/arm/cpu.h | 1 + | ||
13 | target/arm/translate.h | 2 ++ | ||
14 | target/arm/helper.c | 20 ++++++++++++++++++++ | ||
15 | target/arm/translate-a64.c | 9 ++++++++- | ||
16 | target/arm/translate.c | 12 +++++++++--- | ||
17 | 5 files changed, 40 insertions(+), 4 deletions(-) | ||
7 | 18 | ||
8 | This also fixes a bug in which we failed to clear the high bits | 19 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
9 | of the SVE register after an AdvSIMD operation. | ||
10 | |||
11 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
12 | Message-id: 20200514212831.31248-2-richard.henderson@linaro.org | ||
13 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
15 | --- | ||
16 | target/arm/helper.h | 6 ++-- | ||
17 | target/arm/vec_internal.h | 33 +++++++++++++++++ | ||
18 | target/arm/crypto_helper.c | 72 +++++++++++++++++++++++++++----------- | ||
19 | target/arm/translate-a64.c | 55 ++++++++++++++++++----------- | ||
20 | target/arm/translate.c | 27 +++++++------- | ||
21 | target/arm/vec_helper.c | 12 +------ | ||
22 | 6 files changed, 138 insertions(+), 67 deletions(-) | ||
23 | create mode 100644 target/arm/vec_internal.h | ||
24 | |||
25 | diff --git a/target/arm/helper.h b/target/arm/helper.h | ||
26 | index XXXXXXX..XXXXXXX 100644 | 20 | index XXXXXXX..XXXXXXX 100644 |
27 | --- a/target/arm/helper.h | 21 | --- a/target/arm/cpu.h |
28 | +++ b/target/arm/helper.h | 22 | +++ b/target/arm/cpu.h |
29 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_2(neon_qzip8, TCG_CALL_NO_RWG, void, ptr, ptr) | 23 | @@ -XXX,XX +XXX,XX @@ FIELD(TBFLAG_ANY, FPEXC_EL, 8, 2) |
30 | DEF_HELPER_FLAGS_2(neon_qzip16, TCG_CALL_NO_RWG, void, ptr, ptr) | 24 | FIELD(TBFLAG_ANY, ALIGN_MEM, 10, 1) |
31 | DEF_HELPER_FLAGS_2(neon_qzip32, TCG_CALL_NO_RWG, void, ptr, ptr) | 25 | FIELD(TBFLAG_ANY, PSTATE__IL, 11, 1) |
32 | 26 | FIELD(TBFLAG_ANY, FGT_ACTIVE, 12, 1) | |
33 | -DEF_HELPER_FLAGS_3(crypto_aese, TCG_CALL_NO_RWG, void, ptr, ptr, i32) | 27 | +FIELD(TBFLAG_ANY, FGT_SVC, 13, 1) |
34 | +DEF_HELPER_FLAGS_4(crypto_aese, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | 28 | |
35 | DEF_HELPER_FLAGS_3(crypto_aesmc, TCG_CALL_NO_RWG, void, ptr, ptr, i32) | 29 | /* |
36 | 30 | * Bit usage when in AArch32 state, both A- and M-profile. | |
37 | DEF_HELPER_FLAGS_4(crypto_sha1_3reg, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | 31 | diff --git a/target/arm/translate.h b/target/arm/translate.h |
38 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_5(crypto_sm3tt, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32, i32) | 32 | index XXXXXXX..XXXXXXX 100644 |
39 | DEF_HELPER_FLAGS_3(crypto_sm3partw1, TCG_CALL_NO_RWG, void, ptr, ptr, ptr) | 33 | --- a/target/arm/translate.h |
40 | DEF_HELPER_FLAGS_3(crypto_sm3partw2, TCG_CALL_NO_RWG, void, ptr, ptr, ptr) | 34 | +++ b/target/arm/translate.h |
41 | 35 | @@ -XXX,XX +XXX,XX @@ typedef struct DisasContext { | |
42 | -DEF_HELPER_FLAGS_2(crypto_sm4e, TCG_CALL_NO_RWG, void, ptr, ptr) | 36 | bool fgt_active; |
43 | -DEF_HELPER_FLAGS_3(crypto_sm4ekey, TCG_CALL_NO_RWG, void, ptr, ptr, ptr) | 37 | /* True if fine-grained trap on ERET is enabled */ |
44 | +DEF_HELPER_FLAGS_4(crypto_sm4e, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | 38 | bool fgt_eret; |
45 | +DEF_HELPER_FLAGS_4(crypto_sm4ekey, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | 39 | + /* True if fine-grained trap on SVC is enabled */ |
46 | 40 | + bool fgt_svc; | |
47 | DEF_HELPER_FLAGS_3(crc32, TCG_CALL_NO_RWG_SE, i32, i32, i32, i32) | 41 | /* |
48 | DEF_HELPER_FLAGS_3(crc32c, TCG_CALL_NO_RWG_SE, i32, i32, i32, i32) | 42 | * >= 0, a copy of PSTATE.BTYPE, which will be 0 without v8.5-BTI. |
49 | diff --git a/target/arm/vec_internal.h b/target/arm/vec_internal.h | 43 | * < 0, set by the current instruction. |
50 | new file mode 100644 | 44 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
51 | index XXXXXXX..XXXXXXX | 45 | index XXXXXXX..XXXXXXX 100644 |
52 | --- /dev/null | 46 | --- a/target/arm/helper.c |
53 | +++ b/target/arm/vec_internal.h | 47 | +++ b/target/arm/helper.c |
54 | @@ -XXX,XX +XXX,XX @@ | 48 | @@ -XXX,XX +XXX,XX @@ ARMMMUIdx arm_mmu_idx(CPUARMState *env) |
55 | +/* | 49 | return arm_mmu_idx_el(env, arm_current_el(env)); |
56 | + * ARM AdvSIMD / SVE Vector Helpers | 50 | } |
57 | + * | 51 | |
58 | + * Copyright (c) 2020 Linaro | 52 | +static inline bool fgt_svc(CPUARMState *env, int el) |
59 | + * | ||
60 | + * This library is free software; you can redistribute it and/or | ||
61 | + * modify it under the terms of the GNU Lesser General Public | ||
62 | + * License as published by the Free Software Foundation; either | ||
63 | + * version 2 of the License, or (at your option) any later version. | ||
64 | + * | ||
65 | + * This library is distributed in the hope that it will be useful, | ||
66 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
67 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
68 | + * Lesser General Public License for more details. | ||
69 | + * | ||
70 | + * You should have received a copy of the GNU Lesser General Public | ||
71 | + * License along with this library; if not, see <http://www.gnu.org/licenses/>. | ||
72 | + */ | ||
73 | + | ||
74 | +#ifndef TARGET_ARM_VEC_INTERNALS_H | ||
75 | +#define TARGET_ARM_VEC_INTERNALS_H | ||
76 | + | ||
77 | +static inline void clear_tail(void *vd, uintptr_t opr_sz, uintptr_t max_sz) | ||
78 | +{ | 53 | +{ |
79 | + uint64_t *d = vd + opr_sz; | 54 | + /* |
80 | + uintptr_t i; | 55 | + * Assuming fine-grained-traps are active, return true if we |
81 | + | 56 | + * should be trapping on SVC instructions. Only AArch64 can |
82 | + for (i = opr_sz; i < max_sz; i += 8) { | 57 | + * trap on an SVC at EL1, but we don't need to special-case this |
83 | + *d++ = 0; | 58 | + * because if this is AArch32 EL1 then arm_fgt_active() is false. |
84 | + } | 59 | + * We also know el is 0 or 1. |
60 | + */ | ||
61 | + return el == 0 ? | ||
62 | + FIELD_EX64(env->cp15.fgt_exec[FGTREG_HFGITR], HFGITR_EL2, SVC_EL0) : | ||
63 | + FIELD_EX64(env->cp15.fgt_exec[FGTREG_HFGITR], HFGITR_EL2, SVC_EL1); | ||
85 | +} | 64 | +} |
86 | + | 65 | + |
87 | +#endif /* TARGET_ARM_VEC_INTERNALS_H */ | 66 | static CPUARMTBFlags rebuild_hflags_common(CPUARMState *env, int fp_el, |
88 | diff --git a/target/arm/crypto_helper.c b/target/arm/crypto_helper.c | 67 | ARMMMUIdx mmu_idx, |
89 | index XXXXXXX..XXXXXXX 100644 | 68 | CPUARMTBFlags flags) |
90 | --- a/target/arm/crypto_helper.c | 69 | @@ -XXX,XX +XXX,XX @@ static CPUARMTBFlags rebuild_hflags_a32(CPUARMState *env, int fp_el, |
91 | +++ b/target/arm/crypto_helper.c | 70 | |
92 | @@ -XXX,XX +XXX,XX @@ | 71 | if (arm_fgt_active(env, el)) { |
93 | 72 | DP_TBFLAG_ANY(flags, FGT_ACTIVE, 1); | |
94 | #include "cpu.h" | 73 | + if (fgt_svc(env, el)) { |
95 | #include "exec/helper-proto.h" | 74 | + DP_TBFLAG_ANY(flags, FGT_SVC, 1); |
96 | +#include "tcg/tcg-gvec-desc.h" | 75 | + } |
97 | #include "crypto/aes.h" | 76 | } |
98 | +#include "vec_internal.h" | 77 | |
99 | 78 | if (env->uncached_cpsr & CPSR_IL) { | |
100 | union CRYPTO_STATE { | 79 | @@ -XXX,XX +XXX,XX @@ static CPUARMTBFlags rebuild_hflags_a64(CPUARMState *env, int el, int fp_el, |
101 | uint8_t bytes[16]; | 80 | if (FIELD_EX64(env->cp15.fgt_exec[FGTREG_HFGITR], HFGITR_EL2, ERET)) { |
102 | @@ -XXX,XX +XXX,XX @@ union CRYPTO_STATE { | 81 | DP_TBFLAG_A64(flags, FGT_ERET, 1); |
103 | #define CR_ST_WORD(state, i) (state.words[i]) | 82 | } |
104 | #endif | 83 | + if (fgt_svc(env, el)) { |
105 | 84 | + DP_TBFLAG_ANY(flags, FGT_SVC, 1); | |
106 | -void HELPER(crypto_aese)(void *vd, void *vm, uint32_t decrypt) | 85 | + } |
107 | +static void do_crypto_aese(uint64_t *rd, uint64_t *rn, | 86 | } |
108 | + uint64_t *rm, bool decrypt) | 87 | |
109 | { | 88 | if (cpu_isar_feature(aa64_mte, env_archcpu(env))) { |
110 | static uint8_t const * const sbox[2] = { AES_sbox, AES_isbox }; | ||
111 | static uint8_t const * const shift[2] = { AES_shifts, AES_ishifts }; | ||
112 | - uint64_t *rd = vd; | ||
113 | - uint64_t *rm = vm; | ||
114 | union CRYPTO_STATE rk = { .l = { rm[0], rm[1] } }; | ||
115 | - union CRYPTO_STATE st = { .l = { rd[0], rd[1] } }; | ||
116 | + union CRYPTO_STATE st = { .l = { rn[0], rn[1] } }; | ||
117 | int i; | ||
118 | |||
119 | - assert(decrypt < 2); | ||
120 | - | ||
121 | /* xor state vector with round key */ | ||
122 | rk.l[0] ^= st.l[0]; | ||
123 | rk.l[1] ^= st.l[1]; | ||
124 | @@ -XXX,XX +XXX,XX @@ void HELPER(crypto_aese)(void *vd, void *vm, uint32_t decrypt) | ||
125 | rd[1] = st.l[1]; | ||
126 | } | ||
127 | |||
128 | -void HELPER(crypto_aesmc)(void *vd, void *vm, uint32_t decrypt) | ||
129 | +void HELPER(crypto_aese)(void *vd, void *vn, void *vm, uint32_t desc) | ||
130 | +{ | ||
131 | + intptr_t i, opr_sz = simd_oprsz(desc); | ||
132 | + bool decrypt = simd_data(desc); | ||
133 | + | ||
134 | + for (i = 0; i < opr_sz; i += 16) { | ||
135 | + do_crypto_aese(vd + i, vn + i, vm + i, decrypt); | ||
136 | + } | ||
137 | + clear_tail(vd, opr_sz, simd_maxsz(desc)); | ||
138 | +} | ||
139 | + | ||
140 | +static void do_crypto_aesmc(uint64_t *rd, uint64_t *rm, bool decrypt) | ||
141 | { | ||
142 | static uint32_t const mc[][256] = { { | ||
143 | /* MixColumns lookup table */ | ||
144 | @@ -XXX,XX +XXX,XX @@ void HELPER(crypto_aesmc)(void *vd, void *vm, uint32_t decrypt) | ||
145 | 0xbe805d9f, 0xb58d5491, 0xa89a4f83, 0xa397468d, | ||
146 | } }; | ||
147 | |||
148 | - uint64_t *rd = vd; | ||
149 | - uint64_t *rm = vm; | ||
150 | union CRYPTO_STATE st = { .l = { rm[0], rm[1] } }; | ||
151 | int i; | ||
152 | |||
153 | - assert(decrypt < 2); | ||
154 | - | ||
155 | for (i = 0; i < 16; i += 4) { | ||
156 | CR_ST_WORD(st, i >> 2) = | ||
157 | mc[decrypt][CR_ST_BYTE(st, i)] ^ | ||
158 | @@ -XXX,XX +XXX,XX @@ void HELPER(crypto_aesmc)(void *vd, void *vm, uint32_t decrypt) | ||
159 | rd[1] = st.l[1]; | ||
160 | } | ||
161 | |||
162 | +void HELPER(crypto_aesmc)(void *vd, void *vm, uint32_t desc) | ||
163 | +{ | ||
164 | + intptr_t i, opr_sz = simd_oprsz(desc); | ||
165 | + bool decrypt = simd_data(desc); | ||
166 | + | ||
167 | + for (i = 0; i < opr_sz; i += 16) { | ||
168 | + do_crypto_aesmc(vd + i, vm + i, decrypt); | ||
169 | + } | ||
170 | + clear_tail(vd, opr_sz, simd_maxsz(desc)); | ||
171 | +} | ||
172 | + | ||
173 | /* | ||
174 | * SHA-1 logical functions | ||
175 | */ | ||
176 | @@ -XXX,XX +XXX,XX @@ static uint8_t const sm4_sbox[] = { | ||
177 | 0x79, 0xee, 0x5f, 0x3e, 0xd7, 0xcb, 0x39, 0x48, | ||
178 | }; | ||
179 | |||
180 | -void HELPER(crypto_sm4e)(void *vd, void *vn) | ||
181 | +static void do_crypto_sm4e(uint64_t *rd, uint64_t *rn, uint64_t *rm) | ||
182 | { | ||
183 | - uint64_t *rd = vd; | ||
184 | - uint64_t *rn = vn; | ||
185 | - union CRYPTO_STATE d = { .l = { rd[0], rd[1] } }; | ||
186 | - union CRYPTO_STATE n = { .l = { rn[0], rn[1] } }; | ||
187 | + union CRYPTO_STATE d = { .l = { rn[0], rn[1] } }; | ||
188 | + union CRYPTO_STATE n = { .l = { rm[0], rm[1] } }; | ||
189 | uint32_t t, i; | ||
190 | |||
191 | for (i = 0; i < 4; i++) { | ||
192 | @@ -XXX,XX +XXX,XX @@ void HELPER(crypto_sm4e)(void *vd, void *vn) | ||
193 | rd[1] = d.l[1]; | ||
194 | } | ||
195 | |||
196 | -void HELPER(crypto_sm4ekey)(void *vd, void *vn, void* vm) | ||
197 | +void HELPER(crypto_sm4e)(void *vd, void *vn, void *vm, uint32_t desc) | ||
198 | +{ | ||
199 | + intptr_t i, opr_sz = simd_oprsz(desc); | ||
200 | + | ||
201 | + for (i = 0; i < opr_sz; i += 16) { | ||
202 | + do_crypto_sm4e(vd + i, vn + i, vm + i); | ||
203 | + } | ||
204 | + clear_tail(vd, opr_sz, simd_maxsz(desc)); | ||
205 | +} | ||
206 | + | ||
207 | +static void do_crypto_sm4ekey(uint64_t *rd, uint64_t *rn, uint64_t *rm) | ||
208 | { | ||
209 | - uint64_t *rd = vd; | ||
210 | - uint64_t *rn = vn; | ||
211 | - uint64_t *rm = vm; | ||
212 | union CRYPTO_STATE d; | ||
213 | union CRYPTO_STATE n = { .l = { rn[0], rn[1] } }; | ||
214 | union CRYPTO_STATE m = { .l = { rm[0], rm[1] } }; | ||
215 | @@ -XXX,XX +XXX,XX @@ void HELPER(crypto_sm4ekey)(void *vd, void *vn, void* vm) | ||
216 | rd[0] = d.l[0]; | ||
217 | rd[1] = d.l[1]; | ||
218 | } | ||
219 | + | ||
220 | +void HELPER(crypto_sm4ekey)(void *vd, void *vn, void* vm, uint32_t desc) | ||
221 | +{ | ||
222 | + intptr_t i, opr_sz = simd_oprsz(desc); | ||
223 | + | ||
224 | + for (i = 0; i < opr_sz; i += 16) { | ||
225 | + do_crypto_sm4ekey(vd + i, vn + i, vm + i); | ||
226 | + } | ||
227 | + clear_tail(vd, opr_sz, simd_maxsz(desc)); | ||
228 | +} | ||
229 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 89 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c |
230 | index XXXXXXX..XXXXXXX 100644 | 90 | index XXXXXXX..XXXXXXX 100644 |
231 | --- a/target/arm/translate-a64.c | 91 | --- a/target/arm/translate-a64.c |
232 | +++ b/target/arm/translate-a64.c | 92 | +++ b/target/arm/translate-a64.c |
233 | @@ -XXX,XX +XXX,XX @@ static void gen_gvec_fn4(DisasContext *s, bool is_q, int rd, int rn, int rm, | 93 | @@ -XXX,XX +XXX,XX @@ static void disas_exc(DisasContext *s, uint32_t insn) |
234 | is_q ? 16 : 8, vec_full_reg_size(s)); | 94 | int opc = extract32(insn, 21, 3); |
235 | } | 95 | int op2_ll = extract32(insn, 0, 5); |
236 | 96 | int imm16 = extract32(insn, 5, 16); | |
237 | +/* Expand a 2-operand operation using an out-of-line helper. */ | 97 | + uint32_t syndrome; |
238 | +static void gen_gvec_op2_ool(DisasContext *s, bool is_q, int rd, | 98 | |
239 | + int rn, int data, gen_helper_gvec_2 *fn) | 99 | switch (opc) { |
240 | +{ | 100 | case 0: |
241 | + tcg_gen_gvec_2_ool(vec_full_reg_offset(s, rd), | 101 | @@ -XXX,XX +XXX,XX @@ static void disas_exc(DisasContext *s, uint32_t insn) |
242 | + vec_full_reg_offset(s, rn), | 102 | */ |
243 | + is_q ? 16 : 8, vec_full_reg_size(s), data, fn); | 103 | switch (op2_ll) { |
244 | +} | 104 | case 1: /* SVC */ |
245 | + | 105 | + syndrome = syn_aa64_svc(imm16); |
246 | /* Expand a 3-operand operation using an out-of-line helper. */ | 106 | + if (s->fgt_svc) { |
247 | static void gen_gvec_op3_ool(DisasContext *s, bool is_q, int rd, | 107 | + gen_exception_insn_el(s, 0, EXCP_UDEF, syndrome, 2); |
248 | int rn, int rm, int data, gen_helper_gvec_3 *fn) | 108 | + break; |
249 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_aes(DisasContext *s, uint32_t insn) | 109 | + } |
250 | int rn = extract32(insn, 5, 5); | 110 | gen_ss_advance(s); |
251 | int rd = extract32(insn, 0, 5); | 111 | - gen_exception_insn(s, 4, EXCP_SWI, syn_aa64_svc(imm16)); |
252 | int decrypt; | 112 | + gen_exception_insn(s, 4, EXCP_SWI, syndrome); |
253 | - TCGv_ptr tcg_rd_ptr, tcg_rn_ptr; | ||
254 | - TCGv_i32 tcg_decrypt; | ||
255 | - CryptoThreeOpIntFn *genfn; | ||
256 | + gen_helper_gvec_2 *genfn2 = NULL; | ||
257 | + gen_helper_gvec_3 *genfn3 = NULL; | ||
258 | |||
259 | if (!dc_isar_feature(aa64_aes, s) || size != 0) { | ||
260 | unallocated_encoding(s); | ||
261 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_aes(DisasContext *s, uint32_t insn) | ||
262 | switch (opcode) { | ||
263 | case 0x4: /* AESE */ | ||
264 | decrypt = 0; | ||
265 | - genfn = gen_helper_crypto_aese; | ||
266 | + genfn3 = gen_helper_crypto_aese; | ||
267 | break; | ||
268 | case 0x6: /* AESMC */ | ||
269 | decrypt = 0; | ||
270 | - genfn = gen_helper_crypto_aesmc; | ||
271 | + genfn2 = gen_helper_crypto_aesmc; | ||
272 | break; | ||
273 | case 0x5: /* AESD */ | ||
274 | decrypt = 1; | ||
275 | - genfn = gen_helper_crypto_aese; | ||
276 | + genfn3 = gen_helper_crypto_aese; | ||
277 | break; | ||
278 | case 0x7: /* AESIMC */ | ||
279 | decrypt = 1; | ||
280 | - genfn = gen_helper_crypto_aesmc; | ||
281 | + genfn2 = gen_helper_crypto_aesmc; | ||
282 | break; | ||
283 | default: | ||
284 | unallocated_encoding(s); | ||
285 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_aes(DisasContext *s, uint32_t insn) | ||
286 | if (!fp_access_check(s)) { | ||
287 | return; | ||
288 | } | ||
289 | - | ||
290 | - tcg_rd_ptr = vec_full_reg_ptr(s, rd); | ||
291 | - tcg_rn_ptr = vec_full_reg_ptr(s, rn); | ||
292 | - tcg_decrypt = tcg_const_i32(decrypt); | ||
293 | - | ||
294 | - genfn(tcg_rd_ptr, tcg_rn_ptr, tcg_decrypt); | ||
295 | - | ||
296 | - tcg_temp_free_ptr(tcg_rd_ptr); | ||
297 | - tcg_temp_free_ptr(tcg_rn_ptr); | ||
298 | - tcg_temp_free_i32(tcg_decrypt); | ||
299 | + if (genfn2) { | ||
300 | + gen_gvec_op2_ool(s, true, rd, rn, decrypt, genfn2); | ||
301 | + } else { | ||
302 | + gen_gvec_op3_ool(s, true, rd, rd, rn, decrypt, genfn3); | ||
303 | + } | ||
304 | } | ||
305 | |||
306 | /* Crypto three-reg SHA | ||
307 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_three_reg_sha512(DisasContext *s, uint32_t insn) | ||
308 | int rn = extract32(insn, 5, 5); | ||
309 | int rd = extract32(insn, 0, 5); | ||
310 | bool feature; | ||
311 | - CryptoThreeOpFn *genfn; | ||
312 | + CryptoThreeOpFn *genfn = NULL; | ||
313 | + gen_helper_gvec_3 *oolfn = NULL; | ||
314 | |||
315 | if (o == 0) { | ||
316 | switch (opcode) { | ||
317 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_three_reg_sha512(DisasContext *s, uint32_t insn) | ||
318 | break; | 113 | break; |
319 | case 2: /* SM4EKEY */ | 114 | case 2: /* HVC */ |
320 | feature = dc_isar_feature(aa64_sm4, s); | 115 | if (s->current_el == 0) { |
321 | - genfn = gen_helper_crypto_sm4ekey; | 116 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_init_disas_context(DisasContextBase *dcbase, |
322 | + oolfn = gen_helper_crypto_sm4ekey; | 117 | dc->align_mem = EX_TBFLAG_ANY(tb_flags, ALIGN_MEM); |
323 | break; | 118 | dc->pstate_il = EX_TBFLAG_ANY(tb_flags, PSTATE__IL); |
324 | default: | 119 | dc->fgt_active = EX_TBFLAG_ANY(tb_flags, FGT_ACTIVE); |
325 | unallocated_encoding(s); | 120 | + dc->fgt_svc = EX_TBFLAG_ANY(tb_flags, FGT_SVC); |
326 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_three_reg_sha512(DisasContext *s, uint32_t insn) | 121 | dc->fgt_eret = EX_TBFLAG_A64(tb_flags, FGT_ERET); |
327 | return; | 122 | dc->sve_excp_el = EX_TBFLAG_A64(tb_flags, SVEEXC_EL); |
328 | } | 123 | dc->sme_excp_el = EX_TBFLAG_A64(tb_flags, SMEEXC_EL); |
329 | |||
330 | + if (oolfn) { | ||
331 | + gen_gvec_op3_ool(s, true, rd, rn, rm, 0, oolfn); | ||
332 | + return; | ||
333 | + } | ||
334 | + | ||
335 | if (genfn) { | ||
336 | TCGv_ptr tcg_rd_ptr, tcg_rn_ptr, tcg_rm_ptr; | ||
337 | |||
338 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_two_reg_sha512(DisasContext *s, uint32_t insn) | ||
339 | TCGv_ptr tcg_rd_ptr, tcg_rn_ptr; | ||
340 | bool feature; | ||
341 | CryptoTwoOpFn *genfn; | ||
342 | + gen_helper_gvec_3 *oolfn = NULL; | ||
343 | |||
344 | switch (opcode) { | ||
345 | case 0: /* SHA512SU0 */ | ||
346 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_two_reg_sha512(DisasContext *s, uint32_t insn) | ||
347 | break; | ||
348 | case 1: /* SM4E */ | ||
349 | feature = dc_isar_feature(aa64_sm4, s); | ||
350 | - genfn = gen_helper_crypto_sm4e; | ||
351 | + oolfn = gen_helper_crypto_sm4e; | ||
352 | break; | ||
353 | default: | ||
354 | unallocated_encoding(s); | ||
355 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_two_reg_sha512(DisasContext *s, uint32_t insn) | ||
356 | return; | ||
357 | } | ||
358 | |||
359 | + if (oolfn) { | ||
360 | + gen_gvec_op3_ool(s, true, rd, rd, rn, 0, oolfn); | ||
361 | + return; | ||
362 | + } | ||
363 | + | ||
364 | tcg_rd_ptr = vec_full_reg_ptr(s, rd); | ||
365 | tcg_rn_ptr = vec_full_reg_ptr(s, rn); | ||
366 | |||
367 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 124 | diff --git a/target/arm/translate.c b/target/arm/translate.c |
368 | index XXXXXXX..XXXXXXX 100644 | 125 | index XXXXXXX..XXXXXXX 100644 |
369 | --- a/target/arm/translate.c | 126 | --- a/target/arm/translate.c |
370 | +++ b/target/arm/translate.c | 127 | +++ b/target/arm/translate.c |
371 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | 128 | @@ -XXX,XX +XXX,XX @@ static bool trans_SVC(DisasContext *s, arg_SVC *a) |
372 | if (!dc_isar_feature(aa32_aes, s) || ((rm | rd) & 1)) { | 129 | (a->imm == semihost_imm)) { |
373 | return 1; | 130 | gen_exception_internal_insn(s, EXCP_SEMIHOST); |
374 | } | 131 | } else { |
375 | - ptr1 = vfp_reg_ptr(true, rd); | 132 | - gen_update_pc(s, curr_insn_len(s)); |
376 | - ptr2 = vfp_reg_ptr(true, rm); | 133 | - s->svc_imm = a->imm; |
377 | - | 134 | - s->base.is_jmp = DISAS_SWI; |
378 | - /* Bit 6 is the lowest opcode bit; it distinguishes between | 135 | + if (s->fgt_svc) { |
379 | - * encryption (AESE/AESMC) and decryption (AESD/AESIMC) | 136 | + uint32_t syndrome = syn_aa32_svc(a->imm, s->thumb); |
380 | - */ | 137 | + gen_exception_insn_el(s, 0, EXCP_UDEF, syndrome, 2); |
381 | - tmp3 = tcg_const_i32(extract32(insn, 6, 1)); | 138 | + } else { |
382 | - | 139 | + gen_update_pc(s, curr_insn_len(s)); |
383 | + /* | 140 | + s->svc_imm = a->imm; |
384 | + * Bit 6 is the lowest opcode bit; it distinguishes | 141 | + s->base.is_jmp = DISAS_SWI; |
385 | + * between encryption (AESE/AESMC) and decryption | 142 | + } |
386 | + * (AESD/AESIMC). | 143 | } |
387 | + */ | 144 | return true; |
388 | if (op == NEON_2RM_AESE) { | 145 | } |
389 | - gen_helper_crypto_aese(ptr1, ptr2, tmp3); | 146 | @@ -XXX,XX +XXX,XX @@ static void arm_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) |
390 | + tcg_gen_gvec_3_ool(vfp_reg_offset(true, rd), | 147 | dc->align_mem = EX_TBFLAG_ANY(tb_flags, ALIGN_MEM); |
391 | + vfp_reg_offset(true, rd), | 148 | dc->pstate_il = EX_TBFLAG_ANY(tb_flags, PSTATE__IL); |
392 | + vfp_reg_offset(true, rm), | 149 | dc->fgt_active = EX_TBFLAG_ANY(tb_flags, FGT_ACTIVE); |
393 | + 16, 16, extract32(insn, 6, 1), | 150 | + dc->fgt_svc = EX_TBFLAG_ANY(tb_flags, FGT_SVC); |
394 | + gen_helper_crypto_aese); | 151 | |
395 | } else { | 152 | if (arm_feature(env, ARM_FEATURE_M)) { |
396 | - gen_helper_crypto_aesmc(ptr1, ptr2, tmp3); | 153 | dc->vfp_enabled = 1; |
397 | + tcg_gen_gvec_2_ool(vfp_reg_offset(true, rd), | ||
398 | + vfp_reg_offset(true, rm), | ||
399 | + 16, 16, extract32(insn, 6, 1), | ||
400 | + gen_helper_crypto_aesmc); | ||
401 | } | ||
402 | - tcg_temp_free_ptr(ptr1); | ||
403 | - tcg_temp_free_ptr(ptr2); | ||
404 | - tcg_temp_free_i32(tmp3); | ||
405 | break; | ||
406 | case NEON_2RM_SHA1H: | ||
407 | if (!dc_isar_feature(aa32_sha1, s) || ((rm | rd) & 1)) { | ||
408 | diff --git a/target/arm/vec_helper.c b/target/arm/vec_helper.c | ||
409 | index XXXXXXX..XXXXXXX 100644 | ||
410 | --- a/target/arm/vec_helper.c | ||
411 | +++ b/target/arm/vec_helper.c | ||
412 | @@ -XXX,XX +XXX,XX @@ | ||
413 | #include "exec/helper-proto.h" | ||
414 | #include "tcg/tcg-gvec-desc.h" | ||
415 | #include "fpu/softfloat.h" | ||
416 | - | ||
417 | +#include "vec_internal.h" | ||
418 | |||
419 | /* Note that vector data is stored in host-endian 64-bit chunks, | ||
420 | so addressing units smaller than that needs a host-endian fixup. */ | ||
421 | @@ -XXX,XX +XXX,XX @@ | ||
422 | #define H4(x) (x) | ||
423 | #endif | ||
424 | |||
425 | -static void clear_tail(void *vd, uintptr_t opr_sz, uintptr_t max_sz) | ||
426 | -{ | ||
427 | - uint64_t *d = vd + opr_sz; | ||
428 | - uintptr_t i; | ||
429 | - | ||
430 | - for (i = opr_sz; i < max_sz; i += 8) { | ||
431 | - *d++ = 0; | ||
432 | - } | ||
433 | -} | ||
434 | - | ||
435 | /* Signed saturating rounding doubling multiply-accumulate high half, 16-bit */ | ||
436 | static int16_t inl_qrdmlah_s16(int16_t src1, int16_t src2, | ||
437 | int16_t src3, uint32_t *sat) | ||
438 | -- | 154 | -- |
439 | 2.20.1 | 155 | 2.34.1 |
440 | |||
441 | diff view generated by jsdifflib |
1 | Convert the VSHL and VSLI insns from the Neon 2-registers-and-a-shift | 1 | FEAT_FGT also implements an extra trap bit in the MDCR_EL2 and |
---|---|---|---|
2 | group to decodetree. | 2 | MDCR_EL3 registers: bit TDCC enables trapping of use of the Debug |
3 | Comms Channel registers OSDTRRX_EL1, OSDTRTX_EL1, MDCCSR_EL0, | ||
4 | MDCCINT_EL0, DBGDTR_EL0, DBGDTRRX_EL0 and DBGDTRTX_EL0 (and their | ||
5 | AArch32 equivalents). This trapping is independent of whether | ||
6 | fine-grained traps are enabled or not. | ||
7 | |||
8 | Implement these extra traps. (We don't implement DBGDTR_EL0, | ||
9 | DBGDTRRX_EL0 and DBGDTRTX_EL0.) | ||
3 | 10 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 12 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
6 | Message-id: 20200522145520.6778-2-peter.maydell@linaro.org | 13 | Tested-by: Fuad Tabba <tabba@google.com> |
14 | Message-id: 20230130182459.3309057-23-peter.maydell@linaro.org | ||
15 | Message-id: 20230127175507.2895013-23-peter.maydell@linaro.org | ||
7 | --- | 16 | --- |
8 | target/arm/neon-dp.decode | 25 ++++++++++++++++++++++ | 17 | target/arm/debug_helper.c | 35 +++++++++++++++++++++++++++++++---- |
9 | target/arm/translate-neon.inc.c | 38 +++++++++++++++++++++++++++++++++ | 18 | 1 file changed, 31 insertions(+), 4 deletions(-) |
10 | target/arm/translate.c | 18 +++++++--------- | ||
11 | 3 files changed, 71 insertions(+), 10 deletions(-) | ||
12 | 19 | ||
13 | diff --git a/target/arm/neon-dp.decode b/target/arm/neon-dp.decode | 20 | diff --git a/target/arm/debug_helper.c b/target/arm/debug_helper.c |
14 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/neon-dp.decode | 22 | --- a/target/arm/debug_helper.c |
16 | +++ b/target/arm/neon-dp.decode | 23 | +++ b/target/arm/debug_helper.c |
17 | @@ -XXX,XX +XXX,XX @@ VRECPS_fp_3s 1111 001 0 0 . 0 . .... .... 1111 ... 1 .... @3same_fp | 24 | @@ -XXX,XX +XXX,XX @@ static CPAccessResult access_tda(CPUARMState *env, const ARMCPRegInfo *ri, |
18 | VRSQRTS_fp_3s 1111 001 0 0 . 1 . .... .... 1111 ... 1 .... @3same_fp | 25 | return CP_ACCESS_OK; |
19 | VMAXNM_fp_3s 1111 001 1 0 . 0 . .... .... 1111 ... 1 .... @3same_fp | 26 | } |
20 | VMINNM_fp_3s 1111 001 1 0 . 1 . .... .... 1111 ... 1 .... @3same_fp | 27 | |
28 | +/* | ||
29 | + * Check for traps to Debug Comms Channel registers. If FEAT_FGT | ||
30 | + * is implemented then these are controlled by MDCR_EL2.TDCC for | ||
31 | + * EL2 and MDCR_EL3.TDCC for EL3. They are also controlled by | ||
32 | + * the general debug access trap bits MDCR_EL2.TDA and MDCR_EL3.TDA. | ||
33 | + */ | ||
34 | +static CPAccessResult access_tdcc(CPUARMState *env, const ARMCPRegInfo *ri, | ||
35 | + bool isread) | ||
36 | +{ | ||
37 | + int el = arm_current_el(env); | ||
38 | + uint64_t mdcr_el2 = arm_mdcr_el2_eff(env); | ||
39 | + bool mdcr_el2_tda = (mdcr_el2 & MDCR_TDA) || (mdcr_el2 & MDCR_TDE) || | ||
40 | + (arm_hcr_el2_eff(env) & HCR_TGE); | ||
41 | + bool mdcr_el2_tdcc = cpu_isar_feature(aa64_fgt, env_archcpu(env)) && | ||
42 | + (mdcr_el2 & MDCR_TDCC); | ||
43 | + bool mdcr_el3_tdcc = cpu_isar_feature(aa64_fgt, env_archcpu(env)) && | ||
44 | + (env->cp15.mdcr_el3 & MDCR_TDCC); | ||
21 | + | 45 | + |
22 | +###################################################################### | 46 | + if (el < 2 && (mdcr_el2_tda || mdcr_el2_tdcc)) { |
23 | +# 2-reg-and-shift grouping: | 47 | + return CP_ACCESS_TRAP_EL2; |
24 | +# 1111 001 U 1 D immH:3 immL:3 Vd:4 opc:4 L Q M 1 Vm:4 | ||
25 | +###################################################################### | ||
26 | +&2reg_shift vm vd q shift size | ||
27 | + | ||
28 | +@2reg_shl_d .... ... . . . shift:6 .... .... 1 q:1 . . .... \ | ||
29 | + &2reg_shift vm=%vm_dp vd=%vd_dp size=3 | ||
30 | +@2reg_shl_s .... ... . . . 1 shift:5 .... .... 0 q:1 . . .... \ | ||
31 | + &2reg_shift vm=%vm_dp vd=%vd_dp size=2 | ||
32 | +@2reg_shl_h .... ... . . . 01 shift:4 .... .... 0 q:1 . . .... \ | ||
33 | + &2reg_shift vm=%vm_dp vd=%vd_dp size=1 | ||
34 | +@2reg_shl_b .... ... . . . 001 shift:3 .... .... 0 q:1 . . .... \ | ||
35 | + &2reg_shift vm=%vm_dp vd=%vd_dp size=0 | ||
36 | + | ||
37 | +VSHL_2sh 1111 001 0 1 . ...... .... 0101 . . . 1 .... @2reg_shl_d | ||
38 | +VSHL_2sh 1111 001 0 1 . ...... .... 0101 . . . 1 .... @2reg_shl_s | ||
39 | +VSHL_2sh 1111 001 0 1 . ...... .... 0101 . . . 1 .... @2reg_shl_h | ||
40 | +VSHL_2sh 1111 001 0 1 . ...... .... 0101 . . . 1 .... @2reg_shl_b | ||
41 | + | ||
42 | +VSLI_2sh 1111 001 1 1 . ...... .... 0101 . . . 1 .... @2reg_shl_d | ||
43 | +VSLI_2sh 1111 001 1 1 . ...... .... 0101 . . . 1 .... @2reg_shl_s | ||
44 | +VSLI_2sh 1111 001 1 1 . ...... .... 0101 . . . 1 .... @2reg_shl_h | ||
45 | +VSLI_2sh 1111 001 1 1 . ...... .... 0101 . . . 1 .... @2reg_shl_b | ||
46 | diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c | ||
47 | index XXXXXXX..XXXXXXX 100644 | ||
48 | --- a/target/arm/translate-neon.inc.c | ||
49 | +++ b/target/arm/translate-neon.inc.c | ||
50 | @@ -XXX,XX +XXX,XX @@ static bool do_3same_fp_pair(DisasContext *s, arg_3same *a, VFPGen3OpSPFn *fn) | ||
51 | DO_3S_FP_PAIR(VPADD, gen_helper_vfp_adds) | ||
52 | DO_3S_FP_PAIR(VPMAX, gen_helper_vfp_maxs) | ||
53 | DO_3S_FP_PAIR(VPMIN, gen_helper_vfp_mins) | ||
54 | + | ||
55 | +static bool do_vector_2sh(DisasContext *s, arg_2reg_shift *a, GVecGen2iFn *fn) | ||
56 | +{ | ||
57 | + /* Handle a 2-reg-shift insn which can be vectorized. */ | ||
58 | + int vec_size = a->q ? 16 : 8; | ||
59 | + int rd_ofs = neon_reg_offset(a->vd, 0); | ||
60 | + int rm_ofs = neon_reg_offset(a->vm, 0); | ||
61 | + | ||
62 | + if (!arm_dc_feature(s, ARM_FEATURE_NEON)) { | ||
63 | + return false; | ||
64 | + } | 48 | + } |
65 | + | 49 | + if (el < 3 && ((env->cp15.mdcr_el3 & MDCR_TDA) || mdcr_el3_tdcc)) { |
66 | + /* UNDEF accesses to D16-D31 if they don't exist. */ | 50 | + return CP_ACCESS_TRAP_EL3; |
67 | + if (!dc_isar_feature(aa32_simd_r32, s) && | ||
68 | + ((a->vd | a->vm) & 0x10)) { | ||
69 | + return false; | ||
70 | + } | 51 | + } |
71 | + | 52 | + return CP_ACCESS_OK; |
72 | + if ((a->vm | a->vd) & a->q) { | ||
73 | + return false; | ||
74 | + } | ||
75 | + | ||
76 | + if (!vfp_access_check(s)) { | ||
77 | + return true; | ||
78 | + } | ||
79 | + | ||
80 | + fn(a->size, rd_ofs, rm_ofs, a->shift, vec_size, vec_size); | ||
81 | + return true; | ||
82 | +} | 53 | +} |
83 | + | 54 | + |
84 | +#define DO_2SH(INSN, FUNC) \ | 55 | static void oslar_write(CPUARMState *env, const ARMCPRegInfo *ri, |
85 | + static bool trans_##INSN##_2sh(DisasContext *s, arg_2reg_shift *a) \ | 56 | uint64_t value) |
86 | + { \ | 57 | { |
87 | + return do_vector_2sh(s, a, FUNC); \ | 58 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo debug_cp_reginfo[] = { |
88 | + } \ | 59 | */ |
89 | + | 60 | { .name = "MDCCSR_EL0", .state = ARM_CP_STATE_AA64, |
90 | +DO_2SH(VSHL, tcg_gen_gvec_shli) | 61 | .opc0 = 2, .opc1 = 3, .crn = 0, .crm = 1, .opc2 = 0, |
91 | +DO_2SH(VSLI, gen_gvec_sli) | 62 | - .access = PL0_R, .accessfn = access_tda, |
92 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 63 | + .access = PL0_R, .accessfn = access_tdcc, |
93 | index XXXXXXX..XXXXXXX 100644 | 64 | .type = ARM_CP_CONST, .resetvalue = 0 }, |
94 | --- a/target/arm/translate.c | 65 | /* |
95 | +++ b/target/arm/translate.c | 66 | * OSDTRRX_EL1/OSDTRTX_EL1 are used for save and restore of DBGDTRRX_EL0. |
96 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | 67 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo debug_cp_reginfo[] = { |
97 | if ((insn & 0x00380080) != 0) { | 68 | */ |
98 | /* Two registers and shift. */ | 69 | { .name = "OSDTRRX_EL1", .state = ARM_CP_STATE_BOTH, .cp = 14, |
99 | op = (insn >> 8) & 0xf; | 70 | .opc0 = 2, .opc1 = 0, .crn = 0, .crm = 0, .opc2 = 2, |
100 | + | 71 | - .access = PL1_RW, .accessfn = access_tda, |
101 | + switch (op) { | 72 | + .access = PL1_RW, .accessfn = access_tdcc, |
102 | + case 5: /* VSHL, VSLI */ | 73 | .type = ARM_CP_CONST, .resetvalue = 0 }, |
103 | + return 1; /* handled by decodetree */ | 74 | { .name = "OSDTRTX_EL1", .state = ARM_CP_STATE_BOTH, .cp = 14, |
104 | + default: | 75 | .opc0 = 2, .opc1 = 0, .crn = 0, .crm = 3, .opc2 = 2, |
105 | + break; | 76 | - .access = PL1_RW, .accessfn = access_tda, |
106 | + } | 77 | + .access = PL1_RW, .accessfn = access_tdcc, |
107 | + | 78 | .type = ARM_CP_CONST, .resetvalue = 0 }, |
108 | if (insn & (1 << 7)) { | 79 | /* |
109 | /* 64-bit shift. */ | 80 | * OSECCR_EL1 provides a mechanism for an operating system |
110 | if (op > 7) { | 81 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo debug_cp_reginfo[] = { |
111 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | 82 | */ |
112 | gen_gvec_sri(size, rd_ofs, rm_ofs, shift, | 83 | { .name = "MDCCINT_EL1", .state = ARM_CP_STATE_BOTH, |
113 | vec_size, vec_size); | 84 | .cp = 14, .opc0 = 2, .opc1 = 0, .crn = 0, .crm = 2, .opc2 = 0, |
114 | return 0; | 85 | - .access = PL1_RW, .accessfn = access_tda, |
115 | - | 86 | + .access = PL1_RW, .accessfn = access_tdcc, |
116 | - case 5: /* VSHL, VSLI */ | 87 | .type = ARM_CP_NOP }, |
117 | - if (u) { /* VSLI */ | 88 | /* |
118 | - gen_gvec_sli(size, rd_ofs, rm_ofs, shift, | 89 | * Dummy DBGCLAIM registers. |
119 | - vec_size, vec_size); | ||
120 | - } else { /* VSHL */ | ||
121 | - tcg_gen_gvec_shli(size, rd_ofs, rm_ofs, shift, | ||
122 | - vec_size, vec_size); | ||
123 | - } | ||
124 | - return 0; | ||
125 | } | ||
126 | |||
127 | if (size == 3) { | ||
128 | -- | 90 | -- |
129 | 2.20.1 | 91 | 2.34.1 |
130 | |||
131 | diff view generated by jsdifflib |
1 | From: Eden Mikitas <e.mikitas@gmail.com> | 1 | Update the ID registers for TCG's '-cpu max' to report the |
---|---|---|---|
2 | presence of FEAT_FGT Fine-Grained Traps support. | ||
2 | 3 | ||
3 | The while statement in question only checked if tx_burst is not 0. | 4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | tx_burst is a signed int, which is assigned the value put by the | 5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
5 | guest driver in ECSPI_CONREG. The burst length can be anywhere | 6 | Tested-by: Fuad Tabba <tabba@google.com> |
6 | between 1 and 4096, and since tx_burst is always decremented by 8 | 7 | Message-id: 20230130182459.3309057-24-peter.maydell@linaro.org |
7 | it could possibly underflow, causing an infinite loop. | 8 | Message-id: 20230127175507.2895013-24-peter.maydell@linaro.org |
9 | --- | ||
10 | docs/system/arm/emulation.rst | 1 + | ||
11 | target/arm/cpu64.c | 1 + | ||
12 | 2 files changed, 2 insertions(+) | ||
8 | 13 | ||
9 | Signed-off-by: Eden Mikitas <e.mikitas@gmail.com> | 14 | diff --git a/docs/system/arm/emulation.rst b/docs/system/arm/emulation.rst |
10 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | --- | ||
13 | hw/ssi/imx_spi.c | 2 +- | ||
14 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
15 | |||
16 | diff --git a/hw/ssi/imx_spi.c b/hw/ssi/imx_spi.c | ||
17 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/hw/ssi/imx_spi.c | 16 | --- a/docs/system/arm/emulation.rst |
19 | +++ b/hw/ssi/imx_spi.c | 17 | +++ b/docs/system/arm/emulation.rst |
20 | @@ -XXX,XX +XXX,XX @@ static void imx_spi_flush_txfifo(IMXSPIState *s) | 18 | @@ -XXX,XX +XXX,XX @@ the following architecture extensions: |
21 | 19 | - FEAT_ETS (Enhanced Translation Synchronization) | |
22 | rx = 0; | 20 | - FEAT_EVT (Enhanced Virtualization Traps) |
23 | 21 | - FEAT_FCMA (Floating-point complex number instructions) | |
24 | - while (tx_burst) { | 22 | +- FEAT_FGT (Fine-Grained Traps) |
25 | + while (tx_burst > 0) { | 23 | - FEAT_FHM (Floating-point half-precision multiplication instructions) |
26 | uint8_t byte = tx & 0xff; | 24 | - FEAT_FP16 (Half-precision floating-point data processing) |
27 | 25 | - FEAT_FRINTTS (Floating-point to integer instructions) | |
28 | DPRINTF("writing 0x%02x\n", (uint32_t)byte); | 26 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c |
27 | index XXXXXXX..XXXXXXX 100644 | ||
28 | --- a/target/arm/cpu64.c | ||
29 | +++ b/target/arm/cpu64.c | ||
30 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) | ||
31 | t = FIELD_DP64(t, ID_AA64MMFR0, TGRAN16_2, 2); /* 16k stage2 supported */ | ||
32 | t = FIELD_DP64(t, ID_AA64MMFR0, TGRAN64_2, 2); /* 64k stage2 supported */ | ||
33 | t = FIELD_DP64(t, ID_AA64MMFR0, TGRAN4_2, 2); /* 4k stage2 supported */ | ||
34 | + t = FIELD_DP64(t, ID_AA64MMFR0, FGT, 1); /* FEAT_FGT */ | ||
35 | cpu->isar.id_aa64mmfr0 = t; | ||
36 | |||
37 | t = cpu->isar.id_aa64mmfr1; | ||
29 | -- | 38 | -- |
30 | 2.20.1 | 39 | 2.34.1 |
31 | |||
32 | diff view generated by jsdifflib |