1 | Arm queue; some of the simpler stuff, things other have reviewed (thanks!), etc. | 1 | Two small bugfixes, plus most of RTH's refactoring of cpregs |
---|---|---|---|
2 | handling. | ||
2 | 3 | ||
3 | -- PMM | 4 | -- PMM |
4 | 5 | ||
5 | The following changes since commit 5d2f557b47dfbf8f23277a5bdd8473d4607c681a: | 6 | The following changes since commit 1fba9dc71a170b3a05b9d3272dd8ecfe7f26e215: |
6 | 7 | ||
7 | Merge remote-tracking branch 'remotes/kraxel/tags/vga-20200605-pull-request' into staging (2020-06-05 13:53:05 +0100) | 8 | Merge tag 'pull-request-2022-05-04' of https://gitlab.com/thuth/qemu into staging (2022-05-04 08:07:02 -0700) |
8 | 9 | ||
9 | are available in the Git repository at: | 10 | are available in the Git repository at: |
10 | 11 | ||
11 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20200605 | 12 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20220505 |
12 | 13 | ||
13 | for you to fetch changes up to 2c35a39eda0b16c2ed85c94cec204bf5efb97812: | 14 | for you to fetch changes up to 99a50d1a67c602126fc2b3a4812d3000eba9bf34: |
14 | 15 | ||
15 | target/arm: Convert Neon one-register-and-immediate insns to decodetree (2020-06-05 17:23:10 +0100) | 16 | target/arm: read access to performance counters from EL0 (2022-05-05 09:36:22 +0100) |
16 | 17 | ||
17 | ---------------------------------------------------------------- | 18 | ---------------------------------------------------------------- |
18 | target-arm queue: | 19 | target-arm queue: |
19 | hw/ssi/imx_spi: Handle tx burst lengths other than 8 correctly | 20 | * Enable read access to performance counters from EL0 |
20 | hw/input/pxa2xx_keypad: Replace hw_error() by qemu_log_mask() | 21 | * Enable SCTLR_EL1.BT0 for aarch64-linux-user |
21 | hw/arm/pxa2xx: Replace printf() call by qemu_log_mask() | 22 | * Refactoring of cpreg handling |
22 | target/arm: Convert crypto insns to gvec | ||
23 | hw/adc/stm32f2xx_adc: Correct memory region size and access size | ||
24 | tests/acceptance: Add a boot test for the xlnx-versal-virt machine | ||
25 | docs/system: Document Aspeed boards | ||
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 | 23 | ||
29 | ---------------------------------------------------------------- | 24 | ---------------------------------------------------------------- |
30 | Cédric Le Goater (1): | 25 | Alex Zuepke (1): |
31 | docs/system: Document Aspeed boards | 26 | target/arm: read access to performance counters from EL0 |
32 | 27 | ||
33 | Eden Mikitas (2): | 28 | Richard Henderson (22): |
34 | hw/ssi/imx_spi: changed while statement to prevent underflow | 29 | target/arm: Enable SCTLR_EL1.BT0 for aarch64-linux-user |
35 | hw/ssi/imx_spi: Removed unnecessary cast of rx data received from slave | 30 | target/arm: Split out cpregs.h |
31 | target/arm: Reorg CPAccessResult and access_check_cp_reg | ||
32 | target/arm: Replace sentinels with ARRAY_SIZE in cpregs.h | ||
33 | target/arm: Make some more cpreg data static const | ||
34 | target/arm: Reorg ARMCPRegInfo type field bits | ||
35 | target/arm: Avoid bare abort() or assert(0) | ||
36 | target/arm: Change cpreg access permissions to enum | ||
37 | target/arm: Name CPState type | ||
38 | target/arm: Name CPSecureState type | ||
39 | target/arm: Drop always-true test in define_arm_vh_e2h_redirects_aliases | ||
40 | target/arm: Store cpregs key in the hash table directly | ||
41 | target/arm: Merge allocation of the cpreg and its name | ||
42 | target/arm: Hoist computation of key in add_cpreg_to_hashtable | ||
43 | target/arm: Consolidate cpreg updates in add_cpreg_to_hashtable | ||
44 | target/arm: Use bool for is64 and ns in add_cpreg_to_hashtable | ||
45 | target/arm: Hoist isbanked computation in add_cpreg_to_hashtable | ||
46 | target/arm: Perform override check early in add_cpreg_to_hashtable | ||
47 | target/arm: Reformat comments in add_cpreg_to_hashtable | ||
48 | target/arm: Remove HOST_BIG_ENDIAN ifdef in add_cpreg_to_hashtable | ||
49 | target/arm: Add isar predicates for FEAT_Debugv8p2 | ||
50 | target/arm: Add isar_feature_{aa64,any}_ras | ||
36 | 51 | ||
37 | Paul Zimmerman (7): | 52 | target/arm/cpregs.h | 453 ++++++++++++++++++++++++++++++++++++++ |
38 | raspi: add BCM2835 SOC MPHI emulation | 53 | target/arm/cpu.h | 393 +++------------------------------ |
39 | dwc-hsotg (dwc2) USB host controller register definitions | 54 | hw/arm/pxa2xx.c | 2 +- |
40 | dwc-hsotg (dwc2) USB host controller state definitions | 55 | hw/arm/pxa2xx_pic.c | 2 +- |
41 | dwc-hsotg (dwc2) USB host controller emulation | 56 | hw/intc/arm_gicv3_cpuif.c | 6 +- |
42 | usb: add short-packet handling to usb-storage driver | 57 | hw/intc/arm_gicv3_kvm.c | 3 +- |
43 | wire in the dwc-hsotg (dwc2) USB host controller emulation | 58 | target/arm/cpu.c | 25 +-- |
44 | raspi2 acceptance test: add test for dwc-hsotg (dwc2) USB host | 59 | target/arm/cpu64.c | 2 +- |
45 | 60 | target/arm/cpu_tcg.c | 5 +- | |
46 | Peter Maydell (9): | 61 | target/arm/gdbstub.c | 5 +- |
47 | target/arm: Convert Neon VSHL and VSLI 2-reg-shift insn to decodetree | 62 | target/arm/helper.c | 358 +++++++++++++----------------- |
48 | target/arm: Convert Neon VSHR 2-reg-shift insns to decodetree | 63 | target/arm/hvf/hvf.c | 2 +- |
49 | target/arm: Convert Neon VSRA, VSRI, VRSHR, VRSRA 2-reg-shift insns to decodetree | 64 | target/arm/kvm-stub.c | 4 +- |
50 | target/arm: Convert VQSHLU, VQSHL 2-reg-shift insns to decodetree | 65 | target/arm/kvm.c | 4 +- |
51 | target/arm: Convert Neon narrowing shifts with op==8 to decodetree | 66 | target/arm/machine.c | 4 +- |
52 | target/arm: Convert Neon narrowing shifts with op==9 to decodetree | 67 | target/arm/op_helper.c | 57 ++--- |
53 | target/arm: Convert Neon VSHLL, VMOVL to decodetree | 68 | target/arm/translate-a64.c | 14 +- |
54 | target/arm: Convert VCVT fixed-point ops to decodetree | 69 | target/arm/translate-neon.c | 2 +- |
55 | target/arm: Convert Neon one-register-and-immediate insns to decodetree | 70 | target/arm/translate.c | 13 +- |
56 | 71 | tests/tcg/aarch64/bti-3.c | 42 ++++ | |
57 | Philippe Mathieu-Daudé (3): | 72 | tests/tcg/aarch64/Makefile.target | 6 +- |
58 | hw/input/pxa2xx_keypad: Replace hw_error() by qemu_log_mask() | 73 | 21 files changed, 738 insertions(+), 664 deletions(-) |
59 | hw/arm/pxa2xx: Replace printf() call by qemu_log_mask() | 74 | create mode 100644 target/arm/cpregs.h |
60 | hw/adc/stm32f2xx_adc: Correct memory region size and access size | 75 | create mode 100644 tests/tcg/aarch64/bti-3.c |
61 | |||
62 | Richard Henderson (6): | ||
63 | target/arm: Convert aes and sm4 to gvec helpers | ||
64 | target/arm: Convert rax1 to gvec helpers | ||
65 | target/arm: Convert sha512 and sm3 to gvec helpers | ||
66 | target/arm: Convert sha1 and sha256 to gvec helpers | ||
67 | target/arm: Split helper_crypto_sha1_3reg | ||
68 | target/arm: Split helper_crypto_sm3tt | ||
69 | |||
70 | Thomas Huth (1): | ||
71 | tests/acceptance: Add a boot test for the xlnx-versal-virt machine | ||
72 | |||
73 | docs/system/arm/aspeed.rst | 85 ++ | ||
74 | docs/system/target-arm.rst | 1 + | ||
75 | hw/usb/hcd-dwc2.h | 190 +++++ | ||
76 | include/hw/arm/bcm2835_peripherals.h | 5 +- | ||
77 | include/hw/misc/bcm2835_mphi.h | 44 + | ||
78 | include/hw/usb/dwc2-regs.h | 899 ++++++++++++++++++++ | ||
79 | target/arm/helper.h | 45 +- | ||
80 | target/arm/translate-a64.h | 3 + | ||
81 | target/arm/vec_internal.h | 33 + | ||
82 | target/arm/neon-dp.decode | 214 ++++- | ||
83 | hw/adc/stm32f2xx_adc.c | 4 +- | ||
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: Paul Zimmerman <pauldzim@gmail.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Add the dwc-hsotg (dwc2) USB host controller state definitions. | 3 | This controls whether the PACI{A,B}SP instructions trap with BTYPE=3 |
4 | Mostly based on hw/usb/hcd-ehci.h. | 4 | (indirect branch from register other than x16/x17). The linux kernel |
5 | sets this in bti_enable(). | ||
5 | 6 | ||
6 | Signed-off-by: Paul Zimmerman <pauldzim@gmail.com> | 7 | Resolves: https://gitlab.com/qemu-project/qemu/-/issues/998 |
7 | Message-id: 20200520235349.21215-4-pauldzim@gmail.com | 8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
10 | Message-id: 20220427042312.294300-1-richard.henderson@linaro.org | ||
11 | [PMM: remove stray change to makefile comment] | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 13 | --- |
11 | hw/usb/hcd-dwc2.h | 190 ++++++++++++++++++++++++++++++++++++++++++++++ | 14 | target/arm/cpu.c | 2 ++ |
12 | 1 file changed, 190 insertions(+) | 15 | tests/tcg/aarch64/bti-3.c | 42 +++++++++++++++++++++++++++++++ |
13 | create mode 100644 hw/usb/hcd-dwc2.h | 16 | tests/tcg/aarch64/Makefile.target | 6 ++--- |
17 | 3 files changed, 47 insertions(+), 3 deletions(-) | ||
18 | create mode 100644 tests/tcg/aarch64/bti-3.c | ||
14 | 19 | ||
15 | diff --git a/hw/usb/hcd-dwc2.h b/hw/usb/hcd-dwc2.h | 20 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c |
21 | index XXXXXXX..XXXXXXX 100644 | ||
22 | --- a/target/arm/cpu.c | ||
23 | +++ b/target/arm/cpu.c | ||
24 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_reset(DeviceState *dev) | ||
25 | /* Enable all PAC keys. */ | ||
26 | env->cp15.sctlr_el[1] |= (SCTLR_EnIA | SCTLR_EnIB | | ||
27 | SCTLR_EnDA | SCTLR_EnDB); | ||
28 | + /* Trap on btype=3 for PACIxSP. */ | ||
29 | + env->cp15.sctlr_el[1] |= SCTLR_BT0; | ||
30 | /* and to the FP/Neon instructions */ | ||
31 | env->cp15.cpacr_el1 = deposit64(env->cp15.cpacr_el1, 20, 2, 3); | ||
32 | /* and to the SVE instructions */ | ||
33 | diff --git a/tests/tcg/aarch64/bti-3.c b/tests/tcg/aarch64/bti-3.c | ||
16 | new file mode 100644 | 34 | new file mode 100644 |
17 | index XXXXXXX..XXXXXXX | 35 | index XXXXXXX..XXXXXXX |
18 | --- /dev/null | 36 | --- /dev/null |
19 | +++ b/hw/usb/hcd-dwc2.h | 37 | +++ b/tests/tcg/aarch64/bti-3.c |
20 | @@ -XXX,XX +XXX,XX @@ | 38 | @@ -XXX,XX +XXX,XX @@ |
21 | +/* | 39 | +/* |
22 | + * dwc-hsotg (dwc2) USB host controller state definitions | 40 | + * BTI vs PACIASP |
23 | + * | ||
24 | + * Based on hw/usb/hcd-ehci.h | ||
25 | + * | ||
26 | + * Copyright (c) 2020 Paul Zimmerman <pauldzim@gmail.com> | ||
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 | + */ | 41 | + */ |
38 | + | 42 | + |
39 | +#ifndef HW_USB_DWC2_H | 43 | +#include "bti-crt.inc.c" |
40 | +#define HW_USB_DWC2_H | ||
41 | + | 44 | + |
42 | +#include "qemu/timer.h" | 45 | +static void skip2_sigill(int sig, siginfo_t *info, ucontext_t *uc) |
43 | +#include "hw/irq.h" | 46 | +{ |
44 | +#include "hw/sysbus.h" | 47 | + uc->uc_mcontext.pc += 8; |
45 | +#include "hw/usb.h" | 48 | + uc->uc_mcontext.pstate = 1; |
46 | +#include "sysemu/dma.h" | 49 | +} |
47 | + | 50 | + |
48 | +#define DWC2_MMIO_SIZE 0x11000 | 51 | +#define BTYPE_1() \ |
52 | + asm("mov %0,#1; adr x16, 1f; br x16; 1: hint #25; mov %0,#0" \ | ||
53 | + : "=r"(skipped) : : "x16", "x30") | ||
49 | + | 54 | + |
50 | +#define DWC2_NB_CHAN 8 /* Number of host channels */ | 55 | +#define BTYPE_2() \ |
51 | +#define DWC2_MAX_XFER_SIZE 65536 /* Max transfer size expected in HCTSIZ */ | 56 | + asm("mov %0,#1; adr x16, 1f; blr x16; 1: hint #25; mov %0,#0" \ |
57 | + : "=r"(skipped) : : "x16", "x30") | ||
52 | + | 58 | + |
53 | +typedef struct DWC2Packet DWC2Packet; | 59 | +#define BTYPE_3() \ |
54 | +typedef struct DWC2State DWC2State; | 60 | + asm("mov %0,#1; adr x15, 1f; br x15; 1: hint #25; mov %0,#0" \ |
55 | +typedef struct DWC2Class DWC2Class; | 61 | + : "=r"(skipped) : : "x15", "x30") |
56 | + | 62 | + |
57 | +enum async_state { | 63 | +#define TEST(WHICH, EXPECT) \ |
58 | + DWC2_ASYNC_NONE = 0, | 64 | + do { WHICH(); fail += skipped ^ EXPECT; } while (0) |
59 | + DWC2_ASYNC_INITIALIZED, | ||
60 | + DWC2_ASYNC_INFLIGHT, | ||
61 | + DWC2_ASYNC_FINISHED, | ||
62 | +}; | ||
63 | + | 65 | + |
64 | +struct DWC2Packet { | 66 | +int main() |
65 | + USBPacket packet; | 67 | +{ |
66 | + uint32_t devadr; | 68 | + int fail = 0; |
67 | + uint32_t epnum; | 69 | + int skipped; |
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 | + | 70 | + |
79 | +struct DWC2State { | 71 | + /* Signal-like with SA_SIGINFO. */ |
80 | + /*< private >*/ | 72 | + signal_info(SIGILL, skip2_sigill); |
81 | + SysBusDevice parent_obj; | ||
82 | + | 73 | + |
83 | + /*< public >*/ | 74 | + /* With SCTLR_EL1.BT0 set, PACIASP is not compatible with type=3. */ |
84 | + USBBus bus; | 75 | + TEST(BTYPE_1, 0); |
85 | + qemu_irq irq; | 76 | + TEST(BTYPE_2, 0); |
86 | + MemoryRegion *dma_mr; | 77 | + TEST(BTYPE_3, 1); |
87 | + AddressSpace dma_as; | ||
88 | + MemoryRegion container; | ||
89 | + MemoryRegion hsotg; | ||
90 | + MemoryRegion fifos; | ||
91 | + | 78 | + |
92 | + union { | 79 | + return fail; |
93 | +#define DWC2_GLBREG_SIZE 0x70 | 80 | +} |
94 | + uint32_t glbreg[DWC2_GLBREG_SIZE / sizeof(uint32_t)]; | 81 | diff --git a/tests/tcg/aarch64/Makefile.target b/tests/tcg/aarch64/Makefile.target |
95 | + struct { | 82 | index XXXXXXX..XXXXXXX 100644 |
96 | + uint32_t gotgctl; /* 00 */ | 83 | --- a/tests/tcg/aarch64/Makefile.target |
97 | + uint32_t gotgint; /* 04 */ | 84 | +++ b/tests/tcg/aarch64/Makefile.target |
98 | + uint32_t gahbcfg; /* 08 */ | 85 | @@ -XXX,XX +XXX,XX @@ endif |
99 | + uint32_t gusbcfg; /* 0c */ | 86 | # BTI Tests |
100 | + uint32_t grstctl; /* 10 */ | 87 | # bti-1 tests the elf notes, so we require special compiler support. |
101 | + uint32_t gintsts; /* 14 */ | 88 | ifneq ($(CROSS_CC_HAS_ARMV8_BTI),) |
102 | + uint32_t gintmsk; /* 18 */ | 89 | -AARCH64_TESTS += bti-1 |
103 | + uint32_t grxstsr; /* 1c */ | 90 | -bti-1: CFLAGS += -mbranch-protection=standard |
104 | + uint32_t grxstsp; /* 20 */ | 91 | -bti-1: LDFLAGS += -nostdlib |
105 | + uint32_t grxfsiz; /* 24 */ | 92 | +AARCH64_TESTS += bti-1 bti-3 |
106 | + uint32_t gnptxfsiz; /* 28 */ | 93 | +bti-1 bti-3: CFLAGS += -mbranch-protection=standard |
107 | + uint32_t gnptxsts; /* 2c */ | 94 | +bti-1 bti-3: LDFLAGS += -nostdlib |
108 | + uint32_t gi2cctl; /* 30 */ | 95 | endif |
109 | + uint32_t gpvndctl; /* 34 */ | 96 | # bti-2 tests PROT_BTI, so no special compiler support required. |
110 | + uint32_t ggpio; /* 38 */ | 97 | AARCH64_TESTS += bti-2 |
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 | -- | 98 | -- |
212 | 2.20.1 | 99 | 2.25.1 |
213 | |||
214 | 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 | Move ARMCPRegInfo and all related declarations to a new |
4 | with sve. In particular, pass 3 vector parameters for the | 4 | internal header, out of the public cpu.h. |
5 | 3-operand operations; for advsimd the destination register | ||
6 | is also an input. | ||
7 | 5 | ||
8 | This also fixes a bug in which we failed to clear the high bits | 6 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> |
9 | of the SVE register after an AdvSIMD operation. | 7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
10 | |||
11 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
12 | Message-id: 20200514212831.31248-2-richard.henderson@linaro.org | 9 | Message-id: 20220501055028.646596-2-richard.henderson@linaro.org |
13 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
15 | --- | 11 | --- |
16 | target/arm/helper.h | 6 ++-- | 12 | target/arm/cpregs.h | 413 +++++++++++++++++++++++++++++++++++++ |
17 | target/arm/vec_internal.h | 33 +++++++++++++++++ | 13 | target/arm/cpu.h | 368 --------------------------------- |
18 | target/arm/crypto_helper.c | 72 +++++++++++++++++++++++++++----------- | 14 | hw/arm/pxa2xx.c | 1 + |
19 | target/arm/translate-a64.c | 55 ++++++++++++++++++----------- | 15 | hw/arm/pxa2xx_pic.c | 1 + |
20 | target/arm/translate.c | 27 +++++++------- | 16 | hw/intc/arm_gicv3_cpuif.c | 1 + |
21 | target/arm/vec_helper.c | 12 +------ | 17 | hw/intc/arm_gicv3_kvm.c | 2 + |
22 | 6 files changed, 138 insertions(+), 67 deletions(-) | 18 | target/arm/cpu.c | 1 + |
23 | create mode 100644 target/arm/vec_internal.h | 19 | target/arm/cpu64.c | 1 + |
20 | target/arm/cpu_tcg.c | 1 + | ||
21 | target/arm/gdbstub.c | 3 +- | ||
22 | target/arm/helper.c | 1 + | ||
23 | target/arm/op_helper.c | 1 + | ||
24 | target/arm/translate-a64.c | 4 +- | ||
25 | target/arm/translate.c | 3 +- | ||
26 | 14 files changed, 427 insertions(+), 374 deletions(-) | ||
27 | create mode 100644 target/arm/cpregs.h | ||
24 | 28 | ||
25 | diff --git a/target/arm/helper.h b/target/arm/helper.h | 29 | diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h |
26 | index XXXXXXX..XXXXXXX 100644 | ||
27 | --- a/target/arm/helper.h | ||
28 | +++ b/target/arm/helper.h | ||
29 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_2(neon_qzip8, TCG_CALL_NO_RWG, void, ptr, ptr) | ||
30 | DEF_HELPER_FLAGS_2(neon_qzip16, TCG_CALL_NO_RWG, void, ptr, ptr) | ||
31 | DEF_HELPER_FLAGS_2(neon_qzip32, TCG_CALL_NO_RWG, void, ptr, ptr) | ||
32 | |||
33 | -DEF_HELPER_FLAGS_3(crypto_aese, TCG_CALL_NO_RWG, void, ptr, ptr, i32) | ||
34 | +DEF_HELPER_FLAGS_4(crypto_aese, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | ||
35 | DEF_HELPER_FLAGS_3(crypto_aesmc, TCG_CALL_NO_RWG, void, ptr, ptr, i32) | ||
36 | |||
37 | DEF_HELPER_FLAGS_4(crypto_sha1_3reg, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | ||
38 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_5(crypto_sm3tt, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32, i32) | ||
39 | DEF_HELPER_FLAGS_3(crypto_sm3partw1, TCG_CALL_NO_RWG, void, ptr, ptr, ptr) | ||
40 | DEF_HELPER_FLAGS_3(crypto_sm3partw2, TCG_CALL_NO_RWG, void, ptr, ptr, ptr) | ||
41 | |||
42 | -DEF_HELPER_FLAGS_2(crypto_sm4e, TCG_CALL_NO_RWG, void, ptr, ptr) | ||
43 | -DEF_HELPER_FLAGS_3(crypto_sm4ekey, TCG_CALL_NO_RWG, void, ptr, ptr, ptr) | ||
44 | +DEF_HELPER_FLAGS_4(crypto_sm4e, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | ||
45 | +DEF_HELPER_FLAGS_4(crypto_sm4ekey, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | ||
46 | |||
47 | DEF_HELPER_FLAGS_3(crc32, TCG_CALL_NO_RWG_SE, i32, i32, i32, i32) | ||
48 | DEF_HELPER_FLAGS_3(crc32c, TCG_CALL_NO_RWG_SE, i32, i32, i32, i32) | ||
49 | diff --git a/target/arm/vec_internal.h b/target/arm/vec_internal.h | ||
50 | new file mode 100644 | 30 | new file mode 100644 |
51 | index XXXXXXX..XXXXXXX | 31 | index XXXXXXX..XXXXXXX |
52 | --- /dev/null | 32 | --- /dev/null |
53 | +++ b/target/arm/vec_internal.h | 33 | +++ b/target/arm/cpregs.h |
54 | @@ -XXX,XX +XXX,XX @@ | 34 | @@ -XXX,XX +XXX,XX @@ |
55 | +/* | 35 | +/* |
56 | + * ARM AdvSIMD / SVE Vector Helpers | 36 | + * QEMU ARM CP Register access and descriptions |
57 | + * | 37 | + * |
58 | + * Copyright (c) 2020 Linaro | 38 | + * Copyright (c) 2022 Linaro Ltd |
59 | + * | 39 | + * |
60 | + * This library is free software; you can redistribute it and/or | 40 | + * This program is free software; you can redistribute it and/or |
61 | + * modify it under the terms of the GNU Lesser General Public | 41 | + * modify it under the terms of the GNU General Public License |
62 | + * License as published by the Free Software Foundation; either | 42 | + * as published by the Free Software Foundation; either version 2 |
63 | + * version 2 of the License, or (at your option) any later version. | 43 | + * of the License, or (at your option) any later version. |
64 | + * | 44 | + * |
65 | + * This library is distributed in the hope that it will be useful, | 45 | + * This program is distributed in the hope that it will be useful, |
66 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | 46 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
67 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 47 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
68 | + * Lesser General Public License for more details. | 48 | + * GNU General Public License for more details. |
69 | + * | 49 | + * |
70 | + * You should have received a copy of the GNU Lesser General Public | 50 | + * You should have received a copy of the GNU General Public License |
71 | + * License along with this library; if not, see <http://www.gnu.org/licenses/>. | 51 | + * along with this program; if not, see |
72 | + */ | 52 | + * <http://www.gnu.org/licenses/gpl-2.0.html> |
73 | + | 53 | + */ |
74 | +#ifndef TARGET_ARM_VEC_INTERNALS_H | 54 | + |
75 | +#define TARGET_ARM_VEC_INTERNALS_H | 55 | +#ifndef TARGET_ARM_CPREGS_H |
76 | + | 56 | +#define TARGET_ARM_CPREGS_H |
77 | +static inline void clear_tail(void *vd, uintptr_t opr_sz, uintptr_t max_sz) | 57 | + |
58 | +/* | ||
59 | + * ARMCPRegInfo type field bits. If the SPECIAL bit is set this is a | ||
60 | + * special-behaviour cp reg and bits [11..8] indicate what behaviour | ||
61 | + * it has. Otherwise it is a simple cp reg, where CONST indicates that | ||
62 | + * TCG can assume the value to be constant (ie load at translate time) | ||
63 | + * and 64BIT indicates a 64 bit wide coprocessor register. SUPPRESS_TB_END | ||
64 | + * indicates that the TB should not be ended after a write to this register | ||
65 | + * (the default is that the TB ends after cp writes). OVERRIDE permits | ||
66 | + * a register definition to override a previous definition for the | ||
67 | + * same (cp, is64, crn, crm, opc1, opc2) tuple: either the new or the | ||
68 | + * old must have the OVERRIDE bit set. | ||
69 | + * ALIAS indicates that this register is an alias view of some underlying | ||
70 | + * state which is also visible via another register, and that the other | ||
71 | + * register is handling migration and reset; registers marked ALIAS will not be | ||
72 | + * migrated but may have their state set by syncing of register state from KVM. | ||
73 | + * NO_RAW indicates that this register has no underlying state and does not | ||
74 | + * support raw access for state saving/loading; it will not be used for either | ||
75 | + * migration or KVM state synchronization. (Typically this is for "registers" | ||
76 | + * which are actually used as instructions for cache maintenance and so on.) | ||
77 | + * IO indicates that this register does I/O and therefore its accesses | ||
78 | + * need to be marked with gen_io_start() and also end the TB. In particular, | ||
79 | + * registers which implement clocks or timers require this. | ||
80 | + * RAISES_EXC is for when the read or write hook might raise an exception; | ||
81 | + * the generated code will synchronize the CPU state before calling the hook | ||
82 | + * so that it is safe for the hook to call raise_exception(). | ||
83 | + * NEWEL is for writes to registers that might change the exception | ||
84 | + * level - typically on older ARM chips. For those cases we need to | ||
85 | + * re-read the new el when recomputing the translation flags. | ||
86 | + */ | ||
87 | +#define ARM_CP_SPECIAL 0x0001 | ||
88 | +#define ARM_CP_CONST 0x0002 | ||
89 | +#define ARM_CP_64BIT 0x0004 | ||
90 | +#define ARM_CP_SUPPRESS_TB_END 0x0008 | ||
91 | +#define ARM_CP_OVERRIDE 0x0010 | ||
92 | +#define ARM_CP_ALIAS 0x0020 | ||
93 | +#define ARM_CP_IO 0x0040 | ||
94 | +#define ARM_CP_NO_RAW 0x0080 | ||
95 | +#define ARM_CP_NOP (ARM_CP_SPECIAL | 0x0100) | ||
96 | +#define ARM_CP_WFI (ARM_CP_SPECIAL | 0x0200) | ||
97 | +#define ARM_CP_NZCV (ARM_CP_SPECIAL | 0x0300) | ||
98 | +#define ARM_CP_CURRENTEL (ARM_CP_SPECIAL | 0x0400) | ||
99 | +#define ARM_CP_DC_ZVA (ARM_CP_SPECIAL | 0x0500) | ||
100 | +#define ARM_CP_DC_GVA (ARM_CP_SPECIAL | 0x0600) | ||
101 | +#define ARM_CP_DC_GZVA (ARM_CP_SPECIAL | 0x0700) | ||
102 | +#define ARM_LAST_SPECIAL ARM_CP_DC_GZVA | ||
103 | +#define ARM_CP_FPU 0x1000 | ||
104 | +#define ARM_CP_SVE 0x2000 | ||
105 | +#define ARM_CP_NO_GDB 0x4000 | ||
106 | +#define ARM_CP_RAISES_EXC 0x8000 | ||
107 | +#define ARM_CP_NEWEL 0x10000 | ||
108 | +/* Used only as a terminator for ARMCPRegInfo lists */ | ||
109 | +#define ARM_CP_SENTINEL 0xfffff | ||
110 | +/* Mask of only the flag bits in a type field */ | ||
111 | +#define ARM_CP_FLAG_MASK 0x1f0ff | ||
112 | + | ||
113 | +/* | ||
114 | + * Valid values for ARMCPRegInfo state field, indicating which of | ||
115 | + * the AArch32 and AArch64 execution states this register is visible in. | ||
116 | + * If the reginfo doesn't explicitly specify then it is AArch32 only. | ||
117 | + * If the reginfo is declared to be visible in both states then a second | ||
118 | + * reginfo is synthesised for the AArch32 view of the AArch64 register, | ||
119 | + * such that the AArch32 view is the lower 32 bits of the AArch64 one. | ||
120 | + * Note that we rely on the values of these enums as we iterate through | ||
121 | + * the various states in some places. | ||
122 | + */ | ||
123 | +enum { | ||
124 | + ARM_CP_STATE_AA32 = 0, | ||
125 | + ARM_CP_STATE_AA64 = 1, | ||
126 | + ARM_CP_STATE_BOTH = 2, | ||
127 | +}; | ||
128 | + | ||
129 | +/* | ||
130 | + * ARM CP register secure state flags. These flags identify security state | ||
131 | + * attributes for a given CP register entry. | ||
132 | + * The existence of both or neither secure and non-secure flags indicates that | ||
133 | + * the register has both a secure and non-secure hash entry. A single one of | ||
134 | + * these flags causes the register to only be hashed for the specified | ||
135 | + * security state. | ||
136 | + * Although definitions may have any combination of the S/NS bits, each | ||
137 | + * registered entry will only have one to identify whether the entry is secure | ||
138 | + * or non-secure. | ||
139 | + */ | ||
140 | +enum { | ||
141 | + ARM_CP_SECSTATE_S = (1 << 0), /* bit[0]: Secure state register */ | ||
142 | + ARM_CP_SECSTATE_NS = (1 << 1), /* bit[1]: Non-secure state register */ | ||
143 | +}; | ||
144 | + | ||
145 | +/* | ||
146 | + * Return true if cptype is a valid type field. This is used to try to | ||
147 | + * catch errors where the sentinel has been accidentally left off the end | ||
148 | + * of a list of registers. | ||
149 | + */ | ||
150 | +static inline bool cptype_valid(int cptype) | ||
78 | +{ | 151 | +{ |
79 | + uint64_t *d = vd + opr_sz; | 152 | + return ((cptype & ~ARM_CP_FLAG_MASK) == 0) |
80 | + uintptr_t i; | 153 | + || ((cptype & ARM_CP_SPECIAL) && |
81 | + | 154 | + ((cptype & ~ARM_CP_FLAG_MASK) <= ARM_LAST_SPECIAL)); |
82 | + for (i = opr_sz; i < max_sz; i += 8) { | ||
83 | + *d++ = 0; | ||
84 | + } | ||
85 | +} | 155 | +} |
86 | + | 156 | + |
87 | +#endif /* TARGET_ARM_VEC_INTERNALS_H */ | 157 | +/* |
88 | diff --git a/target/arm/crypto_helper.c b/target/arm/crypto_helper.c | 158 | + * Access rights: |
89 | index XXXXXXX..XXXXXXX 100644 | 159 | + * We define bits for Read and Write access for what rev C of the v7-AR ARM ARM |
90 | --- a/target/arm/crypto_helper.c | 160 | + * defines as PL0 (user), PL1 (fiq/irq/svc/abt/und/sys, ie privileged), and |
91 | +++ b/target/arm/crypto_helper.c | 161 | + * PL2 (hyp). The other level which has Read and Write bits is Secure PL1 |
92 | @@ -XXX,XX +XXX,XX @@ | 162 | + * (ie any of the privileged modes in Secure state, or Monitor mode). |
93 | 163 | + * If a register is accessible in one privilege level it's always accessible | |
164 | + * in higher privilege levels too. Since "Secure PL1" also follows this rule | ||
165 | + * (ie anything visible in PL2 is visible in S-PL1, some things are only | ||
166 | + * visible in S-PL1) but "Secure PL1" is a bit of a mouthful, we bend the | ||
167 | + * terminology a little and call this PL3. | ||
168 | + * In AArch64 things are somewhat simpler as the PLx bits line up exactly | ||
169 | + * with the ELx exception levels. | ||
170 | + * | ||
171 | + * If access permissions for a register are more complex than can be | ||
172 | + * described with these bits, then use a laxer set of restrictions, and | ||
173 | + * do the more restrictive/complex check inside a helper function. | ||
174 | + */ | ||
175 | +#define PL3_R 0x80 | ||
176 | +#define PL3_W 0x40 | ||
177 | +#define PL2_R (0x20 | PL3_R) | ||
178 | +#define PL2_W (0x10 | PL3_W) | ||
179 | +#define PL1_R (0x08 | PL2_R) | ||
180 | +#define PL1_W (0x04 | PL2_W) | ||
181 | +#define PL0_R (0x02 | PL1_R) | ||
182 | +#define PL0_W (0x01 | PL1_W) | ||
183 | + | ||
184 | +/* | ||
185 | + * For user-mode some registers are accessible to EL0 via a kernel | ||
186 | + * trap-and-emulate ABI. In this case we define the read permissions | ||
187 | + * as actually being PL0_R. However some bits of any given register | ||
188 | + * may still be masked. | ||
189 | + */ | ||
190 | +#ifdef CONFIG_USER_ONLY | ||
191 | +#define PL0U_R PL0_R | ||
192 | +#else | ||
193 | +#define PL0U_R PL1_R | ||
194 | +#endif | ||
195 | + | ||
196 | +#define PL3_RW (PL3_R | PL3_W) | ||
197 | +#define PL2_RW (PL2_R | PL2_W) | ||
198 | +#define PL1_RW (PL1_R | PL1_W) | ||
199 | +#define PL0_RW (PL0_R | PL0_W) | ||
200 | + | ||
201 | +typedef enum CPAccessResult { | ||
202 | + /* Access is permitted */ | ||
203 | + CP_ACCESS_OK = 0, | ||
204 | + /* | ||
205 | + * Access fails due to a configurable trap or enable which would | ||
206 | + * result in a categorized exception syndrome giving information about | ||
207 | + * the failing instruction (ie syndrome category 0x3, 0x4, 0x5, 0x6, | ||
208 | + * 0xc or 0x18). The exception is taken to the usual target EL (EL1 or | ||
209 | + * PL1 if in EL0, otherwise to the current EL). | ||
210 | + */ | ||
211 | + CP_ACCESS_TRAP = 1, | ||
212 | + /* | ||
213 | + * Access fails and results in an exception syndrome 0x0 ("uncategorized"). | ||
214 | + * Note that this is not a catch-all case -- the set of cases which may | ||
215 | + * result in this failure is specifically defined by the architecture. | ||
216 | + */ | ||
217 | + CP_ACCESS_TRAP_UNCATEGORIZED = 2, | ||
218 | + /* As CP_ACCESS_TRAP, but for traps directly to EL2 or EL3 */ | ||
219 | + CP_ACCESS_TRAP_EL2 = 3, | ||
220 | + CP_ACCESS_TRAP_EL3 = 4, | ||
221 | + /* As CP_ACCESS_UNCATEGORIZED, but for traps directly to EL2 or EL3 */ | ||
222 | + CP_ACCESS_TRAP_UNCATEGORIZED_EL2 = 5, | ||
223 | + CP_ACCESS_TRAP_UNCATEGORIZED_EL3 = 6, | ||
224 | +} CPAccessResult; | ||
225 | + | ||
226 | +typedef struct ARMCPRegInfo ARMCPRegInfo; | ||
227 | + | ||
228 | +/* | ||
229 | + * Access functions for coprocessor registers. These cannot fail and | ||
230 | + * may not raise exceptions. | ||
231 | + */ | ||
232 | +typedef uint64_t CPReadFn(CPUARMState *env, const ARMCPRegInfo *opaque); | ||
233 | +typedef void CPWriteFn(CPUARMState *env, const ARMCPRegInfo *opaque, | ||
234 | + uint64_t value); | ||
235 | +/* Access permission check functions for coprocessor registers. */ | ||
236 | +typedef CPAccessResult CPAccessFn(CPUARMState *env, | ||
237 | + const ARMCPRegInfo *opaque, | ||
238 | + bool isread); | ||
239 | +/* Hook function for register reset */ | ||
240 | +typedef void CPResetFn(CPUARMState *env, const ARMCPRegInfo *opaque); | ||
241 | + | ||
242 | +#define CP_ANY 0xff | ||
243 | + | ||
244 | +/* Definition of an ARM coprocessor register */ | ||
245 | +struct ARMCPRegInfo { | ||
246 | + /* Name of register (useful mainly for debugging, need not be unique) */ | ||
247 | + const char *name; | ||
248 | + /* | ||
249 | + * Location of register: coprocessor number and (crn,crm,opc1,opc2) | ||
250 | + * tuple. Any of crm, opc1 and opc2 may be CP_ANY to indicate a | ||
251 | + * 'wildcard' field -- any value of that field in the MRC/MCR insn | ||
252 | + * will be decoded to this register. The register read and write | ||
253 | + * callbacks will be passed an ARMCPRegInfo with the crn/crm/opc1/opc2 | ||
254 | + * used by the program, so it is possible to register a wildcard and | ||
255 | + * then behave differently on read/write if necessary. | ||
256 | + * For 64 bit registers, only crm and opc1 are relevant; crn and opc2 | ||
257 | + * must both be zero. | ||
258 | + * For AArch64-visible registers, opc0 is also used. | ||
259 | + * Since there are no "coprocessors" in AArch64, cp is purely used as a | ||
260 | + * way to distinguish (for KVM's benefit) guest-visible system registers | ||
261 | + * from demuxed ones provided to preserve the "no side effects on | ||
262 | + * KVM register read/write from QEMU" semantics. cp==0x13 is guest | ||
263 | + * visible (to match KVM's encoding); cp==0 will be converted to | ||
264 | + * cp==0x13 when the ARMCPRegInfo is registered, for convenience. | ||
265 | + */ | ||
266 | + uint8_t cp; | ||
267 | + uint8_t crn; | ||
268 | + uint8_t crm; | ||
269 | + uint8_t opc0; | ||
270 | + uint8_t opc1; | ||
271 | + uint8_t opc2; | ||
272 | + /* Execution state in which this register is visible: ARM_CP_STATE_* */ | ||
273 | + int state; | ||
274 | + /* Register type: ARM_CP_* bits/values */ | ||
275 | + int type; | ||
276 | + /* Access rights: PL*_[RW] */ | ||
277 | + int access; | ||
278 | + /* Security state: ARM_CP_SECSTATE_* bits/values */ | ||
279 | + int secure; | ||
280 | + /* | ||
281 | + * The opaque pointer passed to define_arm_cp_regs_with_opaque() when | ||
282 | + * this register was defined: can be used to hand data through to the | ||
283 | + * register read/write functions, since they are passed the ARMCPRegInfo*. | ||
284 | + */ | ||
285 | + void *opaque; | ||
286 | + /* | ||
287 | + * Value of this register, if it is ARM_CP_CONST. Otherwise, if | ||
288 | + * fieldoffset is non-zero, the reset value of the register. | ||
289 | + */ | ||
290 | + uint64_t resetvalue; | ||
291 | + /* | ||
292 | + * Offset of the field in CPUARMState for this register. | ||
293 | + * This is not needed if either: | ||
294 | + * 1. type is ARM_CP_CONST or one of the ARM_CP_SPECIALs | ||
295 | + * 2. both readfn and writefn are specified | ||
296 | + */ | ||
297 | + ptrdiff_t fieldoffset; /* offsetof(CPUARMState, field) */ | ||
298 | + | ||
299 | + /* | ||
300 | + * Offsets of the secure and non-secure fields in CPUARMState for the | ||
301 | + * register if it is banked. These fields are only used during the static | ||
302 | + * registration of a register. During hashing the bank associated | ||
303 | + * with a given security state is copied to fieldoffset which is used from | ||
304 | + * there on out. | ||
305 | + * | ||
306 | + * It is expected that register definitions use either fieldoffset or | ||
307 | + * bank_fieldoffsets in the definition but not both. It is also expected | ||
308 | + * that both bank offsets are set when defining a banked register. This | ||
309 | + * use indicates that a register is banked. | ||
310 | + */ | ||
311 | + ptrdiff_t bank_fieldoffsets[2]; | ||
312 | + | ||
313 | + /* | ||
314 | + * Function for making any access checks for this register in addition to | ||
315 | + * those specified by the 'access' permissions bits. If NULL, no extra | ||
316 | + * checks required. The access check is performed at runtime, not at | ||
317 | + * translate time. | ||
318 | + */ | ||
319 | + CPAccessFn *accessfn; | ||
320 | + /* | ||
321 | + * Function for handling reads of this register. If NULL, then reads | ||
322 | + * will be done by loading from the offset into CPUARMState specified | ||
323 | + * by fieldoffset. | ||
324 | + */ | ||
325 | + CPReadFn *readfn; | ||
326 | + /* | ||
327 | + * Function for handling writes of this register. If NULL, then writes | ||
328 | + * will be done by writing to the offset into CPUARMState specified | ||
329 | + * by fieldoffset. | ||
330 | + */ | ||
331 | + CPWriteFn *writefn; | ||
332 | + /* | ||
333 | + * Function for doing a "raw" read; used when we need to copy | ||
334 | + * coprocessor state to the kernel for KVM or out for | ||
335 | + * migration. This only needs to be provided if there is also a | ||
336 | + * readfn and it has side effects (for instance clear-on-read bits). | ||
337 | + */ | ||
338 | + CPReadFn *raw_readfn; | ||
339 | + /* | ||
340 | + * Function for doing a "raw" write; used when we need to copy KVM | ||
341 | + * kernel coprocessor state into userspace, or for inbound | ||
342 | + * migration. This only needs to be provided if there is also a | ||
343 | + * writefn and it masks out "unwritable" bits or has write-one-to-clear | ||
344 | + * or similar behaviour. | ||
345 | + */ | ||
346 | + CPWriteFn *raw_writefn; | ||
347 | + /* | ||
348 | + * Function for resetting the register. If NULL, then reset will be done | ||
349 | + * by writing resetvalue to the field specified in fieldoffset. If | ||
350 | + * fieldoffset is 0 then no reset will be done. | ||
351 | + */ | ||
352 | + CPResetFn *resetfn; | ||
353 | + | ||
354 | + /* | ||
355 | + * "Original" writefn and readfn. | ||
356 | + * For ARMv8.1-VHE register aliases, we overwrite the read/write | ||
357 | + * accessor functions of various EL1/EL0 to perform the runtime | ||
358 | + * check for which sysreg should actually be modified, and then | ||
359 | + * forwards the operation. Before overwriting the accessors, | ||
360 | + * the original function is copied here, so that accesses that | ||
361 | + * really do go to the EL1/EL0 version proceed normally. | ||
362 | + * (The corresponding EL2 register is linked via opaque.) | ||
363 | + */ | ||
364 | + CPReadFn *orig_readfn; | ||
365 | + CPWriteFn *orig_writefn; | ||
366 | +}; | ||
367 | + | ||
368 | +/* | ||
369 | + * Macros which are lvalues for the field in CPUARMState for the | ||
370 | + * ARMCPRegInfo *ri. | ||
371 | + */ | ||
372 | +#define CPREG_FIELD32(env, ri) \ | ||
373 | + (*(uint32_t *)((char *)(env) + (ri)->fieldoffset)) | ||
374 | +#define CPREG_FIELD64(env, ri) \ | ||
375 | + (*(uint64_t *)((char *)(env) + (ri)->fieldoffset)) | ||
376 | + | ||
377 | +#define REGINFO_SENTINEL { .type = ARM_CP_SENTINEL } | ||
378 | + | ||
379 | +void define_arm_cp_regs_with_opaque(ARMCPU *cpu, | ||
380 | + const ARMCPRegInfo *regs, void *opaque); | ||
381 | +void define_one_arm_cp_reg_with_opaque(ARMCPU *cpu, | ||
382 | + const ARMCPRegInfo *regs, void *opaque); | ||
383 | +static inline void define_arm_cp_regs(ARMCPU *cpu, const ARMCPRegInfo *regs) | ||
384 | +{ | ||
385 | + define_arm_cp_regs_with_opaque(cpu, regs, 0); | ||
386 | +} | ||
387 | +static inline void define_one_arm_cp_reg(ARMCPU *cpu, const ARMCPRegInfo *regs) | ||
388 | +{ | ||
389 | + define_one_arm_cp_reg_with_opaque(cpu, regs, 0); | ||
390 | +} | ||
391 | +const ARMCPRegInfo *get_arm_cp_reginfo(GHashTable *cpregs, uint32_t encoded_cp); | ||
392 | + | ||
393 | +/* | ||
394 | + * Definition of an ARM co-processor register as viewed from | ||
395 | + * userspace. This is used for presenting sanitised versions of | ||
396 | + * registers to userspace when emulating the Linux AArch64 CPU | ||
397 | + * ID/feature ABI (advertised as HWCAP_CPUID). | ||
398 | + */ | ||
399 | +typedef struct ARMCPRegUserSpaceInfo { | ||
400 | + /* Name of register */ | ||
401 | + const char *name; | ||
402 | + | ||
403 | + /* Is the name actually a glob pattern */ | ||
404 | + bool is_glob; | ||
405 | + | ||
406 | + /* Only some bits are exported to user space */ | ||
407 | + uint64_t exported_bits; | ||
408 | + | ||
409 | + /* Fixed bits are applied after the mask */ | ||
410 | + uint64_t fixed_bits; | ||
411 | +} ARMCPRegUserSpaceInfo; | ||
412 | + | ||
413 | +#define REGUSERINFO_SENTINEL { .name = NULL } | ||
414 | + | ||
415 | +void modify_arm_cp_regs(ARMCPRegInfo *regs, const ARMCPRegUserSpaceInfo *mods); | ||
416 | + | ||
417 | +/* CPWriteFn that can be used to implement writes-ignored behaviour */ | ||
418 | +void arm_cp_write_ignore(CPUARMState *env, const ARMCPRegInfo *ri, | ||
419 | + uint64_t value); | ||
420 | +/* CPReadFn that can be used for read-as-zero behaviour */ | ||
421 | +uint64_t arm_cp_read_zero(CPUARMState *env, const ARMCPRegInfo *ri); | ||
422 | + | ||
423 | +/* | ||
424 | + * CPResetFn that does nothing, for use if no reset is required even | ||
425 | + * if fieldoffset is non zero. | ||
426 | + */ | ||
427 | +void arm_cp_reset_ignore(CPUARMState *env, const ARMCPRegInfo *opaque); | ||
428 | + | ||
429 | +/* | ||
430 | + * Return true if this reginfo struct's field in the cpu state struct | ||
431 | + * is 64 bits wide. | ||
432 | + */ | ||
433 | +static inline bool cpreg_field_is_64bit(const ARMCPRegInfo *ri) | ||
434 | +{ | ||
435 | + return (ri->state == ARM_CP_STATE_AA64) || (ri->type & ARM_CP_64BIT); | ||
436 | +} | ||
437 | + | ||
438 | +static inline bool cp_access_ok(int current_el, | ||
439 | + const ARMCPRegInfo *ri, int isread) | ||
440 | +{ | ||
441 | + return (ri->access >> ((current_el * 2) + isread)) & 1; | ||
442 | +} | ||
443 | + | ||
444 | +/* Raw read of a coprocessor register (as needed for migration, etc) */ | ||
445 | +uint64_t read_raw_cp_reg(CPUARMState *env, const ARMCPRegInfo *ri); | ||
446 | + | ||
447 | +#endif /* TARGET_ARM_CPREGS_H */ | ||
448 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
449 | index XXXXXXX..XXXXXXX 100644 | ||
450 | --- a/target/arm/cpu.h | ||
451 | +++ b/target/arm/cpu.h | ||
452 | @@ -XXX,XX +XXX,XX @@ static inline uint64_t cpreg_to_kvm_id(uint32_t cpregid) | ||
453 | return kvmid; | ||
454 | } | ||
455 | |||
456 | -/* ARMCPRegInfo type field bits. If the SPECIAL bit is set this is a | ||
457 | - * special-behaviour cp reg and bits [11..8] indicate what behaviour | ||
458 | - * it has. Otherwise it is a simple cp reg, where CONST indicates that | ||
459 | - * TCG can assume the value to be constant (ie load at translate time) | ||
460 | - * and 64BIT indicates a 64 bit wide coprocessor register. SUPPRESS_TB_END | ||
461 | - * indicates that the TB should not be ended after a write to this register | ||
462 | - * (the default is that the TB ends after cp writes). OVERRIDE permits | ||
463 | - * a register definition to override a previous definition for the | ||
464 | - * same (cp, is64, crn, crm, opc1, opc2) tuple: either the new or the | ||
465 | - * old must have the OVERRIDE bit set. | ||
466 | - * ALIAS indicates that this register is an alias view of some underlying | ||
467 | - * state which is also visible via another register, and that the other | ||
468 | - * register is handling migration and reset; registers marked ALIAS will not be | ||
469 | - * migrated but may have their state set by syncing of register state from KVM. | ||
470 | - * NO_RAW indicates that this register has no underlying state and does not | ||
471 | - * support raw access for state saving/loading; it will not be used for either | ||
472 | - * migration or KVM state synchronization. (Typically this is for "registers" | ||
473 | - * which are actually used as instructions for cache maintenance and so on.) | ||
474 | - * IO indicates that this register does I/O and therefore its accesses | ||
475 | - * need to be marked with gen_io_start() and also end the TB. In particular, | ||
476 | - * registers which implement clocks or timers require this. | ||
477 | - * RAISES_EXC is for when the read or write hook might raise an exception; | ||
478 | - * the generated code will synchronize the CPU state before calling the hook | ||
479 | - * so that it is safe for the hook to call raise_exception(). | ||
480 | - * NEWEL is for writes to registers that might change the exception | ||
481 | - * level - typically on older ARM chips. For those cases we need to | ||
482 | - * re-read the new el when recomputing the translation flags. | ||
483 | - */ | ||
484 | -#define ARM_CP_SPECIAL 0x0001 | ||
485 | -#define ARM_CP_CONST 0x0002 | ||
486 | -#define ARM_CP_64BIT 0x0004 | ||
487 | -#define ARM_CP_SUPPRESS_TB_END 0x0008 | ||
488 | -#define ARM_CP_OVERRIDE 0x0010 | ||
489 | -#define ARM_CP_ALIAS 0x0020 | ||
490 | -#define ARM_CP_IO 0x0040 | ||
491 | -#define ARM_CP_NO_RAW 0x0080 | ||
492 | -#define ARM_CP_NOP (ARM_CP_SPECIAL | 0x0100) | ||
493 | -#define ARM_CP_WFI (ARM_CP_SPECIAL | 0x0200) | ||
494 | -#define ARM_CP_NZCV (ARM_CP_SPECIAL | 0x0300) | ||
495 | -#define ARM_CP_CURRENTEL (ARM_CP_SPECIAL | 0x0400) | ||
496 | -#define ARM_CP_DC_ZVA (ARM_CP_SPECIAL | 0x0500) | ||
497 | -#define ARM_CP_DC_GVA (ARM_CP_SPECIAL | 0x0600) | ||
498 | -#define ARM_CP_DC_GZVA (ARM_CP_SPECIAL | 0x0700) | ||
499 | -#define ARM_LAST_SPECIAL ARM_CP_DC_GZVA | ||
500 | -#define ARM_CP_FPU 0x1000 | ||
501 | -#define ARM_CP_SVE 0x2000 | ||
502 | -#define ARM_CP_NO_GDB 0x4000 | ||
503 | -#define ARM_CP_RAISES_EXC 0x8000 | ||
504 | -#define ARM_CP_NEWEL 0x10000 | ||
505 | -/* Used only as a terminator for ARMCPRegInfo lists */ | ||
506 | -#define ARM_CP_SENTINEL 0xfffff | ||
507 | -/* Mask of only the flag bits in a type field */ | ||
508 | -#define ARM_CP_FLAG_MASK 0x1f0ff | ||
509 | - | ||
510 | -/* Valid values for ARMCPRegInfo state field, indicating which of | ||
511 | - * the AArch32 and AArch64 execution states this register is visible in. | ||
512 | - * If the reginfo doesn't explicitly specify then it is AArch32 only. | ||
513 | - * If the reginfo is declared to be visible in both states then a second | ||
514 | - * reginfo is synthesised for the AArch32 view of the AArch64 register, | ||
515 | - * such that the AArch32 view is the lower 32 bits of the AArch64 one. | ||
516 | - * Note that we rely on the values of these enums as we iterate through | ||
517 | - * the various states in some places. | ||
518 | - */ | ||
519 | -enum { | ||
520 | - ARM_CP_STATE_AA32 = 0, | ||
521 | - ARM_CP_STATE_AA64 = 1, | ||
522 | - ARM_CP_STATE_BOTH = 2, | ||
523 | -}; | ||
524 | - | ||
525 | -/* ARM CP register secure state flags. These flags identify security state | ||
526 | - * attributes for a given CP register entry. | ||
527 | - * The existence of both or neither secure and non-secure flags indicates that | ||
528 | - * the register has both a secure and non-secure hash entry. A single one of | ||
529 | - * these flags causes the register to only be hashed for the specified | ||
530 | - * security state. | ||
531 | - * Although definitions may have any combination of the S/NS bits, each | ||
532 | - * registered entry will only have one to identify whether the entry is secure | ||
533 | - * or non-secure. | ||
534 | - */ | ||
535 | -enum { | ||
536 | - ARM_CP_SECSTATE_S = (1 << 0), /* bit[0]: Secure state register */ | ||
537 | - ARM_CP_SECSTATE_NS = (1 << 1), /* bit[1]: Non-secure state register */ | ||
538 | -}; | ||
539 | - | ||
540 | -/* Return true if cptype is a valid type field. This is used to try to | ||
541 | - * catch errors where the sentinel has been accidentally left off the end | ||
542 | - * of a list of registers. | ||
543 | - */ | ||
544 | -static inline bool cptype_valid(int cptype) | ||
545 | -{ | ||
546 | - return ((cptype & ~ARM_CP_FLAG_MASK) == 0) | ||
547 | - || ((cptype & ARM_CP_SPECIAL) && | ||
548 | - ((cptype & ~ARM_CP_FLAG_MASK) <= ARM_LAST_SPECIAL)); | ||
549 | -} | ||
550 | - | ||
551 | -/* Access rights: | ||
552 | - * We define bits for Read and Write access for what rev C of the v7-AR ARM ARM | ||
553 | - * defines as PL0 (user), PL1 (fiq/irq/svc/abt/und/sys, ie privileged), and | ||
554 | - * PL2 (hyp). The other level which has Read and Write bits is Secure PL1 | ||
555 | - * (ie any of the privileged modes in Secure state, or Monitor mode). | ||
556 | - * If a register is accessible in one privilege level it's always accessible | ||
557 | - * in higher privilege levels too. Since "Secure PL1" also follows this rule | ||
558 | - * (ie anything visible in PL2 is visible in S-PL1, some things are only | ||
559 | - * visible in S-PL1) but "Secure PL1" is a bit of a mouthful, we bend the | ||
560 | - * terminology a little and call this PL3. | ||
561 | - * In AArch64 things are somewhat simpler as the PLx bits line up exactly | ||
562 | - * with the ELx exception levels. | ||
563 | - * | ||
564 | - * If access permissions for a register are more complex than can be | ||
565 | - * described with these bits, then use a laxer set of restrictions, and | ||
566 | - * do the more restrictive/complex check inside a helper function. | ||
567 | - */ | ||
568 | -#define PL3_R 0x80 | ||
569 | -#define PL3_W 0x40 | ||
570 | -#define PL2_R (0x20 | PL3_R) | ||
571 | -#define PL2_W (0x10 | PL3_W) | ||
572 | -#define PL1_R (0x08 | PL2_R) | ||
573 | -#define PL1_W (0x04 | PL2_W) | ||
574 | -#define PL0_R (0x02 | PL1_R) | ||
575 | -#define PL0_W (0x01 | PL1_W) | ||
576 | - | ||
577 | -/* | ||
578 | - * For user-mode some registers are accessible to EL0 via a kernel | ||
579 | - * trap-and-emulate ABI. In this case we define the read permissions | ||
580 | - * as actually being PL0_R. However some bits of any given register | ||
581 | - * may still be masked. | ||
582 | - */ | ||
583 | -#ifdef CONFIG_USER_ONLY | ||
584 | -#define PL0U_R PL0_R | ||
585 | -#else | ||
586 | -#define PL0U_R PL1_R | ||
587 | -#endif | ||
588 | - | ||
589 | -#define PL3_RW (PL3_R | PL3_W) | ||
590 | -#define PL2_RW (PL2_R | PL2_W) | ||
591 | -#define PL1_RW (PL1_R | PL1_W) | ||
592 | -#define PL0_RW (PL0_R | PL0_W) | ||
593 | - | ||
594 | /* Return the highest implemented Exception Level */ | ||
595 | static inline int arm_highest_el(CPUARMState *env) | ||
596 | { | ||
597 | @@ -XXX,XX +XXX,XX @@ static inline int arm_current_el(CPUARMState *env) | ||
598 | } | ||
599 | } | ||
600 | |||
601 | -typedef struct ARMCPRegInfo ARMCPRegInfo; | ||
602 | - | ||
603 | -typedef enum CPAccessResult { | ||
604 | - /* Access is permitted */ | ||
605 | - CP_ACCESS_OK = 0, | ||
606 | - /* Access fails due to a configurable trap or enable which would | ||
607 | - * result in a categorized exception syndrome giving information about | ||
608 | - * the failing instruction (ie syndrome category 0x3, 0x4, 0x5, 0x6, | ||
609 | - * 0xc or 0x18). The exception is taken to the usual target EL (EL1 or | ||
610 | - * PL1 if in EL0, otherwise to the current EL). | ||
611 | - */ | ||
612 | - CP_ACCESS_TRAP = 1, | ||
613 | - /* Access fails and results in an exception syndrome 0x0 ("uncategorized"). | ||
614 | - * Note that this is not a catch-all case -- the set of cases which may | ||
615 | - * result in this failure is specifically defined by the architecture. | ||
616 | - */ | ||
617 | - CP_ACCESS_TRAP_UNCATEGORIZED = 2, | ||
618 | - /* As CP_ACCESS_TRAP, but for traps directly to EL2 or EL3 */ | ||
619 | - CP_ACCESS_TRAP_EL2 = 3, | ||
620 | - CP_ACCESS_TRAP_EL3 = 4, | ||
621 | - /* As CP_ACCESS_UNCATEGORIZED, but for traps directly to EL2 or EL3 */ | ||
622 | - CP_ACCESS_TRAP_UNCATEGORIZED_EL2 = 5, | ||
623 | - CP_ACCESS_TRAP_UNCATEGORIZED_EL3 = 6, | ||
624 | -} CPAccessResult; | ||
625 | - | ||
626 | -/* Access functions for coprocessor registers. These cannot fail and | ||
627 | - * may not raise exceptions. | ||
628 | - */ | ||
629 | -typedef uint64_t CPReadFn(CPUARMState *env, const ARMCPRegInfo *opaque); | ||
630 | -typedef void CPWriteFn(CPUARMState *env, const ARMCPRegInfo *opaque, | ||
631 | - uint64_t value); | ||
632 | -/* Access permission check functions for coprocessor registers. */ | ||
633 | -typedef CPAccessResult CPAccessFn(CPUARMState *env, | ||
634 | - const ARMCPRegInfo *opaque, | ||
635 | - bool isread); | ||
636 | -/* Hook function for register reset */ | ||
637 | -typedef void CPResetFn(CPUARMState *env, const ARMCPRegInfo *opaque); | ||
638 | - | ||
639 | -#define CP_ANY 0xff | ||
640 | - | ||
641 | -/* Definition of an ARM coprocessor register */ | ||
642 | -struct ARMCPRegInfo { | ||
643 | - /* Name of register (useful mainly for debugging, need not be unique) */ | ||
644 | - const char *name; | ||
645 | - /* Location of register: coprocessor number and (crn,crm,opc1,opc2) | ||
646 | - * tuple. Any of crm, opc1 and opc2 may be CP_ANY to indicate a | ||
647 | - * 'wildcard' field -- any value of that field in the MRC/MCR insn | ||
648 | - * will be decoded to this register. The register read and write | ||
649 | - * callbacks will be passed an ARMCPRegInfo with the crn/crm/opc1/opc2 | ||
650 | - * used by the program, so it is possible to register a wildcard and | ||
651 | - * then behave differently on read/write if necessary. | ||
652 | - * For 64 bit registers, only crm and opc1 are relevant; crn and opc2 | ||
653 | - * must both be zero. | ||
654 | - * For AArch64-visible registers, opc0 is also used. | ||
655 | - * Since there are no "coprocessors" in AArch64, cp is purely used as a | ||
656 | - * way to distinguish (for KVM's benefit) guest-visible system registers | ||
657 | - * from demuxed ones provided to preserve the "no side effects on | ||
658 | - * KVM register read/write from QEMU" semantics. cp==0x13 is guest | ||
659 | - * visible (to match KVM's encoding); cp==0 will be converted to | ||
660 | - * cp==0x13 when the ARMCPRegInfo is registered, for convenience. | ||
661 | - */ | ||
662 | - uint8_t cp; | ||
663 | - uint8_t crn; | ||
664 | - uint8_t crm; | ||
665 | - uint8_t opc0; | ||
666 | - uint8_t opc1; | ||
667 | - uint8_t opc2; | ||
668 | - /* Execution state in which this register is visible: ARM_CP_STATE_* */ | ||
669 | - int state; | ||
670 | - /* Register type: ARM_CP_* bits/values */ | ||
671 | - int type; | ||
672 | - /* Access rights: PL*_[RW] */ | ||
673 | - int access; | ||
674 | - /* Security state: ARM_CP_SECSTATE_* bits/values */ | ||
675 | - int secure; | ||
676 | - /* The opaque pointer passed to define_arm_cp_regs_with_opaque() when | ||
677 | - * this register was defined: can be used to hand data through to the | ||
678 | - * register read/write functions, since they are passed the ARMCPRegInfo*. | ||
679 | - */ | ||
680 | - void *opaque; | ||
681 | - /* Value of this register, if it is ARM_CP_CONST. Otherwise, if | ||
682 | - * fieldoffset is non-zero, the reset value of the register. | ||
683 | - */ | ||
684 | - uint64_t resetvalue; | ||
685 | - /* Offset of the field in CPUARMState for this register. | ||
686 | - * | ||
687 | - * This is not needed if either: | ||
688 | - * 1. type is ARM_CP_CONST or one of the ARM_CP_SPECIALs | ||
689 | - * 2. both readfn and writefn are specified | ||
690 | - */ | ||
691 | - ptrdiff_t fieldoffset; /* offsetof(CPUARMState, field) */ | ||
692 | - | ||
693 | - /* Offsets of the secure and non-secure fields in CPUARMState for the | ||
694 | - * register if it is banked. These fields are only used during the static | ||
695 | - * registration of a register. During hashing the bank associated | ||
696 | - * with a given security state is copied to fieldoffset which is used from | ||
697 | - * there on out. | ||
698 | - * | ||
699 | - * It is expected that register definitions use either fieldoffset or | ||
700 | - * bank_fieldoffsets in the definition but not both. It is also expected | ||
701 | - * that both bank offsets are set when defining a banked register. This | ||
702 | - * use indicates that a register is banked. | ||
703 | - */ | ||
704 | - ptrdiff_t bank_fieldoffsets[2]; | ||
705 | - | ||
706 | - /* Function for making any access checks for this register in addition to | ||
707 | - * those specified by the 'access' permissions bits. If NULL, no extra | ||
708 | - * checks required. The access check is performed at runtime, not at | ||
709 | - * translate time. | ||
710 | - */ | ||
711 | - CPAccessFn *accessfn; | ||
712 | - /* Function for handling reads of this register. If NULL, then reads | ||
713 | - * will be done by loading from the offset into CPUARMState specified | ||
714 | - * by fieldoffset. | ||
715 | - */ | ||
716 | - CPReadFn *readfn; | ||
717 | - /* Function for handling writes of this register. If NULL, then writes | ||
718 | - * will be done by writing to the offset into CPUARMState specified | ||
719 | - * by fieldoffset. | ||
720 | - */ | ||
721 | - CPWriteFn *writefn; | ||
722 | - /* Function for doing a "raw" read; used when we need to copy | ||
723 | - * coprocessor state to the kernel for KVM or out for | ||
724 | - * migration. This only needs to be provided if there is also a | ||
725 | - * readfn and it has side effects (for instance clear-on-read bits). | ||
726 | - */ | ||
727 | - CPReadFn *raw_readfn; | ||
728 | - /* Function for doing a "raw" write; used when we need to copy KVM | ||
729 | - * kernel coprocessor state into userspace, or for inbound | ||
730 | - * migration. This only needs to be provided if there is also a | ||
731 | - * writefn and it masks out "unwritable" bits or has write-one-to-clear | ||
732 | - * or similar behaviour. | ||
733 | - */ | ||
734 | - CPWriteFn *raw_writefn; | ||
735 | - /* Function for resetting the register. If NULL, then reset will be done | ||
736 | - * by writing resetvalue to the field specified in fieldoffset. If | ||
737 | - * fieldoffset is 0 then no reset will be done. | ||
738 | - */ | ||
739 | - CPResetFn *resetfn; | ||
740 | - | ||
741 | - /* | ||
742 | - * "Original" writefn and readfn. | ||
743 | - * For ARMv8.1-VHE register aliases, we overwrite the read/write | ||
744 | - * accessor functions of various EL1/EL0 to perform the runtime | ||
745 | - * check for which sysreg should actually be modified, and then | ||
746 | - * forwards the operation. Before overwriting the accessors, | ||
747 | - * the original function is copied here, so that accesses that | ||
748 | - * really do go to the EL1/EL0 version proceed normally. | ||
749 | - * (The corresponding EL2 register is linked via opaque.) | ||
750 | - */ | ||
751 | - CPReadFn *orig_readfn; | ||
752 | - CPWriteFn *orig_writefn; | ||
753 | -}; | ||
754 | - | ||
755 | -/* Macros which are lvalues for the field in CPUARMState for the | ||
756 | - * ARMCPRegInfo *ri. | ||
757 | - */ | ||
758 | -#define CPREG_FIELD32(env, ri) \ | ||
759 | - (*(uint32_t *)((char *)(env) + (ri)->fieldoffset)) | ||
760 | -#define CPREG_FIELD64(env, ri) \ | ||
761 | - (*(uint64_t *)((char *)(env) + (ri)->fieldoffset)) | ||
762 | - | ||
763 | -#define REGINFO_SENTINEL { .type = ARM_CP_SENTINEL } | ||
764 | - | ||
765 | -void define_arm_cp_regs_with_opaque(ARMCPU *cpu, | ||
766 | - const ARMCPRegInfo *regs, void *opaque); | ||
767 | -void define_one_arm_cp_reg_with_opaque(ARMCPU *cpu, | ||
768 | - const ARMCPRegInfo *regs, void *opaque); | ||
769 | -static inline void define_arm_cp_regs(ARMCPU *cpu, const ARMCPRegInfo *regs) | ||
770 | -{ | ||
771 | - define_arm_cp_regs_with_opaque(cpu, regs, 0); | ||
772 | -} | ||
773 | -static inline void define_one_arm_cp_reg(ARMCPU *cpu, const ARMCPRegInfo *regs) | ||
774 | -{ | ||
775 | - define_one_arm_cp_reg_with_opaque(cpu, regs, 0); | ||
776 | -} | ||
777 | -const ARMCPRegInfo *get_arm_cp_reginfo(GHashTable *cpregs, uint32_t encoded_cp); | ||
778 | - | ||
779 | -/* | ||
780 | - * Definition of an ARM co-processor register as viewed from | ||
781 | - * userspace. This is used for presenting sanitised versions of | ||
782 | - * registers to userspace when emulating the Linux AArch64 CPU | ||
783 | - * ID/feature ABI (advertised as HWCAP_CPUID). | ||
784 | - */ | ||
785 | -typedef struct ARMCPRegUserSpaceInfo { | ||
786 | - /* Name of register */ | ||
787 | - const char *name; | ||
788 | - | ||
789 | - /* Is the name actually a glob pattern */ | ||
790 | - bool is_glob; | ||
791 | - | ||
792 | - /* Only some bits are exported to user space */ | ||
793 | - uint64_t exported_bits; | ||
794 | - | ||
795 | - /* Fixed bits are applied after the mask */ | ||
796 | - uint64_t fixed_bits; | ||
797 | -} ARMCPRegUserSpaceInfo; | ||
798 | - | ||
799 | -#define REGUSERINFO_SENTINEL { .name = NULL } | ||
800 | - | ||
801 | -void modify_arm_cp_regs(ARMCPRegInfo *regs, const ARMCPRegUserSpaceInfo *mods); | ||
802 | - | ||
803 | -/* CPWriteFn that can be used to implement writes-ignored behaviour */ | ||
804 | -void arm_cp_write_ignore(CPUARMState *env, const ARMCPRegInfo *ri, | ||
805 | - uint64_t value); | ||
806 | -/* CPReadFn that can be used for read-as-zero behaviour */ | ||
807 | -uint64_t arm_cp_read_zero(CPUARMState *env, const ARMCPRegInfo *ri); | ||
808 | - | ||
809 | -/* CPResetFn that does nothing, for use if no reset is required even | ||
810 | - * if fieldoffset is non zero. | ||
811 | - */ | ||
812 | -void arm_cp_reset_ignore(CPUARMState *env, const ARMCPRegInfo *opaque); | ||
813 | - | ||
814 | -/* Return true if this reginfo struct's field in the cpu state struct | ||
815 | - * is 64 bits wide. | ||
816 | - */ | ||
817 | -static inline bool cpreg_field_is_64bit(const ARMCPRegInfo *ri) | ||
818 | -{ | ||
819 | - return (ri->state == ARM_CP_STATE_AA64) || (ri->type & ARM_CP_64BIT); | ||
820 | -} | ||
821 | - | ||
822 | -static inline bool cp_access_ok(int current_el, | ||
823 | - const ARMCPRegInfo *ri, int isread) | ||
824 | -{ | ||
825 | - return (ri->access >> ((current_el * 2) + isread)) & 1; | ||
826 | -} | ||
827 | - | ||
828 | -/* Raw read of a coprocessor register (as needed for migration, etc) */ | ||
829 | -uint64_t read_raw_cp_reg(CPUARMState *env, const ARMCPRegInfo *ri); | ||
830 | - | ||
831 | /** | ||
832 | * write_list_to_cpustate | ||
833 | * @cpu: ARMCPU | ||
834 | diff --git a/hw/arm/pxa2xx.c b/hw/arm/pxa2xx.c | ||
835 | index XXXXXXX..XXXXXXX 100644 | ||
836 | --- a/hw/arm/pxa2xx.c | ||
837 | +++ b/hw/arm/pxa2xx.c | ||
838 | @@ -XXX,XX +XXX,XX @@ | ||
839 | #include "qemu/cutils.h" | ||
840 | #include "qemu/log.h" | ||
841 | #include "qom/object.h" | ||
842 | +#include "target/arm/cpregs.h" | ||
843 | |||
844 | static struct { | ||
845 | hwaddr io_base; | ||
846 | diff --git a/hw/arm/pxa2xx_pic.c b/hw/arm/pxa2xx_pic.c | ||
847 | index XXXXXXX..XXXXXXX 100644 | ||
848 | --- a/hw/arm/pxa2xx_pic.c | ||
849 | +++ b/hw/arm/pxa2xx_pic.c | ||
850 | @@ -XXX,XX +XXX,XX @@ | ||
851 | #include "hw/sysbus.h" | ||
852 | #include "migration/vmstate.h" | ||
853 | #include "qom/object.h" | ||
854 | +#include "target/arm/cpregs.h" | ||
855 | |||
856 | #define ICIP 0x00 /* Interrupt Controller IRQ Pending register */ | ||
857 | #define ICMR 0x04 /* Interrupt Controller Mask register */ | ||
858 | diff --git a/hw/intc/arm_gicv3_cpuif.c b/hw/intc/arm_gicv3_cpuif.c | ||
859 | index XXXXXXX..XXXXXXX 100644 | ||
860 | --- a/hw/intc/arm_gicv3_cpuif.c | ||
861 | +++ b/hw/intc/arm_gicv3_cpuif.c | ||
862 | @@ -XXX,XX +XXX,XX @@ | ||
863 | #include "gicv3_internal.h" | ||
864 | #include "hw/irq.h" | ||
94 | #include "cpu.h" | 865 | #include "cpu.h" |
95 | #include "exec/helper-proto.h" | 866 | +#include "target/arm/cpregs.h" |
96 | +#include "tcg/tcg-gvec-desc.h" | 867 | |
97 | #include "crypto/aes.h" | 868 | /* |
98 | +#include "vec_internal.h" | 869 | * Special case return value from hppvi_index(); must be larger than |
99 | 870 | diff --git a/hw/intc/arm_gicv3_kvm.c b/hw/intc/arm_gicv3_kvm.c | |
100 | union CRYPTO_STATE { | 871 | index XXXXXXX..XXXXXXX 100644 |
101 | uint8_t bytes[16]; | 872 | --- a/hw/intc/arm_gicv3_kvm.c |
102 | @@ -XXX,XX +XXX,XX @@ union CRYPTO_STATE { | 873 | +++ b/hw/intc/arm_gicv3_kvm.c |
103 | #define CR_ST_WORD(state, i) (state.words[i]) | 874 | @@ -XXX,XX +XXX,XX @@ |
875 | #include "vgic_common.h" | ||
876 | #include "migration/blocker.h" | ||
877 | #include "qom/object.h" | ||
878 | +#include "target/arm/cpregs.h" | ||
879 | + | ||
880 | |||
881 | #ifdef DEBUG_GICV3_KVM | ||
882 | #define DPRINTF(fmt, ...) \ | ||
883 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | ||
884 | index XXXXXXX..XXXXXXX 100644 | ||
885 | --- a/target/arm/cpu.c | ||
886 | +++ b/target/arm/cpu.c | ||
887 | @@ -XXX,XX +XXX,XX @@ | ||
888 | #include "kvm_arm.h" | ||
889 | #include "disas/capstone.h" | ||
890 | #include "fpu/softfloat.h" | ||
891 | +#include "cpregs.h" | ||
892 | |||
893 | static void arm_cpu_set_pc(CPUState *cs, vaddr value) | ||
894 | { | ||
895 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | ||
896 | index XXXXXXX..XXXXXXX 100644 | ||
897 | --- a/target/arm/cpu64.c | ||
898 | +++ b/target/arm/cpu64.c | ||
899 | @@ -XXX,XX +XXX,XX @@ | ||
900 | #include "hvf_arm.h" | ||
901 | #include "qapi/visitor.h" | ||
902 | #include "hw/qdev-properties.h" | ||
903 | +#include "cpregs.h" | ||
904 | |||
905 | |||
906 | #ifndef CONFIG_USER_ONLY | ||
907 | diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c | ||
908 | index XXXXXXX..XXXXXXX 100644 | ||
909 | --- a/target/arm/cpu_tcg.c | ||
910 | +++ b/target/arm/cpu_tcg.c | ||
911 | @@ -XXX,XX +XXX,XX @@ | ||
912 | #if !defined(CONFIG_USER_ONLY) | ||
913 | #include "hw/boards.h" | ||
104 | #endif | 914 | #endif |
105 | 915 | +#include "cpregs.h" | |
106 | -void HELPER(crypto_aese)(void *vd, void *vm, uint32_t decrypt) | 916 | |
107 | +static void do_crypto_aese(uint64_t *rd, uint64_t *rn, | 917 | /* CPU models. These are not needed for the AArch64 linux-user build. */ |
108 | + uint64_t *rm, bool decrypt) | 918 | #if !defined(CONFIG_USER_ONLY) || !defined(TARGET_AARCH64) |
109 | { | 919 | diff --git a/target/arm/gdbstub.c b/target/arm/gdbstub.c |
110 | static uint8_t const * const sbox[2] = { AES_sbox, AES_isbox }; | 920 | index XXXXXXX..XXXXXXX 100644 |
111 | static uint8_t const * const shift[2] = { AES_shifts, AES_ishifts }; | 921 | --- a/target/arm/gdbstub.c |
112 | - uint64_t *rd = vd; | 922 | +++ b/target/arm/gdbstub.c |
113 | - uint64_t *rm = vm; | 923 | @@ -XXX,XX +XXX,XX @@ |
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 | */ | 924 | */ |
176 | @@ -XXX,XX +XXX,XX @@ static uint8_t const sm4_sbox[] = { | 925 | #include "qemu/osdep.h" |
177 | 0x79, 0xee, 0x5f, 0x3e, 0xd7, 0xcb, 0x39, 0x48, | 926 | #include "cpu.h" |
178 | }; | 927 | -#include "internals.h" |
179 | 928 | #include "exec/gdbstub.h" | |
180 | -void HELPER(crypto_sm4e)(void *vd, void *vn) | 929 | +#include "internals.h" |
181 | +static void do_crypto_sm4e(uint64_t *rd, uint64_t *rn, uint64_t *rm) | 930 | +#include "cpregs.h" |
182 | { | 931 | |
183 | - uint64_t *rd = vd; | 932 | typedef struct RegisterSysregXmlParam { |
184 | - uint64_t *rn = vn; | 933 | CPUState *cs; |
185 | - union CRYPTO_STATE d = { .l = { rd[0], rd[1] } }; | 934 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
186 | - union CRYPTO_STATE n = { .l = { rn[0], rn[1] } }; | 935 | index XXXXXXX..XXXXXXX 100644 |
187 | + union CRYPTO_STATE d = { .l = { rn[0], rn[1] } }; | 936 | --- a/target/arm/helper.c |
188 | + union CRYPTO_STATE n = { .l = { rm[0], rm[1] } }; | 937 | +++ b/target/arm/helper.c |
189 | uint32_t t, i; | 938 | @@ -XXX,XX +XXX,XX @@ |
190 | 939 | #include "exec/cpu_ldst.h" | |
191 | for (i = 0; i < 4; i++) { | 940 | #include "semihosting/common-semi.h" |
192 | @@ -XXX,XX +XXX,XX @@ void HELPER(crypto_sm4e)(void *vd, void *vn) | 941 | #endif |
193 | rd[1] = d.l[1]; | 942 | +#include "cpregs.h" |
194 | } | 943 | |
195 | 944 | #define ARM_CPU_FREQ 1000000000 /* FIXME: 1 GHz, should be configurable */ | |
196 | -void HELPER(crypto_sm4ekey)(void *vd, void *vn, void* vm) | 945 | #define PMCR_NUM_COUNTERS 4 /* QEMU IMPDEF choice */ |
197 | +void HELPER(crypto_sm4e)(void *vd, void *vn, void *vm, uint32_t desc) | 946 | diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c |
198 | +{ | 947 | index XXXXXXX..XXXXXXX 100644 |
199 | + intptr_t i, opr_sz = simd_oprsz(desc); | 948 | --- a/target/arm/op_helper.c |
200 | + | 949 | +++ b/target/arm/op_helper.c |
201 | + for (i = 0; i < opr_sz; i += 16) { | 950 | @@ -XXX,XX +XXX,XX @@ |
202 | + do_crypto_sm4e(vd + i, vn + i, vm + i); | 951 | #include "internals.h" |
203 | + } | 952 | #include "exec/exec-all.h" |
204 | + clear_tail(vd, opr_sz, simd_maxsz(desc)); | 953 | #include "exec/cpu_ldst.h" |
205 | +} | 954 | +#include "cpregs.h" |
206 | + | 955 | |
207 | +static void do_crypto_sm4ekey(uint64_t *rd, uint64_t *rn, uint64_t *rm) | 956 | #define SIGNBIT (uint32_t)0x80000000 |
208 | { | 957 | #define SIGNBIT64 ((uint64_t)1 << 63) |
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 | 958 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c |
230 | index XXXXXXX..XXXXXXX 100644 | 959 | index XXXXXXX..XXXXXXX 100644 |
231 | --- a/target/arm/translate-a64.c | 960 | --- a/target/arm/translate-a64.c |
232 | +++ b/target/arm/translate-a64.c | 961 | +++ 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, | 962 | @@ -XXX,XX +XXX,XX @@ |
234 | is_q ? 16 : 8, vec_full_reg_size(s)); | 963 | #include "translate.h" |
235 | } | 964 | #include "internals.h" |
236 | 965 | #include "qemu/host-utils.h" | |
237 | +/* Expand a 2-operand operation using an out-of-line helper. */ | 966 | - |
238 | +static void gen_gvec_op2_ool(DisasContext *s, bool is_q, int rd, | 967 | #include "semihosting/semihost.h" |
239 | + int rn, int data, gen_helper_gvec_2 *fn) | 968 | #include "exec/gen-icount.h" |
240 | +{ | 969 | - |
241 | + tcg_gen_gvec_2_ool(vec_full_reg_offset(s, rd), | 970 | #include "exec/helper-proto.h" |
242 | + vec_full_reg_offset(s, rn), | 971 | #include "exec/helper-gen.h" |
243 | + is_q ? 16 : 8, vec_full_reg_size(s), data, fn); | 972 | #include "exec/log.h" |
244 | +} | 973 | - |
245 | + | 974 | +#include "cpregs.h" |
246 | /* Expand a 3-operand operation using an out-of-line helper. */ | 975 | #include "translate-a64.h" |
247 | static void gen_gvec_op3_ool(DisasContext *s, bool is_q, int rd, | 976 | #include "qemu/atomic128.h" |
248 | int rn, int rm, int data, gen_helper_gvec_3 *fn) | ||
249 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_aes(DisasContext *s, uint32_t insn) | ||
250 | int rn = extract32(insn, 5, 5); | ||
251 | int rd = extract32(insn, 0, 5); | ||
252 | int decrypt; | ||
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; | ||
319 | case 2: /* SM4EKEY */ | ||
320 | feature = dc_isar_feature(aa64_sm4, s); | ||
321 | - genfn = gen_helper_crypto_sm4ekey; | ||
322 | + oolfn = gen_helper_crypto_sm4ekey; | ||
323 | break; | ||
324 | default: | ||
325 | unallocated_encoding(s); | ||
326 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_three_reg_sha512(DisasContext *s, uint32_t insn) | ||
327 | return; | ||
328 | } | ||
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 | 977 | ||
367 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 978 | diff --git a/target/arm/translate.c b/target/arm/translate.c |
368 | index XXXXXXX..XXXXXXX 100644 | 979 | index XXXXXXX..XXXXXXX 100644 |
369 | --- a/target/arm/translate.c | 980 | --- a/target/arm/translate.c |
370 | +++ b/target/arm/translate.c | 981 | +++ b/target/arm/translate.c |
371 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | 982 | @@ -XXX,XX +XXX,XX @@ |
372 | if (!dc_isar_feature(aa32_aes, s) || ((rm | rd) & 1)) { | 983 | #include "qemu/bitops.h" |
373 | return 1; | 984 | #include "arm_ldst.h" |
374 | } | 985 | #include "semihosting/semihost.h" |
375 | - ptr1 = vfp_reg_ptr(true, rd); | 986 | - |
376 | - ptr2 = vfp_reg_ptr(true, rm); | ||
377 | - | ||
378 | - /* Bit 6 is the lowest opcode bit; it distinguishes between | ||
379 | - * encryption (AESE/AESMC) and decryption (AESD/AESIMC) | ||
380 | - */ | ||
381 | - tmp3 = tcg_const_i32(extract32(insn, 6, 1)); | ||
382 | - | ||
383 | + /* | ||
384 | + * Bit 6 is the lowest opcode bit; it distinguishes | ||
385 | + * between encryption (AESE/AESMC) and decryption | ||
386 | + * (AESD/AESIMC). | ||
387 | + */ | ||
388 | if (op == NEON_2RM_AESE) { | ||
389 | - gen_helper_crypto_aese(ptr1, ptr2, tmp3); | ||
390 | + tcg_gen_gvec_3_ool(vfp_reg_offset(true, rd), | ||
391 | + vfp_reg_offset(true, rd), | ||
392 | + vfp_reg_offset(true, rm), | ||
393 | + 16, 16, extract32(insn, 6, 1), | ||
394 | + gen_helper_crypto_aese); | ||
395 | } else { | ||
396 | - gen_helper_crypto_aesmc(ptr1, ptr2, tmp3); | ||
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" | 987 | #include "exec/helper-proto.h" |
414 | #include "tcg/tcg-gvec-desc.h" | 988 | #include "exec/helper-gen.h" |
415 | #include "fpu/softfloat.h" | 989 | - |
416 | - | 990 | #include "exec/log.h" |
417 | +#include "vec_internal.h" | 991 | +#include "cpregs.h" |
418 | 992 | ||
419 | /* Note that vector data is stored in host-endian 64-bit chunks, | 993 | |
420 | so addressing units smaller than that needs a host-endian fixup. */ | 994 | #define ENABLE_ARCH_4T arm_dc_feature(s, ARM_FEATURE_V4T) |
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 | -- | 995 | -- |
439 | 2.20.1 | 996 | 2.25.1 |
440 | 997 | ||
441 | 998 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | hw_error() calls exit(). This a bit overkill when we can log | 3 | Rearrange the values of the enumerators of CPAccessResult |
4 | the accesses as unimplemented or guest error. | 4 | so that we may directly extract the target el. For the two |
5 | special cases in access_check_cp_reg, use CPAccessResult. | ||
5 | 6 | ||
6 | When fuzzing the devices, we don't want the whole process to | 7 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> |
7 | exit. Replace some hw_error() calls by qemu_log_mask() | ||
8 | (missed in commit 5a0001ec7e). | ||
9 | |||
10 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
11 | Message-id: 20200525114123.21317-2-f4bug@amsat.org | ||
12 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
10 | Message-id: 20220501055028.646596-3-richard.henderson@linaro.org | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | --- | 12 | --- |
15 | hw/input/pxa2xx_keypad.c | 10 +++++++--- | 13 | target/arm/cpregs.h | 26 ++++++++++++-------- |
16 | 1 file changed, 7 insertions(+), 3 deletions(-) | 14 | target/arm/op_helper.c | 56 +++++++++++++++++++++--------------------- |
15 | 2 files changed, 44 insertions(+), 38 deletions(-) | ||
17 | 16 | ||
18 | diff --git a/hw/input/pxa2xx_keypad.c b/hw/input/pxa2xx_keypad.c | 17 | diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h |
19 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/hw/input/pxa2xx_keypad.c | 19 | --- a/target/arm/cpregs.h |
21 | +++ b/hw/input/pxa2xx_keypad.c | 20 | +++ b/target/arm/cpregs.h |
22 | @@ -XXX,XX +XXX,XX @@ | 21 | @@ -XXX,XX +XXX,XX @@ static inline bool cptype_valid(int cptype) |
23 | */ | 22 | typedef enum CPAccessResult { |
24 | 23 | /* Access is permitted */ | |
25 | #include "qemu/osdep.h" | 24 | CP_ACCESS_OK = 0, |
26 | -#include "hw/hw.h" | 25 | + |
27 | +#include "qemu/log.h" | 26 | + /* |
28 | #include "hw/irq.h" | 27 | + * Combined with one of the following, the low 2 bits indicate the |
29 | #include "migration/vmstate.h" | 28 | + * target exception level. If 0, the exception is taken to the usual |
30 | #include "hw/arm/pxa.h" | 29 | + * target EL (EL1 or PL1 if in EL0, otherwise to the current EL). |
31 | @@ -XXX,XX +XXX,XX @@ static uint64_t pxa2xx_keypad_read(void *opaque, hwaddr offset, | 30 | + */ |
32 | return s->kpkdi; | 31 | + CP_ACCESS_EL_MASK = 3, |
32 | + | ||
33 | /* | ||
34 | * Access fails due to a configurable trap or enable which would | ||
35 | * result in a categorized exception syndrome giving information about | ||
36 | * the failing instruction (ie syndrome category 0x3, 0x4, 0x5, 0x6, | ||
37 | - * 0xc or 0x18). The exception is taken to the usual target EL (EL1 or | ||
38 | - * PL1 if in EL0, otherwise to the current EL). | ||
39 | + * 0xc or 0x18). | ||
40 | */ | ||
41 | - CP_ACCESS_TRAP = 1, | ||
42 | + CP_ACCESS_TRAP = (1 << 2), | ||
43 | + CP_ACCESS_TRAP_EL2 = CP_ACCESS_TRAP | 2, | ||
44 | + CP_ACCESS_TRAP_EL3 = CP_ACCESS_TRAP | 3, | ||
45 | + | ||
46 | /* | ||
47 | * Access fails and results in an exception syndrome 0x0 ("uncategorized"). | ||
48 | * Note that this is not a catch-all case -- the set of cases which may | ||
49 | * result in this failure is specifically defined by the architecture. | ||
50 | */ | ||
51 | - CP_ACCESS_TRAP_UNCATEGORIZED = 2, | ||
52 | - /* As CP_ACCESS_TRAP, but for traps directly to EL2 or EL3 */ | ||
53 | - CP_ACCESS_TRAP_EL2 = 3, | ||
54 | - CP_ACCESS_TRAP_EL3 = 4, | ||
55 | - /* As CP_ACCESS_UNCATEGORIZED, but for traps directly to EL2 or EL3 */ | ||
56 | - CP_ACCESS_TRAP_UNCATEGORIZED_EL2 = 5, | ||
57 | - CP_ACCESS_TRAP_UNCATEGORIZED_EL3 = 6, | ||
58 | + CP_ACCESS_TRAP_UNCATEGORIZED = (2 << 2), | ||
59 | + CP_ACCESS_TRAP_UNCATEGORIZED_EL2 = CP_ACCESS_TRAP_UNCATEGORIZED | 2, | ||
60 | + CP_ACCESS_TRAP_UNCATEGORIZED_EL3 = CP_ACCESS_TRAP_UNCATEGORIZED | 3, | ||
61 | } CPAccessResult; | ||
62 | |||
63 | typedef struct ARMCPRegInfo ARMCPRegInfo; | ||
64 | diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c | ||
65 | index XXXXXXX..XXXXXXX 100644 | ||
66 | --- a/target/arm/op_helper.c | ||
67 | +++ b/target/arm/op_helper.c | ||
68 | @@ -XXX,XX +XXX,XX @@ void HELPER(access_check_cp_reg)(CPUARMState *env, void *rip, uint32_t syndrome, | ||
69 | uint32_t isread) | ||
70 | { | ||
71 | const ARMCPRegInfo *ri = rip; | ||
72 | + CPAccessResult res = CP_ACCESS_OK; | ||
73 | int target_el; | ||
74 | |||
75 | if (arm_feature(env, ARM_FEATURE_XSCALE) && ri->cp < 14 | ||
76 | && extract32(env->cp15.c15_cpar, ri->cp, 1) == 0) { | ||
77 | - raise_exception(env, EXCP_UDEF, syndrome, exception_target_el(env)); | ||
78 | + res = CP_ACCESS_TRAP; | ||
79 | + goto fail; | ||
80 | } | ||
81 | |||
82 | /* | ||
83 | @@ -XXX,XX +XXX,XX @@ void HELPER(access_check_cp_reg)(CPUARMState *env, void *rip, uint32_t syndrome, | ||
84 | mask &= ~((1 << 4) | (1 << 14)); | ||
85 | |||
86 | if (env->cp15.hstr_el2 & mask) { | ||
87 | - target_el = 2; | ||
88 | - goto exept; | ||
89 | + res = CP_ACCESS_TRAP_EL2; | ||
90 | + goto fail; | ||
91 | } | ||
92 | } | ||
93 | |||
94 | - if (!ri->accessfn) { | ||
95 | + if (ri->accessfn) { | ||
96 | + res = ri->accessfn(env, ri, isread); | ||
97 | + } | ||
98 | + if (likely(res == CP_ACCESS_OK)) { | ||
99 | return; | ||
100 | } | ||
101 | |||
102 | - switch (ri->accessfn(env, ri, isread)) { | ||
103 | - case CP_ACCESS_OK: | ||
104 | - return; | ||
105 | + fail: | ||
106 | + switch (res & ~CP_ACCESS_EL_MASK) { | ||
107 | case CP_ACCESS_TRAP: | ||
108 | - target_el = exception_target_el(env); | ||
109 | - break; | ||
110 | - case CP_ACCESS_TRAP_EL2: | ||
111 | - /* Requesting a trap to EL2 when we're in EL3 is | ||
112 | - * a bug in the access function. | ||
113 | - */ | ||
114 | - assert(arm_current_el(env) != 3); | ||
115 | - target_el = 2; | ||
116 | - break; | ||
117 | - case CP_ACCESS_TRAP_EL3: | ||
118 | - target_el = 3; | ||
119 | break; | ||
120 | case CP_ACCESS_TRAP_UNCATEGORIZED: | ||
121 | - target_el = exception_target_el(env); | ||
122 | - syndrome = syn_uncategorized(); | ||
123 | - break; | ||
124 | - case CP_ACCESS_TRAP_UNCATEGORIZED_EL2: | ||
125 | - target_el = 2; | ||
126 | - syndrome = syn_uncategorized(); | ||
127 | - break; | ||
128 | - case CP_ACCESS_TRAP_UNCATEGORIZED_EL3: | ||
129 | - target_el = 3; | ||
130 | syndrome = syn_uncategorized(); | ||
33 | break; | 131 | break; |
34 | default: | 132 | default: |
35 | - hw_error("%s: Bad offset " REG_FMT "\n", __func__, offset); | 133 | g_assert_not_reached(); |
36 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
37 | + "%s: Bad read offset 0x%"HWADDR_PRIx"\n", | ||
38 | + __func__, offset); | ||
39 | } | 134 | } |
40 | 135 | ||
41 | return 0; | 136 | -exept: |
42 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_keypad_write(void *opaque, hwaddr offset, | 137 | + target_el = res & CP_ACCESS_EL_MASK; |
43 | break; | 138 | + switch (target_el) { |
44 | 139 | + case 0: | |
45 | default: | 140 | + target_el = exception_target_el(env); |
46 | - hw_error("%s: Bad offset " REG_FMT "\n", __func__, offset); | 141 | + break; |
47 | + qemu_log_mask(LOG_GUEST_ERROR, | 142 | + case 2: |
48 | + "%s: Bad write offset 0x%"HWADDR_PRIx"\n", | 143 | + assert(arm_current_el(env) != 3); |
49 | + __func__, offset); | 144 | + assert(arm_is_el2_enabled(env)); |
50 | } | 145 | + break; |
146 | + case 3: | ||
147 | + assert(arm_feature(env, ARM_FEATURE_EL3)); | ||
148 | + break; | ||
149 | + default: | ||
150 | + /* No "direct" traps to EL1 */ | ||
151 | + g_assert_not_reached(); | ||
152 | + } | ||
153 | + | ||
154 | raise_exception(env, EXCP_UDEF, syndrome, target_el); | ||
51 | } | 155 | } |
52 | 156 | ||
53 | -- | 157 | -- |
54 | 2.20.1 | 158 | 2.25.1 |
55 | 159 | ||
56 | 160 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Replace printf() calls by qemu_log_mask(), which is disabled | 3 | Remove a possible source of error by removing REGINFO_SENTINEL |
4 | by default. This avoid flooding the terminal when fuzzing the | 4 | and using ARRAY_SIZE (convinently hidden inside a macro) to |
5 | device. | 5 | find the end of the set of regs being registered or modified. |
6 | 6 | ||
7 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 7 | The space saved by not having the extra array element reduces |
8 | Message-id: 20200525114123.21317-3-f4bug@amsat.org | 8 | the executable's .data.rel.ro section by about 9k. |
9 | |||
10 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
12 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
13 | Message-id: 20220501055028.646596-4-richard.henderson@linaro.org | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 15 | --- |
12 | hw/arm/pxa2xx.c | 66 ++++++++++++++++++++++++++++++++++++------------- | 16 | target/arm/cpregs.h | 53 +++++++++--------- |
13 | 1 file changed, 49 insertions(+), 17 deletions(-) | 17 | hw/arm/pxa2xx.c | 1 - |
18 | hw/arm/pxa2xx_pic.c | 1 - | ||
19 | hw/intc/arm_gicv3_cpuif.c | 5 -- | ||
20 | hw/intc/arm_gicv3_kvm.c | 1 - | ||
21 | target/arm/cpu64.c | 1 - | ||
22 | target/arm/cpu_tcg.c | 4 -- | ||
23 | target/arm/helper.c | 111 ++++++++------------------------------ | ||
24 | 8 files changed, 48 insertions(+), 129 deletions(-) | ||
14 | 25 | ||
26 | diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h | ||
27 | index XXXXXXX..XXXXXXX 100644 | ||
28 | --- a/target/arm/cpregs.h | ||
29 | +++ b/target/arm/cpregs.h | ||
30 | @@ -XXX,XX +XXX,XX @@ | ||
31 | #define ARM_CP_NO_GDB 0x4000 | ||
32 | #define ARM_CP_RAISES_EXC 0x8000 | ||
33 | #define ARM_CP_NEWEL 0x10000 | ||
34 | -/* Used only as a terminator for ARMCPRegInfo lists */ | ||
35 | -#define ARM_CP_SENTINEL 0xfffff | ||
36 | /* Mask of only the flag bits in a type field */ | ||
37 | #define ARM_CP_FLAG_MASK 0x1f0ff | ||
38 | |||
39 | @@ -XXX,XX +XXX,XX @@ enum { | ||
40 | ARM_CP_SECSTATE_NS = (1 << 1), /* bit[1]: Non-secure state register */ | ||
41 | }; | ||
42 | |||
43 | -/* | ||
44 | - * Return true if cptype is a valid type field. This is used to try to | ||
45 | - * catch errors where the sentinel has been accidentally left off the end | ||
46 | - * of a list of registers. | ||
47 | - */ | ||
48 | -static inline bool cptype_valid(int cptype) | ||
49 | -{ | ||
50 | - return ((cptype & ~ARM_CP_FLAG_MASK) == 0) | ||
51 | - || ((cptype & ARM_CP_SPECIAL) && | ||
52 | - ((cptype & ~ARM_CP_FLAG_MASK) <= ARM_LAST_SPECIAL)); | ||
53 | -} | ||
54 | - | ||
55 | /* | ||
56 | * Access rights: | ||
57 | * We define bits for Read and Write access for what rev C of the v7-AR ARM ARM | ||
58 | @@ -XXX,XX +XXX,XX @@ struct ARMCPRegInfo { | ||
59 | #define CPREG_FIELD64(env, ri) \ | ||
60 | (*(uint64_t *)((char *)(env) + (ri)->fieldoffset)) | ||
61 | |||
62 | -#define REGINFO_SENTINEL { .type = ARM_CP_SENTINEL } | ||
63 | +void define_one_arm_cp_reg_with_opaque(ARMCPU *cpu, const ARMCPRegInfo *reg, | ||
64 | + void *opaque); | ||
65 | |||
66 | -void define_arm_cp_regs_with_opaque(ARMCPU *cpu, | ||
67 | - const ARMCPRegInfo *regs, void *opaque); | ||
68 | -void define_one_arm_cp_reg_with_opaque(ARMCPU *cpu, | ||
69 | - const ARMCPRegInfo *regs, void *opaque); | ||
70 | -static inline void define_arm_cp_regs(ARMCPU *cpu, const ARMCPRegInfo *regs) | ||
71 | -{ | ||
72 | - define_arm_cp_regs_with_opaque(cpu, regs, 0); | ||
73 | -} | ||
74 | static inline void define_one_arm_cp_reg(ARMCPU *cpu, const ARMCPRegInfo *regs) | ||
75 | { | ||
76 | - define_one_arm_cp_reg_with_opaque(cpu, regs, 0); | ||
77 | + define_one_arm_cp_reg_with_opaque(cpu, regs, NULL); | ||
78 | } | ||
79 | + | ||
80 | +void define_arm_cp_regs_with_opaque_len(ARMCPU *cpu, const ARMCPRegInfo *regs, | ||
81 | + void *opaque, size_t len); | ||
82 | + | ||
83 | +#define define_arm_cp_regs_with_opaque(CPU, REGS, OPAQUE) \ | ||
84 | + do { \ | ||
85 | + QEMU_BUILD_BUG_ON(ARRAY_SIZE(REGS) == 0); \ | ||
86 | + define_arm_cp_regs_with_opaque_len(CPU, REGS, OPAQUE, \ | ||
87 | + ARRAY_SIZE(REGS)); \ | ||
88 | + } while (0) | ||
89 | + | ||
90 | +#define define_arm_cp_regs(CPU, REGS) \ | ||
91 | + define_arm_cp_regs_with_opaque(CPU, REGS, NULL) | ||
92 | + | ||
93 | const ARMCPRegInfo *get_arm_cp_reginfo(GHashTable *cpregs, uint32_t encoded_cp); | ||
94 | |||
95 | /* | ||
96 | @@ -XXX,XX +XXX,XX @@ typedef struct ARMCPRegUserSpaceInfo { | ||
97 | uint64_t fixed_bits; | ||
98 | } ARMCPRegUserSpaceInfo; | ||
99 | |||
100 | -#define REGUSERINFO_SENTINEL { .name = NULL } | ||
101 | +void modify_arm_cp_regs_with_len(ARMCPRegInfo *regs, size_t regs_len, | ||
102 | + const ARMCPRegUserSpaceInfo *mods, | ||
103 | + size_t mods_len); | ||
104 | |||
105 | -void modify_arm_cp_regs(ARMCPRegInfo *regs, const ARMCPRegUserSpaceInfo *mods); | ||
106 | +#define modify_arm_cp_regs(REGS, MODS) \ | ||
107 | + do { \ | ||
108 | + QEMU_BUILD_BUG_ON(ARRAY_SIZE(REGS) == 0); \ | ||
109 | + QEMU_BUILD_BUG_ON(ARRAY_SIZE(MODS) == 0); \ | ||
110 | + modify_arm_cp_regs_with_len(REGS, ARRAY_SIZE(REGS), \ | ||
111 | + MODS, ARRAY_SIZE(MODS)); \ | ||
112 | + } while (0) | ||
113 | |||
114 | /* CPWriteFn that can be used to implement writes-ignored behaviour */ | ||
115 | void arm_cp_write_ignore(CPUARMState *env, const ARMCPRegInfo *ri, | ||
15 | diff --git a/hw/arm/pxa2xx.c b/hw/arm/pxa2xx.c | 116 | diff --git a/hw/arm/pxa2xx.c b/hw/arm/pxa2xx.c |
16 | index XXXXXXX..XXXXXXX 100644 | 117 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/hw/arm/pxa2xx.c | 118 | --- a/hw/arm/pxa2xx.c |
18 | +++ b/hw/arm/pxa2xx.c | 119 | +++ b/hw/arm/pxa2xx.c |
19 | @@ -XXX,XX +XXX,XX @@ | 120 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo pxa_cp_reginfo[] = { |
20 | #include "sysemu/blockdev.h" | 121 | { .name = "PWRMODE", .cp = 14, .crn = 7, .crm = 0, .opc1 = 0, .opc2 = 0, |
21 | #include "sysemu/qtest.h" | 122 | .access = PL1_RW, .type = ARM_CP_IO, |
22 | #include "qemu/cutils.h" | 123 | .readfn = arm_cp_read_zero, .writefn = pxa2xx_pwrmode_write }, |
23 | +#include "qemu/log.h" | 124 | - REGINFO_SENTINEL |
24 | 125 | }; | |
25 | static struct { | 126 | |
26 | hwaddr io_base; | 127 | static void pxa2xx_setup_cp14(PXA2xxState *s) |
27 | @@ -XXX,XX +XXX,XX @@ static uint64_t pxa2xx_pm_read(void *opaque, hwaddr addr, | 128 | diff --git a/hw/arm/pxa2xx_pic.c b/hw/arm/pxa2xx_pic.c |
28 | return s->pm_regs[addr >> 2]; | 129 | index XXXXXXX..XXXXXXX 100644 |
29 | default: | 130 | --- a/hw/arm/pxa2xx_pic.c |
30 | fail: | 131 | +++ b/hw/arm/pxa2xx_pic.c |
31 | - printf("%s: Bad register " REG_FMT "\n", __func__, addr); | 132 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo pxa_pic_cp_reginfo[] = { |
32 | + qemu_log_mask(LOG_GUEST_ERROR, | 133 | REGINFO_FOR_PIC_CP("ICLR2", 8), |
33 | + "%s: Bad read offset 0x%"HWADDR_PRIx"\n", | 134 | REGINFO_FOR_PIC_CP("ICFP2", 9), |
34 | + __func__, addr); | 135 | REGINFO_FOR_PIC_CP("ICPR2", 0xa), |
35 | break; | 136 | - REGINFO_SENTINEL |
137 | }; | ||
138 | |||
139 | static const MemoryRegionOps pxa2xx_pic_ops = { | ||
140 | diff --git a/hw/intc/arm_gicv3_cpuif.c b/hw/intc/arm_gicv3_cpuif.c | ||
141 | index XXXXXXX..XXXXXXX 100644 | ||
142 | --- a/hw/intc/arm_gicv3_cpuif.c | ||
143 | +++ b/hw/intc/arm_gicv3_cpuif.c | ||
144 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo gicv3_cpuif_reginfo[] = { | ||
145 | .readfn = icc_igrpen1_el3_read, | ||
146 | .writefn = icc_igrpen1_el3_write, | ||
147 | }, | ||
148 | - REGINFO_SENTINEL | ||
149 | }; | ||
150 | |||
151 | static uint64_t ich_ap_read(CPUARMState *env, const ARMCPRegInfo *ri) | ||
152 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo gicv3_cpuif_hcr_reginfo[] = { | ||
153 | .readfn = ich_vmcr_read, | ||
154 | .writefn = ich_vmcr_write, | ||
155 | }, | ||
156 | - REGINFO_SENTINEL | ||
157 | }; | ||
158 | |||
159 | static const ARMCPRegInfo gicv3_cpuif_ich_apxr1_reginfo[] = { | ||
160 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo gicv3_cpuif_ich_apxr1_reginfo[] = { | ||
161 | .readfn = ich_ap_read, | ||
162 | .writefn = ich_ap_write, | ||
163 | }, | ||
164 | - REGINFO_SENTINEL | ||
165 | }; | ||
166 | |||
167 | static const ARMCPRegInfo gicv3_cpuif_ich_apxr23_reginfo[] = { | ||
168 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo gicv3_cpuif_ich_apxr23_reginfo[] = { | ||
169 | .readfn = ich_ap_read, | ||
170 | .writefn = ich_ap_write, | ||
171 | }, | ||
172 | - REGINFO_SENTINEL | ||
173 | }; | ||
174 | |||
175 | static void gicv3_cpuif_el_change_hook(ARMCPU *cpu, void *opaque) | ||
176 | @@ -XXX,XX +XXX,XX @@ void gicv3_init_cpuif(GICv3State *s) | ||
177 | .readfn = ich_lr_read, | ||
178 | .writefn = ich_lr_write, | ||
179 | }, | ||
180 | - REGINFO_SENTINEL | ||
181 | }; | ||
182 | define_arm_cp_regs(cpu, lr_regset); | ||
183 | } | ||
184 | diff --git a/hw/intc/arm_gicv3_kvm.c b/hw/intc/arm_gicv3_kvm.c | ||
185 | index XXXXXXX..XXXXXXX 100644 | ||
186 | --- a/hw/intc/arm_gicv3_kvm.c | ||
187 | +++ b/hw/intc/arm_gicv3_kvm.c | ||
188 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo gicv3_cpuif_reginfo[] = { | ||
189 | */ | ||
190 | .resetfn = arm_gicv3_icc_reset, | ||
191 | }, | ||
192 | - REGINFO_SENTINEL | ||
193 | }; | ||
194 | |||
195 | /** | ||
196 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | ||
197 | index XXXXXXX..XXXXXXX 100644 | ||
198 | --- a/target/arm/cpu64.c | ||
199 | +++ b/target/arm/cpu64.c | ||
200 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo cortex_a72_a57_a53_cp_reginfo[] = { | ||
201 | { .name = "L2MERRSR", | ||
202 | .cp = 15, .opc1 = 3, .crm = 15, | ||
203 | .access = PL1_RW, .type = ARM_CP_CONST | ARM_CP_64BIT, .resetvalue = 0 }, | ||
204 | - REGINFO_SENTINEL | ||
205 | }; | ||
206 | |||
207 | static void aarch64_a57_initfn(Object *obj) | ||
208 | diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c | ||
209 | index XXXXXXX..XXXXXXX 100644 | ||
210 | --- a/target/arm/cpu_tcg.c | ||
211 | +++ b/target/arm/cpu_tcg.c | ||
212 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo cortexa8_cp_reginfo[] = { | ||
213 | .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
214 | { .name = "L2AUXCR", .cp = 15, .crn = 9, .crm = 0, .opc1 = 1, .opc2 = 2, | ||
215 | .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
216 | - REGINFO_SENTINEL | ||
217 | }; | ||
218 | |||
219 | static void cortex_a8_initfn(Object *obj) | ||
220 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo cortexa9_cp_reginfo[] = { | ||
221 | .access = PL1_RW, .resetvalue = 0, .type = ARM_CP_CONST }, | ||
222 | { .name = "TLB_ATTR", .cp = 15, .crn = 15, .crm = 7, .opc1 = 5, .opc2 = 2, | ||
223 | .access = PL1_RW, .resetvalue = 0, .type = ARM_CP_CONST }, | ||
224 | - REGINFO_SENTINEL | ||
225 | }; | ||
226 | |||
227 | static void cortex_a9_initfn(Object *obj) | ||
228 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo cortexa15_cp_reginfo[] = { | ||
229 | #endif | ||
230 | { .name = "L2ECTLR", .cp = 15, .crn = 9, .crm = 0, .opc1 = 1, .opc2 = 3, | ||
231 | .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
232 | - REGINFO_SENTINEL | ||
233 | }; | ||
234 | |||
235 | static void cortex_a7_initfn(Object *obj) | ||
236 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo cortexr5_cp_reginfo[] = { | ||
237 | .access = PL1_RW, .type = ARM_CP_CONST }, | ||
238 | { .name = "DCACHE_INVAL", .cp = 15, .opc1 = 0, .crn = 15, .crm = 5, | ||
239 | .opc2 = 0, .access = PL1_W, .type = ARM_CP_NOP }, | ||
240 | - REGINFO_SENTINEL | ||
241 | }; | ||
242 | |||
243 | static void cortex_r5_initfn(Object *obj) | ||
244 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
245 | index XXXXXXX..XXXXXXX 100644 | ||
246 | --- a/target/arm/helper.c | ||
247 | +++ b/target/arm/helper.c | ||
248 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo cp_reginfo[] = { | ||
249 | .secure = ARM_CP_SECSTATE_S, | ||
250 | .fieldoffset = offsetof(CPUARMState, cp15.contextidr_s), | ||
251 | .resetvalue = 0, .writefn = contextidr_write, .raw_writefn = raw_write, }, | ||
252 | - REGINFO_SENTINEL | ||
253 | }; | ||
254 | |||
255 | static const ARMCPRegInfo not_v8_cp_reginfo[] = { | ||
256 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo not_v8_cp_reginfo[] = { | ||
257 | { .name = "CACHEMAINT", .cp = 15, .crn = 7, .crm = CP_ANY, | ||
258 | .opc1 = 0, .opc2 = CP_ANY, .access = PL1_W, | ||
259 | .type = ARM_CP_NOP | ARM_CP_OVERRIDE }, | ||
260 | - REGINFO_SENTINEL | ||
261 | }; | ||
262 | |||
263 | static const ARMCPRegInfo not_v6_cp_reginfo[] = { | ||
264 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo not_v6_cp_reginfo[] = { | ||
265 | */ | ||
266 | { .name = "WFI_v5", .cp = 15, .crn = 7, .crm = 8, .opc1 = 0, .opc2 = 2, | ||
267 | .access = PL1_W, .type = ARM_CP_WFI }, | ||
268 | - REGINFO_SENTINEL | ||
269 | }; | ||
270 | |||
271 | static const ARMCPRegInfo not_v7_cp_reginfo[] = { | ||
272 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo not_v7_cp_reginfo[] = { | ||
273 | .opc1 = 0, .opc2 = 0, .access = PL1_RW, .type = ARM_CP_NOP }, | ||
274 | { .name = "NMRR", .cp = 15, .crn = 10, .crm = 2, | ||
275 | .opc1 = 0, .opc2 = 1, .access = PL1_RW, .type = ARM_CP_NOP }, | ||
276 | - REGINFO_SENTINEL | ||
277 | }; | ||
278 | |||
279 | static void cpacr_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
280 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v6_cp_reginfo[] = { | ||
281 | .crn = 1, .crm = 0, .opc1 = 0, .opc2 = 2, .accessfn = cpacr_access, | ||
282 | .access = PL1_RW, .fieldoffset = offsetof(CPUARMState, cp15.cpacr_el1), | ||
283 | .resetfn = cpacr_reset, .writefn = cpacr_write, .readfn = cpacr_read }, | ||
284 | - REGINFO_SENTINEL | ||
285 | }; | ||
286 | |||
287 | typedef struct pm_event { | ||
288 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v7_cp_reginfo[] = { | ||
289 | { .name = "TLBIMVAA", .cp = 15, .opc1 = 0, .crn = 8, .crm = 7, .opc2 = 3, | ||
290 | .type = ARM_CP_NO_RAW, .access = PL1_W, .accessfn = access_ttlb, | ||
291 | .writefn = tlbimvaa_write }, | ||
292 | - REGINFO_SENTINEL | ||
293 | }; | ||
294 | |||
295 | static const ARMCPRegInfo v7mp_cp_reginfo[] = { | ||
296 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v7mp_cp_reginfo[] = { | ||
297 | { .name = "TLBIMVAAIS", .cp = 15, .opc1 = 0, .crn = 8, .crm = 3, .opc2 = 3, | ||
298 | .type = ARM_CP_NO_RAW, .access = PL1_W, .accessfn = access_ttlb, | ||
299 | .writefn = tlbimvaa_is_write }, | ||
300 | - REGINFO_SENTINEL | ||
301 | }; | ||
302 | |||
303 | static const ARMCPRegInfo pmovsset_cp_reginfo[] = { | ||
304 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo pmovsset_cp_reginfo[] = { | ||
305 | .fieldoffset = offsetof(CPUARMState, cp15.c9_pmovsr), | ||
306 | .writefn = pmovsset_write, | ||
307 | .raw_writefn = raw_write }, | ||
308 | - REGINFO_SENTINEL | ||
309 | }; | ||
310 | |||
311 | static void teecr_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
312 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo t2ee_cp_reginfo[] = { | ||
313 | { .name = "TEEHBR", .cp = 14, .crn = 1, .crm = 0, .opc1 = 6, .opc2 = 0, | ||
314 | .access = PL0_RW, .fieldoffset = offsetof(CPUARMState, teehbr), | ||
315 | .accessfn = teehbr_access, .resetvalue = 0 }, | ||
316 | - REGINFO_SENTINEL | ||
317 | }; | ||
318 | |||
319 | static const ARMCPRegInfo v6k_cp_reginfo[] = { | ||
320 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v6k_cp_reginfo[] = { | ||
321 | .bank_fieldoffsets = { offsetoflow32(CPUARMState, cp15.tpidrprw_s), | ||
322 | offsetoflow32(CPUARMState, cp15.tpidrprw_ns) }, | ||
323 | .resetvalue = 0 }, | ||
324 | - REGINFO_SENTINEL | ||
325 | }; | ||
326 | |||
327 | #ifndef CONFIG_USER_ONLY | ||
328 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo generic_timer_cp_reginfo[] = { | ||
329 | .fieldoffset = offsetof(CPUARMState, cp15.c14_timer[GTIMER_SEC].cval), | ||
330 | .writefn = gt_sec_cval_write, .raw_writefn = raw_write, | ||
331 | }, | ||
332 | - REGINFO_SENTINEL | ||
333 | }; | ||
334 | |||
335 | static CPAccessResult e2h_access(CPUARMState *env, const ARMCPRegInfo *ri, | ||
336 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo generic_timer_cp_reginfo[] = { | ||
337 | .access = PL0_R, .type = ARM_CP_NO_RAW | ARM_CP_IO, | ||
338 | .readfn = gt_virt_cnt_read, | ||
339 | }, | ||
340 | - REGINFO_SENTINEL | ||
341 | }; | ||
342 | |||
343 | #endif | ||
344 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo vapa_cp_reginfo[] = { | ||
345 | .access = PL1_W, .accessfn = ats_access, | ||
346 | .writefn = ats_write, .type = ARM_CP_NO_RAW | ARM_CP_RAISES_EXC }, | ||
347 | #endif | ||
348 | - REGINFO_SENTINEL | ||
349 | }; | ||
350 | |||
351 | /* Return basic MPU access permission bits. */ | ||
352 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo pmsav7_cp_reginfo[] = { | ||
353 | .fieldoffset = offsetof(CPUARMState, pmsav7.rnr[M_REG_NS]), | ||
354 | .writefn = pmsav7_rgnr_write, | ||
355 | .resetfn = arm_cp_reset_ignore }, | ||
356 | - REGINFO_SENTINEL | ||
357 | }; | ||
358 | |||
359 | static const ARMCPRegInfo pmsav5_cp_reginfo[] = { | ||
360 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo pmsav5_cp_reginfo[] = { | ||
361 | { .name = "946_PRBS7", .cp = 15, .crn = 6, .crm = 7, .opc1 = 0, | ||
362 | .opc2 = CP_ANY, .access = PL1_RW, .resetvalue = 0, | ||
363 | .fieldoffset = offsetof(CPUARMState, cp15.c6_region[7]) }, | ||
364 | - REGINFO_SENTINEL | ||
365 | }; | ||
366 | |||
367 | static void vmsa_ttbcr_raw_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
368 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo vmsa_pmsa_cp_reginfo[] = { | ||
369 | .access = PL1_RW, .accessfn = access_tvm_trvm, | ||
370 | .fieldoffset = offsetof(CPUARMState, cp15.far_el[1]), | ||
371 | .resetvalue = 0, }, | ||
372 | - REGINFO_SENTINEL | ||
373 | }; | ||
374 | |||
375 | static const ARMCPRegInfo vmsa_cp_reginfo[] = { | ||
376 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo vmsa_cp_reginfo[] = { | ||
377 | /* No offsetoflow32 -- pass the entire TCR to writefn/raw_writefn. */ | ||
378 | .bank_fieldoffsets = { offsetof(CPUARMState, cp15.tcr_el[3]), | ||
379 | offsetof(CPUARMState, cp15.tcr_el[1])} }, | ||
380 | - REGINFO_SENTINEL | ||
381 | }; | ||
382 | |||
383 | /* Note that unlike TTBCR, writing to TTBCR2 does not require flushing | ||
384 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo omap_cp_reginfo[] = { | ||
385 | { .name = "C9", .cp = 15, .crn = 9, | ||
386 | .crm = CP_ANY, .opc1 = CP_ANY, .opc2 = CP_ANY, .access = PL1_RW, | ||
387 | .type = ARM_CP_CONST | ARM_CP_OVERRIDE, .resetvalue = 0 }, | ||
388 | - REGINFO_SENTINEL | ||
389 | }; | ||
390 | |||
391 | static void xscale_cpar_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
392 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo xscale_cp_reginfo[] = { | ||
393 | { .name = "XSCALE_UNLOCK_DCACHE", | ||
394 | .cp = 15, .opc1 = 0, .crn = 9, .crm = 2, .opc2 = 1, | ||
395 | .access = PL1_W, .type = ARM_CP_NOP }, | ||
396 | - REGINFO_SENTINEL | ||
397 | }; | ||
398 | |||
399 | static const ARMCPRegInfo dummy_c15_cp_reginfo[] = { | ||
400 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo dummy_c15_cp_reginfo[] = { | ||
401 | .access = PL1_RW, | ||
402 | .type = ARM_CP_CONST | ARM_CP_NO_RAW | ARM_CP_OVERRIDE, | ||
403 | .resetvalue = 0 }, | ||
404 | - REGINFO_SENTINEL | ||
405 | }; | ||
406 | |||
407 | static const ARMCPRegInfo cache_dirty_status_cp_reginfo[] = { | ||
408 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo cache_dirty_status_cp_reginfo[] = { | ||
409 | { .name = "CDSR", .cp = 15, .crn = 7, .crm = 10, .opc1 = 0, .opc2 = 6, | ||
410 | .access = PL1_R, .type = ARM_CP_CONST | ARM_CP_NO_RAW, | ||
411 | .resetvalue = 0 }, | ||
412 | - REGINFO_SENTINEL | ||
413 | }; | ||
414 | |||
415 | static const ARMCPRegInfo cache_block_ops_cp_reginfo[] = { | ||
416 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo cache_block_ops_cp_reginfo[] = { | ||
417 | .access = PL0_W, .type = ARM_CP_NOP|ARM_CP_64BIT }, | ||
418 | { .name = "CIDCR", .cp = 15, .crm = 14, .opc1 = 0, | ||
419 | .access = PL1_W, .type = ARM_CP_NOP|ARM_CP_64BIT }, | ||
420 | - REGINFO_SENTINEL | ||
421 | }; | ||
422 | |||
423 | static const ARMCPRegInfo cache_test_clean_cp_reginfo[] = { | ||
424 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo cache_test_clean_cp_reginfo[] = { | ||
425 | { .name = "TCI_DCACHE", .cp = 15, .crn = 7, .crm = 14, .opc1 = 0, .opc2 = 3, | ||
426 | .access = PL0_R, .type = ARM_CP_CONST | ARM_CP_NO_RAW, | ||
427 | .resetvalue = (1 << 30) }, | ||
428 | - REGINFO_SENTINEL | ||
429 | }; | ||
430 | |||
431 | static const ARMCPRegInfo strongarm_cp_reginfo[] = { | ||
432 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo strongarm_cp_reginfo[] = { | ||
433 | .crm = CP_ANY, .opc1 = CP_ANY, .opc2 = CP_ANY, | ||
434 | .access = PL1_RW, .resetvalue = 0, | ||
435 | .type = ARM_CP_CONST | ARM_CP_OVERRIDE | ARM_CP_NO_RAW }, | ||
436 | - REGINFO_SENTINEL | ||
437 | }; | ||
438 | |||
439 | static uint64_t midr_read(CPUARMState *env, const ARMCPRegInfo *ri) | ||
440 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo lpae_cp_reginfo[] = { | ||
441 | .bank_fieldoffsets = { offsetof(CPUARMState, cp15.ttbr1_s), | ||
442 | offsetof(CPUARMState, cp15.ttbr1_ns) }, | ||
443 | .writefn = vmsa_ttbr_write, }, | ||
444 | - REGINFO_SENTINEL | ||
445 | }; | ||
446 | |||
447 | static uint64_t aa64_fpcr_read(CPUARMState *env, const ARMCPRegInfo *ri) | ||
448 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v8_cp_reginfo[] = { | ||
449 | .access = PL1_RW, .accessfn = access_trap_aa32s_el1, | ||
450 | .writefn = sdcr_write, | ||
451 | .fieldoffset = offsetoflow32(CPUARMState, cp15.mdcr_el3) }, | ||
452 | - REGINFO_SENTINEL | ||
453 | }; | ||
454 | |||
455 | /* Used to describe the behaviour of EL2 regs when EL2 does not exist. */ | ||
456 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo el3_no_el2_cp_reginfo[] = { | ||
457 | .type = ARM_CP_CONST, | ||
458 | .cp = 15, .opc1 = 4, .crn = 6, .crm = 0, .opc2 = 2, | ||
459 | .access = PL2_RW, .resetvalue = 0 }, | ||
460 | - REGINFO_SENTINEL | ||
461 | }; | ||
462 | |||
463 | /* Ditto, but for registers which exist in ARMv8 but not v7 */ | ||
464 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo el3_no_el2_v8_cp_reginfo[] = { | ||
465 | .cp = 15, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 4, | ||
466 | .access = PL2_RW, | ||
467 | .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
468 | - REGINFO_SENTINEL | ||
469 | }; | ||
470 | |||
471 | static void do_hcr_write(CPUARMState *env, uint64_t value, uint64_t valid_mask) | ||
472 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo el2_cp_reginfo[] = { | ||
473 | .cp = 15, .opc0 = 3, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 3, | ||
474 | .access = PL2_RW, | ||
475 | .fieldoffset = offsetof(CPUARMState, cp15.hstr_el2) }, | ||
476 | - REGINFO_SENTINEL | ||
477 | }; | ||
478 | |||
479 | static const ARMCPRegInfo el2_v8_cp_reginfo[] = { | ||
480 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo el2_v8_cp_reginfo[] = { | ||
481 | .access = PL2_RW, | ||
482 | .fieldoffset = offsetofhigh32(CPUARMState, cp15.hcr_el2), | ||
483 | .writefn = hcr_writehigh }, | ||
484 | - REGINFO_SENTINEL | ||
485 | }; | ||
486 | |||
487 | static CPAccessResult sel2_access(CPUARMState *env, const ARMCPRegInfo *ri, | ||
488 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo el2_sec_cp_reginfo[] = { | ||
489 | .opc0 = 3, .opc1 = 4, .crn = 2, .crm = 6, .opc2 = 2, | ||
490 | .access = PL2_RW, .accessfn = sel2_access, | ||
491 | .fieldoffset = offsetof(CPUARMState, cp15.vstcr_el2) }, | ||
492 | - REGINFO_SENTINEL | ||
493 | }; | ||
494 | |||
495 | static CPAccessResult nsacr_access(CPUARMState *env, const ARMCPRegInfo *ri, | ||
496 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo el3_cp_reginfo[] = { | ||
497 | .opc0 = 1, .opc1 = 6, .crn = 8, .crm = 7, .opc2 = 5, | ||
498 | .access = PL3_W, .type = ARM_CP_NO_RAW, | ||
499 | .writefn = tlbi_aa64_vae3_write }, | ||
500 | - REGINFO_SENTINEL | ||
501 | }; | ||
502 | |||
503 | #ifndef CONFIG_USER_ONLY | ||
504 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo debug_cp_reginfo[] = { | ||
505 | .cp = 14, .opc0 = 2, .opc1 = 0, .crn = 0, .crm = 2, .opc2 = 0, | ||
506 | .access = PL1_RW, .accessfn = access_tda, | ||
507 | .type = ARM_CP_NOP }, | ||
508 | - REGINFO_SENTINEL | ||
509 | }; | ||
510 | |||
511 | static const ARMCPRegInfo debug_lpae_cp_reginfo[] = { | ||
512 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo debug_lpae_cp_reginfo[] = { | ||
513 | .access = PL0_R, .type = ARM_CP_CONST|ARM_CP_64BIT, .resetvalue = 0 }, | ||
514 | { .name = "DBGDSAR", .cp = 14, .crm = 2, .opc1 = 0, | ||
515 | .access = PL0_R, .type = ARM_CP_CONST|ARM_CP_64BIT, .resetvalue = 0 }, | ||
516 | - REGINFO_SENTINEL | ||
517 | }; | ||
518 | |||
519 | /* Return the exception level to which exceptions should be taken | ||
520 | @@ -XXX,XX +XXX,XX @@ static void define_debug_regs(ARMCPU *cpu) | ||
521 | .fieldoffset = offsetof(CPUARMState, cp15.dbgbcr[i]), | ||
522 | .writefn = dbgbcr_write, .raw_writefn = raw_write | ||
523 | }, | ||
524 | - REGINFO_SENTINEL | ||
525 | }; | ||
526 | define_arm_cp_regs(cpu, dbgregs); | ||
36 | } | 527 | } |
37 | return 0; | 528 | @@ -XXX,XX +XXX,XX @@ static void define_debug_regs(ARMCPU *cpu) |
38 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_pm_write(void *opaque, hwaddr addr, | 529 | .fieldoffset = offsetof(CPUARMState, cp15.dbgwcr[i]), |
39 | s->pm_regs[addr >> 2] = value; | 530 | .writefn = dbgwcr_write, .raw_writefn = raw_write |
40 | break; | 531 | }, |
532 | - REGINFO_SENTINEL | ||
533 | }; | ||
534 | define_arm_cp_regs(cpu, dbgregs); | ||
535 | } | ||
536 | @@ -XXX,XX +XXX,XX @@ static void define_pmu_regs(ARMCPU *cpu) | ||
537 | .type = ARM_CP_IO, | ||
538 | .readfn = pmevtyper_readfn, .writefn = pmevtyper_writefn, | ||
539 | .raw_writefn = pmevtyper_rawwrite }, | ||
540 | - REGINFO_SENTINEL | ||
541 | }; | ||
542 | define_arm_cp_regs(cpu, pmev_regs); | ||
543 | g_free(pmevcntr_name); | ||
544 | @@ -XXX,XX +XXX,XX @@ static void define_pmu_regs(ARMCPU *cpu) | ||
545 | .cp = 15, .opc1 = 0, .crn = 9, .crm = 14, .opc2 = 5, | ||
546 | .access = PL0_R, .accessfn = pmreg_access, .type = ARM_CP_CONST, | ||
547 | .resetvalue = extract64(cpu->pmceid1, 32, 32) }, | ||
548 | - REGINFO_SENTINEL | ||
549 | }; | ||
550 | define_arm_cp_regs(cpu, v81_pmu_regs); | ||
551 | } | ||
552 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo lor_reginfo[] = { | ||
553 | .opc0 = 3, .opc1 = 0, .crn = 10, .crm = 4, .opc2 = 7, | ||
554 | .access = PL1_R, .accessfn = access_lor_ns, | ||
555 | .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
556 | - REGINFO_SENTINEL | ||
557 | }; | ||
558 | |||
559 | #ifdef TARGET_AARCH64 | ||
560 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo pauth_reginfo[] = { | ||
561 | .opc0 = 3, .opc1 = 0, .crn = 2, .crm = 1, .opc2 = 3, | ||
562 | .access = PL1_RW, .accessfn = access_pauth, | ||
563 | .fieldoffset = offsetof(CPUARMState, keys.apib.hi) }, | ||
564 | - REGINFO_SENTINEL | ||
565 | }; | ||
566 | |||
567 | static const ARMCPRegInfo tlbirange_reginfo[] = { | ||
568 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo tlbirange_reginfo[] = { | ||
569 | .opc0 = 1, .opc1 = 6, .crn = 8, .crm = 6, .opc2 = 5, | ||
570 | .access = PL3_W, .type = ARM_CP_NO_RAW, | ||
571 | .writefn = tlbi_aa64_rvae3_write }, | ||
572 | - REGINFO_SENTINEL | ||
573 | }; | ||
574 | |||
575 | static const ARMCPRegInfo tlbios_reginfo[] = { | ||
576 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo tlbios_reginfo[] = { | ||
577 | .opc0 = 1, .opc1 = 6, .crn = 8, .crm = 1, .opc2 = 5, | ||
578 | .access = PL3_W, .type = ARM_CP_NO_RAW, | ||
579 | .writefn = tlbi_aa64_vae3is_write }, | ||
580 | - REGINFO_SENTINEL | ||
581 | }; | ||
582 | |||
583 | static uint64_t rndr_readfn(CPUARMState *env, const ARMCPRegInfo *ri) | ||
584 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo rndr_reginfo[] = { | ||
585 | .type = ARM_CP_NO_RAW | ARM_CP_SUPPRESS_TB_END | ARM_CP_IO, | ||
586 | .opc0 = 3, .opc1 = 3, .crn = 2, .crm = 4, .opc2 = 1, | ||
587 | .access = PL0_R, .readfn = rndr_readfn }, | ||
588 | - REGINFO_SENTINEL | ||
589 | }; | ||
590 | |||
591 | #ifndef CONFIG_USER_ONLY | ||
592 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo dcpop_reg[] = { | ||
593 | .opc0 = 1, .opc1 = 3, .crn = 7, .crm = 12, .opc2 = 1, | ||
594 | .access = PL0_W, .type = ARM_CP_NO_RAW | ARM_CP_SUPPRESS_TB_END, | ||
595 | .accessfn = aa64_cacheop_poc_access, .writefn = dccvap_writefn }, | ||
596 | - REGINFO_SENTINEL | ||
597 | }; | ||
598 | |||
599 | static const ARMCPRegInfo dcpodp_reg[] = { | ||
600 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo dcpodp_reg[] = { | ||
601 | .opc0 = 1, .opc1 = 3, .crn = 7, .crm = 13, .opc2 = 1, | ||
602 | .access = PL0_W, .type = ARM_CP_NO_RAW | ARM_CP_SUPPRESS_TB_END, | ||
603 | .accessfn = aa64_cacheop_poc_access, .writefn = dccvap_writefn }, | ||
604 | - REGINFO_SENTINEL | ||
605 | }; | ||
606 | #endif /*CONFIG_USER_ONLY*/ | ||
607 | |||
608 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo mte_reginfo[] = { | ||
609 | { .name = "DC_CIGDSW", .state = ARM_CP_STATE_AA64, | ||
610 | .opc0 = 1, .opc1 = 0, .crn = 7, .crm = 14, .opc2 = 6, | ||
611 | .type = ARM_CP_NOP, .access = PL1_W, .accessfn = access_tsw }, | ||
612 | - REGINFO_SENTINEL | ||
613 | }; | ||
614 | |||
615 | static const ARMCPRegInfo mte_tco_ro_reginfo[] = { | ||
616 | { .name = "TCO", .state = ARM_CP_STATE_AA64, | ||
617 | .opc0 = 3, .opc1 = 3, .crn = 4, .crm = 2, .opc2 = 7, | ||
618 | .type = ARM_CP_CONST, .access = PL0_RW, }, | ||
619 | - REGINFO_SENTINEL | ||
620 | }; | ||
621 | |||
622 | static const ARMCPRegInfo mte_el0_cacheop_reginfo[] = { | ||
623 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo mte_el0_cacheop_reginfo[] = { | ||
624 | .accessfn = aa64_zva_access, | ||
625 | #endif | ||
626 | }, | ||
627 | - REGINFO_SENTINEL | ||
628 | }; | ||
629 | |||
630 | #endif | ||
631 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo predinv_reginfo[] = { | ||
632 | { .name = "CPPRCTX", .state = ARM_CP_STATE_AA32, | ||
633 | .cp = 15, .opc1 = 0, .crn = 7, .crm = 3, .opc2 = 7, | ||
634 | .type = ARM_CP_NOP, .access = PL0_W, .accessfn = access_predinv }, | ||
635 | - REGINFO_SENTINEL | ||
636 | }; | ||
637 | |||
638 | static uint64_t ccsidr2_read(CPUARMState *env, const ARMCPRegInfo *ri) | ||
639 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo ccsidr2_reginfo[] = { | ||
640 | .access = PL1_R, | ||
641 | .accessfn = access_aa64_tid2, | ||
642 | .readfn = ccsidr2_read, .type = ARM_CP_NO_RAW }, | ||
643 | - REGINFO_SENTINEL | ||
644 | }; | ||
645 | |||
646 | static CPAccessResult access_aa64_tid3(CPUARMState *env, const ARMCPRegInfo *ri, | ||
647 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo jazelle_regs[] = { | ||
648 | .cp = 14, .crn = 2, .crm = 0, .opc1 = 7, .opc2 = 0, | ||
649 | .accessfn = access_joscr_jmcr, | ||
650 | .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
651 | - REGINFO_SENTINEL | ||
652 | }; | ||
653 | |||
654 | static const ARMCPRegInfo vhe_reginfo[] = { | ||
655 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo vhe_reginfo[] = { | ||
656 | .access = PL2_RW, .accessfn = e2h_access, | ||
657 | .writefn = gt_virt_cval_write, .raw_writefn = raw_write }, | ||
658 | #endif | ||
659 | - REGINFO_SENTINEL | ||
660 | }; | ||
661 | |||
662 | #ifndef CONFIG_USER_ONLY | ||
663 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo ats1e1_reginfo[] = { | ||
664 | .opc0 = 1, .opc1 = 0, .crn = 7, .crm = 9, .opc2 = 1, | ||
665 | .access = PL1_W, .type = ARM_CP_NO_RAW | ARM_CP_RAISES_EXC, | ||
666 | .writefn = ats_write64 }, | ||
667 | - REGINFO_SENTINEL | ||
668 | }; | ||
669 | |||
670 | static const ARMCPRegInfo ats1cp_reginfo[] = { | ||
671 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo ats1cp_reginfo[] = { | ||
672 | .cp = 15, .opc1 = 0, .crn = 7, .crm = 9, .opc2 = 1, | ||
673 | .access = PL1_W, .type = ARM_CP_NO_RAW | ARM_CP_RAISES_EXC, | ||
674 | .writefn = ats_write }, | ||
675 | - REGINFO_SENTINEL | ||
676 | }; | ||
677 | #endif | ||
678 | |||
679 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo actlr2_hactlr2_reginfo[] = { | ||
680 | .cp = 15, .opc1 = 4, .crn = 1, .crm = 0, .opc2 = 3, | ||
681 | .access = PL2_RW, .type = ARM_CP_CONST, | ||
682 | .resetvalue = 0 }, | ||
683 | - REGINFO_SENTINEL | ||
684 | }; | ||
685 | |||
686 | void register_cp_regs_for_features(ARMCPU *cpu) | ||
687 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
688 | .access = PL1_R, .type = ARM_CP_CONST, | ||
689 | .accessfn = access_aa32_tid3, | ||
690 | .resetvalue = cpu->isar.id_isar6 }, | ||
691 | - REGINFO_SENTINEL | ||
692 | }; | ||
693 | define_arm_cp_regs(cpu, v6_idregs); | ||
694 | define_arm_cp_regs(cpu, v6_cp_reginfo); | ||
695 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
696 | .opc0 = 3, .opc1 = 3, .crn = 9, .crm = 12, .opc2 = 7, | ||
697 | .access = PL0_R, .accessfn = pmreg_access, .type = ARM_CP_CONST, | ||
698 | .resetvalue = cpu->pmceid1 }, | ||
699 | - REGINFO_SENTINEL | ||
700 | }; | ||
701 | #ifdef CONFIG_USER_ONLY | ||
702 | ARMCPRegUserSpaceInfo v8_user_idregs[] = { | ||
703 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
704 | .exported_bits = 0x000000f0ffffffff }, | ||
705 | { .name = "ID_AA64ISAR*_EL1_RESERVED", | ||
706 | .is_glob = true }, | ||
707 | - REGUSERINFO_SENTINEL | ||
708 | }; | ||
709 | modify_arm_cp_regs(v8_idregs, v8_user_idregs); | ||
710 | #endif | ||
711 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
712 | .access = PL2_RW, | ||
713 | .resetvalue = vmpidr_def, | ||
714 | .fieldoffset = offsetof(CPUARMState, cp15.vmpidr_el2) }, | ||
715 | - REGINFO_SENTINEL | ||
716 | }; | ||
717 | define_arm_cp_regs(cpu, vpidr_regs); | ||
718 | define_arm_cp_regs(cpu, el2_cp_reginfo); | ||
719 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
720 | .access = PL2_RW, .accessfn = access_el3_aa32ns, | ||
721 | .type = ARM_CP_NO_RAW, | ||
722 | .writefn = arm_cp_write_ignore, .readfn = mpidr_read }, | ||
723 | - REGINFO_SENTINEL | ||
724 | }; | ||
725 | define_arm_cp_regs(cpu, vpidr_regs); | ||
726 | define_arm_cp_regs(cpu, el3_no_el2_cp_reginfo); | ||
727 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
728 | .raw_writefn = raw_write, .writefn = sctlr_write, | ||
729 | .fieldoffset = offsetof(CPUARMState, cp15.sctlr_el[3]), | ||
730 | .resetvalue = cpu->reset_sctlr }, | ||
731 | - REGINFO_SENTINEL | ||
732 | }; | ||
733 | |||
734 | define_arm_cp_regs(cpu, el3_regs); | ||
735 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
736 | { .name = "DUMMY", | ||
737 | .cp = 15, .crn = 0, .crm = 7, .opc1 = 0, .opc2 = CP_ANY, | ||
738 | .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
739 | - REGINFO_SENTINEL | ||
740 | }; | ||
741 | ARMCPRegInfo id_v8_midr_cp_reginfo[] = { | ||
742 | { .name = "MIDR_EL1", .state = ARM_CP_STATE_BOTH, | ||
743 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
744 | .access = PL1_R, | ||
745 | .accessfn = access_aa64_tid1, | ||
746 | .type = ARM_CP_CONST, .resetvalue = cpu->revidr }, | ||
747 | - REGINFO_SENTINEL | ||
748 | }; | ||
749 | ARMCPRegInfo id_cp_reginfo[] = { | ||
750 | /* These are common to v8 and pre-v8 */ | ||
751 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
752 | .access = PL1_R, | ||
753 | .accessfn = access_aa32_tid1, | ||
754 | .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
755 | - REGINFO_SENTINEL | ||
756 | }; | ||
757 | /* TLBTR is specific to VMSA */ | ||
758 | ARMCPRegInfo id_tlbtr_reginfo = { | ||
759 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
760 | { .name = "MIDR_EL1", | ||
761 | .exported_bits = 0x00000000ffffffff }, | ||
762 | { .name = "REVIDR_EL1" }, | ||
763 | - REGUSERINFO_SENTINEL | ||
764 | }; | ||
765 | modify_arm_cp_regs(id_v8_midr_cp_reginfo, id_v8_user_midr_cp_reginfo); | ||
766 | #endif | ||
767 | if (arm_feature(env, ARM_FEATURE_OMAPCP) || | ||
768 | arm_feature(env, ARM_FEATURE_STRONGARM)) { | ||
769 | - ARMCPRegInfo *r; | ||
770 | + size_t i; | ||
771 | /* Register the blanket "writes ignored" value first to cover the | ||
772 | * whole space. Then update the specific ID registers to allow write | ||
773 | * access, so that they ignore writes rather than causing them to | ||
774 | * UNDEF. | ||
775 | */ | ||
776 | define_one_arm_cp_reg(cpu, &crn0_wi_reginfo); | ||
777 | - for (r = id_pre_v8_midr_cp_reginfo; | ||
778 | - r->type != ARM_CP_SENTINEL; r++) { | ||
779 | - r->access = PL1_RW; | ||
780 | + for (i = 0; i < ARRAY_SIZE(id_pre_v8_midr_cp_reginfo); ++i) { | ||
781 | + id_pre_v8_midr_cp_reginfo[i].access = PL1_RW; | ||
782 | } | ||
783 | - for (r = id_cp_reginfo; r->type != ARM_CP_SENTINEL; r++) { | ||
784 | - r->access = PL1_RW; | ||
785 | + for (i = 0; i < ARRAY_SIZE(id_cp_reginfo); ++i) { | ||
786 | + id_cp_reginfo[i].access = PL1_RW; | ||
787 | } | ||
788 | id_mpuir_reginfo.access = PL1_RW; | ||
789 | id_tlbtr_reginfo.access = PL1_RW; | ||
790 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
791 | { .name = "MPIDR_EL1", .state = ARM_CP_STATE_BOTH, | ||
792 | .opc0 = 3, .crn = 0, .crm = 0, .opc1 = 0, .opc2 = 5, | ||
793 | .access = PL1_R, .readfn = mpidr_read, .type = ARM_CP_NO_RAW }, | ||
794 | - REGINFO_SENTINEL | ||
795 | }; | ||
796 | #ifdef CONFIG_USER_ONLY | ||
797 | ARMCPRegUserSpaceInfo mpidr_user_cp_reginfo[] = { | ||
798 | { .name = "MPIDR_EL1", | ||
799 | .fixed_bits = 0x0000000080000000 }, | ||
800 | - REGUSERINFO_SENTINEL | ||
801 | }; | ||
802 | modify_arm_cp_regs(mpidr_cp_reginfo, mpidr_user_cp_reginfo); | ||
803 | #endif | ||
804 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
805 | .opc0 = 3, .opc1 = 6, .crn = 1, .crm = 0, .opc2 = 1, | ||
806 | .access = PL3_RW, .type = ARM_CP_CONST, | ||
807 | .resetvalue = 0 }, | ||
808 | - REGINFO_SENTINEL | ||
809 | }; | ||
810 | define_arm_cp_regs(cpu, auxcr_reginfo); | ||
811 | if (cpu_isar_feature(aa32_ac2, cpu)) { | ||
812 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
813 | .type = ARM_CP_CONST, | ||
814 | .opc0 = 3, .opc1 = 1, .crn = 15, .crm = 3, .opc2 = 0, | ||
815 | .access = PL1_R, .resetvalue = cpu->reset_cbar }, | ||
816 | - REGINFO_SENTINEL | ||
817 | }; | ||
818 | /* We don't implement a r/w 64 bit CBAR currently */ | ||
819 | assert(arm_feature(env, ARM_FEATURE_CBAR_RO)); | ||
820 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
821 | .bank_fieldoffsets = { offsetof(CPUARMState, cp15.vbar_s), | ||
822 | offsetof(CPUARMState, cp15.vbar_ns) }, | ||
823 | .resetvalue = 0 }, | ||
824 | - REGINFO_SENTINEL | ||
825 | }; | ||
826 | define_arm_cp_regs(cpu, vbar_cp_reginfo); | ||
827 | } | ||
828 | @@ -XXX,XX +XXX,XX @@ void define_one_arm_cp_reg_with_opaque(ARMCPU *cpu, | ||
829 | r->writefn); | ||
41 | } | 830 | } |
42 | - | 831 | } |
43 | - printf("%s: Bad register " REG_FMT "\n", __func__, addr); | 832 | - /* Bad type field probably means missing sentinel at end of reg list */ |
44 | + qemu_log_mask(LOG_GUEST_ERROR, | 833 | - assert(cptype_valid(r->type)); |
45 | + "%s: Bad write offset 0x%"HWADDR_PRIx"\n", | 834 | + |
46 | + __func__, addr); | 835 | for (crm = crmmin; crm <= crmmax; crm++) { |
47 | break; | 836 | for (opc1 = opc1min; opc1 <= opc1max; opc1++) { |
837 | for (opc2 = opc2min; opc2 <= opc2max; opc2++) { | ||
838 | @@ -XXX,XX +XXX,XX @@ void define_one_arm_cp_reg_with_opaque(ARMCPU *cpu, | ||
48 | } | 839 | } |
49 | } | 840 | } |
50 | @@ -XXX,XX +XXX,XX @@ static uint64_t pxa2xx_cm_read(void *opaque, hwaddr addr, | 841 | |
51 | return s->cm_regs[CCCR >> 2] | (3 << 28); | 842 | -void define_arm_cp_regs_with_opaque(ARMCPU *cpu, |
52 | 843 | - const ARMCPRegInfo *regs, void *opaque) | |
53 | default: | 844 | +/* Define a whole list of registers */ |
54 | - printf("%s: Bad register " REG_FMT "\n", __func__, addr); | 845 | +void define_arm_cp_regs_with_opaque_len(ARMCPU *cpu, const ARMCPRegInfo *regs, |
55 | + qemu_log_mask(LOG_GUEST_ERROR, | 846 | + void *opaque, size_t len) |
56 | + "%s: Bad read offset 0x%"HWADDR_PRIx"\n", | 847 | { |
57 | + __func__, addr); | 848 | - /* Define a whole list of registers */ |
58 | break; | 849 | - const ARMCPRegInfo *r; |
59 | } | 850 | - for (r = regs; r->type != ARM_CP_SENTINEL; r++) { |
60 | return 0; | 851 | - define_one_arm_cp_reg_with_opaque(cpu, r, opaque); |
61 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_cm_write(void *opaque, hwaddr addr, | 852 | + size_t i; |
62 | break; | 853 | + for (i = 0; i < len; ++i) { |
63 | 854 | + define_one_arm_cp_reg_with_opaque(cpu, regs + i, opaque); | |
64 | default: | ||
65 | - printf("%s: Bad register " REG_FMT "\n", __func__, addr); | ||
66 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
67 | + "%s: Bad write offset 0x%"HWADDR_PRIx"\n", | ||
68 | + __func__, addr); | ||
69 | break; | ||
70 | } | 855 | } |
71 | } | 856 | } |
72 | @@ -XXX,XX +XXX,XX @@ static uint64_t pxa2xx_mm_read(void *opaque, hwaddr addr, | 857 | |
73 | return s->mm_regs[addr >> 2]; | 858 | @@ -XXX,XX +XXX,XX @@ void define_arm_cp_regs_with_opaque(ARMCPU *cpu, |
74 | /* fall through */ | 859 | * user-space cannot alter any values and dynamic values pertaining to |
75 | default: | 860 | * execution state are hidden from user space view anyway. |
76 | - printf("%s: Bad register " REG_FMT "\n", __func__, addr); | 861 | */ |
77 | + qemu_log_mask(LOG_GUEST_ERROR, | 862 | -void modify_arm_cp_regs(ARMCPRegInfo *regs, const ARMCPRegUserSpaceInfo *mods) |
78 | + "%s: Bad read offset 0x%"HWADDR_PRIx"\n", | 863 | +void modify_arm_cp_regs_with_len(ARMCPRegInfo *regs, size_t regs_len, |
79 | + __func__, addr); | 864 | + const ARMCPRegUserSpaceInfo *mods, |
80 | break; | 865 | + size_t mods_len) |
81 | } | 866 | { |
82 | return 0; | 867 | - const ARMCPRegUserSpaceInfo *m; |
83 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_mm_write(void *opaque, hwaddr addr, | 868 | - ARMCPRegInfo *r; |
869 | - | ||
870 | - for (m = mods; m->name; m++) { | ||
871 | + for (size_t mi = 0; mi < mods_len; ++mi) { | ||
872 | + const ARMCPRegUserSpaceInfo *m = mods + mi; | ||
873 | GPatternSpec *pat = NULL; | ||
874 | + | ||
875 | if (m->is_glob) { | ||
876 | pat = g_pattern_spec_new(m->name); | ||
84 | } | 877 | } |
85 | 878 | - for (r = regs; r->type != ARM_CP_SENTINEL; r++) { | |
86 | default: | 879 | + for (size_t ri = 0; ri < regs_len; ++ri) { |
87 | - printf("%s: Bad register " REG_FMT "\n", __func__, addr); | 880 | + ARMCPRegInfo *r = regs + ri; |
88 | + qemu_log_mask(LOG_GUEST_ERROR, | 881 | + |
89 | + "%s: Bad write offset 0x%"HWADDR_PRIx"\n", | 882 | if (pat && g_pattern_match_string(pat, r->name)) { |
90 | + __func__, addr); | 883 | r->type = ARM_CP_CONST; |
91 | break; | 884 | r->access = PL0U_R; |
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 | |||
204 | -- | 885 | -- |
205 | 2.20.1 | 886 | 2.25.1 |
206 | 887 | ||
207 | 888 | diff view generated by jsdifflib |
1 | Convert the insns in the one-register-and-immediate group to decodetree. | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | In the new decode, our asimd_imm_const() function returns a 64-bit value | 3 | These particular data structures are not modified at runtime. |
4 | rather than a 32-bit one, which means we don't need to treat cmode=14 op=1 | ||
5 | as a special case in the decoder (it is the only encoding where the two | ||
6 | halves of the 64-bit value are different). | ||
7 | 4 | ||
5 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20220501055028.646596-5-richard.henderson@linaro.org | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
10 | Message-id: 20200522145520.6778-10-peter.maydell@linaro.org | ||
11 | --- | 10 | --- |
12 | target/arm/neon-dp.decode | 22 ++++++ | 11 | target/arm/helper.c | 16 ++++++++-------- |
13 | target/arm/translate-neon.inc.c | 118 ++++++++++++++++++++++++++++++++ | 12 | 1 file changed, 8 insertions(+), 8 deletions(-) |
14 | target/arm/translate.c | 101 +-------------------------- | ||
15 | 3 files changed, 142 insertions(+), 99 deletions(-) | ||
16 | 13 | ||
17 | diff --git a/target/arm/neon-dp.decode b/target/arm/neon-dp.decode | 14 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
18 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/target/arm/neon-dp.decode | 16 | --- a/target/arm/helper.c |
20 | +++ b/target/arm/neon-dp.decode | 17 | +++ b/target/arm/helper.c |
21 | @@ -XXX,XX +XXX,XX @@ VCVT_SF_2sh 1111 001 0 1 . ...... .... 1110 0 . . 1 .... @2reg_vcvt | 18 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) |
22 | VCVT_UF_2sh 1111 001 1 1 . ...... .... 1110 0 . . 1 .... @2reg_vcvt | 19 | .resetvalue = cpu->pmceid1 }, |
23 | VCVT_FS_2sh 1111 001 0 1 . ...... .... 1111 0 . . 1 .... @2reg_vcvt | 20 | }; |
24 | VCVT_FU_2sh 1111 001 1 1 . ...... .... 1111 0 . . 1 .... @2reg_vcvt | 21 | #ifdef CONFIG_USER_ONLY |
25 | + | 22 | - ARMCPRegUserSpaceInfo v8_user_idregs[] = { |
26 | +###################################################################### | 23 | + static const ARMCPRegUserSpaceInfo v8_user_idregs[] = { |
27 | +# 1-reg-and-modified-immediate grouping: | 24 | { .name = "ID_AA64PFR0_EL1", |
28 | +# 1111 001 i 1 D 000 imm:3 Vd:4 cmode:4 0 Q op 1 Vm:4 | 25 | .exported_bits = 0x000f000f00ff0000, |
29 | +###################################################################### | 26 | .fixed_bits = 0x0000000000000011 }, |
30 | + | 27 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) |
31 | +&1reg_imm vd q imm cmode op | 28 | */ |
32 | + | 29 | if (arm_feature(env, ARM_FEATURE_EL3)) { |
33 | +%asimd_imm_value 24:1 16:3 0:4 | 30 | if (arm_feature(env, ARM_FEATURE_AARCH64)) { |
34 | + | 31 | - ARMCPRegInfo nsacr = { |
35 | +@1reg_imm .... ... . . . ... ... .... .... . q:1 . . .... \ | 32 | + static const ARMCPRegInfo nsacr = { |
36 | + &1reg_imm imm=%asimd_imm_value vd=%vd_dp | 33 | .name = "NSACR", .type = ARM_CP_CONST, |
37 | + | 34 | .cp = 15, .opc1 = 0, .crn = 1, .crm = 1, .opc2 = 2, |
38 | +# The cmode/op bits here decode VORR/VBIC/VMOV/VMNV, but | 35 | .access = PL1_RW, .accessfn = nsacr_access, |
39 | +# not in a way we can conveniently represent in decodetree without | 36 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) |
40 | +# a lot of repetition: | 37 | }; |
41 | +# VORR: op=0, (cmode & 1) && cmode < 12 | 38 | define_one_arm_cp_reg(cpu, &nsacr); |
42 | +# VBIC: op=1, (cmode & 1) && cmode < 12 | 39 | } else { |
43 | +# VMOV: everything else | 40 | - ARMCPRegInfo nsacr = { |
44 | +# So we have a single decode line and check the cmode/op in the | 41 | + static const ARMCPRegInfo nsacr = { |
45 | +# trans function. | 42 | .name = "NSACR", |
46 | +Vimm_1r 1111 001 . 1 . 000 ... .... cmode:4 0 . op:1 1 .... @1reg_imm | 43 | .cp = 15, .opc1 = 0, .crn = 1, .crm = 1, .opc2 = 2, |
47 | diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c | 44 | .access = PL3_RW | PL1_R, |
48 | index XXXXXXX..XXXXXXX 100644 | 45 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) |
49 | --- a/target/arm/translate-neon.inc.c | 46 | } |
50 | +++ b/target/arm/translate-neon.inc.c | 47 | } else { |
51 | @@ -XXX,XX +XXX,XX @@ DO_FP_2SH(VCVT_SF, gen_helper_vfp_sltos) | 48 | if (arm_feature(env, ARM_FEATURE_V8)) { |
52 | DO_FP_2SH(VCVT_UF, gen_helper_vfp_ultos) | 49 | - ARMCPRegInfo nsacr = { |
53 | DO_FP_2SH(VCVT_FS, gen_helper_vfp_tosls_round_to_zero) | 50 | + static const ARMCPRegInfo nsacr = { |
54 | DO_FP_2SH(VCVT_FU, gen_helper_vfp_touls_round_to_zero) | 51 | .name = "NSACR", .type = ARM_CP_CONST, |
55 | + | 52 | .cp = 15, .opc1 = 0, .crn = 1, .crm = 1, .opc2 = 2, |
56 | +static uint64_t asimd_imm_const(uint32_t imm, int cmode, int op) | 53 | .access = PL1_R, |
57 | +{ | 54 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) |
58 | + /* | 55 | .access = PL1_R, .type = ARM_CP_CONST, |
59 | + * Expand the encoded constant. | 56 | .resetvalue = cpu->pmsav7_dregion << 8 |
60 | + * Note that cmode = 2,3,4,5,6,7,10,11,12,13 imm=0 is UNPREDICTABLE. | 57 | }; |
61 | + * We choose to not special-case this and will behave as if a | 58 | - ARMCPRegInfo crn0_wi_reginfo = { |
62 | + * valid constant encoding of 0 had been given. | 59 | + static const ARMCPRegInfo crn0_wi_reginfo = { |
63 | + * cmode = 15 op = 1 must UNDEF; we assume decode has handled that. | 60 | .name = "CRN0_WI", .cp = 15, .crn = 0, .crm = CP_ANY, |
64 | + */ | 61 | .opc1 = CP_ANY, .opc2 = CP_ANY, .access = PL1_W, |
65 | + switch (cmode) { | 62 | .type = ARM_CP_NOP | ARM_CP_OVERRIDE |
66 | + case 0: case 1: | 63 | }; |
67 | + /* no-op */ | 64 | #ifdef CONFIG_USER_ONLY |
68 | + break; | 65 | - ARMCPRegUserSpaceInfo id_v8_user_midr_cp_reginfo[] = { |
69 | + case 2: case 3: | 66 | + static const ARMCPRegUserSpaceInfo id_v8_user_midr_cp_reginfo[] = { |
70 | + imm <<= 8; | 67 | { .name = "MIDR_EL1", |
71 | + break; | 68 | .exported_bits = 0x00000000ffffffff }, |
72 | + case 4: case 5: | 69 | { .name = "REVIDR_EL1" }, |
73 | + imm <<= 16; | 70 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) |
74 | + break; | 71 | .access = PL1_R, .readfn = mpidr_read, .type = ARM_CP_NO_RAW }, |
75 | + case 6: case 7: | 72 | }; |
76 | + imm <<= 24; | 73 | #ifdef CONFIG_USER_ONLY |
77 | + break; | 74 | - ARMCPRegUserSpaceInfo mpidr_user_cp_reginfo[] = { |
78 | + case 8: case 9: | 75 | + static const ARMCPRegUserSpaceInfo mpidr_user_cp_reginfo[] = { |
79 | + imm |= imm << 16; | 76 | { .name = "MPIDR_EL1", |
80 | + break; | 77 | .fixed_bits = 0x0000000080000000 }, |
81 | + case 10: case 11: | 78 | }; |
82 | + imm = (imm << 8) | (imm << 24); | 79 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) |
83 | + break; | 80 | } |
84 | + case 12: | 81 | |
85 | + imm = (imm << 8) | 0xff; | 82 | if (arm_feature(env, ARM_FEATURE_VBAR)) { |
86 | + break; | 83 | - ARMCPRegInfo vbar_cp_reginfo[] = { |
87 | + case 13: | 84 | + static const ARMCPRegInfo vbar_cp_reginfo[] = { |
88 | + imm = (imm << 16) | 0xffff; | 85 | { .name = "VBAR", .state = ARM_CP_STATE_BOTH, |
89 | + break; | 86 | .opc0 = 3, .crn = 12, .crm = 0, .opc1 = 0, .opc2 = 0, |
90 | + case 14: | 87 | .access = PL1_RW, .writefn = vbar_write, |
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 | + } | ||
128 | + | ||
129 | + /* UNDEF accesses to D16-D31 if they don't exist. */ | ||
130 | + if (!dc_isar_feature(aa32_simd_r32, s) && (a->vd & 0x10)) { | ||
131 | + return false; | ||
132 | + } | ||
133 | + | ||
134 | + if (a->vd & a->q) { | ||
135 | + return false; | ||
136 | + } | ||
137 | + | ||
138 | + if (!vfp_access_check(s)) { | ||
139 | + return true; | ||
140 | + } | ||
141 | + | ||
142 | + reg_ofs = neon_reg_offset(a->vd, 0); | ||
143 | + vec_size = a->q ? 16 : 8; | ||
144 | + imm = asimd_imm_const(a->imm, a->cmode, a->op); | ||
145 | + | ||
146 | + fn(MO_64, reg_ofs, reg_ofs, imm, vec_size, vec_size); | ||
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 | -- | 88 | -- |
286 | 2.20.1 | 89 | 2.25.1 |
287 | 90 | ||
288 | 91 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Do not yet convert the helpers to loop over opr_sz, but the | 3 | Instead of defining ARM_CP_FLAG_MASK to remove flags, |
4 | descriptor allows the vector tail to be cleared. Which fixes | 4 | define ARM_CP_SPECIAL_MASK to isolate special cases. |
5 | an existing bug vs SVE. | 5 | Sort the specials to the low bits. Use an enum. |
6 | |||
7 | Split the large comment block so as to document each | ||
8 | value separately. | ||
6 | 9 | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 10 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
8 | Message-id: 20200514212831.31248-5-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: 20220501055028.646596-6-richard.henderson@linaro.org | ||
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 | 12 ++-- | 15 | target/arm/cpregs.h | 130 +++++++++++++++++++++++-------------- |
13 | target/arm/neon-dp.decode | 12 ++-- | 16 | target/arm/cpu.c | 4 +- |
14 | target/arm/crypto_helper.c | 24 +++++-- | 17 | target/arm/helper.c | 4 +- |
15 | target/arm/translate-a64.c | 34 ++++----- | 18 | target/arm/translate-a64.c | 6 +- |
16 | target/arm/translate-neon.inc.c | 124 +++++--------------------------- | 19 | target/arm/translate.c | 6 +- |
17 | target/arm/translate.c | 24 ++----- | 20 | 5 files changed, 92 insertions(+), 58 deletions(-) |
18 | 6 files changed, 67 insertions(+), 163 deletions(-) | 21 | |
19 | 22 | diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h | |
20 | diff --git a/target/arm/helper.h b/target/arm/helper.h | 23 | index XXXXXXX..XXXXXXX 100644 |
21 | index XXXXXXX..XXXXXXX 100644 | 24 | --- a/target/arm/cpregs.h |
22 | --- a/target/arm/helper.h | 25 | +++ b/target/arm/cpregs.h |
23 | +++ b/target/arm/helper.h | 26 | @@ -XXX,XX +XXX,XX @@ |
24 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(crypto_aese, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | 27 | #define TARGET_ARM_CPREGS_H |
25 | DEF_HELPER_FLAGS_3(crypto_aesmc, TCG_CALL_NO_RWG, void, ptr, ptr, i32) | 28 | |
26 | 29 | /* | |
27 | DEF_HELPER_FLAGS_4(crypto_sha1_3reg, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | 30 | - * ARMCPRegInfo type field bits. If the SPECIAL bit is set this is a |
28 | -DEF_HELPER_FLAGS_2(crypto_sha1h, TCG_CALL_NO_RWG, void, ptr, ptr) | 31 | - * special-behaviour cp reg and bits [11..8] indicate what behaviour |
29 | -DEF_HELPER_FLAGS_2(crypto_sha1su1, TCG_CALL_NO_RWG, void, ptr, ptr) | 32 | - * it has. Otherwise it is a simple cp reg, where CONST indicates that |
30 | +DEF_HELPER_FLAGS_3(crypto_sha1h, TCG_CALL_NO_RWG, void, ptr, ptr, i32) | 33 | - * TCG can assume the value to be constant (ie load at translate time) |
31 | +DEF_HELPER_FLAGS_3(crypto_sha1su1, TCG_CALL_NO_RWG, void, ptr, ptr, i32) | 34 | - * and 64BIT indicates a 64 bit wide coprocessor register. SUPPRESS_TB_END |
32 | 35 | - * indicates that the TB should not be ended after a write to this register | |
33 | -DEF_HELPER_FLAGS_3(crypto_sha256h, TCG_CALL_NO_RWG, void, ptr, ptr, ptr) | 36 | - * (the default is that the TB ends after cp writes). OVERRIDE permits |
34 | -DEF_HELPER_FLAGS_3(crypto_sha256h2, TCG_CALL_NO_RWG, void, ptr, ptr, ptr) | 37 | - * a register definition to override a previous definition for the |
35 | -DEF_HELPER_FLAGS_2(crypto_sha256su0, TCG_CALL_NO_RWG, void, ptr, ptr) | 38 | - * same (cp, is64, crn, crm, opc1, opc2) tuple: either the new or the |
36 | -DEF_HELPER_FLAGS_3(crypto_sha256su1, TCG_CALL_NO_RWG, void, ptr, ptr, ptr) | 39 | - * old must have the OVERRIDE bit set. |
37 | +DEF_HELPER_FLAGS_4(crypto_sha256h, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | 40 | - * ALIAS indicates that this register is an alias view of some underlying |
38 | +DEF_HELPER_FLAGS_4(crypto_sha256h2, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | 41 | - * state which is also visible via another register, and that the other |
39 | +DEF_HELPER_FLAGS_3(crypto_sha256su0, TCG_CALL_NO_RWG, void, ptr, ptr, i32) | 42 | - * register is handling migration and reset; registers marked ALIAS will not be |
40 | +DEF_HELPER_FLAGS_4(crypto_sha256su1, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | 43 | - * migrated but may have their state set by syncing of register state from KVM. |
41 | 44 | - * NO_RAW indicates that this register has no underlying state and does not | |
42 | DEF_HELPER_FLAGS_4(crypto_sha512h, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | 45 | - * support raw access for state saving/loading; it will not be used for either |
43 | DEF_HELPER_FLAGS_4(crypto_sha512h2, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | 46 | - * migration or KVM state synchronization. (Typically this is for "registers" |
44 | diff --git a/target/arm/neon-dp.decode b/target/arm/neon-dp.decode | 47 | - * which are actually used as instructions for cache maintenance and so on.) |
45 | index XXXXXXX..XXXXXXX 100644 | 48 | - * IO indicates that this register does I/O and therefore its accesses |
46 | --- a/target/arm/neon-dp.decode | 49 | - * need to be marked with gen_io_start() and also end the TB. In particular, |
47 | +++ b/target/arm/neon-dp.decode | 50 | - * registers which implement clocks or timers require this. |
48 | @@ -XXX,XX +XXX,XX @@ VPADD_3s 1111 001 0 0 . .. .... .... 1011 . . . 1 .... @3same_q0 | 51 | - * RAISES_EXC is for when the read or write hook might raise an exception; |
49 | 52 | - * the generated code will synchronize the CPU state before calling the hook | |
50 | VQRDMLAH_3s 1111 001 1 0 . .. .... .... 1011 ... 1 .... @3same | 53 | - * so that it is safe for the hook to call raise_exception(). |
51 | 54 | - * NEWEL is for writes to registers that might change the exception | |
52 | +@3same_crypto .... .... .... .... .... .... .... .... \ | 55 | - * level - typically on older ARM chips. For those cases we need to |
53 | + &3same vm=%vm_dp vn=%vn_dp vd=%vd_dp size=0 q=1 | 56 | - * re-read the new el when recomputing the translation flags. |
57 | + * ARMCPRegInfo type field bits: | ||
58 | */ | ||
59 | -#define ARM_CP_SPECIAL 0x0001 | ||
60 | -#define ARM_CP_CONST 0x0002 | ||
61 | -#define ARM_CP_64BIT 0x0004 | ||
62 | -#define ARM_CP_SUPPRESS_TB_END 0x0008 | ||
63 | -#define ARM_CP_OVERRIDE 0x0010 | ||
64 | -#define ARM_CP_ALIAS 0x0020 | ||
65 | -#define ARM_CP_IO 0x0040 | ||
66 | -#define ARM_CP_NO_RAW 0x0080 | ||
67 | -#define ARM_CP_NOP (ARM_CP_SPECIAL | 0x0100) | ||
68 | -#define ARM_CP_WFI (ARM_CP_SPECIAL | 0x0200) | ||
69 | -#define ARM_CP_NZCV (ARM_CP_SPECIAL | 0x0300) | ||
70 | -#define ARM_CP_CURRENTEL (ARM_CP_SPECIAL | 0x0400) | ||
71 | -#define ARM_CP_DC_ZVA (ARM_CP_SPECIAL | 0x0500) | ||
72 | -#define ARM_CP_DC_GVA (ARM_CP_SPECIAL | 0x0600) | ||
73 | -#define ARM_CP_DC_GZVA (ARM_CP_SPECIAL | 0x0700) | ||
74 | -#define ARM_LAST_SPECIAL ARM_CP_DC_GZVA | ||
75 | -#define ARM_CP_FPU 0x1000 | ||
76 | -#define ARM_CP_SVE 0x2000 | ||
77 | -#define ARM_CP_NO_GDB 0x4000 | ||
78 | -#define ARM_CP_RAISES_EXC 0x8000 | ||
79 | -#define ARM_CP_NEWEL 0x10000 | ||
80 | -/* Mask of only the flag bits in a type field */ | ||
81 | -#define ARM_CP_FLAG_MASK 0x1f0ff | ||
82 | +enum { | ||
83 | + /* | ||
84 | + * Register must be handled specially during translation. | ||
85 | + * The method is one of the values below: | ||
86 | + */ | ||
87 | + ARM_CP_SPECIAL_MASK = 0x000f, | ||
88 | + /* Special: no change to PE state: writes ignored, reads ignored. */ | ||
89 | + ARM_CP_NOP = 0x0001, | ||
90 | + /* Special: sysreg is WFI, for v5 and v6. */ | ||
91 | + ARM_CP_WFI = 0x0002, | ||
92 | + /* Special: sysreg is NZCV. */ | ||
93 | + ARM_CP_NZCV = 0x0003, | ||
94 | + /* Special: sysreg is CURRENTEL. */ | ||
95 | + ARM_CP_CURRENTEL = 0x0004, | ||
96 | + /* Special: sysreg is DC ZVA or similar. */ | ||
97 | + ARM_CP_DC_ZVA = 0x0005, | ||
98 | + ARM_CP_DC_GVA = 0x0006, | ||
99 | + ARM_CP_DC_GZVA = 0x0007, | ||
54 | + | 100 | + |
55 | SHA1_3s 1111 001 0 0 . optype:2 .... .... 1100 . 1 . 0 .... \ | 101 | + /* Flag: reads produce resetvalue; writes ignored. */ |
56 | vm=%vm_dp vn=%vn_dp vd=%vd_dp | 102 | + ARM_CP_CONST = 1 << 4, |
57 | -SHA256H_3s 1111 001 1 0 . 00 .... .... 1100 . 1 . 0 .... \ | 103 | + /* Flag: For ARM_CP_STATE_AA32, sysreg is 64-bit. */ |
58 | - vm=%vm_dp vn=%vn_dp vd=%vd_dp | 104 | + ARM_CP_64BIT = 1 << 5, |
59 | -SHA256H2_3s 1111 001 1 0 . 01 .... .... 1100 . 1 . 0 .... \ | 105 | + /* |
60 | - vm=%vm_dp vn=%vn_dp vd=%vd_dp | 106 | + * Flag: TB should not be ended after a write to this register |
61 | -SHA256SU1_3s 1111 001 1 0 . 10 .... .... 1100 . 1 . 0 .... \ | 107 | + * (the default is that the TB ends after cp writes). |
62 | - vm=%vm_dp vn=%vn_dp vd=%vd_dp | 108 | + */ |
63 | +SHA256H_3s 1111 001 1 0 . 00 .... .... 1100 . 1 . 0 .... @3same_crypto | 109 | + ARM_CP_SUPPRESS_TB_END = 1 << 6, |
64 | +SHA256H2_3s 1111 001 1 0 . 01 .... .... 1100 . 1 . 0 .... @3same_crypto | 110 | + /* |
65 | +SHA256SU1_3s 1111 001 1 0 . 10 .... .... 1100 . 1 . 0 .... @3same_crypto | 111 | + * Flag: Permit a register definition to override a previous definition |
66 | 112 | + * for the same (cp, is64, crn, crm, opc1, opc2) tuple: either the new | |
67 | VFMA_fp_3s 1111 001 0 0 . 0 . .... .... 1100 ... 1 .... @3same_fp | 113 | + * or the old must have the ARM_CP_OVERRIDE bit set. |
68 | VFMS_fp_3s 1111 001 0 0 . 1 . .... .... 1100 ... 1 .... @3same_fp | 114 | + */ |
69 | diff --git a/target/arm/crypto_helper.c b/target/arm/crypto_helper.c | 115 | + ARM_CP_OVERRIDE = 1 << 7, |
70 | index XXXXXXX..XXXXXXX 100644 | 116 | + /* |
71 | --- a/target/arm/crypto_helper.c | 117 | + * Flag: Register is an alias view of some underlying state which is also |
72 | +++ b/target/arm/crypto_helper.c | 118 | + * visible via another register, and that the other register is handling |
73 | @@ -XXX,XX +XXX,XX @@ void HELPER(crypto_sha1_3reg)(void *vd, void *vn, void *vm, uint32_t op) | 119 | + * migration and reset; registers marked ARM_CP_ALIAS will not be migrated |
74 | rd[1] = d.l[1]; | 120 | + * but may have their state set by syncing of register state from KVM. |
75 | } | 121 | + */ |
76 | 122 | + ARM_CP_ALIAS = 1 << 8, | |
77 | -void HELPER(crypto_sha1h)(void *vd, void *vm) | 123 | + /* |
78 | +void HELPER(crypto_sha1h)(void *vd, void *vm, uint32_t desc) | 124 | + * Flag: Register does I/O and therefore its accesses need to be marked |
79 | { | 125 | + * with gen_io_start() and also end the TB. In particular, registers which |
80 | uint64_t *rd = vd; | 126 | + * implement clocks or timers require this. |
81 | uint64_t *rm = vm; | 127 | + */ |
82 | @@ -XXX,XX +XXX,XX @@ void HELPER(crypto_sha1h)(void *vd, void *vm) | 128 | + ARM_CP_IO = 1 << 9, |
83 | 129 | + /* | |
84 | rd[0] = m.l[0]; | 130 | + * Flag: Register has no underlying state and does not support raw access |
85 | rd[1] = m.l[1]; | 131 | + * for state saving/loading; it will not be used for either migration or |
86 | + | 132 | + * KVM state synchronization. Typically this is for "registers" which are |
87 | + clear_tail_16(vd, desc); | 133 | + * actually used as instructions for cache maintenance and so on. |
88 | } | 134 | + */ |
89 | 135 | + ARM_CP_NO_RAW = 1 << 10, | |
90 | -void HELPER(crypto_sha1su1)(void *vd, void *vm) | 136 | + /* |
91 | +void HELPER(crypto_sha1su1)(void *vd, void *vm, uint32_t desc) | 137 | + * Flag: The read or write hook might raise an exception; the generated |
92 | { | 138 | + * code will synchronize the CPU state before calling the hook so that it |
93 | uint64_t *rd = vd; | 139 | + * is safe for the hook to call raise_exception(). |
94 | uint64_t *rm = vm; | 140 | + */ |
95 | @@ -XXX,XX +XXX,XX @@ void HELPER(crypto_sha1su1)(void *vd, void *vm) | 141 | + ARM_CP_RAISES_EXC = 1 << 11, |
96 | 142 | + /* | |
97 | rd[0] = d.l[0]; | 143 | + * Flag: Writes to the sysreg might change the exception level - typically |
98 | rd[1] = d.l[1]; | 144 | + * on older ARM chips. For those cases we need to re-read the new el when |
99 | + | 145 | + * recomputing the translation flags. |
100 | + clear_tail_16(vd, desc); | 146 | + */ |
101 | } | 147 | + ARM_CP_NEWEL = 1 << 12, |
148 | + /* | ||
149 | + * Flag: Access check for this sysreg is identical to accessing FPU state | ||
150 | + * from an instruction: use translation fp_access_check(). | ||
151 | + */ | ||
152 | + ARM_CP_FPU = 1 << 13, | ||
153 | + /* | ||
154 | + * Flag: Access check for this sysreg is identical to accessing SVE state | ||
155 | + * from an instruction: use translation sve_access_check(). | ||
156 | + */ | ||
157 | + ARM_CP_SVE = 1 << 14, | ||
158 | + /* Flag: Do not expose in gdb sysreg xml. */ | ||
159 | + ARM_CP_NO_GDB = 1 << 15, | ||
160 | +}; | ||
102 | 161 | ||
103 | /* | 162 | /* |
104 | @@ -XXX,XX +XXX,XX @@ static uint32_t s1(uint32_t x) | 163 | * Valid values for ARMCPRegInfo state field, indicating which of |
105 | return ror32(x, 17) ^ ror32(x, 19) ^ (x >> 10); | 164 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c |
106 | } | 165 | index XXXXXXX..XXXXXXX 100644 |
107 | 166 | --- a/target/arm/cpu.c | |
108 | -void HELPER(crypto_sha256h)(void *vd, void *vn, void *vm) | 167 | +++ b/target/arm/cpu.c |
109 | +void HELPER(crypto_sha256h)(void *vd, void *vn, void *vm, uint32_t desc) | 168 | @@ -XXX,XX +XXX,XX @@ static void cp_reg_reset(gpointer key, gpointer value, gpointer opaque) |
110 | { | 169 | ARMCPRegInfo *ri = value; |
111 | uint64_t *rd = vd; | 170 | ARMCPU *cpu = opaque; |
112 | uint64_t *rn = vn; | 171 | |
113 | @@ -XXX,XX +XXX,XX @@ void HELPER(crypto_sha256h)(void *vd, void *vn, void *vm) | 172 | - if (ri->type & (ARM_CP_SPECIAL | ARM_CP_ALIAS)) { |
114 | 173 | + if (ri->type & (ARM_CP_SPECIAL_MASK | ARM_CP_ALIAS)) { | |
115 | rd[0] = d.l[0]; | 174 | return; |
116 | rd[1] = d.l[1]; | 175 | } |
117 | + | 176 | |
118 | + clear_tail_16(vd, desc); | 177 | @@ -XXX,XX +XXX,XX @@ static void cp_reg_check_reset(gpointer key, gpointer value, gpointer opaque) |
119 | } | 178 | ARMCPU *cpu = opaque; |
120 | 179 | uint64_t oldvalue, newvalue; | |
121 | -void HELPER(crypto_sha256h2)(void *vd, void *vn, void *vm) | 180 | |
122 | +void HELPER(crypto_sha256h2)(void *vd, void *vn, void *vm, uint32_t desc) | 181 | - if (ri->type & (ARM_CP_SPECIAL | ARM_CP_ALIAS | ARM_CP_NO_RAW)) { |
123 | { | 182 | + if (ri->type & (ARM_CP_SPECIAL_MASK | ARM_CP_ALIAS | ARM_CP_NO_RAW)) { |
124 | uint64_t *rd = vd; | 183 | return; |
125 | uint64_t *rn = vn; | 184 | } |
126 | @@ -XXX,XX +XXX,XX @@ void HELPER(crypto_sha256h2)(void *vd, void *vn, void *vm) | 185 | |
127 | 186 | diff --git a/target/arm/helper.c b/target/arm/helper.c | |
128 | rd[0] = d.l[0]; | 187 | index XXXXXXX..XXXXXXX 100644 |
129 | rd[1] = d.l[1]; | 188 | --- a/target/arm/helper.c |
130 | + | 189 | +++ b/target/arm/helper.c |
131 | + clear_tail_16(vd, desc); | 190 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, |
132 | } | 191 | * multiple times. Special registers (ie NOP/WFI) are |
133 | 192 | * never migratable and not even raw-accessible. | |
134 | -void HELPER(crypto_sha256su0)(void *vd, void *vm) | 193 | */ |
135 | +void HELPER(crypto_sha256su0)(void *vd, void *vm, uint32_t desc) | 194 | - if ((r->type & ARM_CP_SPECIAL)) { |
136 | { | 195 | + if (r->type & ARM_CP_SPECIAL_MASK) { |
137 | uint64_t *rd = vd; | 196 | r2->type |= ARM_CP_NO_RAW; |
138 | uint64_t *rm = vm; | 197 | } |
139 | @@ -XXX,XX +XXX,XX @@ void HELPER(crypto_sha256su0)(void *vd, void *vm) | 198 | if (((r->crm == CP_ANY) && crm != 0) || |
140 | 199 | @@ -XXX,XX +XXX,XX @@ void define_one_arm_cp_reg_with_opaque(ARMCPU *cpu, | |
141 | rd[0] = d.l[0]; | 200 | /* Check that the register definition has enough info to handle |
142 | rd[1] = d.l[1]; | 201 | * reads and writes if they are permitted. |
143 | + | 202 | */ |
144 | + clear_tail_16(vd, desc); | 203 | - if (!(r->type & (ARM_CP_SPECIAL|ARM_CP_CONST))) { |
145 | } | 204 | + if (!(r->type & (ARM_CP_SPECIAL_MASK | ARM_CP_CONST))) { |
146 | 205 | if (r->access & PL3_R) { | |
147 | -void HELPER(crypto_sha256su1)(void *vd, void *vn, void *vm) | 206 | assert((r->fieldoffset || |
148 | +void HELPER(crypto_sha256su1)(void *vd, void *vn, void *vm, uint32_t desc) | 207 | (r->bank_fieldoffsets[0] && r->bank_fieldoffsets[1])) || |
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 | 208 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c |
162 | index XXXXXXX..XXXXXXX 100644 | 209 | index XXXXXXX..XXXXXXX 100644 |
163 | --- a/target/arm/translate-a64.c | 210 | --- a/target/arm/translate-a64.c |
164 | +++ b/target/arm/translate-a64.c | 211 | +++ b/target/arm/translate-a64.c |
165 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_three_reg_sha(DisasContext *s, uint32_t insn) | 212 | @@ -XXX,XX +XXX,XX @@ static void handle_sys(DisasContext *s, uint32_t insn, bool isread, |
166 | int rm = extract32(insn, 16, 5); | 213 | } |
167 | int rn = extract32(insn, 5, 5); | 214 | |
168 | int rd = extract32(insn, 0, 5); | 215 | /* Handle special cases first */ |
169 | - CryptoThreeOpFn *genfn; | 216 | - switch (ri->type & ~(ARM_CP_FLAG_MASK & ~ARM_CP_SPECIAL)) { |
170 | - TCGv_ptr tcg_rd_ptr, tcg_rn_ptr, tcg_rm_ptr; | 217 | + switch (ri->type & ARM_CP_SPECIAL_MASK) { |
171 | + gen_helper_gvec_3 *genfn; | 218 | + case 0: |
172 | bool feature; | 219 | + break; |
173 | 220 | case ARM_CP_NOP: | |
174 | if (size != 0) { | 221 | return; |
175 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_three_reg_sha(DisasContext *s, uint32_t insn) | 222 | case ARM_CP_NZCV: |
176 | return; | 223 | @@ -XXX,XX +XXX,XX @@ static void handle_sys(DisasContext *s, uint32_t insn, bool isread, |
177 | } | 224 | } |
178 | 225 | return; | |
179 | - tcg_rd_ptr = vec_full_reg_ptr(s, rd); | 226 | default: |
180 | - tcg_rn_ptr = vec_full_reg_ptr(s, rn); | 227 | - break; |
181 | - tcg_rm_ptr = vec_full_reg_ptr(s, rm); | 228 | + g_assert_not_reached(); |
182 | - | 229 | } |
183 | if (genfn) { | 230 | if ((ri->type & ARM_CP_FPU) && !fp_access_check(s)) { |
184 | - genfn(tcg_rd_ptr, tcg_rn_ptr, tcg_rm_ptr); | 231 | return; |
185 | + gen_gvec_op3_ool(s, true, rd, rn, rm, 0, genfn); | ||
186 | } else { | ||
187 | TCGv_i32 tcg_opcode = tcg_const_i32(opcode); | ||
188 | + TCGv_ptr tcg_rd_ptr = vec_full_reg_ptr(s, rd); | ||
189 | + TCGv_ptr tcg_rn_ptr = vec_full_reg_ptr(s, rn); | ||
190 | + TCGv_ptr tcg_rm_ptr = vec_full_reg_ptr(s, rm); | ||
191 | |||
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 | 232 | diff --git a/target/arm/translate.c b/target/arm/translate.c |
380 | index XXXXXXX..XXXXXXX 100644 | 233 | index XXXXXXX..XXXXXXX 100644 |
381 | --- a/target/arm/translate.c | 234 | --- a/target/arm/translate.c |
382 | +++ b/target/arm/translate.c | 235 | +++ b/target/arm/translate.c |
383 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | 236 | @@ -XXX,XX +XXX,XX @@ static void do_coproc_insn(DisasContext *s, int cpnum, int is64, |
384 | int vec_size; | 237 | } |
385 | uint32_t imm; | 238 | |
386 | TCGv_i32 tmp, tmp2, tmp3, tmp4, tmp5; | 239 | /* Handle special cases first */ |
387 | - TCGv_ptr ptr1, ptr2; | 240 | - switch (ri->type & ~(ARM_CP_FLAG_MASK & ~ARM_CP_SPECIAL)) { |
388 | + TCGv_ptr ptr1; | 241 | + switch (ri->type & ARM_CP_SPECIAL_MASK) { |
389 | TCGv_i64 tmp64; | 242 | + case 0: |
390 | 243 | + break; | |
391 | if (!arm_dc_feature(s, ARM_FEATURE_NEON)) { | 244 | case ARM_CP_NOP: |
392 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | 245 | return; |
393 | if (!dc_isar_feature(aa32_sha1, s) || ((rm | rd) & 1)) { | 246 | case ARM_CP_WFI: |
394 | return 1; | 247 | @@ -XXX,XX +XXX,XX @@ static void do_coproc_insn(DisasContext *s, int cpnum, int is64, |
395 | } | 248 | s->base.is_jmp = DISAS_WFI; |
396 | - ptr1 = vfp_reg_ptr(true, rd); | 249 | return; |
397 | - ptr2 = vfp_reg_ptr(true, rm); | 250 | default: |
398 | - | 251 | - break; |
399 | - gen_helper_crypto_sha1h(ptr1, ptr2); | 252 | + g_assert_not_reached(); |
400 | - | 253 | } |
401 | - tcg_temp_free_ptr(ptr1); | 254 | |
402 | - tcg_temp_free_ptr(ptr2); | 255 | if ((tb_cflags(s->base.tb) & CF_USE_ICOUNT) && (ri->type & ARM_CP_IO)) { |
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 | -- | 256 | -- |
430 | 2.20.1 | 257 | 2.25.1 |
431 | |||
432 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Do not yet convert the helpers to loop over opr_sz, but the | 3 | Standardize on g_assert_not_reached() for "should not happen". |
4 | descriptor allows the vector tail to be cleared. Which fixes | 4 | Retain abort() when preceeded by fprintf or error_report. |
5 | an existing bug vs SVE. | ||
6 | 5 | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 6 | 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> | 7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Message-id: 20220501055028.646596-7-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 | 15 +++++++----- | 11 | target/arm/helper.c | 7 +++---- |
13 | target/arm/crypto_helper.c | 37 +++++++++++++++++++++++----- | 12 | target/arm/hvf/hvf.c | 2 +- |
14 | target/arm/translate-a64.c | 50 ++++++++++++-------------------------- | 13 | target/arm/kvm-stub.c | 4 ++-- |
15 | 3 files changed, 55 insertions(+), 47 deletions(-) | 14 | target/arm/kvm.c | 4 ++-- |
15 | target/arm/machine.c | 4 ++-- | ||
16 | target/arm/translate-a64.c | 4 ++-- | ||
17 | target/arm/translate-neon.c | 2 +- | ||
18 | target/arm/translate.c | 4 ++-- | ||
19 | 8 files changed, 15 insertions(+), 16 deletions(-) | ||
16 | 20 | ||
17 | diff --git a/target/arm/helper.h b/target/arm/helper.h | 21 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
18 | index XXXXXXX..XXXXXXX 100644 | 22 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/target/arm/helper.h | 23 | --- a/target/arm/helper.c |
20 | +++ b/target/arm/helper.h | 24 | +++ b/target/arm/helper.c |
21 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(crypto_sha256h2, TCG_CALL_NO_RWG, void, ptr, ptr, ptr) | 25 | @@ -XXX,XX +XXX,XX @@ void define_one_arm_cp_reg_with_opaque(ARMCPU *cpu, |
22 | DEF_HELPER_FLAGS_2(crypto_sha256su0, TCG_CALL_NO_RWG, void, ptr, ptr) | 26 | break; |
23 | DEF_HELPER_FLAGS_3(crypto_sha256su1, TCG_CALL_NO_RWG, void, ptr, ptr, ptr) | 27 | default: |
24 | 28 | /* broken reginfo with out-of-range opc1 */ | |
25 | -DEF_HELPER_FLAGS_3(crypto_sha512h, TCG_CALL_NO_RWG, void, ptr, ptr, ptr) | 29 | - assert(false); |
26 | -DEF_HELPER_FLAGS_3(crypto_sha512h2, TCG_CALL_NO_RWG, void, ptr, ptr, ptr) | 30 | - break; |
27 | -DEF_HELPER_FLAGS_2(crypto_sha512su0, TCG_CALL_NO_RWG, void, ptr, ptr) | 31 | + g_assert_not_reached(); |
28 | -DEF_HELPER_FLAGS_3(crypto_sha512su1, TCG_CALL_NO_RWG, void, ptr, ptr, ptr) | 32 | } |
29 | +DEF_HELPER_FLAGS_4(crypto_sha512h, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | 33 | /* assert our permissions are not too lax (stricter is fine) */ |
30 | +DEF_HELPER_FLAGS_4(crypto_sha512h2, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | 34 | assert((r->access & ~mask) == 0); |
31 | +DEF_HELPER_FLAGS_3(crypto_sha512su0, TCG_CALL_NO_RWG, void, ptr, ptr, i32) | 35 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_v5(CPUARMState *env, uint32_t address, |
32 | +DEF_HELPER_FLAGS_4(crypto_sha512su1, TCG_CALL_NO_RWG, | 36 | break; |
33 | + void, ptr, ptr, ptr, i32) | 37 | default: |
34 | 38 | /* Never happens, but compiler isn't smart enough to tell. */ | |
35 | DEF_HELPER_FLAGS_5(crypto_sm3tt, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32, i32) | 39 | - abort(); |
36 | -DEF_HELPER_FLAGS_3(crypto_sm3partw1, TCG_CALL_NO_RWG, void, ptr, ptr, ptr) | 40 | + g_assert_not_reached(); |
37 | -DEF_HELPER_FLAGS_3(crypto_sm3partw2, TCG_CALL_NO_RWG, void, ptr, ptr, ptr) | 41 | } |
38 | +DEF_HELPER_FLAGS_4(crypto_sm3partw1, TCG_CALL_NO_RWG, | 42 | } |
39 | + void, ptr, ptr, ptr, i32) | 43 | *prot = ap_to_rw_prot(env, mmu_idx, ap, domain_prot); |
40 | +DEF_HELPER_FLAGS_4(crypto_sm3partw2, TCG_CALL_NO_RWG, | 44 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_v6(CPUARMState *env, uint32_t address, |
41 | + void, ptr, ptr, ptr, i32) | 45 | break; |
42 | 46 | default: | |
43 | DEF_HELPER_FLAGS_4(crypto_sm4e, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | 47 | /* Never happens, but compiler isn't smart enough to tell. */ |
44 | DEF_HELPER_FLAGS_4(crypto_sm4ekey, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | 48 | - abort(); |
45 | diff --git a/target/arm/crypto_helper.c b/target/arm/crypto_helper.c | 49 | + g_assert_not_reached(); |
50 | } | ||
51 | } | ||
52 | if (domain_prot == 3) { | ||
53 | diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c | ||
46 | index XXXXXXX..XXXXXXX 100644 | 54 | index XXXXXXX..XXXXXXX 100644 |
47 | --- a/target/arm/crypto_helper.c | 55 | --- a/target/arm/hvf/hvf.c |
48 | +++ b/target/arm/crypto_helper.c | 56 | +++ b/target/arm/hvf/hvf.c |
49 | @@ -XXX,XX +XXX,XX @@ union CRYPTO_STATE { | 57 | @@ -XXX,XX +XXX,XX @@ int hvf_vcpu_exec(CPUState *cpu) |
50 | #define CR_ST_WORD(state, i) (state.words[i]) | 58 | /* we got kicked, no exit to process */ |
51 | #endif | 59 | return 0; |
52 | 60 | default: | |
53 | +/* | 61 | - assert(0); |
54 | + * The caller has not been converted to full gvec, and so only | 62 | + g_assert_not_reached(); |
55 | + * modifies the low 16 bytes of the vector register. | 63 | } |
56 | + */ | 64 | |
57 | +static void clear_tail_16(void *vd, uint32_t desc) | 65 | hvf_sync_vtimer(cpu); |
58 | +{ | 66 | diff --git a/target/arm/kvm-stub.c b/target/arm/kvm-stub.c |
59 | + int opr_sz = simd_oprsz(desc); | 67 | index XXXXXXX..XXXXXXX 100644 |
60 | + int max_sz = simd_maxsz(desc); | 68 | --- a/target/arm/kvm-stub.c |
61 | + | 69 | +++ b/target/arm/kvm-stub.c |
62 | + assert(opr_sz == 16); | 70 | @@ -XXX,XX +XXX,XX @@ |
63 | + clear_tail(vd, opr_sz, max_sz); | 71 | |
64 | +} | 72 | bool write_kvmstate_to_list(ARMCPU *cpu) |
65 | + | ||
66 | static void do_crypto_aese(uint64_t *rd, uint64_t *rn, | ||
67 | uint64_t *rm, bool decrypt) | ||
68 | { | 73 | { |
69 | @@ -XXX,XX +XXX,XX @@ static uint64_t s1_512(uint64_t x) | 74 | - abort(); |
70 | return ror64(x, 19) ^ ror64(x, 61) ^ (x >> 6); | 75 | + g_assert_not_reached(); |
71 | } | 76 | } |
72 | 77 | ||
73 | -void HELPER(crypto_sha512h)(void *vd, void *vn, void *vm) | 78 | bool write_list_to_kvmstate(ARMCPU *cpu, int level) |
74 | +void HELPER(crypto_sha512h)(void *vd, void *vn, void *vm, uint32_t desc) | ||
75 | { | 79 | { |
76 | uint64_t *rd = vd; | 80 | - abort(); |
77 | uint64_t *rn = vn; | 81 | + g_assert_not_reached(); |
78 | @@ -XXX,XX +XXX,XX @@ void HELPER(crypto_sha512h)(void *vd, void *vn, void *vm) | ||
79 | |||
80 | rd[0] = d0; | ||
81 | rd[1] = d1; | ||
82 | + | ||
83 | + clear_tail_16(vd, desc); | ||
84 | } | 82 | } |
85 | 83 | diff --git a/target/arm/kvm.c b/target/arm/kvm.c | |
86 | -void HELPER(crypto_sha512h2)(void *vd, void *vn, void *vm) | 84 | index XXXXXXX..XXXXXXX 100644 |
87 | +void HELPER(crypto_sha512h2)(void *vd, void *vn, void *vm, uint32_t desc) | 85 | --- a/target/arm/kvm.c |
88 | { | 86 | +++ b/target/arm/kvm.c |
89 | uint64_t *rd = vd; | 87 | @@ -XXX,XX +XXX,XX @@ bool write_kvmstate_to_list(ARMCPU *cpu) |
90 | uint64_t *rn = vn; | 88 | ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, &r); |
91 | @@ -XXX,XX +XXX,XX @@ void HELPER(crypto_sha512h2)(void *vd, void *vn, void *vm) | 89 | break; |
92 | 90 | default: | |
93 | rd[0] = d0; | 91 | - abort(); |
94 | rd[1] = d1; | 92 | + g_assert_not_reached(); |
95 | + | 93 | } |
96 | + clear_tail_16(vd, desc); | 94 | if (ret) { |
97 | } | 95 | ok = false; |
98 | 96 | @@ -XXX,XX +XXX,XX @@ bool write_list_to_kvmstate(ARMCPU *cpu, int level) | |
99 | -void HELPER(crypto_sha512su0)(void *vd, void *vn) | 97 | r.addr = (uintptr_t)(cpu->cpreg_values + i); |
100 | +void HELPER(crypto_sha512su0)(void *vd, void *vn, uint32_t desc) | 98 | break; |
101 | { | 99 | default: |
102 | uint64_t *rd = vd; | 100 | - abort(); |
103 | uint64_t *rn = vn; | 101 | + g_assert_not_reached(); |
104 | @@ -XXX,XX +XXX,XX @@ void HELPER(crypto_sha512su0)(void *vd, void *vn) | 102 | } |
105 | 103 | ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, &r); | |
106 | rd[0] = d0; | 104 | if (ret) { |
107 | rd[1] = d1; | 105 | diff --git a/target/arm/machine.c b/target/arm/machine.c |
108 | + | 106 | index XXXXXXX..XXXXXXX 100644 |
109 | + clear_tail_16(vd, desc); | 107 | --- a/target/arm/machine.c |
110 | } | 108 | +++ b/target/arm/machine.c |
111 | 109 | @@ -XXX,XX +XXX,XX @@ static int cpu_pre_save(void *opaque) | |
112 | -void HELPER(crypto_sha512su1)(void *vd, void *vn, void *vm) | 110 | if (kvm_enabled()) { |
113 | +void HELPER(crypto_sha512su1)(void *vd, void *vn, void *vm, uint32_t desc) | 111 | if (!write_kvmstate_to_list(cpu)) { |
114 | { | 112 | /* This should never fail */ |
115 | uint64_t *rd = vd; | 113 | - abort(); |
116 | uint64_t *rn = vn; | 114 | + g_assert_not_reached(); |
117 | @@ -XXX,XX +XXX,XX @@ void HELPER(crypto_sha512su1)(void *vd, void *vn, void *vm) | 115 | } |
118 | 116 | ||
119 | rd[0] += s1_512(rn[0]) + rm[0]; | 117 | /* |
120 | rd[1] += s1_512(rn[1]) + rm[1]; | 118 | @@ -XXX,XX +XXX,XX @@ static int cpu_pre_save(void *opaque) |
121 | + | 119 | } else { |
122 | + clear_tail_16(vd, desc); | 120 | if (!write_cpustate_to_list(cpu, false)) { |
123 | } | 121 | /* This should never fail. */ |
124 | 122 | - abort(); | |
125 | -void HELPER(crypto_sm3partw1)(void *vd, void *vn, void *vm) | 123 | + g_assert_not_reached(); |
126 | +void HELPER(crypto_sm3partw1)(void *vd, void *vn, void *vm, uint32_t desc) | 124 | } |
127 | { | 125 | } |
128 | uint64_t *rd = vd; | 126 | |
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 | 127 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c |
153 | index XXXXXXX..XXXXXXX 100644 | 128 | index XXXXXXX..XXXXXXX 100644 |
154 | --- a/target/arm/translate-a64.c | 129 | --- a/target/arm/translate-a64.c |
155 | +++ b/target/arm/translate-a64.c | 130 | +++ b/target/arm/translate-a64.c |
156 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_three_reg_sha512(DisasContext *s, uint32_t insn) | 131 | @@ -XXX,XX +XXX,XX @@ static void handle_fp_1src_half(DisasContext *s, int opcode, int rd, int rn) |
157 | int rn = extract32(insn, 5, 5); | 132 | gen_helper_advsimd_rinth(tcg_res, tcg_op, fpst); |
158 | int rd = extract32(insn, 0, 5); | 133 | break; |
159 | bool feature; | 134 | default: |
160 | - CryptoThreeOpFn *genfn = NULL; | 135 | - abort(); |
161 | gen_helper_gvec_3 *oolfn = NULL; | 136 | + g_assert_not_reached(); |
162 | GVecGen3Fn *gvecfn = NULL; | 137 | } |
163 | 138 | ||
164 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_three_reg_sha512(DisasContext *s, uint32_t insn) | 139 | write_fp_sreg(s, rd, tcg_res); |
165 | switch (opcode) { | 140 | @@ -XXX,XX +XXX,XX @@ static void handle_fp_fcvt(DisasContext *s, int opcode, |
166 | case 0: /* SHA512H */ | 141 | break; |
167 | feature = dc_isar_feature(aa64_sha512, s); | 142 | } |
168 | - genfn = gen_helper_crypto_sha512h; | 143 | default: |
169 | + oolfn = gen_helper_crypto_sha512h; | 144 | - abort(); |
170 | break; | 145 | + g_assert_not_reached(); |
171 | case 1: /* SHA512H2 */ | ||
172 | feature = dc_isar_feature(aa64_sha512, s); | ||
173 | - genfn = gen_helper_crypto_sha512h2; | ||
174 | + oolfn = gen_helper_crypto_sha512h2; | ||
175 | break; | ||
176 | case 2: /* SHA512SU1 */ | ||
177 | feature = dc_isar_feature(aa64_sha512, s); | ||
178 | - genfn = gen_helper_crypto_sha512su1; | ||
179 | + oolfn = gen_helper_crypto_sha512su1; | ||
180 | break; | ||
181 | case 3: /* RAX1 */ | ||
182 | feature = dc_isar_feature(aa64_sha3, s); | ||
183 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_three_reg_sha512(DisasContext *s, uint32_t insn) | ||
184 | switch (opcode) { | ||
185 | case 0: /* SM3PARTW1 */ | ||
186 | feature = dc_isar_feature(aa64_sm3, s); | ||
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 | } | 146 | } |
217 | } | 147 | } |
218 | 148 | ||
219 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_two_reg_sha512(DisasContext *s, uint32_t insn) | 149 | diff --git a/target/arm/translate-neon.c b/target/arm/translate-neon.c |
220 | int opcode = extract32(insn, 10, 2); | 150 | index XXXXXXX..XXXXXXX 100644 |
221 | int rn = extract32(insn, 5, 5); | 151 | --- a/target/arm/translate-neon.c |
222 | int rd = extract32(insn, 0, 5); | 152 | +++ b/target/arm/translate-neon.c |
223 | - TCGv_ptr tcg_rd_ptr, tcg_rn_ptr; | 153 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLDST_single(DisasContext *s, arg_VLDST_single *a) |
224 | bool feature; | 154 | } |
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; | 155 | break; |
237 | default: | 156 | default: |
238 | unallocated_encoding(s); | 157 | - abort(); |
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(); | 158 | + g_assert_not_reached(); |
255 | } | 159 | } |
256 | - | 160 | if ((vd + a->stride * (nregs - 1)) > 31) { |
257 | - tcg_rd_ptr = vec_full_reg_ptr(s, rd); | 161 | /* |
258 | - tcg_rn_ptr = vec_full_reg_ptr(s, rn); | 162 | diff --git a/target/arm/translate.c b/target/arm/translate.c |
259 | - | 163 | index XXXXXXX..XXXXXXX 100644 |
260 | - genfn(tcg_rd_ptr, tcg_rn_ptr); | 164 | --- a/target/arm/translate.c |
261 | - | 165 | +++ b/target/arm/translate.c |
262 | - tcg_temp_free_ptr(tcg_rd_ptr); | 166 | @@ -XXX,XX +XXX,XX @@ static void gen_srs(DisasContext *s, |
263 | - tcg_temp_free_ptr(tcg_rn_ptr); | 167 | offset = 4; |
264 | } | 168 | break; |
265 | 169 | default: | |
266 | /* Crypto four-register | 170 | - abort(); |
171 | + g_assert_not_reached(); | ||
172 | } | ||
173 | tcg_gen_addi_i32(addr, addr, offset); | ||
174 | tmp = load_reg(s, 14); | ||
175 | @@ -XXX,XX +XXX,XX @@ static void gen_srs(DisasContext *s, | ||
176 | offset = 0; | ||
177 | break; | ||
178 | default: | ||
179 | - abort(); | ||
180 | + g_assert_not_reached(); | ||
181 | } | ||
182 | tcg_gen_addi_i32(addr, addr, offset); | ||
183 | gen_helper_set_r13_banked(cpu_env, tcg_constant_i32(mode), addr); | ||
267 | -- | 184 | -- |
268 | 2.20.1 | 185 | 2.25.1 |
269 | |||
270 | diff view generated by jsdifflib |
1 | From: Paul Zimmerman <pauldzim@gmail.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Import the dwc-hsotg (dwc2) register definitions file from the | 3 | Create a typedef as well, and use it in ARMCPRegInfo. |
4 | Linux kernel. This is a copy of drivers/usb/dwc2/hw.h from the | 4 | This won't be perfect for debugging, but it'll nicely |
5 | mainline Linux kernel, the only changes being to the header, and | 5 | display the most common cases. |
6 | two instances of 'u32' changed to 'uint32_t' to allow it to | ||
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 | 6 | ||
10 | Signed-off-by: Paul Zimmerman <pauldzim@gmail.com> | ||
11 | Message-id: 20200520235349.21215-3-pauldzim@gmail.com | ||
12 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20220501055028.646596-8-richard.henderson@linaro.org | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | --- | 11 | --- |
15 | include/hw/usb/dwc2-regs.h | 899 +++++++++++++++++++++++++++++++++++++ | 12 | target/arm/cpregs.h | 44 +++++++++++++++++++++++--------------------- |
16 | 1 file changed, 899 insertions(+) | 13 | target/arm/helper.c | 2 +- |
17 | create mode 100644 include/hw/usb/dwc2-regs.h | 14 | 2 files changed, 24 insertions(+), 22 deletions(-) |
18 | 15 | ||
19 | diff --git a/include/hw/usb/dwc2-regs.h b/include/hw/usb/dwc2-regs.h | 16 | diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h |
20 | new file mode 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
21 | index XXXXXXX..XXXXXXX | 18 | --- a/target/arm/cpregs.h |
22 | --- /dev/null | 19 | +++ b/target/arm/cpregs.h |
23 | +++ b/include/hw/usb/dwc2-regs.h | 20 | @@ -XXX,XX +XXX,XX @@ enum { |
24 | @@ -XXX,XX +XXX,XX @@ | 21 | * described with these bits, then use a laxer set of restrictions, and |
25 | +/* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */ | 22 | * do the more restrictive/complex check inside a helper function. |
26 | +/* | 23 | */ |
27 | + * Imported from the Linux kernel file drivers/usb/dwc2/hw.h, commit | 24 | -#define PL3_R 0x80 |
28 | + * a89bae709b3492b478480a2c9734e7e9393b279c ("usb: dwc2: Move | 25 | -#define PL3_W 0x40 |
29 | + * UTMI_PHY_DATA defines closer") | 26 | -#define PL2_R (0x20 | PL3_R) |
30 | + * | 27 | -#define PL2_W (0x10 | PL3_W) |
31 | + * hw.h - DesignWare HS OTG Controller hardware definitions | 28 | -#define PL1_R (0x08 | PL2_R) |
32 | + * | 29 | -#define PL1_W (0x04 | PL2_W) |
33 | + * Copyright 2004-2013 Synopsys, Inc. | 30 | -#define PL0_R (0x02 | PL1_R) |
34 | + * | 31 | -#define PL0_W (0x01 | PL1_W) |
35 | + * Redistribution and use in source and binary forms, with or without | 32 | +typedef enum { |
36 | + * modification, are permitted provided that the following conditions | 33 | + PL3_R = 0x80, |
37 | + * are met: | 34 | + PL3_W = 0x40, |
38 | + * 1. Redistributions of source code must retain the above copyright | 35 | + PL2_R = 0x20 | PL3_R, |
39 | + * notice, this list of conditions, and the following disclaimer, | 36 | + PL2_W = 0x10 | PL3_W, |
40 | + * without modification. | 37 | + PL1_R = 0x08 | PL2_R, |
41 | + * 2. Redistributions in binary form must reproduce the above copyright | 38 | + PL1_W = 0x04 | PL2_W, |
42 | + * notice, this list of conditions and the following disclaimer in the | 39 | + PL0_R = 0x02 | PL1_R, |
43 | + * documentation and/or other materials provided with the distribution. | 40 | + PL0_W = 0x01 | PL1_W, |
44 | + * 3. The names of the above-listed copyright holders may not be used | 41 | |
45 | + * to endorse or promote products derived from this software without | 42 | -/* |
46 | + * specific prior written permission. | 43 | - * For user-mode some registers are accessible to EL0 via a kernel |
47 | + * | 44 | - * trap-and-emulate ABI. In this case we define the read permissions |
48 | + * ALTERNATIVELY, this software may be distributed under the terms of the | 45 | - * as actually being PL0_R. However some bits of any given register |
49 | + * GNU General Public License ("GPL") as published by the Free Software | 46 | - * may still be masked. |
50 | + * Foundation; either version 2 of the License, or (at your option) any | 47 | - */ |
51 | + * later version. | 48 | + /* |
52 | + * | 49 | + * For user-mode some registers are accessible to EL0 via a kernel |
53 | + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS | 50 | + * trap-and-emulate ABI. In this case we define the read permissions |
54 | + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | 51 | + * as actually being PL0_R. However some bits of any given register |
55 | + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 52 | + * may still be masked. |
56 | + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | 53 | + */ |
57 | + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 54 | #ifdef CONFIG_USER_ONLY |
58 | + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 55 | -#define PL0U_R PL0_R |
59 | + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 56 | + PL0U_R = PL0_R, |
60 | + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | 57 | #else |
61 | + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | 58 | -#define PL0U_R PL1_R |
62 | + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 59 | + PL0U_R = PL1_R, |
63 | + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 60 | #endif |
64 | + */ | 61 | |
65 | + | 62 | -#define PL3_RW (PL3_R | PL3_W) |
66 | +#ifndef __DWC2_HW_H__ | 63 | -#define PL2_RW (PL2_R | PL2_W) |
67 | +#define __DWC2_HW_H__ | 64 | -#define PL1_RW (PL1_R | PL1_W) |
68 | + | 65 | -#define PL0_RW (PL0_R | PL0_W) |
69 | +#define HSOTG_REG(x) (x) | 66 | + PL3_RW = PL3_R | PL3_W, |
70 | + | 67 | + PL2_RW = PL2_R | PL2_W, |
71 | +#define GOTGCTL HSOTG_REG(0x000) | 68 | + PL1_RW = PL1_R | PL1_W, |
72 | +#define GOTGCTL_CHIRPEN BIT(27) | 69 | + PL0_RW = PL0_R | PL0_W, |
73 | +#define GOTGCTL_MULT_VALID_BC_MASK (0x1f << 22) | 70 | +} CPAccessRights; |
74 | +#define GOTGCTL_MULT_VALID_BC_SHIFT 22 | 71 | |
75 | +#define GOTGCTL_OTGVER BIT(20) | 72 | typedef enum CPAccessResult { |
76 | +#define GOTGCTL_BSESVLD BIT(19) | 73 | /* Access is permitted */ |
77 | +#define GOTGCTL_ASESVLD BIT(18) | 74 | @@ -XXX,XX +XXX,XX @@ struct ARMCPRegInfo { |
78 | +#define GOTGCTL_DBNC_SHORT BIT(17) | 75 | /* Register type: ARM_CP_* bits/values */ |
79 | +#define GOTGCTL_CONID_B BIT(16) | 76 | int type; |
80 | +#define GOTGCTL_DBNCE_FLTR_BYPASS BIT(15) | 77 | /* Access rights: PL*_[RW] */ |
81 | +#define GOTGCTL_DEVHNPEN BIT(11) | 78 | - int access; |
82 | +#define GOTGCTL_HSTSETHNPEN BIT(10) | 79 | + CPAccessRights access; |
83 | +#define GOTGCTL_HNPREQ BIT(9) | 80 | /* Security state: ARM_CP_SECSTATE_* bits/values */ |
84 | +#define GOTGCTL_HSTNEGSCS BIT(8) | 81 | int secure; |
85 | +#define GOTGCTL_SESREQ BIT(1) | 82 | /* |
86 | +#define GOTGCTL_SESREQSCS BIT(0) | 83 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
87 | + | 84 | index XXXXXXX..XXXXXXX 100644 |
88 | +#define GOTGINT HSOTG_REG(0x004) | 85 | --- a/target/arm/helper.c |
89 | +#define GOTGINT_DBNCE_DONE BIT(19) | 86 | +++ b/target/arm/helper.c |
90 | +#define GOTGINT_A_DEV_TOUT_CHG BIT(18) | 87 | @@ -XXX,XX +XXX,XX @@ void define_one_arm_cp_reg_with_opaque(ARMCPU *cpu, |
91 | +#define GOTGINT_HST_NEG_DET BIT(17) | 88 | * to encompass the generic architectural permission check. |
92 | +#define GOTGINT_HST_NEG_SUC_STS_CHNG BIT(9) | 89 | */ |
93 | +#define GOTGINT_SES_REQ_SUC_STS_CHNG BIT(8) | 90 | if (r->state != ARM_CP_STATE_AA32) { |
94 | +#define GOTGINT_SES_END_DET BIT(2) | 91 | - int mask = 0; |
95 | + | 92 | + CPAccessRights mask; |
96 | +#define GAHBCFG HSOTG_REG(0x008) | 93 | switch (r->opc1) { |
97 | +#define GAHBCFG_AHB_SINGLE BIT(23) | 94 | case 0: |
98 | +#define GAHBCFG_NOTI_ALL_DMA_WRIT BIT(22) | 95 | /* min_EL EL1, but some accessible to EL0 via kernel ABI */ |
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 | -- | 96 | -- |
925 | 2.20.1 | 97 | 2.25.1 |
926 | |||
927 | diff view generated by jsdifflib |
1 | From: Cédric Le Goater <clg@kaod.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | 3 | Give this enum a name and use in ARMCPRegInfo, |
4 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 4 | add_cpreg_to_hashtable and define_one_arm_cp_reg_with_opaque. |
5 | Message-id: 20200602135050.593692-1-clg@kaod.org | 5 | |
6 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20220501055028.646596-9-richard.henderson@linaro.org | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | --- | 11 | --- |
8 | docs/system/arm/aspeed.rst | 85 ++++++++++++++++++++++++++++++++++++++ | 12 | target/arm/cpregs.h | 6 +++--- |
9 | docs/system/target-arm.rst | 1 + | 13 | target/arm/helper.c | 6 ++++-- |
10 | 2 files changed, 86 insertions(+) | 14 | 2 files changed, 7 insertions(+), 5 deletions(-) |
11 | create mode 100644 docs/system/arm/aspeed.rst | ||
12 | 15 | ||
13 | diff --git a/docs/system/arm/aspeed.rst b/docs/system/arm/aspeed.rst | 16 | diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h |
14 | new file mode 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
15 | index XXXXXXX..XXXXXXX | 18 | --- a/target/arm/cpregs.h |
16 | --- /dev/null | 19 | +++ b/target/arm/cpregs.h |
17 | +++ b/docs/system/arm/aspeed.rst | 20 | @@ -XXX,XX +XXX,XX @@ enum { |
18 | @@ -XXX,XX +XXX,XX @@ | 21 | * Note that we rely on the values of these enums as we iterate through |
19 | +Aspeed family boards (``*-bmc``, ``ast2500-evb``, ``ast2600-evb``) | 22 | * the various states in some places. |
20 | +================================================================== | 23 | */ |
24 | -enum { | ||
25 | +typedef enum { | ||
26 | ARM_CP_STATE_AA32 = 0, | ||
27 | ARM_CP_STATE_AA64 = 1, | ||
28 | ARM_CP_STATE_BOTH = 2, | ||
29 | -}; | ||
30 | +} CPState; | ||
31 | |||
32 | /* | ||
33 | * ARM CP register secure state flags. These flags identify security state | ||
34 | @@ -XXX,XX +XXX,XX @@ struct ARMCPRegInfo { | ||
35 | uint8_t opc1; | ||
36 | uint8_t opc2; | ||
37 | /* Execution state in which this register is visible: ARM_CP_STATE_* */ | ||
38 | - int state; | ||
39 | + CPState state; | ||
40 | /* Register type: ARM_CP_* bits/values */ | ||
41 | int type; | ||
42 | /* Access rights: PL*_[RW] */ | ||
43 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
44 | index XXXXXXX..XXXXXXX 100644 | ||
45 | --- a/target/arm/helper.c | ||
46 | +++ b/target/arm/helper.c | ||
47 | @@ -XXX,XX +XXX,XX @@ CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp) | ||
48 | } | ||
49 | |||
50 | static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, | ||
51 | - void *opaque, int state, int secstate, | ||
52 | + void *opaque, CPState state, int secstate, | ||
53 | int crm, int opc1, int opc2, | ||
54 | const char *name) | ||
55 | { | ||
56 | @@ -XXX,XX +XXX,XX @@ void define_one_arm_cp_reg_with_opaque(ARMCPU *cpu, | ||
57 | * bits; the ARM_CP_64BIT* flag applies only to the AArch32 view of | ||
58 | * the register, if any. | ||
59 | */ | ||
60 | - int crm, opc1, opc2, state; | ||
61 | + int crm, opc1, opc2; | ||
62 | int crmmin = (r->crm == CP_ANY) ? 0 : r->crm; | ||
63 | int crmmax = (r->crm == CP_ANY) ? 15 : r->crm; | ||
64 | int opc1min = (r->opc1 == CP_ANY) ? 0 : r->opc1; | ||
65 | int opc1max = (r->opc1 == CP_ANY) ? 7 : r->opc1; | ||
66 | int opc2min = (r->opc2 == CP_ANY) ? 0 : r->opc2; | ||
67 | int opc2max = (r->opc2 == CP_ANY) ? 7 : r->opc2; | ||
68 | + CPState state; | ||
21 | + | 69 | + |
22 | +The QEMU Aspeed machines model BMCs of various OpenPOWER systems and | 70 | /* 64 bit registers have only CRm and Opc1 fields */ |
23 | +Aspeed evaluation boards. They are based on different releases of the | 71 | assert(!((r->type & ARM_CP_64BIT) && (r->opc2 || r->crn))); |
24 | +Aspeed SoC : the AST2400 integrating an ARM926EJ-S CPU (400MHz), the | 72 | /* op0 only exists in the AArch64 encodings */ |
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 | ||
106 | --- a/docs/system/target-arm.rst | ||
107 | +++ b/docs/system/target-arm.rst | ||
108 | @@ -XXX,XX +XXX,XX @@ undocumented; you can get a complete list by running | ||
109 | arm/realview | ||
110 | arm/versatile | ||
111 | arm/vexpress | ||
112 | + arm/aspeed | ||
113 | arm/musicpal | ||
114 | arm/nseries | ||
115 | arm/orangepi | ||
116 | -- | 73 | -- |
117 | 2.20.1 | 74 | 2.25.1 |
118 | 75 | ||
119 | 76 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | The ADC region size is 256B, split as: | 3 | Give this enum a name and use in ARMCPRegInfo and add_cpreg_to_hashtable. |
4 | - [0x00 - 0x4f] defined | 4 | Add the enumerator ARM_CP_SECSTATE_BOTH to clarify how 0 |
5 | - [0x50 - 0xff] reserved | 5 | is handled in define_one_arm_cp_reg_with_opaque. |
6 | 6 | ||
7 | All registers are 32-bit (thus when the datasheet mentions the | 7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
8 | last defined register is 0x4c, it means its address range is | 8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
9 | 0x4c .. 0x4f. | 9 | Message-id: 20220501055028.646596-10-richard.henderson@linaro.org |
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> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
22 | --- | 11 | --- |
23 | hw/adc/stm32f2xx_adc.c | 4 +++- | 12 | target/arm/cpregs.h | 7 ++++--- |
24 | 1 file changed, 3 insertions(+), 1 deletion(-) | 13 | target/arm/helper.c | 7 +++++-- |
14 | 2 files changed, 9 insertions(+), 5 deletions(-) | ||
25 | 15 | ||
26 | diff --git a/hw/adc/stm32f2xx_adc.c b/hw/adc/stm32f2xx_adc.c | 16 | diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h |
27 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
28 | --- a/hw/adc/stm32f2xx_adc.c | 18 | --- a/target/arm/cpregs.h |
29 | +++ b/hw/adc/stm32f2xx_adc.c | 19 | +++ b/target/arm/cpregs.h |
30 | @@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps stm32f2xx_adc_ops = { | 20 | @@ -XXX,XX +XXX,XX @@ typedef enum { |
31 | .read = stm32f2xx_adc_read, | 21 | * registered entry will only have one to identify whether the entry is secure |
32 | .write = stm32f2xx_adc_write, | 22 | * or non-secure. |
33 | .endianness = DEVICE_NATIVE_ENDIAN, | 23 | */ |
34 | + .impl.min_access_size = 4, | 24 | -enum { |
35 | + .impl.max_access_size = 4, | 25 | +typedef enum { |
36 | }; | 26 | + ARM_CP_SECSTATE_BOTH = 0, /* define one cpreg for each secstate */ |
37 | 27 | ARM_CP_SECSTATE_S = (1 << 0), /* bit[0]: Secure state register */ | |
38 | static const VMStateDescription vmstate_stm32f2xx_adc = { | 28 | ARM_CP_SECSTATE_NS = (1 << 1), /* bit[1]: Non-secure state register */ |
39 | @@ -XXX,XX +XXX,XX @@ static void stm32f2xx_adc_init(Object *obj) | 29 | -}; |
40 | sysbus_init_irq(SYS_BUS_DEVICE(obj), &s->irq); | 30 | +} CPSecureState; |
41 | 31 | ||
42 | memory_region_init_io(&s->mmio, obj, &stm32f2xx_adc_ops, s, | 32 | /* |
43 | - TYPE_STM32F2XX_ADC, 0xFF); | 33 | * Access rights: |
44 | + TYPE_STM32F2XX_ADC, 0x100); | 34 | @@ -XXX,XX +XXX,XX @@ struct ARMCPRegInfo { |
45 | sysbus_init_mmio(SYS_BUS_DEVICE(obj), &s->mmio); | 35 | /* Access rights: PL*_[RW] */ |
36 | CPAccessRights access; | ||
37 | /* Security state: ARM_CP_SECSTATE_* bits/values */ | ||
38 | - int secure; | ||
39 | + CPSecureState secure; | ||
40 | /* | ||
41 | * The opaque pointer passed to define_arm_cp_regs_with_opaque() when | ||
42 | * this register was defined: can be used to hand data through to the | ||
43 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
44 | index XXXXXXX..XXXXXXX 100644 | ||
45 | --- a/target/arm/helper.c | ||
46 | +++ b/target/arm/helper.c | ||
47 | @@ -XXX,XX +XXX,XX @@ CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp) | ||
46 | } | 48 | } |
47 | 49 | ||
50 | static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, | ||
51 | - void *opaque, CPState state, int secstate, | ||
52 | + void *opaque, CPState state, | ||
53 | + CPSecureState secstate, | ||
54 | int crm, int opc1, int opc2, | ||
55 | const char *name) | ||
56 | { | ||
57 | @@ -XXX,XX +XXX,XX @@ void define_one_arm_cp_reg_with_opaque(ARMCPU *cpu, | ||
58 | r->secure, crm, opc1, opc2, | ||
59 | r->name); | ||
60 | break; | ||
61 | - default: | ||
62 | + case ARM_CP_SECSTATE_BOTH: | ||
63 | name = g_strdup_printf("%s_S", r->name); | ||
64 | add_cpreg_to_hashtable(cpu, r, opaque, state, | ||
65 | ARM_CP_SECSTATE_S, | ||
66 | @@ -XXX,XX +XXX,XX @@ void define_one_arm_cp_reg_with_opaque(ARMCPU *cpu, | ||
67 | ARM_CP_SECSTATE_NS, | ||
68 | crm, opc1, opc2, r->name); | ||
69 | break; | ||
70 | + default: | ||
71 | + g_assert_not_reached(); | ||
72 | } | ||
73 | } else { | ||
74 | /* AArch64 registers get mapped to non-secure instance | ||
48 | -- | 75 | -- |
49 | 2.20.1 | 76 | 2.25.1 |
50 | |||
51 | diff view generated by jsdifflib |
1 | From: Paul Zimmerman <pauldzim@gmail.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Add a check for functional dwc-hsotg (dwc2) USB host emulation to | 3 | The new_key field is always non-zero -- drop the if. |
4 | the Raspi 2 acceptance test | ||
5 | 4 | ||
6 | Signed-off-by: Paul Zimmerman <pauldzim@gmail.com> | 5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
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 | Message-id: 20220501055028.646596-11-richard.henderson@linaro.org |
8 | [PMM: reinstated dropped PL3_RW mask] | ||
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 | target/arm/helper.c | 23 +++++++++++------------ |
12 | 1 file changed, 7 insertions(+), 2 deletions(-) | 12 | 1 file changed, 11 insertions(+), 12 deletions(-) |
13 | 13 | ||
14 | diff --git a/tests/acceptance/boot_linux_console.py b/tests/acceptance/boot_linux_console.py | 14 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
15 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/tests/acceptance/boot_linux_console.py | 16 | --- a/target/arm/helper.c |
17 | +++ b/tests/acceptance/boot_linux_console.py | 17 | +++ b/target/arm/helper.c |
18 | @@ -XXX,XX +XXX,XX @@ class BootLinuxConsole(LinuxKernelTest): | 18 | @@ -XXX,XX +XXX,XX @@ static void define_arm_vh_e2h_redirects_aliases(ARMCPU *cpu) |
19 | 19 | ||
20 | self.vm.set_console() | 20 | for (i = 0; i < ARRAY_SIZE(aliases); i++) { |
21 | kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE + | 21 | const struct E2HAlias *a = &aliases[i]; |
22 | - serial_kernel_cmdline[uart_id]) | 22 | - ARMCPRegInfo *src_reg, *dst_reg; |
23 | + serial_kernel_cmdline[uart_id] + | 23 | + ARMCPRegInfo *src_reg, *dst_reg, *new_reg; |
24 | + ' root=/dev/mmcblk0p2 rootwait ' + | 24 | + uint32_t *new_key; |
25 | + 'dwc_otg.fiq_fsm_enable=0') | 25 | + bool ok; |
26 | self.vm.add_args('-kernel', kernel_path, | 26 | |
27 | '-dtb', dtb_path, | 27 | if (a->feature && !a->feature(&cpu->isar)) { |
28 | - '-append', kernel_command_line) | 28 | continue; |
29 | + '-append', kernel_command_line, | 29 | @@ -XXX,XX +XXX,XX @@ static void define_arm_vh_e2h_redirects_aliases(ARMCPU *cpu) |
30 | + '-device', 'usb-kbd') | 30 | g_assert(src_reg->opaque == NULL); |
31 | self.vm.launch() | 31 | |
32 | console_pattern = 'Kernel command line: %s' % kernel_command_line | 32 | /* Create alias before redirection so we dup the right data. */ |
33 | self.wait_for_console_pattern(console_pattern) | 33 | - if (a->new_key) { |
34 | + console_pattern = 'Product: QEMU USB Keyboard' | 34 | - ARMCPRegInfo *new_reg = g_memdup(src_reg, sizeof(ARMCPRegInfo)); |
35 | + self.wait_for_console_pattern(console_pattern) | 35 | - uint32_t *new_key = g_memdup(&a->new_key, sizeof(uint32_t)); |
36 | 36 | - bool ok; | |
37 | def test_arm_raspi2_uart0(self): | 37 | + new_reg = g_memdup(src_reg, sizeof(ARMCPRegInfo)); |
38 | """ | 38 | + new_key = g_memdup(&a->new_key, sizeof(uint32_t)); |
39 | |||
40 | - new_reg->name = a->new_name; | ||
41 | - new_reg->type |= ARM_CP_ALIAS; | ||
42 | - /* Remove PL1/PL0 access, leaving PL2/PL3 R/W in place. */ | ||
43 | - new_reg->access &= PL2_RW | PL3_RW; | ||
44 | + new_reg->name = a->new_name; | ||
45 | + new_reg->type |= ARM_CP_ALIAS; | ||
46 | + /* Remove PL1/PL0 access, leaving PL2/PL3 R/W in place. */ | ||
47 | + new_reg->access &= PL2_RW | PL3_RW; | ||
48 | |||
49 | - ok = g_hash_table_insert(cpu->cp_regs, new_key, new_reg); | ||
50 | - g_assert(ok); | ||
51 | - } | ||
52 | + ok = g_hash_table_insert(cpu->cp_regs, new_key, new_reg); | ||
53 | + g_assert(ok); | ||
54 | |||
55 | src_reg->opaque = dst_reg; | ||
56 | src_reg->orig_readfn = src_reg->readfn ?: raw_read; | ||
39 | -- | 57 | -- |
40 | 2.20.1 | 58 | 2.25.1 |
41 | |||
42 | 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 | Cast the uint32_t key into a gpointer directly, which |
4 | operation at translate time. Use clear_tail_16 to zap the | 4 | allows us to avoid allocating storage for each key. |
5 | balance of the SVE register with the AdvSIMD write. | 5 | |
6 | Use g_hash_table_lookup when we already have a gpointer | ||
7 | (e.g. for callbacks like count_cpreg), or when using | ||
8 | get_arm_cp_reginfo would require casting away const. | ||
6 | 9 | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 10 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
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: 20220501055028.646596-12-richard.henderson@linaro.org | ||
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 | target/arm/cpu.c | 4 ++-- |
13 | target/arm/neon-dp.decode | 6 +- | 16 | target/arm/gdbstub.c | 2 +- |
14 | target/arm/crypto_helper.c | 99 +++++++++++++++++++++------------ | 17 | target/arm/helper.c | 41 ++++++++++++++++++----------------------- |
15 | target/arm/translate-a64.c | 29 ++++------ | 18 | 3 files changed, 21 insertions(+), 26 deletions(-) |
16 | target/arm/translate-neon.inc.c | 46 ++++----------- | ||
17 | 5 files changed, 93 insertions(+), 92 deletions(-) | ||
18 | 19 | ||
19 | diff --git a/target/arm/helper.h b/target/arm/helper.h | 20 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c |
20 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/target/arm/helper.h | 22 | --- a/target/arm/cpu.c |
22 | +++ b/target/arm/helper.h | 23 | +++ b/target/arm/cpu.c |
23 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_2(neon_qzip32, TCG_CALL_NO_RWG, void, ptr, ptr) | 24 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_initfn(Object *obj) |
24 | DEF_HELPER_FLAGS_4(crypto_aese, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | 25 | ARMCPU *cpu = ARM_CPU(obj); |
25 | DEF_HELPER_FLAGS_3(crypto_aesmc, TCG_CALL_NO_RWG, void, ptr, ptr, i32) | 26 | |
26 | 27 | cpu_set_cpustate_pointers(cpu); | |
27 | -DEF_HELPER_FLAGS_4(crypto_sha1_3reg, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | 28 | - cpu->cp_regs = g_hash_table_new_full(g_int_hash, g_int_equal, |
28 | +DEF_HELPER_FLAGS_4(crypto_sha1su0, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | 29 | - g_free, cpreg_hashtable_data_destroy); |
29 | +DEF_HELPER_FLAGS_4(crypto_sha1c, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | 30 | + cpu->cp_regs = g_hash_table_new_full(g_direct_hash, g_direct_equal, |
30 | +DEF_HELPER_FLAGS_4(crypto_sha1p, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | 31 | + NULL, cpreg_hashtable_data_destroy); |
31 | +DEF_HELPER_FLAGS_4(crypto_sha1m, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | 32 | |
32 | DEF_HELPER_FLAGS_3(crypto_sha1h, TCG_CALL_NO_RWG, void, ptr, ptr, i32) | 33 | QLIST_INIT(&cpu->pre_el_change_hooks); |
33 | DEF_HELPER_FLAGS_3(crypto_sha1su1, TCG_CALL_NO_RWG, void, ptr, ptr, i32) | 34 | QLIST_INIT(&cpu->el_change_hooks); |
34 | 35 | diff --git a/target/arm/gdbstub.c b/target/arm/gdbstub.c | |
35 | diff --git a/target/arm/neon-dp.decode b/target/arm/neon-dp.decode | ||
36 | index XXXXXXX..XXXXXXX 100644 | 36 | index XXXXXXX..XXXXXXX 100644 |
37 | --- a/target/arm/neon-dp.decode | 37 | --- a/target/arm/gdbstub.c |
38 | +++ b/target/arm/neon-dp.decode | 38 | +++ b/target/arm/gdbstub.c |
39 | @@ -XXX,XX +XXX,XX @@ VQRDMLAH_3s 1111 001 1 0 . .. .... .... 1011 ... 1 .... @3same | 39 | @@ -XXX,XX +XXX,XX @@ static void arm_gen_one_xml_sysreg_tag(GString *s, DynamicGDBXMLInfo *dyn_xml, |
40 | @3same_crypto .... .... .... .... .... .... .... .... \ | 40 | static void arm_register_sysreg_for_xml(gpointer key, gpointer value, |
41 | &3same vm=%vm_dp vn=%vn_dp vd=%vd_dp size=0 q=1 | 41 | gpointer p) |
42 | 42 | { | |
43 | -SHA1_3s 1111 001 0 0 . optype:2 .... .... 1100 . 1 . 0 .... \ | 43 | - uint32_t ri_key = *(uint32_t *)key; |
44 | - vm=%vm_dp vn=%vn_dp vd=%vd_dp | 44 | + uint32_t ri_key = (uintptr_t)key; |
45 | +SHA1C_3s 1111 001 0 0 . 00 .... .... 1100 . 1 . 0 .... @3same_crypto | 45 | ARMCPRegInfo *ri = value; |
46 | +SHA1P_3s 1111 001 0 0 . 01 .... .... 1100 . 1 . 0 .... @3same_crypto | 46 | RegisterSysregXmlParam *param = (RegisterSysregXmlParam *)p; |
47 | +SHA1M_3s 1111 001 0 0 . 10 .... .... 1100 . 1 . 0 .... @3same_crypto | 47 | GString *s = param->s; |
48 | +SHA1SU0_3s 1111 001 0 0 . 11 .... .... 1100 . 1 . 0 .... @3same_crypto | 48 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
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 | 49 | index XXXXXXX..XXXXXXX 100644 |
54 | --- a/target/arm/crypto_helper.c | 50 | --- a/target/arm/helper.c |
55 | +++ b/target/arm/crypto_helper.c | 51 | +++ b/target/arm/helper.c |
56 | @@ -XXX,XX +XXX,XX @@ union CRYPTO_STATE { | 52 | @@ -XXX,XX +XXX,XX @@ bool write_list_to_cpustate(ARMCPU *cpu) |
57 | }; | 53 | static void add_cpreg_to_list(gpointer key, gpointer opaque) |
58 | 54 | { | |
59 | #ifdef HOST_WORDS_BIGENDIAN | 55 | ARMCPU *cpu = opaque; |
60 | -#define CR_ST_BYTE(state, i) (state.bytes[(15 - (i)) ^ 8]) | 56 | - uint64_t regidx; |
61 | -#define CR_ST_WORD(state, i) (state.words[(3 - (i)) ^ 2]) | 57 | - const ARMCPRegInfo *ri; |
62 | +#define CR_ST_BYTE(state, i) ((state).bytes[(15 - (i)) ^ 8]) | 58 | - |
63 | +#define CR_ST_WORD(state, i) ((state).words[(3 - (i)) ^ 2]) | 59 | - regidx = *(uint32_t *)key; |
64 | #else | 60 | - ri = get_arm_cp_reginfo(cpu->cp_regs, regidx); |
65 | -#define CR_ST_BYTE(state, i) (state.bytes[i]) | 61 | + uint32_t regidx = (uintptr_t)key; |
66 | -#define CR_ST_WORD(state, i) (state.words[i]) | 62 | + const ARMCPRegInfo *ri = get_arm_cp_reginfo(cpu->cp_regs, regidx); |
67 | +#define CR_ST_BYTE(state, i) ((state).bytes[i]) | 63 | |
68 | +#define CR_ST_WORD(state, i) ((state).words[i]) | 64 | if (!(ri->type & (ARM_CP_NO_RAW|ARM_CP_ALIAS))) { |
69 | #endif | 65 | cpu->cpreg_indexes[cpu->cpreg_array_len] = cpreg_to_kvm_id(regidx); |
70 | 66 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_list(gpointer key, gpointer opaque) | |
71 | /* | 67 | static void count_cpreg(gpointer key, gpointer opaque) |
72 | @@ -XXX,XX +XXX,XX @@ static uint32_t maj(uint32_t x, uint32_t y, uint32_t z) | 68 | { |
73 | return (x & y) | ((x | y) & z); | 69 | ARMCPU *cpu = opaque; |
70 | - uint64_t regidx; | ||
71 | const ARMCPRegInfo *ri; | ||
72 | |||
73 | - regidx = *(uint32_t *)key; | ||
74 | - ri = get_arm_cp_reginfo(cpu->cp_regs, regidx); | ||
75 | + ri = g_hash_table_lookup(cpu->cp_regs, key); | ||
76 | |||
77 | if (!(ri->type & (ARM_CP_NO_RAW|ARM_CP_ALIAS))) { | ||
78 | cpu->cpreg_array_len++; | ||
79 | @@ -XXX,XX +XXX,XX @@ static void count_cpreg(gpointer key, gpointer opaque) | ||
80 | |||
81 | static gint cpreg_key_compare(gconstpointer a, gconstpointer b) | ||
82 | { | ||
83 | - uint64_t aidx = cpreg_to_kvm_id(*(uint32_t *)a); | ||
84 | - uint64_t bidx = cpreg_to_kvm_id(*(uint32_t *)b); | ||
85 | + uint64_t aidx = cpreg_to_kvm_id((uintptr_t)a); | ||
86 | + uint64_t bidx = cpreg_to_kvm_id((uintptr_t)b); | ||
87 | |||
88 | if (aidx > bidx) { | ||
89 | return 1; | ||
90 | @@ -XXX,XX +XXX,XX @@ static void define_arm_vh_e2h_redirects_aliases(ARMCPU *cpu) | ||
91 | for (i = 0; i < ARRAY_SIZE(aliases); i++) { | ||
92 | const struct E2HAlias *a = &aliases[i]; | ||
93 | ARMCPRegInfo *src_reg, *dst_reg, *new_reg; | ||
94 | - uint32_t *new_key; | ||
95 | bool ok; | ||
96 | |||
97 | if (a->feature && !a->feature(&cpu->isar)) { | ||
98 | continue; | ||
99 | } | ||
100 | |||
101 | - src_reg = g_hash_table_lookup(cpu->cp_regs, &a->src_key); | ||
102 | - dst_reg = g_hash_table_lookup(cpu->cp_regs, &a->dst_key); | ||
103 | + src_reg = g_hash_table_lookup(cpu->cp_regs, | ||
104 | + (gpointer)(uintptr_t)a->src_key); | ||
105 | + dst_reg = g_hash_table_lookup(cpu->cp_regs, | ||
106 | + (gpointer)(uintptr_t)a->dst_key); | ||
107 | g_assert(src_reg != NULL); | ||
108 | g_assert(dst_reg != NULL); | ||
109 | |||
110 | @@ -XXX,XX +XXX,XX @@ static void define_arm_vh_e2h_redirects_aliases(ARMCPU *cpu) | ||
111 | |||
112 | /* Create alias before redirection so we dup the right data. */ | ||
113 | new_reg = g_memdup(src_reg, sizeof(ARMCPRegInfo)); | ||
114 | - new_key = g_memdup(&a->new_key, sizeof(uint32_t)); | ||
115 | |||
116 | new_reg->name = a->new_name; | ||
117 | new_reg->type |= ARM_CP_ALIAS; | ||
118 | /* Remove PL1/PL0 access, leaving PL2/PL3 R/W in place. */ | ||
119 | new_reg->access &= PL2_RW | PL3_RW; | ||
120 | |||
121 | - ok = g_hash_table_insert(cpu->cp_regs, new_key, new_reg); | ||
122 | + ok = g_hash_table_insert(cpu->cp_regs, | ||
123 | + (gpointer)(uintptr_t)a->new_key, new_reg); | ||
124 | g_assert(ok); | ||
125 | |||
126 | src_reg->opaque = dst_reg; | ||
127 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, | ||
128 | /* Private utility function for define_one_arm_cp_reg_with_opaque(): | ||
129 | * add a single reginfo struct to the hash table. | ||
130 | */ | ||
131 | - uint32_t *key = g_new(uint32_t, 1); | ||
132 | + uint32_t key; | ||
133 | ARMCPRegInfo *r2 = g_memdup(r, sizeof(ARMCPRegInfo)); | ||
134 | int is64 = (r->type & ARM_CP_64BIT) ? 1 : 0; | ||
135 | int ns = (secstate & ARM_CP_SECSTATE_NS) ? 1 : 0; | ||
136 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, | ||
137 | if (r->cp == 0 || r->state == ARM_CP_STATE_BOTH) { | ||
138 | r2->cp = CP_REG_ARM64_SYSREG_CP; | ||
139 | } | ||
140 | - *key = ENCODE_AA64_CP_REG(r2->cp, r2->crn, crm, | ||
141 | - r2->opc0, opc1, opc2); | ||
142 | + key = ENCODE_AA64_CP_REG(r2->cp, r2->crn, crm, | ||
143 | + r2->opc0, opc1, opc2); | ||
144 | } else { | ||
145 | - *key = ENCODE_CP_REG(r2->cp, is64, ns, r2->crn, crm, opc1, opc2); | ||
146 | + key = ENCODE_CP_REG(r2->cp, is64, ns, r2->crn, crm, opc1, opc2); | ||
147 | } | ||
148 | if (opaque) { | ||
149 | r2->opaque = opaque; | ||
150 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, | ||
151 | * requested. | ||
152 | */ | ||
153 | if (!(r->type & ARM_CP_OVERRIDE)) { | ||
154 | - ARMCPRegInfo *oldreg; | ||
155 | - oldreg = g_hash_table_lookup(cpu->cp_regs, key); | ||
156 | + const ARMCPRegInfo *oldreg = get_arm_cp_reginfo(cpu->cp_regs, key); | ||
157 | if (oldreg && !(oldreg->type & ARM_CP_OVERRIDE)) { | ||
158 | fprintf(stderr, "Register redefined: cp=%d %d bit " | ||
159 | "crn=%d crm=%d opc1=%d opc2=%d, " | ||
160 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, | ||
161 | g_assert_not_reached(); | ||
162 | } | ||
163 | } | ||
164 | - g_hash_table_insert(cpu->cp_regs, key, r2); | ||
165 | + g_hash_table_insert(cpu->cp_regs, (gpointer)(uintptr_t)key, r2); | ||
74 | } | 166 | } |
75 | 167 | ||
76 | -void HELPER(crypto_sha1_3reg)(void *vd, void *vn, void *vm, uint32_t op) | 168 | |
77 | +void HELPER(crypto_sha1su0)(void *vd, void *vn, void *vm, uint32_t desc) | 169 | @@ -XXX,XX +XXX,XX @@ void modify_arm_cp_regs_with_len(ARMCPRegInfo *regs, size_t regs_len, |
78 | +{ | 170 | |
79 | + uint64_t *d = vd, *n = vn, *m = vm; | 171 | const ARMCPRegInfo *get_arm_cp_reginfo(GHashTable *cpregs, uint32_t encoded_cp) |
80 | + uint64_t d0, d1; | ||
81 | + | ||
82 | + d0 = d[1] ^ d[0] ^ m[0]; | ||
83 | + d1 = n[0] ^ d[1] ^ m[1]; | ||
84 | + d[0] = d0; | ||
85 | + d[1] = d1; | ||
86 | + | ||
87 | + clear_tail_16(vd, desc); | ||
88 | +} | ||
89 | + | ||
90 | +static inline void crypto_sha1_3reg(uint64_t *rd, uint64_t *rn, | ||
91 | + uint64_t *rm, uint32_t desc, | ||
92 | + uint32_t (*fn)(union CRYPTO_STATE *d)) | ||
93 | { | 172 | { |
94 | - uint64_t *rd = vd; | 173 | - return g_hash_table_lookup(cpregs, &encoded_cp); |
95 | - uint64_t *rn = vn; | 174 | + return g_hash_table_lookup(cpregs, (gpointer)(uintptr_t)encoded_cp); |
96 | - uint64_t *rm = vm; | ||
97 | union CRYPTO_STATE d = { .l = { rd[0], rd[1] } }; | ||
98 | union CRYPTO_STATE n = { .l = { rn[0], rn[1] } }; | ||
99 | union CRYPTO_STATE m = { .l = { rm[0], rm[1] } }; | ||
100 | + int i; | ||
101 | |||
102 | - if (op == 3) { /* sha1su0 */ | ||
103 | - d.l[0] ^= d.l[1] ^ m.l[0]; | ||
104 | - d.l[1] ^= n.l[0] ^ m.l[1]; | ||
105 | - } else { | ||
106 | - int i; | ||
107 | + for (i = 0; i < 4; i++) { | ||
108 | + uint32_t t = fn(&d); | ||
109 | |||
110 | - for (i = 0; i < 4; i++) { | ||
111 | - uint32_t t; | ||
112 | + t += rol32(CR_ST_WORD(d, 0), 5) + CR_ST_WORD(n, 0) | ||
113 | + + CR_ST_WORD(m, i); | ||
114 | |||
115 | - switch (op) { | ||
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 | } | 175 | } |
178 | 176 | ||
179 | void HELPER(crypto_sha1h)(void *vd, void *vm, uint32_t desc) | 177 | void arm_cp_write_ignore(CPUARMState *env, const ARMCPRegInfo *ri, |
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 | -- | 178 | -- |
290 | 2.20.1 | 179 | 2.25.1 |
291 | |||
292 | diff view generated by jsdifflib |
1 | Convert the remaining Neon narrowing shifts to decodetree: | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | * VQSHRN | ||
3 | * VQRSHRN | ||
4 | 2 | ||
3 | Simplify freeing cp_regs hash table entries by using a single | ||
4 | allocation for the entire value. | ||
5 | |||
6 | This fixes a theoretical bug if we were to ever free the entire | ||
7 | hash table, because we've been installing string literal constants | ||
8 | into the cpreg structure in define_arm_vh_e2h_redirects_aliases. | ||
9 | However, at present we only free entries created for AArch32 | ||
10 | wildcard cpregs which get overwritten by more specific cpregs, | ||
11 | so this bug is never exposed. | ||
12 | |||
13 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
14 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
15 | Message-id: 20220501055028.646596-13-richard.henderson@linaro.org | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20200522145520.6778-7-peter.maydell@linaro.org | ||
8 | --- | 17 | --- |
9 | target/arm/neon-dp.decode | 20 ++++++ | 18 | target/arm/cpu.c | 16 +--------------- |
10 | target/arm/translate-neon.inc.c | 15 +++++ | 19 | target/arm/helper.c | 10 ++++++++-- |
11 | target/arm/translate.c | 110 +------------------------------- | 20 | 2 files changed, 9 insertions(+), 17 deletions(-) |
12 | 3 files changed, 37 insertions(+), 108 deletions(-) | ||
13 | 21 | ||
14 | diff --git a/target/arm/neon-dp.decode b/target/arm/neon-dp.decode | 22 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c |
15 | index XXXXXXX..XXXXXXX 100644 | 23 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/neon-dp.decode | 24 | --- a/target/arm/cpu.c |
17 | +++ b/target/arm/neon-dp.decode | 25 | +++ b/target/arm/cpu.c |
18 | @@ -XXX,XX +XXX,XX @@ VQSHRUN_16_2sh 1111 001 1 1 . ...... .... 1000 . 0 . 1 .... @2reg_shrn_h | 26 | @@ -XXX,XX +XXX,XX @@ uint64_t arm_cpu_mp_affinity(int idx, uint8_t clustersz) |
19 | VQRSHRUN_64_2sh 1111 001 1 1 . ...... .... 1000 . 1 . 1 .... @2reg_shrn_d | 27 | return (Aff1 << ARM_AFF1_SHIFT) | Aff0; |
20 | VQRSHRUN_32_2sh 1111 001 1 1 . ...... .... 1000 . 1 . 1 .... @2reg_shrn_s | ||
21 | VQRSHRUN_16_2sh 1111 001 1 1 . ...... .... 1000 . 1 . 1 .... @2reg_shrn_h | ||
22 | + | ||
23 | +# VQSHRN with signed input | ||
24 | +VQSHRN_S64_2sh 1111 001 0 1 . ...... .... 1001 . 0 . 1 .... @2reg_shrn_d | ||
25 | +VQSHRN_S32_2sh 1111 001 0 1 . ...... .... 1001 . 0 . 1 .... @2reg_shrn_s | ||
26 | +VQSHRN_S16_2sh 1111 001 0 1 . ...... .... 1001 . 0 . 1 .... @2reg_shrn_h | ||
27 | + | ||
28 | +# VQRSHRN with signed input | ||
29 | +VQRSHRN_S64_2sh 1111 001 0 1 . ...... .... 1001 . 1 . 1 .... @2reg_shrn_d | ||
30 | +VQRSHRN_S32_2sh 1111 001 0 1 . ...... .... 1001 . 1 . 1 .... @2reg_shrn_s | ||
31 | +VQRSHRN_S16_2sh 1111 001 0 1 . ...... .... 1001 . 1 . 1 .... @2reg_shrn_h | ||
32 | + | ||
33 | +# VQSHRN with unsigned input | ||
34 | +VQSHRN_U64_2sh 1111 001 1 1 . ...... .... 1001 . 0 . 1 .... @2reg_shrn_d | ||
35 | +VQSHRN_U32_2sh 1111 001 1 1 . ...... .... 1001 . 0 . 1 .... @2reg_shrn_s | ||
36 | +VQSHRN_U16_2sh 1111 001 1 1 . ...... .... 1001 . 0 . 1 .... @2reg_shrn_h | ||
37 | + | ||
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 | ||
44 | --- a/target/arm/translate-neon.inc.c | ||
45 | +++ b/target/arm/translate-neon.inc.c | ||
46 | @@ -XXX,XX +XXX,XX @@ DO_2SN_32(VQSHRUN_16, gen_helper_neon_shl_s16, gen_helper_neon_unarrow_sat8) | ||
47 | DO_2SN_64(VQRSHRUN_64, gen_helper_neon_rshl_s64, gen_helper_neon_unarrow_sat32) | ||
48 | DO_2SN_32(VQRSHRUN_32, gen_helper_neon_rshl_s32, gen_helper_neon_unarrow_sat16) | ||
49 | DO_2SN_32(VQRSHRUN_16, gen_helper_neon_rshl_s16, gen_helper_neon_unarrow_sat8) | ||
50 | +DO_2SN_64(VQSHRN_S64, gen_sshl_i64, gen_helper_neon_narrow_sat_s32) | ||
51 | +DO_2SN_32(VQSHRN_S32, gen_sshl_i32, gen_helper_neon_narrow_sat_s16) | ||
52 | +DO_2SN_32(VQSHRN_S16, gen_helper_neon_shl_s16, gen_helper_neon_narrow_sat_s8) | ||
53 | + | ||
54 | +DO_2SN_64(VQRSHRN_S64, gen_helper_neon_rshl_s64, gen_helper_neon_narrow_sat_s32) | ||
55 | +DO_2SN_32(VQRSHRN_S32, gen_helper_neon_rshl_s32, gen_helper_neon_narrow_sat_s16) | ||
56 | +DO_2SN_32(VQRSHRN_S16, gen_helper_neon_rshl_s16, gen_helper_neon_narrow_sat_s8) | ||
57 | + | ||
58 | +DO_2SN_64(VQSHRN_U64, gen_ushl_i64, gen_helper_neon_narrow_sat_u32) | ||
59 | +DO_2SN_32(VQSHRN_U32, gen_ushl_i32, gen_helper_neon_narrow_sat_u16) | ||
60 | +DO_2SN_32(VQSHRN_U16, gen_helper_neon_shl_u16, gen_helper_neon_narrow_sat_u8) | ||
61 | + | ||
62 | +DO_2SN_64(VQRSHRN_U64, gen_helper_neon_rshl_u64, gen_helper_neon_narrow_sat_u32) | ||
63 | +DO_2SN_32(VQRSHRN_U32, gen_helper_neon_rshl_u32, gen_helper_neon_narrow_sat_u16) | ||
64 | +DO_2SN_32(VQRSHRN_U16, gen_helper_neon_rshl_u16, gen_helper_neon_narrow_sat_u8) | ||
65 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
66 | index XXXXXXX..XXXXXXX 100644 | ||
67 | --- a/target/arm/translate.c | ||
68 | +++ b/target/arm/translate.c | ||
69 | @@ -XXX,XX +XXX,XX @@ static inline void gen_neon_unarrow_sats(int size, TCGv_i32 dest, TCGv_i64 src) | ||
70 | } | ||
71 | } | 28 | } |
72 | 29 | ||
73 | -static inline void gen_neon_shift_narrow(int size, TCGv_i32 var, TCGv_i32 shift, | 30 | -static void cpreg_hashtable_data_destroy(gpointer data) |
74 | - int q, int u) | ||
75 | -{ | 31 | -{ |
76 | - if (q) { | 32 | - /* |
77 | - if (u) { | 33 | - * Destroy function for cpu->cp_regs hashtable data entries. |
78 | - switch (size) { | 34 | - * We must free the name string because it was g_strdup()ed in |
79 | - case 1: gen_helper_neon_rshl_u16(var, var, shift); break; | 35 | - * add_cpreg_to_hashtable(). It's OK to cast away the 'const' |
80 | - case 2: gen_helper_neon_rshl_u32(var, var, shift); break; | 36 | - * from r->name because we know we definitely allocated it. |
81 | - default: abort(); | 37 | - */ |
82 | - } | 38 | - ARMCPRegInfo *r = data; |
83 | - } else { | 39 | - |
84 | - switch (size) { | 40 | - g_free((void *)r->name); |
85 | - case 1: gen_helper_neon_rshl_s16(var, var, shift); break; | 41 | - g_free(r); |
86 | - case 2: gen_helper_neon_rshl_s32(var, var, shift); break; | ||
87 | - default: abort(); | ||
88 | - } | ||
89 | - } | ||
90 | - } else { | ||
91 | - if (u) { | ||
92 | - switch (size) { | ||
93 | - case 1: gen_helper_neon_shl_u16(var, var, shift); break; | ||
94 | - case 2: gen_ushl_i32(var, var, shift); break; | ||
95 | - default: abort(); | ||
96 | - } | ||
97 | - } else { | ||
98 | - switch (size) { | ||
99 | - case 1: gen_helper_neon_shl_s16(var, var, shift); break; | ||
100 | - case 2: gen_sshl_i32(var, var, shift); break; | ||
101 | - default: abort(); | ||
102 | - } | ||
103 | - } | ||
104 | - } | ||
105 | -} | 42 | -} |
106 | - | 43 | - |
107 | static inline void gen_neon_widen(TCGv_i64 dest, TCGv_i32 src, int size, int u) | 44 | static void arm_cpu_initfn(Object *obj) |
108 | { | 45 | { |
109 | if (u) { | 46 | ARMCPU *cpu = ARM_CPU(obj); |
110 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | 47 | |
111 | case 6: /* VQSHLU */ | 48 | cpu_set_cpustate_pointers(cpu); |
112 | case 7: /* VQSHL */ | 49 | cpu->cp_regs = g_hash_table_new_full(g_direct_hash, g_direct_equal, |
113 | case 8: /* VSHRN, VRSHRN, VQSHRUN, VQRSHRUN */ | 50 | - NULL, cpreg_hashtable_data_destroy); |
114 | + case 9: /* VQSHRN, VQRSHRN */ | 51 | + NULL, g_free); |
115 | return 1; /* handled by decodetree */ | 52 | |
116 | default: | 53 | QLIST_INIT(&cpu->pre_el_change_hooks); |
117 | break; | 54 | QLIST_INIT(&cpu->el_change_hooks); |
118 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | 55 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
119 | size--; | 56 | index XXXXXXX..XXXXXXX 100644 |
120 | } | 57 | --- a/target/arm/helper.c |
121 | shift = (insn >> 16) & ((1 << (3 + size)) - 1); | 58 | +++ b/target/arm/helper.c |
122 | - if (op < 10) { | 59 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, |
123 | - /* Shift by immediate and narrow: | 60 | * add a single reginfo struct to the hash table. |
124 | - VSHRN, VRSHRN, VQSHRN, VQRSHRN. */ | 61 | */ |
125 | - int input_unsigned = (op == 8) ? !u : u; | 62 | uint32_t key; |
126 | - if (rm & 1) { | 63 | - ARMCPRegInfo *r2 = g_memdup(r, sizeof(ARMCPRegInfo)); |
127 | - return 1; | 64 | + ARMCPRegInfo *r2; |
128 | - } | 65 | int is64 = (r->type & ARM_CP_64BIT) ? 1 : 0; |
129 | - shift = shift - (1 << (size + 3)); | 66 | int ns = (secstate & ARM_CP_SECSTATE_NS) ? 1 : 0; |
130 | - size++; | 67 | + size_t name_len; |
131 | - if (size == 3) { | 68 | + |
132 | - tmp64 = tcg_const_i64(shift); | 69 | + /* Combine cpreg and name into one allocation. */ |
133 | - neon_load_reg64(cpu_V0, rm); | 70 | + name_len = strlen(name) + 1; |
134 | - neon_load_reg64(cpu_V1, rm + 1); | 71 | + r2 = g_malloc(sizeof(*r2) + name_len); |
135 | - for (pass = 0; pass < 2; pass++) { | 72 | + *r2 = *r; |
136 | - TCGv_i64 in; | 73 | + r2->name = memcpy(r2 + 1, name, name_len); |
137 | - if (pass == 0) { | 74 | |
138 | - in = cpu_V0; | 75 | - r2->name = g_strdup(name); |
139 | - } else { | 76 | /* Reset the secure state to the specific incoming state. This is |
140 | - in = cpu_V1; | 77 | * necessary as the register may have been defined with both states. |
141 | - } | 78 | */ |
142 | - if (q) { | ||
143 | - if (input_unsigned) { | ||
144 | - gen_helper_neon_rshl_u64(cpu_V0, in, tmp64); | ||
145 | - } else { | ||
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 | -- | 79 | -- |
201 | 2.20.1 | 80 | 2.25.1 |
202 | |||
203 | diff view generated by jsdifflib |
1 | From: Paul Zimmerman <pauldzim@gmail.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Add the dwc-hsotg (dwc2) USB host controller emulation code. | 3 | Move the computation of key to the top of the function. |
4 | Based on hw/usb/hcd-ehci.c and hw/usb/hcd-ohci.c. | 4 | Hoist the resolution of cp as well, as an input to the |
5 | computation of key. | ||
5 | 6 | ||
6 | Note that to use this with the dwc-otg driver in the Raspbian | 7 | This will be required by a subsequent patch. |
7 | kernel, you must pass the option "dwc_otg.fiq_fsm_enable=0" on | ||
8 | the kernel command line. | ||
9 | 8 | ||
10 | Emulation of slave mode and of descriptor-DMA mode has not been | 9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
11 | implemented yet. These modes are seldom used. | ||
12 | |||
13 | I have used some on-line sources of information while developing | ||
14 | this emulation, including: | ||
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> | 10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
11 | Message-id: 20220501055028.646596-14-richard.henderson@linaro.org | ||
30 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
31 | --- | 13 | --- |
32 | hw/usb/hcd-dwc2.c | 1417 ++++++++++++++++++++++++++++++++++++++++++ | 14 | target/arm/helper.c | 49 +++++++++++++++++++++++++-------------------- |
33 | hw/usb/Kconfig | 5 + | 15 | 1 file changed, 27 insertions(+), 22 deletions(-) |
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 | 16 | ||
39 | diff --git a/hw/usb/hcd-dwc2.c b/hw/usb/hcd-dwc2.c | 17 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
40 | new file mode 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
41 | index XXXXXXX..XXXXXXX | 19 | --- a/target/arm/helper.c |
42 | --- /dev/null | 20 | +++ b/target/arm/helper.c |
43 | +++ b/hw/usb/hcd-dwc2.c | 21 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, |
44 | @@ -XXX,XX +XXX,XX @@ | 22 | ARMCPRegInfo *r2; |
45 | +/* | 23 | int is64 = (r->type & ARM_CP_64BIT) ? 1 : 0; |
46 | + * dwc-hsotg (dwc2) USB host controller emulation | 24 | int ns = (secstate & ARM_CP_SECSTATE_NS) ? 1 : 0; |
47 | + * | 25 | + int cp = r->cp; |
48 | + * Based on hw/usb/hcd-ehci.c and hw/usb/hcd-ohci.c | 26 | size_t name_len; |
49 | + * | 27 | |
50 | + * Note that to use this emulation with the dwc-otg driver in the | 28 | + switch (state) { |
51 | + * Raspbian kernel, you must pass the option "dwc_otg.fiq_fsm_enable=0" | 29 | + case ARM_CP_STATE_AA32: |
52 | + * on the kernel command line. | 30 | + /* We assume it is a cp15 register if the .cp field is left unset. */ |
53 | + * | 31 | + if (cp == 0 && r->state == ARM_CP_STATE_BOTH) { |
54 | + * Some useful documentation used to develop this emulation can be | 32 | + cp = 15; |
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 | + | ||
78 | +#include "qemu/osdep.h" | ||
79 | +#include "qemu/units.h" | ||
80 | +#include "qapi/error.h" | ||
81 | +#include "hw/usb/dwc2-regs.h" | ||
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 | + } | 33 | + } |
152 | + } | 34 | + key = ENCODE_CP_REG(cp, is64, ns, r->crn, crm, opc1, opc2); |
153 | +} | 35 | + break; |
154 | + | 36 | + case ARM_CP_STATE_AA64: |
155 | +static inline void dwc2_lower_host_irq(DWC2State *s, uint32_t host_intr) | 37 | + /* |
156 | +{ | 38 | + * To allow abbreviation of ARMCPRegInfo definitions, we treat |
157 | + if (s->haint & host_intr) { | 39 | + * cp == 0 as equivalent to the value for "standard guest-visible |
158 | + s->haint &= ~host_intr; | 40 | + * sysreg". STATE_BOTH definitions are also always "standard sysreg" |
159 | + trace_usb_dwc2_lower_host_irq(host_intr); | 41 | + * in their AArch64 view (the .cp value may be non-zero for the |
160 | + if (!(s->haint & s->haintmsk)) { | 42 | + * benefit of the AArch32 view). |
161 | + dwc2_lower_global_irq(s, GINTSTS_HCHINT); | 43 | + */ |
44 | + if (cp == 0 || r->state == ARM_CP_STATE_BOTH) { | ||
45 | + cp = CP_REG_ARM64_SYSREG_CP; | ||
162 | + } | 46 | + } |
163 | + } | 47 | + key = ENCODE_AA64_CP_REG(cp, r->crn, crm, r->opc0, opc1, opc2); |
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 | + } | ||
242 | + | ||
243 | + trace_usb_dwc2_device_not_found(); | ||
244 | + return NULL; | ||
245 | +} | ||
246 | + | ||
247 | +static const char *pstatus[] = { | ||
248 | + "USB_RET_SUCCESS", "USB_RET_NODEV", "USB_RET_NAK", "USB_RET_STALL", | ||
249 | + "USB_RET_BABBLE", "USB_RET_IOERROR", "USB_RET_ASYNC", | ||
250 | + "USB_RET_ADD_TO_QUEUE", "USB_RET_REMOVE_FROM_QUEUE" | ||
251 | +}; | ||
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 | + } | ||
297 | + | ||
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; | 48 | + break; |
1106 | + default: | 49 | + default: |
1107 | + g_assert_not_reached(); | 50 | + g_assert_not_reached(); |
1108 | + } | 51 | + } |
1109 | + | 52 | + |
1110 | + return val; | 53 | /* Combine cpreg and name into one allocation. */ |
1111 | +} | 54 | name_len = strlen(name) + 1; |
1112 | + | 55 | r2 = g_malloc(sizeof(*r2) + name_len); |
1113 | +static void dwc2_hsotg_write(void *ptr, hwaddr addr, uint64_t val, | 56 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, |
1114 | + unsigned size) | 57 | } |
1115 | +{ | 58 | |
1116 | + switch (addr) { | 59 | if (r->state == ARM_CP_STATE_BOTH) { |
1117 | + case HSOTG_REG(0x000) ... HSOTG_REG(0x0fc): | 60 | - /* We assume it is a cp15 register if the .cp field is left unset. |
1118 | + dwc2_glbreg_write(ptr, addr, (addr - HSOTG_REG(0x000)) >> 2, val, size); | 61 | - */ |
1119 | + break; | 62 | - if (r2->cp == 0) { |
1120 | + case HSOTG_REG(0x100): | 63 | - r2->cp = 15; |
1121 | + dwc2_fszreg_write(ptr, addr, (addr - HSOTG_REG(0x100)) >> 2, val, size); | 64 | - } |
1122 | + break; | 65 | - |
1123 | + case HSOTG_REG(0x104) ... HSOTG_REG(0x3fc): | 66 | #if HOST_BIG_ENDIAN |
1124 | + /* Gadget-mode registers, do nothing for now */ | 67 | if (r2->fieldoffset) { |
1125 | + break; | 68 | r2->fieldoffset += sizeof(uint32_t); |
1126 | + case HSOTG_REG(0x400) ... HSOTG_REG(0x4fc): | 69 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, |
1127 | + dwc2_hreg0_write(ptr, addr, (addr - HSOTG_REG(0x400)) >> 2, val, size); | 70 | #endif |
1128 | + break; | 71 | } |
1129 | + case HSOTG_REG(0x500) ... HSOTG_REG(0x7fc): | 72 | } |
1130 | + dwc2_hreg1_write(ptr, addr, (addr - HSOTG_REG(0x500)) >> 2, val, size); | 73 | - if (state == ARM_CP_STATE_AA64) { |
1131 | + break; | 74 | - /* To allow abbreviation of ARMCPRegInfo |
1132 | + case HSOTG_REG(0x800) ... HSOTG_REG(0xdfc): | 75 | - * definitions, we treat cp == 0 as equivalent to |
1133 | + /* Gadget-mode registers, do nothing for now */ | 76 | - * the value for "standard guest-visible sysreg". |
1134 | + break; | 77 | - * STATE_BOTH definitions are also always "standard |
1135 | + case HSOTG_REG(0xe00) ... HSOTG_REG(0xffc): | 78 | - * sysreg" in their AArch64 view (the .cp value may |
1136 | + dwc2_pcgreg_write(ptr, addr, (addr - HSOTG_REG(0xe00)) >> 2, val, size); | 79 | - * be non-zero for the benefit of the AArch32 view). |
1137 | + break; | 80 | - */ |
1138 | + default: | 81 | - if (r->cp == 0 || r->state == ARM_CP_STATE_BOTH) { |
1139 | + g_assert_not_reached(); | 82 | - r2->cp = CP_REG_ARM64_SYSREG_CP; |
1140 | + } | 83 | - } |
1141 | +} | 84 | - key = ENCODE_AA64_CP_REG(r2->cp, r2->crn, crm, |
1142 | + | 85 | - r2->opc0, opc1, opc2); |
1143 | +static const MemoryRegionOps dwc2_mmio_hsotg_ops = { | 86 | - } else { |
1144 | + .read = dwc2_hsotg_read, | 87 | - key = ENCODE_CP_REG(r2->cp, is64, ns, r2->crn, crm, opc1, opc2); |
1145 | + .write = dwc2_hsotg_write, | 88 | - } |
1146 | + .impl.min_access_size = 4, | 89 | if (opaque) { |
1147 | + .impl.max_access_size = 4, | 90 | r2->opaque = opaque; |
1148 | + .endianness = DEVICE_LITTLE_ENDIAN, | 91 | } |
1149 | +}; | 92 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, |
1150 | + | 93 | /* Make sure reginfo passed to helpers for wildcarded regs |
1151 | +static uint64_t dwc2_hreg2_read(void *ptr, hwaddr addr, unsigned size) | 94 | * has the correct crm/opc1/opc2 for this reg, not CP_ANY: |
1152 | +{ | 95 | */ |
1153 | + /* TODO - implement FIFOs to support slave mode */ | 96 | + r2->cp = cp; |
1154 | + trace_usb_dwc2_hreg2_read(addr, addr >> 12, 0); | 97 | r2->crm = crm; |
1155 | + qemu_log_mask(LOG_UNIMP, "FIFO read not implemented\n"); | 98 | r2->opc1 = opc1; |
1156 | + return 0; | 99 | r2->opc2 = opc2; |
1157 | +} | ||
1158 | + | ||
1159 | +static void dwc2_hreg2_write(void *ptr, hwaddr addr, uint64_t val, | ||
1160 | + unsigned size) | ||
1161 | +{ | ||
1162 | + uint64_t orig = val; | ||
1163 | + | ||
1164 | + /* TODO - implement FIFOs to support slave mode */ | ||
1165 | + trace_usb_dwc2_hreg2_write(addr, addr >> 12, orig, 0, val); | ||
1166 | + qemu_log_mask(LOG_UNIMP, "FIFO write not implemented\n"); | ||
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 | -- | 100 | -- |
1552 | 2.20.1 | 101 | 2.25.1 |
1553 | |||
1554 | diff view generated by jsdifflib |
1 | From: Paul Zimmerman <pauldzim@gmail.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | The dwc-hsotg (dwc2) USB host depends on a short packet to | 3 | Put most of the value writeback to the same place, |
4 | indicate the end of an IN transfer. The usb-storage driver | 4 | and improve the comment that goes with them. |
5 | currently doesn't provide this, so fix it. | ||
6 | 5 | ||
7 | I have tested this change rather extensively using a PC | 6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
8 | emulation with xhci, ehci, and uhci controllers, and have | 7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
9 | not observed any regressions. | 8 | Message-id: 20220501055028.646596-15-richard.henderson@linaro.org |
10 | |||
11 | Signed-off-by: Paul Zimmerman <pauldzim@gmail.com> | ||
12 | Message-id: 20200520235349.21215-6-pauldzim@gmail.com | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | --- | 10 | --- |
15 | hw/usb/dev-storage.c | 15 ++++++++++++++- | 11 | target/arm/helper.c | 28 ++++++++++++---------------- |
16 | 1 file changed, 14 insertions(+), 1 deletion(-) | 12 | 1 file changed, 12 insertions(+), 16 deletions(-) |
17 | 13 | ||
18 | diff --git a/hw/usb/dev-storage.c b/hw/usb/dev-storage.c | 14 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
19 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/hw/usb/dev-storage.c | 16 | --- a/target/arm/helper.c |
21 | +++ b/hw/usb/dev-storage.c | 17 | +++ b/target/arm/helper.c |
22 | @@ -XXX,XX +XXX,XX @@ static void usb_msd_copy_data(MSDState *s, USBPacket *p) | 18 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, |
23 | usb_packet_copy(p, scsi_req_get_buf(s->req) + s->scsi_off, len); | 19 | *r2 = *r; |
24 | s->scsi_len -= len; | 20 | r2->name = memcpy(r2 + 1, name, name_len); |
25 | s->scsi_off += len; | 21 | |
26 | + if (len > s->data_len) { | 22 | - /* Reset the secure state to the specific incoming state. This is |
27 | + len = s->data_len; | 23 | - * necessary as the register may have been defined with both states. |
24 | + /* | ||
25 | + * Update fields to match the instantiation, overwiting wildcards | ||
26 | + * such as CP_ANY, ARM_CP_STATE_BOTH, or ARM_CP_SECSTATE_BOTH. | ||
27 | */ | ||
28 | + r2->cp = cp; | ||
29 | + r2->crm = crm; | ||
30 | + r2->opc1 = opc1; | ||
31 | + r2->opc2 = opc2; | ||
32 | + r2->state = state; | ||
33 | r2->secure = secstate; | ||
34 | + if (opaque) { | ||
35 | + r2->opaque = opaque; | ||
28 | + } | 36 | + } |
29 | s->data_len -= len; | 37 | |
30 | if (s->scsi_len == 0 || s->data_len == 0) { | 38 | if (r->bank_fieldoffsets[0] && r->bank_fieldoffsets[1]) { |
31 | scsi_req_continue(s->req); | 39 | /* Register is banked (using both entries in array). |
32 | @@ -XXX,XX +XXX,XX @@ static void usb_msd_command_complete(SCSIRequest *req, uint32_t status, size_t r | 40 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, |
33 | if (s->data_len) { | 41 | #endif |
34 | int len = (p->iov.size - p->actual_length); | 42 | } |
35 | usb_packet_skip(p, len); | 43 | } |
36 | + if (len > s->data_len) { | 44 | - if (opaque) { |
37 | + len = s->data_len; | 45 | - r2->opaque = opaque; |
38 | + } | 46 | - } |
39 | s->data_len -= len; | 47 | - /* reginfo passed to helpers is correct for the actual access, |
40 | } | 48 | - * and is never ARM_CP_STATE_BOTH: |
41 | if (s->data_len == 0) { | 49 | - */ |
42 | @@ -XXX,XX +XXX,XX @@ static void usb_msd_handle_data(USBDevice *dev, USBPacket *p) | 50 | - r2->state = state; |
43 | int len = p->iov.size - p->actual_length; | 51 | - /* Make sure reginfo passed to helpers for wildcarded regs |
44 | if (len) { | 52 | - * has the correct crm/opc1/opc2 for this reg, not CP_ANY: |
45 | usb_packet_skip(p, len); | 53 | - */ |
46 | + if (len > s->data_len) { | 54 | - r2->cp = cp; |
47 | + len = s->data_len; | 55 | - r2->crm = crm; |
48 | + } | 56 | - r2->opc1 = opc1; |
49 | s->data_len -= len; | 57 | - r2->opc2 = opc2; |
50 | if (s->data_len == 0) { | 58 | + |
51 | s->mode = USB_MSDM_CSW; | 59 | /* By convention, for wildcarded registers only the first |
52 | @@ -XXX,XX +XXX,XX @@ static void usb_msd_handle_data(USBDevice *dev, USBPacket *p) | 60 | * entry is used for migration; the others are marked as |
53 | int len = p->iov.size - p->actual_length; | 61 | * ALIAS so we don't try to transfer the register |
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 | -- | 62 | -- |
72 | 2.20.1 | 63 | 2.25.1 |
73 | |||
74 | 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 | Bool is a more appropriate type for these variables. |
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 | ||
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-3-richard.henderson@linaro.org | ||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Message-id: 20220501055028.646596-16-richard.henderson@linaro.org | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 9 | --- |
12 | target/arm/helper.h | 2 ++ | 10 | target/arm/helper.c | 4 ++-- |
13 | target/arm/translate-a64.h | 3 ++ | 11 | 1 file changed, 2 insertions(+), 2 deletions(-) |
14 | target/arm/crypto_helper.c | 11 +++++++ | ||
15 | target/arm/translate-a64.c | 59 ++++++++++++++++++++------------------ | ||
16 | 4 files changed, 47 insertions(+), 28 deletions(-) | ||
17 | 12 | ||
18 | diff --git a/target/arm/helper.h b/target/arm/helper.h | 13 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
19 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/target/arm/helper.h | 15 | --- a/target/arm/helper.c |
21 | +++ b/target/arm/helper.h | 16 | +++ b/target/arm/helper.c |
22 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(crypto_sm3partw2, TCG_CALL_NO_RWG, void, ptr, ptr, ptr) | 17 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, |
23 | DEF_HELPER_FLAGS_4(crypto_sm4e, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | 18 | */ |
24 | DEF_HELPER_FLAGS_4(crypto_sm4ekey, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | 19 | uint32_t key; |
25 | 20 | ARMCPRegInfo *r2; | |
26 | +DEF_HELPER_FLAGS_4(crypto_rax1, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | 21 | - int is64 = (r->type & ARM_CP_64BIT) ? 1 : 0; |
27 | + | 22 | - int ns = (secstate & ARM_CP_SECSTATE_NS) ? 1 : 0; |
28 | DEF_HELPER_FLAGS_3(crc32, TCG_CALL_NO_RWG_SE, i32, i32, i32, i32) | 23 | + bool is64 = r->type & ARM_CP_64BIT; |
29 | DEF_HELPER_FLAGS_3(crc32c, TCG_CALL_NO_RWG_SE, i32, i32, i32, i32) | 24 | + bool ns = secstate & ARM_CP_SECSTATE_NS; |
30 | 25 | int cp = r->cp; | |
31 | diff --git a/target/arm/translate-a64.h b/target/arm/translate-a64.h | 26 | size_t name_len; |
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 | 27 | ||
160 | -- | 28 | -- |
161 | 2.20.1 | 29 | 2.25.1 |
162 | |||
163 | diff view generated by jsdifflib |
1 | From: Eden Mikitas <e.mikitas@gmail.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | The while statement in question only checked if tx_burst is not 0. | 3 | Computing isbanked only once makes the code |
4 | tx_burst is a signed int, which is assigned the value put by the | 4 | a bit easier to read. |
5 | guest driver in ECSPI_CONREG. The burst length can be anywhere | ||
6 | between 1 and 4096, and since tx_burst is always decremented by 8 | ||
7 | it could possibly underflow, causing an infinite loop. | ||
8 | 5 | ||
9 | Signed-off-by: Eden Mikitas <e.mikitas@gmail.com> | 6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
10 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | 7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Message-id: 20220501055028.646596-17-richard.henderson@linaro.org | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | --- | 10 | --- |
13 | hw/ssi/imx_spi.c | 2 +- | 11 | target/arm/helper.c | 6 ++++-- |
14 | 1 file changed, 1 insertion(+), 1 deletion(-) | 12 | 1 file changed, 4 insertions(+), 2 deletions(-) |
15 | 13 | ||
16 | diff --git a/hw/ssi/imx_spi.c b/hw/ssi/imx_spi.c | 14 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
17 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/hw/ssi/imx_spi.c | 16 | --- a/target/arm/helper.c |
19 | +++ b/hw/ssi/imx_spi.c | 17 | +++ b/target/arm/helper.c |
20 | @@ -XXX,XX +XXX,XX @@ static void imx_spi_flush_txfifo(IMXSPIState *s) | 18 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, |
21 | 19 | bool is64 = r->type & ARM_CP_64BIT; | |
22 | rx = 0; | 20 | bool ns = secstate & ARM_CP_SECSTATE_NS; |
23 | 21 | int cp = r->cp; | |
24 | - while (tx_burst) { | 22 | + bool isbanked; |
25 | + while (tx_burst > 0) { | 23 | size_t name_len; |
26 | uint8_t byte = tx & 0xff; | 24 | |
27 | 25 | switch (state) { | |
28 | DPRINTF("writing 0x%02x\n", (uint32_t)byte); | 26 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, |
27 | r2->opaque = opaque; | ||
28 | } | ||
29 | |||
30 | - if (r->bank_fieldoffsets[0] && r->bank_fieldoffsets[1]) { | ||
31 | + isbanked = r->bank_fieldoffsets[0] && r->bank_fieldoffsets[1]; | ||
32 | + if (isbanked) { | ||
33 | /* Register is banked (using both entries in array). | ||
34 | * Overwriting fieldoffset as the array is only used to define | ||
35 | * banked registers but later only fieldoffset is used. | ||
36 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, | ||
37 | } | ||
38 | |||
39 | if (state == ARM_CP_STATE_AA32) { | ||
40 | - if (r->bank_fieldoffsets[0] && r->bank_fieldoffsets[1]) { | ||
41 | + if (isbanked) { | ||
42 | /* If the register is banked then we don't need to migrate or | ||
43 | * reset the 32-bit instance in certain cases: | ||
44 | * | ||
29 | -- | 45 | -- |
30 | 2.20.1 | 46 | 2.25.1 |
31 | |||
32 | diff view generated by jsdifflib |
1 | From: Paul Zimmerman <pauldzim@gmail.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Wire the dwc-hsotg (dwc2) emulation into Qemu | 3 | Perform the override check early, so that it is still done |
4 | even when we decide to discard an unreachable cpreg. | ||
4 | 5 | ||
5 | Signed-off-by: Paul Zimmerman <pauldzim@gmail.com> | 6 | Use assert not printf+abort. |
6 | Reviewed-by: Philippe Mathieu-Daude <f4bug@amsat.org> | 7 | |
7 | Message-id: 20200520235349.21215-7-pauldzim@gmail.com | 8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Message-id: 20220501055028.646596-18-richard.henderson@linaro.org | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | --- | 12 | --- |
10 | include/hw/arm/bcm2835_peripherals.h | 3 ++- | 13 | target/arm/helper.c | 22 ++++++++-------------- |
11 | hw/arm/bcm2835_peripherals.c | 21 ++++++++++++++++++++- | 14 | 1 file changed, 8 insertions(+), 14 deletions(-) |
12 | 2 files changed, 22 insertions(+), 2 deletions(-) | ||
13 | 15 | ||
14 | diff --git a/include/hw/arm/bcm2835_peripherals.h b/include/hw/arm/bcm2835_peripherals.h | 16 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
15 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/include/hw/arm/bcm2835_peripherals.h | 18 | --- a/target/arm/helper.c |
17 | +++ b/include/hw/arm/bcm2835_peripherals.h | 19 | +++ b/target/arm/helper.c |
18 | @@ -XXX,XX +XXX,XX @@ | 20 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, |
19 | #include "hw/sd/bcm2835_sdhost.h" | 21 | g_assert_not_reached(); |
20 | #include "hw/gpio/bcm2835_gpio.h" | 22 | } |
21 | #include "hw/timer/bcm2835_systmr.h" | 23 | |
22 | +#include "hw/usb/hcd-dwc2.h" | 24 | + /* Overriding of an existing definition must be explicitly requested. */ |
23 | #include "hw/misc/unimp.h" | 25 | + if (!(r->type & ARM_CP_OVERRIDE)) { |
24 | 26 | + const ARMCPRegInfo *oldreg = get_arm_cp_reginfo(cpu->cp_regs, key); | |
25 | #define TYPE_BCM2835_PERIPHERALS "bcm2835-peripherals" | 27 | + if (oldreg) { |
26 | @@ -XXX,XX +XXX,XX @@ typedef struct BCM2835PeripheralState { | 28 | + assert(oldreg->type & ARM_CP_OVERRIDE); |
27 | UnimplementedDeviceState ave0; | 29 | + } |
28 | UnimplementedDeviceState bscsl; | ||
29 | UnimplementedDeviceState smi; | ||
30 | - UnimplementedDeviceState dwc2; | ||
31 | + DWC2State dwc2; | ||
32 | UnimplementedDeviceState sdramc; | ||
33 | } BCM2835PeripheralState; | ||
34 | |||
35 | diff --git a/hw/arm/bcm2835_peripherals.c b/hw/arm/bcm2835_peripherals.c | ||
36 | index XXXXXXX..XXXXXXX 100644 | ||
37 | --- a/hw/arm/bcm2835_peripherals.c | ||
38 | +++ b/hw/arm/bcm2835_peripherals.c | ||
39 | @@ -XXX,XX +XXX,XX @@ static void bcm2835_peripherals_init(Object *obj) | ||
40 | /* Mphi */ | ||
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 | } | ||
51 | |||
52 | static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp) | ||
53 | @@ -XXX,XX +XXX,XX @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp) | ||
54 | qdev_get_gpio_in_named(DEVICE(&s->ic), BCM2835_IC_GPU_IRQ, | ||
55 | INTERRUPT_HOSTPORT)); | ||
56 | |||
57 | + /* DWC2 */ | ||
58 | + object_property_set_bool(OBJECT(&s->dwc2), true, "realized", &err); | ||
59 | + if (err) { | ||
60 | + error_propagate(errp, err); | ||
61 | + return; | ||
62 | + } | 30 | + } |
63 | + | 31 | + |
64 | + memory_region_add_subregion(&s->peri_mr, USB_OTG_OFFSET, | 32 | /* Combine cpreg and name into one allocation. */ |
65 | + sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->dwc2), 0)); | 33 | name_len = strlen(name) + 1; |
66 | + sysbus_connect_irq(SYS_BUS_DEVICE(&s->dwc2), 0, | 34 | r2 = g_malloc(sizeof(*r2) + name_len); |
67 | + qdev_get_gpio_in_named(DEVICE(&s->ic), BCM2835_IC_GPU_IRQ, | 35 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, |
68 | + INTERRUPT_USB)); | 36 | assert(!raw_accessors_invalid(r2)); |
69 | + | 37 | } |
70 | create_unimp(s, &s->armtmr, "bcm2835-sp804", ARMCTRL_TIMER0_1_OFFSET, 0x40); | 38 | |
71 | create_unimp(s, &s->cprman, "bcm2835-cprman", CPRMAN_OFFSET, 0x1000); | 39 | - /* Overriding of an existing definition must be explicitly |
72 | create_unimp(s, &s->a2w, "bcm2835-a2w", A2W_OFFSET, 0x1000); | 40 | - * requested. |
73 | @@ -XXX,XX +XXX,XX @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp) | 41 | - */ |
74 | create_unimp(s, &s->otp, "bcm2835-otp", OTP_OFFSET, 0x80); | 42 | - if (!(r->type & ARM_CP_OVERRIDE)) { |
75 | create_unimp(s, &s->dbus, "bcm2835-dbus", DBUS_OFFSET, 0x8000); | 43 | - const ARMCPRegInfo *oldreg = get_arm_cp_reginfo(cpu->cp_regs, key); |
76 | create_unimp(s, &s->ave0, "bcm2835-ave0", AVE0_OFFSET, 0x8000); | 44 | - if (oldreg && !(oldreg->type & ARM_CP_OVERRIDE)) { |
77 | - create_unimp(s, &s->dwc2, "dwc-usb2", USB_OTG_OFFSET, 0x1000); | 45 | - fprintf(stderr, "Register redefined: cp=%d %d bit " |
78 | create_unimp(s, &s->sdramc, "bcm2835-sdramc", SDRAMC_OFFSET, 0x100); | 46 | - "crn=%d crm=%d opc1=%d opc2=%d, " |
47 | - "was %s, now %s\n", r2->cp, 32 + 32 * is64, | ||
48 | - r2->crn, r2->crm, r2->opc1, r2->opc2, | ||
49 | - oldreg->name, r2->name); | ||
50 | - g_assert_not_reached(); | ||
51 | - } | ||
52 | - } | ||
53 | g_hash_table_insert(cpu->cp_regs, (gpointer)(uintptr_t)key, r2); | ||
79 | } | 54 | } |
80 | 55 | ||
81 | -- | 56 | -- |
82 | 2.20.1 | 57 | 2.25.1 |
83 | |||
84 | 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 | Put the block comments into the current coding style. |
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 | ||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Message-id: 20220501055028.646596-19-richard.henderson@linaro.org | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 9 | --- |
12 | target/arm/helper.h | 5 ++++- | 10 | target/arm/helper.c | 24 +++++++++++++++--------- |
13 | target/arm/crypto_helper.c | 24 ++++++++++++++++++------ | 11 | 1 file changed, 15 insertions(+), 9 deletions(-) |
14 | target/arm/translate-a64.c | 21 +++++---------------- | ||
15 | 3 files changed, 27 insertions(+), 23 deletions(-) | ||
16 | 12 | ||
17 | diff --git a/target/arm/helper.h b/target/arm/helper.h | 13 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
18 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/target/arm/helper.h | 15 | --- a/target/arm/helper.c |
20 | +++ b/target/arm/helper.h | 16 | +++ b/target/arm/helper.c |
21 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(crypto_sha512su0, TCG_CALL_NO_RWG, void, ptr, ptr, i32) | 17 | @@ -XXX,XX +XXX,XX @@ CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp) |
22 | DEF_HELPER_FLAGS_4(crypto_sha512su1, TCG_CALL_NO_RWG, | 18 | return cpu_list; |
23 | void, ptr, ptr, ptr, i32) | ||
24 | |||
25 | -DEF_HELPER_FLAGS_5(crypto_sm3tt, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32, i32) | ||
26 | +DEF_HELPER_FLAGS_4(crypto_sm3tt1a, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | ||
27 | +DEF_HELPER_FLAGS_4(crypto_sm3tt1b, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | ||
28 | +DEF_HELPER_FLAGS_4(crypto_sm3tt2a, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | ||
29 | +DEF_HELPER_FLAGS_4(crypto_sm3tt2b, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | ||
30 | DEF_HELPER_FLAGS_4(crypto_sm3partw1, TCG_CALL_NO_RWG, | ||
31 | void, ptr, ptr, ptr, i32) | ||
32 | DEF_HELPER_FLAGS_4(crypto_sm3partw2, TCG_CALL_NO_RWG, | ||
33 | diff --git a/target/arm/crypto_helper.c b/target/arm/crypto_helper.c | ||
34 | index XXXXXXX..XXXXXXX 100644 | ||
35 | --- a/target/arm/crypto_helper.c | ||
36 | +++ b/target/arm/crypto_helper.c | ||
37 | @@ -XXX,XX +XXX,XX @@ void HELPER(crypto_sm3partw2)(void *vd, void *vn, void *vm, uint32_t desc) | ||
38 | clear_tail_16(vd, desc); | ||
39 | } | 19 | } |
40 | 20 | ||
41 | -void HELPER(crypto_sm3tt)(void *vd, void *vn, void *vm, uint32_t imm2, | 21 | +/* |
42 | - uint32_t opcode) | 22 | + * Private utility function for define_one_arm_cp_reg_with_opaque(): |
43 | +static inline void QEMU_ALWAYS_INLINE | 23 | + * add a single reginfo struct to the hash table. |
44 | +crypto_sm3tt(uint64_t *rd, uint64_t *rn, uint64_t *rm, | 24 | + */ |
45 | + uint32_t desc, uint32_t opcode) | 25 | static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, |
26 | void *opaque, CPState state, | ||
27 | CPSecureState secstate, | ||
28 | int crm, int opc1, int opc2, | ||
29 | const char *name) | ||
46 | { | 30 | { |
47 | - uint64_t *rd = vd; | 31 | - /* Private utility function for define_one_arm_cp_reg_with_opaque(): |
48 | - uint64_t *rn = vn; | 32 | - * add a single reginfo struct to the hash table. |
49 | - uint64_t *rm = vm; | 33 | - */ |
50 | union CRYPTO_STATE d = { .l = { rd[0], rd[1] } }; | 34 | uint32_t key; |
51 | union CRYPTO_STATE n = { .l = { rn[0], rn[1] } }; | 35 | ARMCPRegInfo *r2; |
52 | union CRYPTO_STATE m = { .l = { rm[0], rm[1] } }; | 36 | bool is64 = r->type & ARM_CP_64BIT; |
53 | + uint32_t imm2 = simd_data(desc); | 37 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, |
54 | uint32_t t; | 38 | |
55 | 39 | isbanked = r->bank_fieldoffsets[0] && r->bank_fieldoffsets[1]; | |
56 | assert(imm2 < 4); | 40 | if (isbanked) { |
57 | @@ -XXX,XX +XXX,XX @@ void HELPER(crypto_sm3tt)(void *vd, void *vn, void *vm, uint32_t imm2, | 41 | - /* Register is banked (using both entries in array). |
58 | /* SM3TT2B */ | 42 | + /* |
59 | t = cho(CR_ST_WORD(d, 3), CR_ST_WORD(d, 2), CR_ST_WORD(d, 1)); | 43 | + * Register is banked (using both entries in array). |
60 | } else { | 44 | * Overwriting fieldoffset as the array is only used to define |
61 | - g_assert_not_reached(); | 45 | * banked registers but later only fieldoffset is used. |
62 | + qemu_build_not_reached(); | 46 | */ |
47 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, | ||
48 | |||
49 | if (state == ARM_CP_STATE_AA32) { | ||
50 | if (isbanked) { | ||
51 | - /* If the register is banked then we don't need to migrate or | ||
52 | + /* | ||
53 | + * If the register is banked then we don't need to migrate or | ||
54 | * reset the 32-bit instance in certain cases: | ||
55 | * | ||
56 | * 1) If the register has both 32-bit and 64-bit instances then we | ||
57 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, | ||
58 | r2->type |= ARM_CP_ALIAS; | ||
59 | } | ||
60 | } else if ((secstate != r->secure) && !ns) { | ||
61 | - /* The register is not banked so we only want to allow migration of | ||
62 | - * the non-secure instance. | ||
63 | + /* | ||
64 | + * The register is not banked so we only want to allow migration | ||
65 | + * of the non-secure instance. | ||
66 | */ | ||
67 | r2->type |= ARM_CP_ALIAS; | ||
68 | } | ||
69 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, | ||
70 | } | ||
63 | } | 71 | } |
64 | 72 | ||
65 | t += CR_ST_WORD(d, 0) + CR_ST_WORD(m, imm2); | 73 | - /* By convention, for wildcarded registers only the first |
66 | @@ -XXX,XX +XXX,XX @@ void HELPER(crypto_sm3tt)(void *vd, void *vn, void *vm, uint32_t imm2, | 74 | + /* |
67 | 75 | + * By convention, for wildcarded registers only the first | |
68 | rd[0] = d.l[0]; | 76 | * entry is used for migration; the others are marked as |
69 | rd[1] = d.l[1]; | 77 | * ALIAS so we don't try to transfer the register |
70 | + | 78 | * multiple times. Special registers (ie NOP/WFI) are |
71 | + clear_tail_16(rd, desc); | 79 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, |
72 | } | 80 | r2->type |= ARM_CP_ALIAS | ARM_CP_NO_GDB; |
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; | ||
112 | } | 81 | } |
113 | 82 | ||
114 | - tcg_rd_ptr = vec_full_reg_ptr(s, rd); | 83 | - /* Check that raw accesses are either forbidden or handled. Note that |
115 | - tcg_rn_ptr = vec_full_reg_ptr(s, rn); | 84 | + /* |
116 | - tcg_rm_ptr = vec_full_reg_ptr(s, rm); | 85 | + * Check that raw accesses are either forbidden or handled. Note that |
117 | - tcg_imm2 = tcg_const_i32(imm2); | 86 | * we can't assert this earlier because the setup of fieldoffset for |
118 | - tcg_opcode = tcg_const_i32(opcode); | 87 | * banked registers has to be done first. |
119 | - | 88 | */ |
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 | -- | 89 | -- |
133 | 2.20.1 | 90 | 2.25.1 |
134 | |||
135 | diff view generated by jsdifflib |
1 | From: Eden Mikitas <e.mikitas@gmail.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | When inserting the value retrieved (rx) from the spi slave, rx is pushed to | 3 | Since e03b56863d2bc, our host endian indicator is unconditionally |
4 | rx_fifo after being cast to uint8_t. rx_fifo is a fifo32, and the rx | 4 | set, which means that we can use a normal C condition. |
5 | register the driver uses is also 32 bit. This zeroes the 24 most | ||
6 | significant bits of rx. This proved problematic with devices that expect to | ||
7 | use the whole 32 bits of the rx register. | ||
8 | 5 | ||
9 | Signed-off-by: Eden Mikitas <e.mikitas@gmail.com> | 6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
10 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | 7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Message-id: 20220501055028.646596-20-richard.henderson@linaro.org | ||
9 | [PMM: quote correct git hash in commit message] | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | --- | 11 | --- |
13 | hw/ssi/imx_spi.c | 2 +- | 12 | target/arm/helper.c | 9 +++------ |
14 | 1 file changed, 1 insertion(+), 1 deletion(-) | 13 | 1 file changed, 3 insertions(+), 6 deletions(-) |
15 | 14 | ||
16 | diff --git a/hw/ssi/imx_spi.c b/hw/ssi/imx_spi.c | 15 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
17 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/hw/ssi/imx_spi.c | 17 | --- a/target/arm/helper.c |
19 | +++ b/hw/ssi/imx_spi.c | 18 | +++ b/target/arm/helper.c |
20 | @@ -XXX,XX +XXX,XX @@ static void imx_spi_flush_txfifo(IMXSPIState *s) | 19 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, |
21 | if (fifo32_is_full(&s->rx_fifo)) { | 20 | r2->type |= ARM_CP_ALIAS; |
22 | s->regs[ECSPI_STATREG] |= ECSPI_STATREG_RO; | ||
23 | } else { | ||
24 | - fifo32_push(&s->rx_fifo, (uint8_t)rx); | ||
25 | + fifo32_push(&s->rx_fifo, rx); | ||
26 | } | 21 | } |
27 | 22 | ||
28 | if (s->burst_length <= 0) { | 23 | - if (r->state == ARM_CP_STATE_BOTH) { |
24 | -#if HOST_BIG_ENDIAN | ||
25 | - if (r2->fieldoffset) { | ||
26 | - r2->fieldoffset += sizeof(uint32_t); | ||
27 | - } | ||
28 | -#endif | ||
29 | + if (HOST_BIG_ENDIAN && | ||
30 | + r->state == ARM_CP_STATE_BOTH && r2->fieldoffset) { | ||
31 | + r2->fieldoffset += sizeof(uint32_t); | ||
32 | } | ||
33 | } | ||
34 | |||
29 | -- | 35 | -- |
30 | 2.20.1 | 36 | 2.25.1 |
31 | |||
32 | diff view generated by jsdifflib |
1 | Convert the VSHR 2-reg-shift insns to decodetree. | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Note that unlike the legacy decoder, we present the right shift | 3 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
4 | amount to the trans_ function as a positive integer. | 4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
5 | Message-id: 20220501055028.646596-24-richard.henderson@linaro.org | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | --- | ||
8 | target/arm/cpu.h | 15 +++++++++++++++ | ||
9 | 1 file changed, 15 insertions(+) | ||
5 | 10 | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20200522145520.6778-3-peter.maydell@linaro.org | ||
9 | --- | ||
10 | target/arm/neon-dp.decode | 25 ++++++++++++++++++++ | ||
11 | target/arm/translate-neon.inc.c | 41 +++++++++++++++++++++++++++++++++ | ||
12 | target/arm/translate.c | 21 +---------------- | ||
13 | 3 files changed, 67 insertions(+), 20 deletions(-) | ||
14 | |||
15 | diff --git a/target/arm/neon-dp.decode b/target/arm/neon-dp.decode | ||
16 | index XXXXXXX..XXXXXXX 100644 | 12 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/neon-dp.decode | 13 | --- a/target/arm/cpu.h |
18 | +++ b/target/arm/neon-dp.decode | 14 | +++ b/target/arm/cpu.h |
19 | @@ -XXX,XX +XXX,XX @@ VMINNM_fp_3s 1111 001 1 0 . 1 . .... .... 1111 ... 1 .... @3same_fp | 15 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa32_ssbs(const ARMISARegisters *id) |
20 | ###################################################################### | 16 | return FIELD_EX32(id->id_pfr2, ID_PFR2, SSBS) != 0; |
21 | &2reg_shift vm vd q shift size | ||
22 | |||
23 | +# Right shifts are encoded as N - shift, where N is the element size in bits. | ||
24 | +%neon_rshift_i6 16:6 !function=rsub_64 | ||
25 | +%neon_rshift_i5 16:5 !function=rsub_32 | ||
26 | +%neon_rshift_i4 16:4 !function=rsub_16 | ||
27 | +%neon_rshift_i3 16:3 !function=rsub_8 | ||
28 | + | ||
29 | +@2reg_shr_d .... ... . . . ...... .... .... 1 q:1 . . .... \ | ||
30 | + &2reg_shift vm=%vm_dp vd=%vd_dp size=3 shift=%neon_rshift_i6 | ||
31 | +@2reg_shr_s .... ... . . . 1 ..... .... .... 0 q:1 . . .... \ | ||
32 | + &2reg_shift vm=%vm_dp vd=%vd_dp size=2 shift=%neon_rshift_i5 | ||
33 | +@2reg_shr_h .... ... . . . 01 .... .... .... 0 q:1 . . .... \ | ||
34 | + &2reg_shift vm=%vm_dp vd=%vd_dp size=1 shift=%neon_rshift_i4 | ||
35 | +@2reg_shr_b .... ... . . . 001 ... .... .... 0 q:1 . . .... \ | ||
36 | + &2reg_shift vm=%vm_dp vd=%vd_dp size=0 shift=%neon_rshift_i3 | ||
37 | + | ||
38 | @2reg_shl_d .... ... . . . shift:6 .... .... 1 q:1 . . .... \ | ||
39 | &2reg_shift vm=%vm_dp vd=%vd_dp size=3 | ||
40 | @2reg_shl_s .... ... . . . 1 shift:5 .... .... 0 q:1 . . .... \ | ||
41 | @@ -XXX,XX +XXX,XX @@ VMINNM_fp_3s 1111 001 1 0 . 1 . .... .... 1111 ... 1 .... @3same_fp | ||
42 | @2reg_shl_b .... ... . . . 001 shift:3 .... .... 0 q:1 . . .... \ | ||
43 | &2reg_shift vm=%vm_dp vd=%vd_dp size=0 | ||
44 | |||
45 | +VSHR_S_2sh 1111 001 0 1 . ...... .... 0000 . . . 1 .... @2reg_shr_d | ||
46 | +VSHR_S_2sh 1111 001 0 1 . ...... .... 0000 . . . 1 .... @2reg_shr_s | ||
47 | +VSHR_S_2sh 1111 001 0 1 . ...... .... 0000 . . . 1 .... @2reg_shr_h | ||
48 | +VSHR_S_2sh 1111 001 0 1 . ...... .... 0000 . . . 1 .... @2reg_shr_b | ||
49 | + | ||
50 | +VSHR_U_2sh 1111 001 1 1 . ...... .... 0000 . . . 1 .... @2reg_shr_d | ||
51 | +VSHR_U_2sh 1111 001 1 1 . ...... .... 0000 . . . 1 .... @2reg_shr_s | ||
52 | +VSHR_U_2sh 1111 001 1 1 . ...... .... 0000 . . . 1 .... @2reg_shr_h | ||
53 | +VSHR_U_2sh 1111 001 1 1 . ...... .... 0000 . . . 1 .... @2reg_shr_b | ||
54 | + | ||
55 | VSHL_2sh 1111 001 0 1 . ...... .... 0101 . . . 1 .... @2reg_shl_d | ||
56 | VSHL_2sh 1111 001 0 1 . ...... .... 0101 . . . 1 .... @2reg_shl_s | ||
57 | VSHL_2sh 1111 001 0 1 . ...... .... 0101 . . . 1 .... @2reg_shl_h | ||
58 | diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c | ||
59 | index XXXXXXX..XXXXXXX 100644 | ||
60 | --- a/target/arm/translate-neon.inc.c | ||
61 | +++ b/target/arm/translate-neon.inc.c | ||
62 | @@ -XXX,XX +XXX,XX @@ static inline int plus1(DisasContext *s, int x) | ||
63 | return x + 1; | ||
64 | } | 17 | } |
65 | 18 | ||
66 | +static inline int rsub_64(DisasContext *s, int x) | 19 | +static inline bool isar_feature_aa32_debugv8p2(const ARMISARegisters *id) |
67 | +{ | 20 | +{ |
68 | + return 64 - x; | 21 | + return FIELD_EX32(id->id_dfr0, ID_DFR0, COPDBG) >= 8; |
69 | +} | 22 | +} |
70 | + | 23 | + |
71 | +static inline int rsub_32(DisasContext *s, int x) | 24 | /* |
25 | * 64-bit feature tests via id registers. | ||
26 | */ | ||
27 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa64_ssbs(const ARMISARegisters *id) | ||
28 | return FIELD_EX64(id->id_aa64pfr1, ID_AA64PFR1, SSBS) != 0; | ||
29 | } | ||
30 | |||
31 | +static inline bool isar_feature_aa64_debugv8p2(const ARMISARegisters *id) | ||
72 | +{ | 32 | +{ |
73 | + return 32 - x; | 33 | + return FIELD_EX64(id->id_aa64dfr0, ID_AA64DFR0, DEBUGVER) >= 8; |
74 | +} | ||
75 | +static inline int rsub_16(DisasContext *s, int x) | ||
76 | +{ | ||
77 | + return 16 - x; | ||
78 | +} | ||
79 | +static inline int rsub_8(DisasContext *s, int x) | ||
80 | +{ | ||
81 | + return 8 - x; | ||
82 | +} | 34 | +} |
83 | + | 35 | + |
84 | /* Include the generated Neon decoder */ | 36 | static inline bool isar_feature_aa64_sve2(const ARMISARegisters *id) |
85 | #include "decode-neon-dp.inc.c" | 37 | { |
86 | #include "decode-neon-ls.inc.c" | 38 | return FIELD_EX64(id->id_aa64zfr0, ID_AA64ZFR0, SVEVER) != 0; |
87 | @@ -XXX,XX +XXX,XX @@ static bool do_vector_2sh(DisasContext *s, arg_2reg_shift *a, GVecGen2iFn *fn) | 39 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_any_tts2uxn(const ARMISARegisters *id) |
88 | 40 | return isar_feature_aa64_tts2uxn(id) || isar_feature_aa32_tts2uxn(id); | |
89 | DO_2SH(VSHL, tcg_gen_gvec_shli) | 41 | } |
90 | DO_2SH(VSLI, gen_gvec_sli) | 42 | |
91 | + | 43 | +static inline bool isar_feature_any_debugv8p2(const ARMISARegisters *id) |
92 | +static bool trans_VSHR_S_2sh(DisasContext *s, arg_2reg_shift *a) | ||
93 | +{ | 44 | +{ |
94 | + /* Signed shift out of range results in all-sign-bits */ | 45 | + return isar_feature_aa64_debugv8p2(id) || isar_feature_aa32_debugv8p2(id); |
95 | + a->shift = MIN(a->shift, (8 << a->size) - 1); | ||
96 | + return do_vector_2sh(s, a, tcg_gen_gvec_sari); | ||
97 | +} | 46 | +} |
98 | + | 47 | + |
99 | +static void gen_zero_rd_2sh(unsigned vece, uint32_t rd_ofs, uint32_t rm_ofs, | 48 | /* |
100 | + int64_t shift, uint32_t oprsz, uint32_t maxsz) | 49 | * Forward to the above feature tests given an ARMCPU pointer. |
101 | +{ | 50 | */ |
102 | + tcg_gen_gvec_dup_imm(vece, rd_ofs, oprsz, maxsz, 0); | ||
103 | +} | ||
104 | + | ||
105 | +static bool trans_VSHR_U_2sh(DisasContext *s, arg_2reg_shift *a) | ||
106 | +{ | ||
107 | + /* Shift out of range is architecturally valid and results in zero. */ | ||
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 | + } | ||
113 | +} | ||
114 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
115 | index XXXXXXX..XXXXXXX 100644 | ||
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 | -- | 51 | -- |
154 | 2.20.1 | 52 | 2.25.1 |
155 | |||
156 | diff view generated by jsdifflib |
1 | From: Paul Zimmerman <pauldzim@gmail.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Add BCM2835 SOC MPHI (Message-based Parallel Host Interface) | 3 | Add the aa64 predicate for detecting RAS support from id registers. |
4 | emulation. It is very basic, only providing the FIQ interrupt | 4 | We already have the aa32 version from the M-profile work. |
5 | needed to allow the dwc-otg USB host controller driver in the | 5 | Add the 'any' predicate for testing both aa64 and aa32. |
6 | Raspbian kernel to function. | ||
7 | 6 | ||
8 | Signed-off-by: Paul Zimmerman <pauldzim@gmail.com> | ||
9 | Acked-by: Philippe Mathieu-Daude <f4bug@amsat.org> | ||
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
11 | Message-id: 20200520235349.21215-2-pauldzim@gmail.com | 8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
9 | Message-id: 20220501055028.646596-34-richard.henderson@linaro.org | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | --- | 11 | --- |
14 | include/hw/arm/bcm2835_peripherals.h | 2 + | 12 | target/arm/cpu.h | 10 ++++++++++ |
15 | include/hw/misc/bcm2835_mphi.h | 44 ++++++ | 13 | 1 file changed, 10 insertions(+) |
16 | hw/arm/bcm2835_peripherals.c | 17 +++ | ||
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 | 14 | ||
23 | diff --git a/include/hw/arm/bcm2835_peripherals.h b/include/hw/arm/bcm2835_peripherals.h | 15 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
24 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
25 | --- a/include/hw/arm/bcm2835_peripherals.h | 17 | --- a/target/arm/cpu.h |
26 | +++ b/include/hw/arm/bcm2835_peripherals.h | 18 | +++ b/target/arm/cpu.h |
27 | @@ -XXX,XX +XXX,XX @@ | 19 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa64_aa32_el1(const ARMISARegisters *id) |
28 | #include "hw/misc/bcm2835_property.h" | 20 | return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, EL1) >= 2; |
29 | #include "hw/misc/bcm2835_rng.h" | ||
30 | #include "hw/misc/bcm2835_mbox.h" | ||
31 | +#include "hw/misc/bcm2835_mphi.h" | ||
32 | #include "hw/misc/bcm2835_thermal.h" | ||
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 | + | ||
65 | +#ifndef HW_MISC_BCM2835_MPHI_H | ||
66 | +#define HW_MISC_BCM2835_MPHI_H | ||
67 | + | ||
68 | +#include "hw/irq.h" | ||
69 | +#include "hw/sysbus.h" | ||
70 | + | ||
71 | +#define MPHI_MMIO_SIZE 0x1000 | ||
72 | + | ||
73 | +typedef struct BCM2835MphiState BCM2835MphiState; | ||
74 | + | ||
75 | +struct BCM2835MphiState { | ||
76 | + SysBusDevice parent_obj; | ||
77 | + qemu_irq irq; | ||
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 | ||
95 | --- a/hw/arm/bcm2835_peripherals.c | ||
96 | +++ b/hw/arm/bcm2835_peripherals.c | ||
97 | @@ -XXX,XX +XXX,XX @@ static void bcm2835_peripherals_init(Object *obj) | ||
98 | OBJECT(&s->sdhci.sdbus)); | ||
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 | } | 21 | } |
106 | 22 | ||
107 | static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp) | 23 | +static inline bool isar_feature_aa64_ras(const ARMISARegisters *id) |
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 | +{ | 24 | +{ |
164 | + qemu_set_irq(s->irq, 1); | 25 | + return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, RAS) != 0; |
165 | +} | 26 | +} |
166 | + | 27 | + |
167 | +static inline void mphi_lower_irq(BCM2835MphiState *s) | 28 | static inline bool isar_feature_aa64_sve(const ARMISARegisters *id) |
29 | { | ||
30 | return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, SVE) != 0; | ||
31 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_any_debugv8p2(const ARMISARegisters *id) | ||
32 | return isar_feature_aa64_debugv8p2(id) || isar_feature_aa32_debugv8p2(id); | ||
33 | } | ||
34 | |||
35 | +static inline bool isar_feature_any_ras(const ARMISARegisters *id) | ||
168 | +{ | 36 | +{ |
169 | + qemu_set_irq(s->irq, 0); | 37 | + return isar_feature_aa64_ras(id) || isar_feature_aa32_ras(id); |
170 | +} | 38 | +} |
171 | + | 39 | + |
172 | +static uint64_t mphi_reg_read(void *ptr, hwaddr addr, unsigned size) | 40 | /* |
173 | +{ | 41 | * Forward to the above feature tests given an ARMCPU pointer. |
174 | + BCM2835MphiState *s = ptr; | 42 | */ |
175 | + uint32_t val = 0; | ||
176 | + | ||
177 | + switch (addr) { | ||
178 | + case 0x28: /* outdda */ | ||
179 | + val = s->outdda; | ||
180 | + break; | ||
181 | + case 0x2c: /* outddb */ | ||
182 | + val = s->outddb; | ||
183 | + break; | ||
184 | + case 0x4c: /* ctrl */ | ||
185 | + val = s->ctrl; | ||
186 | + val |= 1 << 17; | ||
187 | + break; | ||
188 | + case 0x50: /* intstat */ | ||
189 | + val = s->intstat; | ||
190 | + break; | ||
191 | + case 0x1f0: /* swirq_set */ | ||
192 | + val = s->swirq; | ||
193 | + break; | ||
194 | + case 0x1f4: /* swirq_clr */ | ||
195 | + val = s->swirq; | ||
196 | + break; | ||
197 | + default: | ||
198 | + qemu_log_mask(LOG_UNIMP, "read from unknown register"); | ||
199 | + break; | ||
200 | + } | ||
201 | + | ||
202 | + return val; | ||
203 | +} | ||
204 | + | ||
205 | +static void mphi_reg_write(void *ptr, hwaddr addr, uint64_t val, unsigned size) | ||
206 | +{ | ||
207 | + BCM2835MphiState *s = ptr; | ||
208 | + int do_irq = 0; | ||
209 | + | ||
210 | + switch (addr) { | ||
211 | + case 0x28: /* outdda */ | ||
212 | + s->outdda = val; | ||
213 | + break; | ||
214 | + case 0x2c: /* outddb */ | ||
215 | + s->outddb = val; | ||
216 | + if (val & (1 << 29)) { | ||
217 | + do_irq = 1; | ||
218 | + } | ||
219 | + break; | ||
220 | + case 0x4c: /* ctrl */ | ||
221 | + s->ctrl = val; | ||
222 | + if (val & (1 << 16)) { | ||
223 | + do_irq = -1; | ||
224 | + } | ||
225 | + break; | ||
226 | + case 0x50: /* intstat */ | ||
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 | -- | 43 | -- |
338 | 2.20.1 | 44 | 2.25.1 |
339 | |||
340 | diff view generated by jsdifflib |
1 | From: Thomas Huth <thuth@redhat.com> | 1 | From: Alex Zuepke <alex.zuepke@tum.de> |
---|---|---|---|
2 | 2 | ||
3 | As described by Edgar here: | 3 | The ARMv8 manual defines that PMUSERENR_EL0.ER enables read-access |
4 | to both PMXEVCNTR_EL0 and PMEVCNTR<n>_EL0 registers, however, | ||
5 | we only use it for PMXEVCNTR_EL0. Extend to PMEVCNTR<n>_EL0 as well. | ||
4 | 6 | ||
5 | https://www.mail-archive.com/qemu-devel@nongnu.org/msg605124.html | 7 | Signed-off-by: Alex Zuepke <alex.zuepke@tum.de> |
6 | 8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | |
7 | we can use the Ubuntu kernel for testing the xlnx-versal-virt machine. | 9 | Message-id: 20220428132717.84190-1-alex.zuepke@tum.de |
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> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
17 | --- | 11 | --- |
18 | tests/acceptance/boot_linux_console.py | 26 ++++++++++++++++++++++++++ | 12 | target/arm/helper.c | 4 ++-- |
19 | 1 file changed, 26 insertions(+) | 13 | 1 file changed, 2 insertions(+), 2 deletions(-) |
20 | 14 | ||
21 | diff --git a/tests/acceptance/boot_linux_console.py b/tests/acceptance/boot_linux_console.py | 15 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
22 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
23 | --- a/tests/acceptance/boot_linux_console.py | 17 | --- a/target/arm/helper.c |
24 | +++ b/tests/acceptance/boot_linux_console.py | 18 | +++ b/target/arm/helper.c |
25 | @@ -XXX,XX +XXX,XX @@ class BootLinuxConsole(LinuxKernelTest): | 19 | @@ -XXX,XX +XXX,XX @@ static void define_pmu_regs(ARMCPU *cpu) |
26 | console_pattern = 'Kernel command line: %s' % kernel_command_line | 20 | .crm = 8 | (3 & (i >> 3)), .opc1 = 0, .opc2 = i & 7, |
27 | self.wait_for_console_pattern(console_pattern) | 21 | .access = PL0_RW, .type = ARM_CP_IO | ARM_CP_ALIAS, |
28 | 22 | .readfn = pmevcntr_readfn, .writefn = pmevcntr_writefn, | |
29 | + def test_aarch64_xlnx_versal_virt(self): | 23 | - .accessfn = pmreg_access }, |
30 | + """ | 24 | + .accessfn = pmreg_access_xevcntr }, |
31 | + :avocado: tags=arch:aarch64 | 25 | { .name = pmevcntr_el0_name, .state = ARM_CP_STATE_AA64, |
32 | + :avocado: tags=machine:xlnx-versal-virt | 26 | .opc0 = 3, .opc1 = 3, .crn = 14, .crm = 8 | (3 & (i >> 3)), |
33 | + :avocado: tags=device:pl011 | 27 | - .opc2 = i & 7, .access = PL0_RW, .accessfn = pmreg_access, |
34 | + :avocado: tags=device:arm_gicv3 | 28 | + .opc2 = i & 7, .access = PL0_RW, .accessfn = pmreg_access_xevcntr, |
35 | + """ | 29 | .type = ARM_CP_IO, |
36 | + kernel_url = ('http://ports.ubuntu.com/ubuntu-ports/dists/' | 30 | .readfn = pmevcntr_readfn, .writefn = pmevcntr_writefn, |
37 | + 'bionic-updates/main/installer-arm64/current/images/' | 31 | .raw_readfn = pmevcntr_rawread, |
38 | + 'netboot/ubuntu-installer/arm64/linux') | ||
39 | + kernel_hash = '5bfc54cf7ed8157d93f6e5b0241e727b6dc22c50' | ||
40 | + kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash) | ||
41 | + | ||
42 | + initrd_url = ('http://ports.ubuntu.com/ubuntu-ports/dists/' | ||
43 | + 'bionic-updates/main/installer-arm64/current/images/' | ||
44 | + 'netboot/ubuntu-installer/arm64/initrd.gz') | ||
45 | + initrd_hash = 'd385d3e88d53e2004c5d43cbe668b458a094f772' | ||
46 | + initrd_path = self.fetch_asset(initrd_url, asset_hash=initrd_hash) | ||
47 | + | ||
48 | + self.vm.set_console() | ||
49 | + self.vm.add_args('-m', '2G', | ||
50 | + '-kernel', kernel_path, | ||
51 | + '-initrd', initrd_path) | ||
52 | + self.vm.launch() | ||
53 | + self.wait_for_console_pattern('Checked W+X mappings: passed') | ||
54 | + | ||
55 | def test_arm_virt(self): | ||
56 | """ | ||
57 | :avocado: tags=arch:arm | ||
58 | -- | 32 | -- |
59 | 2.20.1 | 33 | 2.25.1 |
60 | |||
61 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Convert the VSHL and VSLI insns from the Neon 2-registers-and-a-shift | ||
2 | group to decodetree. | ||
3 | 1 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20200522145520.6778-2-peter.maydell@linaro.org | ||
7 | --- | ||
8 | target/arm/neon-dp.decode | 25 ++++++++++++++++++++++ | ||
9 | target/arm/translate-neon.inc.c | 38 +++++++++++++++++++++++++++++++++ | ||
10 | target/arm/translate.c | 18 +++++++--------- | ||
11 | 3 files changed, 71 insertions(+), 10 deletions(-) | ||
12 | |||
13 | diff --git a/target/arm/neon-dp.decode b/target/arm/neon-dp.decode | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/target/arm/neon-dp.decode | ||
16 | +++ b/target/arm/neon-dp.decode | ||
17 | @@ -XXX,XX +XXX,XX @@ VRECPS_fp_3s 1111 001 0 0 . 0 . .... .... 1111 ... 1 .... @3same_fp | ||
18 | VRSQRTS_fp_3s 1111 001 0 0 . 1 . .... .... 1111 ... 1 .... @3same_fp | ||
19 | VMAXNM_fp_3s 1111 001 1 0 . 0 . .... .... 1111 ... 1 .... @3same_fp | ||
20 | VMINNM_fp_3s 1111 001 1 0 . 1 . .... .... 1111 ... 1 .... @3same_fp | ||
21 | + | ||
22 | +###################################################################### | ||
23 | +# 2-reg-and-shift grouping: | ||
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 | + } | ||
65 | + | ||
66 | + /* UNDEF accesses to D16-D31 if they don't exist. */ | ||
67 | + if (!dc_isar_feature(aa32_simd_r32, s) && | ||
68 | + ((a->vd | a->vm) & 0x10)) { | ||
69 | + return false; | ||
70 | + } | ||
71 | + | ||
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 | +} | ||
83 | + | ||
84 | +#define DO_2SH(INSN, FUNC) \ | ||
85 | + static bool trans_##INSN##_2sh(DisasContext *s, arg_2reg_shift *a) \ | ||
86 | + { \ | ||
87 | + return do_vector_2sh(s, a, FUNC); \ | ||
88 | + } \ | ||
89 | + | ||
90 | +DO_2SH(VSHL, tcg_gen_gvec_shli) | ||
91 | +DO_2SH(VSLI, gen_gvec_sli) | ||
92 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
93 | index XXXXXXX..XXXXXXX 100644 | ||
94 | --- a/target/arm/translate.c | ||
95 | +++ b/target/arm/translate.c | ||
96 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
97 | if ((insn & 0x00380080) != 0) { | ||
98 | /* Two registers and shift. */ | ||
99 | op = (insn >> 8) & 0xf; | ||
100 | + | ||
101 | + switch (op) { | ||
102 | + case 5: /* VSHL, VSLI */ | ||
103 | + return 1; /* handled by decodetree */ | ||
104 | + default: | ||
105 | + break; | ||
106 | + } | ||
107 | + | ||
108 | if (insn & (1 << 7)) { | ||
109 | /* 64-bit shift. */ | ||
110 | if (op > 7) { | ||
111 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
112 | gen_gvec_sri(size, rd_ofs, rm_ofs, shift, | ||
113 | vec_size, vec_size); | ||
114 | return 0; | ||
115 | - | ||
116 | - case 5: /* VSHL, VSLI */ | ||
117 | - if (u) { /* VSLI */ | ||
118 | - gen_gvec_sli(size, rd_ofs, rm_ofs, shift, | ||
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 | -- | ||
129 | 2.20.1 | ||
130 | |||
131 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Convert the VSRA, VSRI, VRSHR, VRSRA 2-reg-shift insns to decodetree. | ||
2 | (These are the last instructions in the group that are vectorized; | ||
3 | the rest all require looping over each element.) | ||
4 | 1 | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20200522145520.6778-4-peter.maydell@linaro.org | ||
8 | --- | ||
9 | target/arm/neon-dp.decode | 35 ++++++++++++++++++++++ | ||
10 | target/arm/translate-neon.inc.c | 7 +++++ | ||
11 | target/arm/translate.c | 52 +++------------------------------ | ||
12 | 3 files changed, 46 insertions(+), 48 deletions(-) | ||
13 | |||
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 @@ VSHR_U_2sh 1111 001 1 1 . ...... .... 0000 . . . 1 .... @2reg_shr_s | ||
19 | VSHR_U_2sh 1111 001 1 1 . ...... .... 0000 . . . 1 .... @2reg_shr_h | ||
20 | VSHR_U_2sh 1111 001 1 1 . ...... .... 0000 . . . 1 .... @2reg_shr_b | ||
21 | |||
22 | +VSRA_S_2sh 1111 001 0 1 . ...... .... 0001 . . . 1 .... @2reg_shr_d | ||
23 | +VSRA_S_2sh 1111 001 0 1 . ...... .... 0001 . . . 1 .... @2reg_shr_s | ||
24 | +VSRA_S_2sh 1111 001 0 1 . ...... .... 0001 . . . 1 .... @2reg_shr_h | ||
25 | +VSRA_S_2sh 1111 001 0 1 . ...... .... 0001 . . . 1 .... @2reg_shr_b | ||
26 | + | ||
27 | +VSRA_U_2sh 1111 001 1 1 . ...... .... 0001 . . . 1 .... @2reg_shr_d | ||
28 | +VSRA_U_2sh 1111 001 1 1 . ...... .... 0001 . . . 1 .... @2reg_shr_s | ||
29 | +VSRA_U_2sh 1111 001 1 1 . ...... .... 0001 . . . 1 .... @2reg_shr_h | ||
30 | +VSRA_U_2sh 1111 001 1 1 . ...... .... 0001 . . . 1 .... @2reg_shr_b | ||
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 | ||
79 | index XXXXXXX..XXXXXXX 100644 | ||
80 | --- a/target/arm/translate.c | ||
81 | +++ b/target/arm/translate.c | ||
82 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
83 | |||
84 | switch (op) { | ||
85 | case 0: /* VSHR */ | ||
86 | + case 1: /* VSRA */ | ||
87 | + case 2: /* VRSHR */ | ||
88 | + case 3: /* VRSRA */ | ||
89 | + case 4: /* VSRI */ | ||
90 | case 5: /* VSHL, VSLI */ | ||
91 | return 1; /* handled by decodetree */ | ||
92 | default: | ||
93 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
94 | shift = shift - (1 << (size + 3)); | ||
95 | } | ||
96 | |||
97 | - switch (op) { | ||
98 | - case 1: /* VSRA */ | ||
99 | - /* Right shift comes here negative. */ | ||
100 | - shift = -shift; | ||
101 | - if (u) { | ||
102 | - gen_gvec_usra(size, rd_ofs, rm_ofs, shift, | ||
103 | - vec_size, vec_size); | ||
104 | - } else { | ||
105 | - gen_gvec_ssra(size, rd_ofs, rm_ofs, shift, | ||
106 | - vec_size, vec_size); | ||
107 | - } | ||
108 | - return 0; | ||
109 | - | ||
110 | - case 2: /* VRSHR */ | ||
111 | - /* Right shift comes here negative. */ | ||
112 | - shift = -shift; | ||
113 | - if (u) { | ||
114 | - gen_gvec_urshr(size, rd_ofs, rm_ofs, shift, | ||
115 | - vec_size, vec_size); | ||
116 | - } else { | ||
117 | - gen_gvec_srshr(size, rd_ofs, rm_ofs, shift, | ||
118 | - vec_size, vec_size); | ||
119 | - } | ||
120 | - return 0; | ||
121 | - | ||
122 | - case 3: /* VRSRA */ | ||
123 | - /* Right shift comes here negative. */ | ||
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 | -- | ||
149 | 2.20.1 | ||
150 | |||
151 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Convert the VQSHLU and QVSHL 2-reg-shift insns to decodetree. | ||
2 | These are the last of the simple shift-by-immediate insns. | ||
3 | 1 | ||
4 | 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 | --- | ||
8 | target/arm/neon-dp.decode | 15 +++++ | ||
9 | target/arm/translate-neon.inc.c | 108 +++++++++++++++++++++++++++++++ | ||
10 | target/arm/translate.c | 110 +------------------------------- | ||
11 | 3 files changed, 126 insertions(+), 107 deletions(-) | ||
12 | |||
13 | diff --git a/target/arm/neon-dp.decode b/target/arm/neon-dp.decode | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/target/arm/neon-dp.decode | ||
16 | +++ b/target/arm/neon-dp.decode | ||
17 | @@ -XXX,XX +XXX,XX @@ VSLI_2sh 1111 001 1 1 . ...... .... 0101 . . . 1 .... @2reg_shl_d | ||
18 | VSLI_2sh 1111 001 1 1 . ...... .... 0101 . . . 1 .... @2reg_shl_s | ||
19 | VSLI_2sh 1111 001 1 1 . ...... .... 0101 . . . 1 .... @2reg_shl_h | ||
20 | VSLI_2sh 1111 001 1 1 . ...... .... 0101 . . . 1 .... @2reg_shl_b | ||
21 | + | ||
22 | +VQSHLU_64_2sh 1111 001 1 1 . ...... .... 0110 . . . 1 .... @2reg_shl_d | ||
23 | +VQSHLU_2sh 1111 001 1 1 . ...... .... 0110 . . . 1 .... @2reg_shl_s | ||
24 | +VQSHLU_2sh 1111 001 1 1 . ...... .... 0110 . . . 1 .... @2reg_shl_h | ||
25 | +VQSHLU_2sh 1111 001 1 1 . ...... .... 0110 . . . 1 .... @2reg_shl_b | ||
26 | + | ||
27 | +VQSHL_S_64_2sh 1111 001 0 1 . ...... .... 0111 . . . 1 .... @2reg_shl_d | ||
28 | +VQSHL_S_2sh 1111 001 0 1 . ...... .... 0111 . . . 1 .... @2reg_shl_s | ||
29 | +VQSHL_S_2sh 1111 001 0 1 . ...... .... 0111 . . . 1 .... @2reg_shl_h | ||
30 | +VQSHL_S_2sh 1111 001 0 1 . ...... .... 0111 . . . 1 .... @2reg_shl_b | ||
31 | + | ||
32 | +VQSHL_U_64_2sh 1111 001 1 1 . ...... .... 0111 . . . 1 .... @2reg_shl_d | ||
33 | +VQSHL_U_2sh 1111 001 1 1 . ...... .... 0111 . . . 1 .... @2reg_shl_s | ||
34 | +VQSHL_U_2sh 1111 001 1 1 . ...... .... 0111 . . . 1 .... @2reg_shl_h | ||
35 | +VQSHL_U_2sh 1111 001 1 1 . ...... .... 0111 . . . 1 .... @2reg_shl_b | ||
36 | diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c | ||
37 | index XXXXXXX..XXXXXXX 100644 | ||
38 | --- a/target/arm/translate-neon.inc.c | ||
39 | +++ b/target/arm/translate-neon.inc.c | ||
40 | @@ -XXX,XX +XXX,XX @@ static bool trans_VSHR_U_2sh(DisasContext *s, arg_2reg_shift *a) | ||
41 | return do_vector_2sh(s, a, tcg_gen_gvec_shri); | ||
42 | } | ||
43 | } | ||
44 | + | ||
45 | +static bool do_2shift_env_64(DisasContext *s, arg_2reg_shift *a, | ||
46 | + NeonGenTwo64OpEnvFn *fn) | ||
47 | +{ | ||
48 | + /* | ||
49 | + * 2-reg-and-shift operations, size == 3 case, where the | ||
50 | + * function needs to be passed cpu_env. | ||
51 | + */ | ||
52 | + TCGv_i64 constimm; | ||
53 | + int pass; | ||
54 | + | ||
55 | + if (!arm_dc_feature(s, ARM_FEATURE_NEON)) { | ||
56 | + return false; | ||
57 | + } | ||
58 | + | ||
59 | + /* UNDEF accesses to D16-D31 if they don't exist. */ | ||
60 | + if (!dc_isar_feature(aa32_simd_r32, s) && | ||
61 | + ((a->vd | a->vm) & 0x10)) { | ||
62 | + return false; | ||
63 | + } | ||
64 | + | ||
65 | + if ((a->vm | a->vd) & a->q) { | ||
66 | + return false; | ||
67 | + } | ||
68 | + | ||
69 | + if (!vfp_access_check(s)) { | ||
70 | + return true; | ||
71 | + } | ||
72 | + | ||
73 | + /* | ||
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 | +} | ||
89 | + | ||
90 | +static bool do_2shift_env_32(DisasContext *s, arg_2reg_shift *a, | ||
91 | + NeonGenTwoOpEnvFn *fn) | ||
92 | +{ | ||
93 | + /* | ||
94 | + * 2-reg-and-shift operations, size < 3 case, where the | ||
95 | + * helper needs to be passed cpu_env. | ||
96 | + */ | ||
97 | + TCGv_i32 constimm; | ||
98 | + int pass; | ||
99 | + | ||
100 | + if (!arm_dc_feature(s, ARM_FEATURE_NEON)) { | ||
101 | + return false; | ||
102 | + } | ||
103 | + | ||
104 | + /* UNDEF accesses to D16-D31 if they don't exist. */ | ||
105 | + if (!dc_isar_feature(aa32_simd_r32, s) && | ||
106 | + ((a->vd | a->vm) & 0x10)) { | ||
107 | + return false; | ||
108 | + } | ||
109 | + | ||
110 | + if ((a->vm | a->vd) & a->q) { | ||
111 | + return false; | ||
112 | + } | ||
113 | + | ||
114 | + if (!vfp_access_check(s)) { | ||
115 | + return true; | ||
116 | + } | ||
117 | + | ||
118 | + /* | ||
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 | +} | ||
132 | + | ||
133 | +#define DO_2SHIFT_ENV(INSN, FUNC) \ | ||
134 | + static bool trans_##INSN##_64_2sh(DisasContext *s, arg_2reg_shift *a) \ | ||
135 | + { \ | ||
136 | + return do_2shift_env_64(s, a, gen_helper_neon_##FUNC##64); \ | ||
137 | + } \ | ||
138 | + static bool trans_##INSN##_2sh(DisasContext *s, arg_2reg_shift *a) \ | ||
139 | + { \ | ||
140 | + static NeonGenTwoOpEnvFn * const fns[] = { \ | ||
141 | + gen_helper_neon_##FUNC##8, \ | ||
142 | + gen_helper_neon_##FUNC##16, \ | ||
143 | + gen_helper_neon_##FUNC##32, \ | ||
144 | + }; \ | ||
145 | + assert(a->size < ARRAY_SIZE(fns)); \ | ||
146 | + return do_2shift_env_32(s, a, fns[a->size]); \ | ||
147 | + } | ||
148 | + | ||
149 | +DO_2SHIFT_ENV(VQSHLU, qshlu_s) | ||
150 | +DO_2SHIFT_ENV(VQSHL_U, qshl_u) | ||
151 | +DO_2SHIFT_ENV(VQSHL_S, qshl_s) | ||
152 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
153 | index XXXXXXX..XXXXXXX 100644 | ||
154 | --- a/target/arm/translate.c | ||
155 | +++ b/target/arm/translate.c | ||
156 | @@ -XXX,XX +XXX,XX @@ static inline void gen_neon_rsb(int size, TCGv_i32 t0, TCGv_i32 t1) | ||
157 | } | ||
158 | } | ||
159 | |||
160 | -#define GEN_NEON_INTEGER_OP_ENV(name) do { \ | ||
161 | - switch ((size << 1) | u) { \ | ||
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 | -- | ||
295 | 2.20.1 | ||
296 | |||
297 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Convert the Neon narrowing shifts where op==8 to decodetree: | ||
2 | * VSHRN | ||
3 | * VRSHRN | ||
4 | * VQSHRUN | ||
5 | * VQRSHRUN | ||
6 | 1 | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20200522145520.6778-6-peter.maydell@linaro.org | ||
10 | --- | ||
11 | target/arm/neon-dp.decode | 27 ++++++ | ||
12 | target/arm/translate-neon.inc.c | 167 ++++++++++++++++++++++++++++++++ | ||
13 | target/arm/translate.c | 1 + | ||
14 | 3 files changed, 195 insertions(+) | ||
15 | |||
16 | diff --git a/target/arm/neon-dp.decode b/target/arm/neon-dp.decode | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/target/arm/neon-dp.decode | ||
19 | +++ b/target/arm/neon-dp.decode | ||
20 | @@ -XXX,XX +XXX,XX @@ VMINNM_fp_3s 1111 001 1 0 . 1 . .... .... 1111 ... 1 .... @3same_fp | ||
21 | @2reg_shl_b .... ... . . . 001 shift:3 .... .... 0 q:1 . . .... \ | ||
22 | &2reg_shift vm=%vm_dp vd=%vd_dp size=0 | ||
23 | |||
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 | + | ||
35 | VSHR_S_2sh 1111 001 0 1 . ...... .... 0000 . . . 1 .... @2reg_shr_d | ||
36 | VSHR_S_2sh 1111 001 0 1 . ...... .... 0000 . . . 1 .... @2reg_shr_s | ||
37 | VSHR_S_2sh 1111 001 0 1 . ...... .... 0000 . . . 1 .... @2reg_shr_h | ||
38 | @@ -XXX,XX +XXX,XX @@ VQSHL_U_64_2sh 1111 001 1 1 . ...... .... 0111 . . . 1 .... @2reg_shl_d | ||
39 | VQSHL_U_2sh 1111 001 1 1 . ...... .... 0111 . . . 1 .... @2reg_shl_s | ||
40 | VQSHL_U_2sh 1111 001 1 1 . ...... .... 0111 . . . 1 .... @2reg_shl_h | ||
41 | VQSHL_U_2sh 1111 001 1 1 . ...... .... 0111 . . . 1 .... @2reg_shl_b | ||
42 | + | ||
43 | +VSHRN_64_2sh 1111 001 0 1 . ...... .... 1000 . 0 . 1 .... @2reg_shrn_d | ||
44 | +VSHRN_32_2sh 1111 001 0 1 . ...... .... 1000 . 0 . 1 .... @2reg_shrn_s | ||
45 | +VSHRN_16_2sh 1111 001 0 1 . ...... .... 1000 . 0 . 1 .... @2reg_shrn_h | ||
46 | + | ||
47 | +VRSHRN_64_2sh 1111 001 0 1 . ...... .... 1000 . 1 . 1 .... @2reg_shrn_d | ||
48 | +VRSHRN_32_2sh 1111 001 0 1 . ...... .... 1000 . 1 . 1 .... @2reg_shrn_s | ||
49 | +VRSHRN_16_2sh 1111 001 0 1 . ...... .... 1000 . 1 . 1 .... @2reg_shrn_h | ||
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 | ||
60 | --- a/target/arm/translate-neon.inc.c | ||
61 | +++ b/target/arm/translate-neon.inc.c | ||
62 | @@ -XXX,XX +XXX,XX @@ static bool do_2shift_env_32(DisasContext *s, arg_2reg_shift *a, | ||
63 | DO_2SHIFT_ENV(VQSHLU, qshlu_s) | ||
64 | DO_2SHIFT_ENV(VQSHL_U, qshl_u) | ||
65 | DO_2SHIFT_ENV(VQSHL_S, qshl_s) | ||
66 | + | ||
67 | +static bool do_2shift_narrow_64(DisasContext *s, arg_2reg_shift *a, | ||
68 | + NeonGenTwo64OpFn *shiftfn, | ||
69 | + NeonGenNarrowEnvFn *narrowfn) | ||
70 | +{ | ||
71 | + /* 2-reg-and-shift narrowing-shift operations, size == 3 case */ | ||
72 | + TCGv_i64 constimm, rm1, rm2; | ||
73 | + TCGv_i32 rd; | ||
74 | + | ||
75 | + if (!arm_dc_feature(s, ARM_FEATURE_NEON)) { | ||
76 | + return false; | ||
77 | + } | ||
78 | + | ||
79 | + /* UNDEF accesses to D16-D31 if they don't exist. */ | ||
80 | + if (!dc_isar_feature(aa32_simd_r32, s) && | ||
81 | + ((a->vd | a->vm) & 0x10)) { | ||
82 | + return false; | ||
83 | + } | ||
84 | + | ||
85 | + if (a->vm & 1) { | ||
86 | + return false; | ||
87 | + } | ||
88 | + | ||
89 | + if (!vfp_access_check(s)) { | ||
90 | + return true; | ||
91 | + } | ||
92 | + | ||
93 | + /* | ||
94 | + * This is always a right shift, and the shiftfn is always a | ||
95 | + * left-shift helper, which thus needs the negated shift count. | ||
96 | + */ | ||
97 | + constimm = tcg_const_i64(-a->shift); | ||
98 | + rm1 = tcg_temp_new_i64(); | ||
99 | + rm2 = tcg_temp_new_i64(); | ||
100 | + | ||
101 | + /* Load both inputs first to avoid potential overwrite if rm == rd */ | ||
102 | + neon_load_reg64(rm1, a->vm); | ||
103 | + neon_load_reg64(rm2, a->vm + 1); | ||
104 | + | ||
105 | + shiftfn(rm1, rm1, constimm); | ||
106 | + rd = tcg_temp_new_i32(); | ||
107 | + narrowfn(rd, cpu_env, rm1); | ||
108 | + neon_store_reg(a->vd, 0, rd); | ||
109 | + | ||
110 | + shiftfn(rm2, rm2, constimm); | ||
111 | + rd = tcg_temp_new_i32(); | ||
112 | + narrowfn(rd, cpu_env, rm2); | ||
113 | + neon_store_reg(a->vd, 1, rd); | ||
114 | + | ||
115 | + tcg_temp_free_i64(rm1); | ||
116 | + tcg_temp_free_i64(rm2); | ||
117 | + tcg_temp_free_i64(constimm); | ||
118 | + | ||
119 | + return true; | ||
120 | +} | ||
121 | + | ||
122 | +static bool do_2shift_narrow_32(DisasContext *s, arg_2reg_shift *a, | ||
123 | + NeonGenTwoOpFn *shiftfn, | ||
124 | + NeonGenNarrowEnvFn *narrowfn) | ||
125 | +{ | ||
126 | + /* 2-reg-and-shift narrowing-shift operations, size < 3 case */ | ||
127 | + TCGv_i32 constimm, rm1, rm2, rm3, rm4; | ||
128 | + TCGv_i64 rtmp; | ||
129 | + uint32_t imm; | ||
130 | + | ||
131 | + if (!arm_dc_feature(s, ARM_FEATURE_NEON)) { | ||
132 | + return false; | ||
133 | + } | ||
134 | + | ||
135 | + /* UNDEF accesses to D16-D31 if they don't exist. */ | ||
136 | + if (!dc_isar_feature(aa32_simd_r32, s) && | ||
137 | + ((a->vd | a->vm) & 0x10)) { | ||
138 | + return false; | ||
139 | + } | ||
140 | + | ||
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 | -- | ||
246 | 2.20.1 | ||
247 | |||
248 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Convert the VSHLL and VMOVL insns from the 2-reg-shift group | ||
2 | to decodetree. Since the loop always has two passes, we unroll | ||
3 | it to avoid the awkward reassignment of one TCGv to another. | ||
4 | 1 | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20200522145520.6778-8-peter.maydell@linaro.org | ||
8 | --- | ||
9 | target/arm/neon-dp.decode | 16 +++++++ | ||
10 | target/arm/translate-neon.inc.c | 81 +++++++++++++++++++++++++++++++++ | ||
11 | target/arm/translate.c | 46 +------------------ | ||
12 | 3 files changed, 99 insertions(+), 44 deletions(-) | ||
13 | |||
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 | ||
135 | index XXXXXXX..XXXXXXX 100644 | ||
136 | --- a/target/arm/translate.c | ||
137 | +++ b/target/arm/translate.c | ||
138 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
139 | case 7: /* VQSHL */ | ||
140 | case 8: /* VSHRN, VRSHRN, VQSHRUN, VQRSHRUN */ | ||
141 | case 9: /* VQSHRN, VQRSHRN */ | ||
142 | + case 10: /* VSHLL, including VMOVL */ | ||
143 | return 1; /* handled by decodetree */ | ||
144 | default: | ||
145 | break; | ||
146 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
147 | size--; | ||
148 | } | ||
149 | shift = (insn >> 16) & ((1 << (3 + size)) - 1); | ||
150 | - if (op == 10) { | ||
151 | - /* VSHLL, VMOVL */ | ||
152 | - if (q || (rd & 1)) { | ||
153 | - return 1; | ||
154 | - } | ||
155 | - tmp = neon_load_reg(rm, 0); | ||
156 | - tmp2 = neon_load_reg(rm, 1); | ||
157 | - for (pass = 0; pass < 2; pass++) { | ||
158 | - if (pass == 1) | ||
159 | - tmp = tmp2; | ||
160 | - | ||
161 | - gen_neon_widen(cpu_V0, tmp, size, u); | ||
162 | - | ||
163 | - if (shift != 0) { | ||
164 | - /* The shift is less than the width of the source | ||
165 | - type, so we can just shift the whole register. */ | ||
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 | -- | ||
199 | 2.20.1 | ||
200 | |||
201 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Convert the VCVT fixed-point conversion operations in the | ||
2 | Neon 2-regs-and-shift group to decodetree. | ||
3 | 1 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20200522145520.6778-9-peter.maydell@linaro.org | ||
7 | --- | ||
8 | target/arm/neon-dp.decode | 11 +++++ | ||
9 | target/arm/translate-neon.inc.c | 49 +++++++++++++++++++++ | ||
10 | target/arm/translate.c | 75 +-------------------------------- | ||
11 | 3 files changed, 62 insertions(+), 73 deletions(-) | ||
12 | |||
13 | diff --git a/target/arm/neon-dp.decode b/target/arm/neon-dp.decode | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/target/arm/neon-dp.decode | ||
16 | +++ b/target/arm/neon-dp.decode | ||
17 | @@ -XXX,XX +XXX,XX @@ VMINNM_fp_3s 1111 001 1 0 . 1 . .... .... 1111 ... 1 .... @3same_fp | ||
18 | @2reg_shll_b .... ... . . . 001 shift:3 .... .... 0 . . . .... \ | ||
19 | &2reg_shift vm=%vm_dp vd=%vd_dp size=0 q=0 | ||
20 | |||
21 | +# We use size=0 for fp32 and size=1 for fp16 to match the 3-same encodings. | ||
22 | +@2reg_vcvt .... ... . . . 1 ..... .... .... . q:1 . . .... \ | ||
23 | + &2reg_shift vm=%vm_dp vd=%vd_dp size=0 shift=%neon_rshift_i5 | ||
24 | + | ||
25 | VSHR_S_2sh 1111 001 0 1 . ...... .... 0000 . . . 1 .... @2reg_shr_d | ||
26 | VSHR_S_2sh 1111 001 0 1 . ...... .... 0000 . . . 1 .... @2reg_shr_s | ||
27 | VSHR_S_2sh 1111 001 0 1 . ...... .... 0000 . . . 1 .... @2reg_shr_h | ||
28 | @@ -XXX,XX +XXX,XX @@ VSHLL_S_2sh 1111 001 0 1 . ...... .... 1010 . 0 . 1 .... @2reg_shll_b | ||
29 | VSHLL_U_2sh 1111 001 1 1 . ...... .... 1010 . 0 . 1 .... @2reg_shll_s | ||
30 | VSHLL_U_2sh 1111 001 1 1 . ...... .... 1010 . 0 . 1 .... @2reg_shll_h | ||
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 | ||
41 | --- a/target/arm/translate-neon.inc.c | ||
42 | +++ b/target/arm/translate-neon.inc.c | ||
43 | @@ -XXX,XX +XXX,XX @@ static bool trans_VSHLL_U_2sh(DisasContext *s, arg_2reg_shift *a) | ||
44 | }; | ||
45 | return do_vshll_2sh(s, a, widenfn[a->size], true); | ||
46 | } | ||
47 | + | ||
48 | +static bool do_fp_2sh(DisasContext *s, arg_2reg_shift *a, | ||
49 | + NeonGenTwoSingleOPFn *fn) | ||
50 | +{ | ||
51 | + /* FP operations in 2-reg-and-shift group */ | ||
52 | + TCGv_i32 tmp, shiftv; | ||
53 | + TCGv_ptr fpstatus; | ||
54 | + int pass; | ||
55 | + | ||
56 | + if (!arm_dc_feature(s, ARM_FEATURE_NEON)) { | ||
57 | + return false; | ||
58 | + } | ||
59 | + | ||
60 | + /* UNDEF accesses to D16-D31 if they don't exist. */ | ||
61 | + if (!dc_isar_feature(aa32_simd_r32, s) && | ||
62 | + ((a->vd | a->vm) & 0x10)) { | ||
63 | + return false; | ||
64 | + } | ||
65 | + | ||
66 | + if ((a->vm | a->vd) & a->q) { | ||
67 | + return false; | ||
68 | + } | ||
69 | + | ||
70 | + if (!vfp_access_check(s)) { | ||
71 | + return true; | ||
72 | + } | ||
73 | + | ||
74 | + fpstatus = get_fpstatus_ptr(1); | ||
75 | + shiftv = tcg_const_i32(a->shift); | ||
76 | + for (pass = 0; pass < (a->q ? 4 : 2); pass++) { | ||
77 | + tmp = neon_load_reg(a->vm, pass); | ||
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 | |||
189 | -- | ||
190 | 2.20.1 | ||
191 | |||
192 | diff view generated by jsdifflib |