1 | Arm queue -- mostly the first slice of my Musca patches. | 1 | Big pullreq this week, though none of the new features are |
---|---|---|---|
2 | particularly earthshaking. Most of the bulk is from code cleanup | ||
3 | patches from me or rth. | ||
2 | 4 | ||
3 | thanks | 5 | thanks |
4 | -- PMM | 6 | -- PMM |
5 | 7 | ||
6 | The following changes since commit fc3dbb90f2eb069801bfb4cfe9cbc83cf9c5f4a9: | 8 | The following changes since commit b651b80822fa8cb66ca30087ac7fbc75507ae5d2: |
7 | 9 | ||
8 | Merge remote-tracking branch 'remotes/jnsnow/tags/bitmaps-pull-request' into staging (2019-02-21 13:09:33 +0000) | 10 | Merge remote-tracking branch 'remotes/vivier2/tags/linux-user-for-5.0-pull-request' into staging (2020-02-20 17:35:42 +0000) |
9 | 11 | ||
10 | are available in the Git repository at: | 12 | are available in the Git repository at: |
11 | 13 | ||
12 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20190221 | 14 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20200221 |
13 | 15 | ||
14 | for you to fetch changes up to 3733f80308d2a7f23f5e39b039e0547aba6c07f1: | 16 | for you to fetch changes up to 270a679b3f950d7c4c600f324aab8bff292d0971: |
15 | 17 | ||
16 | hw/arm/armsse: Make 0x5... alias region work for per-CPU devices (2019-02-21 18:17:48 +0000) | 18 | target/arm: Add missing checks for fpsp_v2 (2020-02-21 12:54:25 +0000) |
17 | 19 | ||
18 | ---------------------------------------------------------------- | 20 | ---------------------------------------------------------------- |
19 | target-arm queue: | 21 | target-arm queue: |
20 | * Model the Arm "Musca" development boards: "musca-a" and "musca-b1" | 22 | * aspeed/scu: Implement chip ID register |
21 | * Implement the ARMv8.3-JSConv extension | 23 | * hw/misc/iotkit-secctl: Fix writing to 'PPC Interrupt Clear' register |
22 | * v8M MPU should use background region as default, not always | 24 | * mainstone: Make providing flash images non-mandatory |
23 | * Stop unintentional sign extension in pmu_init | 25 | * z2: Make providing flash images non-mandatory |
26 | * Fix failures to flush SVE high bits after AdvSIMD INS/ZIP/UZP/TRN/TBL/TBX/EXT | ||
27 | * Minor performance improvement: spend less time recalculating hflags values | ||
28 | * Code cleanup to isar_feature function tests | ||
29 | * Implement ARMv8.1-PMU and ARMv8.4-PMU extensions | ||
30 | * Bugfix: correct handling of PMCR_EL0.LC bit | ||
31 | * Bugfix: correct definition of PMCRDP | ||
32 | * Correctly implement ACTLR2, HACTLR2 | ||
33 | * allwinner: Wire up USB ports | ||
34 | * Vectorize emulation of USHL, SSHL, PMUL* | ||
35 | * xilinx_spips: Correct the number of dummy cycles for the FAST_READ_4 cmd | ||
36 | * sh4: Fix PCI ISA IO memory subregion | ||
37 | * Code cleanup to use more isar_feature tests and fewer ARM_FEATURE_* tests | ||
24 | 38 | ||
25 | ---------------------------------------------------------------- | 39 | ---------------------------------------------------------------- |
26 | Aaron Lindsay OS (1): | 40 | Francisco Iglesias (1): |
27 | target/arm: Stop unintentional sign extension in pmu_init | 41 | xilinx_spips: Correct the number of dummy cycles for the FAST_READ_4 cmd |
28 | 42 | ||
29 | Peter Maydell (16): | 43 | Guenter Roeck (6): |
30 | hw/arm/armsse: Fix memory leak in error-exit path | 44 | mainstone: Make providing flash images non-mandatory |
31 | target/arm: v8M MPU should use background region as default, not always | 45 | z2: Make providing flash images non-mandatory |
32 | hw/misc/tz-ppc: Support having unused ports in the middle of the range | 46 | hw: usb: hcd-ohci: Move OHCISysBusState and TYPE_SYSBUS_OHCI to include file |
33 | hw/timer/pl031: Allow use as an embedded-struct device | 47 | hcd-ehci: Introduce "companion-enable" sysbus property |
34 | hw/timer/pl031: Convert to using trace events | 48 | arm: allwinner: Wire up USB ports |
35 | hw/char/pl011: Allow use as an embedded-struct device | 49 | sh4: Fix PCI ISA IO memory subregion |
36 | hw/char/pl011: Support all interrupt lines | ||
37 | hw/char/pl011: Use '0x' prefix when logging hex numbers | ||
38 | hw/arm/armsse: Document SRAM_ADDR_WIDTH property in header comment | ||
39 | hw/arm/armsse: Allow boards to specify init-svtor | ||
40 | hw/arm/musca.c: Implement models of the Musca-A and -B1 boards | ||
41 | hw/arm/musca: Add PPCs | ||
42 | hw/arm/musca: Add MPCs | ||
43 | hw/arm/musca: Wire up PL031 RTC | ||
44 | hw/arm/musca: Wire up PL011 UARTs | ||
45 | hw/arm/armsse: Make 0x5... alias region work for per-CPU devices | ||
46 | 50 | ||
47 | Richard Henderson (4): | 51 | Joel Stanley (2): |
48 | target/arm: Restructure disas_fp_int_conv | 52 | aspeed/scu: Create separate write callbacks |
49 | target/arm: Split out vfp_helper.c | 53 | aspeed/scu: Implement chip ID register |
50 | target/arm: Rearrange Floating-point data-processing (2 regs) | ||
51 | target/arm: Implement ARMv8.3-JSConv | ||
52 | 54 | ||
53 | hw/arm/Makefile.objs | 1 + | 55 | Peter Maydell (21): |
54 | target/arm/Makefile.objs | 2 +- | 56 | target/arm: Add _aa32_ to isar_feature functions testing 32-bit ID registers |
55 | include/hw/arm/armsse.h | 7 +- | 57 | target/arm: Check aa32_pan in take_aarch32_exception(), not aa64_pan |
56 | include/hw/char/pl011.h | 34 ++ | 58 | target/arm: Add isar_feature_any_fp16 and document naming/usage conventions |
57 | include/hw/misc/tz-ppc.h | 8 +- | 59 | target/arm: Define and use any_predinv isar_feature test |
58 | include/hw/timer/pl031.h | 44 ++ | 60 | target/arm: Factor out PMU register definitions |
59 | target/arm/cpu.h | 10 + | 61 | target/arm: Add and use FIELD definitions for ID_AA64DFR0_EL1 |
60 | target/arm/helper.h | 3 + | 62 | target/arm: Use FIELD macros for clearing ID_DFR0 PERFMON field |
61 | hw/arm/armsse.c | 44 +- | 63 | target/arm: Define an aa32_pmu_8_1 isar feature test function |
62 | hw/arm/musca.c | 669 ++++++++++++++++++++++ | 64 | target/arm: Add _aa64_ and _any_ versions of pmu_8_1 isar checks |
63 | hw/char/pl011.c | 81 +-- | 65 | target/arm: Stop assuming DBGDIDR always exists |
64 | hw/misc/tz-ppc.c | 32 ++ | 66 | target/arm: Move DBGDIDR into ARMISARegisters |
65 | hw/timer/pl031.c | 80 ++- | 67 | target/arm: Read debug-related ID registers from KVM |
66 | target/arm/cpu.c | 1 + | 68 | target/arm: Implement ARMv8.1-PMU extension |
67 | target/arm/cpu64.c | 2 + | 69 | target/arm: Implement ARMv8.4-PMU extension |
68 | target/arm/helper.c | 1072 +---------------------------------- | 70 | target/arm: Provide ARMv8.4-PMU in '-cpu max' |
69 | target/arm/translate-a64.c | 120 ++-- | 71 | target/arm: Correct definition of PMCRDP |
70 | target/arm/translate.c | 237 ++++---- | 72 | target/arm: Correct handling of PMCR_EL0.LC bit |
71 | target/arm/vfp_helper.c | 1176 +++++++++++++++++++++++++++++++++++++++ | 73 | target/arm: Test correct register in aa32_pan and aa32_ats1e1 checks |
72 | MAINTAINERS | 7 + | 74 | target/arm: Use isar_feature function for testing AA32HPD feature |
73 | default-configs/arm-softmmu.mak | 1 + | 75 | target/arm: Use FIELD_EX32 for testing 32-bit fields |
74 | hw/timer/trace-events | 6 + | 76 | target/arm: Correctly implement ACTLR2, HACTLR2 |
75 | 22 files changed, 2307 insertions(+), 1330 deletions(-) | ||
76 | create mode 100644 include/hw/timer/pl031.h | ||
77 | create mode 100644 hw/arm/musca.c | ||
78 | create mode 100644 target/arm/vfp_helper.c | ||
79 | 77 | ||
78 | Philippe Mathieu-Daudé (1): | ||
79 | hw/misc/iotkit-secctl: Fix writing to 'PPC Interrupt Clear' register | ||
80 | |||
81 | Richard Henderson (21): | ||
82 | target/arm: Flush high bits of sve register after AdvSIMD EXT | ||
83 | target/arm: Flush high bits of sve register after AdvSIMD TBL/TBX | ||
84 | target/arm: Flush high bits of sve register after AdvSIMD ZIP/UZP/TRN | ||
85 | target/arm: Flush high bits of sve register after AdvSIMD INS | ||
86 | target/arm: Use bit 55 explicitly for pauth | ||
87 | target/arm: Fix select for aa64_va_parameters_both | ||
88 | target/arm: Remove ttbr1_valid check from get_phys_addr_lpae | ||
89 | target/arm: Split out aa64_va_parameter_tbi, aa64_va_parameter_tbid | ||
90 | target/arm: Vectorize USHL and SSHL | ||
91 | target/arm: Convert PMUL.8 to gvec | ||
92 | target/arm: Convert PMULL.64 to gvec | ||
93 | target/arm: Convert PMULL.8 to gvec | ||
94 | target/arm: Rename isar_feature_aa32_simd_r32 | ||
95 | target/arm: Use isar_feature_aa32_simd_r32 more places | ||
96 | target/arm: Set MVFR0.FPSP for ARMv5 cpus | ||
97 | target/arm: Add isar_feature_aa32_simd_r16 | ||
98 | target/arm: Rename isar_feature_aa32_fpdp_v2 | ||
99 | target/arm: Add isar_feature_aa32_{fpsp_v2, fpsp_v3, fpdp_v3} | ||
100 | target/arm: Perform fpdp_v2 check first | ||
101 | target/arm: Replace ARM_FEATURE_VFP3 checks with fp{sp, dp}_v3 | ||
102 | target/arm: Add missing checks for fpsp_v2 | ||
103 | |||
104 | hw/usb/hcd-ohci.h | 16 ++ | ||
105 | include/hw/arm/allwinner-a10.h | 6 + | ||
106 | target/arm/cpu.h | 173 ++++++++++++--- | ||
107 | target/arm/helper-sve.h | 2 + | ||
108 | target/arm/helper.h | 21 +- | ||
109 | target/arm/internals.h | 47 +++- | ||
110 | target/arm/translate.h | 6 + | ||
111 | hw/arm/allwinner-a10.c | 43 ++++ | ||
112 | hw/arm/mainstone.c | 11 +- | ||
113 | hw/arm/z2.c | 6 - | ||
114 | hw/intc/armv7m_nvic.c | 30 +-- | ||
115 | hw/misc/aspeed_scu.c | 93 ++++++-- | ||
116 | hw/misc/iotkit-secctl.c | 2 +- | ||
117 | hw/sh4/sh_pci.c | 11 +- | ||
118 | hw/ssi/xilinx_spips.c | 2 +- | ||
119 | hw/usb/hcd-ehci-sysbus.c | 2 + | ||
120 | hw/usb/hcd-ohci.c | 15 -- | ||
121 | linux-user/arm/signal.c | 4 +- | ||
122 | linux-user/elfload.c | 4 +- | ||
123 | target/arm/arch_dump.c | 11 +- | ||
124 | target/arm/cpu.c | 175 +++++++-------- | ||
125 | target/arm/cpu64.c | 58 +++-- | ||
126 | target/arm/debug_helper.c | 6 +- | ||
127 | target/arm/helper.c | 472 +++++++++++++++++++++++------------------ | ||
128 | target/arm/kvm32.c | 25 +++ | ||
129 | target/arm/kvm64.c | 46 ++++ | ||
130 | target/arm/m_helper.c | 11 +- | ||
131 | target/arm/machine.c | 3 +- | ||
132 | target/arm/neon_helper.c | 117 ---------- | ||
133 | target/arm/pauth_helper.c | 3 +- | ||
134 | target/arm/translate-a64.c | 92 ++++---- | ||
135 | target/arm/translate-vfp.inc.c | 263 ++++++++++++++--------- | ||
136 | target/arm/translate.c | 356 ++++++++++++++++++++++++++----- | ||
137 | target/arm/vec_helper.c | 211 ++++++++++++++++++ | ||
138 | target/arm/vfp_helper.c | 2 +- | ||
139 | 35 files changed, 1564 insertions(+), 781 deletions(-) | ||
140 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Joel Stanley <joel@jms.id.au> | ||
1 | 2 | ||
3 | This splits the common write callback into separate ast2400 and ast2500 | ||
4 | implementations. This makes it clearer when implementing differing | ||
5 | behaviour. | ||
6 | |||
7 | Signed-off-by: Joel Stanley <joel@jms.id.au> | ||
8 | Reviewed-by: Andrew Jeffery <andrew@aj.id.au> | ||
9 | Reviewed-by: Cédric Le Goater <clg@kaod.org> | ||
10 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
11 | Message-id: 20200121013302.43839-2-joel@jms.id.au | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | --- | ||
14 | hw/misc/aspeed_scu.c | 80 +++++++++++++++++++++++++++++++------------- | ||
15 | 1 file changed, 57 insertions(+), 23 deletions(-) | ||
16 | |||
17 | diff --git a/hw/misc/aspeed_scu.c b/hw/misc/aspeed_scu.c | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/hw/misc/aspeed_scu.c | ||
20 | +++ b/hw/misc/aspeed_scu.c | ||
21 | @@ -XXX,XX +XXX,XX @@ static uint64_t aspeed_scu_read(void *opaque, hwaddr offset, unsigned size) | ||
22 | return s->regs[reg]; | ||
23 | } | ||
24 | |||
25 | -static void aspeed_scu_write(void *opaque, hwaddr offset, uint64_t data, | ||
26 | - unsigned size) | ||
27 | +static void aspeed_ast2400_scu_write(void *opaque, hwaddr offset, | ||
28 | + uint64_t data, unsigned size) | ||
29 | +{ | ||
30 | + AspeedSCUState *s = ASPEED_SCU(opaque); | ||
31 | + int reg = TO_REG(offset); | ||
32 | + | ||
33 | + if (reg >= ASPEED_SCU_NR_REGS) { | ||
34 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
35 | + "%s: Out-of-bounds write at offset 0x%" HWADDR_PRIx "\n", | ||
36 | + __func__, offset); | ||
37 | + return; | ||
38 | + } | ||
39 | + | ||
40 | + if (reg > PROT_KEY && reg < CPU2_BASE_SEG1 && | ||
41 | + !s->regs[PROT_KEY]) { | ||
42 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: SCU is locked!\n", __func__); | ||
43 | + } | ||
44 | + | ||
45 | + trace_aspeed_scu_write(offset, size, data); | ||
46 | + | ||
47 | + switch (reg) { | ||
48 | + case PROT_KEY: | ||
49 | + s->regs[reg] = (data == ASPEED_SCU_PROT_KEY) ? 1 : 0; | ||
50 | + return; | ||
51 | + case SILICON_REV: | ||
52 | + case FREQ_CNTR_EVAL: | ||
53 | + case VGA_SCRATCH1 ... VGA_SCRATCH8: | ||
54 | + case RNG_DATA: | ||
55 | + case FREE_CNTR4: | ||
56 | + case FREE_CNTR4_EXT: | ||
57 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
58 | + "%s: Write to read-only offset 0x%" HWADDR_PRIx "\n", | ||
59 | + __func__, offset); | ||
60 | + return; | ||
61 | + } | ||
62 | + | ||
63 | + s->regs[reg] = data; | ||
64 | +} | ||
65 | + | ||
66 | +static void aspeed_ast2500_scu_write(void *opaque, hwaddr offset, | ||
67 | + uint64_t data, unsigned size) | ||
68 | { | ||
69 | AspeedSCUState *s = ASPEED_SCU(opaque); | ||
70 | int reg = TO_REG(offset); | ||
71 | @@ -XXX,XX +XXX,XX @@ static void aspeed_scu_write(void *opaque, hwaddr offset, uint64_t data, | ||
72 | case PROT_KEY: | ||
73 | s->regs[reg] = (data == ASPEED_SCU_PROT_KEY) ? 1 : 0; | ||
74 | return; | ||
75 | - case CLK_SEL: | ||
76 | - s->regs[reg] = data; | ||
77 | - break; | ||
78 | case HW_STRAP1: | ||
79 | - if (ASPEED_IS_AST2500(s->regs[SILICON_REV])) { | ||
80 | - s->regs[HW_STRAP1] |= data; | ||
81 | - return; | ||
82 | - } | ||
83 | - /* Jump to assignment below */ | ||
84 | - break; | ||
85 | + s->regs[HW_STRAP1] |= data; | ||
86 | + return; | ||
87 | case SILICON_REV: | ||
88 | - if (ASPEED_IS_AST2500(s->regs[SILICON_REV])) { | ||
89 | - s->regs[HW_STRAP1] &= ~data; | ||
90 | - } else { | ||
91 | - qemu_log_mask(LOG_GUEST_ERROR, | ||
92 | - "%s: Write to read-only offset 0x%" HWADDR_PRIx "\n", | ||
93 | - __func__, offset); | ||
94 | - } | ||
95 | - /* Avoid assignment below, we've handled everything */ | ||
96 | + s->regs[HW_STRAP1] &= ~data; | ||
97 | return; | ||
98 | case FREQ_CNTR_EVAL: | ||
99 | case VGA_SCRATCH1 ... VGA_SCRATCH8: | ||
100 | @@ -XXX,XX +XXX,XX @@ static void aspeed_scu_write(void *opaque, hwaddr offset, uint64_t data, | ||
101 | s->regs[reg] = data; | ||
102 | } | ||
103 | |||
104 | -static const MemoryRegionOps aspeed_scu_ops = { | ||
105 | +static const MemoryRegionOps aspeed_ast2400_scu_ops = { | ||
106 | .read = aspeed_scu_read, | ||
107 | - .write = aspeed_scu_write, | ||
108 | + .write = aspeed_ast2400_scu_write, | ||
109 | + .endianness = DEVICE_LITTLE_ENDIAN, | ||
110 | + .valid.min_access_size = 4, | ||
111 | + .valid.max_access_size = 4, | ||
112 | + .valid.unaligned = false, | ||
113 | +}; | ||
114 | + | ||
115 | +static const MemoryRegionOps aspeed_ast2500_scu_ops = { | ||
116 | + .read = aspeed_scu_read, | ||
117 | + .write = aspeed_ast2500_scu_write, | ||
118 | .endianness = DEVICE_LITTLE_ENDIAN, | ||
119 | .valid.min_access_size = 4, | ||
120 | .valid.max_access_size = 4, | ||
121 | @@ -XXX,XX +XXX,XX @@ static void aspeed_2400_scu_class_init(ObjectClass *klass, void *data) | ||
122 | asc->calc_hpll = aspeed_2400_scu_calc_hpll; | ||
123 | asc->apb_divider = 2; | ||
124 | asc->nr_regs = ASPEED_SCU_NR_REGS; | ||
125 | - asc->ops = &aspeed_scu_ops; | ||
126 | + asc->ops = &aspeed_ast2400_scu_ops; | ||
127 | } | ||
128 | |||
129 | static const TypeInfo aspeed_2400_scu_info = { | ||
130 | @@ -XXX,XX +XXX,XX @@ static void aspeed_2500_scu_class_init(ObjectClass *klass, void *data) | ||
131 | asc->calc_hpll = aspeed_2500_scu_calc_hpll; | ||
132 | asc->apb_divider = 4; | ||
133 | asc->nr_regs = ASPEED_SCU_NR_REGS; | ||
134 | - asc->ops = &aspeed_scu_ops; | ||
135 | + asc->ops = &aspeed_ast2500_scu_ops; | ||
136 | } | ||
137 | |||
138 | static const TypeInfo aspeed_2500_scu_info = { | ||
139 | -- | ||
140 | 2.20.1 | ||
141 | |||
142 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Joel Stanley <joel@jms.id.au> | ||
1 | 2 | ||
3 | This returns a fixed but non-zero value for the chip id. | ||
4 | |||
5 | Signed-off-by: Joel Stanley <joel@jms.id.au> | ||
6 | Reviewed-by: Andrew Jeffery <andrew@aj.id.au> | ||
7 | Reviewed-by: Cédric Le Goater <clg@kaod.org> | ||
8 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
9 | Message-id: 20200121013302.43839-3-joel@jms.id.au | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | hw/misc/aspeed_scu.c | 13 +++++++++++++ | ||
13 | 1 file changed, 13 insertions(+) | ||
14 | |||
15 | diff --git a/hw/misc/aspeed_scu.c b/hw/misc/aspeed_scu.c | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/hw/misc/aspeed_scu.c | ||
18 | +++ b/hw/misc/aspeed_scu.c | ||
19 | @@ -XXX,XX +XXX,XX @@ | ||
20 | #define CPU2_BASE_SEG4 TO_REG(0x110) | ||
21 | #define CPU2_BASE_SEG5 TO_REG(0x114) | ||
22 | #define CPU2_CACHE_CTRL TO_REG(0x118) | ||
23 | +#define CHIP_ID0 TO_REG(0x150) | ||
24 | +#define CHIP_ID1 TO_REG(0x154) | ||
25 | #define UART_HPLL_CLK TO_REG(0x160) | ||
26 | #define PCIE_CTRL TO_REG(0x180) | ||
27 | #define BMC_MMIO_CTRL TO_REG(0x184) | ||
28 | @@ -XXX,XX +XXX,XX @@ | ||
29 | #define AST2600_HW_STRAP2_PROT TO_REG(0x518) | ||
30 | #define AST2600_RNG_CTRL TO_REG(0x524) | ||
31 | #define AST2600_RNG_DATA TO_REG(0x540) | ||
32 | +#define AST2600_CHIP_ID0 TO_REG(0x5B0) | ||
33 | +#define AST2600_CHIP_ID1 TO_REG(0x5B4) | ||
34 | |||
35 | #define AST2600_CLK TO_REG(0x40) | ||
36 | |||
37 | @@ -XXX,XX +XXX,XX @@ static const uint32_t ast2500_a1_resets[ASPEED_SCU_NR_REGS] = { | ||
38 | [CPU2_BASE_SEG1] = 0x80000000U, | ||
39 | [CPU2_BASE_SEG4] = 0x1E600000U, | ||
40 | [CPU2_BASE_SEG5] = 0xC0000000U, | ||
41 | + [CHIP_ID0] = 0x1234ABCDU, | ||
42 | + [CHIP_ID1] = 0x88884444U, | ||
43 | [UART_HPLL_CLK] = 0x00001903U, | ||
44 | [PCIE_CTRL] = 0x0000007BU, | ||
45 | [BMC_DEV_ID] = 0x00002402U | ||
46 | @@ -XXX,XX +XXX,XX @@ static void aspeed_ast2500_scu_write(void *opaque, hwaddr offset, | ||
47 | case RNG_DATA: | ||
48 | case FREE_CNTR4: | ||
49 | case FREE_CNTR4_EXT: | ||
50 | + case CHIP_ID0: | ||
51 | + case CHIP_ID1: | ||
52 | qemu_log_mask(LOG_GUEST_ERROR, | ||
53 | "%s: Write to read-only offset 0x%" HWADDR_PRIx "\n", | ||
54 | __func__, offset); | ||
55 | @@ -XXX,XX +XXX,XX @@ static void aspeed_ast2600_scu_write(void *opaque, hwaddr offset, | ||
56 | case AST2600_RNG_DATA: | ||
57 | case AST2600_SILICON_REV: | ||
58 | case AST2600_SILICON_REV2: | ||
59 | + case AST2600_CHIP_ID0: | ||
60 | + case AST2600_CHIP_ID1: | ||
61 | /* Add read only registers here */ | ||
62 | qemu_log_mask(LOG_GUEST_ERROR, | ||
63 | "%s: Write to read-only offset 0x%" HWADDR_PRIx "\n", | ||
64 | @@ -XXX,XX +XXX,XX @@ static const uint32_t ast2600_a0_resets[ASPEED_AST2600_SCU_NR_REGS] = { | ||
65 | [AST2600_CLK_STOP_CTRL2] = 0xFFF0FFF0, | ||
66 | [AST2600_SDRAM_HANDSHAKE] = 0x00000040, /* SoC completed DRAM init */ | ||
67 | [AST2600_HPLL_PARAM] = 0x1000405F, | ||
68 | + [AST2600_CHIP_ID0] = 0x1234ABCD, | ||
69 | + [AST2600_CHIP_ID1] = 0x88884444, | ||
70 | + | ||
71 | }; | ||
72 | |||
73 | static void aspeed_ast2600_scu_reset(DeviceState *dev) | ||
74 | -- | ||
75 | 2.20.1 | ||
76 | |||
77 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
1 | 2 | ||
3 | Fix warning reported by Clang static code analyzer: | ||
4 | |||
5 | CC hw/misc/iotkit-secctl.o | ||
6 | hw/misc/iotkit-secctl.c:343:9: warning: Value stored to 'value' is never read | ||
7 | value &= 0x00f000f3; | ||
8 | ^ ~~~~~~~~~~ | ||
9 | |||
10 | Fixes: b3717c23e1c | ||
11 | Reported-by: Clang Static Analyzer | ||
12 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
13 | Message-id: 20200217132922.24607-1-f4bug@amsat.org | ||
14 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
16 | --- | ||
17 | hw/misc/iotkit-secctl.c | 2 +- | ||
18 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
19 | |||
20 | diff --git a/hw/misc/iotkit-secctl.c b/hw/misc/iotkit-secctl.c | ||
21 | index XXXXXXX..XXXXXXX 100644 | ||
22 | --- a/hw/misc/iotkit-secctl.c | ||
23 | +++ b/hw/misc/iotkit-secctl.c | ||
24 | @@ -XXX,XX +XXX,XX @@ static MemTxResult iotkit_secctl_s_write(void *opaque, hwaddr addr, | ||
25 | qemu_set_irq(s->sec_resp_cfg, s->secrespcfg); | ||
26 | break; | ||
27 | case A_SECPPCINTCLR: | ||
28 | - value &= 0x00f000f3; | ||
29 | + s->secppcintstat &= ~(value & 0x00f000f3); | ||
30 | foreach_ppc(s, iotkit_secctl_ppc_update_irq_clear); | ||
31 | break; | ||
32 | case A_SECPPCINTEN: | ||
33 | -- | ||
34 | 2.20.1 | ||
35 | |||
36 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Guenter Roeck <linux@roeck-us.net> | ||
1 | 2 | ||
3 | Up to now, the mainstone machine only boots if two flash images are | ||
4 | provided. This is not really necessary; the machine can boot from initrd | ||
5 | or from SD without it. At the same time, having to provide dummy flash | ||
6 | images is a nuisance and does not add any real value. Make it optional. | ||
7 | |||
8 | Signed-off-by: Guenter Roeck <linux@roeck-us.net> | ||
9 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
10 | Message-id: 20200217210824.18513-1-linux@roeck-us.net | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | --- | ||
13 | hw/arm/mainstone.c | 11 +---------- | ||
14 | 1 file changed, 1 insertion(+), 10 deletions(-) | ||
15 | |||
16 | diff --git a/hw/arm/mainstone.c b/hw/arm/mainstone.c | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/hw/arm/mainstone.c | ||
19 | +++ b/hw/arm/mainstone.c | ||
20 | @@ -XXX,XX +XXX,XX @@ static void mainstone_common_init(MemoryRegion *address_space_mem, | ||
21 | /* There are two 32MiB flash devices on the board */ | ||
22 | for (i = 0; i < 2; i ++) { | ||
23 | dinfo = drive_get(IF_PFLASH, 0, i); | ||
24 | - if (!dinfo) { | ||
25 | - if (qtest_enabled()) { | ||
26 | - break; | ||
27 | - } | ||
28 | - error_report("Two flash images must be given with the " | ||
29 | - "'pflash' parameter"); | ||
30 | - exit(1); | ||
31 | - } | ||
32 | - | ||
33 | if (!pflash_cfi01_register(mainstone_flash_base[i], | ||
34 | i ? "mainstone.flash1" : "mainstone.flash0", | ||
35 | MAINSTONE_FLASH, | ||
36 | - blk_by_legacy_dinfo(dinfo), | ||
37 | + dinfo ? blk_by_legacy_dinfo(dinfo) : NULL, | ||
38 | sector_len, 4, 0, 0, 0, 0, be)) { | ||
39 | error_report("Error registering flash memory"); | ||
40 | exit(1); | ||
41 | -- | ||
42 | 2.20.1 | ||
43 | |||
44 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Guenter Roeck <linux@roeck-us.net> | ||
1 | 2 | ||
3 | Up to now, the z2 machine only boots if a flash image is provided. | ||
4 | This is not really necessary; the machine can boot from initrd or from | ||
5 | SD without it. At the same time, having to provide dummy flash images | ||
6 | is a nuisance and does not add any real value. Make it optional. | ||
7 | |||
8 | Signed-off-by: Guenter Roeck <linux@roeck-us.net> | ||
9 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
10 | Message-id: 20200217210903.18602-1-linux@roeck-us.net | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | --- | ||
13 | hw/arm/z2.c | 6 ------ | ||
14 | 1 file changed, 6 deletions(-) | ||
15 | |||
16 | diff --git a/hw/arm/z2.c b/hw/arm/z2.c | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/hw/arm/z2.c | ||
19 | +++ b/hw/arm/z2.c | ||
20 | @@ -XXX,XX +XXX,XX @@ static void z2_init(MachineState *machine) | ||
21 | be = 0; | ||
22 | #endif | ||
23 | dinfo = drive_get(IF_PFLASH, 0, 0); | ||
24 | - if (!dinfo && !qtest_enabled()) { | ||
25 | - error_report("Flash image must be given with the " | ||
26 | - "'pflash' parameter"); | ||
27 | - exit(1); | ||
28 | - } | ||
29 | - | ||
30 | if (!pflash_cfi01_register(Z2_FLASH_BASE, "z2.flash0", Z2_FLASH_SIZE, | ||
31 | dinfo ? blk_by_legacy_dinfo(dinfo) : NULL, | ||
32 | sector_len, 4, 0, 0, 0, 0, be)) { | ||
33 | -- | ||
34 | 2.20.1 | ||
35 | |||
36 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
1 | 2 | ||
3 | Writes to AdvSIMD registers flush the bits above 128. | ||
4 | |||
5 | Buglink: https://bugs.launchpad.net/bugs/1863247 | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20200214194643.23317-2-richard.henderson@linaro.org | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | target/arm/translate-a64.c | 1 + | ||
12 | 1 file changed, 1 insertion(+) | ||
13 | |||
14 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/target/arm/translate-a64.c | ||
17 | +++ b/target/arm/translate-a64.c | ||
18 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_ext(DisasContext *s, uint32_t insn) | ||
19 | tcg_temp_free_i64(tcg_resl); | ||
20 | write_vec_element(s, tcg_resh, rd, 1, MO_64); | ||
21 | tcg_temp_free_i64(tcg_resh); | ||
22 | + clear_vec_high(s, true, rd); | ||
23 | } | ||
24 | |||
25 | /* TBL/TBX | ||
26 | -- | ||
27 | 2.20.1 | ||
28 | |||
29 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
1 | 2 | ||
3 | Writes to AdvSIMD registers flush the bits above 128. | ||
4 | |||
5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20200214194643.23317-3-richard.henderson@linaro.org | ||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | --- | ||
10 | target/arm/translate-a64.c | 1 + | ||
11 | 1 file changed, 1 insertion(+) | ||
12 | |||
13 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/target/arm/translate-a64.c | ||
16 | +++ b/target/arm/translate-a64.c | ||
17 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_tb(DisasContext *s, uint32_t insn) | ||
18 | tcg_temp_free_i64(tcg_resl); | ||
19 | write_vec_element(s, tcg_resh, rd, 1, MO_64); | ||
20 | tcg_temp_free_i64(tcg_resh); | ||
21 | + clear_vec_high(s, true, rd); | ||
22 | } | ||
23 | |||
24 | /* ZIP/UZP/TRN | ||
25 | -- | ||
26 | 2.20.1 | ||
27 | |||
28 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
1 | 2 | ||
3 | Writes to AdvSIMD registers flush the bits above 128. | ||
4 | |||
5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20200214194643.23317-4-richard.henderson@linaro.org | ||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | --- | ||
10 | target/arm/translate-a64.c | 1 + | ||
11 | 1 file changed, 1 insertion(+) | ||
12 | |||
13 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/target/arm/translate-a64.c | ||
16 | +++ b/target/arm/translate-a64.c | ||
17 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_zip_trn(DisasContext *s, uint32_t insn) | ||
18 | tcg_temp_free_i64(tcg_resl); | ||
19 | write_vec_element(s, tcg_resh, rd, 1, MO_64); | ||
20 | tcg_temp_free_i64(tcg_resh); | ||
21 | + clear_vec_high(s, true, rd); | ||
22 | } | ||
23 | |||
24 | /* | ||
25 | -- | ||
26 | 2.20.1 | ||
27 | |||
28 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | For opcodes 0-5, move some if conditions into the structure | 3 | Writes to AdvSIMD registers flush the bits above 128. |
4 | of a switch statement. For opcodes 6 & 7, decode everything | ||
5 | at once with a second switch. | ||
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: 20190215192302.27855-2-richard.henderson@linaro.org | 6 | Message-id: 20200214194643.23317-5-richard.henderson@linaro.org |
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 9 | --- |
12 | target/arm/translate-a64.c | 94 ++++++++++++++++++++------------------ | 10 | target/arm/translate-a64.c | 6 ++++++ |
13 | 1 file changed, 49 insertions(+), 45 deletions(-) | 11 | 1 file changed, 6 insertions(+) |
14 | 12 | ||
15 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 13 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c |
16 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/translate-a64.c | 15 | --- a/target/arm/translate-a64.c |
18 | +++ b/target/arm/translate-a64.c | 16 | +++ b/target/arm/translate-a64.c |
19 | @@ -XXX,XX +XXX,XX @@ static void disas_fp_int_conv(DisasContext *s, uint32_t insn) | 17 | @@ -XXX,XX +XXX,XX @@ static void handle_simd_inse(DisasContext *s, int rd, int rn, |
20 | int type = extract32(insn, 22, 2); | 18 | write_vec_element(s, tmp, rd, dst_index, size); |
21 | bool sbit = extract32(insn, 29, 1); | 19 | |
22 | bool sf = extract32(insn, 31, 1); | 20 | tcg_temp_free_i64(tmp); |
23 | + bool itof = false; | ||
24 | |||
25 | if (sbit) { | ||
26 | - unallocated_encoding(s); | ||
27 | - return; | ||
28 | + goto do_unallocated; | ||
29 | } | ||
30 | |||
31 | - if (opcode > 5) { | ||
32 | - /* FMOV */ | ||
33 | - bool itof = opcode & 1; | ||
34 | - | ||
35 | - if (rmode >= 2) { | ||
36 | - unallocated_encoding(s); | ||
37 | - return; | ||
38 | - } | ||
39 | - | ||
40 | - switch (sf << 3 | type << 1 | rmode) { | ||
41 | - case 0x0: /* 32 bit */ | ||
42 | - case 0xa: /* 64 bit */ | ||
43 | - case 0xd: /* 64 bit to top half of quad */ | ||
44 | - break; | ||
45 | - case 0x6: /* 16-bit float, 32-bit int */ | ||
46 | - case 0xe: /* 16-bit float, 64-bit int */ | ||
47 | - if (dc_isar_feature(aa64_fp16, s)) { | ||
48 | - break; | ||
49 | - } | ||
50 | - /* fallthru */ | ||
51 | - default: | ||
52 | - /* all other sf/type/rmode combinations are invalid */ | ||
53 | - unallocated_encoding(s); | ||
54 | - return; | ||
55 | - } | ||
56 | - | ||
57 | - if (!fp_access_check(s)) { | ||
58 | - return; | ||
59 | - } | ||
60 | - handle_fmov(s, rd, rn, type, itof); | ||
61 | - } else { | ||
62 | - /* actual FP conversions */ | ||
63 | - bool itof = extract32(opcode, 1, 1); | ||
64 | - | ||
65 | - if (rmode != 0 && opcode > 1) { | ||
66 | - unallocated_encoding(s); | ||
67 | - return; | ||
68 | + switch (opcode) { | ||
69 | + case 2: /* SCVTF */ | ||
70 | + case 3: /* UCVTF */ | ||
71 | + itof = true; | ||
72 | + /* fallthru */ | ||
73 | + case 4: /* FCVTAS */ | ||
74 | + case 5: /* FCVTAU */ | ||
75 | + if (rmode != 0) { | ||
76 | + goto do_unallocated; | ||
77 | } | ||
78 | + /* fallthru */ | ||
79 | + case 0: /* FCVT[NPMZ]S */ | ||
80 | + case 1: /* FCVT[NPMZ]U */ | ||
81 | switch (type) { | ||
82 | case 0: /* float32 */ | ||
83 | case 1: /* float64 */ | ||
84 | break; | ||
85 | case 3: /* float16 */ | ||
86 | - if (dc_isar_feature(aa64_fp16, s)) { | ||
87 | - break; | ||
88 | + if (!dc_isar_feature(aa64_fp16, s)) { | ||
89 | + goto do_unallocated; | ||
90 | } | ||
91 | - /* fallthru */ | ||
92 | + break; | ||
93 | default: | ||
94 | - unallocated_encoding(s); | ||
95 | - return; | ||
96 | + goto do_unallocated; | ||
97 | } | ||
98 | - | ||
99 | if (!fp_access_check(s)) { | ||
100 | return; | ||
101 | } | ||
102 | handle_fpfpcvt(s, rd, rn, opcode, itof, rmode, 64, sf, type); | ||
103 | + break; | ||
104 | + | 21 | + |
105 | + default: | 22 | + /* INS is considered a 128-bit write for SVE. */ |
106 | + switch (sf << 7 | type << 5 | rmode << 3 | opcode) { | 23 | + clear_vec_high(s, true, rd); |
107 | + case 0b01100110: /* FMOV half <-> 32-bit int */ | 24 | } |
108 | + case 0b01100111: | 25 | |
109 | + case 0b11100110: /* FMOV half <-> 64-bit int */ | 26 | |
110 | + case 0b11100111: | 27 | @@ -XXX,XX +XXX,XX @@ static void handle_simd_insg(DisasContext *s, int rd, int rn, int imm5) |
111 | + if (!dc_isar_feature(aa64_fp16, s)) { | 28 | |
112 | + goto do_unallocated; | 29 | idx = extract32(imm5, 1 + size, 4 - size); |
113 | + } | 30 | write_vec_element(s, cpu_reg(s, rn), rd, idx, size); |
114 | + /* fallthru */ | ||
115 | + case 0b00000110: /* FMOV 32-bit */ | ||
116 | + case 0b00000111: | ||
117 | + case 0b10100110: /* FMOV 64-bit */ | ||
118 | + case 0b10100111: | ||
119 | + case 0b11001110: /* FMOV top half of 128-bit */ | ||
120 | + case 0b11001111: | ||
121 | + if (!fp_access_check(s)) { | ||
122 | + return; | ||
123 | + } | ||
124 | + itof = opcode & 1; | ||
125 | + handle_fmov(s, rd, rn, type, itof); | ||
126 | + break; | ||
127 | + | 31 | + |
128 | + default: | 32 | + /* INS is considered a 128-bit write for SVE. */ |
129 | + do_unallocated: | 33 | + clear_vec_high(s, true, rd); |
130 | + unallocated_encoding(s); | ||
131 | + return; | ||
132 | + } | ||
133 | + break; | ||
134 | } | ||
135 | } | 34 | } |
136 | 35 | ||
36 | /* | ||
137 | -- | 37 | -- |
138 | 2.20.1 | 38 | 2.20.1 |
139 | 39 | ||
140 | 40 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
1 | 2 | ||
3 | The psuedocode in aarch64/functions/pac/auth/Auth and | ||
4 | aarch64/functions/pac/strip/Strip always uses bit 55 for | ||
5 | extfield and do not consider if the current regime has 2 ranges. | ||
6 | |||
7 | Suggested-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Message-id: 20200216194343.21331-2-richard.henderson@linaro.org | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | --- | ||
13 | target/arm/pauth_helper.c | 3 ++- | ||
14 | 1 file changed, 2 insertions(+), 1 deletion(-) | ||
15 | |||
16 | diff --git a/target/arm/pauth_helper.c b/target/arm/pauth_helper.c | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/target/arm/pauth_helper.c | ||
19 | +++ b/target/arm/pauth_helper.c | ||
20 | @@ -XXX,XX +XXX,XX @@ static uint64_t pauth_addpac(CPUARMState *env, uint64_t ptr, uint64_t modifier, | ||
21 | |||
22 | static uint64_t pauth_original_ptr(uint64_t ptr, ARMVAParameters param) | ||
23 | { | ||
24 | - uint64_t extfield = -param.select; | ||
25 | + /* Note that bit 55 is used whether or not the regime has 2 ranges. */ | ||
26 | + uint64_t extfield = sextract64(ptr, 55, 1); | ||
27 | int bot_pac_bit = 64 - param.tsz; | ||
28 | int top_pac_bit = 64 - 8 * param.tbi; | ||
29 | |||
30 | -- | ||
31 | 2.20.1 | ||
32 | |||
33 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
1 | 2 | ||
3 | Select should always be 0 for a regime with one range. | ||
4 | |||
5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20200216194343.21331-3-richard.henderson@linaro.org | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | --- | ||
10 | target/arm/helper.c | 46 +++++++++++++++++++++++---------------------- | ||
11 | 1 file changed, 24 insertions(+), 22 deletions(-) | ||
12 | |||
13 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/target/arm/helper.c | ||
16 | +++ b/target/arm/helper.c | ||
17 | @@ -XXX,XX +XXX,XX @@ ARMVAParameters aa64_va_parameters_both(CPUARMState *env, uint64_t va, | ||
18 | bool tbi, tbid, epd, hpd, using16k, using64k; | ||
19 | int select, tsz; | ||
20 | |||
21 | - /* | ||
22 | - * Bit 55 is always between the two regions, and is canonical for | ||
23 | - * determining if address tagging is enabled. | ||
24 | - */ | ||
25 | - select = extract64(va, 55, 1); | ||
26 | - | ||
27 | if (!regime_has_2_ranges(mmu_idx)) { | ||
28 | + select = 0; | ||
29 | tsz = extract32(tcr, 0, 6); | ||
30 | using64k = extract32(tcr, 14, 1); | ||
31 | using16k = extract32(tcr, 15, 1); | ||
32 | @@ -XXX,XX +XXX,XX @@ ARMVAParameters aa64_va_parameters_both(CPUARMState *env, uint64_t va, | ||
33 | tbid = extract32(tcr, 29, 1); | ||
34 | } | ||
35 | epd = false; | ||
36 | - } else if (!select) { | ||
37 | - tsz = extract32(tcr, 0, 6); | ||
38 | - epd = extract32(tcr, 7, 1); | ||
39 | - using64k = extract32(tcr, 14, 1); | ||
40 | - using16k = extract32(tcr, 15, 1); | ||
41 | - tbi = extract64(tcr, 37, 1); | ||
42 | - hpd = extract64(tcr, 41, 1); | ||
43 | - tbid = extract64(tcr, 51, 1); | ||
44 | } else { | ||
45 | - int tg = extract32(tcr, 30, 2); | ||
46 | - using16k = tg == 1; | ||
47 | - using64k = tg == 3; | ||
48 | - tsz = extract32(tcr, 16, 6); | ||
49 | - epd = extract32(tcr, 23, 1); | ||
50 | - tbi = extract64(tcr, 38, 1); | ||
51 | - hpd = extract64(tcr, 42, 1); | ||
52 | - tbid = extract64(tcr, 52, 1); | ||
53 | + /* | ||
54 | + * Bit 55 is always between the two regions, and is canonical for | ||
55 | + * determining if address tagging is enabled. | ||
56 | + */ | ||
57 | + select = extract64(va, 55, 1); | ||
58 | + if (!select) { | ||
59 | + tsz = extract32(tcr, 0, 6); | ||
60 | + epd = extract32(tcr, 7, 1); | ||
61 | + using64k = extract32(tcr, 14, 1); | ||
62 | + using16k = extract32(tcr, 15, 1); | ||
63 | + tbi = extract64(tcr, 37, 1); | ||
64 | + hpd = extract64(tcr, 41, 1); | ||
65 | + tbid = extract64(tcr, 51, 1); | ||
66 | + } else { | ||
67 | + int tg = extract32(tcr, 30, 2); | ||
68 | + using16k = tg == 1; | ||
69 | + using64k = tg == 3; | ||
70 | + tsz = extract32(tcr, 16, 6); | ||
71 | + epd = extract32(tcr, 23, 1); | ||
72 | + tbi = extract64(tcr, 38, 1); | ||
73 | + hpd = extract64(tcr, 42, 1); | ||
74 | + tbid = extract64(tcr, 52, 1); | ||
75 | + } | ||
76 | } | ||
77 | tsz = MIN(tsz, 39); /* TODO: ARMv8.4-TTST */ | ||
78 | tsz = MAX(tsz, 16); /* TODO: ARMv8.2-LVA */ | ||
79 | -- | ||
80 | 2.20.1 | ||
81 | |||
82 | diff view generated by jsdifflib |
1 | From: Aaron Lindsay OS <aaron@os.amperecomputing.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | This was introduced by | 3 | Now that aa64_va_parameters_both sets select based on the number |
4 | commit bf8d09694ccc07487cd73d7562081fdaec3370c8 | 4 | of ranges in the regime, the ttbr1_valid check is redundant. |
5 | target/arm: Don't clear supported PMU events when initializing PMCEID1 | ||
6 | and identified by Coverity (CID 1398645). | ||
7 | 5 | ||
8 | Signed-off-by: Aaron Lindsay <aaron@os.amperecomputing.com> | 6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
9 | Reported-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Message-id: 20200216194343.21331-4-richard.henderson@linaro.org |
10 | Message-id: 20190219144621.450-1-aaron@os.amperecomputing.com | ||
11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | --- | 10 | --- |
14 | target/arm/helper.c | 2 +- | 11 | target/arm/helper.c | 6 +----- |
15 | 1 file changed, 1 insertion(+), 1 deletion(-) | 12 | 1 file changed, 1 insertion(+), 5 deletions(-) |
16 | 13 | ||
17 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 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/helper.c | 16 | --- a/target/arm/helper.c |
20 | +++ b/target/arm/helper.c | 17 | +++ b/target/arm/helper.c |
21 | @@ -XXX,XX +XXX,XX @@ void pmu_init(ARMCPU *cpu) | 18 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, target_ulong address, |
22 | 19 | TCR *tcr = regime_tcr(env, mmu_idx); | |
23 | if (cnt->supported(&cpu->env)) { | 20 | int ap, ns, xn, pxn; |
24 | supported_event_map[cnt->number] = i; | 21 | uint32_t el = regime_el(env, mmu_idx); |
25 | - uint64_t event_mask = 1 << (cnt->number & 0x1f); | 22 | - bool ttbr1_valid; |
26 | + uint64_t event_mask = 1ULL << (cnt->number & 0x1f); | 23 | uint64_t descaddrmask; |
27 | if (cnt->number & 0x20) { | 24 | bool aarch64 = arm_el_is_aa64(env, el); |
28 | cpu->pmceid1 |= event_mask; | 25 | bool guarded = false; |
29 | } else { | 26 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, target_ulong address, |
27 | param = aa64_va_parameters(env, address, mmu_idx, | ||
28 | access_type != MMU_INST_FETCH); | ||
29 | level = 0; | ||
30 | - ttbr1_valid = regime_has_2_ranges(mmu_idx); | ||
31 | addrsize = 64 - 8 * param.tbi; | ||
32 | inputsize = 64 - param.tsz; | ||
33 | } else { | ||
34 | param = aa32_va_parameters(env, address, mmu_idx); | ||
35 | level = 1; | ||
36 | - /* There is no TTBR1 for EL2 */ | ||
37 | - ttbr1_valid = (el != 2); | ||
38 | addrsize = (mmu_idx == ARMMMUIdx_Stage2 ? 40 : 32); | ||
39 | inputsize = addrsize - param.tsz; | ||
40 | } | ||
41 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, target_ulong address, | ||
42 | if (inputsize < addrsize) { | ||
43 | target_ulong top_bits = sextract64(address, inputsize, | ||
44 | addrsize - inputsize); | ||
45 | - if (-top_bits != param.select || (param.select && !ttbr1_valid)) { | ||
46 | + if (-top_bits != param.select) { | ||
47 | /* The gap between the two regions is a Translation fault */ | ||
48 | fault_type = ARMFault_Translation; | ||
49 | goto do_fault; | ||
30 | -- | 50 | -- |
31 | 2.20.1 | 51 | 2.20.1 |
32 | 52 | ||
33 | 53 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
1 | 2 | ||
3 | For the purpose of rebuild_hflags_a64, we do not need to compute | ||
4 | all of the va parameters, only tbi. Moreover, we can compute them | ||
5 | in a form that is more useful to storing in hflags. | ||
6 | |||
7 | This eliminates the need for aa64_va_parameter_both, so fold that | ||
8 | in to aa64_va_parameter. The remaining calls to aa64_va_parameter | ||
9 | are in get_phys_addr_lpae and in pauth_helper.c. | ||
10 | |||
11 | This reduces the total cpu consumption of aa64_va_parameter in a | ||
12 | kernel boot plus a kvm guest kernel boot from 3% to 0.5%. | ||
13 | |||
14 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
15 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
16 | Message-id: 20200216194343.21331-5-richard.henderson@linaro.org | ||
17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
18 | --- | ||
19 | target/arm/internals.h | 3 -- | ||
20 | target/arm/helper.c | 68 +++++++++++++++++++++++------------------- | ||
21 | 2 files changed, 37 insertions(+), 34 deletions(-) | ||
22 | |||
23 | diff --git a/target/arm/internals.h b/target/arm/internals.h | ||
24 | index XXXXXXX..XXXXXXX 100644 | ||
25 | --- a/target/arm/internals.h | ||
26 | +++ b/target/arm/internals.h | ||
27 | @@ -XXX,XX +XXX,XX @@ typedef struct ARMVAParameters { | ||
28 | unsigned tsz : 8; | ||
29 | unsigned select : 1; | ||
30 | bool tbi : 1; | ||
31 | - bool tbid : 1; | ||
32 | bool epd : 1; | ||
33 | bool hpd : 1; | ||
34 | bool using16k : 1; | ||
35 | bool using64k : 1; | ||
36 | } ARMVAParameters; | ||
37 | |||
38 | -ARMVAParameters aa64_va_parameters_both(CPUARMState *env, uint64_t va, | ||
39 | - ARMMMUIdx mmu_idx); | ||
40 | ARMVAParameters aa64_va_parameters(CPUARMState *env, uint64_t va, | ||
41 | ARMMMUIdx mmu_idx, bool data); | ||
42 | |||
43 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
44 | index XXXXXXX..XXXXXXX 100644 | ||
45 | --- a/target/arm/helper.c | ||
46 | +++ b/target/arm/helper.c | ||
47 | @@ -XXX,XX +XXX,XX @@ static uint8_t convert_stage2_attrs(CPUARMState *env, uint8_t s2attrs) | ||
48 | } | ||
49 | #endif /* !CONFIG_USER_ONLY */ | ||
50 | |||
51 | -ARMVAParameters aa64_va_parameters_both(CPUARMState *env, uint64_t va, | ||
52 | - ARMMMUIdx mmu_idx) | ||
53 | +static int aa64_va_parameter_tbi(uint64_t tcr, ARMMMUIdx mmu_idx) | ||
54 | +{ | ||
55 | + if (regime_has_2_ranges(mmu_idx)) { | ||
56 | + return extract64(tcr, 37, 2); | ||
57 | + } else if (mmu_idx == ARMMMUIdx_Stage2) { | ||
58 | + return 0; /* VTCR_EL2 */ | ||
59 | + } else { | ||
60 | + return extract32(tcr, 20, 1); | ||
61 | + } | ||
62 | +} | ||
63 | + | ||
64 | +static int aa64_va_parameter_tbid(uint64_t tcr, ARMMMUIdx mmu_idx) | ||
65 | +{ | ||
66 | + if (regime_has_2_ranges(mmu_idx)) { | ||
67 | + return extract64(tcr, 51, 2); | ||
68 | + } else if (mmu_idx == ARMMMUIdx_Stage2) { | ||
69 | + return 0; /* VTCR_EL2 */ | ||
70 | + } else { | ||
71 | + return extract32(tcr, 29, 1); | ||
72 | + } | ||
73 | +} | ||
74 | + | ||
75 | +ARMVAParameters aa64_va_parameters(CPUARMState *env, uint64_t va, | ||
76 | + ARMMMUIdx mmu_idx, bool data) | ||
77 | { | ||
78 | uint64_t tcr = regime_tcr(env, mmu_idx)->raw_tcr; | ||
79 | - bool tbi, tbid, epd, hpd, using16k, using64k; | ||
80 | - int select, tsz; | ||
81 | + bool epd, hpd, using16k, using64k; | ||
82 | + int select, tsz, tbi; | ||
83 | |||
84 | if (!regime_has_2_ranges(mmu_idx)) { | ||
85 | select = 0; | ||
86 | @@ -XXX,XX +XXX,XX @@ ARMVAParameters aa64_va_parameters_both(CPUARMState *env, uint64_t va, | ||
87 | using16k = extract32(tcr, 15, 1); | ||
88 | if (mmu_idx == ARMMMUIdx_Stage2) { | ||
89 | /* VTCR_EL2 */ | ||
90 | - tbi = tbid = hpd = false; | ||
91 | + hpd = false; | ||
92 | } else { | ||
93 | - tbi = extract32(tcr, 20, 1); | ||
94 | hpd = extract32(tcr, 24, 1); | ||
95 | - tbid = extract32(tcr, 29, 1); | ||
96 | } | ||
97 | epd = false; | ||
98 | } else { | ||
99 | @@ -XXX,XX +XXX,XX @@ ARMVAParameters aa64_va_parameters_both(CPUARMState *env, uint64_t va, | ||
100 | epd = extract32(tcr, 7, 1); | ||
101 | using64k = extract32(tcr, 14, 1); | ||
102 | using16k = extract32(tcr, 15, 1); | ||
103 | - tbi = extract64(tcr, 37, 1); | ||
104 | hpd = extract64(tcr, 41, 1); | ||
105 | - tbid = extract64(tcr, 51, 1); | ||
106 | } else { | ||
107 | int tg = extract32(tcr, 30, 2); | ||
108 | using16k = tg == 1; | ||
109 | using64k = tg == 3; | ||
110 | tsz = extract32(tcr, 16, 6); | ||
111 | epd = extract32(tcr, 23, 1); | ||
112 | - tbi = extract64(tcr, 38, 1); | ||
113 | hpd = extract64(tcr, 42, 1); | ||
114 | - tbid = extract64(tcr, 52, 1); | ||
115 | } | ||
116 | } | ||
117 | tsz = MIN(tsz, 39); /* TODO: ARMv8.4-TTST */ | ||
118 | tsz = MAX(tsz, 16); /* TODO: ARMv8.2-LVA */ | ||
119 | |||
120 | + /* Present TBI as a composite with TBID. */ | ||
121 | + tbi = aa64_va_parameter_tbi(tcr, mmu_idx); | ||
122 | + if (!data) { | ||
123 | + tbi &= ~aa64_va_parameter_tbid(tcr, mmu_idx); | ||
124 | + } | ||
125 | + tbi = (tbi >> select) & 1; | ||
126 | + | ||
127 | return (ARMVAParameters) { | ||
128 | .tsz = tsz, | ||
129 | .select = select, | ||
130 | .tbi = tbi, | ||
131 | - .tbid = tbid, | ||
132 | .epd = epd, | ||
133 | .hpd = hpd, | ||
134 | .using16k = using16k, | ||
135 | @@ -XXX,XX +XXX,XX @@ ARMVAParameters aa64_va_parameters_both(CPUARMState *env, uint64_t va, | ||
136 | }; | ||
137 | } | ||
138 | |||
139 | -ARMVAParameters aa64_va_parameters(CPUARMState *env, uint64_t va, | ||
140 | - ARMMMUIdx mmu_idx, bool data) | ||
141 | -{ | ||
142 | - ARMVAParameters ret = aa64_va_parameters_both(env, va, mmu_idx); | ||
143 | - | ||
144 | - /* Present TBI as a composite with TBID. */ | ||
145 | - ret.tbi &= (data || !ret.tbid); | ||
146 | - return ret; | ||
147 | -} | ||
148 | - | ||
149 | #ifndef CONFIG_USER_ONLY | ||
150 | static ARMVAParameters aa32_va_parameters(CPUARMState *env, uint32_t va, | ||
151 | ARMMMUIdx mmu_idx) | ||
152 | @@ -XXX,XX +XXX,XX @@ static uint32_t rebuild_hflags_a64(CPUARMState *env, int el, int fp_el, | ||
153 | { | ||
154 | uint32_t flags = rebuild_hflags_aprofile(env); | ||
155 | ARMMMUIdx stage1 = stage_1_mmu_idx(mmu_idx); | ||
156 | - ARMVAParameters p0 = aa64_va_parameters_both(env, 0, stage1); | ||
157 | + uint64_t tcr = regime_tcr(env, mmu_idx)->raw_tcr; | ||
158 | uint64_t sctlr; | ||
159 | int tbii, tbid; | ||
160 | |||
161 | flags = FIELD_DP32(flags, TBFLAG_ANY, AARCH64_STATE, 1); | ||
162 | |||
163 | /* Get control bits for tagged addresses. */ | ||
164 | - if (regime_has_2_ranges(mmu_idx)) { | ||
165 | - ARMVAParameters p1 = aa64_va_parameters_both(env, -1, stage1); | ||
166 | - tbid = (p1.tbi << 1) | p0.tbi; | ||
167 | - tbii = tbid & ~((p1.tbid << 1) | p0.tbid); | ||
168 | - } else { | ||
169 | - tbid = p0.tbi; | ||
170 | - tbii = tbid & !p0.tbid; | ||
171 | - } | ||
172 | + tbid = aa64_va_parameter_tbi(tcr, mmu_idx); | ||
173 | + tbii = tbid & ~aa64_va_parameter_tbid(tcr, mmu_idx); | ||
174 | |||
175 | flags = FIELD_DP32(flags, TBFLAG_A64, TBII, tbii); | ||
176 | flags = FIELD_DP32(flags, TBFLAG_A64, TBID, tbid); | ||
177 | -- | ||
178 | 2.20.1 | ||
179 | |||
180 | diff view generated by jsdifflib |
1 | Create a new include file for the pl031's device struct, | 1 | Enforce a convention that an isar_feature function that tests a |
---|---|---|---|
2 | type macros, etc, so that it can be instantiated using | 2 | 32-bit ID register always has _aa32_ in its name, and one that |
3 | the "embedded struct" coding style. | 3 | tests a 64-bit ID register always has _aa64_ in its name. |
4 | We already follow this except for three cases: thumb_div, | ||
5 | arm_div and jazelle, which all need _aa32_ adding. | ||
4 | 6 | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 7 | (As noted in the comment, isar_feature_aa32_fp16_arith() |
8 | is an exception in that it currently tests ID_AA64PFR0_EL1, | ||
9 | but will switch to MVFR1 once we've properly implemented | ||
10 | FP16 for AArch32.) | ||
11 | |||
6 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 12 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> |
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 13 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
15 | Message-id: 20200214175116.9164-2-peter.maydell@linaro.org | ||
8 | --- | 16 | --- |
9 | include/hw/timer/pl031.h | 44 ++++++++++++++++++++++++++++++++++++++++ | 17 | target/arm/cpu.h | 13 ++++++++++--- |
10 | hw/timer/pl031.c | 25 +---------------------- | 18 | target/arm/internals.h | 2 +- |
11 | MAINTAINERS | 1 + | 19 | linux-user/elfload.c | 4 ++-- |
12 | 3 files changed, 46 insertions(+), 24 deletions(-) | 20 | target/arm/cpu.c | 6 ++++-- |
13 | create mode 100644 include/hw/timer/pl031.h | 21 | target/arm/helper.c | 2 +- |
22 | target/arm/translate.c | 6 +++--- | ||
23 | 6 files changed, 21 insertions(+), 12 deletions(-) | ||
14 | 24 | ||
15 | diff --git a/include/hw/timer/pl031.h b/include/hw/timer/pl031.h | 25 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
16 | new file mode 100644 | 26 | index XXXXXXX..XXXXXXX 100644 |
17 | index XXXXXXX..XXXXXXX | 27 | --- a/target/arm/cpu.h |
18 | --- /dev/null | 28 | +++ b/target/arm/cpu.h |
19 | +++ b/include/hw/timer/pl031.h | 29 | @@ -XXX,XX +XXX,XX @@ static inline uint64_t *aa64_vfp_qreg(CPUARMState *env, unsigned regno) |
20 | @@ -XXX,XX +XXX,XX @@ | 30 | /* Shared between translate-sve.c and sve_helper.c. */ |
31 | extern const uint64_t pred_esz_masks[4]; | ||
32 | |||
21 | +/* | 33 | +/* |
22 | + * ARM AMBA PrimeCell PL031 RTC | 34 | + * Naming convention for isar_feature functions: |
23 | + * | 35 | + * Functions which test 32-bit ID registers should have _aa32_ in |
24 | + * Copyright (c) 2007 CodeSourcery | 36 | + * their name. Functions which test 64-bit ID registers should have |
25 | + * | 37 | + * _aa64_ in their name. |
26 | + * This file is free software; you can redistribute it and/or modify | ||
27 | + * it under the terms of the GNU General Public License version 2 as | ||
28 | + * published by the Free Software Foundation. | ||
29 | + * | ||
30 | + * Contributions after 2012-01-13 are licensed under the terms of the | ||
31 | + * GNU GPL, version 2 or (at your option) any later version. | ||
32 | + */ | 38 | + */ |
33 | + | 39 | + |
34 | +#ifndef HW_TIMER_PL031 | 40 | /* |
35 | +#define HW_TIMER_PL031 | 41 | * 32-bit feature tests via id registers. |
36 | + | 42 | */ |
37 | +#include "hw/sysbus.h" | 43 | -static inline bool isar_feature_thumb_div(const ARMISARegisters *id) |
38 | + | 44 | +static inline bool isar_feature_aa32_thumb_div(const ARMISARegisters *id) |
39 | +#define TYPE_PL031 "pl031" | 45 | { |
40 | +#define PL031(obj) OBJECT_CHECK(PL031State, (obj), TYPE_PL031) | 46 | return FIELD_EX32(id->id_isar0, ID_ISAR0, DIVIDE) != 0; |
41 | + | 47 | } |
42 | +typedef struct PL031State { | 48 | |
43 | + SysBusDevice parent_obj; | 49 | -static inline bool isar_feature_arm_div(const ARMISARegisters *id) |
44 | + | 50 | +static inline bool isar_feature_aa32_arm_div(const ARMISARegisters *id) |
45 | + MemoryRegion iomem; | 51 | { |
46 | + QEMUTimer *timer; | 52 | return FIELD_EX32(id->id_isar0, ID_ISAR0, DIVIDE) > 1; |
47 | + qemu_irq irq; | 53 | } |
48 | + | 54 | |
49 | + /* | 55 | -static inline bool isar_feature_jazelle(const ARMISARegisters *id) |
50 | + * Needed to preserve the tick_count across migration, even if the | 56 | +static inline bool isar_feature_aa32_jazelle(const ARMISARegisters *id) |
51 | + * absolute value of the rtc_clock is different on the source and | 57 | { |
52 | + * destination. | 58 | return FIELD_EX32(id->id_isar1, ID_ISAR1, JAZELLE) != 0; |
53 | + */ | 59 | } |
54 | + uint32_t tick_offset_vmstate; | 60 | diff --git a/target/arm/internals.h b/target/arm/internals.h |
55 | + uint32_t tick_offset; | ||
56 | + | ||
57 | + uint32_t mr; | ||
58 | + uint32_t lr; | ||
59 | + uint32_t cr; | ||
60 | + uint32_t im; | ||
61 | + uint32_t is; | ||
62 | +} PL031State; | ||
63 | + | ||
64 | +#endif | ||
65 | diff --git a/hw/timer/pl031.c b/hw/timer/pl031.c | ||
66 | index XXXXXXX..XXXXXXX 100644 | 61 | index XXXXXXX..XXXXXXX 100644 |
67 | --- a/hw/timer/pl031.c | 62 | --- a/target/arm/internals.h |
68 | +++ b/hw/timer/pl031.c | 63 | +++ b/target/arm/internals.h |
64 | @@ -XXX,XX +XXX,XX @@ static inline uint32_t aarch32_cpsr_valid_mask(uint64_t features, | ||
65 | if ((features >> ARM_FEATURE_THUMB2) & 1) { | ||
66 | valid |= CPSR_IT; | ||
67 | } | ||
68 | - if (isar_feature_jazelle(id)) { | ||
69 | + if (isar_feature_aa32_jazelle(id)) { | ||
70 | valid |= CPSR_J; | ||
71 | } | ||
72 | if (isar_feature_aa32_pan(id)) { | ||
73 | diff --git a/linux-user/elfload.c b/linux-user/elfload.c | ||
74 | index XXXXXXX..XXXXXXX 100644 | ||
75 | --- a/linux-user/elfload.c | ||
76 | +++ b/linux-user/elfload.c | ||
77 | @@ -XXX,XX +XXX,XX @@ static uint32_t get_elf_hwcap(void) | ||
78 | GET_FEATURE(ARM_FEATURE_VFP3, ARM_HWCAP_ARM_VFPv3); | ||
79 | GET_FEATURE(ARM_FEATURE_V6K, ARM_HWCAP_ARM_TLS); | ||
80 | GET_FEATURE(ARM_FEATURE_VFP4, ARM_HWCAP_ARM_VFPv4); | ||
81 | - GET_FEATURE_ID(arm_div, ARM_HWCAP_ARM_IDIVA); | ||
82 | - GET_FEATURE_ID(thumb_div, ARM_HWCAP_ARM_IDIVT); | ||
83 | + GET_FEATURE_ID(aa32_arm_div, ARM_HWCAP_ARM_IDIVA); | ||
84 | + GET_FEATURE_ID(aa32_thumb_div, ARM_HWCAP_ARM_IDIVT); | ||
85 | /* All QEMU's VFPv3 CPUs have 32 registers, see VFP_DREG in translate.c. | ||
86 | * Note that the ARM_HWCAP_ARM_VFPv3D16 bit is always the inverse of | ||
87 | * ARM_HWCAP_ARM_VFPD32 (and so always clear for QEMU); it is unrelated | ||
88 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | ||
89 | index XXXXXXX..XXXXXXX 100644 | ||
90 | --- a/target/arm/cpu.c | ||
91 | +++ b/target/arm/cpu.c | ||
92 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) | ||
93 | * Presence of EL2 itself is ARM_FEATURE_EL2, and of the | ||
94 | * Security Extensions is ARM_FEATURE_EL3. | ||
95 | */ | ||
96 | - assert(!tcg_enabled() || no_aa32 || cpu_isar_feature(arm_div, cpu)); | ||
97 | + assert(!tcg_enabled() || no_aa32 || | ||
98 | + cpu_isar_feature(aa32_arm_div, cpu)); | ||
99 | set_feature(env, ARM_FEATURE_LPAE); | ||
100 | set_feature(env, ARM_FEATURE_V7); | ||
101 | } | ||
102 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) | ||
103 | if (arm_feature(env, ARM_FEATURE_V6)) { | ||
104 | set_feature(env, ARM_FEATURE_V5); | ||
105 | if (!arm_feature(env, ARM_FEATURE_M)) { | ||
106 | - assert(!tcg_enabled() || no_aa32 || cpu_isar_feature(jazelle, cpu)); | ||
107 | + assert(!tcg_enabled() || no_aa32 || | ||
108 | + cpu_isar_feature(aa32_jazelle, cpu)); | ||
109 | set_feature(env, ARM_FEATURE_AUXCR); | ||
110 | } | ||
111 | } | ||
112 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
113 | index XXXXXXX..XXXXXXX 100644 | ||
114 | --- a/target/arm/helper.c | ||
115 | +++ b/target/arm/helper.c | ||
116 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
117 | if (arm_feature(env, ARM_FEATURE_LPAE)) { | ||
118 | define_arm_cp_regs(cpu, lpae_cp_reginfo); | ||
119 | } | ||
120 | - if (cpu_isar_feature(jazelle, cpu)) { | ||
121 | + if (cpu_isar_feature(aa32_jazelle, cpu)) { | ||
122 | define_arm_cp_regs(cpu, jazelle_regs); | ||
123 | } | ||
124 | /* Slightly awkwardly, the OMAP and StrongARM cores need all of | ||
125 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
126 | index XXXXXXX..XXXXXXX 100644 | ||
127 | --- a/target/arm/translate.c | ||
128 | +++ b/target/arm/translate.c | ||
69 | @@ -XXX,XX +XXX,XX @@ | 129 | @@ -XXX,XX +XXX,XX @@ |
70 | */ | 130 | #define ENABLE_ARCH_5 arm_dc_feature(s, ARM_FEATURE_V5) |
71 | 131 | /* currently all emulated v5 cores are also v5TE, so don't bother */ | |
72 | #include "qemu/osdep.h" | 132 | #define ENABLE_ARCH_5TE arm_dc_feature(s, ARM_FEATURE_V5) |
73 | +#include "hw/timer/pl031.h" | 133 | -#define ENABLE_ARCH_5J dc_isar_feature(jazelle, s) |
74 | #include "hw/sysbus.h" | 134 | +#define ENABLE_ARCH_5J dc_isar_feature(aa32_jazelle, s) |
75 | #include "qemu/timer.h" | 135 | #define ENABLE_ARCH_6 arm_dc_feature(s, ARM_FEATURE_V6) |
76 | #include "sysemu/sysemu.h" | 136 | #define ENABLE_ARCH_6K arm_dc_feature(s, ARM_FEATURE_V6K) |
77 | @@ -XXX,XX +XXX,XX @@ do { printf("pl031: " fmt , ## __VA_ARGS__); } while (0) | 137 | #define ENABLE_ARCH_6T2 arm_dc_feature(s, ARM_FEATURE_THUMB2) |
78 | #define RTC_MIS 0x18 /* Masked interrupt status register */ | 138 | @@ -XXX,XX +XXX,XX @@ static bool op_div(DisasContext *s, arg_rrr *a, bool u) |
79 | #define RTC_ICR 0x1c /* Interrupt clear register */ | 139 | TCGv_i32 t1, t2; |
80 | 140 | ||
81 | -#define TYPE_PL031 "pl031" | 141 | if (s->thumb |
82 | -#define PL031(obj) OBJECT_CHECK(PL031State, (obj), TYPE_PL031) | 142 | - ? !dc_isar_feature(thumb_div, s) |
83 | - | 143 | - : !dc_isar_feature(arm_div, s)) { |
84 | -typedef struct PL031State { | 144 | + ? !dc_isar_feature(aa32_thumb_div, s) |
85 | - SysBusDevice parent_obj; | 145 | + : !dc_isar_feature(aa32_arm_div, s)) { |
86 | - | 146 | return false; |
87 | - MemoryRegion iomem; | 147 | } |
88 | - QEMUTimer *timer; | 148 | |
89 | - qemu_irq irq; | ||
90 | - | ||
91 | - /* Needed to preserve the tick_count across migration, even if the | ||
92 | - * absolute value of the rtc_clock is different on the source and | ||
93 | - * destination. | ||
94 | - */ | ||
95 | - uint32_t tick_offset_vmstate; | ||
96 | - uint32_t tick_offset; | ||
97 | - | ||
98 | - uint32_t mr; | ||
99 | - uint32_t lr; | ||
100 | - uint32_t cr; | ||
101 | - uint32_t im; | ||
102 | - uint32_t is; | ||
103 | -} PL031State; | ||
104 | - | ||
105 | static const unsigned char pl031_id[] = { | ||
106 | 0x31, 0x10, 0x14, 0x00, /* Device ID */ | ||
107 | 0x0d, 0xf0, 0x05, 0xb1 /* Cell ID */ | ||
108 | diff --git a/MAINTAINERS b/MAINTAINERS | ||
109 | index XXXXXXX..XXXXXXX 100644 | ||
110 | --- a/MAINTAINERS | ||
111 | +++ b/MAINTAINERS | ||
112 | @@ -XXX,XX +XXX,XX @@ F: hw/sd/pl181.c | ||
113 | F: hw/ssi/pl022.c | ||
114 | F: include/hw/ssi/pl022.h | ||
115 | F: hw/timer/pl031.c | ||
116 | +F: include/hw/timer/pl031.h | ||
117 | F: include/hw/arm/primecell.h | ||
118 | F: hw/timer/cmsdk-apb-timer.c | ||
119 | F: include/hw/timer/cmsdk-apb-timer.h | ||
120 | -- | 149 | -- |
121 | 2.20.1 | 150 | 2.20.1 |
122 | 151 | ||
123 | 152 | diff view generated by jsdifflib |
1 | The "background region" for a v8M MPU is a default which will be used | 1 | In take_aarch32_exception(), we know we are dealing with a CPU that |
---|---|---|---|
2 | (if enabled, and if the access is privileged) if the access does | 2 | has AArch32, so the right isar_feature test is aa32_pan, not aa64_pan. |
3 | not match any specific MPU region. We were incorrectly using it | ||
4 | always (by putting the condition at the wrong nesting level). This | ||
5 | meant that we would always return the default background permissions | ||
6 | rather than the correct permissions for a specific region, and also | ||
7 | that we would not return the right information in response to a | ||
8 | TT instruction. | ||
9 | |||
10 | Move the check for the background region to the same place in the | ||
11 | logic as the equivalent v8M MPUCheck() pseudocode puts it. | ||
12 | This in turn means we must adjust the condition we use to detect | ||
13 | matches in multiple regions to avoid false-positives. | ||
14 | 3 | ||
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
16 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
17 | Message-id: 20190214113408.10214-1-peter.maydell@linaro.org | 6 | Message-id: 20200214175116.9164-3-peter.maydell@linaro.org |
18 | --- | 7 | --- |
19 | target/arm/helper.c | 8 +++++--- | 8 | target/arm/helper.c | 2 +- |
20 | 1 file changed, 5 insertions(+), 3 deletions(-) | 9 | 1 file changed, 1 insertion(+), 1 deletion(-) |
21 | 10 | ||
22 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 11 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
23 | index XXXXXXX..XXXXXXX 100644 | 12 | index XXXXXXX..XXXXXXX 100644 |
24 | --- a/target/arm/helper.c | 13 | --- a/target/arm/helper.c |
25 | +++ b/target/arm/helper.c | 14 | +++ b/target/arm/helper.c |
26 | @@ -XXX,XX +XXX,XX @@ static bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address, | 15 | @@ -XXX,XX +XXX,XX @@ static void take_aarch32_exception(CPUARMState *env, int new_mode, |
27 | hit = true; | 16 | env->elr_el[2] = env->regs[15]; |
28 | } else if (m_is_ppb_region(env, address)) { | ||
29 | hit = true; | ||
30 | - } else if (pmsav7_use_background_region(cpu, mmu_idx, is_user)) { | ||
31 | - hit = true; | ||
32 | } else { | 17 | } else { |
33 | + if (pmsav7_use_background_region(cpu, mmu_idx, is_user)) { | 18 | /* CPSR.PAN is normally preserved preserved unless... */ |
34 | + hit = true; | 19 | - if (cpu_isar_feature(aa64_pan, env_archcpu(env))) { |
35 | + } | 20 | + if (cpu_isar_feature(aa32_pan, env_archcpu(env))) { |
36 | + | 21 | switch (new_el) { |
37 | for (n = (int)cpu->pmsav7_dregion - 1; n >= 0; n--) { | 22 | case 3: |
38 | /* region search */ | 23 | if (!arm_is_secure_below_el3(env)) { |
39 | /* Note that the base address is bits [31:5] from the register | ||
40 | @@ -XXX,XX +XXX,XX @@ static bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address, | ||
41 | *is_subpage = true; | ||
42 | } | ||
43 | |||
44 | - if (hit) { | ||
45 | + if (matchregion != -1) { | ||
46 | /* Multiple regions match -- always a failure (unlike | ||
47 | * PMSAv7 where highest-numbered-region wins) | ||
48 | */ | ||
49 | -- | 24 | -- |
50 | 2.20.1 | 25 | 2.20.1 |
51 | 26 | ||
52 | 27 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Our current usage of the isar_feature feature tests almost always | ||
2 | uses an _aa32_ test when the code path is known to be AArch32 | ||
3 | specific and an _aa64_ test when the code path is known to be | ||
4 | AArch64 specific. There is just one exception: in the vfp_set_fpscr | ||
5 | helper we check aa64_fp16 to determine whether the FZ16 bit in | ||
6 | the FP(S)CR exists, but this code is also used for AArch32. | ||
7 | There are other places in future where we're likely to want | ||
8 | a general "does this feature exist for either AArch32 or | ||
9 | AArch64" check (typically where architecturally the feature exists | ||
10 | for both CPU states if it exists at all, but the CPU might be | ||
11 | AArch32-only or AArch64-only, and so only have one set of ID | ||
12 | registers). | ||
1 | 13 | ||
14 | Introduce a new category of isar_feature_* functions: | ||
15 | isar_feature_any_foo() should be tested when what we want to | ||
16 | know is "does this feature exist for either AArch32 or AArch64", | ||
17 | and always returns the logical OR of isar_feature_aa32_foo() | ||
18 | and isar_feature_aa64_foo(). | ||
19 | |||
20 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
21 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
22 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
23 | Message-id: 20200214175116.9164-4-peter.maydell@linaro.org | ||
24 | --- | ||
25 | target/arm/cpu.h | 19 ++++++++++++++++++- | ||
26 | target/arm/vfp_helper.c | 2 +- | ||
27 | 2 files changed, 19 insertions(+), 2 deletions(-) | ||
28 | |||
29 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
30 | index XXXXXXX..XXXXXXX 100644 | ||
31 | --- a/target/arm/cpu.h | ||
32 | +++ b/target/arm/cpu.h | ||
33 | @@ -XXX,XX +XXX,XX @@ extern const uint64_t pred_esz_masks[4]; | ||
34 | * Naming convention for isar_feature functions: | ||
35 | * Functions which test 32-bit ID registers should have _aa32_ in | ||
36 | * their name. Functions which test 64-bit ID registers should have | ||
37 | - * _aa64_ in their name. | ||
38 | + * _aa64_ in their name. These must only be used in code where we | ||
39 | + * know for certain that the CPU has AArch32 or AArch64 respectively | ||
40 | + * or where the correct answer for a CPU which doesn't implement that | ||
41 | + * CPU state is "false" (eg when generating A32 or A64 code, if adding | ||
42 | + * system registers that are specific to that CPU state, for "should | ||
43 | + * we let this system register bit be set" tests where the 32-bit | ||
44 | + * flavour of the register doesn't have the bit, and so on). | ||
45 | + * Functions which simply ask "does this feature exist at all" have | ||
46 | + * _any_ in their name, and always return the logical OR of the _aa64_ | ||
47 | + * and the _aa32_ function. | ||
48 | */ | ||
49 | |||
50 | /* | ||
51 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa64_bti(const ARMISARegisters *id) | ||
52 | return FIELD_EX64(id->id_aa64pfr1, ID_AA64PFR1, BT) != 0; | ||
53 | } | ||
54 | |||
55 | +/* | ||
56 | + * Feature tests for "does this exist in either 32-bit or 64-bit?" | ||
57 | + */ | ||
58 | +static inline bool isar_feature_any_fp16(const ARMISARegisters *id) | ||
59 | +{ | ||
60 | + return isar_feature_aa64_fp16(id) || isar_feature_aa32_fp16_arith(id); | ||
61 | +} | ||
62 | + | ||
63 | /* | ||
64 | * Forward to the above feature tests given an ARMCPU pointer. | ||
65 | */ | ||
66 | diff --git a/target/arm/vfp_helper.c b/target/arm/vfp_helper.c | ||
67 | index XXXXXXX..XXXXXXX 100644 | ||
68 | --- a/target/arm/vfp_helper.c | ||
69 | +++ b/target/arm/vfp_helper.c | ||
70 | @@ -XXX,XX +XXX,XX @@ uint32_t vfp_get_fpscr(CPUARMState *env) | ||
71 | void HELPER(vfp_set_fpscr)(CPUARMState *env, uint32_t val) | ||
72 | { | ||
73 | /* When ARMv8.2-FP16 is not supported, FZ16 is RES0. */ | ||
74 | - if (!cpu_isar_feature(aa64_fp16, env_archcpu(env))) { | ||
75 | + if (!cpu_isar_feature(any_fp16, env_archcpu(env))) { | ||
76 | val &= ~FPCR_FZ16; | ||
77 | } | ||
78 | |||
79 | -- | ||
80 | 2.20.1 | ||
81 | |||
82 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Instead of open-coding "ARM_FEATURE_AARCH64 ? aa64_predinv: aa32_predinv", | ||
2 | define and use an any_predinv isar_feature test function. | ||
1 | 3 | ||
4 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Message-id: 20200214175116.9164-5-peter.maydell@linaro.org | ||
8 | --- | ||
9 | target/arm/cpu.h | 5 +++++ | ||
10 | target/arm/helper.c | 9 +-------- | ||
11 | 2 files changed, 6 insertions(+), 8 deletions(-) | ||
12 | |||
13 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/target/arm/cpu.h | ||
16 | +++ b/target/arm/cpu.h | ||
17 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_any_fp16(const ARMISARegisters *id) | ||
18 | return isar_feature_aa64_fp16(id) || isar_feature_aa32_fp16_arith(id); | ||
19 | } | ||
20 | |||
21 | +static inline bool isar_feature_any_predinv(const ARMISARegisters *id) | ||
22 | +{ | ||
23 | + return isar_feature_aa64_predinv(id) || isar_feature_aa32_predinv(id); | ||
24 | +} | ||
25 | + | ||
26 | /* | ||
27 | * Forward to the above feature tests given an ARMCPU pointer. | ||
28 | */ | ||
29 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
30 | index XXXXXXX..XXXXXXX 100644 | ||
31 | --- a/target/arm/helper.c | ||
32 | +++ b/target/arm/helper.c | ||
33 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
34 | #endif /*CONFIG_USER_ONLY*/ | ||
35 | #endif | ||
36 | |||
37 | - /* | ||
38 | - * While all v8.0 cpus support aarch64, QEMU does have configurations | ||
39 | - * that do not set ID_AA64ISAR1, e.g. user-only qemu-arm -cpu max, | ||
40 | - * which will set ID_ISAR6. | ||
41 | - */ | ||
42 | - if (arm_feature(&cpu->env, ARM_FEATURE_AARCH64) | ||
43 | - ? cpu_isar_feature(aa64_predinv, cpu) | ||
44 | - : cpu_isar_feature(aa32_predinv, cpu)) { | ||
45 | + if (cpu_isar_feature(any_predinv, cpu)) { | ||
46 | define_arm_cp_regs(cpu, predinv_reginfo); | ||
47 | } | ||
48 | |||
49 | -- | ||
50 | 2.20.1 | ||
51 | |||
52 | diff view generated by jsdifflib |
1 | The pl011 logs when the guest makes a bad access. It prints | 1 | Pull the code that defines the various PMU registers out |
---|---|---|---|
2 | the address offset in hex but confusingly omits the '0x' | 2 | into its own function, matching the pattern we have |
3 | prefix; add it. | 3 | already for the debug registers. |
4 | 4 | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 5 | Apart from one style fix to a multi-line comment, this |
6 | is purely movement of code with no changes to it. | ||
7 | |||
6 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 8 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> |
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | Message-id: 20200214175116.9164-6-peter.maydell@linaro.org | ||
8 | --- | 12 | --- |
9 | hw/char/pl011.c | 4 ++-- | 13 | target/arm/helper.c | 158 +++++++++++++++++++++++--------------------- |
10 | 1 file changed, 2 insertions(+), 2 deletions(-) | 14 | 1 file changed, 82 insertions(+), 76 deletions(-) |
11 | 15 | ||
12 | diff --git a/hw/char/pl011.c b/hw/char/pl011.c | 16 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
13 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
14 | --- a/hw/char/pl011.c | 18 | --- a/target/arm/helper.c |
15 | +++ b/hw/char/pl011.c | 19 | +++ b/target/arm/helper.c |
16 | @@ -XXX,XX +XXX,XX @@ static uint64_t pl011_read(void *opaque, hwaddr offset, | 20 | @@ -XXX,XX +XXX,XX @@ static void define_debug_regs(ARMCPU *cpu) |
17 | break; | ||
18 | default: | ||
19 | qemu_log_mask(LOG_GUEST_ERROR, | ||
20 | - "pl011_read: Bad offset %x\n", (int)offset); | ||
21 | + "pl011_read: Bad offset 0x%x\n", (int)offset); | ||
22 | r = 0; | ||
23 | break; | ||
24 | } | ||
25 | @@ -XXX,XX +XXX,XX @@ static void pl011_write(void *opaque, hwaddr offset, | ||
26 | break; | ||
27 | default: | ||
28 | qemu_log_mask(LOG_GUEST_ERROR, | ||
29 | - "pl011_write: Bad offset %x\n", (int)offset); | ||
30 | + "pl011_write: Bad offset 0x%x\n", (int)offset); | ||
31 | } | 21 | } |
32 | } | 22 | } |
33 | 23 | ||
24 | +static void define_pmu_regs(ARMCPU *cpu) | ||
25 | +{ | ||
26 | + /* | ||
27 | + * v7 performance monitor control register: same implementor | ||
28 | + * field as main ID register, and we implement four counters in | ||
29 | + * addition to the cycle count register. | ||
30 | + */ | ||
31 | + unsigned int i, pmcrn = 4; | ||
32 | + ARMCPRegInfo pmcr = { | ||
33 | + .name = "PMCR", .cp = 15, .crn = 9, .crm = 12, .opc1 = 0, .opc2 = 0, | ||
34 | + .access = PL0_RW, | ||
35 | + .type = ARM_CP_IO | ARM_CP_ALIAS, | ||
36 | + .fieldoffset = offsetoflow32(CPUARMState, cp15.c9_pmcr), | ||
37 | + .accessfn = pmreg_access, .writefn = pmcr_write, | ||
38 | + .raw_writefn = raw_write, | ||
39 | + }; | ||
40 | + ARMCPRegInfo pmcr64 = { | ||
41 | + .name = "PMCR_EL0", .state = ARM_CP_STATE_AA64, | ||
42 | + .opc0 = 3, .opc1 = 3, .crn = 9, .crm = 12, .opc2 = 0, | ||
43 | + .access = PL0_RW, .accessfn = pmreg_access, | ||
44 | + .type = ARM_CP_IO, | ||
45 | + .fieldoffset = offsetof(CPUARMState, cp15.c9_pmcr), | ||
46 | + .resetvalue = (cpu->midr & 0xff000000) | (pmcrn << PMCRN_SHIFT), | ||
47 | + .writefn = pmcr_write, .raw_writefn = raw_write, | ||
48 | + }; | ||
49 | + define_one_arm_cp_reg(cpu, &pmcr); | ||
50 | + define_one_arm_cp_reg(cpu, &pmcr64); | ||
51 | + for (i = 0; i < pmcrn; i++) { | ||
52 | + char *pmevcntr_name = g_strdup_printf("PMEVCNTR%d", i); | ||
53 | + char *pmevcntr_el0_name = g_strdup_printf("PMEVCNTR%d_EL0", i); | ||
54 | + char *pmevtyper_name = g_strdup_printf("PMEVTYPER%d", i); | ||
55 | + char *pmevtyper_el0_name = g_strdup_printf("PMEVTYPER%d_EL0", i); | ||
56 | + ARMCPRegInfo pmev_regs[] = { | ||
57 | + { .name = pmevcntr_name, .cp = 15, .crn = 14, | ||
58 | + .crm = 8 | (3 & (i >> 3)), .opc1 = 0, .opc2 = i & 7, | ||
59 | + .access = PL0_RW, .type = ARM_CP_IO | ARM_CP_ALIAS, | ||
60 | + .readfn = pmevcntr_readfn, .writefn = pmevcntr_writefn, | ||
61 | + .accessfn = pmreg_access }, | ||
62 | + { .name = pmevcntr_el0_name, .state = ARM_CP_STATE_AA64, | ||
63 | + .opc0 = 3, .opc1 = 3, .crn = 14, .crm = 8 | (3 & (i >> 3)), | ||
64 | + .opc2 = i & 7, .access = PL0_RW, .accessfn = pmreg_access, | ||
65 | + .type = ARM_CP_IO, | ||
66 | + .readfn = pmevcntr_readfn, .writefn = pmevcntr_writefn, | ||
67 | + .raw_readfn = pmevcntr_rawread, | ||
68 | + .raw_writefn = pmevcntr_rawwrite }, | ||
69 | + { .name = pmevtyper_name, .cp = 15, .crn = 14, | ||
70 | + .crm = 12 | (3 & (i >> 3)), .opc1 = 0, .opc2 = i & 7, | ||
71 | + .access = PL0_RW, .type = ARM_CP_IO | ARM_CP_ALIAS, | ||
72 | + .readfn = pmevtyper_readfn, .writefn = pmevtyper_writefn, | ||
73 | + .accessfn = pmreg_access }, | ||
74 | + { .name = pmevtyper_el0_name, .state = ARM_CP_STATE_AA64, | ||
75 | + .opc0 = 3, .opc1 = 3, .crn = 14, .crm = 12 | (3 & (i >> 3)), | ||
76 | + .opc2 = i & 7, .access = PL0_RW, .accessfn = pmreg_access, | ||
77 | + .type = ARM_CP_IO, | ||
78 | + .readfn = pmevtyper_readfn, .writefn = pmevtyper_writefn, | ||
79 | + .raw_writefn = pmevtyper_rawwrite }, | ||
80 | + REGINFO_SENTINEL | ||
81 | + }; | ||
82 | + define_arm_cp_regs(cpu, pmev_regs); | ||
83 | + g_free(pmevcntr_name); | ||
84 | + g_free(pmevcntr_el0_name); | ||
85 | + g_free(pmevtyper_name); | ||
86 | + g_free(pmevtyper_el0_name); | ||
87 | + } | ||
88 | + if (FIELD_EX32(cpu->id_dfr0, ID_DFR0, PERFMON) >= 4 && | ||
89 | + FIELD_EX32(cpu->id_dfr0, ID_DFR0, PERFMON) != 0xf) { | ||
90 | + ARMCPRegInfo v81_pmu_regs[] = { | ||
91 | + { .name = "PMCEID2", .state = ARM_CP_STATE_AA32, | ||
92 | + .cp = 15, .opc1 = 0, .crn = 9, .crm = 14, .opc2 = 4, | ||
93 | + .access = PL0_R, .accessfn = pmreg_access, .type = ARM_CP_CONST, | ||
94 | + .resetvalue = extract64(cpu->pmceid0, 32, 32) }, | ||
95 | + { .name = "PMCEID3", .state = ARM_CP_STATE_AA32, | ||
96 | + .cp = 15, .opc1 = 0, .crn = 9, .crm = 14, .opc2 = 5, | ||
97 | + .access = PL0_R, .accessfn = pmreg_access, .type = ARM_CP_CONST, | ||
98 | + .resetvalue = extract64(cpu->pmceid1, 32, 32) }, | ||
99 | + REGINFO_SENTINEL | ||
100 | + }; | ||
101 | + define_arm_cp_regs(cpu, v81_pmu_regs); | ||
102 | + } | ||
103 | +} | ||
104 | + | ||
105 | /* We don't know until after realize whether there's a GICv3 | ||
106 | * attached, and that is what registers the gicv3 sysregs. | ||
107 | * So we have to fill in the GIC fields in ID_PFR/ID_PFR1_EL1/ID_AA64PFR0_EL1 | ||
108 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
109 | define_arm_cp_regs(cpu, pmovsset_cp_reginfo); | ||
110 | } | ||
111 | if (arm_feature(env, ARM_FEATURE_V7)) { | ||
112 | - /* v7 performance monitor control register: same implementor | ||
113 | - * field as main ID register, and we implement four counters in | ||
114 | - * addition to the cycle count register. | ||
115 | - */ | ||
116 | - unsigned int i, pmcrn = 4; | ||
117 | - ARMCPRegInfo pmcr = { | ||
118 | - .name = "PMCR", .cp = 15, .crn = 9, .crm = 12, .opc1 = 0, .opc2 = 0, | ||
119 | - .access = PL0_RW, | ||
120 | - .type = ARM_CP_IO | ARM_CP_ALIAS, | ||
121 | - .fieldoffset = offsetoflow32(CPUARMState, cp15.c9_pmcr), | ||
122 | - .accessfn = pmreg_access, .writefn = pmcr_write, | ||
123 | - .raw_writefn = raw_write, | ||
124 | - }; | ||
125 | - ARMCPRegInfo pmcr64 = { | ||
126 | - .name = "PMCR_EL0", .state = ARM_CP_STATE_AA64, | ||
127 | - .opc0 = 3, .opc1 = 3, .crn = 9, .crm = 12, .opc2 = 0, | ||
128 | - .access = PL0_RW, .accessfn = pmreg_access, | ||
129 | - .type = ARM_CP_IO, | ||
130 | - .fieldoffset = offsetof(CPUARMState, cp15.c9_pmcr), | ||
131 | - .resetvalue = (cpu->midr & 0xff000000) | (pmcrn << PMCRN_SHIFT), | ||
132 | - .writefn = pmcr_write, .raw_writefn = raw_write, | ||
133 | - }; | ||
134 | - define_one_arm_cp_reg(cpu, &pmcr); | ||
135 | - define_one_arm_cp_reg(cpu, &pmcr64); | ||
136 | - for (i = 0; i < pmcrn; i++) { | ||
137 | - char *pmevcntr_name = g_strdup_printf("PMEVCNTR%d", i); | ||
138 | - char *pmevcntr_el0_name = g_strdup_printf("PMEVCNTR%d_EL0", i); | ||
139 | - char *pmevtyper_name = g_strdup_printf("PMEVTYPER%d", i); | ||
140 | - char *pmevtyper_el0_name = g_strdup_printf("PMEVTYPER%d_EL0", i); | ||
141 | - ARMCPRegInfo pmev_regs[] = { | ||
142 | - { .name = pmevcntr_name, .cp = 15, .crn = 14, | ||
143 | - .crm = 8 | (3 & (i >> 3)), .opc1 = 0, .opc2 = i & 7, | ||
144 | - .access = PL0_RW, .type = ARM_CP_IO | ARM_CP_ALIAS, | ||
145 | - .readfn = pmevcntr_readfn, .writefn = pmevcntr_writefn, | ||
146 | - .accessfn = pmreg_access }, | ||
147 | - { .name = pmevcntr_el0_name, .state = ARM_CP_STATE_AA64, | ||
148 | - .opc0 = 3, .opc1 = 3, .crn = 14, .crm = 8 | (3 & (i >> 3)), | ||
149 | - .opc2 = i & 7, .access = PL0_RW, .accessfn = pmreg_access, | ||
150 | - .type = ARM_CP_IO, | ||
151 | - .readfn = pmevcntr_readfn, .writefn = pmevcntr_writefn, | ||
152 | - .raw_readfn = pmevcntr_rawread, | ||
153 | - .raw_writefn = pmevcntr_rawwrite }, | ||
154 | - { .name = pmevtyper_name, .cp = 15, .crn = 14, | ||
155 | - .crm = 12 | (3 & (i >> 3)), .opc1 = 0, .opc2 = i & 7, | ||
156 | - .access = PL0_RW, .type = ARM_CP_IO | ARM_CP_ALIAS, | ||
157 | - .readfn = pmevtyper_readfn, .writefn = pmevtyper_writefn, | ||
158 | - .accessfn = pmreg_access }, | ||
159 | - { .name = pmevtyper_el0_name, .state = ARM_CP_STATE_AA64, | ||
160 | - .opc0 = 3, .opc1 = 3, .crn = 14, .crm = 12 | (3 & (i >> 3)), | ||
161 | - .opc2 = i & 7, .access = PL0_RW, .accessfn = pmreg_access, | ||
162 | - .type = ARM_CP_IO, | ||
163 | - .readfn = pmevtyper_readfn, .writefn = pmevtyper_writefn, | ||
164 | - .raw_writefn = pmevtyper_rawwrite }, | ||
165 | - REGINFO_SENTINEL | ||
166 | - }; | ||
167 | - define_arm_cp_regs(cpu, pmev_regs); | ||
168 | - g_free(pmevcntr_name); | ||
169 | - g_free(pmevcntr_el0_name); | ||
170 | - g_free(pmevtyper_name); | ||
171 | - g_free(pmevtyper_el0_name); | ||
172 | - } | ||
173 | ARMCPRegInfo clidr = { | ||
174 | .name = "CLIDR", .state = ARM_CP_STATE_BOTH, | ||
175 | .opc0 = 3, .crn = 0, .crm = 0, .opc1 = 1, .opc2 = 1, | ||
176 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
177 | define_one_arm_cp_reg(cpu, &clidr); | ||
178 | define_arm_cp_regs(cpu, v7_cp_reginfo); | ||
179 | define_debug_regs(cpu); | ||
180 | + define_pmu_regs(cpu); | ||
181 | } else { | ||
182 | define_arm_cp_regs(cpu, not_v7_cp_reginfo); | ||
183 | } | ||
184 | - if (FIELD_EX32(cpu->id_dfr0, ID_DFR0, PERFMON) >= 4 && | ||
185 | - FIELD_EX32(cpu->id_dfr0, ID_DFR0, PERFMON) != 0xf) { | ||
186 | - ARMCPRegInfo v81_pmu_regs[] = { | ||
187 | - { .name = "PMCEID2", .state = ARM_CP_STATE_AA32, | ||
188 | - .cp = 15, .opc1 = 0, .crn = 9, .crm = 14, .opc2 = 4, | ||
189 | - .access = PL0_R, .accessfn = pmreg_access, .type = ARM_CP_CONST, | ||
190 | - .resetvalue = extract64(cpu->pmceid0, 32, 32) }, | ||
191 | - { .name = "PMCEID3", .state = ARM_CP_STATE_AA32, | ||
192 | - .cp = 15, .opc1 = 0, .crn = 9, .crm = 14, .opc2 = 5, | ||
193 | - .access = PL0_R, .accessfn = pmreg_access, .type = ARM_CP_CONST, | ||
194 | - .resetvalue = extract64(cpu->pmceid1, 32, 32) }, | ||
195 | - REGINFO_SENTINEL | ||
196 | - }; | ||
197 | - define_arm_cp_regs(cpu, v81_pmu_regs); | ||
198 | - } | ||
199 | if (arm_feature(env, ARM_FEATURE_V8)) { | ||
200 | /* AArch64 ID registers, which all have impdef reset values. | ||
201 | * Note that within the ID register ranges the unused slots | ||
34 | -- | 202 | -- |
35 | 2.20.1 | 203 | 2.20.1 |
36 | 204 | ||
37 | 205 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Add FIELD() definitions for the ID_AA64DFR0_EL1 and use them | ||
2 | where we currently have hard-coded bit values. | ||
1 | 3 | ||
4 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Message-id: 20200214175116.9164-7-peter.maydell@linaro.org | ||
8 | --- | ||
9 | target/arm/cpu.h | 10 ++++++++++ | ||
10 | target/arm/cpu.c | 2 +- | ||
11 | target/arm/helper.c | 6 +++--- | ||
12 | 3 files changed, 14 insertions(+), 4 deletions(-) | ||
13 | |||
14 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/target/arm/cpu.h | ||
17 | +++ b/target/arm/cpu.h | ||
18 | @@ -XXX,XX +XXX,XX @@ FIELD(ID_AA64MMFR2, BBM, 52, 4) | ||
19 | FIELD(ID_AA64MMFR2, EVT, 56, 4) | ||
20 | FIELD(ID_AA64MMFR2, E0PD, 60, 4) | ||
21 | |||
22 | +FIELD(ID_AA64DFR0, DEBUGVER, 0, 4) | ||
23 | +FIELD(ID_AA64DFR0, TRACEVER, 4, 4) | ||
24 | +FIELD(ID_AA64DFR0, PMUVER, 8, 4) | ||
25 | +FIELD(ID_AA64DFR0, BRPS, 12, 4) | ||
26 | +FIELD(ID_AA64DFR0, WRPS, 20, 4) | ||
27 | +FIELD(ID_AA64DFR0, CTX_CMPS, 28, 4) | ||
28 | +FIELD(ID_AA64DFR0, PMSVER, 32, 4) | ||
29 | +FIELD(ID_AA64DFR0, DOUBLELOCK, 36, 4) | ||
30 | +FIELD(ID_AA64DFR0, TRACEFILT, 40, 4) | ||
31 | + | ||
32 | FIELD(ID_DFR0, COPDBG, 0, 4) | ||
33 | FIELD(ID_DFR0, COPSDBG, 4, 4) | ||
34 | FIELD(ID_DFR0, MMAPDBG, 8, 4) | ||
35 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | ||
36 | index XXXXXXX..XXXXXXX 100644 | ||
37 | --- a/target/arm/cpu.c | ||
38 | +++ b/target/arm/cpu.c | ||
39 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) | ||
40 | cpu); | ||
41 | #endif | ||
42 | } else { | ||
43 | - cpu->id_aa64dfr0 &= ~0xf00; | ||
44 | + cpu->id_aa64dfr0 = FIELD_DP64(cpu->id_aa64dfr0, ID_AA64DFR0, PMUVER, 0); | ||
45 | cpu->id_dfr0 &= ~(0xf << 24); | ||
46 | cpu->pmceid0 = 0; | ||
47 | cpu->pmceid1 = 0; | ||
48 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
49 | index XXXXXXX..XXXXXXX 100644 | ||
50 | --- a/target/arm/helper.c | ||
51 | +++ b/target/arm/helper.c | ||
52 | @@ -XXX,XX +XXX,XX @@ static void define_debug_regs(ARMCPU *cpu) | ||
53 | * check that if they both exist then they agree. | ||
54 | */ | ||
55 | if (arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) { | ||
56 | - assert(extract32(cpu->id_aa64dfr0, 12, 4) == brps); | ||
57 | - assert(extract32(cpu->id_aa64dfr0, 20, 4) == wrps); | ||
58 | - assert(extract32(cpu->id_aa64dfr0, 28, 4) == ctx_cmps); | ||
59 | + assert(FIELD_EX64(cpu->id_aa64dfr0, ID_AA64DFR0, BRPS) == brps); | ||
60 | + assert(FIELD_EX64(cpu->id_aa64dfr0, ID_AA64DFR0, WRPS) == wrps); | ||
61 | + assert(FIELD_EX64(cpu->id_aa64dfr0, ID_AA64DFR0, CTX_CMPS) == ctx_cmps); | ||
62 | } | ||
63 | |||
64 | define_one_arm_cp_reg(cpu, &dbgdidr); | ||
65 | -- | ||
66 | 2.20.1 | ||
67 | |||
68 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | We already define FIELD macros for ID_DFR0, so use them in the | ||
2 | one place where we're doing direct bit value manipulation. | ||
1 | 3 | ||
4 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Message-id: 20200214175116.9164-8-peter.maydell@linaro.org | ||
8 | --- | ||
9 | target/arm/cpu.c | 2 +- | ||
10 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
11 | |||
12 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/target/arm/cpu.c | ||
15 | +++ b/target/arm/cpu.c | ||
16 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) | ||
17 | #endif | ||
18 | } else { | ||
19 | cpu->id_aa64dfr0 = FIELD_DP64(cpu->id_aa64dfr0, ID_AA64DFR0, PMUVER, 0); | ||
20 | - cpu->id_dfr0 &= ~(0xf << 24); | ||
21 | + cpu->id_dfr0 = FIELD_DP32(cpu->id_dfr0, ID_DFR0, PERFMON, 0); | ||
22 | cpu->pmceid0 = 0; | ||
23 | cpu->pmceid1 = 0; | ||
24 | } | ||
25 | -- | ||
26 | 2.20.1 | ||
27 | |||
28 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | 1 | Instead of open-coding a check on the ID_DFR0 PerfMon ID register | |
2 | field, create a standardly-named isar_feature for "does AArch32 have | ||
3 | a v8.1 PMUv3" and use it. | ||
4 | |||
5 | This entails moving the id_dfr0 field into the ARMISARegisters struct. | ||
6 | |||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Message-id: 20200214175116.9164-9-peter.maydell@linaro.org | ||
10 | --- | ||
11 | target/arm/cpu.h | 9 ++++++++- | ||
12 | hw/intc/armv7m_nvic.c | 2 +- | ||
13 | target/arm/cpu.c | 28 ++++++++++++++-------------- | ||
14 | target/arm/cpu64.c | 6 +++--- | ||
15 | target/arm/helper.c | 5 ++--- | ||
16 | 5 files changed, 28 insertions(+), 22 deletions(-) | ||
17 | |||
18 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
19 | index XXXXXXX..XXXXXXX 100644 | ||
20 | --- a/target/arm/cpu.h | ||
21 | +++ b/target/arm/cpu.h | ||
22 | @@ -XXX,XX +XXX,XX @@ struct ARMCPU { | ||
23 | uint32_t mvfr0; | ||
24 | uint32_t mvfr1; | ||
25 | uint32_t mvfr2; | ||
26 | + uint32_t id_dfr0; | ||
27 | uint64_t id_aa64isar0; | ||
28 | uint64_t id_aa64isar1; | ||
29 | uint64_t id_aa64pfr0; | ||
30 | @@ -XXX,XX +XXX,XX @@ struct ARMCPU { | ||
31 | uint32_t reset_sctlr; | ||
32 | uint32_t id_pfr0; | ||
33 | uint32_t id_pfr1; | ||
34 | - uint32_t id_dfr0; | ||
35 | uint64_t pmceid0; | ||
36 | uint64_t pmceid1; | ||
37 | uint32_t id_afr0; | ||
38 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa32_ats1e1(const ARMISARegisters *id) | ||
39 | return FIELD_EX64(id->mvfr0, ID_MMFR3, PAN) >= 2; | ||
40 | } | ||
41 | |||
42 | +static inline bool isar_feature_aa32_pmu_8_1(const ARMISARegisters *id) | ||
43 | +{ | ||
44 | + /* 0xf means "non-standard IMPDEF PMU" */ | ||
45 | + return FIELD_EX32(id->id_dfr0, ID_DFR0, PERFMON) >= 4 && | ||
46 | + FIELD_EX32(id->id_dfr0, ID_DFR0, PERFMON) != 0xf; | ||
47 | +} | ||
48 | + | ||
49 | /* | ||
50 | * 64-bit feature tests via id registers. | ||
51 | */ | ||
52 | diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c | ||
53 | index XXXXXXX..XXXXXXX 100644 | ||
54 | --- a/hw/intc/armv7m_nvic.c | ||
55 | +++ b/hw/intc/armv7m_nvic.c | ||
56 | @@ -XXX,XX +XXX,XX @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs) | ||
57 | case 0xd44: /* PFR1. */ | ||
58 | return cpu->id_pfr1; | ||
59 | case 0xd48: /* DFR0. */ | ||
60 | - return cpu->id_dfr0; | ||
61 | + return cpu->isar.id_dfr0; | ||
62 | case 0xd4c: /* AFR0. */ | ||
63 | return cpu->id_afr0; | ||
64 | case 0xd50: /* MMFR0. */ | ||
65 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | ||
66 | index XXXXXXX..XXXXXXX 100644 | ||
67 | --- a/target/arm/cpu.c | ||
68 | +++ b/target/arm/cpu.c | ||
69 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) | ||
70 | #endif | ||
71 | } else { | ||
72 | cpu->id_aa64dfr0 = FIELD_DP64(cpu->id_aa64dfr0, ID_AA64DFR0, PMUVER, 0); | ||
73 | - cpu->id_dfr0 = FIELD_DP32(cpu->id_dfr0, ID_DFR0, PERFMON, 0); | ||
74 | + cpu->isar.id_dfr0 = FIELD_DP32(cpu->isar.id_dfr0, ID_DFR0, PERFMON, 0); | ||
75 | cpu->pmceid0 = 0; | ||
76 | cpu->pmceid1 = 0; | ||
77 | } | ||
78 | @@ -XXX,XX +XXX,XX @@ static void arm1136_r2_initfn(Object *obj) | ||
79 | cpu->reset_sctlr = 0x00050078; | ||
80 | cpu->id_pfr0 = 0x111; | ||
81 | cpu->id_pfr1 = 0x1; | ||
82 | - cpu->id_dfr0 = 0x2; | ||
83 | + cpu->isar.id_dfr0 = 0x2; | ||
84 | cpu->id_afr0 = 0x3; | ||
85 | cpu->id_mmfr0 = 0x01130003; | ||
86 | cpu->id_mmfr1 = 0x10030302; | ||
87 | @@ -XXX,XX +XXX,XX @@ static void arm1136_initfn(Object *obj) | ||
88 | cpu->reset_sctlr = 0x00050078; | ||
89 | cpu->id_pfr0 = 0x111; | ||
90 | cpu->id_pfr1 = 0x1; | ||
91 | - cpu->id_dfr0 = 0x2; | ||
92 | + cpu->isar.id_dfr0 = 0x2; | ||
93 | cpu->id_afr0 = 0x3; | ||
94 | cpu->id_mmfr0 = 0x01130003; | ||
95 | cpu->id_mmfr1 = 0x10030302; | ||
96 | @@ -XXX,XX +XXX,XX @@ static void arm1176_initfn(Object *obj) | ||
97 | cpu->reset_sctlr = 0x00050078; | ||
98 | cpu->id_pfr0 = 0x111; | ||
99 | cpu->id_pfr1 = 0x11; | ||
100 | - cpu->id_dfr0 = 0x33; | ||
101 | + cpu->isar.id_dfr0 = 0x33; | ||
102 | cpu->id_afr0 = 0; | ||
103 | cpu->id_mmfr0 = 0x01130003; | ||
104 | cpu->id_mmfr1 = 0x10030302; | ||
105 | @@ -XXX,XX +XXX,XX @@ static void arm11mpcore_initfn(Object *obj) | ||
106 | cpu->ctr = 0x1d192992; /* 32K icache 32K dcache */ | ||
107 | cpu->id_pfr0 = 0x111; | ||
108 | cpu->id_pfr1 = 0x1; | ||
109 | - cpu->id_dfr0 = 0; | ||
110 | + cpu->isar.id_dfr0 = 0; | ||
111 | cpu->id_afr0 = 0x2; | ||
112 | cpu->id_mmfr0 = 0x01100103; | ||
113 | cpu->id_mmfr1 = 0x10020302; | ||
114 | @@ -XXX,XX +XXX,XX @@ static void cortex_m3_initfn(Object *obj) | ||
115 | cpu->pmsav7_dregion = 8; | ||
116 | cpu->id_pfr0 = 0x00000030; | ||
117 | cpu->id_pfr1 = 0x00000200; | ||
118 | - cpu->id_dfr0 = 0x00100000; | ||
119 | + cpu->isar.id_dfr0 = 0x00100000; | ||
120 | cpu->id_afr0 = 0x00000000; | ||
121 | cpu->id_mmfr0 = 0x00000030; | ||
122 | cpu->id_mmfr1 = 0x00000000; | ||
123 | @@ -XXX,XX +XXX,XX @@ static void cortex_m4_initfn(Object *obj) | ||
124 | cpu->isar.mvfr2 = 0x00000000; | ||
125 | cpu->id_pfr0 = 0x00000030; | ||
126 | cpu->id_pfr1 = 0x00000200; | ||
127 | - cpu->id_dfr0 = 0x00100000; | ||
128 | + cpu->isar.id_dfr0 = 0x00100000; | ||
129 | cpu->id_afr0 = 0x00000000; | ||
130 | cpu->id_mmfr0 = 0x00000030; | ||
131 | cpu->id_mmfr1 = 0x00000000; | ||
132 | @@ -XXX,XX +XXX,XX @@ static void cortex_m7_initfn(Object *obj) | ||
133 | cpu->isar.mvfr2 = 0x00000040; | ||
134 | cpu->id_pfr0 = 0x00000030; | ||
135 | cpu->id_pfr1 = 0x00000200; | ||
136 | - cpu->id_dfr0 = 0x00100000; | ||
137 | + cpu->isar.id_dfr0 = 0x00100000; | ||
138 | cpu->id_afr0 = 0x00000000; | ||
139 | cpu->id_mmfr0 = 0x00100030; | ||
140 | cpu->id_mmfr1 = 0x00000000; | ||
141 | @@ -XXX,XX +XXX,XX @@ static void cortex_m33_initfn(Object *obj) | ||
142 | cpu->isar.mvfr2 = 0x00000040; | ||
143 | cpu->id_pfr0 = 0x00000030; | ||
144 | cpu->id_pfr1 = 0x00000210; | ||
145 | - cpu->id_dfr0 = 0x00200000; | ||
146 | + cpu->isar.id_dfr0 = 0x00200000; | ||
147 | cpu->id_afr0 = 0x00000000; | ||
148 | cpu->id_mmfr0 = 0x00101F40; | ||
149 | cpu->id_mmfr1 = 0x00000000; | ||
150 | @@ -XXX,XX +XXX,XX @@ static void cortex_r5_initfn(Object *obj) | ||
151 | cpu->midr = 0x411fc153; /* r1p3 */ | ||
152 | cpu->id_pfr0 = 0x0131; | ||
153 | cpu->id_pfr1 = 0x001; | ||
154 | - cpu->id_dfr0 = 0x010400; | ||
155 | + cpu->isar.id_dfr0 = 0x010400; | ||
156 | cpu->id_afr0 = 0x0; | ||
157 | cpu->id_mmfr0 = 0x0210030; | ||
158 | cpu->id_mmfr1 = 0x00000000; | ||
159 | @@ -XXX,XX +XXX,XX @@ static void cortex_a8_initfn(Object *obj) | ||
160 | cpu->reset_sctlr = 0x00c50078; | ||
161 | cpu->id_pfr0 = 0x1031; | ||
162 | cpu->id_pfr1 = 0x11; | ||
163 | - cpu->id_dfr0 = 0x400; | ||
164 | + cpu->isar.id_dfr0 = 0x400; | ||
165 | cpu->id_afr0 = 0; | ||
166 | cpu->id_mmfr0 = 0x31100003; | ||
167 | cpu->id_mmfr1 = 0x20000000; | ||
168 | @@ -XXX,XX +XXX,XX @@ static void cortex_a9_initfn(Object *obj) | ||
169 | cpu->reset_sctlr = 0x00c50078; | ||
170 | cpu->id_pfr0 = 0x1031; | ||
171 | cpu->id_pfr1 = 0x11; | ||
172 | - cpu->id_dfr0 = 0x000; | ||
173 | + cpu->isar.id_dfr0 = 0x000; | ||
174 | cpu->id_afr0 = 0; | ||
175 | cpu->id_mmfr0 = 0x00100103; | ||
176 | cpu->id_mmfr1 = 0x20000000; | ||
177 | @@ -XXX,XX +XXX,XX @@ static void cortex_a7_initfn(Object *obj) | ||
178 | cpu->reset_sctlr = 0x00c50078; | ||
179 | cpu->id_pfr0 = 0x00001131; | ||
180 | cpu->id_pfr1 = 0x00011011; | ||
181 | - cpu->id_dfr0 = 0x02010555; | ||
182 | + cpu->isar.id_dfr0 = 0x02010555; | ||
183 | cpu->id_afr0 = 0x00000000; | ||
184 | cpu->id_mmfr0 = 0x10101105; | ||
185 | cpu->id_mmfr1 = 0x40000000; | ||
186 | @@ -XXX,XX +XXX,XX @@ static void cortex_a15_initfn(Object *obj) | ||
187 | cpu->reset_sctlr = 0x00c50078; | ||
188 | cpu->id_pfr0 = 0x00001131; | ||
189 | cpu->id_pfr1 = 0x00011011; | ||
190 | - cpu->id_dfr0 = 0x02010555; | ||
191 | + cpu->isar.id_dfr0 = 0x02010555; | ||
192 | cpu->id_afr0 = 0x00000000; | ||
193 | cpu->id_mmfr0 = 0x10201105; | ||
194 | cpu->id_mmfr1 = 0x20000000; | ||
195 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | ||
196 | index XXXXXXX..XXXXXXX 100644 | ||
197 | --- a/target/arm/cpu64.c | ||
198 | +++ b/target/arm/cpu64.c | ||
199 | @@ -XXX,XX +XXX,XX @@ static void aarch64_a57_initfn(Object *obj) | ||
200 | cpu->reset_sctlr = 0x00c50838; | ||
201 | cpu->id_pfr0 = 0x00000131; | ||
202 | cpu->id_pfr1 = 0x00011011; | ||
203 | - cpu->id_dfr0 = 0x03010066; | ||
204 | + cpu->isar.id_dfr0 = 0x03010066; | ||
205 | cpu->id_afr0 = 0x00000000; | ||
206 | cpu->id_mmfr0 = 0x10101105; | ||
207 | cpu->id_mmfr1 = 0x40000000; | ||
208 | @@ -XXX,XX +XXX,XX @@ static void aarch64_a53_initfn(Object *obj) | ||
209 | cpu->reset_sctlr = 0x00c50838; | ||
210 | cpu->id_pfr0 = 0x00000131; | ||
211 | cpu->id_pfr1 = 0x00011011; | ||
212 | - cpu->id_dfr0 = 0x03010066; | ||
213 | + cpu->isar.id_dfr0 = 0x03010066; | ||
214 | cpu->id_afr0 = 0x00000000; | ||
215 | cpu->id_mmfr0 = 0x10101105; | ||
216 | cpu->id_mmfr1 = 0x40000000; | ||
217 | @@ -XXX,XX +XXX,XX @@ static void aarch64_a72_initfn(Object *obj) | ||
218 | cpu->reset_sctlr = 0x00c50838; | ||
219 | cpu->id_pfr0 = 0x00000131; | ||
220 | cpu->id_pfr1 = 0x00011011; | ||
221 | - cpu->id_dfr0 = 0x03010066; | ||
222 | + cpu->isar.id_dfr0 = 0x03010066; | ||
223 | cpu->id_afr0 = 0x00000000; | ||
224 | cpu->id_mmfr0 = 0x10201105; | ||
225 | cpu->id_mmfr1 = 0x40000000; | ||
226 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
227 | index XXXXXXX..XXXXXXX 100644 | ||
228 | --- a/target/arm/helper.c | ||
229 | +++ b/target/arm/helper.c | ||
230 | @@ -XXX,XX +XXX,XX @@ static void define_pmu_regs(ARMCPU *cpu) | ||
231 | g_free(pmevtyper_name); | ||
232 | g_free(pmevtyper_el0_name); | ||
233 | } | ||
234 | - if (FIELD_EX32(cpu->id_dfr0, ID_DFR0, PERFMON) >= 4 && | ||
235 | - FIELD_EX32(cpu->id_dfr0, ID_DFR0, PERFMON) != 0xf) { | ||
236 | + if (cpu_isar_feature(aa32_pmu_8_1, cpu)) { | ||
237 | ARMCPRegInfo v81_pmu_regs[] = { | ||
238 | { .name = "PMCEID2", .state = ARM_CP_STATE_AA32, | ||
239 | .cp = 15, .opc1 = 0, .crn = 9, .crm = 14, .opc2 = 4, | ||
240 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
241 | .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 1, .opc2 = 2, | ||
242 | .access = PL1_R, .type = ARM_CP_CONST, | ||
243 | .accessfn = access_aa32_tid3, | ||
244 | - .resetvalue = cpu->id_dfr0 }, | ||
245 | + .resetvalue = cpu->isar.id_dfr0 }, | ||
246 | { .name = "ID_AFR0", .state = ARM_CP_STATE_BOTH, | ||
247 | .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 1, .opc2 = 3, | ||
248 | .access = PL1_R, .type = ARM_CP_CONST, | ||
249 | -- | ||
250 | 2.20.1 | ||
251 | |||
252 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Add the 64-bit version of the "is this a v8.1 PMUv3?" | ||
2 | ID register check function, and the _any_ version that | ||
3 | checks for either AArch32 or AArch64 support. We'll use | ||
4 | this in a later commit. | ||
1 | 5 | ||
6 | We don't (yet) do any isar_feature checks on ID_AA64DFR1_EL1, | ||
7 | but we move id_aa64dfr1 into the ARMISARegisters struct with | ||
8 | id_aa64dfr0, for consistency. | ||
9 | |||
10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
11 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | Message-id: 20200214175116.9164-10-peter.maydell@linaro.org | ||
14 | --- | ||
15 | target/arm/cpu.h | 15 +++++++++++++-- | ||
16 | target/arm/cpu.c | 3 ++- | ||
17 | target/arm/cpu64.c | 6 +++--- | ||
18 | target/arm/helper.c | 12 +++++++----- | ||
19 | 4 files changed, 25 insertions(+), 11 deletions(-) | ||
20 | |||
21 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
22 | index XXXXXXX..XXXXXXX 100644 | ||
23 | --- a/target/arm/cpu.h | ||
24 | +++ b/target/arm/cpu.h | ||
25 | @@ -XXX,XX +XXX,XX @@ struct ARMCPU { | ||
26 | uint64_t id_aa64mmfr0; | ||
27 | uint64_t id_aa64mmfr1; | ||
28 | uint64_t id_aa64mmfr2; | ||
29 | + uint64_t id_aa64dfr0; | ||
30 | + uint64_t id_aa64dfr1; | ||
31 | } isar; | ||
32 | uint32_t midr; | ||
33 | uint32_t revidr; | ||
34 | @@ -XXX,XX +XXX,XX @@ struct ARMCPU { | ||
35 | uint32_t id_mmfr2; | ||
36 | uint32_t id_mmfr3; | ||
37 | uint32_t id_mmfr4; | ||
38 | - uint64_t id_aa64dfr0; | ||
39 | - uint64_t id_aa64dfr1; | ||
40 | uint64_t id_aa64afr0; | ||
41 | uint64_t id_aa64afr1; | ||
42 | uint32_t dbgdidr; | ||
43 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa64_bti(const ARMISARegisters *id) | ||
44 | return FIELD_EX64(id->id_aa64pfr1, ID_AA64PFR1, BT) != 0; | ||
45 | } | ||
46 | |||
47 | +static inline bool isar_feature_aa64_pmu_8_1(const ARMISARegisters *id) | ||
48 | +{ | ||
49 | + return FIELD_EX64(id->id_aa64dfr0, ID_AA64DFR0, PMUVER) >= 4 && | ||
50 | + FIELD_EX64(id->id_aa64dfr0, ID_AA64DFR0, PMUVER) != 0xf; | ||
51 | +} | ||
52 | + | ||
53 | /* | ||
54 | * Feature tests for "does this exist in either 32-bit or 64-bit?" | ||
55 | */ | ||
56 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_any_predinv(const ARMISARegisters *id) | ||
57 | return isar_feature_aa64_predinv(id) || isar_feature_aa32_predinv(id); | ||
58 | } | ||
59 | |||
60 | +static inline bool isar_feature_any_pmu_8_1(const ARMISARegisters *id) | ||
61 | +{ | ||
62 | + return isar_feature_aa64_pmu_8_1(id) || isar_feature_aa32_pmu_8_1(id); | ||
63 | +} | ||
64 | + | ||
65 | /* | ||
66 | * Forward to the above feature tests given an ARMCPU pointer. | ||
67 | */ | ||
68 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | ||
69 | index XXXXXXX..XXXXXXX 100644 | ||
70 | --- a/target/arm/cpu.c | ||
71 | +++ b/target/arm/cpu.c | ||
72 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) | ||
73 | cpu); | ||
74 | #endif | ||
75 | } else { | ||
76 | - cpu->id_aa64dfr0 = FIELD_DP64(cpu->id_aa64dfr0, ID_AA64DFR0, PMUVER, 0); | ||
77 | + cpu->isar.id_aa64dfr0 = | ||
78 | + FIELD_DP64(cpu->isar.id_aa64dfr0, ID_AA64DFR0, PMUVER, 0); | ||
79 | cpu->isar.id_dfr0 = FIELD_DP32(cpu->isar.id_dfr0, ID_DFR0, PERFMON, 0); | ||
80 | cpu->pmceid0 = 0; | ||
81 | cpu->pmceid1 = 0; | ||
82 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | ||
83 | index XXXXXXX..XXXXXXX 100644 | ||
84 | --- a/target/arm/cpu64.c | ||
85 | +++ b/target/arm/cpu64.c | ||
86 | @@ -XXX,XX +XXX,XX @@ static void aarch64_a57_initfn(Object *obj) | ||
87 | cpu->isar.id_isar5 = 0x00011121; | ||
88 | cpu->isar.id_isar6 = 0; | ||
89 | cpu->isar.id_aa64pfr0 = 0x00002222; | ||
90 | - cpu->id_aa64dfr0 = 0x10305106; | ||
91 | + cpu->isar.id_aa64dfr0 = 0x10305106; | ||
92 | cpu->isar.id_aa64isar0 = 0x00011120; | ||
93 | cpu->isar.id_aa64mmfr0 = 0x00001124; | ||
94 | cpu->dbgdidr = 0x3516d000; | ||
95 | @@ -XXX,XX +XXX,XX @@ static void aarch64_a53_initfn(Object *obj) | ||
96 | cpu->isar.id_isar5 = 0x00011121; | ||
97 | cpu->isar.id_isar6 = 0; | ||
98 | cpu->isar.id_aa64pfr0 = 0x00002222; | ||
99 | - cpu->id_aa64dfr0 = 0x10305106; | ||
100 | + cpu->isar.id_aa64dfr0 = 0x10305106; | ||
101 | cpu->isar.id_aa64isar0 = 0x00011120; | ||
102 | cpu->isar.id_aa64mmfr0 = 0x00001122; /* 40 bit physical addr */ | ||
103 | cpu->dbgdidr = 0x3516d000; | ||
104 | @@ -XXX,XX +XXX,XX @@ static void aarch64_a72_initfn(Object *obj) | ||
105 | cpu->isar.id_isar4 = 0x00011142; | ||
106 | cpu->isar.id_isar5 = 0x00011121; | ||
107 | cpu->isar.id_aa64pfr0 = 0x00002222; | ||
108 | - cpu->id_aa64dfr0 = 0x10305106; | ||
109 | + cpu->isar.id_aa64dfr0 = 0x10305106; | ||
110 | cpu->isar.id_aa64isar0 = 0x00011120; | ||
111 | cpu->isar.id_aa64mmfr0 = 0x00001124; | ||
112 | cpu->dbgdidr = 0x3516d000; | ||
113 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
114 | index XXXXXXX..XXXXXXX 100644 | ||
115 | --- a/target/arm/helper.c | ||
116 | +++ b/target/arm/helper.c | ||
117 | @@ -XXX,XX +XXX,XX @@ | ||
118 | #include "hw/semihosting/semihost.h" | ||
119 | #include "sysemu/cpus.h" | ||
120 | #include "sysemu/kvm.h" | ||
121 | +#include "sysemu/tcg.h" | ||
122 | #include "qemu/range.h" | ||
123 | #include "qapi/qapi-commands-machine-target.h" | ||
124 | #include "qapi/error.h" | ||
125 | @@ -XXX,XX +XXX,XX @@ static void define_debug_regs(ARMCPU *cpu) | ||
126 | * check that if they both exist then they agree. | ||
127 | */ | ||
128 | if (arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) { | ||
129 | - assert(FIELD_EX64(cpu->id_aa64dfr0, ID_AA64DFR0, BRPS) == brps); | ||
130 | - assert(FIELD_EX64(cpu->id_aa64dfr0, ID_AA64DFR0, WRPS) == wrps); | ||
131 | - assert(FIELD_EX64(cpu->id_aa64dfr0, ID_AA64DFR0, CTX_CMPS) == ctx_cmps); | ||
132 | + assert(FIELD_EX64(cpu->isar.id_aa64dfr0, ID_AA64DFR0, BRPS) == brps); | ||
133 | + assert(FIELD_EX64(cpu->isar.id_aa64dfr0, ID_AA64DFR0, WRPS) == wrps); | ||
134 | + assert(FIELD_EX64(cpu->isar.id_aa64dfr0, ID_AA64DFR0, CTX_CMPS) | ||
135 | + == ctx_cmps); | ||
136 | } | ||
137 | |||
138 | define_one_arm_cp_reg(cpu, &dbgdidr); | ||
139 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
140 | .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 5, .opc2 = 0, | ||
141 | .access = PL1_R, .type = ARM_CP_CONST, | ||
142 | .accessfn = access_aa64_tid3, | ||
143 | - .resetvalue = cpu->id_aa64dfr0 }, | ||
144 | + .resetvalue = cpu->isar.id_aa64dfr0 }, | ||
145 | { .name = "ID_AA64DFR1_EL1", .state = ARM_CP_STATE_AA64, | ||
146 | .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 5, .opc2 = 1, | ||
147 | .access = PL1_R, .type = ARM_CP_CONST, | ||
148 | .accessfn = access_aa64_tid3, | ||
149 | - .resetvalue = cpu->id_aa64dfr1 }, | ||
150 | + .resetvalue = cpu->isar.id_aa64dfr1 }, | ||
151 | { .name = "ID_AA64DFR2_EL1_RESERVED", .state = ARM_CP_STATE_AA64, | ||
152 | .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 5, .opc2 = 2, | ||
153 | .access = PL1_R, .type = ARM_CP_CONST, | ||
154 | -- | ||
155 | 2.20.1 | ||
156 | |||
157 | diff view generated by jsdifflib |
1 | Many of the devices on the Musca board live behind TrustZone | 1 | The AArch32 DBGDIDR defines properties like the number of |
---|---|---|---|
2 | Peripheral Protection Controllers (PPCs); add models of the | 2 | breakpoints, watchpoints and context-matching comparators. On an |
3 | PPCs, using a similar scheme to the MPS2 board models. | 3 | AArch64 CPU, the register may not even exist if AArch32 is not |
4 | This commit wires up the PPCs with "unimplemented device" | 4 | supported at EL1. |
5 | stubs behind them in the correct places in the address map. | 5 | |
6 | Currently we hard-code use of DBGDIDR to identify the number of | ||
7 | breakpoints etc; this works for all our TCG CPUs, but will break if | ||
8 | we ever add an AArch64-only CPU. We also have an assert() that the | ||
9 | AArch32 and AArch64 registers match, which currently works only by | ||
10 | luck for KVM because we don't populate either of these ID registers | ||
11 | from the KVM vCPU and so they are both zero. | ||
12 | |||
13 | Clean this up so we have functions for finding the number | ||
14 | of breakpoints, watchpoints and context comparators which look | ||
15 | in the appropriate ID register. | ||
16 | |||
17 | This allows us to drop the "check that AArch64 and AArch32 agree | ||
18 | on the number of breakpoints etc" asserts: | ||
19 | * we no longer look at the AArch32 versions unless that's the | ||
20 | right place to be looking | ||
21 | * it's valid to have a CPU (eg AArch64-only) where they don't match | ||
22 | * we shouldn't have been asserting the validity of ID registers | ||
23 | in a codepath used with KVM anyway | ||
6 | 24 | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 25 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 26 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
27 | Message-id: 20200214175116.9164-11-peter.maydell@linaro.org | ||
9 | --- | 28 | --- |
10 | hw/arm/musca.c | 289 +++++++++++++++++++++++++++++++++++++++++++++++++ | 29 | target/arm/cpu.h | 7 +++++++ |
11 | 1 file changed, 289 insertions(+) | 30 | target/arm/internals.h | 42 +++++++++++++++++++++++++++++++++++++++ |
31 | target/arm/debug_helper.c | 6 +++--- | ||
32 | target/arm/helper.c | 21 +++++--------------- | ||
33 | 4 files changed, 57 insertions(+), 19 deletions(-) | ||
12 | 34 | ||
13 | diff --git a/hw/arm/musca.c b/hw/arm/musca.c | 35 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
14 | index XXXXXXX..XXXXXXX 100644 | 36 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/hw/arm/musca.c | 37 | --- a/target/arm/cpu.h |
16 | +++ b/hw/arm/musca.c | 38 | +++ b/target/arm/cpu.h |
17 | @@ -XXX,XX +XXX,XX @@ | 39 | @@ -XXX,XX +XXX,XX @@ FIELD(ID_DFR0, MPROFDBG, 20, 4) |
18 | #include "hw/arm/armsse.h" | 40 | FIELD(ID_DFR0, PERFMON, 24, 4) |
19 | #include "hw/boards.h" | 41 | FIELD(ID_DFR0, TRACEFILT, 28, 4) |
20 | #include "hw/core/split-irq.h" | 42 | |
21 | +#include "hw/misc/tz-ppc.h" | 43 | +FIELD(DBGDIDR, SE_IMP, 12, 1) |
22 | +#include "hw/misc/unimp.h" | 44 | +FIELD(DBGDIDR, NSUHD_IMP, 14, 1) |
23 | 45 | +FIELD(DBGDIDR, VERSION, 16, 4) | |
24 | #define MUSCA_NUMIRQ_MAX 96 | 46 | +FIELD(DBGDIDR, CTX_CMPS, 20, 4) |
25 | +#define MUSCA_PPC_MAX 3 | 47 | +FIELD(DBGDIDR, BRPS, 24, 4) |
26 | 48 | +FIELD(DBGDIDR, WRPS, 28, 4) | |
27 | typedef enum MuscaType { | 49 | + |
28 | MUSCA_A, | 50 | FIELD(MVFR0, SIMDREG, 0, 4) |
29 | @@ -XXX,XX +XXX,XX @@ typedef struct { | 51 | FIELD(MVFR0, FPSP, 4, 4) |
30 | 52 | FIELD(MVFR0, FPDP, 8, 4) | |
31 | ARMSSE sse; | 53 | diff --git a/target/arm/internals.h b/target/arm/internals.h |
32 | SplitIRQ cpu_irq_splitter[MUSCA_NUMIRQ_MAX]; | 54 | index XXXXXXX..XXXXXXX 100644 |
33 | + SplitIRQ sec_resp_splitter; | 55 | --- a/target/arm/internals.h |
34 | + TZPPC ppc[MUSCA_PPC_MAX]; | 56 | +++ b/target/arm/internals.h |
35 | + MemoryRegion container; | 57 | @@ -XXX,XX +XXX,XX @@ static inline uint32_t arm_debug_exception_fsr(CPUARMState *env) |
36 | + UnimplementedDeviceState eflash[2]; | 58 | } |
37 | + UnimplementedDeviceState qspi; | 59 | } |
38 | + UnimplementedDeviceState mpc[5]; | 60 | |
39 | + UnimplementedDeviceState mhu[2]; | 61 | +/** |
40 | + UnimplementedDeviceState pwm[3]; | 62 | + * arm_num_brps: Return number of implemented breakpoints. |
41 | + UnimplementedDeviceState i2s; | 63 | + * Note that the ID register BRPS field is "number of bps - 1", |
42 | + UnimplementedDeviceState uart[2]; | 64 | + * and we return the actual number of breakpoints. |
43 | + UnimplementedDeviceState i2c[2]; | ||
44 | + UnimplementedDeviceState spi; | ||
45 | + UnimplementedDeviceState scc; | ||
46 | + UnimplementedDeviceState timer; | ||
47 | + UnimplementedDeviceState rtc; | ||
48 | + UnimplementedDeviceState pvt; | ||
49 | + UnimplementedDeviceState sdio; | ||
50 | + UnimplementedDeviceState gpio; | ||
51 | } MuscaMachineState; | ||
52 | |||
53 | #define TYPE_MUSCA_MACHINE "musca" | ||
54 | @@ -XXX,XX +XXX,XX @@ typedef struct { | ||
55 | */ | ||
56 | #define SYSCLK_FRQ 40000000 | ||
57 | |||
58 | +/* | ||
59 | + * Most of the devices in the Musca board sit behind Peripheral Protection | ||
60 | + * Controllers. These data structures define the layout of which devices | ||
61 | + * sit behind which PPCs. | ||
62 | + * The devfn for each port is a function which creates, configures | ||
63 | + * and initializes the device, returning the MemoryRegion which | ||
64 | + * needs to be plugged into the downstream end of the PPC port. | ||
65 | + */ | 65 | + */ |
66 | +typedef MemoryRegion *MakeDevFn(MuscaMachineState *mms, void *opaque, | 66 | +static inline int arm_num_brps(ARMCPU *cpu) |
67 | + const char *name, hwaddr size); | ||
68 | + | ||
69 | +typedef struct PPCPortInfo { | ||
70 | + const char *name; | ||
71 | + MakeDevFn *devfn; | ||
72 | + void *opaque; | ||
73 | + hwaddr addr; | ||
74 | + hwaddr size; | ||
75 | +} PPCPortInfo; | ||
76 | + | ||
77 | +typedef struct PPCInfo { | ||
78 | + const char *name; | ||
79 | + PPCPortInfo ports[TZ_NUM_PORTS]; | ||
80 | +} PPCInfo; | ||
81 | + | ||
82 | +static MemoryRegion *make_unimp_dev(MuscaMachineState *mms, | ||
83 | + void *opaque, const char *name, hwaddr size) | ||
84 | +{ | 67 | +{ |
85 | + /* | 68 | + if (arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) { |
86 | + * Initialize, configure and realize a TYPE_UNIMPLEMENTED_DEVICE, | 69 | + return FIELD_EX64(cpu->isar.id_aa64dfr0, ID_AA64DFR0, BRPS) + 1; |
87 | + * and return a pointer to its MemoryRegion. | 70 | + } else { |
88 | + */ | 71 | + return FIELD_EX32(cpu->dbgdidr, DBGDIDR, BRPS) + 1; |
89 | + UnimplementedDeviceState *uds = opaque; | 72 | + } |
90 | + | ||
91 | + sysbus_init_child_obj(OBJECT(mms), name, uds, | ||
92 | + sizeof(UnimplementedDeviceState), | ||
93 | + TYPE_UNIMPLEMENTED_DEVICE); | ||
94 | + qdev_prop_set_string(DEVICE(uds), "name", name); | ||
95 | + qdev_prop_set_uint64(DEVICE(uds), "size", size); | ||
96 | + object_property_set_bool(OBJECT(uds), true, "realized", &error_fatal); | ||
97 | + return sysbus_mmio_get_region(SYS_BUS_DEVICE(uds), 0); | ||
98 | +} | 73 | +} |
99 | + | 74 | + |
100 | +static MemoryRegion *make_musca_a_devs(MuscaMachineState *mms, void *opaque, | 75 | +/** |
101 | + const char *name, hwaddr size) | 76 | + * arm_num_wrps: Return number of implemented watchpoints. |
77 | + * Note that the ID register WRPS field is "number of wps - 1", | ||
78 | + * and we return the actual number of watchpoints. | ||
79 | + */ | ||
80 | +static inline int arm_num_wrps(ARMCPU *cpu) | ||
102 | +{ | 81 | +{ |
103 | + /* | 82 | + if (arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) { |
104 | + * Create the container MemoryRegion for all the devices that live | 83 | + return FIELD_EX64(cpu->isar.id_aa64dfr0, ID_AA64DFR0, WRPS) + 1; |
105 | + * behind the Musca-A PPC's single port. These devices don't have a PPC | 84 | + } else { |
106 | + * port each, but we use the PPCPortInfo struct as a convenient way | 85 | + return FIELD_EX32(cpu->dbgdidr, DBGDIDR, WRPS) + 1; |
107 | + * to describe them. Note that addresses here are relative to the base | ||
108 | + * address of the PPC port region: 0x40100000, and devices appear both | ||
109 | + * at the 0x4... NS region and the 0x5... S region. | ||
110 | + */ | ||
111 | + int i; | ||
112 | + MemoryRegion *container = &mms->container; | ||
113 | + | ||
114 | + const PPCPortInfo devices[] = { | ||
115 | + { "uart0", make_unimp_dev, &mms->uart[0], 0x1000, 0x1000 }, | ||
116 | + { "uart1", make_unimp_dev, &mms->uart[1], 0x2000, 0x1000 }, | ||
117 | + { "spi", make_unimp_dev, &mms->spi, 0x3000, 0x1000 }, | ||
118 | + { "i2c0", make_unimp_dev, &mms->i2c[0], 0x4000, 0x1000 }, | ||
119 | + { "i2c1", make_unimp_dev, &mms->i2c[1], 0x5000, 0x1000 }, | ||
120 | + { "i2s", make_unimp_dev, &mms->i2s, 0x6000, 0x1000 }, | ||
121 | + { "pwm0", make_unimp_dev, &mms->pwm[0], 0x7000, 0x1000 }, | ||
122 | + { "rtc", make_unimp_dev, &mms->rtc, 0x8000, 0x1000 }, | ||
123 | + { "qspi", make_unimp_dev, &mms->qspi, 0xa000, 0x1000 }, | ||
124 | + { "timer", make_unimp_dev, &mms->timer, 0xb000, 0x1000 }, | ||
125 | + { "scc", make_unimp_dev, &mms->scc, 0xc000, 0x1000 }, | ||
126 | + { "pwm1", make_unimp_dev, &mms->pwm[1], 0xe000, 0x1000 }, | ||
127 | + { "pwm2", make_unimp_dev, &mms->pwm[2], 0xf000, 0x1000 }, | ||
128 | + { "gpio", make_unimp_dev, &mms->gpio, 0x10000, 0x1000 }, | ||
129 | + { "mpc0", make_unimp_dev, &mms->mpc[0], 0x12000, 0x1000 }, | ||
130 | + { "mpc1", make_unimp_dev, &mms->mpc[1], 0x13000, 0x1000 }, | ||
131 | + }; | ||
132 | + | ||
133 | + memory_region_init(container, OBJECT(mms), "musca-device-container", size); | ||
134 | + | ||
135 | + for (i = 0; i < ARRAY_SIZE(devices); i++) { | ||
136 | + const PPCPortInfo *pinfo = &devices[i]; | ||
137 | + MemoryRegion *mr; | ||
138 | + | ||
139 | + mr = pinfo->devfn(mms, pinfo->opaque, pinfo->name, pinfo->size); | ||
140 | + memory_region_add_subregion(container, pinfo->addr, mr); | ||
141 | + } | 86 | + } |
142 | + | ||
143 | + return &mms->container; | ||
144 | +} | 87 | +} |
145 | + | 88 | + |
146 | static void musca_init(MachineState *machine) | 89 | +/** |
90 | + * arm_num_ctx_cmps: Return number of implemented context comparators. | ||
91 | + * Note that the ID register CTX_CMPS field is "number of cmps - 1", | ||
92 | + * and we return the actual number of comparators. | ||
93 | + */ | ||
94 | +static inline int arm_num_ctx_cmps(ARMCPU *cpu) | ||
95 | +{ | ||
96 | + if (arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) { | ||
97 | + return FIELD_EX64(cpu->isar.id_aa64dfr0, ID_AA64DFR0, CTX_CMPS) + 1; | ||
98 | + } else { | ||
99 | + return FIELD_EX32(cpu->dbgdidr, DBGDIDR, CTX_CMPS) + 1; | ||
100 | + } | ||
101 | +} | ||
102 | + | ||
103 | /* Note make_memop_idx reserves 4 bits for mmu_idx, and MO_BSWAP is bit 3. | ||
104 | * Thus a TCGMemOpIdx, without any MO_ALIGN bits, fits in 8 bits. | ||
105 | */ | ||
106 | diff --git a/target/arm/debug_helper.c b/target/arm/debug_helper.c | ||
107 | index XXXXXXX..XXXXXXX 100644 | ||
108 | --- a/target/arm/debug_helper.c | ||
109 | +++ b/target/arm/debug_helper.c | ||
110 | @@ -XXX,XX +XXX,XX @@ static bool linked_bp_matches(ARMCPU *cpu, int lbn) | ||
147 | { | 111 | { |
148 | MuscaMachineState *mms = MUSCA_MACHINE(machine); | 112 | CPUARMState *env = &cpu->env; |
149 | @@ -XXX,XX +XXX,XX @@ static void musca_init(MachineState *machine) | 113 | uint64_t bcr = env->cp15.dbgbcr[lbn]; |
150 | MachineClass *mc = MACHINE_GET_CLASS(machine); | 114 | - int brps = extract32(cpu->dbgdidr, 24, 4); |
151 | MemoryRegion *system_memory = get_system_memory(); | 115 | - int ctx_cmps = extract32(cpu->dbgdidr, 20, 4); |
152 | DeviceState *ssedev; | 116 | + int brps = arm_num_brps(cpu); |
153 | + DeviceState *dev_splitter; | 117 | + int ctx_cmps = arm_num_ctx_cmps(cpu); |
154 | + const PPCInfo *ppcs; | 118 | int bt; |
155 | + int num_ppcs; | 119 | uint32_t contextidr; |
156 | int i; | 120 | uint64_t hcr_el2; |
157 | 121 | @@ -XXX,XX +XXX,XX @@ static bool linked_bp_matches(ARMCPU *cpu, int lbn) | |
158 | assert(mmc->num_irqs <= MUSCA_NUMIRQ_MAX); | 122 | * case DBGWCR<n>_EL1.LBN must indicate that breakpoint). |
159 | @@ -XXX,XX +XXX,XX @@ static void musca_init(MachineState *machine) | 123 | * We choose the former. |
160 | "EXP_CPU1_IRQ", i)); | 124 | */ |
125 | - if (lbn > brps || lbn < (brps - ctx_cmps)) { | ||
126 | + if (lbn >= brps || lbn < (brps - ctx_cmps)) { | ||
127 | return false; | ||
161 | } | 128 | } |
162 | 129 | ||
163 | + /* | 130 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
164 | + * The sec_resp_cfg output from the SSE-200 must be split into multiple | 131 | index XXXXXXX..XXXXXXX 100644 |
165 | + * lines, one for each of the PPCs we create here. | 132 | --- a/target/arm/helper.c |
166 | + */ | 133 | +++ b/target/arm/helper.c |
167 | + object_initialize(&mms->sec_resp_splitter, sizeof(mms->sec_resp_splitter), | 134 | @@ -XXX,XX +XXX,XX @@ static void define_debug_regs(ARMCPU *cpu) |
168 | + TYPE_SPLIT_IRQ); | 135 | }; |
169 | + object_property_add_child(OBJECT(machine), "sec-resp-splitter", | 136 | |
170 | + OBJECT(&mms->sec_resp_splitter), &error_fatal); | 137 | /* Note that all these register fields hold "number of Xs minus 1". */ |
171 | + object_property_set_int(OBJECT(&mms->sec_resp_splitter), | 138 | - brps = extract32(cpu->dbgdidr, 24, 4); |
172 | + ARRAY_SIZE(mms->ppc), "num-lines", &error_fatal); | 139 | - wrps = extract32(cpu->dbgdidr, 28, 4); |
173 | + object_property_set_bool(OBJECT(&mms->sec_resp_splitter), true, | 140 | - ctx_cmps = extract32(cpu->dbgdidr, 20, 4); |
174 | + "realized", &error_fatal); | 141 | + brps = arm_num_brps(cpu); |
175 | + dev_splitter = DEVICE(&mms->sec_resp_splitter); | 142 | + wrps = arm_num_wrps(cpu); |
176 | + qdev_connect_gpio_out_named(ssedev, "sec_resp_cfg", 0, | 143 | + ctx_cmps = arm_num_ctx_cmps(cpu); |
177 | + qdev_get_gpio_in(dev_splitter, 0)); | 144 | |
178 | + | 145 | assert(ctx_cmps <= brps); |
179 | + /* | 146 | |
180 | + * Most of the devices in the board are behind Peripheral Protection | 147 | - /* The DBGDIDR and ID_AA64DFR0_EL1 define various properties |
181 | + * Controllers. The required order for initializing things is: | 148 | - * of the debug registers such as number of breakpoints; |
182 | + * + initialize the PPC | 149 | - * check that if they both exist then they agree. |
183 | + * + initialize, configure and realize downstream devices | 150 | - */ |
184 | + * + connect downstream device MemoryRegions to the PPC | 151 | - if (arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) { |
185 | + * + realize the PPC | 152 | - assert(FIELD_EX64(cpu->isar.id_aa64dfr0, ID_AA64DFR0, BRPS) == brps); |
186 | + * + map the PPC's MemoryRegions to the places in the address map | 153 | - assert(FIELD_EX64(cpu->isar.id_aa64dfr0, ID_AA64DFR0, WRPS) == wrps); |
187 | + * where the downstream devices should appear | 154 | - assert(FIELD_EX64(cpu->isar.id_aa64dfr0, ID_AA64DFR0, CTX_CMPS) |
188 | + * + wire up the PPC's control lines to the SSE object | 155 | - == ctx_cmps); |
189 | + * | 156 | - } |
190 | + * The PPC mapping differs for the -A and -B1 variants; the -A version | 157 | - |
191 | + * is much simpler, using only a single port of a single PPC and putting | 158 | define_one_arm_cp_reg(cpu, &dbgdidr); |
192 | + * all the devices behind that. | 159 | define_arm_cp_regs(cpu, debug_cp_reginfo); |
193 | + */ | 160 | |
194 | + const PPCInfo a_ppcs[] = { { | 161 | @@ -XXX,XX +XXX,XX @@ static void define_debug_regs(ARMCPU *cpu) |
195 | + .name = "ahb_ppcexp0", | 162 | define_arm_cp_regs(cpu, debug_lpae_cp_reginfo); |
196 | + .ports = { | 163 | } |
197 | + { "musca-devices", make_musca_a_devs, 0, 0x40100000, 0x100000 }, | 164 | |
198 | + }, | 165 | - for (i = 0; i < brps + 1; i++) { |
199 | + }, | 166 | + for (i = 0; i < brps; i++) { |
200 | + }; | 167 | ARMCPRegInfo dbgregs[] = { |
201 | + | 168 | { .name = "DBGBVR", .state = ARM_CP_STATE_BOTH, |
202 | + /* | 169 | .cp = 14, .opc0 = 2, .opc1 = 0, .crn = 0, .crm = i, .opc2 = 4, |
203 | + * Devices listed with an 0x4.. address appear in both the NS 0x4.. region | 170 | @@ -XXX,XX +XXX,XX @@ static void define_debug_regs(ARMCPU *cpu) |
204 | + * and the 0x5.. S region. Devices listed with an 0x5.. address appear | 171 | define_arm_cp_regs(cpu, dbgregs); |
205 | + * only in the S region. | 172 | } |
206 | + */ | 173 | |
207 | + const PPCInfo b1_ppcs[] = { { | 174 | - for (i = 0; i < wrps + 1; i++) { |
208 | + .name = "apb_ppcexp0", | 175 | + for (i = 0; i < wrps; i++) { |
209 | + .ports = { | 176 | ARMCPRegInfo dbgregs[] = { |
210 | + { "eflash0", make_unimp_dev, &mms->eflash[0], | 177 | { .name = "DBGWVR", .state = ARM_CP_STATE_BOTH, |
211 | + 0x52400000, 0x1000 }, | 178 | .cp = 14, .opc0 = 2, .opc1 = 0, .crn = 0, .crm = i, .opc2 = 6, |
212 | + { "eflash1", make_unimp_dev, &mms->eflash[1], | ||
213 | + 0x52500000, 0x1000 }, | ||
214 | + { "qspi", make_unimp_dev, &mms->qspi, 0x42800000, 0x100000 }, | ||
215 | + { "mpc0", make_unimp_dev, &mms->mpc[0], 0x52000000, 0x1000 }, | ||
216 | + { "mpc1", make_unimp_dev, &mms->mpc[1], 0x52100000, 0x1000 }, | ||
217 | + { "mpc2", make_unimp_dev, &mms->mpc[2], 0x52200000, 0x1000 }, | ||
218 | + { "mpc3", make_unimp_dev, &mms->mpc[3], 0x52300000, 0x1000 }, | ||
219 | + { "mhu0", make_unimp_dev, &mms->mhu[0], 0x42600000, 0x100000 }, | ||
220 | + { "mhu1", make_unimp_dev, &mms->mhu[1], 0x42700000, 0x100000 }, | ||
221 | + { }, /* port 9: unused */ | ||
222 | + { }, /* port 10: unused */ | ||
223 | + { }, /* port 11: unused */ | ||
224 | + { }, /* port 12: unused */ | ||
225 | + { }, /* port 13: unused */ | ||
226 | + { "mpc4", make_unimp_dev, &mms->mpc[4], 0x52e00000, 0x1000 }, | ||
227 | + }, | ||
228 | + }, { | ||
229 | + .name = "apb_ppcexp1", | ||
230 | + .ports = { | ||
231 | + { "pwm0", make_unimp_dev, &mms->pwm[0], 0x40101000, 0x1000 }, | ||
232 | + { "pwm1", make_unimp_dev, &mms->pwm[1], 0x40102000, 0x1000 }, | ||
233 | + { "pwm2", make_unimp_dev, &mms->pwm[2], 0x40103000, 0x1000 }, | ||
234 | + { "i2s", make_unimp_dev, &mms->i2s, 0x40104000, 0x1000 }, | ||
235 | + { "uart0", make_unimp_dev, &mms->uart[0], 0x40105000, 0x1000 }, | ||
236 | + { "uart1", make_unimp_dev, &mms->uart[1], 0x40106000, 0x1000 }, | ||
237 | + { "i2c0", make_unimp_dev, &mms->i2c[0], 0x40108000, 0x1000 }, | ||
238 | + { "i2c1", make_unimp_dev, &mms->i2c[1], 0x40109000, 0x1000 }, | ||
239 | + { "spi", make_unimp_dev, &mms->spi, 0x4010a000, 0x1000 }, | ||
240 | + { "scc", make_unimp_dev, &mms->scc, 0x5010b000, 0x1000 }, | ||
241 | + { "timer", make_unimp_dev, &mms->timer, 0x4010c000, 0x1000 }, | ||
242 | + { "rtc", make_unimp_dev, &mms->rtc, 0x4010d000, 0x1000 }, | ||
243 | + { "pvt", make_unimp_dev, &mms->pvt, 0x4010e000, 0x1000 }, | ||
244 | + { "sdio", make_unimp_dev, &mms->sdio, 0x4010f000, 0x1000 }, | ||
245 | + }, | ||
246 | + }, { | ||
247 | + .name = "ahb_ppcexp0", | ||
248 | + .ports = { | ||
249 | + { }, /* port 0: unused */ | ||
250 | + { "gpio", make_unimp_dev, &mms->gpio, 0x41000000, 0x1000 }, | ||
251 | + }, | ||
252 | + }, | ||
253 | + }; | ||
254 | + | ||
255 | + switch (mmc->type) { | ||
256 | + case MUSCA_A: | ||
257 | + ppcs = a_ppcs; | ||
258 | + num_ppcs = ARRAY_SIZE(a_ppcs); | ||
259 | + break; | ||
260 | + case MUSCA_B1: | ||
261 | + ppcs = b1_ppcs; | ||
262 | + num_ppcs = ARRAY_SIZE(b1_ppcs); | ||
263 | + break; | ||
264 | + default: | ||
265 | + g_assert_not_reached(); | ||
266 | + } | ||
267 | + assert(num_ppcs <= MUSCA_PPC_MAX); | ||
268 | + | ||
269 | + for (i = 0; i < num_ppcs; i++) { | ||
270 | + const PPCInfo *ppcinfo = &ppcs[i]; | ||
271 | + TZPPC *ppc = &mms->ppc[i]; | ||
272 | + DeviceState *ppcdev; | ||
273 | + int port; | ||
274 | + char *gpioname; | ||
275 | + | ||
276 | + sysbus_init_child_obj(OBJECT(machine), ppcinfo->name, ppc, | ||
277 | + sizeof(TZPPC), TYPE_TZ_PPC); | ||
278 | + ppcdev = DEVICE(ppc); | ||
279 | + | ||
280 | + for (port = 0; port < TZ_NUM_PORTS; port++) { | ||
281 | + const PPCPortInfo *pinfo = &ppcinfo->ports[port]; | ||
282 | + MemoryRegion *mr; | ||
283 | + char *portname; | ||
284 | + | ||
285 | + if (!pinfo->devfn) { | ||
286 | + continue; | ||
287 | + } | ||
288 | + | ||
289 | + mr = pinfo->devfn(mms, pinfo->opaque, pinfo->name, pinfo->size); | ||
290 | + portname = g_strdup_printf("port[%d]", port); | ||
291 | + object_property_set_link(OBJECT(ppc), OBJECT(mr), | ||
292 | + portname, &error_fatal); | ||
293 | + g_free(portname); | ||
294 | + } | ||
295 | + | ||
296 | + object_property_set_bool(OBJECT(ppc), true, "realized", &error_fatal); | ||
297 | + | ||
298 | + for (port = 0; port < TZ_NUM_PORTS; port++) { | ||
299 | + const PPCPortInfo *pinfo = &ppcinfo->ports[port]; | ||
300 | + | ||
301 | + if (!pinfo->devfn) { | ||
302 | + continue; | ||
303 | + } | ||
304 | + sysbus_mmio_map(SYS_BUS_DEVICE(ppc), port, pinfo->addr); | ||
305 | + | ||
306 | + gpioname = g_strdup_printf("%s_nonsec", ppcinfo->name); | ||
307 | + qdev_connect_gpio_out_named(ssedev, gpioname, port, | ||
308 | + qdev_get_gpio_in_named(ppcdev, | ||
309 | + "cfg_nonsec", | ||
310 | + port)); | ||
311 | + g_free(gpioname); | ||
312 | + gpioname = g_strdup_printf("%s_ap", ppcinfo->name); | ||
313 | + qdev_connect_gpio_out_named(ssedev, gpioname, port, | ||
314 | + qdev_get_gpio_in_named(ppcdev, | ||
315 | + "cfg_ap", port)); | ||
316 | + g_free(gpioname); | ||
317 | + } | ||
318 | + | ||
319 | + gpioname = g_strdup_printf("%s_irq_enable", ppcinfo->name); | ||
320 | + qdev_connect_gpio_out_named(ssedev, gpioname, 0, | ||
321 | + qdev_get_gpio_in_named(ppcdev, | ||
322 | + "irq_enable", 0)); | ||
323 | + g_free(gpioname); | ||
324 | + gpioname = g_strdup_printf("%s_irq_clear", ppcinfo->name); | ||
325 | + qdev_connect_gpio_out_named(ssedev, gpioname, 0, | ||
326 | + qdev_get_gpio_in_named(ppcdev, | ||
327 | + "irq_clear", 0)); | ||
328 | + g_free(gpioname); | ||
329 | + gpioname = g_strdup_printf("%s_irq_status", ppcinfo->name); | ||
330 | + qdev_connect_gpio_out_named(ppcdev, "irq", 0, | ||
331 | + qdev_get_gpio_in_named(ssedev, | ||
332 | + gpioname, 0)); | ||
333 | + g_free(gpioname); | ||
334 | + | ||
335 | + qdev_connect_gpio_out(dev_splitter, i, | ||
336 | + qdev_get_gpio_in_named(ppcdev, | ||
337 | + "cfg_sec_resp", 0)); | ||
338 | + } | ||
339 | + | ||
340 | armv7m_load_kernel(ARM_CPU(first_cpu), machine->kernel_filename, 0x2000000); | ||
341 | } | ||
342 | |||
343 | -- | 179 | -- |
344 | 2.20.1 | 180 | 2.20.1 |
345 | 181 | ||
346 | 182 | diff view generated by jsdifflib |
1 | Convert the debug printing in the PL031 device to use trace events, | 1 | We're going to want to read the DBGDIDR register from KVM in |
---|---|---|---|
2 | and augment it to cover the interesting parts of device operation. | 2 | a subsequent commit, which means it needs to be in the |
3 | ARMISARegisters sub-struct. Move it. | ||
3 | 4 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
7 | Message-id: 20200214175116.9164-12-peter.maydell@linaro.org | ||
7 | --- | 8 | --- |
8 | hw/timer/pl031.c | 55 +++++++++++++++++++++++-------------------- | 9 | target/arm/cpu.h | 2 +- |
9 | hw/timer/trace-events | 6 +++++ | 10 | target/arm/internals.h | 6 +++--- |
10 | 2 files changed, 36 insertions(+), 25 deletions(-) | 11 | target/arm/cpu.c | 8 ++++---- |
12 | target/arm/cpu64.c | 6 +++--- | ||
13 | target/arm/helper.c | 2 +- | ||
14 | 5 files changed, 12 insertions(+), 12 deletions(-) | ||
11 | 15 | ||
12 | diff --git a/hw/timer/pl031.c b/hw/timer/pl031.c | 16 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
13 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
14 | --- a/hw/timer/pl031.c | 18 | --- a/target/arm/cpu.h |
15 | +++ b/hw/timer/pl031.c | 19 | +++ b/target/arm/cpu.h |
16 | @@ -XXX,XX +XXX,XX @@ | 20 | @@ -XXX,XX +XXX,XX @@ struct ARMCPU { |
17 | #include "sysemu/sysemu.h" | 21 | uint32_t mvfr1; |
18 | #include "qemu/cutils.h" | 22 | uint32_t mvfr2; |
19 | #include "qemu/log.h" | 23 | uint32_t id_dfr0; |
20 | - | 24 | + uint32_t dbgdidr; |
21 | -//#define DEBUG_PL031 | 25 | uint64_t id_aa64isar0; |
22 | - | 26 | uint64_t id_aa64isar1; |
23 | -#ifdef DEBUG_PL031 | 27 | uint64_t id_aa64pfr0; |
24 | -#define DPRINTF(fmt, ...) \ | 28 | @@ -XXX,XX +XXX,XX @@ struct ARMCPU { |
25 | -do { printf("pl031: " fmt , ## __VA_ARGS__); } while (0) | 29 | uint32_t id_mmfr4; |
26 | -#else | 30 | uint64_t id_aa64afr0; |
27 | -#define DPRINTF(fmt, ...) do {} while(0) | 31 | uint64_t id_aa64afr1; |
28 | -#endif | 32 | - uint32_t dbgdidr; |
29 | +#include "trace.h" | 33 | uint32_t clidr; |
30 | 34 | uint64_t mp_affinity; /* MP ID without feature bits */ | |
31 | #define RTC_DR 0x00 /* Data read register */ | 35 | /* The elements of this array are the CCSIDR values for each cache, |
32 | #define RTC_MR 0x04 /* Match register */ | 36 | diff --git a/target/arm/internals.h b/target/arm/internals.h |
33 | @@ -XXX,XX +XXX,XX @@ static const unsigned char pl031_id[] = { | 37 | index XXXXXXX..XXXXXXX 100644 |
34 | 38 | --- a/target/arm/internals.h | |
35 | static void pl031_update(PL031State *s) | 39 | +++ b/target/arm/internals.h |
36 | { | 40 | @@ -XXX,XX +XXX,XX @@ static inline int arm_num_brps(ARMCPU *cpu) |
37 | - qemu_set_irq(s->irq, s->is & s->im); | 41 | if (arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) { |
38 | + uint32_t flags = s->is & s->im; | 42 | return FIELD_EX64(cpu->isar.id_aa64dfr0, ID_AA64DFR0, BRPS) + 1; |
39 | + | 43 | } else { |
40 | + trace_pl031_irq_state(flags); | 44 | - return FIELD_EX32(cpu->dbgdidr, DBGDIDR, BRPS) + 1; |
41 | + qemu_set_irq(s->irq, flags); | 45 | + return FIELD_EX32(cpu->isar.dbgdidr, DBGDIDR, BRPS) + 1; |
46 | } | ||
42 | } | 47 | } |
43 | 48 | ||
44 | static void pl031_interrupt(void * opaque) | 49 | @@ -XXX,XX +XXX,XX @@ static inline int arm_num_wrps(ARMCPU *cpu) |
45 | @@ -XXX,XX +XXX,XX @@ static void pl031_interrupt(void * opaque) | 50 | if (arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) { |
46 | PL031State *s = (PL031State *)opaque; | 51 | return FIELD_EX64(cpu->isar.id_aa64dfr0, ID_AA64DFR0, WRPS) + 1; |
47 | 52 | } else { | |
48 | s->is = 1; | 53 | - return FIELD_EX32(cpu->dbgdidr, DBGDIDR, WRPS) + 1; |
49 | - DPRINTF("Alarm raised\n"); | 54 | + return FIELD_EX32(cpu->isar.dbgdidr, DBGDIDR, WRPS) + 1; |
50 | + trace_pl031_alarm_raised(); | 55 | } |
51 | pl031_update(s); | ||
52 | } | 56 | } |
53 | 57 | ||
54 | @@ -XXX,XX +XXX,XX @@ static void pl031_set_alarm(PL031State *s) | 58 | @@ -XXX,XX +XXX,XX @@ static inline int arm_num_ctx_cmps(ARMCPU *cpu) |
55 | /* The timer wraps around. This subtraction also wraps in the same way, | 59 | if (arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) { |
56 | and gives correct results when alarm < now_ticks. */ | 60 | return FIELD_EX64(cpu->isar.id_aa64dfr0, ID_AA64DFR0, CTX_CMPS) + 1; |
57 | ticks = s->mr - pl031_get_count(s); | 61 | } else { |
58 | - DPRINTF("Alarm set in %ud ticks\n", ticks); | 62 | - return FIELD_EX32(cpu->dbgdidr, DBGDIDR, CTX_CMPS) + 1; |
59 | + trace_pl031_set_alarm(ticks); | 63 | + return FIELD_EX32(cpu->isar.dbgdidr, DBGDIDR, CTX_CMPS) + 1; |
60 | if (ticks == 0) { | ||
61 | timer_del(s->timer); | ||
62 | pl031_interrupt(s); | ||
63 | @@ -XXX,XX +XXX,XX @@ static uint64_t pl031_read(void *opaque, hwaddr offset, | ||
64 | unsigned size) | ||
65 | { | ||
66 | PL031State *s = (PL031State *)opaque; | ||
67 | - | ||
68 | - if (offset >= 0xfe0 && offset < 0x1000) | ||
69 | - return pl031_id[(offset - 0xfe0) >> 2]; | ||
70 | + uint64_t r; | ||
71 | |||
72 | switch (offset) { | ||
73 | case RTC_DR: | ||
74 | - return pl031_get_count(s); | ||
75 | + r = pl031_get_count(s); | ||
76 | + break; | ||
77 | case RTC_MR: | ||
78 | - return s->mr; | ||
79 | + r = s->mr; | ||
80 | + break; | ||
81 | case RTC_IMSC: | ||
82 | - return s->im; | ||
83 | + r = s->im; | ||
84 | + break; | ||
85 | case RTC_RIS: | ||
86 | - return s->is; | ||
87 | + r = s->is; | ||
88 | + break; | ||
89 | case RTC_LR: | ||
90 | - return s->lr; | ||
91 | + r = s->lr; | ||
92 | + break; | ||
93 | case RTC_CR: | ||
94 | /* RTC is permanently enabled. */ | ||
95 | - return 1; | ||
96 | + r = 1; | ||
97 | + break; | ||
98 | case RTC_MIS: | ||
99 | - return s->is & s->im; | ||
100 | + r = s->is & s->im; | ||
101 | + break; | ||
102 | + case 0xfe0 ... 0xfff: | ||
103 | + r = pl031_id[(offset - 0xfe0) >> 2]; | ||
104 | + break; | ||
105 | case RTC_ICR: | ||
106 | qemu_log_mask(LOG_GUEST_ERROR, | ||
107 | "pl031: read of write-only register at offset 0x%x\n", | ||
108 | (int)offset); | ||
109 | + r = 0; | ||
110 | break; | ||
111 | default: | ||
112 | qemu_log_mask(LOG_GUEST_ERROR, | ||
113 | "pl031_read: Bad offset 0x%x\n", (int)offset); | ||
114 | + r = 0; | ||
115 | break; | ||
116 | } | 64 | } |
117 | |||
118 | - return 0; | ||
119 | + trace_pl031_read(offset, r); | ||
120 | + return r; | ||
121 | } | 65 | } |
122 | 66 | ||
123 | static void pl031_write(void * opaque, hwaddr offset, | 67 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c |
124 | @@ -XXX,XX +XXX,XX @@ static void pl031_write(void * opaque, hwaddr offset, | ||
125 | { | ||
126 | PL031State *s = (PL031State *)opaque; | ||
127 | |||
128 | + trace_pl031_write(offset, value); | ||
129 | |||
130 | switch (offset) { | ||
131 | case RTC_LR: | ||
132 | @@ -XXX,XX +XXX,XX @@ static void pl031_write(void * opaque, hwaddr offset, | ||
133 | break; | ||
134 | case RTC_IMSC: | ||
135 | s->im = value & 1; | ||
136 | - DPRINTF("Interrupt mask %d\n", s->im); | ||
137 | pl031_update(s); | ||
138 | break; | ||
139 | case RTC_ICR: | ||
140 | @@ -XXX,XX +XXX,XX @@ static void pl031_write(void * opaque, hwaddr offset, | ||
141 | cleared when bit 0 of the written value is set. However the | ||
142 | arm926e documentation (DDI0287B) states that the interrupt is | ||
143 | cleared when any value is written. */ | ||
144 | - DPRINTF("Interrupt cleared"); | ||
145 | s->is = 0; | ||
146 | pl031_update(s); | ||
147 | break; | ||
148 | diff --git a/hw/timer/trace-events b/hw/timer/trace-events | ||
149 | index XXXXXXX..XXXXXXX 100644 | 68 | index XXXXXXX..XXXXXXX 100644 |
150 | --- a/hw/timer/trace-events | 69 | --- a/target/arm/cpu.c |
151 | +++ b/hw/timer/trace-events | 70 | +++ b/target/arm/cpu.c |
152 | @@ -XXX,XX +XXX,XX @@ xlnx_zynqmp_rtc_gettime(int year, int month, int day, int hour, int min, int sec | 71 | @@ -XXX,XX +XXX,XX @@ static void cortex_a8_initfn(Object *obj) |
153 | nrf51_timer_read(uint64_t addr, uint32_t value, unsigned size) "read addr 0x%" PRIx64 " data 0x%" PRIx32 " size %u" | 72 | cpu->isar.id_isar2 = 0x21232031; |
154 | nrf51_timer_write(uint64_t addr, uint32_t value, unsigned size) "write addr 0x%" PRIx64 " data 0x%" PRIx32 " size %u" | 73 | cpu->isar.id_isar3 = 0x11112131; |
155 | 74 | cpu->isar.id_isar4 = 0x00111142; | |
156 | +# hw/timer/pl031.c | 75 | - cpu->dbgdidr = 0x15141000; |
157 | +pl031_irq_state(int level) "irq state %d" | 76 | + cpu->isar.dbgdidr = 0x15141000; |
158 | +pl031_read(uint32_t addr, uint32_t value) "addr 0x%08x value 0x%08x" | 77 | cpu->clidr = (1 << 27) | (2 << 24) | 3; |
159 | +pl031_write(uint32_t addr, uint32_t value) "addr 0x%08x value 0x%08x" | 78 | cpu->ccsidr[0] = 0xe007e01a; /* 16k L1 dcache. */ |
160 | +pl031_alarm_raised(void) "alarm raised" | 79 | cpu->ccsidr[1] = 0x2007e01a; /* 16k L1 icache. */ |
161 | +pl031_set_alarm(uint32_t ticks) "alarm set for %u ticks" | 80 | @@ -XXX,XX +XXX,XX @@ static void cortex_a9_initfn(Object *obj) |
81 | cpu->isar.id_isar2 = 0x21232041; | ||
82 | cpu->isar.id_isar3 = 0x11112131; | ||
83 | cpu->isar.id_isar4 = 0x00111142; | ||
84 | - cpu->dbgdidr = 0x35141000; | ||
85 | + cpu->isar.dbgdidr = 0x35141000; | ||
86 | cpu->clidr = (1 << 27) | (1 << 24) | 3; | ||
87 | cpu->ccsidr[0] = 0xe00fe019; /* 16k L1 dcache. */ | ||
88 | cpu->ccsidr[1] = 0x200fe019; /* 16k L1 icache. */ | ||
89 | @@ -XXX,XX +XXX,XX @@ static void cortex_a7_initfn(Object *obj) | ||
90 | cpu->isar.id_isar2 = 0x21232041; | ||
91 | cpu->isar.id_isar3 = 0x11112131; | ||
92 | cpu->isar.id_isar4 = 0x10011142; | ||
93 | - cpu->dbgdidr = 0x3515f005; | ||
94 | + cpu->isar.dbgdidr = 0x3515f005; | ||
95 | cpu->clidr = 0x0a200023; | ||
96 | cpu->ccsidr[0] = 0x701fe00a; /* 32K L1 dcache */ | ||
97 | cpu->ccsidr[1] = 0x201fe00a; /* 32K L1 icache */ | ||
98 | @@ -XXX,XX +XXX,XX @@ static void cortex_a15_initfn(Object *obj) | ||
99 | cpu->isar.id_isar2 = 0x21232041; | ||
100 | cpu->isar.id_isar3 = 0x11112131; | ||
101 | cpu->isar.id_isar4 = 0x10011142; | ||
102 | - cpu->dbgdidr = 0x3515f021; | ||
103 | + cpu->isar.dbgdidr = 0x3515f021; | ||
104 | cpu->clidr = 0x0a200023; | ||
105 | cpu->ccsidr[0] = 0x701fe00a; /* 32K L1 dcache */ | ||
106 | cpu->ccsidr[1] = 0x201fe00a; /* 32K L1 icache */ | ||
107 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | ||
108 | index XXXXXXX..XXXXXXX 100644 | ||
109 | --- a/target/arm/cpu64.c | ||
110 | +++ b/target/arm/cpu64.c | ||
111 | @@ -XXX,XX +XXX,XX @@ static void aarch64_a57_initfn(Object *obj) | ||
112 | cpu->isar.id_aa64dfr0 = 0x10305106; | ||
113 | cpu->isar.id_aa64isar0 = 0x00011120; | ||
114 | cpu->isar.id_aa64mmfr0 = 0x00001124; | ||
115 | - cpu->dbgdidr = 0x3516d000; | ||
116 | + cpu->isar.dbgdidr = 0x3516d000; | ||
117 | cpu->clidr = 0x0a200023; | ||
118 | cpu->ccsidr[0] = 0x701fe00a; /* 32KB L1 dcache */ | ||
119 | cpu->ccsidr[1] = 0x201fe012; /* 48KB L1 icache */ | ||
120 | @@ -XXX,XX +XXX,XX @@ static void aarch64_a53_initfn(Object *obj) | ||
121 | cpu->isar.id_aa64dfr0 = 0x10305106; | ||
122 | cpu->isar.id_aa64isar0 = 0x00011120; | ||
123 | cpu->isar.id_aa64mmfr0 = 0x00001122; /* 40 bit physical addr */ | ||
124 | - cpu->dbgdidr = 0x3516d000; | ||
125 | + cpu->isar.dbgdidr = 0x3516d000; | ||
126 | cpu->clidr = 0x0a200023; | ||
127 | cpu->ccsidr[0] = 0x700fe01a; /* 32KB L1 dcache */ | ||
128 | cpu->ccsidr[1] = 0x201fe00a; /* 32KB L1 icache */ | ||
129 | @@ -XXX,XX +XXX,XX @@ static void aarch64_a72_initfn(Object *obj) | ||
130 | cpu->isar.id_aa64dfr0 = 0x10305106; | ||
131 | cpu->isar.id_aa64isar0 = 0x00011120; | ||
132 | cpu->isar.id_aa64mmfr0 = 0x00001124; | ||
133 | - cpu->dbgdidr = 0x3516d000; | ||
134 | + cpu->isar.dbgdidr = 0x3516d000; | ||
135 | cpu->clidr = 0x0a200023; | ||
136 | cpu->ccsidr[0] = 0x701fe00a; /* 32KB L1 dcache */ | ||
137 | cpu->ccsidr[1] = 0x201fe012; /* 48KB L1 icache */ | ||
138 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
139 | index XXXXXXX..XXXXXXX 100644 | ||
140 | --- a/target/arm/helper.c | ||
141 | +++ b/target/arm/helper.c | ||
142 | @@ -XXX,XX +XXX,XX @@ static void define_debug_regs(ARMCPU *cpu) | ||
143 | ARMCPRegInfo dbgdidr = { | ||
144 | .name = "DBGDIDR", .cp = 14, .crn = 0, .crm = 0, .opc1 = 0, .opc2 = 0, | ||
145 | .access = PL0_R, .accessfn = access_tda, | ||
146 | - .type = ARM_CP_CONST, .resetvalue = cpu->dbgdidr, | ||
147 | + .type = ARM_CP_CONST, .resetvalue = cpu->isar.dbgdidr, | ||
148 | }; | ||
149 | |||
150 | /* Note that all these register fields hold "number of Xs minus 1". */ | ||
162 | -- | 151 | -- |
163 | 2.20.1 | 152 | 2.20.1 |
164 | 153 | ||
165 | 154 | diff view generated by jsdifflib |
1 | The region 0x40010000 .. 0x4001ffff and its secure-only alias | 1 | Now we have isar_feature test functions that look at fields in the |
---|---|---|---|
2 | at 0x50010000... are for per-CPU devices. We implement this by | 2 | ID_AA64DFR0_EL1 and ID_DFR0 ID registers, add the code that reads |
3 | giving each CPU its own container memory region, where the | 3 | these register values from KVM so that the checks behave correctly |
4 | per-CPU devices live. Unfortunately, the alias region which | 4 | when we're using KVM. |
5 | makes devices mapped at 0x4... addresses also appear at 0x5... | ||
6 | is only implemented in the overall "all CPUs" container. The | ||
7 | effect of this bug is that the CPU_IDENTITY register block appears | ||
8 | only at 0x4001f000, but not at the 0x5001f000 alias where it should | ||
9 | also appear. Guests (like very recent Arm Trusted Firmware-M) | ||
10 | which try to access it at 0x5001f000 will crash. | ||
11 | 5 | ||
12 | Fix this by moving the handling for this alias from the "all CPUs" | 6 | No isar_feature function tests ID_AA64DFR1_EL1 or DBGDIDR yet, but we |
13 | container to the per-CPU container. (We leave the aliases for | 7 | add it to maintain the invariant that every field in the |
14 | 0x1... and 0x3... in the overall container, because there are | 8 | ARMISARegisters struct is populated for a KVM CPU and can be relied |
15 | no per-CPU devices there.) | 9 | on. This requirement isn't actually written down yet, so add a note |
10 | to the relevant comment. | ||
16 | 11 | ||
17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
18 | Message-id: 20190215180500.6906-1-peter.maydell@linaro.org | 13 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
19 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | 14 | Message-id: 20200214175116.9164-13-peter.maydell@linaro.org |
20 | --- | 15 | --- |
21 | include/hw/arm/armsse.h | 2 +- | 16 | target/arm/cpu.h | 5 +++++ |
22 | hw/arm/armsse.c | 26 ++++++++++++++++---------- | 17 | target/arm/kvm32.c | 8 ++++++++ |
23 | 2 files changed, 17 insertions(+), 11 deletions(-) | 18 | target/arm/kvm64.c | 36 ++++++++++++++++++++++++++++++++++++ |
19 | 3 files changed, 49 insertions(+) | ||
24 | 20 | ||
25 | diff --git a/include/hw/arm/armsse.h b/include/hw/arm/armsse.h | 21 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
26 | index XXXXXXX..XXXXXXX 100644 | 22 | index XXXXXXX..XXXXXXX 100644 |
27 | --- a/include/hw/arm/armsse.h | 23 | --- a/target/arm/cpu.h |
28 | +++ b/include/hw/arm/armsse.h | 24 | +++ b/target/arm/cpu.h |
29 | @@ -XXX,XX +XXX,XX @@ typedef struct ARMSSE { | 25 | @@ -XXX,XX +XXX,XX @@ struct ARMCPU { |
30 | MemoryRegion cpu_container[SSE_MAX_CPUS]; | 26 | * prefix means a constant register. |
31 | MemoryRegion alias1; | 27 | * Some of these registers are split out into a substructure that |
32 | MemoryRegion alias2; | 28 | * is shared with the translators to control the ISA. |
33 | - MemoryRegion alias3; | 29 | + * |
34 | + MemoryRegion alias3[SSE_MAX_CPUS]; | 30 | + * Note that if you add an ID register to the ARMISARegisters struct |
35 | MemoryRegion sram[MAX_SRAM_BANKS]; | 31 | + * you need to also update the 32-bit and 64-bit versions of the |
36 | 32 | + * kvm_arm_get_host_cpu_features() function to correctly populate the | |
37 | qemu_irq *exp_irqs[SSE_MAX_CPUS]; | 33 | + * field by reading the value from the KVM vCPU. |
38 | diff --git a/hw/arm/armsse.c b/hw/arm/armsse.c | 34 | */ |
35 | struct ARMISARegisters { | ||
36 | uint32_t id_isar0; | ||
37 | diff --git a/target/arm/kvm32.c b/target/arm/kvm32.c | ||
39 | index XXXXXXX..XXXXXXX 100644 | 38 | index XXXXXXX..XXXXXXX 100644 |
40 | --- a/hw/arm/armsse.c | 39 | --- a/target/arm/kvm32.c |
41 | +++ b/hw/arm/armsse.c | 40 | +++ b/target/arm/kvm32.c |
42 | @@ -XXX,XX +XXX,XX @@ static bool irq_is_common[32] = { | 41 | @@ -XXX,XX +XXX,XX @@ bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf) |
43 | /* 30, 31: reserved */ | 42 | ahcf->isar.id_isar6 = 0; |
44 | }; | ||
45 | |||
46 | -/* Create an alias region of @size bytes starting at @base | ||
47 | +/* | ||
48 | + * Create an alias region in @container of @size bytes starting at @base | ||
49 | * which mirrors the memory starting at @orig. | ||
50 | */ | ||
51 | -static void make_alias(ARMSSE *s, MemoryRegion *mr, const char *name, | ||
52 | - hwaddr base, hwaddr size, hwaddr orig) | ||
53 | +static void make_alias(ARMSSE *s, MemoryRegion *mr, MemoryRegion *container, | ||
54 | + const char *name, hwaddr base, hwaddr size, hwaddr orig) | ||
55 | { | ||
56 | - memory_region_init_alias(mr, NULL, name, &s->container, orig, size); | ||
57 | + memory_region_init_alias(mr, NULL, name, container, orig, size); | ||
58 | /* The alias is even lower priority than unimplemented_device regions */ | ||
59 | - memory_region_add_subregion_overlap(&s->container, base, mr, -1500); | ||
60 | + memory_region_add_subregion_overlap(container, base, mr, -1500); | ||
61 | } | ||
62 | |||
63 | static void irq_status_forwarder(void *opaque, int n, int level) | ||
64 | @@ -XXX,XX +XXX,XX @@ static void armsse_realize(DeviceState *dev, Error **errp) | ||
65 | } | 43 | } |
66 | 44 | ||
67 | /* Set up the big aliases first */ | 45 | + err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_dfr0, |
68 | - make_alias(s, &s->alias1, "alias 1", 0x10000000, 0x10000000, 0x00000000); | 46 | + ARM_CP15_REG32(0, 0, 1, 2)); |
69 | - make_alias(s, &s->alias2, "alias 2", 0x30000000, 0x10000000, 0x20000000); | 47 | + |
70 | + make_alias(s, &s->alias1, &s->container, "alias 1", | 48 | err |= read_sys_reg32(fdarray[2], &ahcf->isar.mvfr0, |
71 | + 0x10000000, 0x10000000, 0x00000000); | 49 | KVM_REG_ARM | KVM_REG_SIZE_U32 | |
72 | + make_alias(s, &s->alias2, &s->container, | 50 | KVM_REG_ARM_VFP | KVM_REG_ARM_VFP_MVFR0); |
73 | + "alias 2", 0x30000000, 0x10000000, 0x20000000); | 51 | @@ -XXX,XX +XXX,XX @@ bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf) |
74 | /* The 0x50000000..0x5fffffff region is not a pure alias: it has | 52 | * Fortunately there is not yet anything in there that affects migration. |
75 | * a few extra devices that only appear there (generally the | ||
76 | * control interfaces for the protection controllers). | ||
77 | * We implement this by mapping those devices over the top of this | ||
78 | - * alias MR at a higher priority. | ||
79 | + * alias MR at a higher priority. Some of the devices in this range | ||
80 | + * are per-CPU, so we must put this alias in the per-cpu containers. | ||
81 | */ | 53 | */ |
82 | - make_alias(s, &s->alias3, "alias 3", 0x50000000, 0x10000000, 0x40000000); | 54 | |
83 | - | 55 | + /* |
84 | + for (i = 0; i < info->num_cpus; i++) { | 56 | + * There is no way to read DBGDIDR, because currently 32-bit KVM |
85 | + make_alias(s, &s->alias3[i], &s->cpu_container[i], | 57 | + * doesn't implement debug at all. Leave it at zero. |
86 | + "alias 3", 0x50000000, 0x10000000, 0x40000000); | 58 | + */ |
87 | + } | 59 | + |
88 | 60 | kvm_arm_destroy_scratch_host_vcpu(fdarray); | |
89 | /* Security controller */ | 61 | |
90 | object_property_set_bool(OBJECT(&s->secctl), true, "realized", &err); | 62 | if (err < 0) { |
63 | diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c | ||
64 | index XXXXXXX..XXXXXXX 100644 | ||
65 | --- a/target/arm/kvm64.c | ||
66 | +++ b/target/arm/kvm64.c | ||
67 | @@ -XXX,XX +XXX,XX @@ bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf) | ||
68 | } else { | ||
69 | err |= read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64pfr1, | ||
70 | ARM64_SYS_REG(3, 0, 0, 4, 1)); | ||
71 | + err |= read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64dfr0, | ||
72 | + ARM64_SYS_REG(3, 0, 0, 5, 0)); | ||
73 | + err |= read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64dfr1, | ||
74 | + ARM64_SYS_REG(3, 0, 0, 5, 1)); | ||
75 | err |= read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64isar0, | ||
76 | ARM64_SYS_REG(3, 0, 0, 6, 0)); | ||
77 | err |= read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64isar1, | ||
78 | @@ -XXX,XX +XXX,XX @@ bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf) | ||
79 | * than skipping the reads and leaving 0, as we must avoid | ||
80 | * considering the values in every case. | ||
81 | */ | ||
82 | + err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_dfr0, | ||
83 | + ARM64_SYS_REG(3, 0, 0, 1, 2)); | ||
84 | err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_isar0, | ||
85 | ARM64_SYS_REG(3, 0, 0, 2, 0)); | ||
86 | err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_isar1, | ||
87 | @@ -XXX,XX +XXX,XX @@ bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf) | ||
88 | ARM64_SYS_REG(3, 0, 0, 3, 1)); | ||
89 | err |= read_sys_reg32(fdarray[2], &ahcf->isar.mvfr2, | ||
90 | ARM64_SYS_REG(3, 0, 0, 3, 2)); | ||
91 | + | ||
92 | + /* | ||
93 | + * DBGDIDR is a bit complicated because the kernel doesn't | ||
94 | + * provide an accessor for it in 64-bit mode, which is what this | ||
95 | + * scratch VM is in, and there's no architected "64-bit sysreg | ||
96 | + * which reads the same as the 32-bit register" the way there is | ||
97 | + * for other ID registers. Instead we synthesize a value from the | ||
98 | + * AArch64 ID_AA64DFR0, the same way the kernel code in | ||
99 | + * arch/arm64/kvm/sys_regs.c:trap_dbgidr() does. | ||
100 | + * We only do this if the CPU supports AArch32 at EL1. | ||
101 | + */ | ||
102 | + if (FIELD_EX32(ahcf->isar.id_aa64pfr0, ID_AA64PFR0, EL1) >= 2) { | ||
103 | + int wrps = FIELD_EX64(ahcf->isar.id_aa64dfr0, ID_AA64DFR0, WRPS); | ||
104 | + int brps = FIELD_EX64(ahcf->isar.id_aa64dfr0, ID_AA64DFR0, BRPS); | ||
105 | + int ctx_cmps = | ||
106 | + FIELD_EX64(ahcf->isar.id_aa64dfr0, ID_AA64DFR0, CTX_CMPS); | ||
107 | + int version = 6; /* ARMv8 debug architecture */ | ||
108 | + bool has_el3 = | ||
109 | + !!FIELD_EX32(ahcf->isar.id_aa64pfr0, ID_AA64PFR0, EL3); | ||
110 | + uint32_t dbgdidr = 0; | ||
111 | + | ||
112 | + dbgdidr = FIELD_DP32(dbgdidr, DBGDIDR, WRPS, wrps); | ||
113 | + dbgdidr = FIELD_DP32(dbgdidr, DBGDIDR, BRPS, brps); | ||
114 | + dbgdidr = FIELD_DP32(dbgdidr, DBGDIDR, CTX_CMPS, ctx_cmps); | ||
115 | + dbgdidr = FIELD_DP32(dbgdidr, DBGDIDR, VERSION, version); | ||
116 | + dbgdidr = FIELD_DP32(dbgdidr, DBGDIDR, NSUHD_IMP, has_el3); | ||
117 | + dbgdidr = FIELD_DP32(dbgdidr, DBGDIDR, SE_IMP, has_el3); | ||
118 | + dbgdidr |= (1 << 15); /* RES1 bit */ | ||
119 | + ahcf->isar.dbgdidr = dbgdidr; | ||
120 | + } | ||
121 | } | ||
122 | |||
123 | sve_supported = ioctl(fdarray[0], KVM_CHECK_EXTENSION, KVM_CAP_ARM_SVE) > 0; | ||
91 | -- | 124 | -- |
92 | 2.20.1 | 125 | 2.20.1 |
93 | 126 | ||
94 | 127 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | The ARMv8.1-PMU extension requires: | ||
2 | * the evtCount field in PMETYPER<n>_EL0 is 16 bits, not 10 | ||
3 | * MDCR_EL2.HPMD allows event counting to be disabled at EL2 | ||
4 | * two new required events, STALL_FRONTEND and STALL_BACKEND | ||
5 | * ID register bits in ID_AA64DFR0_EL1 and ID_DFR0 | ||
1 | 6 | ||
7 | We already implement the 16-bit evtCount field and the | ||
8 | HPMD bit, so all that is missing is the two new events: | ||
9 | STALL_FRONTEND | ||
10 | "counts every cycle counted by the CPU_CYCLES event on which no | ||
11 | operation was issued because there are no operations available | ||
12 | to issue to this PE from the frontend" | ||
13 | STALL_BACKEND | ||
14 | "counts every cycle counted by the CPU_CYCLES event on which no | ||
15 | operation was issued because the backend is unable to accept | ||
16 | any available operations from the frontend" | ||
17 | |||
18 | QEMU never stalls in this sense, so our implementation is trivial: | ||
19 | always return a zero count. | ||
20 | |||
21 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
22 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
23 | Message-id: 20200214175116.9164-14-peter.maydell@linaro.org | ||
24 | --- | ||
25 | target/arm/helper.c | 32 ++++++++++++++++++++++++++++++-- | ||
26 | 1 file changed, 30 insertions(+), 2 deletions(-) | ||
27 | |||
28 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
29 | index XXXXXXX..XXXXXXX 100644 | ||
30 | --- a/target/arm/helper.c | ||
31 | +++ b/target/arm/helper.c | ||
32 | @@ -XXX,XX +XXX,XX @@ static int64_t instructions_ns_per(uint64_t icount) | ||
33 | } | ||
34 | #endif | ||
35 | |||
36 | +static bool pmu_8_1_events_supported(CPUARMState *env) | ||
37 | +{ | ||
38 | + /* For events which are supported in any v8.1 PMU */ | ||
39 | + return cpu_isar_feature(any_pmu_8_1, env_archcpu(env)); | ||
40 | +} | ||
41 | + | ||
42 | +static uint64_t zero_event_get_count(CPUARMState *env) | ||
43 | +{ | ||
44 | + /* For events which on QEMU never fire, so their count is always zero */ | ||
45 | + return 0; | ||
46 | +} | ||
47 | + | ||
48 | +static int64_t zero_event_ns_per(uint64_t cycles) | ||
49 | +{ | ||
50 | + /* An event which never fires can never overflow */ | ||
51 | + return -1; | ||
52 | +} | ||
53 | + | ||
54 | static const pm_event pm_events[] = { | ||
55 | { .number = 0x000, /* SW_INCR */ | ||
56 | .supported = event_always_supported, | ||
57 | @@ -XXX,XX +XXX,XX @@ static const pm_event pm_events[] = { | ||
58 | .supported = event_always_supported, | ||
59 | .get_count = cycles_get_count, | ||
60 | .ns_per_count = cycles_ns_per, | ||
61 | - } | ||
62 | + }, | ||
63 | #endif | ||
64 | + { .number = 0x023, /* STALL_FRONTEND */ | ||
65 | + .supported = pmu_8_1_events_supported, | ||
66 | + .get_count = zero_event_get_count, | ||
67 | + .ns_per_count = zero_event_ns_per, | ||
68 | + }, | ||
69 | + { .number = 0x024, /* STALL_BACKEND */ | ||
70 | + .supported = pmu_8_1_events_supported, | ||
71 | + .get_count = zero_event_get_count, | ||
72 | + .ns_per_count = zero_event_ns_per, | ||
73 | + }, | ||
74 | }; | ||
75 | |||
76 | /* | ||
77 | @@ -XXX,XX +XXX,XX @@ static const pm_event pm_events[] = { | ||
78 | * should first be updated to something sparse instead of the current | ||
79 | * supported_event_map[] array. | ||
80 | */ | ||
81 | -#define MAX_EVENT_ID 0x11 | ||
82 | +#define MAX_EVENT_ID 0x24 | ||
83 | #define UNSUPPORTED_EVENT UINT16_MAX | ||
84 | static uint16_t supported_event_map[MAX_EVENT_ID + 1]; | ||
85 | |||
86 | -- | ||
87 | 2.20.1 | ||
88 | |||
89 | diff view generated by jsdifflib |
1 | Wire up the PL031 RTC for the Musca board. | 1 | The ARMv8.4-PMU extension adds: |
---|---|---|---|
2 | * one new required event, STALL | ||
3 | * one new system register PMMIR_EL1 | ||
2 | 4 | ||
5 | (There are also some more L1-cache related events, but since | ||
6 | we don't implement any cache we don't provide these, in the | ||
7 | same way we don't provide the base-PMUv3 cache events.) | ||
8 | |||
9 | The STALL event "counts every attributable cycle on which no | ||
10 | attributable instruction or operation was sent for execution on this | ||
11 | PE". QEMU doesn't stall in this sense, so this is another | ||
12 | always-reads-zero event. | ||
13 | |||
14 | The PMMIR_EL1 register is a read-only register providing | ||
15 | implementation-specific information about the PMU; currently it has | ||
16 | only one field, SLOTS, which defines behaviour of the STALL_SLOT PMU | ||
17 | event. Since QEMU doesn't implement the STALL_SLOT event, we can | ||
18 | validly make the register read zero. | ||
19 | |||
20 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
3 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 21 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 22 | Message-id: 20200214175116.9164-15-peter.maydell@linaro.org |
5 | --- | 23 | --- |
6 | hw/arm/musca.c | 26 +++++++++++++++++++++++--- | 24 | target/arm/cpu.h | 18 ++++++++++++++++++ |
7 | 1 file changed, 23 insertions(+), 3 deletions(-) | 25 | target/arm/helper.c | 22 +++++++++++++++++++++- |
26 | 2 files changed, 39 insertions(+), 1 deletion(-) | ||
8 | 27 | ||
9 | diff --git a/hw/arm/musca.c b/hw/arm/musca.c | 28 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
10 | index XXXXXXX..XXXXXXX 100644 | 29 | index XXXXXXX..XXXXXXX 100644 |
11 | --- a/hw/arm/musca.c | 30 | --- a/target/arm/cpu.h |
12 | +++ b/hw/arm/musca.c | 31 | +++ b/target/arm/cpu.h |
13 | @@ -XXX,XX +XXX,XX @@ | 32 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa32_pmu_8_1(const ARMISARegisters *id) |
14 | #include "hw/misc/tz-mpc.h" | 33 | FIELD_EX32(id->id_dfr0, ID_DFR0, PERFMON) != 0xf; |
15 | #include "hw/misc/tz-ppc.h" | 34 | } |
16 | #include "hw/misc/unimp.h" | 35 | |
17 | +#include "hw/timer/pl031.h" | 36 | +static inline bool isar_feature_aa32_pmu_8_4(const ARMISARegisters *id) |
18 | |||
19 | #define MUSCA_NUMIRQ_MAX 96 | ||
20 | #define MUSCA_PPC_MAX 3 | ||
21 | @@ -XXX,XX +XXX,XX @@ typedef struct { | ||
22 | UnimplementedDeviceState spi; | ||
23 | UnimplementedDeviceState scc; | ||
24 | UnimplementedDeviceState timer; | ||
25 | - UnimplementedDeviceState rtc; | ||
26 | + PL031State rtc; | ||
27 | UnimplementedDeviceState pvt; | ||
28 | UnimplementedDeviceState sdio; | ||
29 | UnimplementedDeviceState gpio; | ||
30 | @@ -XXX,XX +XXX,XX @@ typedef struct { | ||
31 | */ | ||
32 | #define SYSCLK_FRQ 40000000 | ||
33 | |||
34 | +static qemu_irq get_sse_irq_in(MuscaMachineState *mms, int irqno) | ||
35 | +{ | 37 | +{ |
36 | + /* Return a qemu_irq which will signal IRQ n to all CPUs in the SSE. */ | 38 | + /* 0xf means "non-standard IMPDEF PMU" */ |
37 | + assert(irqno < MUSCA_NUMIRQ_MAX); | 39 | + return FIELD_EX32(id->id_dfr0, ID_DFR0, PERFMON) >= 5 && |
38 | + | 40 | + FIELD_EX32(id->id_dfr0, ID_DFR0, PERFMON) != 0xf; |
39 | + return qdev_get_gpio_in(DEVICE(&mms->cpu_irq_splitter[irqno]), 0); | ||
40 | +} | 41 | +} |
41 | + | 42 | + |
42 | /* | 43 | /* |
43 | * Most of the devices in the Musca board sit behind Peripheral Protection | 44 | * 64-bit feature tests via id registers. |
44 | * Controllers. These data structures define the layout of which devices | 45 | */ |
45 | @@ -XXX,XX +XXX,XX @@ static MemoryRegion *make_mpc(MuscaMachineState *mms, void *opaque, | 46 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa64_pmu_8_1(const ARMISARegisters *id) |
46 | return sysbus_mmio_get_region(SYS_BUS_DEVICE(mpc), 0); | 47 | FIELD_EX64(id->id_aa64dfr0, ID_AA64DFR0, PMUVER) != 0xf; |
47 | } | 48 | } |
48 | 49 | ||
49 | +static MemoryRegion *make_rtc(MuscaMachineState *mms, void *opaque, | 50 | +static inline bool isar_feature_aa64_pmu_8_4(const ARMISARegisters *id) |
50 | + const char *name, hwaddr size) | ||
51 | +{ | 51 | +{ |
52 | + PL031State *rtc = opaque; | 52 | + return FIELD_EX32(id->id_aa64dfr0, ID_AA64DFR0, PMUVER) >= 5 && |
53 | + | 53 | + FIELD_EX32(id->id_aa64dfr0, ID_AA64DFR0, PMUVER) != 0xf; |
54 | + sysbus_init_child_obj(OBJECT(mms), name, rtc, sizeof(mms->rtc), TYPE_PL031); | ||
55 | + object_property_set_bool(OBJECT(rtc), true, "realized", &error_fatal); | ||
56 | + sysbus_connect_irq(SYS_BUS_DEVICE(rtc), 0, get_sse_irq_in(mms, 39)); | ||
57 | + return sysbus_mmio_get_region(SYS_BUS_DEVICE(rtc), 0); | ||
58 | +} | 54 | +} |
59 | + | 55 | + |
60 | static MemoryRegion *make_musca_a_devs(MuscaMachineState *mms, void *opaque, | 56 | /* |
61 | const char *name, hwaddr size) | 57 | * Feature tests for "does this exist in either 32-bit or 64-bit?" |
58 | */ | ||
59 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_any_pmu_8_1(const ARMISARegisters *id) | ||
60 | return isar_feature_aa64_pmu_8_1(id) || isar_feature_aa32_pmu_8_1(id); | ||
61 | } | ||
62 | |||
63 | +static inline bool isar_feature_any_pmu_8_4(const ARMISARegisters *id) | ||
64 | +{ | ||
65 | + return isar_feature_aa64_pmu_8_4(id) || isar_feature_aa32_pmu_8_4(id); | ||
66 | +} | ||
67 | + | ||
68 | /* | ||
69 | * Forward to the above feature tests given an ARMCPU pointer. | ||
70 | */ | ||
71 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
72 | index XXXXXXX..XXXXXXX 100644 | ||
73 | --- a/target/arm/helper.c | ||
74 | +++ b/target/arm/helper.c | ||
75 | @@ -XXX,XX +XXX,XX @@ static bool pmu_8_1_events_supported(CPUARMState *env) | ||
76 | return cpu_isar_feature(any_pmu_8_1, env_archcpu(env)); | ||
77 | } | ||
78 | |||
79 | +static bool pmu_8_4_events_supported(CPUARMState *env) | ||
80 | +{ | ||
81 | + /* For events which are supported in any v8.1 PMU */ | ||
82 | + return cpu_isar_feature(any_pmu_8_4, env_archcpu(env)); | ||
83 | +} | ||
84 | + | ||
85 | static uint64_t zero_event_get_count(CPUARMState *env) | ||
62 | { | 86 | { |
63 | @@ -XXX,XX +XXX,XX @@ static MemoryRegion *make_musca_a_devs(MuscaMachineState *mms, void *opaque, | 87 | /* For events which on QEMU never fire, so their count is always zero */ |
64 | { "i2c1", make_unimp_dev, &mms->i2c[1], 0x5000, 0x1000 }, | 88 | @@ -XXX,XX +XXX,XX @@ static const pm_event pm_events[] = { |
65 | { "i2s", make_unimp_dev, &mms->i2s, 0x6000, 0x1000 }, | 89 | .get_count = zero_event_get_count, |
66 | { "pwm0", make_unimp_dev, &mms->pwm[0], 0x7000, 0x1000 }, | 90 | .ns_per_count = zero_event_ns_per, |
67 | - { "rtc", make_unimp_dev, &mms->rtc, 0x8000, 0x1000 }, | 91 | }, |
68 | + { "rtc", make_rtc, &mms->rtc, 0x8000, 0x1000 }, | 92 | + { .number = 0x03c, /* STALL */ |
69 | { "qspi", make_unimp_dev, &mms->qspi, 0xa000, 0x1000 }, | 93 | + .supported = pmu_8_4_events_supported, |
70 | { "timer", make_unimp_dev, &mms->timer, 0xb000, 0x1000 }, | 94 | + .get_count = zero_event_get_count, |
71 | { "scc", make_unimp_dev, &mms->scc, 0xc000, 0x1000 }, | 95 | + .ns_per_count = zero_event_ns_per, |
72 | @@ -XXX,XX +XXX,XX @@ static void musca_init(MachineState *machine) | 96 | + }, |
73 | { "spi", make_unimp_dev, &mms->spi, 0x4010a000, 0x1000 }, | 97 | }; |
74 | { "scc", make_unimp_dev, &mms->scc, 0x5010b000, 0x1000 }, | 98 | |
75 | { "timer", make_unimp_dev, &mms->timer, 0x4010c000, 0x1000 }, | 99 | /* |
76 | - { "rtc", make_unimp_dev, &mms->rtc, 0x4010d000, 0x1000 }, | 100 | @@ -XXX,XX +XXX,XX @@ static const pm_event pm_events[] = { |
77 | + { "rtc", make_rtc, &mms->rtc, 0x4010d000, 0x1000 }, | 101 | * should first be updated to something sparse instead of the current |
78 | { "pvt", make_unimp_dev, &mms->pvt, 0x4010e000, 0x1000 }, | 102 | * supported_event_map[] array. |
79 | { "sdio", make_unimp_dev, &mms->sdio, 0x4010f000, 0x1000 }, | 103 | */ |
80 | }, | 104 | -#define MAX_EVENT_ID 0x24 |
105 | +#define MAX_EVENT_ID 0x3c | ||
106 | #define UNSUPPORTED_EVENT UINT16_MAX | ||
107 | static uint16_t supported_event_map[MAX_EVENT_ID + 1]; | ||
108 | |||
109 | @@ -XXX,XX +XXX,XX @@ static void define_pmu_regs(ARMCPU *cpu) | ||
110 | }; | ||
111 | define_arm_cp_regs(cpu, v81_pmu_regs); | ||
112 | } | ||
113 | + if (cpu_isar_feature(any_pmu_8_4, cpu)) { | ||
114 | + static const ARMCPRegInfo v84_pmmir = { | ||
115 | + .name = "PMMIR_EL1", .state = ARM_CP_STATE_BOTH, | ||
116 | + .opc0 = 3, .opc1 = 0, .crn = 9, .crm = 14, .opc2 = 6, | ||
117 | + .access = PL1_R, .accessfn = pmreg_access, .type = ARM_CP_CONST, | ||
118 | + .resetvalue = 0 | ||
119 | + }; | ||
120 | + define_one_arm_cp_reg(cpu, &v84_pmmir); | ||
121 | + } | ||
122 | } | ||
123 | |||
124 | /* We don't know until after realize whether there's a GICv3 | ||
81 | -- | 125 | -- |
82 | 2.20.1 | 126 | 2.20.1 |
83 | 127 | ||
84 | 128 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Set the ID register bits to provide ARMv8.4-PMU (and implicitly | ||
2 | also ARMv8.1-PMU) in the 'max' CPU. | ||
1 | 3 | ||
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Message-id: 20200214175116.9164-16-peter.maydell@linaro.org | ||
7 | --- | ||
8 | target/arm/cpu64.c | 8 ++++++++ | ||
9 | 1 file changed, 8 insertions(+) | ||
10 | |||
11 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | ||
12 | index XXXXXXX..XXXXXXX 100644 | ||
13 | --- a/target/arm/cpu64.c | ||
14 | +++ b/target/arm/cpu64.c | ||
15 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) | ||
16 | u = FIELD_DP32(u, ID_MMFR3, PAN, 2); /* ATS1E1 */ | ||
17 | cpu->id_mmfr3 = u; | ||
18 | |||
19 | + u = cpu->isar.id_aa64dfr0; | ||
20 | + u = FIELD_DP64(u, ID_AA64DFR0, PMUVER, 5); /* v8.4-PMU */ | ||
21 | + cpu->isar.id_aa64dfr0 = u; | ||
22 | + | ||
23 | + u = cpu->isar.id_dfr0; | ||
24 | + u = FIELD_DP32(u, ID_DFR0, PERFMON, 5); /* v8.4-PMU */ | ||
25 | + cpu->isar.id_dfr0 = u; | ||
26 | + | ||
27 | /* | ||
28 | * FIXME: We do not yet support ARMv8.2-fp16 for AArch32 yet, | ||
29 | * so do not set MVFR1.FPHP. Strictly speaking this is not legal, | ||
30 | -- | ||
31 | 2.20.1 | ||
32 | |||
33 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | The PMCR_EL0.DP bit is bit 5, which is 0x20, not 0x10. 0x10 is 'X'. | ||
2 | Correct our #define of PMCRDP and add the missing PMCRX. | ||
1 | 3 | ||
4 | We do have the correct behaviour for handling the DP bit being | ||
5 | set, so this fixes a guest-visible bug. | ||
6 | |||
7 | Fixes: 033614c47de | ||
8 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | Message-id: 20200214175116.9164-17-peter.maydell@linaro.org | ||
12 | --- | ||
13 | target/arm/helper.c | 3 ++- | ||
14 | 1 file changed, 2 insertions(+), 1 deletion(-) | ||
15 | |||
16 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/target/arm/helper.c | ||
19 | +++ b/target/arm/helper.c | ||
20 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v6_cp_reginfo[] = { | ||
21 | #define PMCRN_MASK 0xf800 | ||
22 | #define PMCRN_SHIFT 11 | ||
23 | #define PMCRLC 0x40 | ||
24 | -#define PMCRDP 0x10 | ||
25 | +#define PMCRDP 0x20 | ||
26 | +#define PMCRX 0x10 | ||
27 | #define PMCRD 0x8 | ||
28 | #define PMCRC 0x4 | ||
29 | #define PMCRP 0x2 | ||
30 | -- | ||
31 | 2.20.1 | ||
32 | |||
33 | diff view generated by jsdifflib |
1 | Coverity points out (CID 1398632, CID 1398650) that we | 1 | The LC bit in the PMCR_EL0 register is supposed to be: |
---|---|---|---|
2 | leak a couple of allocated strings in the error-exit | 2 | * read/write |
3 | code path for setting up the MHUs in the ARMSSE. | 3 | * RES1 on an AArch64-only implementation |
4 | Fix this bug by moving the allocate-and-free of each | 4 | * an architecturally UNKNOWN value on reset |
5 | string to be closer to the use, so we do the free before | 5 | (and use of LC==0 by software is deprecated). |
6 | doing the error-exit check. | ||
7 | 6 | ||
8 | Fixes: f8574705f62b38a ("hw/arm/armsse: Add unimplemented-device stubs for MHUs") | 7 | We were implementing it incorrectly as read-only always zero, |
8 | though we do have all the code needed to test it and behave | ||
9 | accordingly. | ||
10 | |||
11 | Instead make it a read-write bit which resets to 1 always, which | ||
12 | satisfies all the architectural requirements above. | ||
13 | |||
14 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
15 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 17 | Message-id: 20200214175116.9164-18-peter.maydell@linaro.org |
11 | Message-id: 20190215113707.24553-1-peter.maydell@linaro.org | ||
12 | --- | 18 | --- |
13 | hw/arm/armsse.c | 10 ++++++---- | 19 | target/arm/helper.c | 13 +++++++++---- |
14 | 1 file changed, 6 insertions(+), 4 deletions(-) | 20 | 1 file changed, 9 insertions(+), 4 deletions(-) |
15 | 21 | ||
16 | diff --git a/hw/arm/armsse.c b/hw/arm/armsse.c | 22 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
17 | index XXXXXXX..XXXXXXX 100644 | 23 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/hw/arm/armsse.c | 24 | --- a/target/arm/helper.c |
19 | +++ b/hw/arm/armsse.c | 25 | +++ b/target/arm/helper.c |
20 | @@ -XXX,XX +XXX,XX @@ static void armsse_realize(DeviceState *dev, Error **errp) | 26 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v6_cp_reginfo[] = { |
21 | 27 | #define PMCRC 0x4 | |
22 | if (info->has_mhus) { | 28 | #define PMCRP 0x2 |
23 | for (i = 0; i < ARRAY_SIZE(s->mhu); i++) { | 29 | #define PMCRE 0x1 |
24 | - char *name = g_strdup_printf("MHU%d", i); | 30 | +/* |
25 | - char *port = g_strdup_printf("port[%d]", i + 3); | 31 | + * Mask of PMCR bits writeable by guest (not including WO bits like C, P, |
26 | + char *name; | 32 | + * which can be written as 1 to trigger behaviour but which stay RAZ). |
27 | + char *port; | 33 | + */ |
28 | 34 | +#define PMCR_WRITEABLE_MASK (PMCRLC | PMCRDP | PMCRX | PMCRD | PMCRE) | |
29 | + name = g_strdup_printf("MHU%d", i); | 35 | |
30 | qdev_prop_set_string(DEVICE(&s->mhu[i]), "name", name); | 36 | #define PMXEVTYPER_P 0x80000000 |
31 | qdev_prop_set_uint64(DEVICE(&s->mhu[i]), "size", 0x1000); | 37 | #define PMXEVTYPER_U 0x40000000 |
32 | object_property_set_bool(OBJECT(&s->mhu[i]), true, | 38 | @@ -XXX,XX +XXX,XX @@ static void pmcr_write(CPUARMState *env, const ARMCPRegInfo *ri, |
33 | "realized", &err); | ||
34 | + g_free(name); | ||
35 | if (err) { | ||
36 | error_propagate(errp, err); | ||
37 | return; | ||
38 | } | ||
39 | + port = g_strdup_printf("port[%d]", i + 3); | ||
40 | mr = sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->mhu[i]), 0); | ||
41 | object_property_set_link(OBJECT(&s->apb_ppc0), OBJECT(mr), | ||
42 | port, &err); | ||
43 | + g_free(port); | ||
44 | if (err) { | ||
45 | error_propagate(errp, err); | ||
46 | return; | ||
47 | } | ||
48 | - g_free(name); | ||
49 | - g_free(port); | ||
50 | } | 39 | } |
51 | } | 40 | } |
52 | 41 | ||
42 | - /* only the DP, X, D and E bits are writable */ | ||
43 | - env->cp15.c9_pmcr &= ~0x39; | ||
44 | - env->cp15.c9_pmcr |= (value & 0x39); | ||
45 | + env->cp15.c9_pmcr &= ~PMCR_WRITEABLE_MASK; | ||
46 | + env->cp15.c9_pmcr |= (value & PMCR_WRITEABLE_MASK); | ||
47 | |||
48 | pmu_op_finish(env); | ||
49 | } | ||
50 | @@ -XXX,XX +XXX,XX @@ static void define_pmu_regs(ARMCPU *cpu) | ||
51 | .access = PL0_RW, .accessfn = pmreg_access, | ||
52 | .type = ARM_CP_IO, | ||
53 | .fieldoffset = offsetof(CPUARMState, cp15.c9_pmcr), | ||
54 | - .resetvalue = (cpu->midr & 0xff000000) | (pmcrn << PMCRN_SHIFT), | ||
55 | + .resetvalue = (cpu->midr & 0xff000000) | (pmcrn << PMCRN_SHIFT) | | ||
56 | + PMCRLC, | ||
57 | .writefn = pmcr_write, .raw_writefn = raw_write, | ||
58 | }; | ||
59 | define_one_arm_cp_reg(cpu, &pmcr); | ||
53 | -- | 60 | -- |
54 | 2.20.1 | 61 | 2.20.1 |
55 | 62 | ||
56 | 63 | diff view generated by jsdifflib |
1 | In commit 4b635cf7a95e501211 we added a QOM property to the ARMSSE | 1 | The isar_feature_aa32_pan and isar_feature_aa32_ats1e1 functions |
---|---|---|---|
2 | object, but forgot to add it to the documentation comment in the | 2 | are supposed to be testing fields in ID_MMFR3; but a cut-and-paste |
3 | header. Correct the omission. | 3 | error meant we were looking at MVFR0 instead. |
4 | 4 | ||
5 | Fixes: 4b635cf7a95e501211 ("hw/arm/armsse: Make SRAM bank size configurable") | 5 | Fix the functions to look at the right register; this requires |
6 | us to move at least id_mmfr3 to the ARMISARegisters struct; we | ||
7 | choose to move all the ID_MMFRn registers for consistency. | ||
8 | |||
9 | Fixes: 3d6ad6bb466f | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 11 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
12 | Message-id: 20200214175116.9164-19-peter.maydell@linaro.org | ||
8 | --- | 13 | --- |
9 | include/hw/arm/armsse.h | 2 ++ | 14 | target/arm/cpu.h | 14 +++--- |
10 | 1 file changed, 2 insertions(+) | 15 | hw/intc/armv7m_nvic.c | 8 ++-- |
16 | target/arm/cpu.c | 104 +++++++++++++++++++++--------------------- | ||
17 | target/arm/cpu64.c | 28 ++++++------ | ||
18 | target/arm/helper.c | 12 ++--- | ||
19 | target/arm/kvm32.c | 17 +++++++ | ||
20 | target/arm/kvm64.c | 10 ++++ | ||
21 | 7 files changed, 110 insertions(+), 83 deletions(-) | ||
11 | 22 | ||
12 | diff --git a/include/hw/arm/armsse.h b/include/hw/arm/armsse.h | 23 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
13 | index XXXXXXX..XXXXXXX 100644 | 24 | index XXXXXXX..XXXXXXX 100644 |
14 | --- a/include/hw/arm/armsse.h | 25 | --- a/target/arm/cpu.h |
15 | +++ b/include/hw/arm/armsse.h | 26 | +++ b/target/arm/cpu.h |
16 | @@ -XXX,XX +XXX,XX @@ | 27 | @@ -XXX,XX +XXX,XX @@ struct ARMCPU { |
17 | * being the same for both, to avoid having to have separate Property | 28 | uint32_t id_isar4; |
18 | * lists for different variants. This restriction can be relaxed later | 29 | uint32_t id_isar5; |
19 | * if necessary.) | 30 | uint32_t id_isar6; |
20 | + * + QOM property "SRAM_ADDR_WIDTH" sets the number of bits used for the | 31 | + uint32_t id_mmfr0; |
21 | + * address of each SRAM bank (and thus the total amount of internal SRAM) | 32 | + uint32_t id_mmfr1; |
22 | * + Named GPIO inputs "EXP_IRQ" 0..n are the expansion interrupts for CPU 0, | 33 | + uint32_t id_mmfr2; |
23 | * which are wired to its NVIC lines 32 .. n+32 | 34 | + uint32_t id_mmfr3; |
24 | * + Named GPIO inputs "EXP_CPU1_IRQ" 0..n are the expansion interrupts for | 35 | + uint32_t id_mmfr4; |
36 | uint32_t mvfr0; | ||
37 | uint32_t mvfr1; | ||
38 | uint32_t mvfr2; | ||
39 | @@ -XXX,XX +XXX,XX @@ struct ARMCPU { | ||
40 | uint64_t pmceid0; | ||
41 | uint64_t pmceid1; | ||
42 | uint32_t id_afr0; | ||
43 | - uint32_t id_mmfr0; | ||
44 | - uint32_t id_mmfr1; | ||
45 | - uint32_t id_mmfr2; | ||
46 | - uint32_t id_mmfr3; | ||
47 | - uint32_t id_mmfr4; | ||
48 | uint64_t id_aa64afr0; | ||
49 | uint64_t id_aa64afr1; | ||
50 | uint32_t clidr; | ||
51 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa32_vminmaxnm(const ARMISARegisters *id) | ||
52 | |||
53 | static inline bool isar_feature_aa32_pan(const ARMISARegisters *id) | ||
54 | { | ||
55 | - return FIELD_EX64(id->mvfr0, ID_MMFR3, PAN) != 0; | ||
56 | + return FIELD_EX32(id->id_mmfr3, ID_MMFR3, PAN) != 0; | ||
57 | } | ||
58 | |||
59 | static inline bool isar_feature_aa32_ats1e1(const ARMISARegisters *id) | ||
60 | { | ||
61 | - return FIELD_EX64(id->mvfr0, ID_MMFR3, PAN) >= 2; | ||
62 | + return FIELD_EX32(id->id_mmfr3, ID_MMFR3, PAN) >= 2; | ||
63 | } | ||
64 | |||
65 | static inline bool isar_feature_aa32_pmu_8_1(const ARMISARegisters *id) | ||
66 | diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c | ||
67 | index XXXXXXX..XXXXXXX 100644 | ||
68 | --- a/hw/intc/armv7m_nvic.c | ||
69 | +++ b/hw/intc/armv7m_nvic.c | ||
70 | @@ -XXX,XX +XXX,XX @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs) | ||
71 | case 0xd4c: /* AFR0. */ | ||
72 | return cpu->id_afr0; | ||
73 | case 0xd50: /* MMFR0. */ | ||
74 | - return cpu->id_mmfr0; | ||
75 | + return cpu->isar.id_mmfr0; | ||
76 | case 0xd54: /* MMFR1. */ | ||
77 | - return cpu->id_mmfr1; | ||
78 | + return cpu->isar.id_mmfr1; | ||
79 | case 0xd58: /* MMFR2. */ | ||
80 | - return cpu->id_mmfr2; | ||
81 | + return cpu->isar.id_mmfr2; | ||
82 | case 0xd5c: /* MMFR3. */ | ||
83 | - return cpu->id_mmfr3; | ||
84 | + return cpu->isar.id_mmfr3; | ||
85 | case 0xd60: /* ISAR0. */ | ||
86 | return cpu->isar.id_isar0; | ||
87 | case 0xd64: /* ISAR1. */ | ||
88 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | ||
89 | index XXXXXXX..XXXXXXX 100644 | ||
90 | --- a/target/arm/cpu.c | ||
91 | +++ b/target/arm/cpu.c | ||
92 | @@ -XXX,XX +XXX,XX @@ static void arm1136_r2_initfn(Object *obj) | ||
93 | cpu->id_pfr1 = 0x1; | ||
94 | cpu->isar.id_dfr0 = 0x2; | ||
95 | cpu->id_afr0 = 0x3; | ||
96 | - cpu->id_mmfr0 = 0x01130003; | ||
97 | - cpu->id_mmfr1 = 0x10030302; | ||
98 | - cpu->id_mmfr2 = 0x01222110; | ||
99 | + cpu->isar.id_mmfr0 = 0x01130003; | ||
100 | + cpu->isar.id_mmfr1 = 0x10030302; | ||
101 | + cpu->isar.id_mmfr2 = 0x01222110; | ||
102 | cpu->isar.id_isar0 = 0x00140011; | ||
103 | cpu->isar.id_isar1 = 0x12002111; | ||
104 | cpu->isar.id_isar2 = 0x11231111; | ||
105 | @@ -XXX,XX +XXX,XX @@ static void arm1136_initfn(Object *obj) | ||
106 | cpu->id_pfr1 = 0x1; | ||
107 | cpu->isar.id_dfr0 = 0x2; | ||
108 | cpu->id_afr0 = 0x3; | ||
109 | - cpu->id_mmfr0 = 0x01130003; | ||
110 | - cpu->id_mmfr1 = 0x10030302; | ||
111 | - cpu->id_mmfr2 = 0x01222110; | ||
112 | + cpu->isar.id_mmfr0 = 0x01130003; | ||
113 | + cpu->isar.id_mmfr1 = 0x10030302; | ||
114 | + cpu->isar.id_mmfr2 = 0x01222110; | ||
115 | cpu->isar.id_isar0 = 0x00140011; | ||
116 | cpu->isar.id_isar1 = 0x12002111; | ||
117 | cpu->isar.id_isar2 = 0x11231111; | ||
118 | @@ -XXX,XX +XXX,XX @@ static void arm1176_initfn(Object *obj) | ||
119 | cpu->id_pfr1 = 0x11; | ||
120 | cpu->isar.id_dfr0 = 0x33; | ||
121 | cpu->id_afr0 = 0; | ||
122 | - cpu->id_mmfr0 = 0x01130003; | ||
123 | - cpu->id_mmfr1 = 0x10030302; | ||
124 | - cpu->id_mmfr2 = 0x01222100; | ||
125 | + cpu->isar.id_mmfr0 = 0x01130003; | ||
126 | + cpu->isar.id_mmfr1 = 0x10030302; | ||
127 | + cpu->isar.id_mmfr2 = 0x01222100; | ||
128 | cpu->isar.id_isar0 = 0x0140011; | ||
129 | cpu->isar.id_isar1 = 0x12002111; | ||
130 | cpu->isar.id_isar2 = 0x11231121; | ||
131 | @@ -XXX,XX +XXX,XX @@ static void arm11mpcore_initfn(Object *obj) | ||
132 | cpu->id_pfr1 = 0x1; | ||
133 | cpu->isar.id_dfr0 = 0; | ||
134 | cpu->id_afr0 = 0x2; | ||
135 | - cpu->id_mmfr0 = 0x01100103; | ||
136 | - cpu->id_mmfr1 = 0x10020302; | ||
137 | - cpu->id_mmfr2 = 0x01222000; | ||
138 | + cpu->isar.id_mmfr0 = 0x01100103; | ||
139 | + cpu->isar.id_mmfr1 = 0x10020302; | ||
140 | + cpu->isar.id_mmfr2 = 0x01222000; | ||
141 | cpu->isar.id_isar0 = 0x00100011; | ||
142 | cpu->isar.id_isar1 = 0x12002111; | ||
143 | cpu->isar.id_isar2 = 0x11221011; | ||
144 | @@ -XXX,XX +XXX,XX @@ static void cortex_m3_initfn(Object *obj) | ||
145 | cpu->id_pfr1 = 0x00000200; | ||
146 | cpu->isar.id_dfr0 = 0x00100000; | ||
147 | cpu->id_afr0 = 0x00000000; | ||
148 | - cpu->id_mmfr0 = 0x00000030; | ||
149 | - cpu->id_mmfr1 = 0x00000000; | ||
150 | - cpu->id_mmfr2 = 0x00000000; | ||
151 | - cpu->id_mmfr3 = 0x00000000; | ||
152 | + cpu->isar.id_mmfr0 = 0x00000030; | ||
153 | + cpu->isar.id_mmfr1 = 0x00000000; | ||
154 | + cpu->isar.id_mmfr2 = 0x00000000; | ||
155 | + cpu->isar.id_mmfr3 = 0x00000000; | ||
156 | cpu->isar.id_isar0 = 0x01141110; | ||
157 | cpu->isar.id_isar1 = 0x02111000; | ||
158 | cpu->isar.id_isar2 = 0x21112231; | ||
159 | @@ -XXX,XX +XXX,XX @@ static void cortex_m4_initfn(Object *obj) | ||
160 | cpu->id_pfr1 = 0x00000200; | ||
161 | cpu->isar.id_dfr0 = 0x00100000; | ||
162 | cpu->id_afr0 = 0x00000000; | ||
163 | - cpu->id_mmfr0 = 0x00000030; | ||
164 | - cpu->id_mmfr1 = 0x00000000; | ||
165 | - cpu->id_mmfr2 = 0x00000000; | ||
166 | - cpu->id_mmfr3 = 0x00000000; | ||
167 | + cpu->isar.id_mmfr0 = 0x00000030; | ||
168 | + cpu->isar.id_mmfr1 = 0x00000000; | ||
169 | + cpu->isar.id_mmfr2 = 0x00000000; | ||
170 | + cpu->isar.id_mmfr3 = 0x00000000; | ||
171 | cpu->isar.id_isar0 = 0x01141110; | ||
172 | cpu->isar.id_isar1 = 0x02111000; | ||
173 | cpu->isar.id_isar2 = 0x21112231; | ||
174 | @@ -XXX,XX +XXX,XX @@ static void cortex_m7_initfn(Object *obj) | ||
175 | cpu->id_pfr1 = 0x00000200; | ||
176 | cpu->isar.id_dfr0 = 0x00100000; | ||
177 | cpu->id_afr0 = 0x00000000; | ||
178 | - cpu->id_mmfr0 = 0x00100030; | ||
179 | - cpu->id_mmfr1 = 0x00000000; | ||
180 | - cpu->id_mmfr2 = 0x01000000; | ||
181 | - cpu->id_mmfr3 = 0x00000000; | ||
182 | + cpu->isar.id_mmfr0 = 0x00100030; | ||
183 | + cpu->isar.id_mmfr1 = 0x00000000; | ||
184 | + cpu->isar.id_mmfr2 = 0x01000000; | ||
185 | + cpu->isar.id_mmfr3 = 0x00000000; | ||
186 | cpu->isar.id_isar0 = 0x01101110; | ||
187 | cpu->isar.id_isar1 = 0x02112000; | ||
188 | cpu->isar.id_isar2 = 0x20232231; | ||
189 | @@ -XXX,XX +XXX,XX @@ static void cortex_m33_initfn(Object *obj) | ||
190 | cpu->id_pfr1 = 0x00000210; | ||
191 | cpu->isar.id_dfr0 = 0x00200000; | ||
192 | cpu->id_afr0 = 0x00000000; | ||
193 | - cpu->id_mmfr0 = 0x00101F40; | ||
194 | - cpu->id_mmfr1 = 0x00000000; | ||
195 | - cpu->id_mmfr2 = 0x01000000; | ||
196 | - cpu->id_mmfr3 = 0x00000000; | ||
197 | + cpu->isar.id_mmfr0 = 0x00101F40; | ||
198 | + cpu->isar.id_mmfr1 = 0x00000000; | ||
199 | + cpu->isar.id_mmfr2 = 0x01000000; | ||
200 | + cpu->isar.id_mmfr3 = 0x00000000; | ||
201 | cpu->isar.id_isar0 = 0x01101110; | ||
202 | cpu->isar.id_isar1 = 0x02212000; | ||
203 | cpu->isar.id_isar2 = 0x20232232; | ||
204 | @@ -XXX,XX +XXX,XX @@ static void cortex_r5_initfn(Object *obj) | ||
205 | cpu->id_pfr1 = 0x001; | ||
206 | cpu->isar.id_dfr0 = 0x010400; | ||
207 | cpu->id_afr0 = 0x0; | ||
208 | - cpu->id_mmfr0 = 0x0210030; | ||
209 | - cpu->id_mmfr1 = 0x00000000; | ||
210 | - cpu->id_mmfr2 = 0x01200000; | ||
211 | - cpu->id_mmfr3 = 0x0211; | ||
212 | + cpu->isar.id_mmfr0 = 0x0210030; | ||
213 | + cpu->isar.id_mmfr1 = 0x00000000; | ||
214 | + cpu->isar.id_mmfr2 = 0x01200000; | ||
215 | + cpu->isar.id_mmfr3 = 0x0211; | ||
216 | cpu->isar.id_isar0 = 0x02101111; | ||
217 | cpu->isar.id_isar1 = 0x13112111; | ||
218 | cpu->isar.id_isar2 = 0x21232141; | ||
219 | @@ -XXX,XX +XXX,XX @@ static void cortex_a8_initfn(Object *obj) | ||
220 | cpu->id_pfr1 = 0x11; | ||
221 | cpu->isar.id_dfr0 = 0x400; | ||
222 | cpu->id_afr0 = 0; | ||
223 | - cpu->id_mmfr0 = 0x31100003; | ||
224 | - cpu->id_mmfr1 = 0x20000000; | ||
225 | - cpu->id_mmfr2 = 0x01202000; | ||
226 | - cpu->id_mmfr3 = 0x11; | ||
227 | + cpu->isar.id_mmfr0 = 0x31100003; | ||
228 | + cpu->isar.id_mmfr1 = 0x20000000; | ||
229 | + cpu->isar.id_mmfr2 = 0x01202000; | ||
230 | + cpu->isar.id_mmfr3 = 0x11; | ||
231 | cpu->isar.id_isar0 = 0x00101111; | ||
232 | cpu->isar.id_isar1 = 0x12112111; | ||
233 | cpu->isar.id_isar2 = 0x21232031; | ||
234 | @@ -XXX,XX +XXX,XX @@ static void cortex_a9_initfn(Object *obj) | ||
235 | cpu->id_pfr1 = 0x11; | ||
236 | cpu->isar.id_dfr0 = 0x000; | ||
237 | cpu->id_afr0 = 0; | ||
238 | - cpu->id_mmfr0 = 0x00100103; | ||
239 | - cpu->id_mmfr1 = 0x20000000; | ||
240 | - cpu->id_mmfr2 = 0x01230000; | ||
241 | - cpu->id_mmfr3 = 0x00002111; | ||
242 | + cpu->isar.id_mmfr0 = 0x00100103; | ||
243 | + cpu->isar.id_mmfr1 = 0x20000000; | ||
244 | + cpu->isar.id_mmfr2 = 0x01230000; | ||
245 | + cpu->isar.id_mmfr3 = 0x00002111; | ||
246 | cpu->isar.id_isar0 = 0x00101111; | ||
247 | cpu->isar.id_isar1 = 0x13112111; | ||
248 | cpu->isar.id_isar2 = 0x21232041; | ||
249 | @@ -XXX,XX +XXX,XX @@ static void cortex_a7_initfn(Object *obj) | ||
250 | cpu->id_pfr1 = 0x00011011; | ||
251 | cpu->isar.id_dfr0 = 0x02010555; | ||
252 | cpu->id_afr0 = 0x00000000; | ||
253 | - cpu->id_mmfr0 = 0x10101105; | ||
254 | - cpu->id_mmfr1 = 0x40000000; | ||
255 | - cpu->id_mmfr2 = 0x01240000; | ||
256 | - cpu->id_mmfr3 = 0x02102211; | ||
257 | + cpu->isar.id_mmfr0 = 0x10101105; | ||
258 | + cpu->isar.id_mmfr1 = 0x40000000; | ||
259 | + cpu->isar.id_mmfr2 = 0x01240000; | ||
260 | + cpu->isar.id_mmfr3 = 0x02102211; | ||
261 | /* a7_mpcore_r0p5_trm, page 4-4 gives 0x01101110; but | ||
262 | * table 4-41 gives 0x02101110, which includes the arm div insns. | ||
263 | */ | ||
264 | @@ -XXX,XX +XXX,XX @@ static void cortex_a15_initfn(Object *obj) | ||
265 | cpu->id_pfr1 = 0x00011011; | ||
266 | cpu->isar.id_dfr0 = 0x02010555; | ||
267 | cpu->id_afr0 = 0x00000000; | ||
268 | - cpu->id_mmfr0 = 0x10201105; | ||
269 | - cpu->id_mmfr1 = 0x20000000; | ||
270 | - cpu->id_mmfr2 = 0x01240000; | ||
271 | - cpu->id_mmfr3 = 0x02102211; | ||
272 | + cpu->isar.id_mmfr0 = 0x10201105; | ||
273 | + cpu->isar.id_mmfr1 = 0x20000000; | ||
274 | + cpu->isar.id_mmfr2 = 0x01240000; | ||
275 | + cpu->isar.id_mmfr3 = 0x02102211; | ||
276 | cpu->isar.id_isar0 = 0x02101110; | ||
277 | cpu->isar.id_isar1 = 0x13112111; | ||
278 | cpu->isar.id_isar2 = 0x21232041; | ||
279 | @@ -XXX,XX +XXX,XX @@ static void arm_max_initfn(Object *obj) | ||
280 | t = FIELD_DP32(t, MVFR2, FPMISC, 4); /* FP MaxNum */ | ||
281 | cpu->isar.mvfr2 = t; | ||
282 | |||
283 | - t = cpu->id_mmfr3; | ||
284 | + t = cpu->isar.id_mmfr3; | ||
285 | t = FIELD_DP32(t, ID_MMFR3, PAN, 2); /* ATS1E1 */ | ||
286 | - cpu->id_mmfr3 = t; | ||
287 | + cpu->isar.id_mmfr3 = t; | ||
288 | |||
289 | - t = cpu->id_mmfr4; | ||
290 | + t = cpu->isar.id_mmfr4; | ||
291 | t = FIELD_DP32(t, ID_MMFR4, HPDS, 1); /* AA32HPD */ | ||
292 | - cpu->id_mmfr4 = t; | ||
293 | + cpu->isar.id_mmfr4 = t; | ||
294 | } | ||
295 | #endif | ||
296 | } | ||
297 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | ||
298 | index XXXXXXX..XXXXXXX 100644 | ||
299 | --- a/target/arm/cpu64.c | ||
300 | +++ b/target/arm/cpu64.c | ||
301 | @@ -XXX,XX +XXX,XX @@ static void aarch64_a57_initfn(Object *obj) | ||
302 | cpu->id_pfr1 = 0x00011011; | ||
303 | cpu->isar.id_dfr0 = 0x03010066; | ||
304 | cpu->id_afr0 = 0x00000000; | ||
305 | - cpu->id_mmfr0 = 0x10101105; | ||
306 | - cpu->id_mmfr1 = 0x40000000; | ||
307 | - cpu->id_mmfr2 = 0x01260000; | ||
308 | - cpu->id_mmfr3 = 0x02102211; | ||
309 | + cpu->isar.id_mmfr0 = 0x10101105; | ||
310 | + cpu->isar.id_mmfr1 = 0x40000000; | ||
311 | + cpu->isar.id_mmfr2 = 0x01260000; | ||
312 | + cpu->isar.id_mmfr3 = 0x02102211; | ||
313 | cpu->isar.id_isar0 = 0x02101110; | ||
314 | cpu->isar.id_isar1 = 0x13112111; | ||
315 | cpu->isar.id_isar2 = 0x21232042; | ||
316 | @@ -XXX,XX +XXX,XX @@ static void aarch64_a53_initfn(Object *obj) | ||
317 | cpu->id_pfr1 = 0x00011011; | ||
318 | cpu->isar.id_dfr0 = 0x03010066; | ||
319 | cpu->id_afr0 = 0x00000000; | ||
320 | - cpu->id_mmfr0 = 0x10101105; | ||
321 | - cpu->id_mmfr1 = 0x40000000; | ||
322 | - cpu->id_mmfr2 = 0x01260000; | ||
323 | - cpu->id_mmfr3 = 0x02102211; | ||
324 | + cpu->isar.id_mmfr0 = 0x10101105; | ||
325 | + cpu->isar.id_mmfr1 = 0x40000000; | ||
326 | + cpu->isar.id_mmfr2 = 0x01260000; | ||
327 | + cpu->isar.id_mmfr3 = 0x02102211; | ||
328 | cpu->isar.id_isar0 = 0x02101110; | ||
329 | cpu->isar.id_isar1 = 0x13112111; | ||
330 | cpu->isar.id_isar2 = 0x21232042; | ||
331 | @@ -XXX,XX +XXX,XX @@ static void aarch64_a72_initfn(Object *obj) | ||
332 | cpu->id_pfr1 = 0x00011011; | ||
333 | cpu->isar.id_dfr0 = 0x03010066; | ||
334 | cpu->id_afr0 = 0x00000000; | ||
335 | - cpu->id_mmfr0 = 0x10201105; | ||
336 | - cpu->id_mmfr1 = 0x40000000; | ||
337 | - cpu->id_mmfr2 = 0x01260000; | ||
338 | - cpu->id_mmfr3 = 0x02102211; | ||
339 | + cpu->isar.id_mmfr0 = 0x10201105; | ||
340 | + cpu->isar.id_mmfr1 = 0x40000000; | ||
341 | + cpu->isar.id_mmfr2 = 0x01260000; | ||
342 | + cpu->isar.id_mmfr3 = 0x02102211; | ||
343 | cpu->isar.id_isar0 = 0x02101110; | ||
344 | cpu->isar.id_isar1 = 0x13112111; | ||
345 | cpu->isar.id_isar2 = 0x21232042; | ||
346 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) | ||
347 | u = FIELD_DP32(u, ID_ISAR6, SPECRES, 1); | ||
348 | cpu->isar.id_isar6 = u; | ||
349 | |||
350 | - u = cpu->id_mmfr3; | ||
351 | + u = cpu->isar.id_mmfr3; | ||
352 | u = FIELD_DP32(u, ID_MMFR3, PAN, 2); /* ATS1E1 */ | ||
353 | - cpu->id_mmfr3 = u; | ||
354 | + cpu->isar.id_mmfr3 = u; | ||
355 | |||
356 | u = cpu->isar.id_aa64dfr0; | ||
357 | u = FIELD_DP64(u, ID_AA64DFR0, PMUVER, 5); /* v8.4-PMU */ | ||
358 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
359 | index XXXXXXX..XXXXXXX 100644 | ||
360 | --- a/target/arm/helper.c | ||
361 | +++ b/target/arm/helper.c | ||
362 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
363 | .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 1, .opc2 = 4, | ||
364 | .access = PL1_R, .type = ARM_CP_CONST, | ||
365 | .accessfn = access_aa32_tid3, | ||
366 | - .resetvalue = cpu->id_mmfr0 }, | ||
367 | + .resetvalue = cpu->isar.id_mmfr0 }, | ||
368 | { .name = "ID_MMFR1", .state = ARM_CP_STATE_BOTH, | ||
369 | .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 1, .opc2 = 5, | ||
370 | .access = PL1_R, .type = ARM_CP_CONST, | ||
371 | .accessfn = access_aa32_tid3, | ||
372 | - .resetvalue = cpu->id_mmfr1 }, | ||
373 | + .resetvalue = cpu->isar.id_mmfr1 }, | ||
374 | { .name = "ID_MMFR2", .state = ARM_CP_STATE_BOTH, | ||
375 | .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 1, .opc2 = 6, | ||
376 | .access = PL1_R, .type = ARM_CP_CONST, | ||
377 | .accessfn = access_aa32_tid3, | ||
378 | - .resetvalue = cpu->id_mmfr2 }, | ||
379 | + .resetvalue = cpu->isar.id_mmfr2 }, | ||
380 | { .name = "ID_MMFR3", .state = ARM_CP_STATE_BOTH, | ||
381 | .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 1, .opc2 = 7, | ||
382 | .access = PL1_R, .type = ARM_CP_CONST, | ||
383 | .accessfn = access_aa32_tid3, | ||
384 | - .resetvalue = cpu->id_mmfr3 }, | ||
385 | + .resetvalue = cpu->isar.id_mmfr3 }, | ||
386 | { .name = "ID_ISAR0", .state = ARM_CP_STATE_BOTH, | ||
387 | .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 2, .opc2 = 0, | ||
388 | .access = PL1_R, .type = ARM_CP_CONST, | ||
389 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
390 | .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 2, .opc2 = 6, | ||
391 | .access = PL1_R, .type = ARM_CP_CONST, | ||
392 | .accessfn = access_aa32_tid3, | ||
393 | - .resetvalue = cpu->id_mmfr4 }, | ||
394 | + .resetvalue = cpu->isar.id_mmfr4 }, | ||
395 | { .name = "ID_ISAR6", .state = ARM_CP_STATE_BOTH, | ||
396 | .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 2, .opc2 = 7, | ||
397 | .access = PL1_R, .type = ARM_CP_CONST, | ||
398 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
399 | define_arm_cp_regs(cpu, vmsa_pmsa_cp_reginfo); | ||
400 | define_arm_cp_regs(cpu, vmsa_cp_reginfo); | ||
401 | /* TTCBR2 is introduced with ARMv8.2-A32HPD. */ | ||
402 | - if (FIELD_EX32(cpu->id_mmfr4, ID_MMFR4, HPDS) != 0) { | ||
403 | + if (FIELD_EX32(cpu->isar.id_mmfr4, ID_MMFR4, HPDS) != 0) { | ||
404 | define_one_arm_cp_reg(cpu, &ttbcr2_reginfo); | ||
405 | } | ||
406 | } | ||
407 | diff --git a/target/arm/kvm32.c b/target/arm/kvm32.c | ||
408 | index XXXXXXX..XXXXXXX 100644 | ||
409 | --- a/target/arm/kvm32.c | ||
410 | +++ b/target/arm/kvm32.c | ||
411 | @@ -XXX,XX +XXX,XX @@ bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf) | ||
412 | * Fortunately there is not yet anything in there that affects migration. | ||
413 | */ | ||
414 | |||
415 | + err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_mmfr0, | ||
416 | + ARM_CP15_REG32(0, 0, 1, 4)); | ||
417 | + err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_mmfr1, | ||
418 | + ARM_CP15_REG32(0, 0, 1, 5)); | ||
419 | + err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_mmfr2, | ||
420 | + ARM_CP15_REG32(0, 0, 1, 6)); | ||
421 | + err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_mmfr3, | ||
422 | + ARM_CP15_REG32(0, 0, 1, 7)); | ||
423 | + if (read_sys_reg32(fdarray[2], &ahcf->isar.id_mmfr4, | ||
424 | + ARM_CP15_REG32(0, 0, 2, 6))) { | ||
425 | + /* | ||
426 | + * Older kernels don't support reading ID_MMFR4 (a new in v8 | ||
427 | + * register); assume it's zero. | ||
428 | + */ | ||
429 | + ahcf->isar.id_mmfr4 = 0; | ||
430 | + } | ||
431 | + | ||
432 | /* | ||
433 | * There is no way to read DBGDIDR, because currently 32-bit KVM | ||
434 | * doesn't implement debug at all. Leave it at zero. | ||
435 | diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c | ||
436 | index XXXXXXX..XXXXXXX 100644 | ||
437 | --- a/target/arm/kvm64.c | ||
438 | +++ b/target/arm/kvm64.c | ||
439 | @@ -XXX,XX +XXX,XX @@ bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf) | ||
440 | */ | ||
441 | err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_dfr0, | ||
442 | ARM64_SYS_REG(3, 0, 0, 1, 2)); | ||
443 | + err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_mmfr0, | ||
444 | + ARM64_SYS_REG(3, 0, 0, 1, 4)); | ||
445 | + err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_mmfr1, | ||
446 | + ARM64_SYS_REG(3, 0, 0, 1, 5)); | ||
447 | + err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_mmfr2, | ||
448 | + ARM64_SYS_REG(3, 0, 0, 1, 6)); | ||
449 | + err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_mmfr3, | ||
450 | + ARM64_SYS_REG(3, 0, 0, 1, 7)); | ||
451 | err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_isar0, | ||
452 | ARM64_SYS_REG(3, 0, 0, 2, 0)); | ||
453 | err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_isar1, | ||
454 | @@ -XXX,XX +XXX,XX @@ bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf) | ||
455 | ARM64_SYS_REG(3, 0, 0, 2, 4)); | ||
456 | err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_isar5, | ||
457 | ARM64_SYS_REG(3, 0, 0, 2, 5)); | ||
458 | + err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_mmfr4, | ||
459 | + ARM64_SYS_REG(3, 0, 0, 2, 6)); | ||
460 | err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_isar6, | ||
461 | ARM64_SYS_REG(3, 0, 0, 2, 7)); | ||
462 | |||
25 | -- | 463 | -- |
26 | 2.20.1 | 464 | 2.20.1 |
27 | 465 | ||
28 | 466 | diff view generated by jsdifflib |
1 | Wire up the two PL011 UARTs in the Musca board. | 1 | Now we have moved ID_MMFR4 into the ARMISARegisters struct, we |
---|---|---|---|
2 | can define and use an isar_feature for the presence of the | ||
3 | ARMv8.2-AA32HPD feature, rather than open-coding the test. | ||
4 | |||
5 | While we're here, correct a comment typo which missed an 'A' | ||
6 | from the feature name. | ||
2 | 7 | ||
3 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
10 | Message-id: 20200214175116.9164-20-peter.maydell@linaro.org | ||
5 | --- | 11 | --- |
6 | hw/arm/musca.c | 34 +++++++++++++++++++++++++++++----- | 12 | target/arm/cpu.h | 5 +++++ |
7 | 1 file changed, 29 insertions(+), 5 deletions(-) | 13 | target/arm/helper.c | 4 ++-- |
14 | 2 files changed, 7 insertions(+), 2 deletions(-) | ||
8 | 15 | ||
9 | diff --git a/hw/arm/musca.c b/hw/arm/musca.c | 16 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
10 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
11 | --- a/hw/arm/musca.c | 18 | --- a/target/arm/cpu.h |
12 | +++ b/hw/arm/musca.c | 19 | +++ b/target/arm/cpu.h |
13 | @@ -XXX,XX +XXX,XX @@ | 20 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa32_pmu_8_4(const ARMISARegisters *id) |
14 | #include "qemu/error-report.h" | 21 | FIELD_EX32(id->id_dfr0, ID_DFR0, PERFMON) != 0xf; |
15 | #include "qapi/error.h" | ||
16 | #include "exec/address-spaces.h" | ||
17 | +#include "sysemu/sysemu.h" | ||
18 | #include "hw/arm/arm.h" | ||
19 | #include "hw/arm/armsse.h" | ||
20 | #include "hw/boards.h" | ||
21 | +#include "hw/char/pl011.h" | ||
22 | #include "hw/core/split-irq.h" | ||
23 | #include "hw/misc/tz-mpc.h" | ||
24 | #include "hw/misc/tz-ppc.h" | ||
25 | @@ -XXX,XX +XXX,XX @@ typedef struct { | ||
26 | UnimplementedDeviceState mhu[2]; | ||
27 | UnimplementedDeviceState pwm[3]; | ||
28 | UnimplementedDeviceState i2s; | ||
29 | - UnimplementedDeviceState uart[2]; | ||
30 | + PL011State uart[2]; | ||
31 | UnimplementedDeviceState i2c[2]; | ||
32 | UnimplementedDeviceState spi; | ||
33 | UnimplementedDeviceState scc; | ||
34 | @@ -XXX,XX +XXX,XX @@ static MemoryRegion *make_rtc(MuscaMachineState *mms, void *opaque, | ||
35 | return sysbus_mmio_get_region(SYS_BUS_DEVICE(rtc), 0); | ||
36 | } | 22 | } |
37 | 23 | ||
38 | +static MemoryRegion *make_uart(MuscaMachineState *mms, void *opaque, | 24 | +static inline bool isar_feature_aa32_hpd(const ARMISARegisters *id) |
39 | + const char *name, hwaddr size) | ||
40 | +{ | 25 | +{ |
41 | + PL011State *uart = opaque; | 26 | + return FIELD_EX32(id->id_mmfr4, ID_MMFR4, HPDS) != 0; |
42 | + int i = uart - &mms->uart[0]; | ||
43 | + int irqbase = 7 + i * 6; | ||
44 | + SysBusDevice *s; | ||
45 | + | ||
46 | + sysbus_init_child_obj(OBJECT(mms), name, uart, sizeof(mms->uart[0]), | ||
47 | + TYPE_PL011); | ||
48 | + qdev_prop_set_chr(DEVICE(uart), "chardev", serial_hd(i)); | ||
49 | + object_property_set_bool(OBJECT(uart), true, "realized", &error_fatal); | ||
50 | + s = SYS_BUS_DEVICE(uart); | ||
51 | + sysbus_connect_irq(s, 0, get_sse_irq_in(mms, irqbase + 5)); /* combined */ | ||
52 | + sysbus_connect_irq(s, 1, get_sse_irq_in(mms, irqbase + 0)); /* RX */ | ||
53 | + sysbus_connect_irq(s, 2, get_sse_irq_in(mms, irqbase + 1)); /* TX */ | ||
54 | + sysbus_connect_irq(s, 3, get_sse_irq_in(mms, irqbase + 2)); /* RT */ | ||
55 | + sysbus_connect_irq(s, 4, get_sse_irq_in(mms, irqbase + 3)); /* MS */ | ||
56 | + sysbus_connect_irq(s, 5, get_sse_irq_in(mms, irqbase + 4)); /* E */ | ||
57 | + return sysbus_mmio_get_region(SYS_BUS_DEVICE(uart), 0); | ||
58 | +} | 27 | +} |
59 | + | 28 | + |
60 | static MemoryRegion *make_musca_a_devs(MuscaMachineState *mms, void *opaque, | 29 | /* |
61 | const char *name, hwaddr size) | 30 | * 64-bit feature tests via id registers. |
62 | { | 31 | */ |
63 | @@ -XXX,XX +XXX,XX @@ static MemoryRegion *make_musca_a_devs(MuscaMachineState *mms, void *opaque, | 32 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
64 | MemoryRegion *container = &mms->container; | 33 | index XXXXXXX..XXXXXXX 100644 |
65 | 34 | --- a/target/arm/helper.c | |
66 | const PPCPortInfo devices[] = { | 35 | +++ b/target/arm/helper.c |
67 | - { "uart0", make_unimp_dev, &mms->uart[0], 0x1000, 0x1000 }, | 36 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) |
68 | - { "uart1", make_unimp_dev, &mms->uart[1], 0x2000, 0x1000 }, | 37 | } else { |
69 | + { "uart0", make_uart, &mms->uart[0], 0x1000, 0x1000 }, | 38 | define_arm_cp_regs(cpu, vmsa_pmsa_cp_reginfo); |
70 | + { "uart1", make_uart, &mms->uart[1], 0x2000, 0x1000 }, | 39 | define_arm_cp_regs(cpu, vmsa_cp_reginfo); |
71 | { "spi", make_unimp_dev, &mms->spi, 0x3000, 0x1000 }, | 40 | - /* TTCBR2 is introduced with ARMv8.2-A32HPD. */ |
72 | { "i2c0", make_unimp_dev, &mms->i2c[0], 0x4000, 0x1000 }, | 41 | - if (FIELD_EX32(cpu->isar.id_mmfr4, ID_MMFR4, HPDS) != 0) { |
73 | { "i2c1", make_unimp_dev, &mms->i2c[1], 0x5000, 0x1000 }, | 42 | + /* TTCBR2 is introduced with ARMv8.2-AA32HPD. */ |
74 | @@ -XXX,XX +XXX,XX @@ static void musca_init(MachineState *machine) | 43 | + if (cpu_isar_feature(aa32_hpd, cpu)) { |
75 | { "pwm1", make_unimp_dev, &mms->pwm[1], 0x40102000, 0x1000 }, | 44 | define_one_arm_cp_reg(cpu, &ttbcr2_reginfo); |
76 | { "pwm2", make_unimp_dev, &mms->pwm[2], 0x40103000, 0x1000 }, | 45 | } |
77 | { "i2s", make_unimp_dev, &mms->i2s, 0x40104000, 0x1000 }, | 46 | } |
78 | - { "uart0", make_unimp_dev, &mms->uart[0], 0x40105000, 0x1000 }, | ||
79 | - { "uart1", make_unimp_dev, &mms->uart[1], 0x40106000, 0x1000 }, | ||
80 | + { "uart0", make_uart, &mms->uart[0], 0x40105000, 0x1000 }, | ||
81 | + { "uart1", make_uart, &mms->uart[1], 0x40106000, 0x1000 }, | ||
82 | { "i2c0", make_unimp_dev, &mms->i2c[0], 0x40108000, 0x1000 }, | ||
83 | { "i2c1", make_unimp_dev, &mms->i2c[1], 0x40109000, 0x1000 }, | ||
84 | { "spi", make_unimp_dev, &mms->spi, 0x4010a000, 0x1000 }, | ||
85 | -- | 47 | -- |
86 | 2.20.1 | 48 | 2.20.1 |
87 | 49 | ||
88 | 50 | diff view generated by jsdifflib |
1 | The Musca board puts its SRAM and flash behind TrustZone | 1 | Cut-and-paste errors mean we're using FIELD_EX64() to extract fields from |
---|---|---|---|
2 | Memory Protection Controllers (MPCs). Each MPC sits between | 2 | some 32-bit ID register fields. Use FIELD_EX32() instead. (This makes |
3 | the CPU and the RAM/flash, and also has a set of memory mapped | 3 | no difference in behaviour, it's just more consistent.) |
4 | control registers. Wire up the MPCs, and the memory behind them. | ||
5 | For the moment we implement the flash as simple ROM, which | ||
6 | cannot be reprogrammed by the guest. | ||
7 | 4 | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
7 | Message-id: 20200214175116.9164-21-peter.maydell@linaro.org | ||
10 | --- | 8 | --- |
11 | hw/arm/musca.c | 155 ++++++++++++++++++++++++++++++++++++++++++++++--- | 9 | target/arm/cpu.h | 18 +++++++++--------- |
12 | 1 file changed, 147 insertions(+), 8 deletions(-) | 10 | 1 file changed, 9 insertions(+), 9 deletions(-) |
13 | 11 | ||
14 | diff --git a/hw/arm/musca.c b/hw/arm/musca.c | 12 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
15 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/hw/arm/musca.c | 14 | --- a/target/arm/cpu.h |
17 | +++ b/hw/arm/musca.c | 15 | +++ b/target/arm/cpu.h |
18 | @@ -XXX,XX +XXX,XX @@ | 16 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa32_fp16_arith(const ARMISARegisters *id) |
19 | #include "hw/arm/armsse.h" | 17 | static inline bool isar_feature_aa32_fp_d32(const ARMISARegisters *id) |
20 | #include "hw/boards.h" | 18 | { |
21 | #include "hw/core/split-irq.h" | 19 | /* Return true if D16-D31 are implemented */ |
22 | +#include "hw/misc/tz-mpc.h" | 20 | - return FIELD_EX64(id->mvfr0, MVFR0, SIMDREG) >= 2; |
23 | #include "hw/misc/tz-ppc.h" | 21 | + return FIELD_EX32(id->mvfr0, MVFR0, SIMDREG) >= 2; |
24 | #include "hw/misc/unimp.h" | ||
25 | |||
26 | #define MUSCA_NUMIRQ_MAX 96 | ||
27 | #define MUSCA_PPC_MAX 3 | ||
28 | +#define MUSCA_MPC_MAX 5 | ||
29 | + | ||
30 | +typedef struct MPCInfo MPCInfo; | ||
31 | |||
32 | typedef enum MuscaType { | ||
33 | MUSCA_A, | ||
34 | @@ -XXX,XX +XXX,XX @@ typedef struct { | ||
35 | uint32_t init_svtor; | ||
36 | int sram_addr_width; | ||
37 | int num_irqs; | ||
38 | + const MPCInfo *mpc_info; | ||
39 | + int num_mpcs; | ||
40 | } MuscaMachineClass; | ||
41 | |||
42 | typedef struct { | ||
43 | MachineState parent; | ||
44 | |||
45 | ARMSSE sse; | ||
46 | + /* RAM and flash */ | ||
47 | + MemoryRegion ram[MUSCA_MPC_MAX]; | ||
48 | SplitIRQ cpu_irq_splitter[MUSCA_NUMIRQ_MAX]; | ||
49 | SplitIRQ sec_resp_splitter; | ||
50 | TZPPC ppc[MUSCA_PPC_MAX]; | ||
51 | MemoryRegion container; | ||
52 | UnimplementedDeviceState eflash[2]; | ||
53 | UnimplementedDeviceState qspi; | ||
54 | - UnimplementedDeviceState mpc[5]; | ||
55 | + TZMPC mpc[MUSCA_MPC_MAX]; | ||
56 | UnimplementedDeviceState mhu[2]; | ||
57 | UnimplementedDeviceState pwm[3]; | ||
58 | UnimplementedDeviceState i2s; | ||
59 | @@ -XXX,XX +XXX,XX @@ typedef struct { | ||
60 | UnimplementedDeviceState pvt; | ||
61 | UnimplementedDeviceState sdio; | ||
62 | UnimplementedDeviceState gpio; | ||
63 | + UnimplementedDeviceState cryptoisland; | ||
64 | } MuscaMachineState; | ||
65 | |||
66 | #define TYPE_MUSCA_MACHINE "musca" | ||
67 | @@ -XXX,XX +XXX,XX @@ static MemoryRegion *make_unimp_dev(MuscaMachineState *mms, | ||
68 | return sysbus_mmio_get_region(SYS_BUS_DEVICE(uds), 0); | ||
69 | } | 22 | } |
70 | 23 | ||
71 | +typedef enum MPCInfoType { | 24 | static inline bool isar_feature_aa32_fpshvec(const ARMISARegisters *id) |
72 | + MPC_RAM, | ||
73 | + MPC_ROM, | ||
74 | + MPC_CRYPTOISLAND, | ||
75 | +} MPCInfoType; | ||
76 | + | ||
77 | +struct MPCInfo { | ||
78 | + const char *name; | ||
79 | + hwaddr addr; | ||
80 | + hwaddr size; | ||
81 | + MPCInfoType type; | ||
82 | +}; | ||
83 | + | ||
84 | +/* Order of the MPCs here must match the order of the bits in SECMPCINTSTATUS */ | ||
85 | +static const MPCInfo a_mpc_info[] = { { | ||
86 | + .name = "qspi", | ||
87 | + .type = MPC_ROM, | ||
88 | + .addr = 0x00200000, | ||
89 | + .size = 0x00800000, | ||
90 | + }, { | ||
91 | + .name = "sram", | ||
92 | + .type = MPC_RAM, | ||
93 | + .addr = 0x00000000, | ||
94 | + .size = 0x00200000, | ||
95 | + } | ||
96 | +}; | ||
97 | + | ||
98 | +static const MPCInfo b1_mpc_info[] = { { | ||
99 | + .name = "qspi", | ||
100 | + .type = MPC_ROM, | ||
101 | + .addr = 0x00000000, | ||
102 | + .size = 0x02000000, | ||
103 | + }, { | ||
104 | + .name = "sram", | ||
105 | + .type = MPC_RAM, | ||
106 | + .addr = 0x0a400000, | ||
107 | + .size = 0x00080000, | ||
108 | + }, { | ||
109 | + .name = "eflash0", | ||
110 | + .type = MPC_ROM, | ||
111 | + .addr = 0x0a000000, | ||
112 | + .size = 0x00200000, | ||
113 | + }, { | ||
114 | + .name = "eflash1", | ||
115 | + .type = MPC_ROM, | ||
116 | + .addr = 0x0a200000, | ||
117 | + .size = 0x00200000, | ||
118 | + }, { | ||
119 | + .name = "cryptoisland", | ||
120 | + .type = MPC_CRYPTOISLAND, | ||
121 | + .addr = 0x0a000000, | ||
122 | + .size = 0x00200000, | ||
123 | + } | ||
124 | +}; | ||
125 | + | ||
126 | +static MemoryRegion *make_mpc(MuscaMachineState *mms, void *opaque, | ||
127 | + const char *name, hwaddr size) | ||
128 | +{ | ||
129 | + /* | ||
130 | + * Create an MPC and the RAM or flash behind it. | ||
131 | + * MPC 0: eFlash 0 | ||
132 | + * MPC 1: eFlash 1 | ||
133 | + * MPC 2: SRAM | ||
134 | + * MPC 3: QSPI flash | ||
135 | + * MPC 4: CryptoIsland | ||
136 | + * For now we implement the flash regions as ROM (ie not programmable) | ||
137 | + * (with their control interface memory regions being unimplemented | ||
138 | + * stubs behind the PPCs). | ||
139 | + * The whole CryptoIsland region behind its MPC is an unimplemented stub. | ||
140 | + */ | ||
141 | + MuscaMachineClass *mmc = MUSCA_MACHINE_GET_CLASS(mms); | ||
142 | + TZMPC *mpc = opaque; | ||
143 | + int i = mpc - &mms->mpc[0]; | ||
144 | + MemoryRegion *downstream; | ||
145 | + MemoryRegion *upstream; | ||
146 | + UnimplementedDeviceState *uds; | ||
147 | + char *mpcname; | ||
148 | + const MPCInfo *mpcinfo = mmc->mpc_info; | ||
149 | + | ||
150 | + mpcname = g_strdup_printf("%s-mpc", mpcinfo[i].name); | ||
151 | + | ||
152 | + switch (mpcinfo[i].type) { | ||
153 | + case MPC_ROM: | ||
154 | + downstream = &mms->ram[i]; | ||
155 | + memory_region_init_rom(downstream, NULL, mpcinfo[i].name, | ||
156 | + mpcinfo[i].size, &error_fatal); | ||
157 | + break; | ||
158 | + case MPC_RAM: | ||
159 | + downstream = &mms->ram[i]; | ||
160 | + memory_region_init_ram(downstream, NULL, mpcinfo[i].name, | ||
161 | + mpcinfo[i].size, &error_fatal); | ||
162 | + break; | ||
163 | + case MPC_CRYPTOISLAND: | ||
164 | + /* We don't implement the CryptoIsland yet */ | ||
165 | + uds = &mms->cryptoisland; | ||
166 | + sysbus_init_child_obj(OBJECT(mms), name, uds, | ||
167 | + sizeof(UnimplementedDeviceState), | ||
168 | + TYPE_UNIMPLEMENTED_DEVICE); | ||
169 | + qdev_prop_set_string(DEVICE(uds), "name", mpcinfo[i].name); | ||
170 | + qdev_prop_set_uint64(DEVICE(uds), "size", mpcinfo[i].size); | ||
171 | + object_property_set_bool(OBJECT(uds), true, "realized", &error_fatal); | ||
172 | + downstream = sysbus_mmio_get_region(SYS_BUS_DEVICE(uds), 0); | ||
173 | + break; | ||
174 | + default: | ||
175 | + g_assert_not_reached(); | ||
176 | + } | ||
177 | + | ||
178 | + sysbus_init_child_obj(OBJECT(mms), mpcname, mpc, sizeof(mms->mpc[0]), | ||
179 | + TYPE_TZ_MPC); | ||
180 | + object_property_set_link(OBJECT(mpc), OBJECT(downstream), | ||
181 | + "downstream", &error_fatal); | ||
182 | + object_property_set_bool(OBJECT(mpc), true, "realized", &error_fatal); | ||
183 | + /* Map the upstream end of the MPC into system memory */ | ||
184 | + upstream = sysbus_mmio_get_region(SYS_BUS_DEVICE(mpc), 1); | ||
185 | + memory_region_add_subregion(get_system_memory(), mpcinfo[i].addr, upstream); | ||
186 | + /* and connect its interrupt to the SSE-200 */ | ||
187 | + qdev_connect_gpio_out_named(DEVICE(mpc), "irq", 0, | ||
188 | + qdev_get_gpio_in_named(DEVICE(&mms->sse), | ||
189 | + "mpcexp_status", i)); | ||
190 | + | ||
191 | + g_free(mpcname); | ||
192 | + /* Return the register interface MR for our caller to map behind the PPC */ | ||
193 | + return sysbus_mmio_get_region(SYS_BUS_DEVICE(mpc), 0); | ||
194 | +} | ||
195 | + | ||
196 | static MemoryRegion *make_musca_a_devs(MuscaMachineState *mms, void *opaque, | ||
197 | const char *name, hwaddr size) | ||
198 | { | 25 | { |
199 | @@ -XXX,XX +XXX,XX @@ static MemoryRegion *make_musca_a_devs(MuscaMachineState *mms, void *opaque, | 26 | - return FIELD_EX64(id->mvfr0, MVFR0, FPSHVEC) > 0; |
200 | { "pwm1", make_unimp_dev, &mms->pwm[1], 0xe000, 0x1000 }, | 27 | + return FIELD_EX32(id->mvfr0, MVFR0, FPSHVEC) > 0; |
201 | { "pwm2", make_unimp_dev, &mms->pwm[2], 0xf000, 0x1000 }, | ||
202 | { "gpio", make_unimp_dev, &mms->gpio, 0x10000, 0x1000 }, | ||
203 | - { "mpc0", make_unimp_dev, &mms->mpc[0], 0x12000, 0x1000 }, | ||
204 | - { "mpc1", make_unimp_dev, &mms->mpc[1], 0x13000, 0x1000 }, | ||
205 | + { "mpc0", make_mpc, &mms->mpc[0], 0x12000, 0x1000 }, | ||
206 | + { "mpc1", make_mpc, &mms->mpc[1], 0x13000, 0x1000 }, | ||
207 | }; | ||
208 | |||
209 | memory_region_init(container, OBJECT(mms), "musca-device-container", size); | ||
210 | @@ -XXX,XX +XXX,XX @@ static void musca_init(MachineState *machine) | ||
211 | int i; | ||
212 | |||
213 | assert(mmc->num_irqs <= MUSCA_NUMIRQ_MAX); | ||
214 | + assert(mmc->num_mpcs <= MUSCA_MPC_MAX); | ||
215 | |||
216 | if (strcmp(machine->cpu_type, mc->default_cpu_type) != 0) { | ||
217 | error_report("This board can only be used with CPU %s", | ||
218 | @@ -XXX,XX +XXX,XX @@ static void musca_init(MachineState *machine) | ||
219 | { "eflash1", make_unimp_dev, &mms->eflash[1], | ||
220 | 0x52500000, 0x1000 }, | ||
221 | { "qspi", make_unimp_dev, &mms->qspi, 0x42800000, 0x100000 }, | ||
222 | - { "mpc0", make_unimp_dev, &mms->mpc[0], 0x52000000, 0x1000 }, | ||
223 | - { "mpc1", make_unimp_dev, &mms->mpc[1], 0x52100000, 0x1000 }, | ||
224 | - { "mpc2", make_unimp_dev, &mms->mpc[2], 0x52200000, 0x1000 }, | ||
225 | - { "mpc3", make_unimp_dev, &mms->mpc[3], 0x52300000, 0x1000 }, | ||
226 | + { "mpc0", make_mpc, &mms->mpc[0], 0x52000000, 0x1000 }, | ||
227 | + { "mpc1", make_mpc, &mms->mpc[1], 0x52100000, 0x1000 }, | ||
228 | + { "mpc2", make_mpc, &mms->mpc[2], 0x52200000, 0x1000 }, | ||
229 | + { "mpc3", make_mpc, &mms->mpc[3], 0x52300000, 0x1000 }, | ||
230 | { "mhu0", make_unimp_dev, &mms->mhu[0], 0x42600000, 0x100000 }, | ||
231 | { "mhu1", make_unimp_dev, &mms->mhu[1], 0x42700000, 0x100000 }, | ||
232 | { }, /* port 9: unused */ | ||
233 | @@ -XXX,XX +XXX,XX @@ static void musca_init(MachineState *machine) | ||
234 | { }, /* port 11: unused */ | ||
235 | { }, /* port 12: unused */ | ||
236 | { }, /* port 13: unused */ | ||
237 | - { "mpc4", make_unimp_dev, &mms->mpc[4], 0x52e00000, 0x1000 }, | ||
238 | + { "mpc4", make_mpc, &mms->mpc[4], 0x52e00000, 0x1000 }, | ||
239 | }, | ||
240 | }, { | ||
241 | .name = "apb_ppcexp1", | ||
242 | @@ -XXX,XX +XXX,XX @@ static void musca_a_class_init(ObjectClass *oc, void *data) | ||
243 | mmc->init_svtor = 0x10200000; | ||
244 | mmc->sram_addr_width = 15; | ||
245 | mmc->num_irqs = 64; | ||
246 | + mmc->mpc_info = a_mpc_info; | ||
247 | + mmc->num_mpcs = ARRAY_SIZE(a_mpc_info); | ||
248 | } | 28 | } |
249 | 29 | ||
250 | static void musca_b1_class_init(ObjectClass *oc, void *data) | 30 | static inline bool isar_feature_aa32_fpdp(const ARMISARegisters *id) |
251 | @@ -XXX,XX +XXX,XX @@ static void musca_b1_class_init(ObjectClass *oc, void *data) | 31 | { |
252 | mmc->init_svtor = 0x10000000; | 32 | /* Return true if CPU supports double precision floating point */ |
253 | mmc->sram_addr_width = 17; | 33 | - return FIELD_EX64(id->mvfr0, MVFR0, FPDP) > 0; |
254 | mmc->num_irqs = 96; | 34 | + return FIELD_EX32(id->mvfr0, MVFR0, FPDP) > 0; |
255 | + mmc->mpc_info = b1_mpc_info; | ||
256 | + mmc->num_mpcs = ARRAY_SIZE(b1_mpc_info); | ||
257 | } | 35 | } |
258 | 36 | ||
259 | static const TypeInfo musca_info = { | 37 | /* |
38 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa32_fpdp(const ARMISARegisters *id) | ||
39 | */ | ||
40 | static inline bool isar_feature_aa32_fp16_spconv(const ARMISARegisters *id) | ||
41 | { | ||
42 | - return FIELD_EX64(id->mvfr1, MVFR1, FPHP) > 0; | ||
43 | + return FIELD_EX32(id->mvfr1, MVFR1, FPHP) > 0; | ||
44 | } | ||
45 | |||
46 | static inline bool isar_feature_aa32_fp16_dpconv(const ARMISARegisters *id) | ||
47 | { | ||
48 | - return FIELD_EX64(id->mvfr1, MVFR1, FPHP) > 1; | ||
49 | + return FIELD_EX32(id->mvfr1, MVFR1, FPHP) > 1; | ||
50 | } | ||
51 | |||
52 | static inline bool isar_feature_aa32_vsel(const ARMISARegisters *id) | ||
53 | { | ||
54 | - return FIELD_EX64(id->mvfr2, MVFR2, FPMISC) >= 1; | ||
55 | + return FIELD_EX32(id->mvfr2, MVFR2, FPMISC) >= 1; | ||
56 | } | ||
57 | |||
58 | static inline bool isar_feature_aa32_vcvt_dr(const ARMISARegisters *id) | ||
59 | { | ||
60 | - return FIELD_EX64(id->mvfr2, MVFR2, FPMISC) >= 2; | ||
61 | + return FIELD_EX32(id->mvfr2, MVFR2, FPMISC) >= 2; | ||
62 | } | ||
63 | |||
64 | static inline bool isar_feature_aa32_vrint(const ARMISARegisters *id) | ||
65 | { | ||
66 | - return FIELD_EX64(id->mvfr2, MVFR2, FPMISC) >= 3; | ||
67 | + return FIELD_EX32(id->mvfr2, MVFR2, FPMISC) >= 3; | ||
68 | } | ||
69 | |||
70 | static inline bool isar_feature_aa32_vminmaxnm(const ARMISARegisters *id) | ||
71 | { | ||
72 | - return FIELD_EX64(id->mvfr2, MVFR2, FPMISC) >= 4; | ||
73 | + return FIELD_EX32(id->mvfr2, MVFR2, FPMISC) >= 4; | ||
74 | } | ||
75 | |||
76 | static inline bool isar_feature_aa32_pan(const ARMISARegisters *id) | ||
260 | -- | 77 | -- |
261 | 2.20.1 | 78 | 2.20.1 |
262 | 79 | ||
263 | 80 | diff view generated by jsdifflib |
1 | The Peripheral Protection Controller's handling of unused ports | 1 | The ACTLR2 and HACTLR2 AArch32 system registers didn't exist in ARMv7 |
---|---|---|---|
2 | is that if there is nothing connected to the port's downstream | 2 | or the original ARMv8. They were later added as optional registers, |
3 | then it does not create the sysbus MMIO region for the upstream | 3 | whose presence is signaled by the ID_MMFR4.AC2 field. From ARMv8.2 |
4 | end of the port. This results in odd behaviour when there is | 4 | they are mandatory (ie ID_MMFR4.AC2 must be non-zero). |
5 | an unused port in the middle of the range: since sysbus MMIO | ||
6 | regions are implicitly consecutively allocated, any used ports | ||
7 | above the unused ones end up with sysbus MMIO region numbers | ||
8 | that don't match the port number. | ||
9 | 5 | ||
10 | Avoid this numbering mismatch by creating dummy MMIO regions | 6 | We implemented HACTLR2 in commit 0e0456ab8895a5e85, but we |
11 | for the unused ports. This doesn't change anything for our | 7 | incorrectly made it exist for all v8 CPUs, and we didn't implement |
12 | existing boards, which don't have any gaps in the middle of | 8 | ACTLR2 at all. |
13 | the port ranges they use; but it will be needed for the Musca | ||
14 | board. | ||
15 | 9 | ||
10 | Sort this out by implementing both registers only when they are | ||
11 | supposed to exist, and setting the ID_MMFR4 bit for -cpu max. | ||
12 | |||
13 | Note that this removes HACTLR2 from our Cortex-A53, -A47 and -A72 | ||
14 | CPU models; this is correct, because those CPUs do not implement | ||
15 | this register. | ||
16 | |||
17 | Fixes: 0e0456ab8895a5e85 | ||
16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 18 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
17 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 19 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
20 | Message-id: 20200214175116.9164-22-peter.maydell@linaro.org | ||
18 | --- | 21 | --- |
19 | include/hw/misc/tz-ppc.h | 8 +++++++- | 22 | target/arm/cpu.h | 5 +++++ |
20 | hw/misc/tz-ppc.c | 32 ++++++++++++++++++++++++++++++++ | 23 | target/arm/cpu.c | 1 + |
21 | 2 files changed, 39 insertions(+), 1 deletion(-) | 24 | target/arm/cpu64.c | 4 ++++ |
25 | target/arm/helper.c | 32 +++++++++++++++++++++++--------- | ||
26 | 4 files changed, 33 insertions(+), 9 deletions(-) | ||
22 | 27 | ||
23 | diff --git a/include/hw/misc/tz-ppc.h b/include/hw/misc/tz-ppc.h | 28 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
24 | index XXXXXXX..XXXXXXX 100644 | 29 | index XXXXXXX..XXXXXXX 100644 |
25 | --- a/include/hw/misc/tz-ppc.h | 30 | --- a/target/arm/cpu.h |
26 | +++ b/include/hw/misc/tz-ppc.h | 31 | +++ b/target/arm/cpu.h |
27 | @@ -XXX,XX +XXX,XX @@ | 32 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa32_hpd(const ARMISARegisters *id) |
28 | * | 33 | return FIELD_EX32(id->id_mmfr4, ID_MMFR4, HPDS) != 0; |
29 | * QEMU interface: | 34 | } |
30 | * + sysbus MMIO regions 0..15: MemoryRegions defining the upstream end | 35 | |
31 | - * of each of the 16 ports of the PPC | 36 | +static inline bool isar_feature_aa32_ac2(const ARMISARegisters *id) |
32 | + * of each of the 16 ports of the PPC. When a port is unused (i.e. no | ||
33 | + * downstream MemoryRegion is connected to it) at the end of the 0..15 | ||
34 | + * range then no sysbus MMIO region is created for its upstream. When an | ||
35 | + * unused port lies in the middle of the range with other used ports at | ||
36 | + * higher port numbers, a dummy MMIO region is created to ensure that | ||
37 | + * port N's upstream is always sysbus MMIO region N. Dummy regions should | ||
38 | + * not be mapped, and will assert if any access is made to them. | ||
39 | * + Property "port[0..15]": MemoryRegion defining the downstream device(s) | ||
40 | * for each of the 16 ports of the PPC | ||
41 | * + Named GPIO inputs "cfg_nonsec[0..15]": set to 1 if the port should be | ||
42 | diff --git a/hw/misc/tz-ppc.c b/hw/misc/tz-ppc.c | ||
43 | index XXXXXXX..XXXXXXX 100644 | ||
44 | --- a/hw/misc/tz-ppc.c | ||
45 | +++ b/hw/misc/tz-ppc.c | ||
46 | @@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps tz_ppc_ops = { | ||
47 | .endianness = DEVICE_LITTLE_ENDIAN, | ||
48 | }; | ||
49 | |||
50 | +static bool tz_ppc_dummy_accepts(void *opaque, hwaddr addr, | ||
51 | + unsigned size, bool is_write, | ||
52 | + MemTxAttrs attrs) | ||
53 | +{ | 37 | +{ |
54 | + /* | 38 | + return FIELD_EX32(id->id_mmfr4, ID_MMFR4, AC2) != 0; |
55 | + * Board code should never map the upstream end of an unused port, | ||
56 | + * so we should never try to make a memory access to it. | ||
57 | + */ | ||
58 | + g_assert_not_reached(); | ||
59 | +} | 39 | +} |
60 | + | 40 | + |
61 | +static const MemoryRegionOps tz_ppc_dummy_ops = { | 41 | /* |
62 | + .valid.accepts = tz_ppc_dummy_accepts, | 42 | * 64-bit feature tests via id registers. |
43 | */ | ||
44 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | ||
45 | index XXXXXXX..XXXXXXX 100644 | ||
46 | --- a/target/arm/cpu.c | ||
47 | +++ b/target/arm/cpu.c | ||
48 | @@ -XXX,XX +XXX,XX @@ static void arm_max_initfn(Object *obj) | ||
49 | |||
50 | t = cpu->isar.id_mmfr4; | ||
51 | t = FIELD_DP32(t, ID_MMFR4, HPDS, 1); /* AA32HPD */ | ||
52 | + t = FIELD_DP32(t, ID_MMFR4, AC2, 1); /* ACTLR2, HACTLR2 */ | ||
53 | cpu->isar.id_mmfr4 = t; | ||
54 | } | ||
55 | #endif | ||
56 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | ||
57 | index XXXXXXX..XXXXXXX 100644 | ||
58 | --- a/target/arm/cpu64.c | ||
59 | +++ b/target/arm/cpu64.c | ||
60 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) | ||
61 | u = FIELD_DP32(u, ID_MMFR3, PAN, 2); /* ATS1E1 */ | ||
62 | cpu->isar.id_mmfr3 = u; | ||
63 | |||
64 | + u = cpu->isar.id_mmfr4; | ||
65 | + u = FIELD_DP32(u, ID_MMFR4, AC2, 1); /* ACTLR2, HACTLR2 */ | ||
66 | + cpu->isar.id_mmfr4 = u; | ||
67 | + | ||
68 | u = cpu->isar.id_aa64dfr0; | ||
69 | u = FIELD_DP64(u, ID_AA64DFR0, PMUVER, 5); /* v8.4-PMU */ | ||
70 | cpu->isar.id_aa64dfr0 = u; | ||
71 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
72 | index XXXXXXX..XXXXXXX 100644 | ||
73 | --- a/target/arm/helper.c | ||
74 | +++ b/target/arm/helper.c | ||
75 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo ats1cp_reginfo[] = { | ||
76 | }; | ||
77 | #endif | ||
78 | |||
79 | +/* | ||
80 | + * ACTLR2 and HACTLR2 map to ACTLR_EL1[63:32] and | ||
81 | + * ACTLR_EL2[63:32]. They exist only if the ID_MMFR4.AC2 field | ||
82 | + * is non-zero, which is never for ARMv7, optionally in ARMv8 | ||
83 | + * and mandatorily for ARMv8.2 and up. | ||
84 | + * ACTLR2 is banked for S and NS if EL3 is AArch32. Since QEMU's | ||
85 | + * implementation is RAZ/WI we can ignore this detail, as we | ||
86 | + * do for ACTLR. | ||
87 | + */ | ||
88 | +static const ARMCPRegInfo actlr2_hactlr2_reginfo[] = { | ||
89 | + { .name = "ACTLR2", .state = ARM_CP_STATE_AA32, | ||
90 | + .cp = 15, .opc1 = 0, .crn = 1, .crm = 0, .opc2 = 3, | ||
91 | + .access = PL1_RW, .type = ARM_CP_CONST, | ||
92 | + .resetvalue = 0 }, | ||
93 | + { .name = "HACTLR2", .state = ARM_CP_STATE_AA32, | ||
94 | + .cp = 15, .opc1 = 4, .crn = 1, .crm = 0, .opc2 = 3, | ||
95 | + .access = PL2_RW, .type = ARM_CP_CONST, | ||
96 | + .resetvalue = 0 }, | ||
97 | + REGINFO_SENTINEL | ||
63 | +}; | 98 | +}; |
64 | + | 99 | + |
65 | static void tz_ppc_reset(DeviceState *dev) | 100 | void register_cp_regs_for_features(ARMCPU *cpu) |
66 | { | 101 | { |
67 | TZPPC *s = TZ_PPC(dev); | 102 | /* Register all the coprocessor registers based on feature bits */ |
68 | @@ -XXX,XX +XXX,XX @@ static void tz_ppc_realize(DeviceState *dev, Error **errp) | 103 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) |
69 | SysBusDevice *sbd = SYS_BUS_DEVICE(dev); | 104 | REGINFO_SENTINEL |
70 | TZPPC *s = TZ_PPC(dev); | 105 | }; |
71 | int i; | 106 | define_arm_cp_regs(cpu, auxcr_reginfo); |
72 | + int max_port = 0; | 107 | - if (arm_feature(env, ARM_FEATURE_V8)) { |
73 | 108 | - /* HACTLR2 maps to ACTLR_EL2[63:32] and is not in ARMv7 */ | |
74 | /* We can't create the upstream end of the port until realize, | 109 | - ARMCPRegInfo hactlr2_reginfo = { |
75 | * as we don't know the size of the MR used as the downstream until then. | 110 | - .name = "HACTLR2", .state = ARM_CP_STATE_AA32, |
76 | */ | 111 | - .cp = 15, .opc1 = 4, .crn = 1, .crm = 0, .opc2 = 3, |
77 | for (i = 0; i < TZ_NUM_PORTS; i++) { | 112 | - .access = PL2_RW, .type = ARM_CP_CONST, |
78 | + if (s->port[i].downstream) { | 113 | - .resetvalue = 0 |
79 | + max_port = i; | 114 | - }; |
80 | + } | 115 | - define_one_arm_cp_reg(cpu, &hactlr2_reginfo); |
81 | + } | 116 | + if (cpu_isar_feature(aa32_ac2, cpu)) { |
82 | + | 117 | + define_arm_cp_regs(cpu, actlr2_hactlr2_reginfo); |
83 | + for (i = 0; i <= max_port; i++) { | ||
84 | TZPPCPort *port = &s->port[i]; | ||
85 | char *name; | ||
86 | uint64_t size; | ||
87 | |||
88 | if (!port->downstream) { | ||
89 | + /* | ||
90 | + * Create dummy sysbus MMIO region so the sysbus region | ||
91 | + * numbering doesn't get out of sync with the port numbers. | ||
92 | + * The size is entirely arbitrary. | ||
93 | + */ | ||
94 | + name = g_strdup_printf("tz-ppc-dummy-port[%d]", i); | ||
95 | + memory_region_init_io(&port->upstream, obj, &tz_ppc_dummy_ops, | ||
96 | + port, name, 0x10000); | ||
97 | + sysbus_init_mmio(sbd, &port->upstream); | ||
98 | + g_free(name); | ||
99 | continue; | ||
100 | } | 118 | } |
119 | } | ||
101 | 120 | ||
102 | -- | 121 | -- |
103 | 2.20.1 | 122 | 2.20.1 |
104 | 123 | ||
105 | 124 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Guenter Roeck <linux@roeck-us.net> | ||
1 | 2 | ||
3 | We need to be able to use OHCISysBusState outside hcd-ohci.c, so move it | ||
4 | to its include file. | ||
5 | |||
6 | Reviewed-by: Gerd Hoffmann <kraxel@redhat.com> | ||
7 | Signed-off-by: Guenter Roeck <linux@roeck-us.net> | ||
8 | Tested-by: Niek Linnenbank <nieklinnenbank@gmail.com> | ||
9 | Message-id: 20200217204812.9857-2-linux@roeck-us.net | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | hw/usb/hcd-ohci.h | 16 ++++++++++++++++ | ||
13 | hw/usb/hcd-ohci.c | 15 --------------- | ||
14 | 2 files changed, 16 insertions(+), 15 deletions(-) | ||
15 | |||
16 | diff --git a/hw/usb/hcd-ohci.h b/hw/usb/hcd-ohci.h | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/hw/usb/hcd-ohci.h | ||
19 | +++ b/hw/usb/hcd-ohci.h | ||
20 | @@ -XXX,XX +XXX,XX @@ | ||
21 | #define HCD_OHCI_H | ||
22 | |||
23 | #include "sysemu/dma.h" | ||
24 | +#include "hw/usb.h" | ||
25 | |||
26 | /* Number of Downstream Ports on the root hub: */ | ||
27 | #define OHCI_MAX_PORTS 15 | ||
28 | @@ -XXX,XX +XXX,XX @@ typedef struct OHCIState { | ||
29 | void (*ohci_die)(struct OHCIState *ohci); | ||
30 | } OHCIState; | ||
31 | |||
32 | +#define TYPE_SYSBUS_OHCI "sysbus-ohci" | ||
33 | +#define SYSBUS_OHCI(obj) OBJECT_CHECK(OHCISysBusState, (obj), TYPE_SYSBUS_OHCI) | ||
34 | + | ||
35 | +typedef struct { | ||
36 | + /*< private >*/ | ||
37 | + SysBusDevice parent_obj; | ||
38 | + /*< public >*/ | ||
39 | + | ||
40 | + OHCIState ohci; | ||
41 | + char *masterbus; | ||
42 | + uint32_t num_ports; | ||
43 | + uint32_t firstport; | ||
44 | + dma_addr_t dma_offset; | ||
45 | +} OHCISysBusState; | ||
46 | + | ||
47 | extern const VMStateDescription vmstate_ohci_state; | ||
48 | |||
49 | void usb_ohci_init(OHCIState *ohci, DeviceState *dev, uint32_t num_ports, | ||
50 | diff --git a/hw/usb/hcd-ohci.c b/hw/usb/hcd-ohci.c | ||
51 | index XXXXXXX..XXXXXXX 100644 | ||
52 | --- a/hw/usb/hcd-ohci.c | ||
53 | +++ b/hw/usb/hcd-ohci.c | ||
54 | @@ -XXX,XX +XXX,XX @@ void ohci_sysbus_die(struct OHCIState *ohci) | ||
55 | ohci_bus_stop(ohci); | ||
56 | } | ||
57 | |||
58 | -#define TYPE_SYSBUS_OHCI "sysbus-ohci" | ||
59 | -#define SYSBUS_OHCI(obj) OBJECT_CHECK(OHCISysBusState, (obj), TYPE_SYSBUS_OHCI) | ||
60 | - | ||
61 | -typedef struct { | ||
62 | - /*< private >*/ | ||
63 | - SysBusDevice parent_obj; | ||
64 | - /*< public >*/ | ||
65 | - | ||
66 | - OHCIState ohci; | ||
67 | - char *masterbus; | ||
68 | - uint32_t num_ports; | ||
69 | - uint32_t firstport; | ||
70 | - dma_addr_t dma_offset; | ||
71 | -} OHCISysBusState; | ||
72 | - | ||
73 | static void ohci_realize_pxa(DeviceState *dev, Error **errp) | ||
74 | { | ||
75 | OHCISysBusState *s = SYSBUS_OHCI(dev); | ||
76 | -- | ||
77 | 2.20.1 | ||
78 | |||
79 | diff view generated by jsdifflib |
1 | The Musca boards have DAPLink firmware that sets the initial | 1 | From: Guenter Roeck <linux@roeck-us.net> |
---|---|---|---|
2 | secure VTOR value (the location of the vector table) differently | ||
3 | depending on the boot mode (from flash, from RAM, etc). Export | ||
4 | the init-svtor as a QOM property of the ARMSSE object so that | ||
5 | the board can change it. | ||
6 | 2 | ||
3 | We'll use this property in a follow-up patch to insantiate an EHCI | ||
4 | bus with companion support. | ||
5 | |||
6 | Reviewed-by: Gerd Hoffmann <kraxel@redhat.com> | ||
7 | Signed-off-by: Guenter Roeck <linux@roeck-us.net> | ||
8 | Tested-by: Niek Linnenbank <nieklinnenbank@gmail.com> | ||
9 | Message-id: 20200217204812.9857-3-linux@roeck-us.net | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
10 | --- | 11 | --- |
11 | include/hw/arm/armsse.h | 3 +++ | 12 | hw/usb/hcd-ehci-sysbus.c | 2 ++ |
12 | hw/arm/armsse.c | 8 ++++---- | 13 | 1 file changed, 2 insertions(+) |
13 | 2 files changed, 7 insertions(+), 4 deletions(-) | ||
14 | 14 | ||
15 | diff --git a/include/hw/arm/armsse.h b/include/hw/arm/armsse.h | 15 | diff --git a/hw/usb/hcd-ehci-sysbus.c b/hw/usb/hcd-ehci-sysbus.c |
16 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/include/hw/arm/armsse.h | 17 | --- a/hw/usb/hcd-ehci-sysbus.c |
18 | +++ b/include/hw/arm/armsse.h | 18 | +++ b/hw/usb/hcd-ehci-sysbus.c |
19 | @@ -XXX,XX +XXX,XX @@ | 19 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_ehci_sysbus = { |
20 | * if necessary.) | 20 | |
21 | * + QOM property "SRAM_ADDR_WIDTH" sets the number of bits used for the | 21 | static Property ehci_sysbus_properties[] = { |
22 | * address of each SRAM bank (and thus the total amount of internal SRAM) | 22 | DEFINE_PROP_UINT32("maxframes", EHCISysBusState, ehci.maxframes, 128), |
23 | + * + QOM property "init-svtor" sets the initial value of the CPU SVTOR register | 23 | + DEFINE_PROP_BOOL("companion-enable", EHCISysBusState, ehci.companion_enable, |
24 | + * (where it expects to load the PC and SP from the vector table on reset) | 24 | + false), |
25 | * + Named GPIO inputs "EXP_IRQ" 0..n are the expansion interrupts for CPU 0, | 25 | DEFINE_PROP_END_OF_LIST(), |
26 | * which are wired to its NVIC lines 32 .. n+32 | ||
27 | * + Named GPIO inputs "EXP_CPU1_IRQ" 0..n are the expansion interrupts for | ||
28 | @@ -XXX,XX +XXX,XX @@ typedef struct ARMSSE { | ||
29 | uint32_t exp_numirq; | ||
30 | uint32_t mainclk_frq; | ||
31 | uint32_t sram_addr_width; | ||
32 | + uint32_t init_svtor; | ||
33 | } ARMSSE; | ||
34 | |||
35 | typedef struct ARMSSEInfo ARMSSEInfo; | ||
36 | diff --git a/hw/arm/armsse.c b/hw/arm/armsse.c | ||
37 | index XXXXXXX..XXXXXXX 100644 | ||
38 | --- a/hw/arm/armsse.c | ||
39 | +++ b/hw/arm/armsse.c | ||
40 | @@ -XXX,XX +XXX,XX @@ static void armsse_realize(DeviceState *dev, Error **errp) | ||
41 | * the INITSVTOR* registers before powering up the CPUs in any case, | ||
42 | * so the hardware's default value doesn't matter. QEMU doesn't emulate | ||
43 | * the control processor, so instead we behave in the way that the | ||
44 | - * firmware does. All boards currently known about have firmware that | ||
45 | - * sets the INITSVTOR0 and INITSVTOR1 registers to 0x10000000, like the | ||
46 | - * IoTKit default. We can make this more configurable if necessary. | ||
47 | + * firmware does. The initial value is configurable by the board code | ||
48 | + * to match whatever its firmware does. | ||
49 | */ | ||
50 | - qdev_prop_set_uint32(cpudev, "init-svtor", 0x10000000); | ||
51 | + qdev_prop_set_uint32(cpudev, "init-svtor", s->init_svtor); | ||
52 | /* | ||
53 | * Start all CPUs except CPU0 powered down. In real hardware it is | ||
54 | * a configurable property of the SSE-200 which CPUs start powered up | ||
55 | @@ -XXX,XX +XXX,XX @@ static Property armsse_properties[] = { | ||
56 | DEFINE_PROP_UINT32("EXP_NUMIRQ", ARMSSE, exp_numirq, 64), | ||
57 | DEFINE_PROP_UINT32("MAINCLK", ARMSSE, mainclk_frq, 0), | ||
58 | DEFINE_PROP_UINT32("SRAM_ADDR_WIDTH", ARMSSE, sram_addr_width, 15), | ||
59 | + DEFINE_PROP_UINT32("init-svtor", ARMSSE, init_svtor, 0x10000000), | ||
60 | DEFINE_PROP_END_OF_LIST() | ||
61 | }; | 26 | }; |
62 | 27 | ||
63 | -- | 28 | -- |
64 | 2.20.1 | 29 | 2.20.1 |
65 | 30 | ||
66 | 31 | diff view generated by jsdifflib |
1 | The PL011 UART has six interrupt lines: | 1 | From: Guenter Roeck <linux@roeck-us.net> |
---|---|---|---|
2 | * RX (receive data) | ||
3 | * TX (transmit data) | ||
4 | * RT (receive timeout) | ||
5 | * MS (modem status) | ||
6 | * E (errors) | ||
7 | * combined (logical OR of all the above) | ||
8 | 2 | ||
9 | So far we have only emulated the combined interrupt line; | 3 | Instantiate EHCI and OHCI controllers on Allwinner A10. OHCI ports are |
10 | add support for the others, so that boards that wire them | 4 | modeled as companions of the respective EHCI ports. |
11 | up to different interrupt controller inputs can do so. | ||
12 | 5 | ||
6 | With this patch applied, USB controllers are discovered and instantiated | ||
7 | when booting the cubieboard machine with a recent Linux kernel. | ||
8 | |||
9 | ehci-platform 1c14000.usb: EHCI Host Controller | ||
10 | ehci-platform 1c14000.usb: new USB bus registered, assigned bus number 1 | ||
11 | ehci-platform 1c14000.usb: irq 26, io mem 0x01c14000 | ||
12 | ehci-platform 1c14000.usb: USB 2.0 started, EHCI 1.00 | ||
13 | ehci-platform 1c1c000.usb: EHCI Host Controller | ||
14 | ehci-platform 1c1c000.usb: new USB bus registered, assigned bus number 2 | ||
15 | ehci-platform 1c1c000.usb: irq 31, io mem 0x01c1c000 | ||
16 | ehci-platform 1c1c000.usb: USB 2.0 started, EHCI 1.00 | ||
17 | ohci-platform 1c14400.usb: Generic Platform OHCI controller | ||
18 | ohci-platform 1c14400.usb: new USB bus registered, assigned bus number 3 | ||
19 | ohci-platform 1c14400.usb: irq 27, io mem 0x01c14400 | ||
20 | ohci-platform 1c1c400.usb: Generic Platform OHCI controller | ||
21 | ohci-platform 1c1c400.usb: new USB bus registered, assigned bus number 4 | ||
22 | ohci-platform 1c1c400.usb: irq 32, io mem 0x01c1c400 | ||
23 | usb 2-1: new high-speed USB device number 2 using ehci-platform | ||
24 | usb-storage 2-1:1.0: USB Mass Storage device detected | ||
25 | scsi host1: usb-storage 2-1:1.0 | ||
26 | usb 3-1: new full-speed USB device number 2 using ohci-platform | ||
27 | input: QEMU QEMU USB Mouse as /devices/platform/soc/1c14400.usb/usb3/3-1/3-1:1.0/0003:0627:0001.0001/input/input0 | ||
28 | |||
29 | Reviewed-by: Gerd Hoffmann <kraxel@redhat.com> | ||
30 | Signed-off-by: Guenter Roeck <linux@roeck-us.net> | ||
31 | Tested-by: Niek Linnenbank <nieklinnenbank@gmail.com> | ||
32 | Message-id: 20200217204812.9857-4-linux@roeck-us.net | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 33 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
15 | --- | 34 | --- |
16 | include/hw/char/pl011.h | 2 +- | 35 | include/hw/arm/allwinner-a10.h | 6 +++++ |
17 | hw/char/pl011.c | 46 +++++++++++++++++++++++++++++++++++++++-- | 36 | hw/arm/allwinner-a10.c | 43 ++++++++++++++++++++++++++++++++++ |
18 | 2 files changed, 45 insertions(+), 3 deletions(-) | 37 | 2 files changed, 49 insertions(+) |
19 | 38 | ||
20 | diff --git a/include/hw/char/pl011.h b/include/hw/char/pl011.h | 39 | diff --git a/include/hw/arm/allwinner-a10.h b/include/hw/arm/allwinner-a10.h |
21 | index XXXXXXX..XXXXXXX 100644 | 40 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/include/hw/char/pl011.h | 41 | --- a/include/hw/arm/allwinner-a10.h |
23 | +++ b/include/hw/char/pl011.h | 42 | +++ b/include/hw/arm/allwinner-a10.h |
24 | @@ -XXX,XX +XXX,XX @@ typedef struct PL011State { | 43 | @@ -XXX,XX +XXX,XX @@ |
25 | int read_count; | 44 | #include "hw/intc/allwinner-a10-pic.h" |
26 | int read_trigger; | 45 | #include "hw/net/allwinner_emac.h" |
27 | CharBackend chr; | 46 | #include "hw/ide/ahci.h" |
28 | - qemu_irq irq; | 47 | +#include "hw/usb/hcd-ohci.h" |
29 | + qemu_irq irq[6]; | 48 | +#include "hw/usb/hcd-ehci.h" |
30 | const unsigned char *id; | 49 | |
31 | } PL011State; | 50 | #include "target/arm/cpu.h" |
32 | 51 | ||
33 | diff --git a/hw/char/pl011.c b/hw/char/pl011.c | 52 | |
53 | #define AW_A10_SDRAM_BASE 0x40000000 | ||
54 | |||
55 | +#define AW_A10_NUM_USB 2 | ||
56 | + | ||
57 | #define TYPE_AW_A10 "allwinner-a10" | ||
58 | #define AW_A10(obj) OBJECT_CHECK(AwA10State, (obj), TYPE_AW_A10) | ||
59 | |||
60 | @@ -XXX,XX +XXX,XX @@ typedef struct AwA10State { | ||
61 | AwEmacState emac; | ||
62 | AllwinnerAHCIState sata; | ||
63 | MemoryRegion sram_a; | ||
64 | + EHCISysBusState ehci[AW_A10_NUM_USB]; | ||
65 | + OHCISysBusState ohci[AW_A10_NUM_USB]; | ||
66 | } AwA10State; | ||
67 | |||
68 | #endif | ||
69 | diff --git a/hw/arm/allwinner-a10.c b/hw/arm/allwinner-a10.c | ||
34 | index XXXXXXX..XXXXXXX 100644 | 70 | index XXXXXXX..XXXXXXX 100644 |
35 | --- a/hw/char/pl011.c | 71 | --- a/hw/arm/allwinner-a10.c |
36 | +++ b/hw/char/pl011.c | 72 | +++ b/hw/arm/allwinner-a10.c |
37 | @@ -XXX,XX +XXX,XX @@ | 73 | @@ -XXX,XX +XXX,XX @@ |
38 | * This code is licensed under the GPL. | 74 | #include "hw/arm/allwinner-a10.h" |
39 | */ | 75 | #include "hw/misc/unimp.h" |
40 | 76 | #include "sysemu/sysemu.h" | |
41 | +/* | 77 | +#include "hw/boards.h" |
42 | + * QEMU interface: | 78 | +#include "hw/usb/hcd-ohci.h" |
43 | + * + sysbus MMIO region 0: device registers | 79 | |
44 | + * + sysbus IRQ 0: UARTINTR (combined interrupt line) | 80 | #define AW_A10_PIC_REG_BASE 0x01c20400 |
45 | + * + sysbus IRQ 1: UARTRXINTR (receive FIFO interrupt line) | 81 | #define AW_A10_PIT_REG_BASE 0x01c20c00 |
46 | + * + sysbus IRQ 2: UARTTXINTR (transmit FIFO interrupt line) | 82 | #define AW_A10_UART0_REG_BASE 0x01c28000 |
47 | + * + sysbus IRQ 3: UARTRTINTR (receive timeout interrupt line) | 83 | #define AW_A10_EMAC_BASE 0x01c0b000 |
48 | + * + sysbus IRQ 4: UARTMSINTR (momem status interrupt line) | 84 | +#define AW_A10_EHCI_BASE 0x01c14000 |
49 | + * + sysbus IRQ 5: UARTEINTR (error interrupt line) | 85 | +#define AW_A10_OHCI_BASE 0x01c14400 |
50 | + */ | 86 | #define AW_A10_SATA_BASE 0x01c18000 |
87 | |||
88 | static void aw_a10_init(Object *obj) | ||
89 | @@ -XXX,XX +XXX,XX @@ static void aw_a10_init(Object *obj) | ||
90 | |||
91 | sysbus_init_child_obj(obj, "sata", &s->sata, sizeof(s->sata), | ||
92 | TYPE_ALLWINNER_AHCI); | ||
51 | + | 93 | + |
52 | #include "qemu/osdep.h" | 94 | + if (machine_usb(current_machine)) { |
53 | #include "hw/char/pl011.h" | 95 | + int i; |
54 | #include "hw/sysbus.h" | ||
55 | @@ -XXX,XX +XXX,XX @@ | ||
56 | #define PL011_FLAG_TXFF 0x20 | ||
57 | #define PL011_FLAG_RXFE 0x10 | ||
58 | |||
59 | +/* Interrupt status bits in UARTRIS, UARTMIS, UARTIMSC */ | ||
60 | +#define INT_OE (1 << 10) | ||
61 | +#define INT_BE (1 << 9) | ||
62 | +#define INT_PE (1 << 8) | ||
63 | +#define INT_FE (1 << 7) | ||
64 | +#define INT_RT (1 << 6) | ||
65 | +#define INT_TX (1 << 5) | ||
66 | +#define INT_RX (1 << 4) | ||
67 | +#define INT_DSR (1 << 3) | ||
68 | +#define INT_DCD (1 << 2) | ||
69 | +#define INT_CTS (1 << 1) | ||
70 | +#define INT_RI (1 << 0) | ||
71 | +#define INT_E (INT_OE | INT_BE | INT_PE | INT_FE) | ||
72 | +#define INT_MS (INT_RI | INT_DSR | INT_DCD | INT_CTS) | ||
73 | + | 96 | + |
74 | static const unsigned char pl011_id_arm[8] = | 97 | + for (i = 0; i < AW_A10_NUM_USB; i++) { |
75 | { 0x11, 0x10, 0x14, 0x00, 0x0d, 0xf0, 0x05, 0xb1 }; | 98 | + sysbus_init_child_obj(obj, "ehci[*]", OBJECT(&s->ehci[i]), |
76 | static const unsigned char pl011_id_luminary[8] = | 99 | + sizeof(s->ehci[i]), TYPE_PLATFORM_EHCI); |
77 | { 0x11, 0x00, 0x18, 0x01, 0x0d, 0xf0, 0x05, 0xb1 }; | 100 | + sysbus_init_child_obj(obj, "ohci[*]", OBJECT(&s->ohci[i]), |
78 | 101 | + sizeof(s->ohci[i]), TYPE_SYSBUS_OHCI); | |
79 | +/* Which bits in the interrupt status matter for each outbound IRQ line ? */ | 102 | + } |
80 | +static const uint32_t irqmask[] = { | ||
81 | + INT_E | INT_MS | INT_RT | INT_TX | INT_RX, /* combined IRQ */ | ||
82 | + INT_RX, | ||
83 | + INT_TX, | ||
84 | + INT_RT, | ||
85 | + INT_MS, | ||
86 | + INT_E, | ||
87 | +}; | ||
88 | + | ||
89 | static void pl011_update(PL011State *s) | ||
90 | { | ||
91 | uint32_t flags; | ||
92 | + int i; | ||
93 | |||
94 | flags = s->int_level & s->int_enabled; | ||
95 | trace_pl011_irq_state(flags != 0); | ||
96 | - qemu_set_irq(s->irq, flags != 0); | ||
97 | + for (i = 0; i < ARRAY_SIZE(s->irq); i++) { | ||
98 | + qemu_set_irq(s->irq[i], (flags & irqmask[i]) != 0); | ||
99 | + } | 103 | + } |
100 | } | 104 | } |
101 | 105 | ||
102 | static uint64_t pl011_read(void *opaque, hwaddr offset, | 106 | static void aw_a10_realize(DeviceState *dev, Error **errp) |
103 | @@ -XXX,XX +XXX,XX @@ static void pl011_init(Object *obj) | 107 | @@ -XXX,XX +XXX,XX @@ static void aw_a10_realize(DeviceState *dev, Error **errp) |
104 | { | 108 | serial_mm_init(get_system_memory(), AW_A10_UART0_REG_BASE, 2, |
105 | SysBusDevice *sbd = SYS_BUS_DEVICE(obj); | 109 | qdev_get_gpio_in(dev, 1), |
106 | PL011State *s = PL011(obj); | 110 | 115200, serial_hd(0), DEVICE_NATIVE_ENDIAN); |
107 | + int i; | 111 | + |
108 | 112 | + if (machine_usb(current_machine)) { | |
109 | memory_region_init_io(&s->iomem, OBJECT(s), &pl011_ops, s, "pl011", 0x1000); | 113 | + int i; |
110 | sysbus_init_mmio(sbd, &s->iomem); | 114 | + |
111 | - sysbus_init_irq(sbd, &s->irq); | 115 | + for (i = 0; i < AW_A10_NUM_USB; i++) { |
112 | + for (i = 0; i < ARRAY_SIZE(s->irq); i++) { | 116 | + char bus[16]; |
113 | + sysbus_init_irq(sbd, &s->irq[i]); | 117 | + |
118 | + sprintf(bus, "usb-bus.%d", i); | ||
119 | + | ||
120 | + object_property_set_bool(OBJECT(&s->ehci[i]), true, | ||
121 | + "companion-enable", &error_fatal); | ||
122 | + object_property_set_bool(OBJECT(&s->ehci[i]), true, "realized", | ||
123 | + &error_fatal); | ||
124 | + sysbus_mmio_map(SYS_BUS_DEVICE(&s->ehci[i]), 0, | ||
125 | + AW_A10_EHCI_BASE + i * 0x8000); | ||
126 | + sysbus_connect_irq(SYS_BUS_DEVICE(&s->ehci[i]), 0, | ||
127 | + qdev_get_gpio_in(dev, 39 + i)); | ||
128 | + | ||
129 | + object_property_set_str(OBJECT(&s->ohci[i]), bus, "masterbus", | ||
130 | + &error_fatal); | ||
131 | + object_property_set_bool(OBJECT(&s->ohci[i]), true, "realized", | ||
132 | + &error_fatal); | ||
133 | + sysbus_mmio_map(SYS_BUS_DEVICE(&s->ohci[i]), 0, | ||
134 | + AW_A10_OHCI_BASE + i * 0x8000); | ||
135 | + sysbus_connect_irq(SYS_BUS_DEVICE(&s->ohci[i]), 0, | ||
136 | + qdev_get_gpio_in(dev, 64 + i)); | ||
137 | + } | ||
114 | + } | 138 | + } |
115 | 139 | } | |
116 | s->read_trigger = 1; | 140 | |
117 | s->ifl = 0x12; | 141 | static void aw_a10_class_init(ObjectClass *oc, void *data) |
118 | -- | 142 | -- |
119 | 2.20.1 | 143 | 2.20.1 |
120 | 144 | ||
121 | 145 | diff view generated by jsdifflib |
1 | The Musca-A and Musca-B1 development boards are based on the | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | SSE-200 subsystem for embedded. Implement an initial skeleton | ||
3 | model of these boards, which are similar but not identical. | ||
4 | 2 | ||
5 | This commit creates the board model with the SSE and the IRQ | 3 | These instructions shift left or right depending on the sign |
6 | splitters to wire IRQs up to its two CPUs. As yet there | 4 | of the input, and 7 bits are significant to the shift. This |
7 | are no devices and no memory: these will be added later. | 5 | requires several masks and selects in addition to the actual |
6 | shifts to form the complete answer. | ||
8 | 7 | ||
8 | That said, the operation is still a small improvement even for | ||
9 | two 64-bit elements -- 13 vector operations instead of 2 * 7 | ||
10 | integer operations. | ||
11 | |||
12 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
13 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
14 | Message-id: 20200216214232.4230-2-richard.henderson@linaro.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
11 | --- | 16 | --- |
12 | hw/arm/Makefile.objs | 1 + | 17 | target/arm/helper.h | 11 +- |
13 | hw/arm/musca.c | 197 ++++++++++++++++++++++++++++++++ | 18 | target/arm/translate.h | 6 + |
14 | MAINTAINERS | 6 + | 19 | target/arm/neon_helper.c | 33 ---- |
15 | default-configs/arm-softmmu.mak | 1 + | 20 | target/arm/translate-a64.c | 18 +-- |
16 | 4 files changed, 205 insertions(+) | 21 | target/arm/translate.c | 299 +++++++++++++++++++++++++++++++++++-- |
17 | create mode 100644 hw/arm/musca.c | 22 | target/arm/vec_helper.c | 88 +++++++++++ |
23 | 6 files changed, 389 insertions(+), 66 deletions(-) | ||
18 | 24 | ||
19 | diff --git a/hw/arm/Makefile.objs b/hw/arm/Makefile.objs | 25 | diff --git a/target/arm/helper.h b/target/arm/helper.h |
20 | index XXXXXXX..XXXXXXX 100644 | 26 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/hw/arm/Makefile.objs | 27 | --- a/target/arm/helper.h |
22 | +++ b/hw/arm/Makefile.objs | 28 | +++ b/target/arm/helper.h |
23 | @@ -XXX,XX +XXX,XX @@ obj-$(CONFIG_ASPEED_SOC) += aspeed_soc.o aspeed.o | 29 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_2(neon_abd_s16, i32, i32, i32) |
24 | obj-$(CONFIG_MPS2) += mps2.o | 30 | DEF_HELPER_2(neon_abd_u32, i32, i32, i32) |
25 | obj-$(CONFIG_MPS2) += mps2-tz.o | 31 | DEF_HELPER_2(neon_abd_s32, i32, i32, i32) |
26 | obj-$(CONFIG_MSF2) += msf2-soc.o msf2-som.o | 32 | |
27 | +obj-$(CONFIG_MUSCA) += musca.o | 33 | -DEF_HELPER_2(neon_shl_u8, i32, i32, i32) |
28 | obj-$(CONFIG_ARMSSE) += armsse.o | 34 | -DEF_HELPER_2(neon_shl_s8, i32, i32, i32) |
29 | obj-$(CONFIG_FSL_IMX7) += fsl-imx7.o mcimx7d-sabre.o | 35 | DEF_HELPER_2(neon_shl_u16, i32, i32, i32) |
30 | obj-$(CONFIG_ARM_SMMUV3) += smmu-common.o smmuv3.o | 36 | DEF_HELPER_2(neon_shl_s16, i32, i32, i32) |
31 | diff --git a/hw/arm/musca.c b/hw/arm/musca.c | 37 | -DEF_HELPER_2(neon_shl_u32, i32, i32, i32) |
32 | new file mode 100644 | 38 | -DEF_HELPER_2(neon_shl_s32, i32, i32, i32) |
33 | index XXXXXXX..XXXXXXX | 39 | -DEF_HELPER_2(neon_shl_u64, i64, i64, i64) |
34 | --- /dev/null | 40 | -DEF_HELPER_2(neon_shl_s64, i64, i64, i64) |
35 | +++ b/hw/arm/musca.c | 41 | DEF_HELPER_2(neon_rshl_u8, i32, i32, i32) |
36 | @@ -XXX,XX +XXX,XX @@ | 42 | DEF_HELPER_2(neon_rshl_s8, i32, i32, i32) |
37 | +/* | 43 | DEF_HELPER_2(neon_rshl_u16, i32, i32, i32) |
38 | + * Arm Musca-B1 test chip board emulation | 44 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_2(frint64_s, TCG_CALL_NO_RWG, f32, f32, ptr) |
39 | + * | 45 | DEF_HELPER_FLAGS_2(frint32_d, TCG_CALL_NO_RWG, f64, f64, ptr) |
40 | + * Copyright (c) 2019 Linaro Limited | 46 | DEF_HELPER_FLAGS_2(frint64_d, TCG_CALL_NO_RWG, f64, f64, ptr) |
41 | + * Written by Peter Maydell | 47 | |
42 | + * | 48 | +DEF_HELPER_FLAGS_4(gvec_sshl_b, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) |
43 | + * This program is free software; you can redistribute it and/or modify | 49 | +DEF_HELPER_FLAGS_4(gvec_sshl_h, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) |
44 | + * it under the terms of the GNU General Public License version 2 or | 50 | +DEF_HELPER_FLAGS_4(gvec_ushl_b, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) |
45 | + * (at your option) any later version. | 51 | +DEF_HELPER_FLAGS_4(gvec_ushl_h, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) |
46 | + */ | 52 | + |
47 | + | 53 | #ifdef TARGET_AARCH64 |
48 | +/* | 54 | #include "helper-a64.h" |
49 | + * The Musca boards are a reference implementation of a system using | 55 | #include "helper-sve.h" |
50 | + * the SSE-200 subsystem for embedded: | 56 | diff --git a/target/arm/translate.h b/target/arm/translate.h |
51 | + * https://developer.arm.com/products/system-design/development-boards/iot-test-chips-and-boards/musca-a-test-chip-board | 57 | index XXXXXXX..XXXXXXX 100644 |
52 | + * https://developer.arm.com/products/system-design/development-boards/iot-test-chips-and-boards/musca-b-test-chip-board | 58 | --- a/target/arm/translate.h |
53 | + * We model the A and B1 variants of this board, as described in the TRMs: | 59 | +++ b/target/arm/translate.h |
54 | + * http://infocenter.arm.com/help/topic/com.arm.doc.101107_0000_00_en/index.html | 60 | @@ -XXX,XX +XXX,XX @@ uint64_t vfp_expand_imm(int size, uint8_t imm8); |
55 | + * http://infocenter.arm.com/help/topic/com.arm.doc.101312_0000_00_en/index.html | 61 | extern const GVecGen3 mla_op[4]; |
56 | + */ | 62 | extern const GVecGen3 mls_op[4]; |
57 | + | 63 | extern const GVecGen3 cmtst_op[4]; |
58 | +#include "qemu/osdep.h" | 64 | +extern const GVecGen3 sshl_op[4]; |
59 | +#include "qemu/error-report.h" | 65 | +extern const GVecGen3 ushl_op[4]; |
60 | +#include "qapi/error.h" | 66 | extern const GVecGen2i ssra_op[4]; |
61 | +#include "exec/address-spaces.h" | 67 | extern const GVecGen2i usra_op[4]; |
62 | +#include "hw/arm/arm.h" | 68 | extern const GVecGen2i sri_op[4]; |
63 | +#include "hw/arm/armsse.h" | 69 | @@ -XXX,XX +XXX,XX @@ extern const GVecGen4 sqadd_op[4]; |
64 | +#include "hw/boards.h" | 70 | extern const GVecGen4 uqsub_op[4]; |
65 | +#include "hw/core/split-irq.h" | 71 | extern const GVecGen4 sqsub_op[4]; |
66 | + | 72 | void gen_cmtst_i64(TCGv_i64 d, TCGv_i64 a, TCGv_i64 b); |
67 | +#define MUSCA_NUMIRQ_MAX 96 | 73 | +void gen_ushl_i32(TCGv_i32 d, TCGv_i32 a, TCGv_i32 b); |
68 | + | 74 | +void gen_sshl_i32(TCGv_i32 d, TCGv_i32 a, TCGv_i32 b); |
69 | +typedef enum MuscaType { | 75 | +void gen_ushl_i64(TCGv_i64 d, TCGv_i64 a, TCGv_i64 b); |
70 | + MUSCA_A, | 76 | +void gen_sshl_i64(TCGv_i64 d, TCGv_i64 a, TCGv_i64 b); |
71 | + MUSCA_B1, | 77 | |
72 | +} MuscaType; | 78 | /* |
73 | + | 79 | * Forward to the isar_feature_* tests given a DisasContext pointer. |
74 | +typedef struct { | 80 | diff --git a/target/arm/neon_helper.c b/target/arm/neon_helper.c |
75 | + MachineClass parent; | 81 | index XXXXXXX..XXXXXXX 100644 |
76 | + MuscaType type; | 82 | --- a/target/arm/neon_helper.c |
77 | + uint32_t init_svtor; | 83 | +++ b/target/arm/neon_helper.c |
78 | + int sram_addr_width; | 84 | @@ -XXX,XX +XXX,XX @@ NEON_VOP(abd_u32, neon_u32, 1) |
79 | + int num_irqs; | 85 | } else { \ |
80 | +} MuscaMachineClass; | 86 | dest = src1 << tmp; \ |
81 | + | 87 | }} while (0) |
82 | +typedef struct { | 88 | -NEON_VOP(shl_u8, neon_u8, 4) |
83 | + MachineState parent; | 89 | NEON_VOP(shl_u16, neon_u16, 2) |
84 | + | 90 | -NEON_VOP(shl_u32, neon_u32, 1) |
85 | + ARMSSE sse; | 91 | #undef NEON_FN |
86 | + SplitIRQ cpu_irq_splitter[MUSCA_NUMIRQ_MAX]; | 92 | |
87 | +} MuscaMachineState; | 93 | -uint64_t HELPER(neon_shl_u64)(uint64_t val, uint64_t shiftop) |
88 | + | 94 | -{ |
89 | +#define TYPE_MUSCA_MACHINE "musca" | 95 | - int8_t shift = (int8_t)shiftop; |
90 | +#define TYPE_MUSCA_A_MACHINE MACHINE_TYPE_NAME("musca-a") | 96 | - if (shift >= 64 || shift <= -64) { |
91 | +#define TYPE_MUSCA_B1_MACHINE MACHINE_TYPE_NAME("musca-b1") | 97 | - val = 0; |
92 | + | 98 | - } else if (shift < 0) { |
93 | +#define MUSCA_MACHINE(obj) \ | 99 | - val >>= -shift; |
94 | + OBJECT_CHECK(MuscaMachineState, obj, TYPE_MUSCA_MACHINE) | 100 | - } else { |
95 | +#define MUSCA_MACHINE_GET_CLASS(obj) \ | 101 | - val <<= shift; |
96 | + OBJECT_GET_CLASS(MuscaMachineClass, obj, TYPE_MUSCA_MACHINE) | 102 | - } |
97 | +#define MUSCA_MACHINE_CLASS(klass) \ | 103 | - return val; |
98 | + OBJECT_CLASS_CHECK(MuscaMachineClass, klass, TYPE_MUSCA_MACHINE) | 104 | -} |
99 | + | 105 | - |
100 | +/* | 106 | #define NEON_FN(dest, src1, src2) do { \ |
101 | + * Main SYSCLK frequency in Hz | 107 | int8_t tmp; \ |
102 | + * TODO this should really be different for the two cores, but we | 108 | tmp = (int8_t)src2; \ |
103 | + * don't model that in our SSE-200 model yet. | 109 | @@ -XXX,XX +XXX,XX @@ uint64_t HELPER(neon_shl_u64)(uint64_t val, uint64_t shiftop) |
104 | + */ | 110 | } else { \ |
105 | +#define SYSCLK_FRQ 40000000 | 111 | dest = src1 << tmp; \ |
106 | + | 112 | }} while (0) |
107 | +static void musca_init(MachineState *machine) | 113 | -NEON_VOP(shl_s8, neon_s8, 4) |
108 | +{ | 114 | NEON_VOP(shl_s16, neon_s16, 2) |
109 | + MuscaMachineState *mms = MUSCA_MACHINE(machine); | 115 | -NEON_VOP(shl_s32, neon_s32, 1) |
110 | + MuscaMachineClass *mmc = MUSCA_MACHINE_GET_CLASS(mms); | 116 | #undef NEON_FN |
111 | + MachineClass *mc = MACHINE_GET_CLASS(machine); | 117 | |
112 | + MemoryRegion *system_memory = get_system_memory(); | 118 | -uint64_t HELPER(neon_shl_s64)(uint64_t valop, uint64_t shiftop) |
113 | + DeviceState *ssedev; | 119 | -{ |
114 | + int i; | 120 | - int8_t shift = (int8_t)shiftop; |
115 | + | 121 | - int64_t val = valop; |
116 | + assert(mmc->num_irqs <= MUSCA_NUMIRQ_MAX); | 122 | - if (shift >= 64) { |
117 | + | 123 | - val = 0; |
118 | + if (strcmp(machine->cpu_type, mc->default_cpu_type) != 0) { | 124 | - } else if (shift <= -64) { |
119 | + error_report("This board can only be used with CPU %s", | 125 | - val >>= 63; |
120 | + mc->default_cpu_type); | 126 | - } else if (shift < 0) { |
121 | + exit(1); | 127 | - val >>= -shift; |
122 | + } | 128 | - } else { |
123 | + | 129 | - val <<= shift; |
124 | + sysbus_init_child_obj(OBJECT(machine), "sse-200", &mms->sse, | 130 | - } |
125 | + sizeof(mms->sse), TYPE_SSE200); | 131 | - return val; |
126 | + ssedev = DEVICE(&mms->sse); | 132 | -} |
127 | + object_property_set_link(OBJECT(&mms->sse), OBJECT(system_memory), | 133 | - |
128 | + "memory", &error_fatal); | 134 | #define NEON_FN(dest, src1, src2) do { \ |
129 | + qdev_prop_set_uint32(ssedev, "EXP_NUMIRQ", mmc->num_irqs); | 135 | int8_t tmp; \ |
130 | + qdev_prop_set_uint32(ssedev, "init-svtor", mmc->init_svtor); | 136 | tmp = (int8_t)src2; \ |
131 | + qdev_prop_set_uint32(ssedev, "SRAM_ADDR_WIDTH", mmc->sram_addr_width); | 137 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c |
132 | + qdev_prop_set_uint32(ssedev, "MAINCLK", SYSCLK_FRQ); | 138 | index XXXXXXX..XXXXXXX 100644 |
133 | + object_property_set_bool(OBJECT(&mms->sse), true, "realized", | 139 | --- a/target/arm/translate-a64.c |
134 | + &error_fatal); | 140 | +++ b/target/arm/translate-a64.c |
141 | @@ -XXX,XX +XXX,XX @@ static void handle_3same_64(DisasContext *s, int opcode, bool u, | ||
142 | break; | ||
143 | case 0x8: /* SSHL, USHL */ | ||
144 | if (u) { | ||
145 | - gen_helper_neon_shl_u64(tcg_rd, tcg_rn, tcg_rm); | ||
146 | + gen_ushl_i64(tcg_rd, tcg_rn, tcg_rm); | ||
147 | } else { | ||
148 | - gen_helper_neon_shl_s64(tcg_rd, tcg_rn, tcg_rm); | ||
149 | + gen_sshl_i64(tcg_rd, tcg_rn, tcg_rm); | ||
150 | } | ||
151 | break; | ||
152 | case 0x9: /* SQSHL, UQSHL */ | ||
153 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_3same_int(DisasContext *s, uint32_t insn) | ||
154 | is_q ? 16 : 8, vec_full_reg_size(s), | ||
155 | (u ? uqsub_op : sqsub_op) + size); | ||
156 | return; | ||
157 | + case 0x08: /* SSHL, USHL */ | ||
158 | + gen_gvec_op3(s, is_q, rd, rn, rm, | ||
159 | + u ? &ushl_op[size] : &sshl_op[size]); | ||
160 | + return; | ||
161 | case 0x0c: /* SMAX, UMAX */ | ||
162 | if (u) { | ||
163 | gen_gvec_fn3(s, is_q, rd, rn, rm, tcg_gen_gvec_umax, size); | ||
164 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_3same_int(DisasContext *s, uint32_t insn) | ||
165 | genfn = fns[size][u]; | ||
166 | break; | ||
167 | } | ||
168 | - case 0x8: /* SSHL, USHL */ | ||
169 | - { | ||
170 | - static NeonGenTwoOpFn * const fns[3][2] = { | ||
171 | - { gen_helper_neon_shl_s8, gen_helper_neon_shl_u8 }, | ||
172 | - { gen_helper_neon_shl_s16, gen_helper_neon_shl_u16 }, | ||
173 | - { gen_helper_neon_shl_s32, gen_helper_neon_shl_u32 }, | ||
174 | - }; | ||
175 | - genfn = fns[size][u]; | ||
176 | - break; | ||
177 | - } | ||
178 | case 0x9: /* SQSHL, UQSHL */ | ||
179 | { | ||
180 | static NeonGenTwoOpEnvFn * const fns[3][2] = { | ||
181 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
182 | index XXXXXXX..XXXXXXX 100644 | ||
183 | --- a/target/arm/translate.c | ||
184 | +++ b/target/arm/translate.c | ||
185 | @@ -XXX,XX +XXX,XX @@ static inline void gen_neon_shift_narrow(int size, TCGv_i32 var, TCGv_i32 shift, | ||
186 | if (u) { | ||
187 | switch (size) { | ||
188 | case 1: gen_helper_neon_shl_u16(var, var, shift); break; | ||
189 | - case 2: gen_helper_neon_shl_u32(var, var, shift); break; | ||
190 | + case 2: gen_ushl_i32(var, var, shift); break; | ||
191 | default: abort(); | ||
192 | } | ||
193 | } else { | ||
194 | switch (size) { | ||
195 | case 1: gen_helper_neon_shl_s16(var, var, shift); break; | ||
196 | - case 2: gen_helper_neon_shl_s32(var, var, shift); break; | ||
197 | + case 2: gen_sshl_i32(var, var, shift); break; | ||
198 | default: abort(); | ||
199 | } | ||
200 | } | ||
201 | @@ -XXX,XX +XXX,XX @@ const GVecGen3 cmtst_op[4] = { | ||
202 | .vece = MO_64 }, | ||
203 | }; | ||
204 | |||
205 | +void gen_ushl_i32(TCGv_i32 dst, TCGv_i32 src, TCGv_i32 shift) | ||
206 | +{ | ||
207 | + TCGv_i32 lval = tcg_temp_new_i32(); | ||
208 | + TCGv_i32 rval = tcg_temp_new_i32(); | ||
209 | + TCGv_i32 lsh = tcg_temp_new_i32(); | ||
210 | + TCGv_i32 rsh = tcg_temp_new_i32(); | ||
211 | + TCGv_i32 zero = tcg_const_i32(0); | ||
212 | + TCGv_i32 max = tcg_const_i32(32); | ||
135 | + | 213 | + |
136 | + /* | 214 | + /* |
137 | + * We need to create splitters to feed the IRQ inputs | 215 | + * Rely on the TCG guarantee that out of range shifts produce |
138 | + * for each CPU in the SSE-200 from each device in the board. | 216 | + * unspecified results, not undefined behaviour (i.e. no trap). |
217 | + * Discard out-of-range results after the fact. | ||
139 | + */ | 218 | + */ |
140 | + for (i = 0; i < mmc->num_irqs; i++) { | 219 | + tcg_gen_ext8s_i32(lsh, shift); |
141 | + char *name = g_strdup_printf("musca-irq-splitter%d", i); | 220 | + tcg_gen_neg_i32(rsh, lsh); |
142 | + SplitIRQ *splitter = &mms->cpu_irq_splitter[i]; | 221 | + tcg_gen_shl_i32(lval, src, lsh); |
143 | + | 222 | + tcg_gen_shr_i32(rval, src, rsh); |
144 | + object_initialize_child(OBJECT(machine), name, | 223 | + tcg_gen_movcond_i32(TCG_COND_LTU, dst, lsh, max, lval, zero); |
145 | + splitter, sizeof(*splitter), | 224 | + tcg_gen_movcond_i32(TCG_COND_LTU, dst, rsh, max, rval, dst); |
146 | + TYPE_SPLIT_IRQ, &error_fatal, NULL); | 225 | + |
147 | + g_free(name); | 226 | + tcg_temp_free_i32(lval); |
148 | + | 227 | + tcg_temp_free_i32(rval); |
149 | + object_property_set_int(OBJECT(splitter), 2, "num-lines", | 228 | + tcg_temp_free_i32(lsh); |
150 | + &error_fatal); | 229 | + tcg_temp_free_i32(rsh); |
151 | + object_property_set_bool(OBJECT(splitter), true, "realized", | 230 | + tcg_temp_free_i32(zero); |
152 | + &error_fatal); | 231 | + tcg_temp_free_i32(max); |
153 | + qdev_connect_gpio_out(DEVICE(splitter), 0, | 232 | +} |
154 | + qdev_get_gpio_in_named(ssedev, "EXP_IRQ", i)); | 233 | + |
155 | + qdev_connect_gpio_out(DEVICE(splitter), 1, | 234 | +void gen_ushl_i64(TCGv_i64 dst, TCGv_i64 src, TCGv_i64 shift) |
156 | + qdev_get_gpio_in_named(ssedev, | 235 | +{ |
157 | + "EXP_CPU1_IRQ", i)); | 236 | + TCGv_i64 lval = tcg_temp_new_i64(); |
158 | + } | 237 | + TCGv_i64 rval = tcg_temp_new_i64(); |
159 | + | 238 | + TCGv_i64 lsh = tcg_temp_new_i64(); |
160 | + armv7m_load_kernel(ARM_CPU(first_cpu), machine->kernel_filename, 0x2000000); | 239 | + TCGv_i64 rsh = tcg_temp_new_i64(); |
161 | +} | 240 | + TCGv_i64 zero = tcg_const_i64(0); |
162 | + | 241 | + TCGv_i64 max = tcg_const_i64(64); |
163 | +static void musca_class_init(ObjectClass *oc, void *data) | 242 | + |
164 | +{ | ||
165 | + MachineClass *mc = MACHINE_CLASS(oc); | ||
166 | + | ||
167 | + mc->default_cpus = 2; | ||
168 | + mc->min_cpus = mc->default_cpus; | ||
169 | + mc->max_cpus = mc->default_cpus; | ||
170 | + mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-m33"); | ||
171 | + mc->init = musca_init; | ||
172 | +} | ||
173 | + | ||
174 | +static void musca_a_class_init(ObjectClass *oc, void *data) | ||
175 | +{ | ||
176 | + MachineClass *mc = MACHINE_CLASS(oc); | ||
177 | + MuscaMachineClass *mmc = MUSCA_MACHINE_CLASS(oc); | ||
178 | + | ||
179 | + mc->desc = "ARM Musca-A board (dual Cortex-M33)"; | ||
180 | + mmc->type = MUSCA_A; | ||
181 | + mmc->init_svtor = 0x10200000; | ||
182 | + mmc->sram_addr_width = 15; | ||
183 | + mmc->num_irqs = 64; | ||
184 | +} | ||
185 | + | ||
186 | +static void musca_b1_class_init(ObjectClass *oc, void *data) | ||
187 | +{ | ||
188 | + MachineClass *mc = MACHINE_CLASS(oc); | ||
189 | + MuscaMachineClass *mmc = MUSCA_MACHINE_CLASS(oc); | ||
190 | + | ||
191 | + mc->desc = "ARM Musca-B1 board (dual Cortex-M33)"; | ||
192 | + mmc->type = MUSCA_B1; | ||
193 | + /* | 243 | + /* |
194 | + * This matches the DAPlink firmware which boots from QSPI. There | 244 | + * Rely on the TCG guarantee that out of range shifts produce |
195 | + * is also a firmware blob which boots from the eFlash, which | 245 | + * unspecified results, not undefined behaviour (i.e. no trap). |
196 | + * uses init_svtor = 0x1A000000. QEMU doesn't currently support that, | 246 | + * Discard out-of-range results after the fact. |
197 | + * though we could in theory expose a machine property on the command | ||
198 | + * line to allow the user to request eFlash boot. | ||
199 | + */ | 247 | + */ |
200 | + mmc->init_svtor = 0x10000000; | 248 | + tcg_gen_ext8s_i64(lsh, shift); |
201 | + mmc->sram_addr_width = 17; | 249 | + tcg_gen_neg_i64(rsh, lsh); |
202 | + mmc->num_irqs = 96; | 250 | + tcg_gen_shl_i64(lval, src, lsh); |
203 | +} | 251 | + tcg_gen_shr_i64(rval, src, rsh); |
204 | + | 252 | + tcg_gen_movcond_i64(TCG_COND_LTU, dst, lsh, max, lval, zero); |
205 | +static const TypeInfo musca_info = { | 253 | + tcg_gen_movcond_i64(TCG_COND_LTU, dst, rsh, max, rval, dst); |
206 | + .name = TYPE_MUSCA_MACHINE, | 254 | + |
207 | + .parent = TYPE_MACHINE, | 255 | + tcg_temp_free_i64(lval); |
208 | + .abstract = true, | 256 | + tcg_temp_free_i64(rval); |
209 | + .instance_size = sizeof(MuscaMachineState), | 257 | + tcg_temp_free_i64(lsh); |
210 | + .class_size = sizeof(MuscaMachineClass), | 258 | + tcg_temp_free_i64(rsh); |
211 | + .class_init = musca_class_init, | 259 | + tcg_temp_free_i64(zero); |
260 | + tcg_temp_free_i64(max); | ||
261 | +} | ||
262 | + | ||
263 | +static void gen_ushl_vec(unsigned vece, TCGv_vec dst, | ||
264 | + TCGv_vec src, TCGv_vec shift) | ||
265 | +{ | ||
266 | + TCGv_vec lval = tcg_temp_new_vec_matching(dst); | ||
267 | + TCGv_vec rval = tcg_temp_new_vec_matching(dst); | ||
268 | + TCGv_vec lsh = tcg_temp_new_vec_matching(dst); | ||
269 | + TCGv_vec rsh = tcg_temp_new_vec_matching(dst); | ||
270 | + TCGv_vec msk, max; | ||
271 | + | ||
272 | + tcg_gen_neg_vec(vece, rsh, shift); | ||
273 | + if (vece == MO_8) { | ||
274 | + tcg_gen_mov_vec(lsh, shift); | ||
275 | + } else { | ||
276 | + msk = tcg_temp_new_vec_matching(dst); | ||
277 | + tcg_gen_dupi_vec(vece, msk, 0xff); | ||
278 | + tcg_gen_and_vec(vece, lsh, shift, msk); | ||
279 | + tcg_gen_and_vec(vece, rsh, rsh, msk); | ||
280 | + tcg_temp_free_vec(msk); | ||
281 | + } | ||
282 | + | ||
283 | + /* | ||
284 | + * Rely on the TCG guarantee that out of range shifts produce | ||
285 | + * unspecified results, not undefined behaviour (i.e. no trap). | ||
286 | + * Discard out-of-range results after the fact. | ||
287 | + */ | ||
288 | + tcg_gen_shlv_vec(vece, lval, src, lsh); | ||
289 | + tcg_gen_shrv_vec(vece, rval, src, rsh); | ||
290 | + | ||
291 | + max = tcg_temp_new_vec_matching(dst); | ||
292 | + tcg_gen_dupi_vec(vece, max, 8 << vece); | ||
293 | + | ||
294 | + /* | ||
295 | + * The choice of LT (signed) and GEU (unsigned) are biased toward | ||
296 | + * the instructions of the x86_64 host. For MO_8, the whole byte | ||
297 | + * is significant so we must use an unsigned compare; otherwise we | ||
298 | + * have already masked to a byte and so a signed compare works. | ||
299 | + * Other tcg hosts have a full set of comparisons and do not care. | ||
300 | + */ | ||
301 | + if (vece == MO_8) { | ||
302 | + tcg_gen_cmp_vec(TCG_COND_GEU, vece, lsh, lsh, max); | ||
303 | + tcg_gen_cmp_vec(TCG_COND_GEU, vece, rsh, rsh, max); | ||
304 | + tcg_gen_andc_vec(vece, lval, lval, lsh); | ||
305 | + tcg_gen_andc_vec(vece, rval, rval, rsh); | ||
306 | + } else { | ||
307 | + tcg_gen_cmp_vec(TCG_COND_LT, vece, lsh, lsh, max); | ||
308 | + tcg_gen_cmp_vec(TCG_COND_LT, vece, rsh, rsh, max); | ||
309 | + tcg_gen_and_vec(vece, lval, lval, lsh); | ||
310 | + tcg_gen_and_vec(vece, rval, rval, rsh); | ||
311 | + } | ||
312 | + tcg_gen_or_vec(vece, dst, lval, rval); | ||
313 | + | ||
314 | + tcg_temp_free_vec(max); | ||
315 | + tcg_temp_free_vec(lval); | ||
316 | + tcg_temp_free_vec(rval); | ||
317 | + tcg_temp_free_vec(lsh); | ||
318 | + tcg_temp_free_vec(rsh); | ||
319 | +} | ||
320 | + | ||
321 | +static const TCGOpcode ushl_list[] = { | ||
322 | + INDEX_op_neg_vec, INDEX_op_shlv_vec, | ||
323 | + INDEX_op_shrv_vec, INDEX_op_cmp_vec, 0 | ||
212 | +}; | 324 | +}; |
213 | + | 325 | + |
214 | +static const TypeInfo musca_a_info = { | 326 | +const GVecGen3 ushl_op[4] = { |
215 | + .name = TYPE_MUSCA_A_MACHINE, | 327 | + { .fniv = gen_ushl_vec, |
216 | + .parent = TYPE_MUSCA_MACHINE, | 328 | + .fno = gen_helper_gvec_ushl_b, |
217 | + .class_init = musca_a_class_init, | 329 | + .opt_opc = ushl_list, |
330 | + .vece = MO_8 }, | ||
331 | + { .fniv = gen_ushl_vec, | ||
332 | + .fno = gen_helper_gvec_ushl_h, | ||
333 | + .opt_opc = ushl_list, | ||
334 | + .vece = MO_16 }, | ||
335 | + { .fni4 = gen_ushl_i32, | ||
336 | + .fniv = gen_ushl_vec, | ||
337 | + .opt_opc = ushl_list, | ||
338 | + .vece = MO_32 }, | ||
339 | + { .fni8 = gen_ushl_i64, | ||
340 | + .fniv = gen_ushl_vec, | ||
341 | + .opt_opc = ushl_list, | ||
342 | + .vece = MO_64 }, | ||
218 | +}; | 343 | +}; |
219 | + | 344 | + |
220 | +static const TypeInfo musca_b1_info = { | 345 | +void gen_sshl_i32(TCGv_i32 dst, TCGv_i32 src, TCGv_i32 shift) |
221 | + .name = TYPE_MUSCA_B1_MACHINE, | 346 | +{ |
222 | + .parent = TYPE_MUSCA_MACHINE, | 347 | + TCGv_i32 lval = tcg_temp_new_i32(); |
223 | + .class_init = musca_b1_class_init, | 348 | + TCGv_i32 rval = tcg_temp_new_i32(); |
349 | + TCGv_i32 lsh = tcg_temp_new_i32(); | ||
350 | + TCGv_i32 rsh = tcg_temp_new_i32(); | ||
351 | + TCGv_i32 zero = tcg_const_i32(0); | ||
352 | + TCGv_i32 max = tcg_const_i32(31); | ||
353 | + | ||
354 | + /* | ||
355 | + * Rely on the TCG guarantee that out of range shifts produce | ||
356 | + * unspecified results, not undefined behaviour (i.e. no trap). | ||
357 | + * Discard out-of-range results after the fact. | ||
358 | + */ | ||
359 | + tcg_gen_ext8s_i32(lsh, shift); | ||
360 | + tcg_gen_neg_i32(rsh, lsh); | ||
361 | + tcg_gen_shl_i32(lval, src, lsh); | ||
362 | + tcg_gen_umin_i32(rsh, rsh, max); | ||
363 | + tcg_gen_sar_i32(rval, src, rsh); | ||
364 | + tcg_gen_movcond_i32(TCG_COND_LEU, lval, lsh, max, lval, zero); | ||
365 | + tcg_gen_movcond_i32(TCG_COND_LT, dst, lsh, zero, rval, lval); | ||
366 | + | ||
367 | + tcg_temp_free_i32(lval); | ||
368 | + tcg_temp_free_i32(rval); | ||
369 | + tcg_temp_free_i32(lsh); | ||
370 | + tcg_temp_free_i32(rsh); | ||
371 | + tcg_temp_free_i32(zero); | ||
372 | + tcg_temp_free_i32(max); | ||
373 | +} | ||
374 | + | ||
375 | +void gen_sshl_i64(TCGv_i64 dst, TCGv_i64 src, TCGv_i64 shift) | ||
376 | +{ | ||
377 | + TCGv_i64 lval = tcg_temp_new_i64(); | ||
378 | + TCGv_i64 rval = tcg_temp_new_i64(); | ||
379 | + TCGv_i64 lsh = tcg_temp_new_i64(); | ||
380 | + TCGv_i64 rsh = tcg_temp_new_i64(); | ||
381 | + TCGv_i64 zero = tcg_const_i64(0); | ||
382 | + TCGv_i64 max = tcg_const_i64(63); | ||
383 | + | ||
384 | + /* | ||
385 | + * Rely on the TCG guarantee that out of range shifts produce | ||
386 | + * unspecified results, not undefined behaviour (i.e. no trap). | ||
387 | + * Discard out-of-range results after the fact. | ||
388 | + */ | ||
389 | + tcg_gen_ext8s_i64(lsh, shift); | ||
390 | + tcg_gen_neg_i64(rsh, lsh); | ||
391 | + tcg_gen_shl_i64(lval, src, lsh); | ||
392 | + tcg_gen_umin_i64(rsh, rsh, max); | ||
393 | + tcg_gen_sar_i64(rval, src, rsh); | ||
394 | + tcg_gen_movcond_i64(TCG_COND_LEU, lval, lsh, max, lval, zero); | ||
395 | + tcg_gen_movcond_i64(TCG_COND_LT, dst, lsh, zero, rval, lval); | ||
396 | + | ||
397 | + tcg_temp_free_i64(lval); | ||
398 | + tcg_temp_free_i64(rval); | ||
399 | + tcg_temp_free_i64(lsh); | ||
400 | + tcg_temp_free_i64(rsh); | ||
401 | + tcg_temp_free_i64(zero); | ||
402 | + tcg_temp_free_i64(max); | ||
403 | +} | ||
404 | + | ||
405 | +static void gen_sshl_vec(unsigned vece, TCGv_vec dst, | ||
406 | + TCGv_vec src, TCGv_vec shift) | ||
407 | +{ | ||
408 | + TCGv_vec lval = tcg_temp_new_vec_matching(dst); | ||
409 | + TCGv_vec rval = tcg_temp_new_vec_matching(dst); | ||
410 | + TCGv_vec lsh = tcg_temp_new_vec_matching(dst); | ||
411 | + TCGv_vec rsh = tcg_temp_new_vec_matching(dst); | ||
412 | + TCGv_vec tmp = tcg_temp_new_vec_matching(dst); | ||
413 | + | ||
414 | + /* | ||
415 | + * Rely on the TCG guarantee that out of range shifts produce | ||
416 | + * unspecified results, not undefined behaviour (i.e. no trap). | ||
417 | + * Discard out-of-range results after the fact. | ||
418 | + */ | ||
419 | + tcg_gen_neg_vec(vece, rsh, shift); | ||
420 | + if (vece == MO_8) { | ||
421 | + tcg_gen_mov_vec(lsh, shift); | ||
422 | + } else { | ||
423 | + tcg_gen_dupi_vec(vece, tmp, 0xff); | ||
424 | + tcg_gen_and_vec(vece, lsh, shift, tmp); | ||
425 | + tcg_gen_and_vec(vece, rsh, rsh, tmp); | ||
426 | + } | ||
427 | + | ||
428 | + /* Bound rsh so out of bound right shift gets -1. */ | ||
429 | + tcg_gen_dupi_vec(vece, tmp, (8 << vece) - 1); | ||
430 | + tcg_gen_umin_vec(vece, rsh, rsh, tmp); | ||
431 | + tcg_gen_cmp_vec(TCG_COND_GT, vece, tmp, lsh, tmp); | ||
432 | + | ||
433 | + tcg_gen_shlv_vec(vece, lval, src, lsh); | ||
434 | + tcg_gen_sarv_vec(vece, rval, src, rsh); | ||
435 | + | ||
436 | + /* Select in-bound left shift. */ | ||
437 | + tcg_gen_andc_vec(vece, lval, lval, tmp); | ||
438 | + | ||
439 | + /* Select between left and right shift. */ | ||
440 | + if (vece == MO_8) { | ||
441 | + tcg_gen_dupi_vec(vece, tmp, 0); | ||
442 | + tcg_gen_cmpsel_vec(TCG_COND_LT, vece, dst, lsh, tmp, rval, lval); | ||
443 | + } else { | ||
444 | + tcg_gen_dupi_vec(vece, tmp, 0x80); | ||
445 | + tcg_gen_cmpsel_vec(TCG_COND_LT, vece, dst, lsh, tmp, lval, rval); | ||
446 | + } | ||
447 | + | ||
448 | + tcg_temp_free_vec(lval); | ||
449 | + tcg_temp_free_vec(rval); | ||
450 | + tcg_temp_free_vec(lsh); | ||
451 | + tcg_temp_free_vec(rsh); | ||
452 | + tcg_temp_free_vec(tmp); | ||
453 | +} | ||
454 | + | ||
455 | +static const TCGOpcode sshl_list[] = { | ||
456 | + INDEX_op_neg_vec, INDEX_op_umin_vec, INDEX_op_shlv_vec, | ||
457 | + INDEX_op_sarv_vec, INDEX_op_cmp_vec, INDEX_op_cmpsel_vec, 0 | ||
224 | +}; | 458 | +}; |
225 | + | 459 | + |
226 | +static void musca_machine_init(void) | 460 | +const GVecGen3 sshl_op[4] = { |
227 | +{ | 461 | + { .fniv = gen_sshl_vec, |
228 | + type_register_static(&musca_info); | 462 | + .fno = gen_helper_gvec_sshl_b, |
229 | + type_register_static(&musca_a_info); | 463 | + .opt_opc = sshl_list, |
230 | + type_register_static(&musca_b1_info); | 464 | + .vece = MO_8 }, |
231 | +} | 465 | + { .fniv = gen_sshl_vec, |
232 | + | 466 | + .fno = gen_helper_gvec_sshl_h, |
233 | +type_init(musca_machine_init); | 467 | + .opt_opc = sshl_list, |
234 | diff --git a/MAINTAINERS b/MAINTAINERS | 468 | + .vece = MO_16 }, |
469 | + { .fni4 = gen_sshl_i32, | ||
470 | + .fniv = gen_sshl_vec, | ||
471 | + .opt_opc = sshl_list, | ||
472 | + .vece = MO_32 }, | ||
473 | + { .fni8 = gen_sshl_i64, | ||
474 | + .fniv = gen_sshl_vec, | ||
475 | + .opt_opc = sshl_list, | ||
476 | + .vece = MO_64 }, | ||
477 | +}; | ||
478 | + | ||
479 | static void gen_uqadd_vec(unsigned vece, TCGv_vec t, TCGv_vec sat, | ||
480 | TCGv_vec a, TCGv_vec b) | ||
481 | { | ||
482 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
483 | vec_size, vec_size); | ||
484 | } | ||
485 | return 0; | ||
486 | + | ||
487 | + case NEON_3R_VSHL: | ||
488 | + /* Note the operation is vshl vd,vm,vn */ | ||
489 | + tcg_gen_gvec_3(rd_ofs, rm_ofs, rn_ofs, vec_size, vec_size, | ||
490 | + u ? &ushl_op[size] : &sshl_op[size]); | ||
491 | + return 0; | ||
492 | } | ||
493 | |||
494 | if (size == 3) { | ||
495 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
496 | neon_load_reg64(cpu_V0, rn + pass); | ||
497 | neon_load_reg64(cpu_V1, rm + pass); | ||
498 | switch (op) { | ||
499 | - case NEON_3R_VSHL: | ||
500 | - if (u) { | ||
501 | - gen_helper_neon_shl_u64(cpu_V0, cpu_V1, cpu_V0); | ||
502 | - } else { | ||
503 | - gen_helper_neon_shl_s64(cpu_V0, cpu_V1, cpu_V0); | ||
504 | - } | ||
505 | - break; | ||
506 | case NEON_3R_VQSHL: | ||
507 | if (u) { | ||
508 | gen_helper_neon_qshl_u64(cpu_V0, cpu_env, | ||
509 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
510 | } | ||
511 | pairwise = 0; | ||
512 | switch (op) { | ||
513 | - case NEON_3R_VSHL: | ||
514 | case NEON_3R_VQSHL: | ||
515 | case NEON_3R_VRSHL: | ||
516 | case NEON_3R_VQRSHL: | ||
517 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
518 | case NEON_3R_VHSUB: | ||
519 | GEN_NEON_INTEGER_OP(hsub); | ||
520 | break; | ||
521 | - case NEON_3R_VSHL: | ||
522 | - GEN_NEON_INTEGER_OP(shl); | ||
523 | - break; | ||
524 | case NEON_3R_VQSHL: | ||
525 | GEN_NEON_INTEGER_OP_ENV(qshl); | ||
526 | break; | ||
527 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
528 | } | ||
529 | } else { | ||
530 | if (input_unsigned) { | ||
531 | - gen_helper_neon_shl_u64(cpu_V0, in, tmp64); | ||
532 | + gen_ushl_i64(cpu_V0, in, tmp64); | ||
533 | } else { | ||
534 | - gen_helper_neon_shl_s64(cpu_V0, in, tmp64); | ||
535 | + gen_sshl_i64(cpu_V0, in, tmp64); | ||
536 | } | ||
537 | } | ||
538 | tmp = tcg_temp_new_i32(); | ||
539 | diff --git a/target/arm/vec_helper.c b/target/arm/vec_helper.c | ||
235 | index XXXXXXX..XXXXXXX 100644 | 540 | index XXXXXXX..XXXXXXX 100644 |
236 | --- a/MAINTAINERS | 541 | --- a/target/arm/vec_helper.c |
237 | +++ b/MAINTAINERS | 542 | +++ b/target/arm/vec_helper.c |
238 | @@ -XXX,XX +XXX,XX @@ F: include/hw/misc/iotkit-sysinfo.h | 543 | @@ -XXX,XX +XXX,XX @@ void HELPER(gvec_fmlal_idx_a64)(void *vd, void *vn, void *vm, |
239 | F: hw/misc/armsse-cpuid.c | 544 | do_fmlal_idx(vd, vn, vm, &env->vfp.fp_status, desc, |
240 | F: include/hw/misc/armsse-cpuid.h | 545 | get_flush_inputs_to_zero(&env->vfp.fp_status_f16)); |
241 | 546 | } | |
242 | +Musca | 547 | + |
243 | +M: Peter Maydell <peter.maydell@linaro.org> | 548 | +void HELPER(gvec_sshl_b)(void *vd, void *vn, void *vm, uint32_t desc) |
244 | +L: qemu-arm@nongnu.org | 549 | +{ |
245 | +S: Maintained | 550 | + intptr_t i, opr_sz = simd_oprsz(desc); |
246 | +F: hw/arm/musca.c | 551 | + int8_t *d = vd, *n = vn, *m = vm; |
247 | + | 552 | + |
248 | Musicpal | 553 | + for (i = 0; i < opr_sz; ++i) { |
249 | M: Jan Kiszka <jan.kiszka@web.de> | 554 | + int8_t mm = m[i]; |
250 | M: Peter Maydell <peter.maydell@linaro.org> | 555 | + int8_t nn = n[i]; |
251 | diff --git a/default-configs/arm-softmmu.mak b/default-configs/arm-softmmu.mak | 556 | + int8_t res = 0; |
252 | index XXXXXXX..XXXXXXX 100644 | 557 | + if (mm >= 0) { |
253 | --- a/default-configs/arm-softmmu.mak | 558 | + if (mm < 8) { |
254 | +++ b/default-configs/arm-softmmu.mak | 559 | + res = nn << mm; |
255 | @@ -XXX,XX +XXX,XX @@ CONFIG_TUSB6010=y | 560 | + } |
256 | CONFIG_IMX=y | 561 | + } else { |
257 | CONFIG_MAINSTONE=y | 562 | + res = nn >> (mm > -8 ? -mm : 7); |
258 | CONFIG_MPS2=y | 563 | + } |
259 | +CONFIG_MUSCA=y | 564 | + d[i] = res; |
260 | CONFIG_NSERIES=y | 565 | + } |
261 | CONFIG_RASPI=y | 566 | + clear_tail(d, opr_sz, simd_maxsz(desc)); |
262 | CONFIG_REALVIEW=y | 567 | +} |
568 | + | ||
569 | +void HELPER(gvec_sshl_h)(void *vd, void *vn, void *vm, uint32_t desc) | ||
570 | +{ | ||
571 | + intptr_t i, opr_sz = simd_oprsz(desc); | ||
572 | + int16_t *d = vd, *n = vn, *m = vm; | ||
573 | + | ||
574 | + for (i = 0; i < opr_sz / 2; ++i) { | ||
575 | + int8_t mm = m[i]; /* only 8 bits of shift are significant */ | ||
576 | + int16_t nn = n[i]; | ||
577 | + int16_t res = 0; | ||
578 | + if (mm >= 0) { | ||
579 | + if (mm < 16) { | ||
580 | + res = nn << mm; | ||
581 | + } | ||
582 | + } else { | ||
583 | + res = nn >> (mm > -16 ? -mm : 15); | ||
584 | + } | ||
585 | + d[i] = res; | ||
586 | + } | ||
587 | + clear_tail(d, opr_sz, simd_maxsz(desc)); | ||
588 | +} | ||
589 | + | ||
590 | +void HELPER(gvec_ushl_b)(void *vd, void *vn, void *vm, uint32_t desc) | ||
591 | +{ | ||
592 | + intptr_t i, opr_sz = simd_oprsz(desc); | ||
593 | + uint8_t *d = vd, *n = vn, *m = vm; | ||
594 | + | ||
595 | + for (i = 0; i < opr_sz; ++i) { | ||
596 | + int8_t mm = m[i]; | ||
597 | + uint8_t nn = n[i]; | ||
598 | + uint8_t res = 0; | ||
599 | + if (mm >= 0) { | ||
600 | + if (mm < 8) { | ||
601 | + res = nn << mm; | ||
602 | + } | ||
603 | + } else { | ||
604 | + if (mm > -8) { | ||
605 | + res = nn >> -mm; | ||
606 | + } | ||
607 | + } | ||
608 | + d[i] = res; | ||
609 | + } | ||
610 | + clear_tail(d, opr_sz, simd_maxsz(desc)); | ||
611 | +} | ||
612 | + | ||
613 | +void HELPER(gvec_ushl_h)(void *vd, void *vn, void *vm, uint32_t desc) | ||
614 | +{ | ||
615 | + intptr_t i, opr_sz = simd_oprsz(desc); | ||
616 | + uint16_t *d = vd, *n = vn, *m = vm; | ||
617 | + | ||
618 | + for (i = 0; i < opr_sz / 2; ++i) { | ||
619 | + int8_t mm = m[i]; /* only 8 bits of shift are significant */ | ||
620 | + uint16_t nn = n[i]; | ||
621 | + uint16_t res = 0; | ||
622 | + if (mm >= 0) { | ||
623 | + if (mm < 16) { | ||
624 | + res = nn << mm; | ||
625 | + } | ||
626 | + } else { | ||
627 | + if (mm > -16) { | ||
628 | + res = nn >> -mm; | ||
629 | + } | ||
630 | + } | ||
631 | + d[i] = res; | ||
632 | + } | ||
633 | + clear_tail(d, opr_sz, simd_maxsz(desc)); | ||
634 | +} | ||
263 | -- | 635 | -- |
264 | 2.20.1 | 636 | 2.20.1 |
265 | 637 | ||
266 | 638 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
1 | 2 | ||
3 | The gvec form will be needed for implementing SVE2. | ||
4 | |||
5 | Extend the implementation to operate on uint64_t instead of uint32_t. | ||
6 | Use a counted inner loop instead of terminating when op1 goes to zero, | ||
7 | looking toward the required implementation for ARMv8.4-DIT. | ||
8 | |||
9 | Tested-by: Alex Bennée <alex.bennee@linaro.org> | ||
10 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
11 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
12 | Message-id: 20200216214232.4230-3-richard.henderson@linaro.org | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
14 | --- | ||
15 | target/arm/helper.h | 3 ++- | ||
16 | target/arm/neon_helper.c | 22 ---------------------- | ||
17 | target/arm/translate-a64.c | 10 +++------- | ||
18 | target/arm/translate.c | 11 ++++------- | ||
19 | target/arm/vec_helper.c | 30 ++++++++++++++++++++++++++++++ | ||
20 | 5 files changed, 39 insertions(+), 37 deletions(-) | ||
21 | |||
22 | diff --git a/target/arm/helper.h b/target/arm/helper.h | ||
23 | index XXXXXXX..XXXXXXX 100644 | ||
24 | --- a/target/arm/helper.h | ||
25 | +++ b/target/arm/helper.h | ||
26 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_2(neon_sub_u8, i32, i32, i32) | ||
27 | DEF_HELPER_2(neon_sub_u16, i32, i32, i32) | ||
28 | DEF_HELPER_2(neon_mul_u8, i32, i32, i32) | ||
29 | DEF_HELPER_2(neon_mul_u16, i32, i32, i32) | ||
30 | -DEF_HELPER_2(neon_mul_p8, i32, i32, i32) | ||
31 | DEF_HELPER_2(neon_mull_p8, i64, i32, i32) | ||
32 | |||
33 | DEF_HELPER_2(neon_tst_u8, i32, i32, i32) | ||
34 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(gvec_sshl_h, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | ||
35 | DEF_HELPER_FLAGS_4(gvec_ushl_b, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | ||
36 | DEF_HELPER_FLAGS_4(gvec_ushl_h, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | ||
37 | |||
38 | +DEF_HELPER_FLAGS_4(gvec_pmul_b, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | ||
39 | + | ||
40 | #ifdef TARGET_AARCH64 | ||
41 | #include "helper-a64.h" | ||
42 | #include "helper-sve.h" | ||
43 | diff --git a/target/arm/neon_helper.c b/target/arm/neon_helper.c | ||
44 | index XXXXXXX..XXXXXXX 100644 | ||
45 | --- a/target/arm/neon_helper.c | ||
46 | +++ b/target/arm/neon_helper.c | ||
47 | @@ -XXX,XX +XXX,XX @@ NEON_VOP(mul_u16, neon_u16, 2) | ||
48 | |||
49 | /* Polynomial multiplication is like integer multiplication except the | ||
50 | partial products are XORed, not added. */ | ||
51 | -uint32_t HELPER(neon_mul_p8)(uint32_t op1, uint32_t op2) | ||
52 | -{ | ||
53 | - uint32_t mask; | ||
54 | - uint32_t result; | ||
55 | - result = 0; | ||
56 | - while (op1) { | ||
57 | - mask = 0; | ||
58 | - if (op1 & 1) | ||
59 | - mask |= 0xff; | ||
60 | - if (op1 & (1 << 8)) | ||
61 | - mask |= (0xff << 8); | ||
62 | - if (op1 & (1 << 16)) | ||
63 | - mask |= (0xff << 16); | ||
64 | - if (op1 & (1 << 24)) | ||
65 | - mask |= (0xff << 24); | ||
66 | - result ^= op2 & mask; | ||
67 | - op1 = (op1 >> 1) & 0x7f7f7f7f; | ||
68 | - op2 = (op2 << 1) & 0xfefefefe; | ||
69 | - } | ||
70 | - return result; | ||
71 | -} | ||
72 | - | ||
73 | uint64_t HELPER(neon_mull_p8)(uint32_t op1, uint32_t op2) | ||
74 | { | ||
75 | uint64_t result = 0; | ||
76 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
77 | index XXXXXXX..XXXXXXX 100644 | ||
78 | --- a/target/arm/translate-a64.c | ||
79 | +++ b/target/arm/translate-a64.c | ||
80 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_3same_int(DisasContext *s, uint32_t insn) | ||
81 | case 0x13: /* MUL, PMUL */ | ||
82 | if (!u) { /* MUL */ | ||
83 | gen_gvec_fn3(s, is_q, rd, rn, rm, tcg_gen_gvec_mul, size); | ||
84 | - return; | ||
85 | + } else { /* PMUL */ | ||
86 | + gen_gvec_op3_ool(s, is_q, rd, rn, rm, 0, gen_helper_gvec_pmul_b); | ||
87 | } | ||
88 | - break; | ||
89 | + return; | ||
90 | case 0x12: /* MLA, MLS */ | ||
91 | if (u) { | ||
92 | gen_gvec_op3(s, is_q, rd, rn, rm, &mls_op[size]); | ||
93 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_3same_int(DisasContext *s, uint32_t insn) | ||
94 | genfn = fns[size][u]; | ||
95 | break; | ||
96 | } | ||
97 | - case 0x13: /* MUL, PMUL */ | ||
98 | - assert(u); /* PMUL */ | ||
99 | - assert(size == 0); | ||
100 | - genfn = gen_helper_neon_mul_p8; | ||
101 | - break; | ||
102 | case 0x16: /* SQDMULH, SQRDMULH */ | ||
103 | { | ||
104 | static NeonGenTwoOpEnvFn * const fns[2][2] = { | ||
105 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
106 | index XXXXXXX..XXXXXXX 100644 | ||
107 | --- a/target/arm/translate.c | ||
108 | +++ b/target/arm/translate.c | ||
109 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
110 | |||
111 | case NEON_3R_VMUL: /* VMUL */ | ||
112 | if (u) { | ||
113 | - /* Polynomial case allows only P8 and is handled below. */ | ||
114 | + /* Polynomial case allows only P8. */ | ||
115 | if (size != 0) { | ||
116 | return 1; | ||
117 | } | ||
118 | + tcg_gen_gvec_3_ool(rd_ofs, rn_ofs, rm_ofs, vec_size, vec_size, | ||
119 | + 0, gen_helper_gvec_pmul_b); | ||
120 | } else { | ||
121 | tcg_gen_gvec_mul(size, rd_ofs, rn_ofs, rm_ofs, | ||
122 | vec_size, vec_size); | ||
123 | - return 0; | ||
124 | } | ||
125 | - break; | ||
126 | + return 0; | ||
127 | |||
128 | case NEON_3R_VML: /* VMLA, VMLS */ | ||
129 | tcg_gen_gvec_3(rd_ofs, rn_ofs, rm_ofs, vec_size, vec_size, | ||
130 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
131 | tmp2 = neon_load_reg(rd, pass); | ||
132 | gen_neon_add(size, tmp, tmp2); | ||
133 | break; | ||
134 | - case NEON_3R_VMUL: | ||
135 | - /* VMUL.P8; other cases already eliminated. */ | ||
136 | - gen_helper_neon_mul_p8(tmp, tmp, tmp2); | ||
137 | - break; | ||
138 | case NEON_3R_VPMAX: | ||
139 | GEN_NEON_INTEGER_OP(pmax); | ||
140 | break; | ||
141 | diff --git a/target/arm/vec_helper.c b/target/arm/vec_helper.c | ||
142 | index XXXXXXX..XXXXXXX 100644 | ||
143 | --- a/target/arm/vec_helper.c | ||
144 | +++ b/target/arm/vec_helper.c | ||
145 | @@ -XXX,XX +XXX,XX @@ void HELPER(gvec_ushl_h)(void *vd, void *vn, void *vm, uint32_t desc) | ||
146 | } | ||
147 | clear_tail(d, opr_sz, simd_maxsz(desc)); | ||
148 | } | ||
149 | + | ||
150 | +/* | ||
151 | + * 8x8->8 polynomial multiply. | ||
152 | + * | ||
153 | + * Polynomial multiplication is like integer multiplication except the | ||
154 | + * partial products are XORed, not added. | ||
155 | + * | ||
156 | + * TODO: expose this as a generic vector operation, as it is a common | ||
157 | + * crypto building block. | ||
158 | + */ | ||
159 | +void HELPER(gvec_pmul_b)(void *vd, void *vn, void *vm, uint32_t desc) | ||
160 | +{ | ||
161 | + intptr_t i, j, opr_sz = simd_oprsz(desc); | ||
162 | + uint64_t *d = vd, *n = vn, *m = vm; | ||
163 | + | ||
164 | + for (i = 0; i < opr_sz / 8; ++i) { | ||
165 | + uint64_t nn = n[i]; | ||
166 | + uint64_t mm = m[i]; | ||
167 | + uint64_t rr = 0; | ||
168 | + | ||
169 | + for (j = 0; j < 8; ++j) { | ||
170 | + uint64_t mask = (nn & 0x0101010101010101ull) * 0xff; | ||
171 | + rr ^= mm & mask; | ||
172 | + mm = (mm << 1) & 0xfefefefefefefefeull; | ||
173 | + nn >>= 1; | ||
174 | + } | ||
175 | + d[i] = rr; | ||
176 | + } | ||
177 | + clear_tail(d, opr_sz, simd_maxsz(desc)); | ||
178 | +} | ||
179 | -- | ||
180 | 2.20.1 | ||
181 | |||
182 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | The gvec form will be needed for implementing SVE2. | ||
4 | |||
5 | Tested-by: Alex Bennée <alex.bennee@linaro.org> | ||
6 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
3 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
4 | Message-id: 20190215192302.27855-5-richard.henderson@linaro.org | 8 | Message-id: 20200216214232.4230-4-richard.henderson@linaro.org |
5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | [PMM: fixed a couple of comment typos] | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | --- | 10 | --- |
9 | target/arm/cpu.h | 10 +++++ | 11 | target/arm/helper.h | 4 +--- |
10 | target/arm/helper.h | 3 ++ | 12 | target/arm/neon_helper.c | 30 ------------------------------ |
11 | target/arm/cpu.c | 1 + | 13 | target/arm/translate-a64.c | 28 +++------------------------- |
12 | target/arm/cpu64.c | 2 + | 14 | target/arm/translate.c | 16 ++-------------- |
13 | target/arm/translate-a64.c | 26 +++++++++++ | 15 | target/arm/vec_helper.c | 33 +++++++++++++++++++++++++++++++++ |
14 | target/arm/translate.c | 10 +++++ | 16 | 5 files changed, 39 insertions(+), 72 deletions(-) |
15 | target/arm/vfp_helper.c | 88 ++++++++++++++++++++++++++++++++++++++ | ||
16 | 7 files changed, 140 insertions(+) | ||
17 | 17 | ||
18 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
19 | index XXXXXXX..XXXXXXX 100644 | ||
20 | --- a/target/arm/cpu.h | ||
21 | +++ b/target/arm/cpu.h | ||
22 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa32_vcma(const ARMISARegisters *id) | ||
23 | return FIELD_EX32(id->id_isar5, ID_ISAR5, VCMA) != 0; | ||
24 | } | ||
25 | |||
26 | +static inline bool isar_feature_aa32_jscvt(const ARMISARegisters *id) | ||
27 | +{ | ||
28 | + return FIELD_EX32(id->id_isar6, ID_ISAR6, JSCVT) != 0; | ||
29 | +} | ||
30 | + | ||
31 | static inline bool isar_feature_aa32_dp(const ARMISARegisters *id) | ||
32 | { | ||
33 | return FIELD_EX32(id->id_isar6, ID_ISAR6, DP) != 0; | ||
34 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa64_dp(const ARMISARegisters *id) | ||
35 | return FIELD_EX64(id->id_aa64isar0, ID_AA64ISAR0, DP) != 0; | ||
36 | } | ||
37 | |||
38 | +static inline bool isar_feature_aa64_jscvt(const ARMISARegisters *id) | ||
39 | +{ | ||
40 | + return FIELD_EX64(id->id_aa64isar1, ID_AA64ISAR1, JSCVT) != 0; | ||
41 | +} | ||
42 | + | ||
43 | static inline bool isar_feature_aa64_fcma(const ARMISARegisters *id) | ||
44 | { | ||
45 | return FIELD_EX64(id->id_aa64isar1, ID_AA64ISAR1, FCMA) != 0; | ||
46 | diff --git a/target/arm/helper.h b/target/arm/helper.h | 18 | diff --git a/target/arm/helper.h b/target/arm/helper.h |
47 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
48 | --- a/target/arm/helper.h | 20 | --- a/target/arm/helper.h |
49 | +++ b/target/arm/helper.h | 21 | +++ b/target/arm/helper.h |
50 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_2(rintd_exact, TCG_CALL_NO_RWG, f64, f64, ptr) | 22 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(crc32, TCG_CALL_NO_RWG_SE, i32, i32, i32, i32) |
51 | DEF_HELPER_FLAGS_2(rints, TCG_CALL_NO_RWG, f32, f32, ptr) | 23 | DEF_HELPER_FLAGS_3(crc32c, TCG_CALL_NO_RWG_SE, i32, i32, i32, i32) |
52 | DEF_HELPER_FLAGS_2(rintd, TCG_CALL_NO_RWG, f64, f64, ptr) | 24 | DEF_HELPER_2(dc_zva, void, env, i64) |
53 | 25 | ||
54 | +DEF_HELPER_FLAGS_2(vjcvt, TCG_CALL_NO_RWG, i32, f64, env) | 26 | -DEF_HELPER_FLAGS_2(neon_pmull_64_lo, TCG_CALL_NO_RWG_SE, i64, i64, i64) |
55 | +DEF_HELPER_FLAGS_2(fjcvtzs, TCG_CALL_NO_RWG, i64, f64, ptr) | 27 | -DEF_HELPER_FLAGS_2(neon_pmull_64_hi, TCG_CALL_NO_RWG_SE, i64, i64, i64) |
56 | + | 28 | - |
57 | /* neon_helper.c */ | 29 | DEF_HELPER_FLAGS_5(gvec_qrdmlah_s16, TCG_CALL_NO_RWG, |
58 | DEF_HELPER_FLAGS_3(neon_qadd_u8, TCG_CALL_NO_RWG, i32, env, i32, i32) | 30 | void, ptr, ptr, ptr, ptr, i32) |
59 | DEF_HELPER_FLAGS_3(neon_qadd_s8, TCG_CALL_NO_RWG, i32, env, i32, i32) | 31 | DEF_HELPER_FLAGS_5(gvec_qrdmlsh_s16, TCG_CALL_NO_RWG, |
60 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | 32 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(gvec_ushl_b, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) |
33 | DEF_HELPER_FLAGS_4(gvec_ushl_h, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | ||
34 | |||
35 | DEF_HELPER_FLAGS_4(gvec_pmul_b, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | ||
36 | +DEF_HELPER_FLAGS_4(gvec_pmull_q, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | ||
37 | |||
38 | #ifdef TARGET_AARCH64 | ||
39 | #include "helper-a64.h" | ||
40 | diff --git a/target/arm/neon_helper.c b/target/arm/neon_helper.c | ||
61 | index XXXXXXX..XXXXXXX 100644 | 41 | index XXXXXXX..XXXXXXX 100644 |
62 | --- a/target/arm/cpu.c | 42 | --- a/target/arm/neon_helper.c |
63 | +++ b/target/arm/cpu.c | 43 | +++ b/target/arm/neon_helper.c |
64 | @@ -XXX,XX +XXX,XX @@ static void arm_max_initfn(Object *obj) | 44 | @@ -XXX,XX +XXX,XX @@ void HELPER(neon_zip16)(void *vd, void *vm) |
65 | cpu->isar.id_isar5 = t; | 45 | rm[0] = m0; |
66 | 46 | rd[0] = d0; | |
67 | t = cpu->isar.id_isar6; | 47 | } |
68 | + t = FIELD_DP32(t, ID_ISAR6, JSCVT, 1); | 48 | - |
69 | t = FIELD_DP32(t, ID_ISAR6, DP, 1); | 49 | -/* Helper function for 64 bit polynomial multiply case: |
70 | cpu->isar.id_isar6 = t; | 50 | - * perform PolynomialMult(op1, op2) and return either the top or |
71 | 51 | - * bottom half of the 128 bit result. | |
72 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | 52 | - */ |
73 | index XXXXXXX..XXXXXXX 100644 | 53 | -uint64_t HELPER(neon_pmull_64_lo)(uint64_t op1, uint64_t op2) |
74 | --- a/target/arm/cpu64.c | 54 | -{ |
75 | +++ b/target/arm/cpu64.c | 55 | - int bitnum; |
76 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) | 56 | - uint64_t res = 0; |
77 | cpu->isar.id_aa64isar0 = t; | 57 | - |
78 | 58 | - for (bitnum = 0; bitnum < 64; bitnum++) { | |
79 | t = cpu->isar.id_aa64isar1; | 59 | - if (op1 & (1ULL << bitnum)) { |
80 | + t = FIELD_DP64(t, ID_AA64ISAR1, JSCVT, 1); | 60 | - res ^= op2 << bitnum; |
81 | t = FIELD_DP64(t, ID_AA64ISAR1, FCMA, 1); | 61 | - } |
82 | t = FIELD_DP64(t, ID_AA64ISAR1, APA, 1); /* PAuth, architected only */ | 62 | - } |
83 | t = FIELD_DP64(t, ID_AA64ISAR1, API, 0); | 63 | - return res; |
84 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) | 64 | -} |
85 | cpu->isar.id_isar5 = u; | 65 | -uint64_t HELPER(neon_pmull_64_hi)(uint64_t op1, uint64_t op2) |
86 | 66 | -{ | |
87 | u = cpu->isar.id_isar6; | 67 | - int bitnum; |
88 | + u = FIELD_DP32(u, ID_ISAR6, JSCVT, 1); | 68 | - uint64_t res = 0; |
89 | u = FIELD_DP32(u, ID_ISAR6, DP, 1); | 69 | - |
90 | cpu->isar.id_isar6 = u; | 70 | - /* bit 0 of op1 can't influence the high 64 bits at all */ |
91 | 71 | - for (bitnum = 1; bitnum < 64; bitnum++) { | |
72 | - if (op1 & (1ULL << bitnum)) { | ||
73 | - res ^= op2 >> (64 - bitnum); | ||
74 | - } | ||
75 | - } | ||
76 | - return res; | ||
77 | -} | ||
92 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 78 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c |
93 | index XXXXXXX..XXXXXXX 100644 | 79 | index XXXXXXX..XXXXXXX 100644 |
94 | --- a/target/arm/translate-a64.c | 80 | --- a/target/arm/translate-a64.c |
95 | +++ b/target/arm/translate-a64.c | 81 | +++ b/target/arm/translate-a64.c |
96 | @@ -XXX,XX +XXX,XX @@ static void handle_fmov(DisasContext *s, int rd, int rn, int type, bool itof) | 82 | @@ -XXX,XX +XXX,XX @@ static void handle_3rd_narrowing(DisasContext *s, int is_q, int is_u, int size, |
97 | } | 83 | clear_vec_high(s, is_q, rd); |
98 | } | 84 | } |
99 | 85 | ||
100 | +static void handle_fjcvtzs(DisasContext *s, int rd, int rn) | 86 | -static void handle_pmull_64(DisasContext *s, int is_q, int rd, int rn, int rm) |
101 | +{ | 87 | -{ |
102 | + TCGv_i64 t = read_fp_dreg(s, rn); | 88 | - /* PMULL of 64 x 64 -> 128 is an odd special case because it |
103 | + TCGv_ptr fpstatus = get_fpstatus_ptr(false); | 89 | - * is the only three-reg-diff instruction which produces a |
104 | + | 90 | - * 128-bit wide result from a single operation. However since |
105 | + gen_helper_fjcvtzs(t, t, fpstatus); | 91 | - * it's possible to calculate the two halves more or less |
106 | + | 92 | - * separately we just use two helper calls. |
107 | + tcg_temp_free_ptr(fpstatus); | 93 | - */ |
108 | + | 94 | - TCGv_i64 tcg_op1 = tcg_temp_new_i64(); |
109 | + tcg_gen_ext32u_i64(cpu_reg(s, rd), t); | 95 | - TCGv_i64 tcg_op2 = tcg_temp_new_i64(); |
110 | + tcg_gen_extrh_i64_i32(cpu_ZF, t); | 96 | - TCGv_i64 tcg_res = tcg_temp_new_i64(); |
111 | + tcg_gen_movi_i32(cpu_CF, 0); | 97 | - |
112 | + tcg_gen_movi_i32(cpu_NF, 0); | 98 | - read_vec_element(s, tcg_op1, rn, is_q, MO_64); |
113 | + tcg_gen_movi_i32(cpu_VF, 0); | 99 | - read_vec_element(s, tcg_op2, rm, is_q, MO_64); |
114 | + | 100 | - gen_helper_neon_pmull_64_lo(tcg_res, tcg_op1, tcg_op2); |
115 | + tcg_temp_free_i64(t); | 101 | - write_vec_element(s, tcg_res, rd, 0, MO_64); |
116 | +} | 102 | - gen_helper_neon_pmull_64_hi(tcg_res, tcg_op1, tcg_op2); |
117 | + | 103 | - write_vec_element(s, tcg_res, rd, 1, MO_64); |
118 | /* Floating point <-> integer conversions | 104 | - |
119 | * 31 30 29 28 24 23 22 21 20 19 18 16 15 10 9 5 4 0 | 105 | - tcg_temp_free_i64(tcg_op1); |
120 | * +----+---+---+-----------+------+---+-------+-----+-------------+----+----+ | 106 | - tcg_temp_free_i64(tcg_op2); |
121 | @@ -XXX,XX +XXX,XX @@ static void disas_fp_int_conv(DisasContext *s, uint32_t insn) | 107 | - tcg_temp_free_i64(tcg_res); |
122 | handle_fmov(s, rd, rn, type, itof); | 108 | -} |
123 | break; | 109 | - |
124 | 110 | /* AdvSIMD three different | |
125 | + case 0b00111110: /* FJCVTZS */ | 111 | * 31 30 29 28 24 23 22 21 20 16 15 12 11 10 9 5 4 0 |
126 | + if (!dc_isar_feature(aa64_jscvt, s)) { | 112 | * +---+---+---+-----------+------+---+------+--------+-----+------+------+ |
127 | + goto do_unallocated; | 113 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_three_reg_diff(DisasContext *s, uint32_t insn) |
128 | + } else if (fp_access_check(s)) { | 114 | if (!fp_access_check(s)) { |
129 | + handle_fjcvtzs(s, rd, rn); | 115 | return; |
130 | + } | 116 | } |
131 | + break; | 117 | - handle_pmull_64(s, is_q, rd, rn, rm); |
132 | + | 118 | + /* The Q field specifies lo/hi half input for this insn. */ |
133 | default: | 119 | + gen_gvec_op3_ool(s, true, rd, rn, rm, is_q, |
134 | do_unallocated: | 120 | + gen_helper_gvec_pmull_q); |
135 | unallocated_encoding(s); | 121 | return; |
122 | } | ||
123 | goto is_widening; | ||
136 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 124 | diff --git a/target/arm/translate.c b/target/arm/translate.c |
137 | index XXXXXXX..XXXXXXX 100644 | 125 | index XXXXXXX..XXXXXXX 100644 |
138 | --- a/target/arm/translate.c | 126 | --- a/target/arm/translate.c |
139 | +++ b/target/arm/translate.c | 127 | +++ b/target/arm/translate.c |
140 | @@ -XXX,XX +XXX,XX @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) | 128 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) |
141 | rm_is_dp = false; | 129 | * outside the loop below as it only performs a single pass. |
142 | break; | 130 | */ |
143 | 131 | if (op == 14 && size == 2) { | |
144 | + case 0x13: /* vjcvt */ | 132 | - TCGv_i64 tcg_rn, tcg_rm, tcg_rd; |
145 | + if (!dp || !dc_isar_feature(aa32_jscvt, s)) { | 133 | - |
146 | + return 1; | 134 | if (!dc_isar_feature(aa32_pmull, s)) { |
147 | + } | 135 | return 1; |
148 | + rd_is_dp = false; | 136 | } |
149 | + break; | 137 | - tcg_rn = tcg_temp_new_i64(); |
150 | + | 138 | - tcg_rm = tcg_temp_new_i64(); |
151 | default: | 139 | - tcg_rd = tcg_temp_new_i64(); |
152 | return 1; | 140 | - neon_load_reg64(tcg_rn, rn); |
141 | - neon_load_reg64(tcg_rm, rm); | ||
142 | - gen_helper_neon_pmull_64_lo(tcg_rd, tcg_rn, tcg_rm); | ||
143 | - neon_store_reg64(tcg_rd, rd); | ||
144 | - gen_helper_neon_pmull_64_hi(tcg_rd, tcg_rn, tcg_rm); | ||
145 | - neon_store_reg64(tcg_rd, rd + 1); | ||
146 | - tcg_temp_free_i64(tcg_rn); | ||
147 | - tcg_temp_free_i64(tcg_rm); | ||
148 | - tcg_temp_free_i64(tcg_rd); | ||
149 | + tcg_gen_gvec_3_ool(rd_ofs, rn_ofs, rm_ofs, 16, 16, | ||
150 | + 0, gen_helper_gvec_pmull_q); | ||
151 | return 0; | ||
153 | } | 152 | } |
154 | @@ -XXX,XX +XXX,XX @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) | 153 | |
155 | case 17: /* fsito */ | 154 | diff --git a/target/arm/vec_helper.c b/target/arm/vec_helper.c |
156 | gen_vfp_sito(dp, 0); | ||
157 | break; | ||
158 | + case 19: /* vjcvt */ | ||
159 | + gen_helper_vjcvt(cpu_F0s, cpu_F0d, cpu_env); | ||
160 | + break; | ||
161 | case 20: /* fshto */ | ||
162 | gen_vfp_shto(dp, 16 - rm, 0); | ||
163 | break; | ||
164 | diff --git a/target/arm/vfp_helper.c b/target/arm/vfp_helper.c | ||
165 | index XXXXXXX..XXXXXXX 100644 | 155 | index XXXXXXX..XXXXXXX 100644 |
166 | --- a/target/arm/vfp_helper.c | 156 | --- a/target/arm/vec_helper.c |
167 | +++ b/target/arm/vfp_helper.c | 157 | +++ b/target/arm/vec_helper.c |
168 | @@ -XXX,XX +XXX,XX @@ int arm_rmode_to_sf(int rmode) | 158 | @@ -XXX,XX +XXX,XX @@ void HELPER(gvec_pmul_b)(void *vd, void *vn, void *vm, uint32_t desc) |
169 | } | 159 | } |
170 | return rmode; | 160 | clear_tail(d, opr_sz, simd_maxsz(desc)); |
171 | } | 161 | } |
172 | + | 162 | + |
173 | +/* | 163 | +/* |
174 | + * Implement float64 to int32_t conversion without saturation; | 164 | + * 64x64->128 polynomial multiply. |
175 | + * the result is supplied modulo 2^32. | 165 | + * Because of the lanes are not accessed in strict columns, |
166 | + * this probably cannot be turned into a generic helper. | ||
176 | + */ | 167 | + */ |
177 | +uint64_t HELPER(fjcvtzs)(float64 value, void *vstatus) | 168 | +void HELPER(gvec_pmull_q)(void *vd, void *vn, void *vm, uint32_t desc) |
178 | +{ | 169 | +{ |
179 | + float_status *status = vstatus; | 170 | + intptr_t i, j, opr_sz = simd_oprsz(desc); |
180 | + uint32_t exp, sign; | 171 | + intptr_t hi = simd_data(desc); |
181 | + uint64_t frac; | 172 | + uint64_t *d = vd, *n = vn, *m = vm; |
182 | + uint32_t inexact = 1; /* !Z */ | ||
183 | + | 173 | + |
184 | + sign = extract64(value, 63, 1); | 174 | + for (i = 0; i < opr_sz / 8; i += 2) { |
185 | + exp = extract64(value, 52, 11); | 175 | + uint64_t nn = n[i + hi]; |
186 | + frac = extract64(value, 0, 52); | 176 | + uint64_t mm = m[i + hi]; |
177 | + uint64_t rhi = 0; | ||
178 | + uint64_t rlo = 0; | ||
187 | + | 179 | + |
188 | + if (exp == 0) { | 180 | + /* Bit 0 can only influence the low 64-bit result. */ |
189 | + /* While not inexact for IEEE FP, -0.0 is inexact for JavaScript. */ | 181 | + if (nn & 1) { |
190 | + inexact = sign; | 182 | + rlo = mm; |
191 | + if (frac != 0) { | ||
192 | + if (status->flush_inputs_to_zero) { | ||
193 | + float_raise(float_flag_input_denormal, status); | ||
194 | + } else { | ||
195 | + float_raise(float_flag_inexact, status); | ||
196 | + inexact = 1; | ||
197 | + } | ||
198 | + } | ||
199 | + frac = 0; | ||
200 | + } else if (exp == 0x7ff) { | ||
201 | + /* This operation raises Invalid for both NaN and overflow (Inf). */ | ||
202 | + float_raise(float_flag_invalid, status); | ||
203 | + frac = 0; | ||
204 | + } else { | ||
205 | + int true_exp = exp - 1023; | ||
206 | + int shift = true_exp - 52; | ||
207 | + | ||
208 | + /* Restore implicit bit. */ | ||
209 | + frac |= 1ull << 52; | ||
210 | + | ||
211 | + /* Shift the fraction into place. */ | ||
212 | + if (shift >= 0) { | ||
213 | + /* The number is so large we must shift the fraction left. */ | ||
214 | + if (shift >= 64) { | ||
215 | + /* The fraction is shifted out entirely. */ | ||
216 | + frac = 0; | ||
217 | + } else { | ||
218 | + frac <<= shift; | ||
219 | + } | ||
220 | + } else if (shift > -64) { | ||
221 | + /* Normal case -- shift right and notice if bits shift out. */ | ||
222 | + inexact = (frac << (64 + shift)) != 0; | ||
223 | + frac >>= -shift; | ||
224 | + } else { | ||
225 | + /* The fraction is shifted out entirely. */ | ||
226 | + frac = 0; | ||
227 | + } | 183 | + } |
228 | + | 184 | + |
229 | + /* Notice overflow or inexact exceptions. */ | 185 | + for (j = 1; j < 64; ++j) { |
230 | + if (true_exp > 31 || frac > (sign ? 0x80000000ull : 0x7fffffff)) { | 186 | + uint64_t mask = -((nn >> j) & 1); |
231 | + /* Overflow, for which this operation raises invalid. */ | 187 | + rlo ^= (mm << j) & mask; |
232 | + float_raise(float_flag_invalid, status); | 188 | + rhi ^= (mm >> (64 - j)) & mask; |
233 | + inexact = 1; | ||
234 | + } else if (inexact) { | ||
235 | + float_raise(float_flag_inexact, status); | ||
236 | + } | 189 | + } |
237 | + | 190 | + d[i] = rlo; |
238 | + /* Honor the sign. */ | 191 | + d[i + 1] = rhi; |
239 | + if (sign) { | ||
240 | + frac = -frac; | ||
241 | + } | ||
242 | + } | 192 | + } |
243 | + | 193 | + clear_tail(d, opr_sz, simd_maxsz(desc)); |
244 | + /* Pack the result and the env->ZF representation of Z together. */ | ||
245 | + return deposit64(frac, 32, 32, inexact); | ||
246 | +} | ||
247 | + | ||
248 | +uint32_t HELPER(vjcvt)(float64 value, CPUARMState *env) | ||
249 | +{ | ||
250 | + uint64_t pair = HELPER(fjcvtzs)(value, &env->vfp.fp_status); | ||
251 | + uint32_t result = pair; | ||
252 | + uint32_t z = (pair >> 32) == 0; | ||
253 | + | ||
254 | + /* Store Z, clear NCV, in FPSCR.NZCV. */ | ||
255 | + env->vfp.xregs[ARM_VFP_FPSCR] | ||
256 | + = (env->vfp.xregs[ARM_VFP_FPSCR] & ~CPSR_NZCV) | (z * CPSR_Z); | ||
257 | + | ||
258 | + return result; | ||
259 | +} | 194 | +} |
260 | -- | 195 | -- |
261 | 2.20.1 | 196 | 2.20.1 |
262 | 197 | ||
263 | 198 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | There are lots of special cases within these insns. Split the | 3 | We still need two different helpers, since NEON and SVE2 get the |
4 | major argument decode/loading/saving into no_output (compares), | 4 | inputs from different locations within the source vector. However, |
5 | rd_is_dp, and rm_is_dp. | 5 | we can convert both to the same internal form for computation. |
6 | 6 | ||
7 | We still need to special case argument load for compare (rd as | 7 | The sve2 helper is not used yet, but adding it with this patch |
8 | input, rm as zero) and vcvt fixed (rd as input+output), but lots | 8 | helps illustrate why the neon changes are helpful. |
9 | of special cases do disappear. | 9 | |
10 | 10 | Tested-by: Alex Bennée <alex.bennee@linaro.org> | |
11 | Now that we have a full switch at the beginning, hoist the ISA | 11 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> |
12 | checks from the code generation. | ||
13 | |||
14 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 12 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
15 | Message-id: 20190215192302.27855-4-richard.henderson@linaro.org | 13 | Message-id: 20200216214232.4230-5-richard.henderson@linaro.org |
16 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
18 | --- | 15 | --- |
19 | target/arm/translate.c | 227 ++++++++++++++++++++--------------------- | 16 | target/arm/helper-sve.h | 2 ++ |
20 | 1 file changed, 111 insertions(+), 116 deletions(-) | 17 | target/arm/helper.h | 3 +- |
21 | 18 | target/arm/neon_helper.c | 32 -------------------- | |
19 | target/arm/translate-a64.c | 27 +++++++++++------ | ||
20 | target/arm/translate.c | 26 ++++++++--------- | ||
21 | target/arm/vec_helper.c | 60 ++++++++++++++++++++++++++++++++++++++ | ||
22 | 6 files changed, 95 insertions(+), 55 deletions(-) | ||
23 | |||
24 | diff --git a/target/arm/helper-sve.h b/target/arm/helper-sve.h | ||
25 | index XXXXXXX..XXXXXXX 100644 | ||
26 | --- a/target/arm/helper-sve.h | ||
27 | +++ b/target/arm/helper-sve.h | ||
28 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_6(sve_stdd_le_zd, TCG_CALL_NO_WG, | ||
29 | void, env, ptr, ptr, ptr, tl, i32) | ||
30 | DEF_HELPER_FLAGS_6(sve_stdd_be_zd, TCG_CALL_NO_WG, | ||
31 | void, env, ptr, ptr, ptr, tl, i32) | ||
32 | + | ||
33 | +DEF_HELPER_FLAGS_4(sve2_pmull_h, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | ||
34 | diff --git a/target/arm/helper.h b/target/arm/helper.h | ||
35 | index XXXXXXX..XXXXXXX 100644 | ||
36 | --- a/target/arm/helper.h | ||
37 | +++ b/target/arm/helper.h | ||
38 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_2(neon_sub_u8, i32, i32, i32) | ||
39 | DEF_HELPER_2(neon_sub_u16, i32, i32, i32) | ||
40 | DEF_HELPER_2(neon_mul_u8, i32, i32, i32) | ||
41 | DEF_HELPER_2(neon_mul_u16, i32, i32, i32) | ||
42 | -DEF_HELPER_2(neon_mull_p8, i64, i32, i32) | ||
43 | |||
44 | DEF_HELPER_2(neon_tst_u8, i32, i32, i32) | ||
45 | DEF_HELPER_2(neon_tst_u16, i32, i32, i32) | ||
46 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(gvec_ushl_h, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | ||
47 | DEF_HELPER_FLAGS_4(gvec_pmul_b, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | ||
48 | DEF_HELPER_FLAGS_4(gvec_pmull_q, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | ||
49 | |||
50 | +DEF_HELPER_FLAGS_4(neon_pmull_h, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | ||
51 | + | ||
52 | #ifdef TARGET_AARCH64 | ||
53 | #include "helper-a64.h" | ||
54 | #include "helper-sve.h" | ||
55 | diff --git a/target/arm/neon_helper.c b/target/arm/neon_helper.c | ||
56 | index XXXXXXX..XXXXXXX 100644 | ||
57 | --- a/target/arm/neon_helper.c | ||
58 | +++ b/target/arm/neon_helper.c | ||
59 | @@ -XXX,XX +XXX,XX @@ NEON_VOP(mul_u8, neon_u8, 4) | ||
60 | NEON_VOP(mul_u16, neon_u16, 2) | ||
61 | #undef NEON_FN | ||
62 | |||
63 | -/* Polynomial multiplication is like integer multiplication except the | ||
64 | - partial products are XORed, not added. */ | ||
65 | -uint64_t HELPER(neon_mull_p8)(uint32_t op1, uint32_t op2) | ||
66 | -{ | ||
67 | - uint64_t result = 0; | ||
68 | - uint64_t mask; | ||
69 | - uint64_t op2ex = op2; | ||
70 | - op2ex = (op2ex & 0xff) | | ||
71 | - ((op2ex & 0xff00) << 8) | | ||
72 | - ((op2ex & 0xff0000) << 16) | | ||
73 | - ((op2ex & 0xff000000) << 24); | ||
74 | - while (op1) { | ||
75 | - mask = 0; | ||
76 | - if (op1 & 1) { | ||
77 | - mask |= 0xffff; | ||
78 | - } | ||
79 | - if (op1 & (1 << 8)) { | ||
80 | - mask |= (0xffffU << 16); | ||
81 | - } | ||
82 | - if (op1 & (1 << 16)) { | ||
83 | - mask |= (0xffffULL << 32); | ||
84 | - } | ||
85 | - if (op1 & (1 << 24)) { | ||
86 | - mask |= (0xffffULL << 48); | ||
87 | - } | ||
88 | - result ^= op2ex & mask; | ||
89 | - op1 = (op1 >> 1) & 0x7f7f7f7f; | ||
90 | - op2ex <<= 1; | ||
91 | - } | ||
92 | - return result; | ||
93 | -} | ||
94 | - | ||
95 | #define NEON_FN(dest, src1, src2) dest = (src1 & src2) ? -1 : 0 | ||
96 | NEON_VOP(tst_u8, neon_u8, 4) | ||
97 | NEON_VOP(tst_u16, neon_u16, 2) | ||
98 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
99 | index XXXXXXX..XXXXXXX 100644 | ||
100 | --- a/target/arm/translate-a64.c | ||
101 | +++ b/target/arm/translate-a64.c | ||
102 | @@ -XXX,XX +XXX,XX @@ static void handle_3rd_widening(DisasContext *s, int is_q, int is_u, int size, | ||
103 | gen_helper_neon_addl_saturate_s32(tcg_passres, cpu_env, | ||
104 | tcg_passres, tcg_passres); | ||
105 | break; | ||
106 | - case 14: /* PMULL */ | ||
107 | - assert(size == 0); | ||
108 | - gen_helper_neon_mull_p8(tcg_passres, tcg_op1, tcg_op2); | ||
109 | - break; | ||
110 | default: | ||
111 | g_assert_not_reached(); | ||
112 | } | ||
113 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_three_reg_diff(DisasContext *s, uint32_t insn) | ||
114 | handle_3rd_narrowing(s, is_q, is_u, size, opcode, rd, rn, rm); | ||
115 | break; | ||
116 | case 14: /* PMULL, PMULL2 */ | ||
117 | - if (is_u || size == 1 || size == 2) { | ||
118 | + if (is_u) { | ||
119 | unallocated_encoding(s); | ||
120 | return; | ||
121 | } | ||
122 | - if (size == 3) { | ||
123 | + switch (size) { | ||
124 | + case 0: /* PMULL.P8 */ | ||
125 | + if (!fp_access_check(s)) { | ||
126 | + return; | ||
127 | + } | ||
128 | + /* The Q field specifies lo/hi half input for this insn. */ | ||
129 | + gen_gvec_op3_ool(s, true, rd, rn, rm, is_q, | ||
130 | + gen_helper_neon_pmull_h); | ||
131 | + break; | ||
132 | + | ||
133 | + case 3: /* PMULL.P64 */ | ||
134 | if (!dc_isar_feature(aa64_pmull, s)) { | ||
135 | unallocated_encoding(s); | ||
136 | return; | ||
137 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_three_reg_diff(DisasContext *s, uint32_t insn) | ||
138 | /* The Q field specifies lo/hi half input for this insn. */ | ||
139 | gen_gvec_op3_ool(s, true, rd, rn, rm, is_q, | ||
140 | gen_helper_gvec_pmull_q); | ||
141 | - return; | ||
142 | + break; | ||
143 | + | ||
144 | + default: | ||
145 | + unallocated_encoding(s); | ||
146 | + break; | ||
147 | } | ||
148 | - goto is_widening; | ||
149 | + return; | ||
150 | case 9: /* SQDMLAL, SQDMLAL2 */ | ||
151 | case 11: /* SQDMLSL, SQDMLSL2 */ | ||
152 | case 13: /* SQDMULL, SQDMULL2 */ | ||
153 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_three_reg_diff(DisasContext *s, uint32_t insn) | ||
154 | unallocated_encoding(s); | ||
155 | return; | ||
156 | } | ||
157 | - is_widening: | ||
158 | if (!fp_access_check(s)) { | ||
159 | return; | ||
160 | } | ||
22 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 161 | diff --git a/target/arm/translate.c b/target/arm/translate.c |
23 | index XXXXXXX..XXXXXXX 100644 | 162 | index XXXXXXX..XXXXXXX 100644 |
24 | --- a/target/arm/translate.c | 163 | --- a/target/arm/translate.c |
25 | +++ b/target/arm/translate.c | 164 | +++ b/target/arm/translate.c |
26 | @@ -XXX,XX +XXX,XX @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) | 165 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) |
27 | } | ||
28 | } else { | ||
29 | /* data processing */ | ||
30 | + bool rd_is_dp = dp; | ||
31 | + bool rm_is_dp = dp; | ||
32 | + bool no_output = false; | ||
33 | + | ||
34 | /* The opcode is in bits 23, 21, 20 and 6. */ | ||
35 | op = ((insn >> 20) & 8) | ((insn >> 19) & 6) | ((insn >> 6) & 1); | ||
36 | - if (dp) { | ||
37 | - if (op == 15) { | ||
38 | - /* rn is opcode */ | ||
39 | - rn = ((insn >> 15) & 0x1e) | ((insn >> 7) & 1); | ||
40 | - } else { | ||
41 | - /* rn is register number */ | ||
42 | - VFP_DREG_N(rn, insn); | ||
43 | - } | ||
44 | + rn = VFP_SREG_N(insn); | ||
45 | |||
46 | - if (op == 15 && (rn == 15 || ((rn & 0x1c) == 0x18) || | ||
47 | - ((rn & 0x1e) == 0x6))) { | ||
48 | - /* Integer or single/half precision destination. */ | ||
49 | - rd = VFP_SREG_D(insn); | ||
50 | - } else { | ||
51 | - VFP_DREG_D(rd, insn); | ||
52 | - } | ||
53 | - if (op == 15 && | ||
54 | - (((rn & 0x1c) == 0x10) || ((rn & 0x14) == 0x14) || | ||
55 | - ((rn & 0x1e) == 0x4))) { | ||
56 | - /* VCVT from int or half precision is always from S reg | ||
57 | - * regardless of dp bit. VCVT with immediate frac_bits | ||
58 | - * has same format as SREG_M. | ||
59 | + if (op == 15) { | ||
60 | + /* rn is opcode, encoded as per VFP_SREG_N. */ | ||
61 | + switch (rn) { | ||
62 | + case 0x00: /* vmov */ | ||
63 | + case 0x01: /* vabs */ | ||
64 | + case 0x02: /* vneg */ | ||
65 | + case 0x03: /* vsqrt */ | ||
66 | + break; | ||
67 | + | ||
68 | + case 0x04: /* vcvtb.f64.f16, vcvtb.f32.f16 */ | ||
69 | + case 0x05: /* vcvtt.f64.f16, vcvtt.f32.f16 */ | ||
70 | + /* | ||
71 | + * VCVTB, VCVTT: only present with the halfprec extension | ||
72 | + * UNPREDICTABLE if bit 8 is set prior to ARMv8 | ||
73 | + * (we choose to UNDEF) | ||
74 | */ | ||
75 | - rm = VFP_SREG_M(insn); | ||
76 | - } else { | ||
77 | - VFP_DREG_M(rm, insn); | ||
78 | + if ((dp && !arm_dc_feature(s, ARM_FEATURE_V8)) || | ||
79 | + !arm_dc_feature(s, ARM_FEATURE_VFP_FP16)) { | ||
80 | + return 1; | ||
81 | + } | ||
82 | + rm_is_dp = false; | ||
83 | + break; | ||
84 | + case 0x06: /* vcvtb.f16.f32, vcvtb.f16.f64 */ | ||
85 | + case 0x07: /* vcvtt.f16.f32, vcvtt.f16.f64 */ | ||
86 | + if ((dp && !arm_dc_feature(s, ARM_FEATURE_V8)) || | ||
87 | + !arm_dc_feature(s, ARM_FEATURE_VFP_FP16)) { | ||
88 | + return 1; | ||
89 | + } | ||
90 | + rd_is_dp = false; | ||
91 | + break; | ||
92 | + | ||
93 | + case 0x08: case 0x0a: /* vcmp, vcmpz */ | ||
94 | + case 0x09: case 0x0b: /* vcmpe, vcmpez */ | ||
95 | + no_output = true; | ||
96 | + break; | ||
97 | + | ||
98 | + case 0x0c: /* vrintr */ | ||
99 | + case 0x0d: /* vrintz */ | ||
100 | + case 0x0e: /* vrintx */ | ||
101 | + break; | ||
102 | + | ||
103 | + case 0x0f: /* vcvt double<->single */ | ||
104 | + rd_is_dp = !dp; | ||
105 | + break; | ||
106 | + | ||
107 | + case 0x10: /* vcvt.fxx.u32 */ | ||
108 | + case 0x11: /* vcvt.fxx.s32 */ | ||
109 | + rm_is_dp = false; | ||
110 | + break; | ||
111 | + case 0x18: /* vcvtr.u32.fxx */ | ||
112 | + case 0x19: /* vcvtz.u32.fxx */ | ||
113 | + case 0x1a: /* vcvtr.s32.fxx */ | ||
114 | + case 0x1b: /* vcvtz.s32.fxx */ | ||
115 | + rd_is_dp = false; | ||
116 | + break; | ||
117 | + | ||
118 | + case 0x14: /* vcvt fp <-> fixed */ | ||
119 | + case 0x15: | ||
120 | + case 0x16: | ||
121 | + case 0x17: | ||
122 | + case 0x1c: | ||
123 | + case 0x1d: | ||
124 | + case 0x1e: | ||
125 | + case 0x1f: | ||
126 | + if (!arm_dc_feature(s, ARM_FEATURE_VFP3)) { | ||
127 | + return 1; | ||
128 | + } | ||
129 | + /* Immediate frac_bits has same format as SREG_M. */ | ||
130 | + rm_is_dp = false; | ||
131 | + break; | ||
132 | + | ||
133 | + default: | ||
134 | + return 1; | ||
135 | } | ||
136 | + } else if (dp) { | ||
137 | + /* rn is register number */ | ||
138 | + VFP_DREG_N(rn, insn); | ||
139 | + } | ||
140 | + | ||
141 | + if (rd_is_dp) { | ||
142 | + VFP_DREG_D(rd, insn); | ||
143 | + } else { | ||
144 | + rd = VFP_SREG_D(insn); | ||
145 | + } | ||
146 | + if (rm_is_dp) { | ||
147 | + VFP_DREG_M(rm, insn); | ||
148 | } else { | ||
149 | - rn = VFP_SREG_N(insn); | ||
150 | - if (op == 15 && rn == 15) { | ||
151 | - /* Double precision destination. */ | ||
152 | - VFP_DREG_D(rd, insn); | ||
153 | - } else { | ||
154 | - rd = VFP_SREG_D(insn); | ||
155 | - } | ||
156 | - /* NB that we implicitly rely on the encoding for the frac_bits | ||
157 | - * in VCVT of fixed to float being the same as that of an SREG_M | ||
158 | - */ | ||
159 | rm = VFP_SREG_M(insn); | ||
160 | } | ||
161 | |||
162 | veclen = s->vec_len; | ||
163 | - if (op == 15 && rn > 3) | ||
164 | + if (op == 15 && rn > 3) { | ||
165 | veclen = 0; | ||
166 | + } | ||
167 | |||
168 | /* Shut up compiler warnings. */ | ||
169 | delta_m = 0; | ||
170 | @@ -XXX,XX +XXX,XX @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) | ||
171 | /* Load the initial operands. */ | ||
172 | if (op == 15) { | ||
173 | switch (rn) { | ||
174 | - case 16: | ||
175 | - case 17: | ||
176 | - /* Integer source */ | ||
177 | - gen_mov_F0_vreg(0, rm); | ||
178 | - break; | ||
179 | - case 8: | ||
180 | - case 9: | ||
181 | - /* Compare */ | ||
182 | + case 0x08: case 0x09: /* Compare */ | ||
183 | gen_mov_F0_vreg(dp, rd); | ||
184 | gen_mov_F1_vreg(dp, rm); | ||
185 | break; | ||
186 | - case 10: | ||
187 | - case 11: | ||
188 | - /* Compare with zero */ | ||
189 | + case 0x0a: case 0x0b: /* Compare with zero */ | ||
190 | gen_mov_F0_vreg(dp, rd); | ||
191 | gen_vfp_F1_ld0(dp); | ||
192 | break; | ||
193 | - case 20: | ||
194 | - case 21: | ||
195 | - case 22: | ||
196 | - case 23: | ||
197 | - case 28: | ||
198 | - case 29: | ||
199 | - case 30: | ||
200 | - case 31: | ||
201 | + case 0x14: /* vcvt fp <-> fixed */ | ||
202 | + case 0x15: | ||
203 | + case 0x16: | ||
204 | + case 0x17: | ||
205 | + case 0x1c: | ||
206 | + case 0x1d: | ||
207 | + case 0x1e: | ||
208 | + case 0x1f: | ||
209 | /* Source and destination the same. */ | ||
210 | gen_mov_F0_vreg(dp, rd); | ||
211 | break; | ||
212 | - case 4: | ||
213 | - case 5: | ||
214 | - case 6: | ||
215 | - case 7: | ||
216 | - /* VCVTB, VCVTT: only present with the halfprec extension | ||
217 | - * UNPREDICTABLE if bit 8 is set prior to ARMv8 | ||
218 | - * (we choose to UNDEF) | ||
219 | - */ | ||
220 | - if ((dp && !arm_dc_feature(s, ARM_FEATURE_V8)) || | ||
221 | - !arm_dc_feature(s, ARM_FEATURE_VFP_FP16)) { | ||
222 | - return 1; | ||
223 | - } | ||
224 | - if (!extract32(rn, 1, 1)) { | ||
225 | - /* Half precision source. */ | ||
226 | - gen_mov_F0_vreg(0, rm); | ||
227 | - break; | ||
228 | - } | ||
229 | - /* Otherwise fall through */ | ||
230 | default: | ||
231 | /* One source operand. */ | ||
232 | - gen_mov_F0_vreg(dp, rm); | ||
233 | + gen_mov_F0_vreg(rm_is_dp, rm); | ||
234 | break; | ||
235 | } | ||
236 | } else { | ||
237 | @@ -XXX,XX +XXX,XX @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) | ||
238 | break; | ||
239 | } | ||
240 | case 15: /* single<->double conversion */ | ||
241 | - if (dp) | ||
242 | + if (dp) { | ||
243 | gen_helper_vfp_fcvtsd(cpu_F0s, cpu_F0d, cpu_env); | ||
244 | - else | ||
245 | + } else { | ||
246 | gen_helper_vfp_fcvtds(cpu_F0d, cpu_F0s, cpu_env); | ||
247 | + } | ||
248 | break; | ||
249 | case 16: /* fuito */ | ||
250 | gen_vfp_uito(dp, 0); | ||
251 | @@ -XXX,XX +XXX,XX @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) | ||
252 | gen_vfp_sito(dp, 0); | ||
253 | break; | ||
254 | case 20: /* fshto */ | ||
255 | - if (!arm_dc_feature(s, ARM_FEATURE_VFP3)) { | ||
256 | - return 1; | ||
257 | - } | ||
258 | gen_vfp_shto(dp, 16 - rm, 0); | ||
259 | break; | ||
260 | case 21: /* fslto */ | ||
261 | - if (!arm_dc_feature(s, ARM_FEATURE_VFP3)) { | ||
262 | - return 1; | ||
263 | - } | ||
264 | gen_vfp_slto(dp, 32 - rm, 0); | ||
265 | break; | ||
266 | case 22: /* fuhto */ | ||
267 | - if (!arm_dc_feature(s, ARM_FEATURE_VFP3)) { | ||
268 | - return 1; | ||
269 | - } | ||
270 | gen_vfp_uhto(dp, 16 - rm, 0); | ||
271 | break; | ||
272 | case 23: /* fulto */ | ||
273 | - if (!arm_dc_feature(s, ARM_FEATURE_VFP3)) { | ||
274 | - return 1; | ||
275 | - } | ||
276 | gen_vfp_ulto(dp, 32 - rm, 0); | ||
277 | break; | ||
278 | case 24: /* ftoui */ | ||
279 | @@ -XXX,XX +XXX,XX @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) | ||
280 | gen_vfp_tosiz(dp, 0); | ||
281 | break; | ||
282 | case 28: /* ftosh */ | ||
283 | - if (!arm_dc_feature(s, ARM_FEATURE_VFP3)) { | ||
284 | - return 1; | ||
285 | - } | ||
286 | gen_vfp_tosh(dp, 16 - rm, 0); | ||
287 | break; | ||
288 | case 29: /* ftosl */ | ||
289 | - if (!arm_dc_feature(s, ARM_FEATURE_VFP3)) { | ||
290 | - return 1; | ||
291 | - } | ||
292 | gen_vfp_tosl(dp, 32 - rm, 0); | ||
293 | break; | ||
294 | case 30: /* ftouh */ | ||
295 | - if (!arm_dc_feature(s, ARM_FEATURE_VFP3)) { | ||
296 | - return 1; | ||
297 | - } | ||
298 | gen_vfp_touh(dp, 16 - rm, 0); | ||
299 | break; | ||
300 | case 31: /* ftoul */ | ||
301 | - if (!arm_dc_feature(s, ARM_FEATURE_VFP3)) { | ||
302 | - return 1; | ||
303 | - } | ||
304 | gen_vfp_toul(dp, 32 - rm, 0); | ||
305 | break; | ||
306 | default: /* undefined */ | ||
307 | - return 1; | ||
308 | + g_assert_not_reached(); | ||
309 | } | ||
310 | break; | ||
311 | default: /* undefined */ | ||
312 | return 1; | 166 | return 1; |
313 | } | 167 | } |
314 | 168 | ||
315 | - /* Write back the result. */ | 169 | - /* Handle VMULL.P64 (Polynomial 64x64 to 128 bit multiply) |
316 | - if (op == 15 && (rn >= 8 && rn <= 11)) { | 170 | - * outside the loop below as it only performs a single pass. |
317 | - /* Comparison, do nothing. */ | 171 | - */ |
318 | - } else if (op == 15 && dp && ((rn & 0x1c) == 0x18 || | 172 | - if (op == 14 && size == 2) { |
319 | - (rn & 0x1e) == 0x6)) { | 173 | - if (!dc_isar_feature(aa32_pmull, s)) { |
320 | - /* VCVT double to int: always integer result. | 174 | - return 1; |
321 | - * VCVT double to half precision is always a single | 175 | + /* Handle polynomial VMULL in a single pass. */ |
322 | - * precision result. | 176 | + if (op == 14) { |
323 | - */ | 177 | + if (size == 0) { |
324 | - gen_mov_vreg_F0(0, rd); | 178 | + /* VMULL.P8 */ |
325 | - } else if (op == 15 && rn == 15) { | 179 | + tcg_gen_gvec_3_ool(rd_ofs, rn_ofs, rm_ofs, 16, 16, |
326 | - /* conversion */ | 180 | + 0, gen_helper_neon_pmull_h); |
327 | - gen_mov_vreg_F0(!dp, rd); | 181 | + } else { |
328 | - } else { | 182 | + /* VMULL.P64 */ |
329 | - gen_mov_vreg_F0(dp, rd); | 183 | + if (!dc_isar_feature(aa32_pmull, s)) { |
330 | + /* Write back the result, if any. */ | 184 | + return 1; |
331 | + if (!no_output) { | 185 | + } |
332 | + gen_mov_vreg_F0(rd_is_dp, rd); | 186 | + tcg_gen_gvec_3_ool(rd_ofs, rn_ofs, rm_ofs, 16, 16, |
187 | + 0, gen_helper_gvec_pmull_q); | ||
188 | } | ||
189 | - tcg_gen_gvec_3_ool(rd_ofs, rn_ofs, rm_ofs, 16, 16, | ||
190 | - 0, gen_helper_gvec_pmull_q); | ||
191 | return 0; | ||
333 | } | 192 | } |
334 | 193 | ||
335 | /* break out of the loop if we have finished */ | 194 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) |
336 | - if (veclen == 0) | 195 | /* VMLAL, VQDMLAL, VMLSL, VQDMLSL, VMULL, VQDMULL */ |
337 | + if (veclen == 0) { | 196 | gen_neon_mull(cpu_V0, tmp, tmp2, size, u); |
338 | break; | 197 | break; |
339 | + } | 198 | - case 14: /* Polynomial VMULL */ |
340 | 199 | - gen_helper_neon_mull_p8(cpu_V0, tmp, tmp2); | |
341 | if (op == 15 && delta_m == 0) { | 200 | - tcg_temp_free_i32(tmp2); |
342 | /* single source one-many */ | 201 | - tcg_temp_free_i32(tmp); |
202 | - break; | ||
203 | default: /* 15 is RESERVED: caught earlier */ | ||
204 | abort(); | ||
205 | } | ||
206 | diff --git a/target/arm/vec_helper.c b/target/arm/vec_helper.c | ||
207 | index XXXXXXX..XXXXXXX 100644 | ||
208 | --- a/target/arm/vec_helper.c | ||
209 | +++ b/target/arm/vec_helper.c | ||
210 | @@ -XXX,XX +XXX,XX @@ void HELPER(gvec_pmull_q)(void *vd, void *vn, void *vm, uint32_t desc) | ||
211 | } | ||
212 | clear_tail(d, opr_sz, simd_maxsz(desc)); | ||
213 | } | ||
214 | + | ||
215 | +/* | ||
216 | + * 8x8->16 polynomial multiply. | ||
217 | + * | ||
218 | + * The byte inputs are expanded to (or extracted from) half-words. | ||
219 | + * Note that neon and sve2 get the inputs from different positions. | ||
220 | + * This allows 4 bytes to be processed in parallel with uint64_t. | ||
221 | + */ | ||
222 | + | ||
223 | +static uint64_t expand_byte_to_half(uint64_t x) | ||
224 | +{ | ||
225 | + return (x & 0x000000ff) | ||
226 | + | ((x & 0x0000ff00) << 8) | ||
227 | + | ((x & 0x00ff0000) << 16) | ||
228 | + | ((x & 0xff000000) << 24); | ||
229 | +} | ||
230 | + | ||
231 | +static uint64_t pmull_h(uint64_t op1, uint64_t op2) | ||
232 | +{ | ||
233 | + uint64_t result = 0; | ||
234 | + int i; | ||
235 | + | ||
236 | + for (i = 0; i < 8; ++i) { | ||
237 | + uint64_t mask = (op1 & 0x0001000100010001ull) * 0xffff; | ||
238 | + result ^= op2 & mask; | ||
239 | + op1 >>= 1; | ||
240 | + op2 <<= 1; | ||
241 | + } | ||
242 | + return result; | ||
243 | +} | ||
244 | + | ||
245 | +void HELPER(neon_pmull_h)(void *vd, void *vn, void *vm, uint32_t desc) | ||
246 | +{ | ||
247 | + int hi = simd_data(desc); | ||
248 | + uint64_t *d = vd, *n = vn, *m = vm; | ||
249 | + uint64_t nn = n[hi], mm = m[hi]; | ||
250 | + | ||
251 | + d[0] = pmull_h(expand_byte_to_half(nn), expand_byte_to_half(mm)); | ||
252 | + nn >>= 32; | ||
253 | + mm >>= 32; | ||
254 | + d[1] = pmull_h(expand_byte_to_half(nn), expand_byte_to_half(mm)); | ||
255 | + | ||
256 | + clear_tail(d, 16, simd_maxsz(desc)); | ||
257 | +} | ||
258 | + | ||
259 | +#ifdef TARGET_AARCH64 | ||
260 | +void HELPER(sve2_pmull_h)(void *vd, void *vn, void *vm, uint32_t desc) | ||
261 | +{ | ||
262 | + int shift = simd_data(desc) * 8; | ||
263 | + intptr_t i, opr_sz = simd_oprsz(desc); | ||
264 | + uint64_t *d = vd, *n = vn, *m = vm; | ||
265 | + | ||
266 | + for (i = 0; i < opr_sz / 8; ++i) { | ||
267 | + uint64_t nn = (n[i] >> shift) & 0x00ff00ff00ff00ffull; | ||
268 | + uint64_t mm = (m[i] >> shift) & 0x00ff00ff00ff00ffull; | ||
269 | + | ||
270 | + d[i] = pmull_h(nn, mm); | ||
271 | + } | ||
272 | +} | ||
273 | +#endif | ||
343 | -- | 274 | -- |
344 | 2.20.1 | 275 | 2.20.1 |
345 | 276 | ||
346 | 277 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Francisco Iglesias <francisco.iglesias@xilinx.com> | ||
1 | 2 | ||
3 | Correct the number of dummy cycles required by the FAST_READ_4 command (to | ||
4 | be eight, one dummy byte). | ||
5 | |||
6 | Fixes: ef06ca3946 ("xilinx_spips: Add support for RX discard and RX drain") | ||
7 | Suggested-by: Cédric Le Goater <clg@kaod.org> | ||
8 | Signed-off-by: Francisco Iglesias <frasse.iglesias@gmail.com> | ||
9 | Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> | ||
10 | Message-id: 20200218113350.6090-1-frasse.iglesias@gmail.com | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | --- | ||
13 | hw/ssi/xilinx_spips.c | 2 +- | ||
14 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
15 | |||
16 | diff --git a/hw/ssi/xilinx_spips.c b/hw/ssi/xilinx_spips.c | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/hw/ssi/xilinx_spips.c | ||
19 | +++ b/hw/ssi/xilinx_spips.c | ||
20 | @@ -XXX,XX +XXX,XX @@ static int xilinx_spips_num_dummies(XilinxQSPIPS *qs, uint8_t command) | ||
21 | case FAST_READ: | ||
22 | case DOR: | ||
23 | case QOR: | ||
24 | + case FAST_READ_4: | ||
25 | case DOR_4: | ||
26 | case QOR_4: | ||
27 | return 1; | ||
28 | case DIOR: | ||
29 | - case FAST_READ_4: | ||
30 | case DIOR_4: | ||
31 | return 2; | ||
32 | case QIOR: | ||
33 | -- | ||
34 | 2.20.1 | ||
35 | |||
36 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Guenter Roeck <linux@roeck-us.net> | ||
1 | 2 | ||
3 | Booting the r2d machine from flash fails because flash is not discovered. | ||
4 | Looking at the flattened memory tree, we see the following. | ||
5 | |||
6 | FlatView #1 | ||
7 | AS "memory", root: system | ||
8 | AS "cpu-memory-0", root: system | ||
9 | AS "sh_pci_host", root: bus master container | ||
10 | Root memory region: system | ||
11 | 0000000000000000-000000000000ffff (prio 0, i/o): io | ||
12 | 0000000000010000-0000000000ffffff (prio 0, i/o): r2d.flash @0000000000010000 | ||
13 | |||
14 | The overlapping memory region is sh_pci.isa, ie the ISA I/O region bridge. | ||
15 | This region is initially assigned to address 0xfe240000, but overwritten | ||
16 | with a write into the PCIIOBR register. This write is expected to adjust | ||
17 | the PCI memory window, but not to change the region's base adddress. | ||
18 | |||
19 | Peter Maydell provided the following detailed explanation. | ||
20 | |||
21 | "Section 22.3.7 and in particular figure 22.3 (of "SSH7751R user's manual: | ||
22 | hardware") are clear about how this is supposed to work: there is a window | ||
23 | at 0xfe240000 in the system register space for PCI I/O space. When the CPU | ||
24 | makes an access into that area, the PCI controller calculates the PCI | ||
25 | address to use by combining bits 0..17 of the system address with the | ||
26 | bits 31..18 value that the guest has put into the PCIIOBR. That is, writing | ||
27 | to the PCIIOBR changes which section of the IO address space is visible in | ||
28 | the 0xfe240000 window. Instead what QEMU's implementation does is move the | ||
29 | window to whatever value the guest writes to the PCIIOBR register -- so if | ||
30 | the guest writes 0 we put the window at 0 in system address space." | ||
31 | |||
32 | Fix the problem by calling memory_region_set_alias_offset() instead of | ||
33 | removing and re-adding the PCI ISA subregion on writes into PCIIOBR. | ||
34 | At the same time, in sh_pci_device_realize(), don't set iobr since | ||
35 | it is overwritten later anyway. Instead, pass the base address to | ||
36 | memory_region_add_subregion() directly. | ||
37 | |||
38 | Many thanks to Peter Maydell for the detailed problem analysis, and for | ||
39 | providing suggestions on how to fix the problem. | ||
40 | |||
41 | Signed-off-by: Guenter Roeck <linux@roeck-us.net> | ||
42 | Message-id: 20200218201050.15273-1-linux@roeck-us.net | ||
43 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
44 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
45 | --- | ||
46 | hw/sh4/sh_pci.c | 11 +++-------- | ||
47 | 1 file changed, 3 insertions(+), 8 deletions(-) | ||
48 | |||
49 | diff --git a/hw/sh4/sh_pci.c b/hw/sh4/sh_pci.c | ||
50 | index XXXXXXX..XXXXXXX 100644 | ||
51 | --- a/hw/sh4/sh_pci.c | ||
52 | +++ b/hw/sh4/sh_pci.c | ||
53 | @@ -XXX,XX +XXX,XX @@ static void sh_pci_reg_write (void *p, hwaddr addr, uint64_t val, | ||
54 | pcic->mbr = val & 0xff000001; | ||
55 | break; | ||
56 | case 0x1c8: | ||
57 | - if ((val & 0xfffc0000) != (pcic->iobr & 0xfffc0000)) { | ||
58 | - memory_region_del_subregion(get_system_memory(), &pcic->isa); | ||
59 | - pcic->iobr = val & 0xfffc0001; | ||
60 | - memory_region_add_subregion(get_system_memory(), | ||
61 | - pcic->iobr & 0xfffc0000, &pcic->isa); | ||
62 | - } | ||
63 | + pcic->iobr = val & 0xfffc0001; | ||
64 | + memory_region_set_alias_offset(&pcic->isa, val & 0xfffc0000); | ||
65 | break; | ||
66 | case 0x220: | ||
67 | pci_data_write(phb->bus, pcic->par, val, 4); | ||
68 | @@ -XXX,XX +XXX,XX @@ static void sh_pci_device_realize(DeviceState *dev, Error **errp) | ||
69 | get_system_io(), 0, 0x40000); | ||
70 | sysbus_init_mmio(sbd, &s->memconfig_p4); | ||
71 | sysbus_init_mmio(sbd, &s->memconfig_a7); | ||
72 | - s->iobr = 0xfe240000; | ||
73 | - memory_region_add_subregion(get_system_memory(), s->iobr, &s->isa); | ||
74 | + memory_region_add_subregion(get_system_memory(), 0xfe240000, &s->isa); | ||
75 | |||
76 | s->dev = pci_create_simple(phb->bus, PCI_DEVFN(0, 0), "sh_pci_host"); | ||
77 | } | ||
78 | -- | ||
79 | 2.20.1 | ||
80 | |||
81 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | 1 | From: Richard Henderson <richard.henderson@linaro.org> | |
2 | |||
3 | The old name, isar_feature_aa32_fp_d32, does not reflect | ||
4 | the MVFR0 field name, SIMDReg. | ||
5 | |||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
8 | Message-id: 20200214181547.21408-3-richard.henderson@linaro.org | ||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | [PMM: wrapped one long line] | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | --- | ||
13 | target/arm/cpu.h | 2 +- | ||
14 | target/arm/translate-vfp.inc.c | 53 +++++++++++++++++----------------- | ||
15 | 2 files changed, 28 insertions(+), 27 deletions(-) | ||
16 | |||
17 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/target/arm/cpu.h | ||
20 | +++ b/target/arm/cpu.h | ||
21 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa32_fp16_arith(const ARMISARegisters *id) | ||
22 | return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, FP) == 1; | ||
23 | } | ||
24 | |||
25 | -static inline bool isar_feature_aa32_fp_d32(const ARMISARegisters *id) | ||
26 | +static inline bool isar_feature_aa32_simd_r32(const ARMISARegisters *id) | ||
27 | { | ||
28 | /* Return true if D16-D31 are implemented */ | ||
29 | return FIELD_EX32(id->mvfr0, MVFR0, SIMDREG) >= 2; | ||
30 | diff --git a/target/arm/translate-vfp.inc.c b/target/arm/translate-vfp.inc.c | ||
31 | index XXXXXXX..XXXXXXX 100644 | ||
32 | --- a/target/arm/translate-vfp.inc.c | ||
33 | +++ b/target/arm/translate-vfp.inc.c | ||
34 | @@ -XXX,XX +XXX,XX @@ static bool trans_VSEL(DisasContext *s, arg_VSEL *a) | ||
35 | } | ||
36 | |||
37 | /* UNDEF accesses to D16-D31 if they don't exist */ | ||
38 | - if (dp && !dc_isar_feature(aa32_fp_d32, s) && | ||
39 | + if (dp && !dc_isar_feature(aa32_simd_r32, s) && | ||
40 | ((a->vm | a->vn | a->vd) & 0x10)) { | ||
41 | return false; | ||
42 | } | ||
43 | @@ -XXX,XX +XXX,XX @@ static bool trans_VMINMAXNM(DisasContext *s, arg_VMINMAXNM *a) | ||
44 | } | ||
45 | |||
46 | /* UNDEF accesses to D16-D31 if they don't exist */ | ||
47 | - if (dp && !dc_isar_feature(aa32_fp_d32, s) && | ||
48 | + if (dp && !dc_isar_feature(aa32_simd_r32, s) && | ||
49 | ((a->vm | a->vn | a->vd) & 0x10)) { | ||
50 | return false; | ||
51 | } | ||
52 | @@ -XXX,XX +XXX,XX @@ static bool trans_VRINT(DisasContext *s, arg_VRINT *a) | ||
53 | } | ||
54 | |||
55 | /* UNDEF accesses to D16-D31 if they don't exist */ | ||
56 | - if (dp && !dc_isar_feature(aa32_fp_d32, s) && | ||
57 | + if (dp && !dc_isar_feature(aa32_simd_r32, s) && | ||
58 | ((a->vm | a->vd) & 0x10)) { | ||
59 | return false; | ||
60 | } | ||
61 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT(DisasContext *s, arg_VCVT *a) | ||
62 | } | ||
63 | |||
64 | /* UNDEF accesses to D16-D31 if they don't exist */ | ||
65 | - if (dp && !dc_isar_feature(aa32_fp_d32, s) && (a->vm & 0x10)) { | ||
66 | + if (dp && !dc_isar_feature(aa32_simd_r32, s) && (a->vm & 0x10)) { | ||
67 | return false; | ||
68 | } | ||
69 | |||
70 | @@ -XXX,XX +XXX,XX @@ static bool trans_VMOV_to_gp(DisasContext *s, arg_VMOV_to_gp *a) | ||
71 | uint32_t offset; | ||
72 | |||
73 | /* UNDEF accesses to D16-D31 if they don't exist */ | ||
74 | - if (!dc_isar_feature(aa32_fp_d32, s) && (a->vn & 0x10)) { | ||
75 | + if (!dc_isar_feature(aa32_simd_r32, s) && (a->vn & 0x10)) { | ||
76 | return false; | ||
77 | } | ||
78 | |||
79 | @@ -XXX,XX +XXX,XX @@ static bool trans_VMOV_from_gp(DisasContext *s, arg_VMOV_from_gp *a) | ||
80 | uint32_t offset; | ||
81 | |||
82 | /* UNDEF accesses to D16-D31 if they don't exist */ | ||
83 | - if (!dc_isar_feature(aa32_fp_d32, s) && (a->vn & 0x10)) { | ||
84 | + if (!dc_isar_feature(aa32_simd_r32, s) && (a->vn & 0x10)) { | ||
85 | return false; | ||
86 | } | ||
87 | |||
88 | @@ -XXX,XX +XXX,XX @@ static bool trans_VDUP(DisasContext *s, arg_VDUP *a) | ||
89 | } | ||
90 | |||
91 | /* UNDEF accesses to D16-D31 if they don't exist */ | ||
92 | - if (!dc_isar_feature(aa32_fp_d32, s) && (a->vn & 0x10)) { | ||
93 | + if (!dc_isar_feature(aa32_simd_r32, s) && (a->vn & 0x10)) { | ||
94 | return false; | ||
95 | } | ||
96 | |||
97 | @@ -XXX,XX +XXX,XX @@ static bool trans_VMOV_64_dp(DisasContext *s, arg_VMOV_64_dp *a) | ||
98 | */ | ||
99 | |||
100 | /* UNDEF accesses to D16-D31 if they don't exist */ | ||
101 | - if (!dc_isar_feature(aa32_fp_d32, s) && (a->vm & 0x10)) { | ||
102 | + if (!dc_isar_feature(aa32_simd_r32, s) && (a->vm & 0x10)) { | ||
103 | return false; | ||
104 | } | ||
105 | |||
106 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLDR_VSTR_dp(DisasContext *s, arg_VLDR_VSTR_dp *a) | ||
107 | TCGv_i64 tmp; | ||
108 | |||
109 | /* UNDEF accesses to D16-D31 if they don't exist */ | ||
110 | - if (!dc_isar_feature(aa32_fp_d32, s) && (a->vd & 0x10)) { | ||
111 | + if (!dc_isar_feature(aa32_simd_r32, s) && (a->vd & 0x10)) { | ||
112 | return false; | ||
113 | } | ||
114 | |||
115 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLDM_VSTM_dp(DisasContext *s, arg_VLDM_VSTM_dp *a) | ||
116 | } | ||
117 | |||
118 | /* UNDEF accesses to D16-D31 if they don't exist */ | ||
119 | - if (!dc_isar_feature(aa32_fp_d32, s) && (a->vd + n) > 16) { | ||
120 | + if (!dc_isar_feature(aa32_simd_r32, s) && (a->vd + n) > 16) { | ||
121 | return false; | ||
122 | } | ||
123 | |||
124 | @@ -XXX,XX +XXX,XX @@ static bool do_vfp_3op_dp(DisasContext *s, VFPGen3OpDPFn *fn, | ||
125 | TCGv_ptr fpst; | ||
126 | |||
127 | /* UNDEF accesses to D16-D31 if they don't exist */ | ||
128 | - if (!dc_isar_feature(aa32_fp_d32, s) && ((vd | vn | vm) & 0x10)) { | ||
129 | + if (!dc_isar_feature(aa32_simd_r32, s) && ((vd | vn | vm) & 0x10)) { | ||
130 | return false; | ||
131 | } | ||
132 | |||
133 | @@ -XXX,XX +XXX,XX @@ static bool do_vfp_2op_dp(DisasContext *s, VFPGen2OpDPFn *fn, int vd, int vm) | ||
134 | TCGv_i64 f0, fd; | ||
135 | |||
136 | /* UNDEF accesses to D16-D31 if they don't exist */ | ||
137 | - if (!dc_isar_feature(aa32_fp_d32, s) && ((vd | vm) & 0x10)) { | ||
138 | + if (!dc_isar_feature(aa32_simd_r32, s) && ((vd | vm) & 0x10)) { | ||
139 | return false; | ||
140 | } | ||
141 | |||
142 | @@ -XXX,XX +XXX,XX @@ static bool trans_VFM_dp(DisasContext *s, arg_VFM_dp *a) | ||
143 | } | ||
144 | |||
145 | /* UNDEF accesses to D16-D31 if they don't exist. */ | ||
146 | - if (!dc_isar_feature(aa32_fp_d32, s) && ((a->vd | a->vn | a->vm) & 0x10)) { | ||
147 | + if (!dc_isar_feature(aa32_simd_r32, s) && | ||
148 | + ((a->vd | a->vn | a->vm) & 0x10)) { | ||
149 | return false; | ||
150 | } | ||
151 | |||
152 | @@ -XXX,XX +XXX,XX @@ static bool trans_VMOV_imm_dp(DisasContext *s, arg_VMOV_imm_dp *a) | ||
153 | vd = a->vd; | ||
154 | |||
155 | /* UNDEF accesses to D16-D31 if they don't exist. */ | ||
156 | - if (!dc_isar_feature(aa32_fp_d32, s) && (vd & 0x10)) { | ||
157 | + if (!dc_isar_feature(aa32_simd_r32, s) && (vd & 0x10)) { | ||
158 | return false; | ||
159 | } | ||
160 | |||
161 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCMP_dp(DisasContext *s, arg_VCMP_dp *a) | ||
162 | } | ||
163 | |||
164 | /* UNDEF accesses to D16-D31 if they don't exist. */ | ||
165 | - if (!dc_isar_feature(aa32_fp_d32, s) && ((a->vd | a->vm) & 0x10)) { | ||
166 | + if (!dc_isar_feature(aa32_simd_r32, s) && ((a->vd | a->vm) & 0x10)) { | ||
167 | return false; | ||
168 | } | ||
169 | |||
170 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_f64_f16(DisasContext *s, arg_VCVT_f64_f16 *a) | ||
171 | } | ||
172 | |||
173 | /* UNDEF accesses to D16-D31 if they don't exist. */ | ||
174 | - if (!dc_isar_feature(aa32_fp_d32, s) && (a->vd & 0x10)) { | ||
175 | + if (!dc_isar_feature(aa32_simd_r32, s) && (a->vd & 0x10)) { | ||
176 | return false; | ||
177 | } | ||
178 | |||
179 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_f16_f64(DisasContext *s, arg_VCVT_f16_f64 *a) | ||
180 | } | ||
181 | |||
182 | /* UNDEF accesses to D16-D31 if they don't exist. */ | ||
183 | - if (!dc_isar_feature(aa32_fp_d32, s) && (a->vm & 0x10)) { | ||
184 | + if (!dc_isar_feature(aa32_simd_r32, s) && (a->vm & 0x10)) { | ||
185 | return false; | ||
186 | } | ||
187 | |||
188 | @@ -XXX,XX +XXX,XX @@ static bool trans_VRINTR_dp(DisasContext *s, arg_VRINTR_dp *a) | ||
189 | } | ||
190 | |||
191 | /* UNDEF accesses to D16-D31 if they don't exist. */ | ||
192 | - if (!dc_isar_feature(aa32_fp_d32, s) && ((a->vd | a->vm) & 0x10)) { | ||
193 | + if (!dc_isar_feature(aa32_simd_r32, s) && ((a->vd | a->vm) & 0x10)) { | ||
194 | return false; | ||
195 | } | ||
196 | |||
197 | @@ -XXX,XX +XXX,XX @@ static bool trans_VRINTZ_dp(DisasContext *s, arg_VRINTZ_dp *a) | ||
198 | } | ||
199 | |||
200 | /* UNDEF accesses to D16-D31 if they don't exist. */ | ||
201 | - if (!dc_isar_feature(aa32_fp_d32, s) && ((a->vd | a->vm) & 0x10)) { | ||
202 | + if (!dc_isar_feature(aa32_simd_r32, s) && ((a->vd | a->vm) & 0x10)) { | ||
203 | return false; | ||
204 | } | ||
205 | |||
206 | @@ -XXX,XX +XXX,XX @@ static bool trans_VRINTX_dp(DisasContext *s, arg_VRINTX_dp *a) | ||
207 | } | ||
208 | |||
209 | /* UNDEF accesses to D16-D31 if they don't exist. */ | ||
210 | - if (!dc_isar_feature(aa32_fp_d32, s) && ((a->vd | a->vm) & 0x10)) { | ||
211 | + if (!dc_isar_feature(aa32_simd_r32, s) && ((a->vd | a->vm) & 0x10)) { | ||
212 | return false; | ||
213 | } | ||
214 | |||
215 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_sp(DisasContext *s, arg_VCVT_sp *a) | ||
216 | TCGv_i32 vm; | ||
217 | |||
218 | /* UNDEF accesses to D16-D31 if they don't exist. */ | ||
219 | - if (!dc_isar_feature(aa32_fp_d32, s) && (a->vd & 0x10)) { | ||
220 | + if (!dc_isar_feature(aa32_simd_r32, s) && (a->vd & 0x10)) { | ||
221 | return false; | ||
222 | } | ||
223 | |||
224 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_dp(DisasContext *s, arg_VCVT_dp *a) | ||
225 | TCGv_i32 vd; | ||
226 | |||
227 | /* UNDEF accesses to D16-D31 if they don't exist. */ | ||
228 | - if (!dc_isar_feature(aa32_fp_d32, s) && (a->vm & 0x10)) { | ||
229 | + if (!dc_isar_feature(aa32_simd_r32, s) && (a->vm & 0x10)) { | ||
230 | return false; | ||
231 | } | ||
232 | |||
233 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_int_dp(DisasContext *s, arg_VCVT_int_dp *a) | ||
234 | TCGv_ptr fpst; | ||
235 | |||
236 | /* UNDEF accesses to D16-D31 if they don't exist. */ | ||
237 | - if (!dc_isar_feature(aa32_fp_d32, s) && (a->vd & 0x10)) { | ||
238 | + if (!dc_isar_feature(aa32_simd_r32, s) && (a->vd & 0x10)) { | ||
239 | return false; | ||
240 | } | ||
241 | |||
242 | @@ -XXX,XX +XXX,XX @@ static bool trans_VJCVT(DisasContext *s, arg_VJCVT *a) | ||
243 | } | ||
244 | |||
245 | /* UNDEF accesses to D16-D31 if they don't exist. */ | ||
246 | - if (!dc_isar_feature(aa32_fp_d32, s) && (a->vm & 0x10)) { | ||
247 | + if (!dc_isar_feature(aa32_simd_r32, s) && (a->vm & 0x10)) { | ||
248 | return false; | ||
249 | } | ||
250 | |||
251 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_fix_dp(DisasContext *s, arg_VCVT_fix_dp *a) | ||
252 | } | ||
253 | |||
254 | /* UNDEF accesses to D16-D31 if they don't exist. */ | ||
255 | - if (!dc_isar_feature(aa32_fp_d32, s) && (a->vd & 0x10)) { | ||
256 | + if (!dc_isar_feature(aa32_simd_r32, s) && (a->vd & 0x10)) { | ||
257 | return false; | ||
258 | } | ||
259 | |||
260 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_dp_int(DisasContext *s, arg_VCVT_dp_int *a) | ||
261 | TCGv_ptr fpst; | ||
262 | |||
263 | /* UNDEF accesses to D16-D31 if they don't exist. */ | ||
264 | - if (!dc_isar_feature(aa32_fp_d32, s) && (a->vm & 0x10)) { | ||
265 | + if (!dc_isar_feature(aa32_simd_r32, s) && (a->vm & 0x10)) { | ||
266 | return false; | ||
267 | } | ||
268 | |||
269 | -- | ||
270 | 2.20.1 | ||
271 | |||
272 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
1 | 2 | ||
3 | Many uses of ARM_FEATURE_VFP3 are testing for the number of simd | ||
4 | registers implemented. Use the proper test vs MVFR0.SIMDReg. | ||
5 | |||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20200214181547.21408-4-richard.henderson@linaro.org | ||
8 | [PMM: fix typo in commit message] | ||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | target/arm/cpu.c | 9 ++++----- | ||
13 | target/arm/helper.c | 13 ++++++------- | ||
14 | target/arm/translate.c | 2 +- | ||
15 | 3 files changed, 11 insertions(+), 13 deletions(-) | ||
16 | |||
17 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/target/arm/cpu.c | ||
20 | +++ b/target/arm/cpu.c | ||
21 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_dump_state(CPUState *cs, FILE *f, int flags) | ||
22 | |||
23 | if (flags & CPU_DUMP_FPU) { | ||
24 | int numvfpregs = 0; | ||
25 | - if (arm_feature(env, ARM_FEATURE_VFP)) { | ||
26 | - numvfpregs += 16; | ||
27 | - } | ||
28 | - if (arm_feature(env, ARM_FEATURE_VFP3)) { | ||
29 | - numvfpregs += 16; | ||
30 | + if (cpu_isar_feature(aa32_simd_r32, cpu)) { | ||
31 | + numvfpregs = 32; | ||
32 | + } else if (arm_feature(env, ARM_FEATURE_VFP)) { | ||
33 | + numvfpregs = 16; | ||
34 | } | ||
35 | for (i = 0; i < numvfpregs; i++) { | ||
36 | uint64_t v = *aa32_vfp_dreg(env, i); | ||
37 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
38 | index XXXXXXX..XXXXXXX 100644 | ||
39 | --- a/target/arm/helper.c | ||
40 | +++ b/target/arm/helper.c | ||
41 | @@ -XXX,XX +XXX,XX @@ static void switch_mode(CPUARMState *env, int mode); | ||
42 | |||
43 | static int vfp_gdb_get_reg(CPUARMState *env, uint8_t *buf, int reg) | ||
44 | { | ||
45 | - int nregs; | ||
46 | + ARMCPU *cpu = env_archcpu(env); | ||
47 | + int nregs = cpu_isar_feature(aa32_simd_r32, cpu) ? 32 : 16; | ||
48 | |||
49 | /* VFP data registers are always little-endian. */ | ||
50 | - nregs = arm_feature(env, ARM_FEATURE_VFP3) ? 32 : 16; | ||
51 | if (reg < nregs) { | ||
52 | stq_le_p(buf, *aa32_vfp_dreg(env, reg)); | ||
53 | return 8; | ||
54 | @@ -XXX,XX +XXX,XX @@ static int vfp_gdb_get_reg(CPUARMState *env, uint8_t *buf, int reg) | ||
55 | |||
56 | static int vfp_gdb_set_reg(CPUARMState *env, uint8_t *buf, int reg) | ||
57 | { | ||
58 | - int nregs; | ||
59 | + ARMCPU *cpu = env_archcpu(env); | ||
60 | + int nregs = cpu_isar_feature(aa32_simd_r32, cpu) ? 32 : 16; | ||
61 | |||
62 | - nregs = arm_feature(env, ARM_FEATURE_VFP3) ? 32 : 16; | ||
63 | if (reg < nregs) { | ||
64 | *aa32_vfp_dreg(env, reg) = ldq_le_p(buf); | ||
65 | return 8; | ||
66 | @@ -XXX,XX +XXX,XX @@ static void cpacr_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
67 | /* VFPv3 and upwards with NEON implement 32 double precision | ||
68 | * registers (D0-D31). | ||
69 | */ | ||
70 | - if (!arm_feature(env, ARM_FEATURE_NEON) || | ||
71 | - !arm_feature(env, ARM_FEATURE_VFP3)) { | ||
72 | + if (!cpu_isar_feature(aa32_simd_r32, env_archcpu(env))) { | ||
73 | /* D32DIS [30] is RAO/WI if D16-31 are not implemented. */ | ||
74 | value |= (1 << 30); | ||
75 | } | ||
76 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_register_gdb_regs_for_features(ARMCPU *cpu) | ||
77 | } else if (arm_feature(env, ARM_FEATURE_NEON)) { | ||
78 | gdb_register_coprocessor(cs, vfp_gdb_get_reg, vfp_gdb_set_reg, | ||
79 | 51, "arm-neon.xml", 0); | ||
80 | - } else if (arm_feature(env, ARM_FEATURE_VFP3)) { | ||
81 | + } else if (cpu_isar_feature(aa32_simd_r32, cpu)) { | ||
82 | gdb_register_coprocessor(cs, vfp_gdb_get_reg, vfp_gdb_set_reg, | ||
83 | 35, "arm-vfp3.xml", 0); | ||
84 | } else if (arm_feature(env, ARM_FEATURE_VFP)) { | ||
85 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
86 | index XXXXXXX..XXXXXXX 100644 | ||
87 | --- a/target/arm/translate.c | ||
88 | +++ b/target/arm/translate.c | ||
89 | @@ -XXX,XX +XXX,XX @@ static int disas_dsp_insn(DisasContext *s, uint32_t insn) | ||
90 | #define VFP_SREG(insn, bigbit, smallbit) \ | ||
91 | ((VFP_REG_SHR(insn, bigbit - 1) & 0x1e) | (((insn) >> (smallbit)) & 1)) | ||
92 | #define VFP_DREG(reg, insn, bigbit, smallbit) do { \ | ||
93 | - if (arm_dc_feature(s, ARM_FEATURE_VFP3)) { \ | ||
94 | + if (dc_isar_feature(aa32_simd_r32, s)) { \ | ||
95 | reg = (((insn) >> (bigbit)) & 0x0f) \ | ||
96 | | (((insn) >> ((smallbit) - 4)) & 0x10); \ | ||
97 | } else { \ | ||
98 | -- | ||
99 | 2.20.1 | ||
100 | |||
101 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
1 | 2 | ||
3 | We are going to convert FEATURE tests to ISAR tests, | ||
4 | so FPSP needs to be set for these cpus, like we have | ||
5 | already for FPDP. | ||
6 | |||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20200214181547.21408-5-richard.henderson@linaro.org | ||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | target/arm/cpu.c | 10 ++++++---- | ||
13 | 1 file changed, 6 insertions(+), 4 deletions(-) | ||
14 | |||
15 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/target/arm/cpu.c | ||
18 | +++ b/target/arm/cpu.c | ||
19 | @@ -XXX,XX +XXX,XX @@ static void arm926_initfn(Object *obj) | ||
20 | */ | ||
21 | cpu->isar.id_isar1 = FIELD_DP32(cpu->isar.id_isar1, ID_ISAR1, JAZELLE, 1); | ||
22 | /* | ||
23 | - * Similarly, we need to set MVFR0 fields to enable double precision | ||
24 | - * and short vector support even though ARMv5 doesn't have this register. | ||
25 | + * Similarly, we need to set MVFR0 fields to enable vfp and short vector | ||
26 | + * support even though ARMv5 doesn't have this register. | ||
27 | */ | ||
28 | cpu->isar.mvfr0 = FIELD_DP32(cpu->isar.mvfr0, MVFR0, FPSHVEC, 1); | ||
29 | + cpu->isar.mvfr0 = FIELD_DP32(cpu->isar.mvfr0, MVFR0, FPSP, 1); | ||
30 | cpu->isar.mvfr0 = FIELD_DP32(cpu->isar.mvfr0, MVFR0, FPDP, 1); | ||
31 | } | ||
32 | |||
33 | @@ -XXX,XX +XXX,XX @@ static void arm1026_initfn(Object *obj) | ||
34 | */ | ||
35 | cpu->isar.id_isar1 = FIELD_DP32(cpu->isar.id_isar1, ID_ISAR1, JAZELLE, 1); | ||
36 | /* | ||
37 | - * Similarly, we need to set MVFR0 fields to enable double precision | ||
38 | - * and short vector support even though ARMv5 doesn't have this register. | ||
39 | + * Similarly, we need to set MVFR0 fields to enable vfp and short vector | ||
40 | + * support even though ARMv5 doesn't have this register. | ||
41 | */ | ||
42 | cpu->isar.mvfr0 = FIELD_DP32(cpu->isar.mvfr0, MVFR0, FPSHVEC, 1); | ||
43 | + cpu->isar.mvfr0 = FIELD_DP32(cpu->isar.mvfr0, MVFR0, FPSP, 1); | ||
44 | cpu->isar.mvfr0 = FIELD_DP32(cpu->isar.mvfr0, MVFR0, FPDP, 1); | ||
45 | |||
46 | { | ||
47 | -- | ||
48 | 2.20.1 | ||
49 | |||
50 | diff view generated by jsdifflib |
1 | Create a new include file for the pl011's device struct, | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | type macros, etc, so that it can be instantiated using | 2 | |
3 | the "embedded struct" coding style. | 3 | Use this in the places that were checking ARM_FEATURE_VFP, and |
4 | 4 | are obviously testing for the existance of the register set | |
5 | as opposed to testing for some particular instruction extension. | ||
6 | |||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20200214181547.21408-6-richard.henderson@linaro.org | ||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | --- | 11 | --- |
9 | include/hw/char/pl011.h | 34 ++++++++++++++++++++++++++++++++++ | 12 | target/arm/cpu.h | 6 ++++++ |
10 | hw/char/pl011.c | 31 ++----------------------------- | 13 | hw/intc/armv7m_nvic.c | 20 ++++++++++---------- |
11 | 2 files changed, 36 insertions(+), 29 deletions(-) | 14 | linux-user/arm/signal.c | 4 ++-- |
12 | 15 | target/arm/arch_dump.c | 11 ++++++----- | |
13 | diff --git a/include/hw/char/pl011.h b/include/hw/char/pl011.h | 16 | target/arm/cpu.c | 8 ++++---- |
14 | index XXXXXXX..XXXXXXX 100644 | 17 | target/arm/helper.c | 4 ++-- |
15 | --- a/include/hw/char/pl011.h | 18 | target/arm/m_helper.c | 11 ++++++----- |
16 | +++ b/include/hw/char/pl011.h | 19 | target/arm/machine.c | 3 +-- |
20 | 8 files changed, 37 insertions(+), 30 deletions(-) | ||
21 | |||
22 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
23 | index XXXXXXX..XXXXXXX 100644 | ||
24 | --- a/target/arm/cpu.h | ||
25 | +++ b/target/arm/cpu.h | ||
26 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa32_fp16_arith(const ARMISARegisters *id) | ||
27 | return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, FP) == 1; | ||
28 | } | ||
29 | |||
30 | +static inline bool isar_feature_aa32_simd_r16(const ARMISARegisters *id) | ||
31 | +{ | ||
32 | + /* Return true if D0-D15 are implemented */ | ||
33 | + return FIELD_EX32(id->mvfr0, MVFR0, SIMDREG) > 0; | ||
34 | +} | ||
35 | + | ||
36 | static inline bool isar_feature_aa32_simd_r32(const ARMISARegisters *id) | ||
37 | { | ||
38 | /* Return true if D16-D31 are implemented */ | ||
39 | diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c | ||
40 | index XXXXXXX..XXXXXXX 100644 | ||
41 | --- a/hw/intc/armv7m_nvic.c | ||
42 | +++ b/hw/intc/armv7m_nvic.c | ||
43 | @@ -XXX,XX +XXX,XX @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs) | ||
44 | case 0xd84: /* CSSELR */ | ||
45 | return cpu->env.v7m.csselr[attrs.secure]; | ||
46 | case 0xd88: /* CPACR */ | ||
47 | - if (!arm_feature(&cpu->env, ARM_FEATURE_VFP)) { | ||
48 | + if (!cpu_isar_feature(aa32_simd_r16, cpu)) { | ||
49 | return 0; | ||
50 | } | ||
51 | return cpu->env.v7m.cpacr[attrs.secure]; | ||
52 | case 0xd8c: /* NSACR */ | ||
53 | - if (!attrs.secure || !arm_feature(&cpu->env, ARM_FEATURE_VFP)) { | ||
54 | + if (!attrs.secure || !cpu_isar_feature(aa32_simd_r16, cpu)) { | ||
55 | return 0; | ||
56 | } | ||
57 | return cpu->env.v7m.nsacr; | ||
58 | @@ -XXX,XX +XXX,XX @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs) | ||
59 | } | ||
60 | return cpu->env.v7m.sfar; | ||
61 | case 0xf34: /* FPCCR */ | ||
62 | - if (!arm_feature(&cpu->env, ARM_FEATURE_VFP)) { | ||
63 | + if (!cpu_isar_feature(aa32_simd_r16, cpu)) { | ||
64 | return 0; | ||
65 | } | ||
66 | if (attrs.secure) { | ||
67 | @@ -XXX,XX +XXX,XX @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs) | ||
68 | return value; | ||
69 | } | ||
70 | case 0xf38: /* FPCAR */ | ||
71 | - if (!arm_feature(&cpu->env, ARM_FEATURE_VFP)) { | ||
72 | + if (!cpu_isar_feature(aa32_simd_r16, cpu)) { | ||
73 | return 0; | ||
74 | } | ||
75 | return cpu->env.v7m.fpcar[attrs.secure]; | ||
76 | case 0xf3c: /* FPDSCR */ | ||
77 | - if (!arm_feature(&cpu->env, ARM_FEATURE_VFP)) { | ||
78 | + if (!cpu_isar_feature(aa32_simd_r16, cpu)) { | ||
79 | return 0; | ||
80 | } | ||
81 | return cpu->env.v7m.fpdscr[attrs.secure]; | ||
82 | @@ -XXX,XX +XXX,XX @@ static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value, | ||
83 | } | ||
84 | break; | ||
85 | case 0xd88: /* CPACR */ | ||
86 | - if (arm_feature(&cpu->env, ARM_FEATURE_VFP)) { | ||
87 | + if (cpu_isar_feature(aa32_simd_r16, cpu)) { | ||
88 | /* We implement only the Floating Point extension's CP10/CP11 */ | ||
89 | cpu->env.v7m.cpacr[attrs.secure] = value & (0xf << 20); | ||
90 | } | ||
91 | break; | ||
92 | case 0xd8c: /* NSACR */ | ||
93 | - if (attrs.secure && arm_feature(&cpu->env, ARM_FEATURE_VFP)) { | ||
94 | + if (attrs.secure && cpu_isar_feature(aa32_simd_r16, cpu)) { | ||
95 | /* We implement only the Floating Point extension's CP10/CP11 */ | ||
96 | cpu->env.v7m.nsacr = value & (3 << 10); | ||
97 | } | ||
98 | @@ -XXX,XX +XXX,XX @@ static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value, | ||
99 | break; | ||
100 | } | ||
101 | case 0xf34: /* FPCCR */ | ||
102 | - if (arm_feature(&cpu->env, ARM_FEATURE_VFP)) { | ||
103 | + if (cpu_isar_feature(aa32_simd_r16, cpu)) { | ||
104 | /* Not all bits here are banked. */ | ||
105 | uint32_t fpccr_s; | ||
106 | |||
107 | @@ -XXX,XX +XXX,XX @@ static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value, | ||
108 | } | ||
109 | break; | ||
110 | case 0xf38: /* FPCAR */ | ||
111 | - if (arm_feature(&cpu->env, ARM_FEATURE_VFP)) { | ||
112 | + if (cpu_isar_feature(aa32_simd_r16, cpu)) { | ||
113 | value &= ~7; | ||
114 | cpu->env.v7m.fpcar[attrs.secure] = value; | ||
115 | } | ||
116 | break; | ||
117 | case 0xf3c: /* FPDSCR */ | ||
118 | - if (arm_feature(&cpu->env, ARM_FEATURE_VFP)) { | ||
119 | + if (cpu_isar_feature(aa32_simd_r16, cpu)) { | ||
120 | value &= 0x07c00000; | ||
121 | cpu->env.v7m.fpdscr[attrs.secure] = value; | ||
122 | } | ||
123 | diff --git a/linux-user/arm/signal.c b/linux-user/arm/signal.c | ||
124 | index XXXXXXX..XXXXXXX 100644 | ||
125 | --- a/linux-user/arm/signal.c | ||
126 | +++ b/linux-user/arm/signal.c | ||
127 | @@ -XXX,XX +XXX,XX @@ static void setup_sigframe_v2(struct target_ucontext_v2 *uc, | ||
128 | setup_sigcontext(&uc->tuc_mcontext, env, set->sig[0]); | ||
129 | /* Save coprocessor signal frame. */ | ||
130 | regspace = uc->tuc_regspace; | ||
131 | - if (arm_feature(env, ARM_FEATURE_VFP)) { | ||
132 | + if (cpu_isar_feature(aa32_simd_r16, env_archcpu(env))) { | ||
133 | regspace = setup_sigframe_v2_vfp(regspace, env); | ||
134 | } | ||
135 | if (arm_feature(env, ARM_FEATURE_IWMMXT)) { | ||
136 | @@ -XXX,XX +XXX,XX @@ static int do_sigframe_return_v2(CPUARMState *env, | ||
137 | |||
138 | /* Restore coprocessor signal frame */ | ||
139 | regspace = uc->tuc_regspace; | ||
140 | - if (arm_feature(env, ARM_FEATURE_VFP)) { | ||
141 | + if (cpu_isar_feature(aa32_simd_r16, env_archcpu(env))) { | ||
142 | regspace = restore_sigframe_v2_vfp(env, regspace); | ||
143 | if (!regspace) { | ||
144 | return 1; | ||
145 | diff --git a/target/arm/arch_dump.c b/target/arm/arch_dump.c | ||
146 | index XXXXXXX..XXXXXXX 100644 | ||
147 | --- a/target/arm/arch_dump.c | ||
148 | +++ b/target/arm/arch_dump.c | ||
149 | @@ -XXX,XX +XXX,XX @@ int arm_cpu_write_elf32_note(WriteCoreDumpFunction f, CPUState *cs, | ||
150 | int cpuid, void *opaque) | ||
151 | { | ||
152 | struct arm_note note; | ||
153 | - CPUARMState *env = &ARM_CPU(cs)->env; | ||
154 | + ARMCPU *cpu = ARM_CPU(cs); | ||
155 | + CPUARMState *env = &cpu->env; | ||
156 | DumpState *s = opaque; | ||
157 | - int ret, i, fpvalid = !!arm_feature(env, ARM_FEATURE_VFP); | ||
158 | + int ret, i; | ||
159 | + bool fpvalid = cpu_isar_feature(aa32_simd_r16, cpu); | ||
160 | |||
161 | arm_note_init(¬e, s, "CORE", 5, NT_PRSTATUS, sizeof(note.prstatus)); | ||
162 | |||
163 | @@ -XXX,XX +XXX,XX @@ int cpu_get_dump_info(ArchDumpInfo *info, | ||
164 | ssize_t cpu_get_note_size(int class, int machine, int nr_cpus) | ||
165 | { | ||
166 | ARMCPU *cpu = ARM_CPU(first_cpu); | ||
167 | - CPUARMState *env = &cpu->env; | ||
168 | size_t note_size; | ||
169 | |||
170 | if (class == ELFCLASS64) { | ||
171 | @@ -XXX,XX +XXX,XX @@ ssize_t cpu_get_note_size(int class, int machine, int nr_cpus) | ||
172 | note_size += AARCH64_PRFPREG_NOTE_SIZE; | ||
173 | #ifdef TARGET_AARCH64 | ||
174 | if (cpu_isar_feature(aa64_sve, cpu)) { | ||
175 | - note_size += AARCH64_SVE_NOTE_SIZE(env); | ||
176 | + note_size += AARCH64_SVE_NOTE_SIZE(&cpu->env); | ||
177 | } | ||
178 | #endif | ||
179 | } else { | ||
180 | note_size = ARM_PRSTATUS_NOTE_SIZE; | ||
181 | - if (arm_feature(env, ARM_FEATURE_VFP)) { | ||
182 | + if (cpu_isar_feature(aa32_simd_r16, cpu)) { | ||
183 | note_size += ARM_VFP_NOTE_SIZE; | ||
184 | } | ||
185 | } | ||
186 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | ||
187 | index XXXXXXX..XXXXXXX 100644 | ||
188 | --- a/target/arm/cpu.c | ||
189 | +++ b/target/arm/cpu.c | ||
190 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_reset(CPUState *s) | ||
191 | env->v7m.ccr[M_REG_S] |= R_V7M_CCR_UNALIGN_TRP_MASK; | ||
192 | } | ||
193 | |||
194 | - if (arm_feature(env, ARM_FEATURE_VFP)) { | ||
195 | + if (cpu_isar_feature(aa32_simd_r16, cpu)) { | ||
196 | env->v7m.fpccr[M_REG_NS] = R_V7M_FPCCR_ASPEN_MASK; | ||
197 | env->v7m.fpccr[M_REG_S] = R_V7M_FPCCR_ASPEN_MASK | | ||
198 | R_V7M_FPCCR_LSPEN_MASK | R_V7M_FPCCR_S_MASK; | ||
199 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_dump_state(CPUState *cs, FILE *f, int flags) | ||
200 | int numvfpregs = 0; | ||
201 | if (cpu_isar_feature(aa32_simd_r32, cpu)) { | ||
202 | numvfpregs = 32; | ||
203 | - } else if (arm_feature(env, ARM_FEATURE_VFP)) { | ||
204 | + } else if (cpu_isar_feature(aa32_simd_r16, cpu)) { | ||
205 | numvfpregs = 16; | ||
206 | } | ||
207 | for (i = 0; i < numvfpregs; i++) { | ||
208 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_post_init(Object *obj) | ||
209 | * KVM does not currently allow us to lie to the guest about its | ||
210 | * ID/feature registers, so the guest always sees what the host has. | ||
211 | */ | ||
212 | - if (arm_feature(&cpu->env, ARM_FEATURE_VFP)) { | ||
213 | + if (cpu_isar_feature(aa32_simd_r16, cpu)) { | ||
214 | cpu->has_vfp = true; | ||
215 | if (!kvm_enabled()) { | ||
216 | qdev_property_add_static(DEVICE(obj), &arm_cpu_has_vfp_property); | ||
217 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) | ||
218 | * We rely on no XScale CPU having VFP so we can use the same bits in the | ||
219 | * TB flags field for VECSTRIDE and XSCALE_CPAR. | ||
220 | */ | ||
221 | - assert(!(arm_feature(env, ARM_FEATURE_VFP) && | ||
222 | + assert(!(cpu_isar_feature(aa32_simd_r16, cpu) && | ||
223 | arm_feature(env, ARM_FEATURE_XSCALE))); | ||
224 | |||
225 | if (arm_feature(env, ARM_FEATURE_V7) && | ||
226 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
227 | index XXXXXXX..XXXXXXX 100644 | ||
228 | --- a/target/arm/helper.c | ||
229 | +++ b/target/arm/helper.c | ||
230 | @@ -XXX,XX +XXX,XX @@ static void cpacr_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
231 | * ASEDIS [31] and D32DIS [30] are both UNK/SBZP without VFP. | ||
232 | * TRCDIS [28] is RAZ/WI since we do not implement a trace macrocell. | ||
233 | */ | ||
234 | - if (arm_feature(env, ARM_FEATURE_VFP)) { | ||
235 | + if (cpu_isar_feature(aa32_simd_r16, env_archcpu(env))) { | ||
236 | /* VFP coprocessor: cp10 & cp11 [23:20] */ | ||
237 | mask |= (1 << 31) | (1 << 30) | (0xf << 20); | ||
238 | |||
239 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_register_gdb_regs_for_features(ARMCPU *cpu) | ||
240 | } else if (cpu_isar_feature(aa32_simd_r32, cpu)) { | ||
241 | gdb_register_coprocessor(cs, vfp_gdb_get_reg, vfp_gdb_set_reg, | ||
242 | 35, "arm-vfp3.xml", 0); | ||
243 | - } else if (arm_feature(env, ARM_FEATURE_VFP)) { | ||
244 | + } else if (cpu_isar_feature(aa32_simd_r16, cpu)) { | ||
245 | gdb_register_coprocessor(cs, vfp_gdb_get_reg, vfp_gdb_set_reg, | ||
246 | 19, "arm-vfp.xml", 0); | ||
247 | } | ||
248 | diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c | ||
249 | index XXXXXXX..XXXXXXX 100644 | ||
250 | --- a/target/arm/m_helper.c | ||
251 | +++ b/target/arm/m_helper.c | ||
252 | @@ -XXX,XX +XXX,XX @@ static uint32_t v7m_integrity_sig(CPUARMState *env, uint32_t lr) | ||
253 | */ | ||
254 | uint32_t sig = 0xfefa125a; | ||
255 | |||
256 | - if (!arm_feature(env, ARM_FEATURE_VFP) || (lr & R_V7M_EXCRET_FTYPE_MASK)) { | ||
257 | + if (!cpu_isar_feature(aa32_simd_r16, env_archcpu(env)) | ||
258 | + || (lr & R_V7M_EXCRET_FTYPE_MASK)) { | ||
259 | sig |= 1; | ||
260 | } | ||
261 | return sig; | ||
262 | @@ -XXX,XX +XXX,XX @@ static void v7m_exception_taken(ARMCPU *cpu, uint32_t lr, bool dotailchain, | ||
263 | |||
264 | if (dotailchain) { | ||
265 | /* Sanitize LR FType and PREFIX bits */ | ||
266 | - if (!arm_feature(env, ARM_FEATURE_VFP)) { | ||
267 | + if (!cpu_isar_feature(aa32_simd_r16, cpu)) { | ||
268 | lr |= R_V7M_EXCRET_FTYPE_MASK; | ||
269 | } | ||
270 | lr = deposit32(lr, 24, 8, 0xff); | ||
271 | @@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu) | ||
272 | |||
273 | ftype = excret & R_V7M_EXCRET_FTYPE_MASK; | ||
274 | |||
275 | - if (!arm_feature(env, ARM_FEATURE_VFP) && !ftype) { | ||
276 | + if (!ftype && !cpu_isar_feature(aa32_simd_r16, cpu)) { | ||
277 | qemu_log_mask(LOG_GUEST_ERROR, "M profile: zero FTYPE in exception " | ||
278 | "exit PC value 0x%" PRIx32 " is UNPREDICTABLE " | ||
279 | "if FPU not present\n", | ||
280 | @@ -XXX,XX +XXX,XX @@ void HELPER(v7m_msr)(CPUARMState *env, uint32_t maskreg, uint32_t val) | ||
281 | * SFPA is RAZ/WI from NS. FPCA is RO if NSACR.CP10 == 0, | ||
282 | * RES0 if the FPU is not present, and is stored in the S bank | ||
283 | */ | ||
284 | - if (arm_feature(env, ARM_FEATURE_VFP) && | ||
285 | + if (cpu_isar_feature(aa32_simd_r16, env_archcpu(env)) && | ||
286 | extract32(env->v7m.nsacr, 10, 1)) { | ||
287 | env->v7m.control[M_REG_S] &= ~R_V7M_CONTROL_FPCA_MASK; | ||
288 | env->v7m.control[M_REG_S] |= val & R_V7M_CONTROL_FPCA_MASK; | ||
289 | @@ -XXX,XX +XXX,XX @@ void HELPER(v7m_msr)(CPUARMState *env, uint32_t maskreg, uint32_t val) | ||
290 | env->v7m.control[env->v7m.secure] &= ~R_V7M_CONTROL_NPRIV_MASK; | ||
291 | env->v7m.control[env->v7m.secure] |= val & R_V7M_CONTROL_NPRIV_MASK; | ||
292 | } | ||
293 | - if (arm_feature(env, ARM_FEATURE_VFP)) { | ||
294 | + if (cpu_isar_feature(aa32_simd_r16, env_archcpu(env))) { | ||
295 | /* | ||
296 | * SFPA is RAZ/WI from NS or if no FPU. | ||
297 | * FPCA is RO if NSACR.CP10 == 0, RES0 if the FPU is not present. | ||
298 | diff --git a/target/arm/machine.c b/target/arm/machine.c | ||
299 | index XXXXXXX..XXXXXXX 100644 | ||
300 | --- a/target/arm/machine.c | ||
301 | +++ b/target/arm/machine.c | ||
17 | @@ -XXX,XX +XXX,XX @@ | 302 | @@ -XXX,XX +XXX,XX @@ |
18 | #ifndef HW_PL011_H | 303 | static bool vfp_needed(void *opaque) |
19 | #define HW_PL011_H | 304 | { |
20 | 305 | ARMCPU *cpu = opaque; | |
21 | +#include "hw/sysbus.h" | 306 | - CPUARMState *env = &cpu->env; |
22 | +#include "chardev/char-fe.h" | 307 | |
23 | + | 308 | - return arm_feature(env, ARM_FEATURE_VFP); |
24 | +#define TYPE_PL011 "pl011" | 309 | + return cpu_isar_feature(aa32_simd_r16, cpu); |
25 | +#define PL011(obj) OBJECT_CHECK(PL011State, (obj), TYPE_PL011) | ||
26 | + | ||
27 | +/* This shares the same struct (and cast macro) as the base pl011 device */ | ||
28 | +#define TYPE_PL011_LUMINARY "pl011_luminary" | ||
29 | + | ||
30 | +typedef struct PL011State { | ||
31 | + SysBusDevice parent_obj; | ||
32 | + | ||
33 | + MemoryRegion iomem; | ||
34 | + uint32_t readbuff; | ||
35 | + uint32_t flags; | ||
36 | + uint32_t lcr; | ||
37 | + uint32_t rsr; | ||
38 | + uint32_t cr; | ||
39 | + uint32_t dmacr; | ||
40 | + uint32_t int_enabled; | ||
41 | + uint32_t int_level; | ||
42 | + uint32_t read_fifo[16]; | ||
43 | + uint32_t ilpr; | ||
44 | + uint32_t ibrd; | ||
45 | + uint32_t fbrd; | ||
46 | + uint32_t ifl; | ||
47 | + int read_pos; | ||
48 | + int read_count; | ||
49 | + int read_trigger; | ||
50 | + CharBackend chr; | ||
51 | + qemu_irq irq; | ||
52 | + const unsigned char *id; | ||
53 | +} PL011State; | ||
54 | + | ||
55 | static inline DeviceState *pl011_create(hwaddr addr, | ||
56 | qemu_irq irq, | ||
57 | Chardev *chr) | ||
58 | diff --git a/hw/char/pl011.c b/hw/char/pl011.c | ||
59 | index XXXXXXX..XXXXXXX 100644 | ||
60 | --- a/hw/char/pl011.c | ||
61 | +++ b/hw/char/pl011.c | ||
62 | @@ -XXX,XX +XXX,XX @@ | ||
63 | */ | ||
64 | |||
65 | #include "qemu/osdep.h" | ||
66 | +#include "hw/char/pl011.h" | ||
67 | #include "hw/sysbus.h" | ||
68 | #include "chardev/char-fe.h" | ||
69 | #include "qemu/log.h" | ||
70 | #include "trace.h" | ||
71 | |||
72 | -#define TYPE_PL011 "pl011" | ||
73 | -#define PL011(obj) OBJECT_CHECK(PL011State, (obj), TYPE_PL011) | ||
74 | - | ||
75 | -typedef struct PL011State { | ||
76 | - SysBusDevice parent_obj; | ||
77 | - | ||
78 | - MemoryRegion iomem; | ||
79 | - uint32_t readbuff; | ||
80 | - uint32_t flags; | ||
81 | - uint32_t lcr; | ||
82 | - uint32_t rsr; | ||
83 | - uint32_t cr; | ||
84 | - uint32_t dmacr; | ||
85 | - uint32_t int_enabled; | ||
86 | - uint32_t int_level; | ||
87 | - uint32_t read_fifo[16]; | ||
88 | - uint32_t ilpr; | ||
89 | - uint32_t ibrd; | ||
90 | - uint32_t fbrd; | ||
91 | - uint32_t ifl; | ||
92 | - int read_pos; | ||
93 | - int read_count; | ||
94 | - int read_trigger; | ||
95 | - CharBackend chr; | ||
96 | - qemu_irq irq; | ||
97 | - const unsigned char *id; | ||
98 | -} PL011State; | ||
99 | - | ||
100 | #define PL011_INT_TX 0x20 | ||
101 | #define PL011_INT_RX 0x10 | ||
102 | |||
103 | @@ -XXX,XX +XXX,XX @@ static void pl011_luminary_init(Object *obj) | ||
104 | } | 310 | } |
105 | 311 | ||
106 | static const TypeInfo pl011_luminary_info = { | 312 | static int get_fpscr(QEMUFile *f, void *opaque, size_t size, |
107 | - .name = "pl011_luminary", | ||
108 | + .name = TYPE_PL011_LUMINARY, | ||
109 | .parent = TYPE_PL011, | ||
110 | .instance_init = pl011_luminary_init, | ||
111 | }; | ||
112 | -- | 313 | -- |
113 | 2.20.1 | 314 | 2.20.1 |
114 | 315 | ||
115 | 316 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | 1 | From: Richard Henderson <richard.henderson@linaro.org> | |
2 | |||
3 | The old name, isar_feature_aa32_fpdp, does not reflect | ||
4 | that the test includes VFPv2. We will introduce further | ||
5 | feature tests for VFPv3. | ||
6 | |||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
9 | Message-id: 20200214181547.21408-7-richard.henderson@linaro.org | ||
10 | [PMM: fixed grammar in commit message] | ||
11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | --- | ||
14 | target/arm/cpu.h | 4 ++-- | ||
15 | target/arm/translate-vfp.inc.c | 40 +++++++++++++++++----------------- | ||
16 | 2 files changed, 22 insertions(+), 22 deletions(-) | ||
17 | |||
18 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
19 | index XXXXXXX..XXXXXXX 100644 | ||
20 | --- a/target/arm/cpu.h | ||
21 | +++ b/target/arm/cpu.h | ||
22 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa32_fpshvec(const ARMISARegisters *id) | ||
23 | return FIELD_EX32(id->mvfr0, MVFR0, FPSHVEC) > 0; | ||
24 | } | ||
25 | |||
26 | -static inline bool isar_feature_aa32_fpdp(const ARMISARegisters *id) | ||
27 | +static inline bool isar_feature_aa32_fpdp_v2(const ARMISARegisters *id) | ||
28 | { | ||
29 | - /* Return true if CPU supports double precision floating point */ | ||
30 | + /* Return true if CPU supports double precision floating point, VFPv2 */ | ||
31 | return FIELD_EX32(id->mvfr0, MVFR0, FPDP) > 0; | ||
32 | } | ||
33 | |||
34 | diff --git a/target/arm/translate-vfp.inc.c b/target/arm/translate-vfp.inc.c | ||
35 | index XXXXXXX..XXXXXXX 100644 | ||
36 | --- a/target/arm/translate-vfp.inc.c | ||
37 | +++ b/target/arm/translate-vfp.inc.c | ||
38 | @@ -XXX,XX +XXX,XX @@ static bool trans_VSEL(DisasContext *s, arg_VSEL *a) | ||
39 | return false; | ||
40 | } | ||
41 | |||
42 | - if (dp && !dc_isar_feature(aa32_fpdp, s)) { | ||
43 | + if (dp && !dc_isar_feature(aa32_fpdp_v2, s)) { | ||
44 | return false; | ||
45 | } | ||
46 | |||
47 | @@ -XXX,XX +XXX,XX @@ static bool trans_VMINMAXNM(DisasContext *s, arg_VMINMAXNM *a) | ||
48 | return false; | ||
49 | } | ||
50 | |||
51 | - if (dp && !dc_isar_feature(aa32_fpdp, s)) { | ||
52 | + if (dp && !dc_isar_feature(aa32_fpdp_v2, s)) { | ||
53 | return false; | ||
54 | } | ||
55 | |||
56 | @@ -XXX,XX +XXX,XX @@ static bool trans_VRINT(DisasContext *s, arg_VRINT *a) | ||
57 | return false; | ||
58 | } | ||
59 | |||
60 | - if (dp && !dc_isar_feature(aa32_fpdp, s)) { | ||
61 | + if (dp && !dc_isar_feature(aa32_fpdp_v2, s)) { | ||
62 | return false; | ||
63 | } | ||
64 | |||
65 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT(DisasContext *s, arg_VCVT *a) | ||
66 | return false; | ||
67 | } | ||
68 | |||
69 | - if (dp && !dc_isar_feature(aa32_fpdp, s)) { | ||
70 | + if (dp && !dc_isar_feature(aa32_fpdp_v2, s)) { | ||
71 | return false; | ||
72 | } | ||
73 | |||
74 | @@ -XXX,XX +XXX,XX @@ static bool do_vfp_3op_dp(DisasContext *s, VFPGen3OpDPFn *fn, | ||
75 | return false; | ||
76 | } | ||
77 | |||
78 | - if (!dc_isar_feature(aa32_fpdp, s)) { | ||
79 | + if (!dc_isar_feature(aa32_fpdp_v2, s)) { | ||
80 | return false; | ||
81 | } | ||
82 | |||
83 | @@ -XXX,XX +XXX,XX @@ static bool do_vfp_2op_dp(DisasContext *s, VFPGen2OpDPFn *fn, int vd, int vm) | ||
84 | return false; | ||
85 | } | ||
86 | |||
87 | - if (!dc_isar_feature(aa32_fpdp, s)) { | ||
88 | + if (!dc_isar_feature(aa32_fpdp_v2, s)) { | ||
89 | return false; | ||
90 | } | ||
91 | |||
92 | @@ -XXX,XX +XXX,XX @@ static bool trans_VFM_dp(DisasContext *s, arg_VFM_dp *a) | ||
93 | return false; | ||
94 | } | ||
95 | |||
96 | - if (!dc_isar_feature(aa32_fpdp, s)) { | ||
97 | + if (!dc_isar_feature(aa32_fpdp_v2, s)) { | ||
98 | return false; | ||
99 | } | ||
100 | |||
101 | @@ -XXX,XX +XXX,XX @@ static bool trans_VMOV_imm_dp(DisasContext *s, arg_VMOV_imm_dp *a) | ||
102 | return false; | ||
103 | } | ||
104 | |||
105 | - if (!dc_isar_feature(aa32_fpdp, s)) { | ||
106 | + if (!dc_isar_feature(aa32_fpdp_v2, s)) { | ||
107 | return false; | ||
108 | } | ||
109 | |||
110 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCMP_dp(DisasContext *s, arg_VCMP_dp *a) | ||
111 | return false; | ||
112 | } | ||
113 | |||
114 | - if (!dc_isar_feature(aa32_fpdp, s)) { | ||
115 | + if (!dc_isar_feature(aa32_fpdp_v2, s)) { | ||
116 | return false; | ||
117 | } | ||
118 | |||
119 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_f64_f16(DisasContext *s, arg_VCVT_f64_f16 *a) | ||
120 | return false; | ||
121 | } | ||
122 | |||
123 | - if (!dc_isar_feature(aa32_fpdp, s)) { | ||
124 | + if (!dc_isar_feature(aa32_fpdp_v2, s)) { | ||
125 | return false; | ||
126 | } | ||
127 | |||
128 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_f16_f64(DisasContext *s, arg_VCVT_f16_f64 *a) | ||
129 | return false; | ||
130 | } | ||
131 | |||
132 | - if (!dc_isar_feature(aa32_fpdp, s)) { | ||
133 | + if (!dc_isar_feature(aa32_fpdp_v2, s)) { | ||
134 | return false; | ||
135 | } | ||
136 | |||
137 | @@ -XXX,XX +XXX,XX @@ static bool trans_VRINTR_dp(DisasContext *s, arg_VRINTR_dp *a) | ||
138 | return false; | ||
139 | } | ||
140 | |||
141 | - if (!dc_isar_feature(aa32_fpdp, s)) { | ||
142 | + if (!dc_isar_feature(aa32_fpdp_v2, s)) { | ||
143 | return false; | ||
144 | } | ||
145 | |||
146 | @@ -XXX,XX +XXX,XX @@ static bool trans_VRINTZ_dp(DisasContext *s, arg_VRINTZ_dp *a) | ||
147 | return false; | ||
148 | } | ||
149 | |||
150 | - if (!dc_isar_feature(aa32_fpdp, s)) { | ||
151 | + if (!dc_isar_feature(aa32_fpdp_v2, s)) { | ||
152 | return false; | ||
153 | } | ||
154 | |||
155 | @@ -XXX,XX +XXX,XX @@ static bool trans_VRINTX_dp(DisasContext *s, arg_VRINTX_dp *a) | ||
156 | return false; | ||
157 | } | ||
158 | |||
159 | - if (!dc_isar_feature(aa32_fpdp, s)) { | ||
160 | + if (!dc_isar_feature(aa32_fpdp_v2, s)) { | ||
161 | return false; | ||
162 | } | ||
163 | |||
164 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_sp(DisasContext *s, arg_VCVT_sp *a) | ||
165 | return false; | ||
166 | } | ||
167 | |||
168 | - if (!dc_isar_feature(aa32_fpdp, s)) { | ||
169 | + if (!dc_isar_feature(aa32_fpdp_v2, s)) { | ||
170 | return false; | ||
171 | } | ||
172 | |||
173 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_dp(DisasContext *s, arg_VCVT_dp *a) | ||
174 | return false; | ||
175 | } | ||
176 | |||
177 | - if (!dc_isar_feature(aa32_fpdp, s)) { | ||
178 | + if (!dc_isar_feature(aa32_fpdp_v2, s)) { | ||
179 | return false; | ||
180 | } | ||
181 | |||
182 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_int_dp(DisasContext *s, arg_VCVT_int_dp *a) | ||
183 | return false; | ||
184 | } | ||
185 | |||
186 | - if (!dc_isar_feature(aa32_fpdp, s)) { | ||
187 | + if (!dc_isar_feature(aa32_fpdp_v2, s)) { | ||
188 | return false; | ||
189 | } | ||
190 | |||
191 | @@ -XXX,XX +XXX,XX @@ static bool trans_VJCVT(DisasContext *s, arg_VJCVT *a) | ||
192 | return false; | ||
193 | } | ||
194 | |||
195 | - if (!dc_isar_feature(aa32_fpdp, s)) { | ||
196 | + if (!dc_isar_feature(aa32_fpdp_v2, s)) { | ||
197 | return false; | ||
198 | } | ||
199 | |||
200 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_fix_dp(DisasContext *s, arg_VCVT_fix_dp *a) | ||
201 | return false; | ||
202 | } | ||
203 | |||
204 | - if (!dc_isar_feature(aa32_fpdp, s)) { | ||
205 | + if (!dc_isar_feature(aa32_fpdp_v2, s)) { | ||
206 | return false; | ||
207 | } | ||
208 | |||
209 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_dp_int(DisasContext *s, arg_VCVT_dp_int *a) | ||
210 | return false; | ||
211 | } | ||
212 | |||
213 | - if (!dc_isar_feature(aa32_fpdp, s)) { | ||
214 | + if (!dc_isar_feature(aa32_fpdp_v2, s)) { | ||
215 | return false; | ||
216 | } | ||
217 | |||
218 | -- | ||
219 | 2.20.1 | ||
220 | |||
221 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Move all of the fp helpers out of helper.c into a new file. | 3 | We will shortly use these to test for VFPv2 and VFPv3 |
4 | This is code movement only. Since helper.c has no copyright | 4 | in different situations. |
5 | header, take the one from cpu.h for the new file. | ||
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: 20190215192302.27855-3-richard.henderson@linaro.org | 7 | Message-id: 20200214181547.21408-8-richard.henderson@linaro.org |
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Reviewed-by: Peter Maydell <peter.maydell@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/Makefile.objs | 2 +- | 11 | target/arm/cpu.h | 18 ++++++++++++++++++ |
13 | target/arm/helper.c | 1062 ------------------------------------- | 12 | 1 file changed, 18 insertions(+) |
14 | target/arm/vfp_helper.c | 1088 ++++++++++++++++++++++++++++++++++++++ | ||
15 | 3 files changed, 1089 insertions(+), 1063 deletions(-) | ||
16 | create mode 100644 target/arm/vfp_helper.c | ||
17 | 13 | ||
18 | diff --git a/target/arm/Makefile.objs b/target/arm/Makefile.objs | 14 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
19 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/target/arm/Makefile.objs | 16 | --- a/target/arm/cpu.h |
21 | +++ b/target/arm/Makefile.objs | 17 | +++ b/target/arm/cpu.h |
22 | @@ -XXX,XX +XXX,XX @@ obj-$(call land,$(CONFIG_KVM),$(call lnot,$(TARGET_AARCH64))) += kvm32.o | 18 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa32_fpshvec(const ARMISARegisters *id) |
23 | obj-$(call land,$(CONFIG_KVM),$(TARGET_AARCH64)) += kvm64.o | 19 | return FIELD_EX32(id->mvfr0, MVFR0, FPSHVEC) > 0; |
24 | obj-$(call lnot,$(CONFIG_KVM)) += kvm-stub.o | ||
25 | obj-y += translate.o op_helper.o helper.o cpu.o | ||
26 | -obj-y += neon_helper.o iwmmxt_helper.o vec_helper.o | ||
27 | +obj-y += neon_helper.o iwmmxt_helper.o vec_helper.o vfp_helper.o | ||
28 | obj-y += gdbstub.o | ||
29 | obj-$(TARGET_AARCH64) += cpu64.o translate-a64.o helper-a64.o gdbstub64.o | ||
30 | obj-$(TARGET_AARCH64) += pauth_helper.o | ||
31 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
32 | index XXXXXXX..XXXXXXX 100644 | ||
33 | --- a/target/arm/helper.c | ||
34 | +++ b/target/arm/helper.c | ||
35 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(sel_flags)(uint32_t flags, uint32_t a, uint32_t b) | ||
36 | return (a & mask) | (b & ~mask); | ||
37 | } | 20 | } |
38 | 21 | ||
39 | -/* VFP support. We follow the convention used for VFP instructions: | 22 | +static inline bool isar_feature_aa32_fpsp_v2(const ARMISARegisters *id) |
40 | - Single precision routines have a "s" suffix, double precision a | ||
41 | - "d" suffix. */ | ||
42 | - | ||
43 | -/* Convert host exception flags to vfp form. */ | ||
44 | -static inline int vfp_exceptbits_from_host(int host_bits) | ||
45 | -{ | ||
46 | - int target_bits = 0; | ||
47 | - | ||
48 | - if (host_bits & float_flag_invalid) | ||
49 | - target_bits |= 1; | ||
50 | - if (host_bits & float_flag_divbyzero) | ||
51 | - target_bits |= 2; | ||
52 | - if (host_bits & float_flag_overflow) | ||
53 | - target_bits |= 4; | ||
54 | - if (host_bits & (float_flag_underflow | float_flag_output_denormal)) | ||
55 | - target_bits |= 8; | ||
56 | - if (host_bits & float_flag_inexact) | ||
57 | - target_bits |= 0x10; | ||
58 | - if (host_bits & float_flag_input_denormal) | ||
59 | - target_bits |= 0x80; | ||
60 | - return target_bits; | ||
61 | -} | ||
62 | - | ||
63 | -uint32_t HELPER(vfp_get_fpscr)(CPUARMState *env) | ||
64 | -{ | ||
65 | - uint32_t i, fpscr; | ||
66 | - | ||
67 | - fpscr = env->vfp.xregs[ARM_VFP_FPSCR] | ||
68 | - | (env->vfp.vec_len << 16) | ||
69 | - | (env->vfp.vec_stride << 20); | ||
70 | - | ||
71 | - i = get_float_exception_flags(&env->vfp.fp_status); | ||
72 | - i |= get_float_exception_flags(&env->vfp.standard_fp_status); | ||
73 | - /* FZ16 does not generate an input denormal exception. */ | ||
74 | - i |= (get_float_exception_flags(&env->vfp.fp_status_f16) | ||
75 | - & ~float_flag_input_denormal); | ||
76 | - fpscr |= vfp_exceptbits_from_host(i); | ||
77 | - | ||
78 | - i = env->vfp.qc[0] | env->vfp.qc[1] | env->vfp.qc[2] | env->vfp.qc[3]; | ||
79 | - fpscr |= i ? FPCR_QC : 0; | ||
80 | - | ||
81 | - return fpscr; | ||
82 | -} | ||
83 | - | ||
84 | -uint32_t vfp_get_fpscr(CPUARMState *env) | ||
85 | -{ | ||
86 | - return HELPER(vfp_get_fpscr)(env); | ||
87 | -} | ||
88 | - | ||
89 | -/* Convert vfp exception flags to target form. */ | ||
90 | -static inline int vfp_exceptbits_to_host(int target_bits) | ||
91 | -{ | ||
92 | - int host_bits = 0; | ||
93 | - | ||
94 | - if (target_bits & 1) | ||
95 | - host_bits |= float_flag_invalid; | ||
96 | - if (target_bits & 2) | ||
97 | - host_bits |= float_flag_divbyzero; | ||
98 | - if (target_bits & 4) | ||
99 | - host_bits |= float_flag_overflow; | ||
100 | - if (target_bits & 8) | ||
101 | - host_bits |= float_flag_underflow; | ||
102 | - if (target_bits & 0x10) | ||
103 | - host_bits |= float_flag_inexact; | ||
104 | - if (target_bits & 0x80) | ||
105 | - host_bits |= float_flag_input_denormal; | ||
106 | - return host_bits; | ||
107 | -} | ||
108 | - | ||
109 | -void HELPER(vfp_set_fpscr)(CPUARMState *env, uint32_t val) | ||
110 | -{ | ||
111 | - int i; | ||
112 | - uint32_t changed = env->vfp.xregs[ARM_VFP_FPSCR]; | ||
113 | - | ||
114 | - /* When ARMv8.2-FP16 is not supported, FZ16 is RES0. */ | ||
115 | - if (!cpu_isar_feature(aa64_fp16, arm_env_get_cpu(env))) { | ||
116 | - val &= ~FPCR_FZ16; | ||
117 | - } | ||
118 | - | ||
119 | - /* | ||
120 | - * We don't implement trapped exception handling, so the | ||
121 | - * trap enable bits, IDE|IXE|UFE|OFE|DZE|IOE are all RAZ/WI (not RES0!) | ||
122 | - * | ||
123 | - * If we exclude the exception flags, IOC|DZC|OFC|UFC|IXC|IDC | ||
124 | - * (which are stored in fp_status), and the other RES0 bits | ||
125 | - * in between, then we clear all of the low 16 bits. | ||
126 | - */ | ||
127 | - env->vfp.xregs[ARM_VFP_FPSCR] = val & 0xf7c80000; | ||
128 | - env->vfp.vec_len = (val >> 16) & 7; | ||
129 | - env->vfp.vec_stride = (val >> 20) & 3; | ||
130 | - | ||
131 | - /* | ||
132 | - * The bit we set within fpscr_q is arbitrary; the register as a | ||
133 | - * whole being zero/non-zero is what counts. | ||
134 | - */ | ||
135 | - env->vfp.qc[0] = val & FPCR_QC; | ||
136 | - env->vfp.qc[1] = 0; | ||
137 | - env->vfp.qc[2] = 0; | ||
138 | - env->vfp.qc[3] = 0; | ||
139 | - | ||
140 | - changed ^= val; | ||
141 | - if (changed & (3 << 22)) { | ||
142 | - i = (val >> 22) & 3; | ||
143 | - switch (i) { | ||
144 | - case FPROUNDING_TIEEVEN: | ||
145 | - i = float_round_nearest_even; | ||
146 | - break; | ||
147 | - case FPROUNDING_POSINF: | ||
148 | - i = float_round_up; | ||
149 | - break; | ||
150 | - case FPROUNDING_NEGINF: | ||
151 | - i = float_round_down; | ||
152 | - break; | ||
153 | - case FPROUNDING_ZERO: | ||
154 | - i = float_round_to_zero; | ||
155 | - break; | ||
156 | - } | ||
157 | - set_float_rounding_mode(i, &env->vfp.fp_status); | ||
158 | - set_float_rounding_mode(i, &env->vfp.fp_status_f16); | ||
159 | - } | ||
160 | - if (changed & FPCR_FZ16) { | ||
161 | - bool ftz_enabled = val & FPCR_FZ16; | ||
162 | - set_flush_to_zero(ftz_enabled, &env->vfp.fp_status_f16); | ||
163 | - set_flush_inputs_to_zero(ftz_enabled, &env->vfp.fp_status_f16); | ||
164 | - } | ||
165 | - if (changed & FPCR_FZ) { | ||
166 | - bool ftz_enabled = val & FPCR_FZ; | ||
167 | - set_flush_to_zero(ftz_enabled, &env->vfp.fp_status); | ||
168 | - set_flush_inputs_to_zero(ftz_enabled, &env->vfp.fp_status); | ||
169 | - } | ||
170 | - if (changed & FPCR_DN) { | ||
171 | - bool dnan_enabled = val & FPCR_DN; | ||
172 | - set_default_nan_mode(dnan_enabled, &env->vfp.fp_status); | ||
173 | - set_default_nan_mode(dnan_enabled, &env->vfp.fp_status_f16); | ||
174 | - } | ||
175 | - | ||
176 | - /* The exception flags are ORed together when we read fpscr so we | ||
177 | - * only need to preserve the current state in one of our | ||
178 | - * float_status values. | ||
179 | - */ | ||
180 | - i = vfp_exceptbits_to_host(val); | ||
181 | - set_float_exception_flags(i, &env->vfp.fp_status); | ||
182 | - set_float_exception_flags(0, &env->vfp.fp_status_f16); | ||
183 | - set_float_exception_flags(0, &env->vfp.standard_fp_status); | ||
184 | -} | ||
185 | - | ||
186 | -void vfp_set_fpscr(CPUARMState *env, uint32_t val) | ||
187 | -{ | ||
188 | - HELPER(vfp_set_fpscr)(env, val); | ||
189 | -} | ||
190 | - | ||
191 | -#define VFP_HELPER(name, p) HELPER(glue(glue(vfp_,name),p)) | ||
192 | - | ||
193 | -#define VFP_BINOP(name) \ | ||
194 | -float32 VFP_HELPER(name, s)(float32 a, float32 b, void *fpstp) \ | ||
195 | -{ \ | ||
196 | - float_status *fpst = fpstp; \ | ||
197 | - return float32_ ## name(a, b, fpst); \ | ||
198 | -} \ | ||
199 | -float64 VFP_HELPER(name, d)(float64 a, float64 b, void *fpstp) \ | ||
200 | -{ \ | ||
201 | - float_status *fpst = fpstp; \ | ||
202 | - return float64_ ## name(a, b, fpst); \ | ||
203 | -} | ||
204 | -VFP_BINOP(add) | ||
205 | -VFP_BINOP(sub) | ||
206 | -VFP_BINOP(mul) | ||
207 | -VFP_BINOP(div) | ||
208 | -VFP_BINOP(min) | ||
209 | -VFP_BINOP(max) | ||
210 | -VFP_BINOP(minnum) | ||
211 | -VFP_BINOP(maxnum) | ||
212 | -#undef VFP_BINOP | ||
213 | - | ||
214 | -float32 VFP_HELPER(neg, s)(float32 a) | ||
215 | -{ | ||
216 | - return float32_chs(a); | ||
217 | -} | ||
218 | - | ||
219 | -float64 VFP_HELPER(neg, d)(float64 a) | ||
220 | -{ | ||
221 | - return float64_chs(a); | ||
222 | -} | ||
223 | - | ||
224 | -float32 VFP_HELPER(abs, s)(float32 a) | ||
225 | -{ | ||
226 | - return float32_abs(a); | ||
227 | -} | ||
228 | - | ||
229 | -float64 VFP_HELPER(abs, d)(float64 a) | ||
230 | -{ | ||
231 | - return float64_abs(a); | ||
232 | -} | ||
233 | - | ||
234 | -float32 VFP_HELPER(sqrt, s)(float32 a, CPUARMState *env) | ||
235 | -{ | ||
236 | - return float32_sqrt(a, &env->vfp.fp_status); | ||
237 | -} | ||
238 | - | ||
239 | -float64 VFP_HELPER(sqrt, d)(float64 a, CPUARMState *env) | ||
240 | -{ | ||
241 | - return float64_sqrt(a, &env->vfp.fp_status); | ||
242 | -} | ||
243 | - | ||
244 | -static void softfloat_to_vfp_compare(CPUARMState *env, int cmp) | ||
245 | -{ | ||
246 | - uint32_t flags; | ||
247 | - switch (cmp) { | ||
248 | - case float_relation_equal: | ||
249 | - flags = 0x6; | ||
250 | - break; | ||
251 | - case float_relation_less: | ||
252 | - flags = 0x8; | ||
253 | - break; | ||
254 | - case float_relation_greater: | ||
255 | - flags = 0x2; | ||
256 | - break; | ||
257 | - case float_relation_unordered: | ||
258 | - flags = 0x3; | ||
259 | - break; | ||
260 | - default: | ||
261 | - g_assert_not_reached(); | ||
262 | - } | ||
263 | - env->vfp.xregs[ARM_VFP_FPSCR] = | ||
264 | - deposit32(env->vfp.xregs[ARM_VFP_FPSCR], 28, 4, flags); | ||
265 | -} | ||
266 | - | ||
267 | -/* XXX: check quiet/signaling case */ | ||
268 | -#define DO_VFP_cmp(p, type) \ | ||
269 | -void VFP_HELPER(cmp, p)(type a, type b, CPUARMState *env) \ | ||
270 | -{ \ | ||
271 | - softfloat_to_vfp_compare(env, \ | ||
272 | - type ## _compare_quiet(a, b, &env->vfp.fp_status)); \ | ||
273 | -} \ | ||
274 | -void VFP_HELPER(cmpe, p)(type a, type b, CPUARMState *env) \ | ||
275 | -{ \ | ||
276 | - softfloat_to_vfp_compare(env, \ | ||
277 | - type ## _compare(a, b, &env->vfp.fp_status)); \ | ||
278 | -} | ||
279 | -DO_VFP_cmp(s, float32) | ||
280 | -DO_VFP_cmp(d, float64) | ||
281 | -#undef DO_VFP_cmp | ||
282 | - | ||
283 | -/* Integer to float and float to integer conversions */ | ||
284 | - | ||
285 | -#define CONV_ITOF(name, ftype, fsz, sign) \ | ||
286 | -ftype HELPER(name)(uint32_t x, void *fpstp) \ | ||
287 | -{ \ | ||
288 | - float_status *fpst = fpstp; \ | ||
289 | - return sign##int32_to_##float##fsz((sign##int32_t)x, fpst); \ | ||
290 | -} | ||
291 | - | ||
292 | -#define CONV_FTOI(name, ftype, fsz, sign, round) \ | ||
293 | -sign##int32_t HELPER(name)(ftype x, void *fpstp) \ | ||
294 | -{ \ | ||
295 | - float_status *fpst = fpstp; \ | ||
296 | - if (float##fsz##_is_any_nan(x)) { \ | ||
297 | - float_raise(float_flag_invalid, fpst); \ | ||
298 | - return 0; \ | ||
299 | - } \ | ||
300 | - return float##fsz##_to_##sign##int32##round(x, fpst); \ | ||
301 | -} | ||
302 | - | ||
303 | -#define FLOAT_CONVS(name, p, ftype, fsz, sign) \ | ||
304 | - CONV_ITOF(vfp_##name##to##p, ftype, fsz, sign) \ | ||
305 | - CONV_FTOI(vfp_to##name##p, ftype, fsz, sign, ) \ | ||
306 | - CONV_FTOI(vfp_to##name##z##p, ftype, fsz, sign, _round_to_zero) | ||
307 | - | ||
308 | -FLOAT_CONVS(si, h, uint32_t, 16, ) | ||
309 | -FLOAT_CONVS(si, s, float32, 32, ) | ||
310 | -FLOAT_CONVS(si, d, float64, 64, ) | ||
311 | -FLOAT_CONVS(ui, h, uint32_t, 16, u) | ||
312 | -FLOAT_CONVS(ui, s, float32, 32, u) | ||
313 | -FLOAT_CONVS(ui, d, float64, 64, u) | ||
314 | - | ||
315 | -#undef CONV_ITOF | ||
316 | -#undef CONV_FTOI | ||
317 | -#undef FLOAT_CONVS | ||
318 | - | ||
319 | -/* floating point conversion */ | ||
320 | -float64 VFP_HELPER(fcvtd, s)(float32 x, CPUARMState *env) | ||
321 | -{ | ||
322 | - return float32_to_float64(x, &env->vfp.fp_status); | ||
323 | -} | ||
324 | - | ||
325 | -float32 VFP_HELPER(fcvts, d)(float64 x, CPUARMState *env) | ||
326 | -{ | ||
327 | - return float64_to_float32(x, &env->vfp.fp_status); | ||
328 | -} | ||
329 | - | ||
330 | -/* VFP3 fixed point conversion. */ | ||
331 | -#define VFP_CONV_FIX_FLOAT(name, p, fsz, isz, itype) \ | ||
332 | -float##fsz HELPER(vfp_##name##to##p)(uint##isz##_t x, uint32_t shift, \ | ||
333 | - void *fpstp) \ | ||
334 | -{ return itype##_to_##float##fsz##_scalbn(x, -shift, fpstp); } | ||
335 | - | ||
336 | -#define VFP_CONV_FLOAT_FIX_ROUND(name, p, fsz, isz, itype, ROUND, suff) \ | ||
337 | -uint##isz##_t HELPER(vfp_to##name##p##suff)(float##fsz x, uint32_t shift, \ | ||
338 | - void *fpst) \ | ||
339 | -{ \ | ||
340 | - if (unlikely(float##fsz##_is_any_nan(x))) { \ | ||
341 | - float_raise(float_flag_invalid, fpst); \ | ||
342 | - return 0; \ | ||
343 | - } \ | ||
344 | - return float##fsz##_to_##itype##_scalbn(x, ROUND, shift, fpst); \ | ||
345 | -} | ||
346 | - | ||
347 | -#define VFP_CONV_FIX(name, p, fsz, isz, itype) \ | ||
348 | -VFP_CONV_FIX_FLOAT(name, p, fsz, isz, itype) \ | ||
349 | -VFP_CONV_FLOAT_FIX_ROUND(name, p, fsz, isz, itype, \ | ||
350 | - float_round_to_zero, _round_to_zero) \ | ||
351 | -VFP_CONV_FLOAT_FIX_ROUND(name, p, fsz, isz, itype, \ | ||
352 | - get_float_rounding_mode(fpst), ) | ||
353 | - | ||
354 | -#define VFP_CONV_FIX_A64(name, p, fsz, isz, itype) \ | ||
355 | -VFP_CONV_FIX_FLOAT(name, p, fsz, isz, itype) \ | ||
356 | -VFP_CONV_FLOAT_FIX_ROUND(name, p, fsz, isz, itype, \ | ||
357 | - get_float_rounding_mode(fpst), ) | ||
358 | - | ||
359 | -VFP_CONV_FIX(sh, d, 64, 64, int16) | ||
360 | -VFP_CONV_FIX(sl, d, 64, 64, int32) | ||
361 | -VFP_CONV_FIX_A64(sq, d, 64, 64, int64) | ||
362 | -VFP_CONV_FIX(uh, d, 64, 64, uint16) | ||
363 | -VFP_CONV_FIX(ul, d, 64, 64, uint32) | ||
364 | -VFP_CONV_FIX_A64(uq, d, 64, 64, uint64) | ||
365 | -VFP_CONV_FIX(sh, s, 32, 32, int16) | ||
366 | -VFP_CONV_FIX(sl, s, 32, 32, int32) | ||
367 | -VFP_CONV_FIX_A64(sq, s, 32, 64, int64) | ||
368 | -VFP_CONV_FIX(uh, s, 32, 32, uint16) | ||
369 | -VFP_CONV_FIX(ul, s, 32, 32, uint32) | ||
370 | -VFP_CONV_FIX_A64(uq, s, 32, 64, uint64) | ||
371 | - | ||
372 | -#undef VFP_CONV_FIX | ||
373 | -#undef VFP_CONV_FIX_FLOAT | ||
374 | -#undef VFP_CONV_FLOAT_FIX_ROUND | ||
375 | -#undef VFP_CONV_FIX_A64 | ||
376 | - | ||
377 | -uint32_t HELPER(vfp_sltoh)(uint32_t x, uint32_t shift, void *fpst) | ||
378 | -{ | ||
379 | - return int32_to_float16_scalbn(x, -shift, fpst); | ||
380 | -} | ||
381 | - | ||
382 | -uint32_t HELPER(vfp_ultoh)(uint32_t x, uint32_t shift, void *fpst) | ||
383 | -{ | ||
384 | - return uint32_to_float16_scalbn(x, -shift, fpst); | ||
385 | -} | ||
386 | - | ||
387 | -uint32_t HELPER(vfp_sqtoh)(uint64_t x, uint32_t shift, void *fpst) | ||
388 | -{ | ||
389 | - return int64_to_float16_scalbn(x, -shift, fpst); | ||
390 | -} | ||
391 | - | ||
392 | -uint32_t HELPER(vfp_uqtoh)(uint64_t x, uint32_t shift, void *fpst) | ||
393 | -{ | ||
394 | - return uint64_to_float16_scalbn(x, -shift, fpst); | ||
395 | -} | ||
396 | - | ||
397 | -uint32_t HELPER(vfp_toshh)(uint32_t x, uint32_t shift, void *fpst) | ||
398 | -{ | ||
399 | - if (unlikely(float16_is_any_nan(x))) { | ||
400 | - float_raise(float_flag_invalid, fpst); | ||
401 | - return 0; | ||
402 | - } | ||
403 | - return float16_to_int16_scalbn(x, get_float_rounding_mode(fpst), | ||
404 | - shift, fpst); | ||
405 | -} | ||
406 | - | ||
407 | -uint32_t HELPER(vfp_touhh)(uint32_t x, uint32_t shift, void *fpst) | ||
408 | -{ | ||
409 | - if (unlikely(float16_is_any_nan(x))) { | ||
410 | - float_raise(float_flag_invalid, fpst); | ||
411 | - return 0; | ||
412 | - } | ||
413 | - return float16_to_uint16_scalbn(x, get_float_rounding_mode(fpst), | ||
414 | - shift, fpst); | ||
415 | -} | ||
416 | - | ||
417 | -uint32_t HELPER(vfp_toslh)(uint32_t x, uint32_t shift, void *fpst) | ||
418 | -{ | ||
419 | - if (unlikely(float16_is_any_nan(x))) { | ||
420 | - float_raise(float_flag_invalid, fpst); | ||
421 | - return 0; | ||
422 | - } | ||
423 | - return float16_to_int32_scalbn(x, get_float_rounding_mode(fpst), | ||
424 | - shift, fpst); | ||
425 | -} | ||
426 | - | ||
427 | -uint32_t HELPER(vfp_toulh)(uint32_t x, uint32_t shift, void *fpst) | ||
428 | -{ | ||
429 | - if (unlikely(float16_is_any_nan(x))) { | ||
430 | - float_raise(float_flag_invalid, fpst); | ||
431 | - return 0; | ||
432 | - } | ||
433 | - return float16_to_uint32_scalbn(x, get_float_rounding_mode(fpst), | ||
434 | - shift, fpst); | ||
435 | -} | ||
436 | - | ||
437 | -uint64_t HELPER(vfp_tosqh)(uint32_t x, uint32_t shift, void *fpst) | ||
438 | -{ | ||
439 | - if (unlikely(float16_is_any_nan(x))) { | ||
440 | - float_raise(float_flag_invalid, fpst); | ||
441 | - return 0; | ||
442 | - } | ||
443 | - return float16_to_int64_scalbn(x, get_float_rounding_mode(fpst), | ||
444 | - shift, fpst); | ||
445 | -} | ||
446 | - | ||
447 | -uint64_t HELPER(vfp_touqh)(uint32_t x, uint32_t shift, void *fpst) | ||
448 | -{ | ||
449 | - if (unlikely(float16_is_any_nan(x))) { | ||
450 | - float_raise(float_flag_invalid, fpst); | ||
451 | - return 0; | ||
452 | - } | ||
453 | - return float16_to_uint64_scalbn(x, get_float_rounding_mode(fpst), | ||
454 | - shift, fpst); | ||
455 | -} | ||
456 | - | ||
457 | -/* Set the current fp rounding mode and return the old one. | ||
458 | - * The argument is a softfloat float_round_ value. | ||
459 | - */ | ||
460 | -uint32_t HELPER(set_rmode)(uint32_t rmode, void *fpstp) | ||
461 | -{ | ||
462 | - float_status *fp_status = fpstp; | ||
463 | - | ||
464 | - uint32_t prev_rmode = get_float_rounding_mode(fp_status); | ||
465 | - set_float_rounding_mode(rmode, fp_status); | ||
466 | - | ||
467 | - return prev_rmode; | ||
468 | -} | ||
469 | - | ||
470 | -/* Set the current fp rounding mode in the standard fp status and return | ||
471 | - * the old one. This is for NEON instructions that need to change the | ||
472 | - * rounding mode but wish to use the standard FPSCR values for everything | ||
473 | - * else. Always set the rounding mode back to the correct value after | ||
474 | - * modifying it. | ||
475 | - * The argument is a softfloat float_round_ value. | ||
476 | - */ | ||
477 | -uint32_t HELPER(set_neon_rmode)(uint32_t rmode, CPUARMState *env) | ||
478 | -{ | ||
479 | - float_status *fp_status = &env->vfp.standard_fp_status; | ||
480 | - | ||
481 | - uint32_t prev_rmode = get_float_rounding_mode(fp_status); | ||
482 | - set_float_rounding_mode(rmode, fp_status); | ||
483 | - | ||
484 | - return prev_rmode; | ||
485 | -} | ||
486 | - | ||
487 | -/* Half precision conversions. */ | ||
488 | -float32 HELPER(vfp_fcvt_f16_to_f32)(uint32_t a, void *fpstp, uint32_t ahp_mode) | ||
489 | -{ | ||
490 | - /* Squash FZ16 to 0 for the duration of conversion. In this case, | ||
491 | - * it would affect flushing input denormals. | ||
492 | - */ | ||
493 | - float_status *fpst = fpstp; | ||
494 | - flag save = get_flush_inputs_to_zero(fpst); | ||
495 | - set_flush_inputs_to_zero(false, fpst); | ||
496 | - float32 r = float16_to_float32(a, !ahp_mode, fpst); | ||
497 | - set_flush_inputs_to_zero(save, fpst); | ||
498 | - return r; | ||
499 | -} | ||
500 | - | ||
501 | -uint32_t HELPER(vfp_fcvt_f32_to_f16)(float32 a, void *fpstp, uint32_t ahp_mode) | ||
502 | -{ | ||
503 | - /* Squash FZ16 to 0 for the duration of conversion. In this case, | ||
504 | - * it would affect flushing output denormals. | ||
505 | - */ | ||
506 | - float_status *fpst = fpstp; | ||
507 | - flag save = get_flush_to_zero(fpst); | ||
508 | - set_flush_to_zero(false, fpst); | ||
509 | - float16 r = float32_to_float16(a, !ahp_mode, fpst); | ||
510 | - set_flush_to_zero(save, fpst); | ||
511 | - return r; | ||
512 | -} | ||
513 | - | ||
514 | -float64 HELPER(vfp_fcvt_f16_to_f64)(uint32_t a, void *fpstp, uint32_t ahp_mode) | ||
515 | -{ | ||
516 | - /* Squash FZ16 to 0 for the duration of conversion. In this case, | ||
517 | - * it would affect flushing input denormals. | ||
518 | - */ | ||
519 | - float_status *fpst = fpstp; | ||
520 | - flag save = get_flush_inputs_to_zero(fpst); | ||
521 | - set_flush_inputs_to_zero(false, fpst); | ||
522 | - float64 r = float16_to_float64(a, !ahp_mode, fpst); | ||
523 | - set_flush_inputs_to_zero(save, fpst); | ||
524 | - return r; | ||
525 | -} | ||
526 | - | ||
527 | -uint32_t HELPER(vfp_fcvt_f64_to_f16)(float64 a, void *fpstp, uint32_t ahp_mode) | ||
528 | -{ | ||
529 | - /* Squash FZ16 to 0 for the duration of conversion. In this case, | ||
530 | - * it would affect flushing output denormals. | ||
531 | - */ | ||
532 | - float_status *fpst = fpstp; | ||
533 | - flag save = get_flush_to_zero(fpst); | ||
534 | - set_flush_to_zero(false, fpst); | ||
535 | - float16 r = float64_to_float16(a, !ahp_mode, fpst); | ||
536 | - set_flush_to_zero(save, fpst); | ||
537 | - return r; | ||
538 | -} | ||
539 | - | ||
540 | -#define float32_two make_float32(0x40000000) | ||
541 | -#define float32_three make_float32(0x40400000) | ||
542 | -#define float32_one_point_five make_float32(0x3fc00000) | ||
543 | - | ||
544 | -float32 HELPER(recps_f32)(float32 a, float32 b, CPUARMState *env) | ||
545 | -{ | ||
546 | - float_status *s = &env->vfp.standard_fp_status; | ||
547 | - if ((float32_is_infinity(a) && float32_is_zero_or_denormal(b)) || | ||
548 | - (float32_is_infinity(b) && float32_is_zero_or_denormal(a))) { | ||
549 | - if (!(float32_is_zero(a) || float32_is_zero(b))) { | ||
550 | - float_raise(float_flag_input_denormal, s); | ||
551 | - } | ||
552 | - return float32_two; | ||
553 | - } | ||
554 | - return float32_sub(float32_two, float32_mul(a, b, s), s); | ||
555 | -} | ||
556 | - | ||
557 | -float32 HELPER(rsqrts_f32)(float32 a, float32 b, CPUARMState *env) | ||
558 | -{ | ||
559 | - float_status *s = &env->vfp.standard_fp_status; | ||
560 | - float32 product; | ||
561 | - if ((float32_is_infinity(a) && float32_is_zero_or_denormal(b)) || | ||
562 | - (float32_is_infinity(b) && float32_is_zero_or_denormal(a))) { | ||
563 | - if (!(float32_is_zero(a) || float32_is_zero(b))) { | ||
564 | - float_raise(float_flag_input_denormal, s); | ||
565 | - } | ||
566 | - return float32_one_point_five; | ||
567 | - } | ||
568 | - product = float32_mul(a, b, s); | ||
569 | - return float32_div(float32_sub(float32_three, product, s), float32_two, s); | ||
570 | -} | ||
571 | - | ||
572 | -/* NEON helpers. */ | ||
573 | - | ||
574 | -/* Constants 256 and 512 are used in some helpers; we avoid relying on | ||
575 | - * int->float conversions at run-time. */ | ||
576 | -#define float64_256 make_float64(0x4070000000000000LL) | ||
577 | -#define float64_512 make_float64(0x4080000000000000LL) | ||
578 | -#define float16_maxnorm make_float16(0x7bff) | ||
579 | -#define float32_maxnorm make_float32(0x7f7fffff) | ||
580 | -#define float64_maxnorm make_float64(0x7fefffffffffffffLL) | ||
581 | - | ||
582 | -/* Reciprocal functions | ||
583 | - * | ||
584 | - * The algorithm that must be used to calculate the estimate | ||
585 | - * is specified by the ARM ARM, see FPRecipEstimate()/RecipEstimate | ||
586 | - */ | ||
587 | - | ||
588 | -/* See RecipEstimate() | ||
589 | - * | ||
590 | - * input is a 9 bit fixed point number | ||
591 | - * input range 256 .. 511 for a number from 0.5 <= x < 1.0. | ||
592 | - * result range 256 .. 511 for a number from 1.0 to 511/256. | ||
593 | - */ | ||
594 | - | ||
595 | -static int recip_estimate(int input) | ||
596 | -{ | ||
597 | - int a, b, r; | ||
598 | - assert(256 <= input && input < 512); | ||
599 | - a = (input * 2) + 1; | ||
600 | - b = (1 << 19) / a; | ||
601 | - r = (b + 1) >> 1; | ||
602 | - assert(256 <= r && r < 512); | ||
603 | - return r; | ||
604 | -} | ||
605 | - | ||
606 | -/* | ||
607 | - * Common wrapper to call recip_estimate | ||
608 | - * | ||
609 | - * The parameters are exponent and 64 bit fraction (without implicit | ||
610 | - * bit) where the binary point is nominally at bit 52. Returns a | ||
611 | - * float64 which can then be rounded to the appropriate size by the | ||
612 | - * callee. | ||
613 | - */ | ||
614 | - | ||
615 | -static uint64_t call_recip_estimate(int *exp, int exp_off, uint64_t frac) | ||
616 | -{ | ||
617 | - uint32_t scaled, estimate; | ||
618 | - uint64_t result_frac; | ||
619 | - int result_exp; | ||
620 | - | ||
621 | - /* Handle sub-normals */ | ||
622 | - if (*exp == 0) { | ||
623 | - if (extract64(frac, 51, 1) == 0) { | ||
624 | - *exp = -1; | ||
625 | - frac <<= 2; | ||
626 | - } else { | ||
627 | - frac <<= 1; | ||
628 | - } | ||
629 | - } | ||
630 | - | ||
631 | - /* scaled = UInt('1':fraction<51:44>) */ | ||
632 | - scaled = deposit32(1 << 8, 0, 8, extract64(frac, 44, 8)); | ||
633 | - estimate = recip_estimate(scaled); | ||
634 | - | ||
635 | - result_exp = exp_off - *exp; | ||
636 | - result_frac = deposit64(0, 44, 8, estimate); | ||
637 | - if (result_exp == 0) { | ||
638 | - result_frac = deposit64(result_frac >> 1, 51, 1, 1); | ||
639 | - } else if (result_exp == -1) { | ||
640 | - result_frac = deposit64(result_frac >> 2, 50, 2, 1); | ||
641 | - result_exp = 0; | ||
642 | - } | ||
643 | - | ||
644 | - *exp = result_exp; | ||
645 | - | ||
646 | - return result_frac; | ||
647 | -} | ||
648 | - | ||
649 | -static bool round_to_inf(float_status *fpst, bool sign_bit) | ||
650 | -{ | ||
651 | - switch (fpst->float_rounding_mode) { | ||
652 | - case float_round_nearest_even: /* Round to Nearest */ | ||
653 | - return true; | ||
654 | - case float_round_up: /* Round to +Inf */ | ||
655 | - return !sign_bit; | ||
656 | - case float_round_down: /* Round to -Inf */ | ||
657 | - return sign_bit; | ||
658 | - case float_round_to_zero: /* Round to Zero */ | ||
659 | - return false; | ||
660 | - } | ||
661 | - | ||
662 | - g_assert_not_reached(); | ||
663 | -} | ||
664 | - | ||
665 | -uint32_t HELPER(recpe_f16)(uint32_t input, void *fpstp) | ||
666 | -{ | ||
667 | - float_status *fpst = fpstp; | ||
668 | - float16 f16 = float16_squash_input_denormal(input, fpst); | ||
669 | - uint32_t f16_val = float16_val(f16); | ||
670 | - uint32_t f16_sign = float16_is_neg(f16); | ||
671 | - int f16_exp = extract32(f16_val, 10, 5); | ||
672 | - uint32_t f16_frac = extract32(f16_val, 0, 10); | ||
673 | - uint64_t f64_frac; | ||
674 | - | ||
675 | - if (float16_is_any_nan(f16)) { | ||
676 | - float16 nan = f16; | ||
677 | - if (float16_is_signaling_nan(f16, fpst)) { | ||
678 | - float_raise(float_flag_invalid, fpst); | ||
679 | - nan = float16_silence_nan(f16, fpst); | ||
680 | - } | ||
681 | - if (fpst->default_nan_mode) { | ||
682 | - nan = float16_default_nan(fpst); | ||
683 | - } | ||
684 | - return nan; | ||
685 | - } else if (float16_is_infinity(f16)) { | ||
686 | - return float16_set_sign(float16_zero, float16_is_neg(f16)); | ||
687 | - } else if (float16_is_zero(f16)) { | ||
688 | - float_raise(float_flag_divbyzero, fpst); | ||
689 | - return float16_set_sign(float16_infinity, float16_is_neg(f16)); | ||
690 | - } else if (float16_abs(f16) < (1 << 8)) { | ||
691 | - /* Abs(value) < 2.0^-16 */ | ||
692 | - float_raise(float_flag_overflow | float_flag_inexact, fpst); | ||
693 | - if (round_to_inf(fpst, f16_sign)) { | ||
694 | - return float16_set_sign(float16_infinity, f16_sign); | ||
695 | - } else { | ||
696 | - return float16_set_sign(float16_maxnorm, f16_sign); | ||
697 | - } | ||
698 | - } else if (f16_exp >= 29 && fpst->flush_to_zero) { | ||
699 | - float_raise(float_flag_underflow, fpst); | ||
700 | - return float16_set_sign(float16_zero, float16_is_neg(f16)); | ||
701 | - } | ||
702 | - | ||
703 | - f64_frac = call_recip_estimate(&f16_exp, 29, | ||
704 | - ((uint64_t) f16_frac) << (52 - 10)); | ||
705 | - | ||
706 | - /* result = sign : result_exp<4:0> : fraction<51:42> */ | ||
707 | - f16_val = deposit32(0, 15, 1, f16_sign); | ||
708 | - f16_val = deposit32(f16_val, 10, 5, f16_exp); | ||
709 | - f16_val = deposit32(f16_val, 0, 10, extract64(f64_frac, 52 - 10, 10)); | ||
710 | - return make_float16(f16_val); | ||
711 | -} | ||
712 | - | ||
713 | -float32 HELPER(recpe_f32)(float32 input, void *fpstp) | ||
714 | -{ | ||
715 | - float_status *fpst = fpstp; | ||
716 | - float32 f32 = float32_squash_input_denormal(input, fpst); | ||
717 | - uint32_t f32_val = float32_val(f32); | ||
718 | - bool f32_sign = float32_is_neg(f32); | ||
719 | - int f32_exp = extract32(f32_val, 23, 8); | ||
720 | - uint32_t f32_frac = extract32(f32_val, 0, 23); | ||
721 | - uint64_t f64_frac; | ||
722 | - | ||
723 | - if (float32_is_any_nan(f32)) { | ||
724 | - float32 nan = f32; | ||
725 | - if (float32_is_signaling_nan(f32, fpst)) { | ||
726 | - float_raise(float_flag_invalid, fpst); | ||
727 | - nan = float32_silence_nan(f32, fpst); | ||
728 | - } | ||
729 | - if (fpst->default_nan_mode) { | ||
730 | - nan = float32_default_nan(fpst); | ||
731 | - } | ||
732 | - return nan; | ||
733 | - } else if (float32_is_infinity(f32)) { | ||
734 | - return float32_set_sign(float32_zero, float32_is_neg(f32)); | ||
735 | - } else if (float32_is_zero(f32)) { | ||
736 | - float_raise(float_flag_divbyzero, fpst); | ||
737 | - return float32_set_sign(float32_infinity, float32_is_neg(f32)); | ||
738 | - } else if (float32_abs(f32) < (1ULL << 21)) { | ||
739 | - /* Abs(value) < 2.0^-128 */ | ||
740 | - float_raise(float_flag_overflow | float_flag_inexact, fpst); | ||
741 | - if (round_to_inf(fpst, f32_sign)) { | ||
742 | - return float32_set_sign(float32_infinity, f32_sign); | ||
743 | - } else { | ||
744 | - return float32_set_sign(float32_maxnorm, f32_sign); | ||
745 | - } | ||
746 | - } else if (f32_exp >= 253 && fpst->flush_to_zero) { | ||
747 | - float_raise(float_flag_underflow, fpst); | ||
748 | - return float32_set_sign(float32_zero, float32_is_neg(f32)); | ||
749 | - } | ||
750 | - | ||
751 | - f64_frac = call_recip_estimate(&f32_exp, 253, | ||
752 | - ((uint64_t) f32_frac) << (52 - 23)); | ||
753 | - | ||
754 | - /* result = sign : result_exp<7:0> : fraction<51:29> */ | ||
755 | - f32_val = deposit32(0, 31, 1, f32_sign); | ||
756 | - f32_val = deposit32(f32_val, 23, 8, f32_exp); | ||
757 | - f32_val = deposit32(f32_val, 0, 23, extract64(f64_frac, 52 - 23, 23)); | ||
758 | - return make_float32(f32_val); | ||
759 | -} | ||
760 | - | ||
761 | -float64 HELPER(recpe_f64)(float64 input, void *fpstp) | ||
762 | -{ | ||
763 | - float_status *fpst = fpstp; | ||
764 | - float64 f64 = float64_squash_input_denormal(input, fpst); | ||
765 | - uint64_t f64_val = float64_val(f64); | ||
766 | - bool f64_sign = float64_is_neg(f64); | ||
767 | - int f64_exp = extract64(f64_val, 52, 11); | ||
768 | - uint64_t f64_frac = extract64(f64_val, 0, 52); | ||
769 | - | ||
770 | - /* Deal with any special cases */ | ||
771 | - if (float64_is_any_nan(f64)) { | ||
772 | - float64 nan = f64; | ||
773 | - if (float64_is_signaling_nan(f64, fpst)) { | ||
774 | - float_raise(float_flag_invalid, fpst); | ||
775 | - nan = float64_silence_nan(f64, fpst); | ||
776 | - } | ||
777 | - if (fpst->default_nan_mode) { | ||
778 | - nan = float64_default_nan(fpst); | ||
779 | - } | ||
780 | - return nan; | ||
781 | - } else if (float64_is_infinity(f64)) { | ||
782 | - return float64_set_sign(float64_zero, float64_is_neg(f64)); | ||
783 | - } else if (float64_is_zero(f64)) { | ||
784 | - float_raise(float_flag_divbyzero, fpst); | ||
785 | - return float64_set_sign(float64_infinity, float64_is_neg(f64)); | ||
786 | - } else if ((f64_val & ~(1ULL << 63)) < (1ULL << 50)) { | ||
787 | - /* Abs(value) < 2.0^-1024 */ | ||
788 | - float_raise(float_flag_overflow | float_flag_inexact, fpst); | ||
789 | - if (round_to_inf(fpst, f64_sign)) { | ||
790 | - return float64_set_sign(float64_infinity, f64_sign); | ||
791 | - } else { | ||
792 | - return float64_set_sign(float64_maxnorm, f64_sign); | ||
793 | - } | ||
794 | - } else if (f64_exp >= 2045 && fpst->flush_to_zero) { | ||
795 | - float_raise(float_flag_underflow, fpst); | ||
796 | - return float64_set_sign(float64_zero, float64_is_neg(f64)); | ||
797 | - } | ||
798 | - | ||
799 | - f64_frac = call_recip_estimate(&f64_exp, 2045, f64_frac); | ||
800 | - | ||
801 | - /* result = sign : result_exp<10:0> : fraction<51:0>; */ | ||
802 | - f64_val = deposit64(0, 63, 1, f64_sign); | ||
803 | - f64_val = deposit64(f64_val, 52, 11, f64_exp); | ||
804 | - f64_val = deposit64(f64_val, 0, 52, f64_frac); | ||
805 | - return make_float64(f64_val); | ||
806 | -} | ||
807 | - | ||
808 | -/* The algorithm that must be used to calculate the estimate | ||
809 | - * is specified by the ARM ARM. | ||
810 | - */ | ||
811 | - | ||
812 | -static int do_recip_sqrt_estimate(int a) | ||
813 | -{ | ||
814 | - int b, estimate; | ||
815 | - | ||
816 | - assert(128 <= a && a < 512); | ||
817 | - if (a < 256) { | ||
818 | - a = a * 2 + 1; | ||
819 | - } else { | ||
820 | - a = (a >> 1) << 1; | ||
821 | - a = (a + 1) * 2; | ||
822 | - } | ||
823 | - b = 512; | ||
824 | - while (a * (b + 1) * (b + 1) < (1 << 28)) { | ||
825 | - b += 1; | ||
826 | - } | ||
827 | - estimate = (b + 1) / 2; | ||
828 | - assert(256 <= estimate && estimate < 512); | ||
829 | - | ||
830 | - return estimate; | ||
831 | -} | ||
832 | - | ||
833 | - | ||
834 | -static uint64_t recip_sqrt_estimate(int *exp , int exp_off, uint64_t frac) | ||
835 | -{ | ||
836 | - int estimate; | ||
837 | - uint32_t scaled; | ||
838 | - | ||
839 | - if (*exp == 0) { | ||
840 | - while (extract64(frac, 51, 1) == 0) { | ||
841 | - frac = frac << 1; | ||
842 | - *exp -= 1; | ||
843 | - } | ||
844 | - frac = extract64(frac, 0, 51) << 1; | ||
845 | - } | ||
846 | - | ||
847 | - if (*exp & 1) { | ||
848 | - /* scaled = UInt('01':fraction<51:45>) */ | ||
849 | - scaled = deposit32(1 << 7, 0, 7, extract64(frac, 45, 7)); | ||
850 | - } else { | ||
851 | - /* scaled = UInt('1':fraction<51:44>) */ | ||
852 | - scaled = deposit32(1 << 8, 0, 8, extract64(frac, 44, 8)); | ||
853 | - } | ||
854 | - estimate = do_recip_sqrt_estimate(scaled); | ||
855 | - | ||
856 | - *exp = (exp_off - *exp) / 2; | ||
857 | - return extract64(estimate, 0, 8) << 44; | ||
858 | -} | ||
859 | - | ||
860 | -uint32_t HELPER(rsqrte_f16)(uint32_t input, void *fpstp) | ||
861 | -{ | ||
862 | - float_status *s = fpstp; | ||
863 | - float16 f16 = float16_squash_input_denormal(input, s); | ||
864 | - uint16_t val = float16_val(f16); | ||
865 | - bool f16_sign = float16_is_neg(f16); | ||
866 | - int f16_exp = extract32(val, 10, 5); | ||
867 | - uint16_t f16_frac = extract32(val, 0, 10); | ||
868 | - uint64_t f64_frac; | ||
869 | - | ||
870 | - if (float16_is_any_nan(f16)) { | ||
871 | - float16 nan = f16; | ||
872 | - if (float16_is_signaling_nan(f16, s)) { | ||
873 | - float_raise(float_flag_invalid, s); | ||
874 | - nan = float16_silence_nan(f16, s); | ||
875 | - } | ||
876 | - if (s->default_nan_mode) { | ||
877 | - nan = float16_default_nan(s); | ||
878 | - } | ||
879 | - return nan; | ||
880 | - } else if (float16_is_zero(f16)) { | ||
881 | - float_raise(float_flag_divbyzero, s); | ||
882 | - return float16_set_sign(float16_infinity, f16_sign); | ||
883 | - } else if (f16_sign) { | ||
884 | - float_raise(float_flag_invalid, s); | ||
885 | - return float16_default_nan(s); | ||
886 | - } else if (float16_is_infinity(f16)) { | ||
887 | - return float16_zero; | ||
888 | - } | ||
889 | - | ||
890 | - /* Scale and normalize to a double-precision value between 0.25 and 1.0, | ||
891 | - * preserving the parity of the exponent. */ | ||
892 | - | ||
893 | - f64_frac = ((uint64_t) f16_frac) << (52 - 10); | ||
894 | - | ||
895 | - f64_frac = recip_sqrt_estimate(&f16_exp, 44, f64_frac); | ||
896 | - | ||
897 | - /* result = sign : result_exp<4:0> : estimate<7:0> : Zeros(2) */ | ||
898 | - val = deposit32(0, 15, 1, f16_sign); | ||
899 | - val = deposit32(val, 10, 5, f16_exp); | ||
900 | - val = deposit32(val, 2, 8, extract64(f64_frac, 52 - 8, 8)); | ||
901 | - return make_float16(val); | ||
902 | -} | ||
903 | - | ||
904 | -float32 HELPER(rsqrte_f32)(float32 input, void *fpstp) | ||
905 | -{ | ||
906 | - float_status *s = fpstp; | ||
907 | - float32 f32 = float32_squash_input_denormal(input, s); | ||
908 | - uint32_t val = float32_val(f32); | ||
909 | - uint32_t f32_sign = float32_is_neg(f32); | ||
910 | - int f32_exp = extract32(val, 23, 8); | ||
911 | - uint32_t f32_frac = extract32(val, 0, 23); | ||
912 | - uint64_t f64_frac; | ||
913 | - | ||
914 | - if (float32_is_any_nan(f32)) { | ||
915 | - float32 nan = f32; | ||
916 | - if (float32_is_signaling_nan(f32, s)) { | ||
917 | - float_raise(float_flag_invalid, s); | ||
918 | - nan = float32_silence_nan(f32, s); | ||
919 | - } | ||
920 | - if (s->default_nan_mode) { | ||
921 | - nan = float32_default_nan(s); | ||
922 | - } | ||
923 | - return nan; | ||
924 | - } else if (float32_is_zero(f32)) { | ||
925 | - float_raise(float_flag_divbyzero, s); | ||
926 | - return float32_set_sign(float32_infinity, float32_is_neg(f32)); | ||
927 | - } else if (float32_is_neg(f32)) { | ||
928 | - float_raise(float_flag_invalid, s); | ||
929 | - return float32_default_nan(s); | ||
930 | - } else if (float32_is_infinity(f32)) { | ||
931 | - return float32_zero; | ||
932 | - } | ||
933 | - | ||
934 | - /* Scale and normalize to a double-precision value between 0.25 and 1.0, | ||
935 | - * preserving the parity of the exponent. */ | ||
936 | - | ||
937 | - f64_frac = ((uint64_t) f32_frac) << 29; | ||
938 | - | ||
939 | - f64_frac = recip_sqrt_estimate(&f32_exp, 380, f64_frac); | ||
940 | - | ||
941 | - /* result = sign : result_exp<4:0> : estimate<7:0> : Zeros(15) */ | ||
942 | - val = deposit32(0, 31, 1, f32_sign); | ||
943 | - val = deposit32(val, 23, 8, f32_exp); | ||
944 | - val = deposit32(val, 15, 8, extract64(f64_frac, 52 - 8, 8)); | ||
945 | - return make_float32(val); | ||
946 | -} | ||
947 | - | ||
948 | -float64 HELPER(rsqrte_f64)(float64 input, void *fpstp) | ||
949 | -{ | ||
950 | - float_status *s = fpstp; | ||
951 | - float64 f64 = float64_squash_input_denormal(input, s); | ||
952 | - uint64_t val = float64_val(f64); | ||
953 | - bool f64_sign = float64_is_neg(f64); | ||
954 | - int f64_exp = extract64(val, 52, 11); | ||
955 | - uint64_t f64_frac = extract64(val, 0, 52); | ||
956 | - | ||
957 | - if (float64_is_any_nan(f64)) { | ||
958 | - float64 nan = f64; | ||
959 | - if (float64_is_signaling_nan(f64, s)) { | ||
960 | - float_raise(float_flag_invalid, s); | ||
961 | - nan = float64_silence_nan(f64, s); | ||
962 | - } | ||
963 | - if (s->default_nan_mode) { | ||
964 | - nan = float64_default_nan(s); | ||
965 | - } | ||
966 | - return nan; | ||
967 | - } else if (float64_is_zero(f64)) { | ||
968 | - float_raise(float_flag_divbyzero, s); | ||
969 | - return float64_set_sign(float64_infinity, float64_is_neg(f64)); | ||
970 | - } else if (float64_is_neg(f64)) { | ||
971 | - float_raise(float_flag_invalid, s); | ||
972 | - return float64_default_nan(s); | ||
973 | - } else if (float64_is_infinity(f64)) { | ||
974 | - return float64_zero; | ||
975 | - } | ||
976 | - | ||
977 | - f64_frac = recip_sqrt_estimate(&f64_exp, 3068, f64_frac); | ||
978 | - | ||
979 | - /* result = sign : result_exp<4:0> : estimate<7:0> : Zeros(44) */ | ||
980 | - val = deposit64(0, 61, 1, f64_sign); | ||
981 | - val = deposit64(val, 52, 11, f64_exp); | ||
982 | - val = deposit64(val, 44, 8, extract64(f64_frac, 52 - 8, 8)); | ||
983 | - return make_float64(val); | ||
984 | -} | ||
985 | - | ||
986 | -uint32_t HELPER(recpe_u32)(uint32_t a, void *fpstp) | ||
987 | -{ | ||
988 | - /* float_status *s = fpstp; */ | ||
989 | - int input, estimate; | ||
990 | - | ||
991 | - if ((a & 0x80000000) == 0) { | ||
992 | - return 0xffffffff; | ||
993 | - } | ||
994 | - | ||
995 | - input = extract32(a, 23, 9); | ||
996 | - estimate = recip_estimate(input); | ||
997 | - | ||
998 | - return deposit32(0, (32 - 9), 9, estimate); | ||
999 | -} | ||
1000 | - | ||
1001 | -uint32_t HELPER(rsqrte_u32)(uint32_t a, void *fpstp) | ||
1002 | -{ | ||
1003 | - int estimate; | ||
1004 | - | ||
1005 | - if ((a & 0xc0000000) == 0) { | ||
1006 | - return 0xffffffff; | ||
1007 | - } | ||
1008 | - | ||
1009 | - estimate = do_recip_sqrt_estimate(extract32(a, 23, 9)); | ||
1010 | - | ||
1011 | - return deposit32(0, 23, 9, estimate); | ||
1012 | -} | ||
1013 | - | ||
1014 | -/* VFPv4 fused multiply-accumulate */ | ||
1015 | -float32 VFP_HELPER(muladd, s)(float32 a, float32 b, float32 c, void *fpstp) | ||
1016 | -{ | ||
1017 | - float_status *fpst = fpstp; | ||
1018 | - return float32_muladd(a, b, c, 0, fpst); | ||
1019 | -} | ||
1020 | - | ||
1021 | -float64 VFP_HELPER(muladd, d)(float64 a, float64 b, float64 c, void *fpstp) | ||
1022 | -{ | ||
1023 | - float_status *fpst = fpstp; | ||
1024 | - return float64_muladd(a, b, c, 0, fpst); | ||
1025 | -} | ||
1026 | - | ||
1027 | -/* ARMv8 round to integral */ | ||
1028 | -float32 HELPER(rints_exact)(float32 x, void *fp_status) | ||
1029 | -{ | ||
1030 | - return float32_round_to_int(x, fp_status); | ||
1031 | -} | ||
1032 | - | ||
1033 | -float64 HELPER(rintd_exact)(float64 x, void *fp_status) | ||
1034 | -{ | ||
1035 | - return float64_round_to_int(x, fp_status); | ||
1036 | -} | ||
1037 | - | ||
1038 | -float32 HELPER(rints)(float32 x, void *fp_status) | ||
1039 | -{ | ||
1040 | - int old_flags = get_float_exception_flags(fp_status), new_flags; | ||
1041 | - float32 ret; | ||
1042 | - | ||
1043 | - ret = float32_round_to_int(x, fp_status); | ||
1044 | - | ||
1045 | - /* Suppress any inexact exceptions the conversion produced */ | ||
1046 | - if (!(old_flags & float_flag_inexact)) { | ||
1047 | - new_flags = get_float_exception_flags(fp_status); | ||
1048 | - set_float_exception_flags(new_flags & ~float_flag_inexact, fp_status); | ||
1049 | - } | ||
1050 | - | ||
1051 | - return ret; | ||
1052 | -} | ||
1053 | - | ||
1054 | -float64 HELPER(rintd)(float64 x, void *fp_status) | ||
1055 | -{ | ||
1056 | - int old_flags = get_float_exception_flags(fp_status), new_flags; | ||
1057 | - float64 ret; | ||
1058 | - | ||
1059 | - ret = float64_round_to_int(x, fp_status); | ||
1060 | - | ||
1061 | - new_flags = get_float_exception_flags(fp_status); | ||
1062 | - | ||
1063 | - /* Suppress any inexact exceptions the conversion produced */ | ||
1064 | - if (!(old_flags & float_flag_inexact)) { | ||
1065 | - new_flags = get_float_exception_flags(fp_status); | ||
1066 | - set_float_exception_flags(new_flags & ~float_flag_inexact, fp_status); | ||
1067 | - } | ||
1068 | - | ||
1069 | - return ret; | ||
1070 | -} | ||
1071 | - | ||
1072 | -/* Convert ARM rounding mode to softfloat */ | ||
1073 | -int arm_rmode_to_sf(int rmode) | ||
1074 | -{ | ||
1075 | - switch (rmode) { | ||
1076 | - case FPROUNDING_TIEAWAY: | ||
1077 | - rmode = float_round_ties_away; | ||
1078 | - break; | ||
1079 | - case FPROUNDING_ODD: | ||
1080 | - /* FIXME: add support for TIEAWAY and ODD */ | ||
1081 | - qemu_log_mask(LOG_UNIMP, "arm: unimplemented rounding mode: %d\n", | ||
1082 | - rmode); | ||
1083 | - /* fall through for now */ | ||
1084 | - case FPROUNDING_TIEEVEN: | ||
1085 | - default: | ||
1086 | - rmode = float_round_nearest_even; | ||
1087 | - break; | ||
1088 | - case FPROUNDING_POSINF: | ||
1089 | - rmode = float_round_up; | ||
1090 | - break; | ||
1091 | - case FPROUNDING_NEGINF: | ||
1092 | - rmode = float_round_down; | ||
1093 | - break; | ||
1094 | - case FPROUNDING_ZERO: | ||
1095 | - rmode = float_round_to_zero; | ||
1096 | - break; | ||
1097 | - } | ||
1098 | - return rmode; | ||
1099 | -} | ||
1100 | - | ||
1101 | /* CRC helpers. | ||
1102 | * The upper bytes of val (above the number specified by 'bytes') must have | ||
1103 | * been zeroed out by the caller. | ||
1104 | diff --git a/target/arm/vfp_helper.c b/target/arm/vfp_helper.c | ||
1105 | new file mode 100644 | ||
1106 | index XXXXXXX..XXXXXXX | ||
1107 | --- /dev/null | ||
1108 | +++ b/target/arm/vfp_helper.c | ||
1109 | @@ -XXX,XX +XXX,XX @@ | ||
1110 | +/* | ||
1111 | + * ARM VFP floating-point operations | ||
1112 | + * | ||
1113 | + * Copyright (c) 2003 Fabrice Bellard | ||
1114 | + * | ||
1115 | + * This library is free software; you can redistribute it and/or | ||
1116 | + * modify it under the terms of the GNU Lesser General Public | ||
1117 | + * License as published by the Free Software Foundation; either | ||
1118 | + * version 2.1 of the License, or (at your option) any later version. | ||
1119 | + * | ||
1120 | + * This library is distributed in the hope that it will be useful, | ||
1121 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1122 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
1123 | + * Lesser General Public License for more details. | ||
1124 | + * | ||
1125 | + * You should have received a copy of the GNU Lesser General Public | ||
1126 | + * License along with this library; if not, see <http://www.gnu.org/licenses/>. | ||
1127 | + */ | ||
1128 | + | ||
1129 | +#include "qemu/osdep.h" | ||
1130 | +#include "qemu/log.h" | ||
1131 | +#include "cpu.h" | ||
1132 | +#include "exec/helper-proto.h" | ||
1133 | +#include "fpu/softfloat.h" | ||
1134 | +#include "internals.h" | ||
1135 | + | ||
1136 | + | ||
1137 | +/* VFP support. We follow the convention used for VFP instructions: | ||
1138 | + Single precision routines have a "s" suffix, double precision a | ||
1139 | + "d" suffix. */ | ||
1140 | + | ||
1141 | +/* Convert host exception flags to vfp form. */ | ||
1142 | +static inline int vfp_exceptbits_from_host(int host_bits) | ||
1143 | +{ | 23 | +{ |
1144 | + int target_bits = 0; | 24 | + /* Return true if CPU supports single precision floating point, VFPv2 */ |
1145 | + | 25 | + return FIELD_EX32(id->mvfr0, MVFR0, FPSP) > 0; |
1146 | + if (host_bits & float_flag_invalid) | ||
1147 | + target_bits |= 1; | ||
1148 | + if (host_bits & float_flag_divbyzero) | ||
1149 | + target_bits |= 2; | ||
1150 | + if (host_bits & float_flag_overflow) | ||
1151 | + target_bits |= 4; | ||
1152 | + if (host_bits & (float_flag_underflow | float_flag_output_denormal)) | ||
1153 | + target_bits |= 8; | ||
1154 | + if (host_bits & float_flag_inexact) | ||
1155 | + target_bits |= 0x10; | ||
1156 | + if (host_bits & float_flag_input_denormal) | ||
1157 | + target_bits |= 0x80; | ||
1158 | + return target_bits; | ||
1159 | +} | 26 | +} |
1160 | + | 27 | + |
1161 | +uint32_t HELPER(vfp_get_fpscr)(CPUARMState *env) | 28 | +static inline bool isar_feature_aa32_fpsp_v3(const ARMISARegisters *id) |
1162 | +{ | 29 | +{ |
1163 | + uint32_t i, fpscr; | 30 | + /* Return true if CPU supports single precision floating point, VFPv3 */ |
1164 | + | 31 | + return FIELD_EX32(id->mvfr0, MVFR0, FPSP) >= 2; |
1165 | + fpscr = env->vfp.xregs[ARM_VFP_FPSCR] | ||
1166 | + | (env->vfp.vec_len << 16) | ||
1167 | + | (env->vfp.vec_stride << 20); | ||
1168 | + | ||
1169 | + i = get_float_exception_flags(&env->vfp.fp_status); | ||
1170 | + i |= get_float_exception_flags(&env->vfp.standard_fp_status); | ||
1171 | + /* FZ16 does not generate an input denormal exception. */ | ||
1172 | + i |= (get_float_exception_flags(&env->vfp.fp_status_f16) | ||
1173 | + & ~float_flag_input_denormal); | ||
1174 | + fpscr |= vfp_exceptbits_from_host(i); | ||
1175 | + | ||
1176 | + i = env->vfp.qc[0] | env->vfp.qc[1] | env->vfp.qc[2] | env->vfp.qc[3]; | ||
1177 | + fpscr |= i ? FPCR_QC : 0; | ||
1178 | + | ||
1179 | + return fpscr; | ||
1180 | +} | 32 | +} |
1181 | + | 33 | + |
1182 | +uint32_t vfp_get_fpscr(CPUARMState *env) | 34 | static inline bool isar_feature_aa32_fpdp_v2(const ARMISARegisters *id) |
35 | { | ||
36 | /* Return true if CPU supports double precision floating point, VFPv2 */ | ||
37 | return FIELD_EX32(id->mvfr0, MVFR0, FPDP) > 0; | ||
38 | } | ||
39 | |||
40 | +static inline bool isar_feature_aa32_fpdp_v3(const ARMISARegisters *id) | ||
1183 | +{ | 41 | +{ |
1184 | + return HELPER(vfp_get_fpscr)(env); | 42 | + /* Return true if CPU supports double precision floating point, VFPv3 */ |
43 | + return FIELD_EX32(id->mvfr0, MVFR0, FPDP) >= 2; | ||
1185 | +} | 44 | +} |
1186 | + | 45 | + |
1187 | +/* Convert vfp exception flags to target form. */ | 46 | /* |
1188 | +static inline int vfp_exceptbits_to_host(int target_bits) | 47 | * We always set the FP and SIMD FP16 fields to indicate identical |
1189 | +{ | 48 | * levels of support (assuming SIMD is implemented at all), so |
1190 | + int host_bits = 0; | ||
1191 | + | ||
1192 | + if (target_bits & 1) | ||
1193 | + host_bits |= float_flag_invalid; | ||
1194 | + if (target_bits & 2) | ||
1195 | + host_bits |= float_flag_divbyzero; | ||
1196 | + if (target_bits & 4) | ||
1197 | + host_bits |= float_flag_overflow; | ||
1198 | + if (target_bits & 8) | ||
1199 | + host_bits |= float_flag_underflow; | ||
1200 | + if (target_bits & 0x10) | ||
1201 | + host_bits |= float_flag_inexact; | ||
1202 | + if (target_bits & 0x80) | ||
1203 | + host_bits |= float_flag_input_denormal; | ||
1204 | + return host_bits; | ||
1205 | +} | ||
1206 | + | ||
1207 | +void HELPER(vfp_set_fpscr)(CPUARMState *env, uint32_t val) | ||
1208 | +{ | ||
1209 | + int i; | ||
1210 | + uint32_t changed = env->vfp.xregs[ARM_VFP_FPSCR]; | ||
1211 | + | ||
1212 | + /* When ARMv8.2-FP16 is not supported, FZ16 is RES0. */ | ||
1213 | + if (!cpu_isar_feature(aa64_fp16, arm_env_get_cpu(env))) { | ||
1214 | + val &= ~FPCR_FZ16; | ||
1215 | + } | ||
1216 | + | ||
1217 | + /* | ||
1218 | + * We don't implement trapped exception handling, so the | ||
1219 | + * trap enable bits, IDE|IXE|UFE|OFE|DZE|IOE are all RAZ/WI (not RES0!) | ||
1220 | + * | ||
1221 | + * If we exclude the exception flags, IOC|DZC|OFC|UFC|IXC|IDC | ||
1222 | + * (which are stored in fp_status), and the other RES0 bits | ||
1223 | + * in between, then we clear all of the low 16 bits. | ||
1224 | + */ | ||
1225 | + env->vfp.xregs[ARM_VFP_FPSCR] = val & 0xf7c80000; | ||
1226 | + env->vfp.vec_len = (val >> 16) & 7; | ||
1227 | + env->vfp.vec_stride = (val >> 20) & 3; | ||
1228 | + | ||
1229 | + /* | ||
1230 | + * The bit we set within fpscr_q is arbitrary; the register as a | ||
1231 | + * whole being zero/non-zero is what counts. | ||
1232 | + */ | ||
1233 | + env->vfp.qc[0] = val & FPCR_QC; | ||
1234 | + env->vfp.qc[1] = 0; | ||
1235 | + env->vfp.qc[2] = 0; | ||
1236 | + env->vfp.qc[3] = 0; | ||
1237 | + | ||
1238 | + changed ^= val; | ||
1239 | + if (changed & (3 << 22)) { | ||
1240 | + i = (val >> 22) & 3; | ||
1241 | + switch (i) { | ||
1242 | + case FPROUNDING_TIEEVEN: | ||
1243 | + i = float_round_nearest_even; | ||
1244 | + break; | ||
1245 | + case FPROUNDING_POSINF: | ||
1246 | + i = float_round_up; | ||
1247 | + break; | ||
1248 | + case FPROUNDING_NEGINF: | ||
1249 | + i = float_round_down; | ||
1250 | + break; | ||
1251 | + case FPROUNDING_ZERO: | ||
1252 | + i = float_round_to_zero; | ||
1253 | + break; | ||
1254 | + } | ||
1255 | + set_float_rounding_mode(i, &env->vfp.fp_status); | ||
1256 | + set_float_rounding_mode(i, &env->vfp.fp_status_f16); | ||
1257 | + } | ||
1258 | + if (changed & FPCR_FZ16) { | ||
1259 | + bool ftz_enabled = val & FPCR_FZ16; | ||
1260 | + set_flush_to_zero(ftz_enabled, &env->vfp.fp_status_f16); | ||
1261 | + set_flush_inputs_to_zero(ftz_enabled, &env->vfp.fp_status_f16); | ||
1262 | + } | ||
1263 | + if (changed & FPCR_FZ) { | ||
1264 | + bool ftz_enabled = val & FPCR_FZ; | ||
1265 | + set_flush_to_zero(ftz_enabled, &env->vfp.fp_status); | ||
1266 | + set_flush_inputs_to_zero(ftz_enabled, &env->vfp.fp_status); | ||
1267 | + } | ||
1268 | + if (changed & FPCR_DN) { | ||
1269 | + bool dnan_enabled = val & FPCR_DN; | ||
1270 | + set_default_nan_mode(dnan_enabled, &env->vfp.fp_status); | ||
1271 | + set_default_nan_mode(dnan_enabled, &env->vfp.fp_status_f16); | ||
1272 | + } | ||
1273 | + | ||
1274 | + /* The exception flags are ORed together when we read fpscr so we | ||
1275 | + * only need to preserve the current state in one of our | ||
1276 | + * float_status values. | ||
1277 | + */ | ||
1278 | + i = vfp_exceptbits_to_host(val); | ||
1279 | + set_float_exception_flags(i, &env->vfp.fp_status); | ||
1280 | + set_float_exception_flags(0, &env->vfp.fp_status_f16); | ||
1281 | + set_float_exception_flags(0, &env->vfp.standard_fp_status); | ||
1282 | +} | ||
1283 | + | ||
1284 | +void vfp_set_fpscr(CPUARMState *env, uint32_t val) | ||
1285 | +{ | ||
1286 | + HELPER(vfp_set_fpscr)(env, val); | ||
1287 | +} | ||
1288 | + | ||
1289 | +#define VFP_HELPER(name, p) HELPER(glue(glue(vfp_,name),p)) | ||
1290 | + | ||
1291 | +#define VFP_BINOP(name) \ | ||
1292 | +float32 VFP_HELPER(name, s)(float32 a, float32 b, void *fpstp) \ | ||
1293 | +{ \ | ||
1294 | + float_status *fpst = fpstp; \ | ||
1295 | + return float32_ ## name(a, b, fpst); \ | ||
1296 | +} \ | ||
1297 | +float64 VFP_HELPER(name, d)(float64 a, float64 b, void *fpstp) \ | ||
1298 | +{ \ | ||
1299 | + float_status *fpst = fpstp; \ | ||
1300 | + return float64_ ## name(a, b, fpst); \ | ||
1301 | +} | ||
1302 | +VFP_BINOP(add) | ||
1303 | +VFP_BINOP(sub) | ||
1304 | +VFP_BINOP(mul) | ||
1305 | +VFP_BINOP(div) | ||
1306 | +VFP_BINOP(min) | ||
1307 | +VFP_BINOP(max) | ||
1308 | +VFP_BINOP(minnum) | ||
1309 | +VFP_BINOP(maxnum) | ||
1310 | +#undef VFP_BINOP | ||
1311 | + | ||
1312 | +float32 VFP_HELPER(neg, s)(float32 a) | ||
1313 | +{ | ||
1314 | + return float32_chs(a); | ||
1315 | +} | ||
1316 | + | ||
1317 | +float64 VFP_HELPER(neg, d)(float64 a) | ||
1318 | +{ | ||
1319 | + return float64_chs(a); | ||
1320 | +} | ||
1321 | + | ||
1322 | +float32 VFP_HELPER(abs, s)(float32 a) | ||
1323 | +{ | ||
1324 | + return float32_abs(a); | ||
1325 | +} | ||
1326 | + | ||
1327 | +float64 VFP_HELPER(abs, d)(float64 a) | ||
1328 | +{ | ||
1329 | + return float64_abs(a); | ||
1330 | +} | ||
1331 | + | ||
1332 | +float32 VFP_HELPER(sqrt, s)(float32 a, CPUARMState *env) | ||
1333 | +{ | ||
1334 | + return float32_sqrt(a, &env->vfp.fp_status); | ||
1335 | +} | ||
1336 | + | ||
1337 | +float64 VFP_HELPER(sqrt, d)(float64 a, CPUARMState *env) | ||
1338 | +{ | ||
1339 | + return float64_sqrt(a, &env->vfp.fp_status); | ||
1340 | +} | ||
1341 | + | ||
1342 | +static void softfloat_to_vfp_compare(CPUARMState *env, int cmp) | ||
1343 | +{ | ||
1344 | + uint32_t flags; | ||
1345 | + switch (cmp) { | ||
1346 | + case float_relation_equal: | ||
1347 | + flags = 0x6; | ||
1348 | + break; | ||
1349 | + case float_relation_less: | ||
1350 | + flags = 0x8; | ||
1351 | + break; | ||
1352 | + case float_relation_greater: | ||
1353 | + flags = 0x2; | ||
1354 | + break; | ||
1355 | + case float_relation_unordered: | ||
1356 | + flags = 0x3; | ||
1357 | + break; | ||
1358 | + default: | ||
1359 | + g_assert_not_reached(); | ||
1360 | + } | ||
1361 | + env->vfp.xregs[ARM_VFP_FPSCR] = | ||
1362 | + deposit32(env->vfp.xregs[ARM_VFP_FPSCR], 28, 4, flags); | ||
1363 | +} | ||
1364 | + | ||
1365 | +/* XXX: check quiet/signaling case */ | ||
1366 | +#define DO_VFP_cmp(p, type) \ | ||
1367 | +void VFP_HELPER(cmp, p)(type a, type b, CPUARMState *env) \ | ||
1368 | +{ \ | ||
1369 | + softfloat_to_vfp_compare(env, \ | ||
1370 | + type ## _compare_quiet(a, b, &env->vfp.fp_status)); \ | ||
1371 | +} \ | ||
1372 | +void VFP_HELPER(cmpe, p)(type a, type b, CPUARMState *env) \ | ||
1373 | +{ \ | ||
1374 | + softfloat_to_vfp_compare(env, \ | ||
1375 | + type ## _compare(a, b, &env->vfp.fp_status)); \ | ||
1376 | +} | ||
1377 | +DO_VFP_cmp(s, float32) | ||
1378 | +DO_VFP_cmp(d, float64) | ||
1379 | +#undef DO_VFP_cmp | ||
1380 | + | ||
1381 | +/* Integer to float and float to integer conversions */ | ||
1382 | + | ||
1383 | +#define CONV_ITOF(name, ftype, fsz, sign) \ | ||
1384 | +ftype HELPER(name)(uint32_t x, void *fpstp) \ | ||
1385 | +{ \ | ||
1386 | + float_status *fpst = fpstp; \ | ||
1387 | + return sign##int32_to_##float##fsz((sign##int32_t)x, fpst); \ | ||
1388 | +} | ||
1389 | + | ||
1390 | +#define CONV_FTOI(name, ftype, fsz, sign, round) \ | ||
1391 | +sign##int32_t HELPER(name)(ftype x, void *fpstp) \ | ||
1392 | +{ \ | ||
1393 | + float_status *fpst = fpstp; \ | ||
1394 | + if (float##fsz##_is_any_nan(x)) { \ | ||
1395 | + float_raise(float_flag_invalid, fpst); \ | ||
1396 | + return 0; \ | ||
1397 | + } \ | ||
1398 | + return float##fsz##_to_##sign##int32##round(x, fpst); \ | ||
1399 | +} | ||
1400 | + | ||
1401 | +#define FLOAT_CONVS(name, p, ftype, fsz, sign) \ | ||
1402 | + CONV_ITOF(vfp_##name##to##p, ftype, fsz, sign) \ | ||
1403 | + CONV_FTOI(vfp_to##name##p, ftype, fsz, sign, ) \ | ||
1404 | + CONV_FTOI(vfp_to##name##z##p, ftype, fsz, sign, _round_to_zero) | ||
1405 | + | ||
1406 | +FLOAT_CONVS(si, h, uint32_t, 16, ) | ||
1407 | +FLOAT_CONVS(si, s, float32, 32, ) | ||
1408 | +FLOAT_CONVS(si, d, float64, 64, ) | ||
1409 | +FLOAT_CONVS(ui, h, uint32_t, 16, u) | ||
1410 | +FLOAT_CONVS(ui, s, float32, 32, u) | ||
1411 | +FLOAT_CONVS(ui, d, float64, 64, u) | ||
1412 | + | ||
1413 | +#undef CONV_ITOF | ||
1414 | +#undef CONV_FTOI | ||
1415 | +#undef FLOAT_CONVS | ||
1416 | + | ||
1417 | +/* floating point conversion */ | ||
1418 | +float64 VFP_HELPER(fcvtd, s)(float32 x, CPUARMState *env) | ||
1419 | +{ | ||
1420 | + return float32_to_float64(x, &env->vfp.fp_status); | ||
1421 | +} | ||
1422 | + | ||
1423 | +float32 VFP_HELPER(fcvts, d)(float64 x, CPUARMState *env) | ||
1424 | +{ | ||
1425 | + return float64_to_float32(x, &env->vfp.fp_status); | ||
1426 | +} | ||
1427 | + | ||
1428 | +/* VFP3 fixed point conversion. */ | ||
1429 | +#define VFP_CONV_FIX_FLOAT(name, p, fsz, isz, itype) \ | ||
1430 | +float##fsz HELPER(vfp_##name##to##p)(uint##isz##_t x, uint32_t shift, \ | ||
1431 | + void *fpstp) \ | ||
1432 | +{ return itype##_to_##float##fsz##_scalbn(x, -shift, fpstp); } | ||
1433 | + | ||
1434 | +#define VFP_CONV_FLOAT_FIX_ROUND(name, p, fsz, isz, itype, ROUND, suff) \ | ||
1435 | +uint##isz##_t HELPER(vfp_to##name##p##suff)(float##fsz x, uint32_t shift, \ | ||
1436 | + void *fpst) \ | ||
1437 | +{ \ | ||
1438 | + if (unlikely(float##fsz##_is_any_nan(x))) { \ | ||
1439 | + float_raise(float_flag_invalid, fpst); \ | ||
1440 | + return 0; \ | ||
1441 | + } \ | ||
1442 | + return float##fsz##_to_##itype##_scalbn(x, ROUND, shift, fpst); \ | ||
1443 | +} | ||
1444 | + | ||
1445 | +#define VFP_CONV_FIX(name, p, fsz, isz, itype) \ | ||
1446 | +VFP_CONV_FIX_FLOAT(name, p, fsz, isz, itype) \ | ||
1447 | +VFP_CONV_FLOAT_FIX_ROUND(name, p, fsz, isz, itype, \ | ||
1448 | + float_round_to_zero, _round_to_zero) \ | ||
1449 | +VFP_CONV_FLOAT_FIX_ROUND(name, p, fsz, isz, itype, \ | ||
1450 | + get_float_rounding_mode(fpst), ) | ||
1451 | + | ||
1452 | +#define VFP_CONV_FIX_A64(name, p, fsz, isz, itype) \ | ||
1453 | +VFP_CONV_FIX_FLOAT(name, p, fsz, isz, itype) \ | ||
1454 | +VFP_CONV_FLOAT_FIX_ROUND(name, p, fsz, isz, itype, \ | ||
1455 | + get_float_rounding_mode(fpst), ) | ||
1456 | + | ||
1457 | +VFP_CONV_FIX(sh, d, 64, 64, int16) | ||
1458 | +VFP_CONV_FIX(sl, d, 64, 64, int32) | ||
1459 | +VFP_CONV_FIX_A64(sq, d, 64, 64, int64) | ||
1460 | +VFP_CONV_FIX(uh, d, 64, 64, uint16) | ||
1461 | +VFP_CONV_FIX(ul, d, 64, 64, uint32) | ||
1462 | +VFP_CONV_FIX_A64(uq, d, 64, 64, uint64) | ||
1463 | +VFP_CONV_FIX(sh, s, 32, 32, int16) | ||
1464 | +VFP_CONV_FIX(sl, s, 32, 32, int32) | ||
1465 | +VFP_CONV_FIX_A64(sq, s, 32, 64, int64) | ||
1466 | +VFP_CONV_FIX(uh, s, 32, 32, uint16) | ||
1467 | +VFP_CONV_FIX(ul, s, 32, 32, uint32) | ||
1468 | +VFP_CONV_FIX_A64(uq, s, 32, 64, uint64) | ||
1469 | + | ||
1470 | +#undef VFP_CONV_FIX | ||
1471 | +#undef VFP_CONV_FIX_FLOAT | ||
1472 | +#undef VFP_CONV_FLOAT_FIX_ROUND | ||
1473 | +#undef VFP_CONV_FIX_A64 | ||
1474 | + | ||
1475 | +uint32_t HELPER(vfp_sltoh)(uint32_t x, uint32_t shift, void *fpst) | ||
1476 | +{ | ||
1477 | + return int32_to_float16_scalbn(x, -shift, fpst); | ||
1478 | +} | ||
1479 | + | ||
1480 | +uint32_t HELPER(vfp_ultoh)(uint32_t x, uint32_t shift, void *fpst) | ||
1481 | +{ | ||
1482 | + return uint32_to_float16_scalbn(x, -shift, fpst); | ||
1483 | +} | ||
1484 | + | ||
1485 | +uint32_t HELPER(vfp_sqtoh)(uint64_t x, uint32_t shift, void *fpst) | ||
1486 | +{ | ||
1487 | + return int64_to_float16_scalbn(x, -shift, fpst); | ||
1488 | +} | ||
1489 | + | ||
1490 | +uint32_t HELPER(vfp_uqtoh)(uint64_t x, uint32_t shift, void *fpst) | ||
1491 | +{ | ||
1492 | + return uint64_to_float16_scalbn(x, -shift, fpst); | ||
1493 | +} | ||
1494 | + | ||
1495 | +uint32_t HELPER(vfp_toshh)(uint32_t x, uint32_t shift, void *fpst) | ||
1496 | +{ | ||
1497 | + if (unlikely(float16_is_any_nan(x))) { | ||
1498 | + float_raise(float_flag_invalid, fpst); | ||
1499 | + return 0; | ||
1500 | + } | ||
1501 | + return float16_to_int16_scalbn(x, get_float_rounding_mode(fpst), | ||
1502 | + shift, fpst); | ||
1503 | +} | ||
1504 | + | ||
1505 | +uint32_t HELPER(vfp_touhh)(uint32_t x, uint32_t shift, void *fpst) | ||
1506 | +{ | ||
1507 | + if (unlikely(float16_is_any_nan(x))) { | ||
1508 | + float_raise(float_flag_invalid, fpst); | ||
1509 | + return 0; | ||
1510 | + } | ||
1511 | + return float16_to_uint16_scalbn(x, get_float_rounding_mode(fpst), | ||
1512 | + shift, fpst); | ||
1513 | +} | ||
1514 | + | ||
1515 | +uint32_t HELPER(vfp_toslh)(uint32_t x, uint32_t shift, void *fpst) | ||
1516 | +{ | ||
1517 | + if (unlikely(float16_is_any_nan(x))) { | ||
1518 | + float_raise(float_flag_invalid, fpst); | ||
1519 | + return 0; | ||
1520 | + } | ||
1521 | + return float16_to_int32_scalbn(x, get_float_rounding_mode(fpst), | ||
1522 | + shift, fpst); | ||
1523 | +} | ||
1524 | + | ||
1525 | +uint32_t HELPER(vfp_toulh)(uint32_t x, uint32_t shift, void *fpst) | ||
1526 | +{ | ||
1527 | + if (unlikely(float16_is_any_nan(x))) { | ||
1528 | + float_raise(float_flag_invalid, fpst); | ||
1529 | + return 0; | ||
1530 | + } | ||
1531 | + return float16_to_uint32_scalbn(x, get_float_rounding_mode(fpst), | ||
1532 | + shift, fpst); | ||
1533 | +} | ||
1534 | + | ||
1535 | +uint64_t HELPER(vfp_tosqh)(uint32_t x, uint32_t shift, void *fpst) | ||
1536 | +{ | ||
1537 | + if (unlikely(float16_is_any_nan(x))) { | ||
1538 | + float_raise(float_flag_invalid, fpst); | ||
1539 | + return 0; | ||
1540 | + } | ||
1541 | + return float16_to_int64_scalbn(x, get_float_rounding_mode(fpst), | ||
1542 | + shift, fpst); | ||
1543 | +} | ||
1544 | + | ||
1545 | +uint64_t HELPER(vfp_touqh)(uint32_t x, uint32_t shift, void *fpst) | ||
1546 | +{ | ||
1547 | + if (unlikely(float16_is_any_nan(x))) { | ||
1548 | + float_raise(float_flag_invalid, fpst); | ||
1549 | + return 0; | ||
1550 | + } | ||
1551 | + return float16_to_uint64_scalbn(x, get_float_rounding_mode(fpst), | ||
1552 | + shift, fpst); | ||
1553 | +} | ||
1554 | + | ||
1555 | +/* Set the current fp rounding mode and return the old one. | ||
1556 | + * The argument is a softfloat float_round_ value. | ||
1557 | + */ | ||
1558 | +uint32_t HELPER(set_rmode)(uint32_t rmode, void *fpstp) | ||
1559 | +{ | ||
1560 | + float_status *fp_status = fpstp; | ||
1561 | + | ||
1562 | + uint32_t prev_rmode = get_float_rounding_mode(fp_status); | ||
1563 | + set_float_rounding_mode(rmode, fp_status); | ||
1564 | + | ||
1565 | + return prev_rmode; | ||
1566 | +} | ||
1567 | + | ||
1568 | +/* Set the current fp rounding mode in the standard fp status and return | ||
1569 | + * the old one. This is for NEON instructions that need to change the | ||
1570 | + * rounding mode but wish to use the standard FPSCR values for everything | ||
1571 | + * else. Always set the rounding mode back to the correct value after | ||
1572 | + * modifying it. | ||
1573 | + * The argument is a softfloat float_round_ value. | ||
1574 | + */ | ||
1575 | +uint32_t HELPER(set_neon_rmode)(uint32_t rmode, CPUARMState *env) | ||
1576 | +{ | ||
1577 | + float_status *fp_status = &env->vfp.standard_fp_status; | ||
1578 | + | ||
1579 | + uint32_t prev_rmode = get_float_rounding_mode(fp_status); | ||
1580 | + set_float_rounding_mode(rmode, fp_status); | ||
1581 | + | ||
1582 | + return prev_rmode; | ||
1583 | +} | ||
1584 | + | ||
1585 | +/* Half precision conversions. */ | ||
1586 | +float32 HELPER(vfp_fcvt_f16_to_f32)(uint32_t a, void *fpstp, uint32_t ahp_mode) | ||
1587 | +{ | ||
1588 | + /* Squash FZ16 to 0 for the duration of conversion. In this case, | ||
1589 | + * it would affect flushing input denormals. | ||
1590 | + */ | ||
1591 | + float_status *fpst = fpstp; | ||
1592 | + flag save = get_flush_inputs_to_zero(fpst); | ||
1593 | + set_flush_inputs_to_zero(false, fpst); | ||
1594 | + float32 r = float16_to_float32(a, !ahp_mode, fpst); | ||
1595 | + set_flush_inputs_to_zero(save, fpst); | ||
1596 | + return r; | ||
1597 | +} | ||
1598 | + | ||
1599 | +uint32_t HELPER(vfp_fcvt_f32_to_f16)(float32 a, void *fpstp, uint32_t ahp_mode) | ||
1600 | +{ | ||
1601 | + /* Squash FZ16 to 0 for the duration of conversion. In this case, | ||
1602 | + * it would affect flushing output denormals. | ||
1603 | + */ | ||
1604 | + float_status *fpst = fpstp; | ||
1605 | + flag save = get_flush_to_zero(fpst); | ||
1606 | + set_flush_to_zero(false, fpst); | ||
1607 | + float16 r = float32_to_float16(a, !ahp_mode, fpst); | ||
1608 | + set_flush_to_zero(save, fpst); | ||
1609 | + return r; | ||
1610 | +} | ||
1611 | + | ||
1612 | +float64 HELPER(vfp_fcvt_f16_to_f64)(uint32_t a, void *fpstp, uint32_t ahp_mode) | ||
1613 | +{ | ||
1614 | + /* Squash FZ16 to 0 for the duration of conversion. In this case, | ||
1615 | + * it would affect flushing input denormals. | ||
1616 | + */ | ||
1617 | + float_status *fpst = fpstp; | ||
1618 | + flag save = get_flush_inputs_to_zero(fpst); | ||
1619 | + set_flush_inputs_to_zero(false, fpst); | ||
1620 | + float64 r = float16_to_float64(a, !ahp_mode, fpst); | ||
1621 | + set_flush_inputs_to_zero(save, fpst); | ||
1622 | + return r; | ||
1623 | +} | ||
1624 | + | ||
1625 | +uint32_t HELPER(vfp_fcvt_f64_to_f16)(float64 a, void *fpstp, uint32_t ahp_mode) | ||
1626 | +{ | ||
1627 | + /* Squash FZ16 to 0 for the duration of conversion. In this case, | ||
1628 | + * it would affect flushing output denormals. | ||
1629 | + */ | ||
1630 | + float_status *fpst = fpstp; | ||
1631 | + flag save = get_flush_to_zero(fpst); | ||
1632 | + set_flush_to_zero(false, fpst); | ||
1633 | + float16 r = float64_to_float16(a, !ahp_mode, fpst); | ||
1634 | + set_flush_to_zero(save, fpst); | ||
1635 | + return r; | ||
1636 | +} | ||
1637 | + | ||
1638 | +#define float32_two make_float32(0x40000000) | ||
1639 | +#define float32_three make_float32(0x40400000) | ||
1640 | +#define float32_one_point_five make_float32(0x3fc00000) | ||
1641 | + | ||
1642 | +float32 HELPER(recps_f32)(float32 a, float32 b, CPUARMState *env) | ||
1643 | +{ | ||
1644 | + float_status *s = &env->vfp.standard_fp_status; | ||
1645 | + if ((float32_is_infinity(a) && float32_is_zero_or_denormal(b)) || | ||
1646 | + (float32_is_infinity(b) && float32_is_zero_or_denormal(a))) { | ||
1647 | + if (!(float32_is_zero(a) || float32_is_zero(b))) { | ||
1648 | + float_raise(float_flag_input_denormal, s); | ||
1649 | + } | ||
1650 | + return float32_two; | ||
1651 | + } | ||
1652 | + return float32_sub(float32_two, float32_mul(a, b, s), s); | ||
1653 | +} | ||
1654 | + | ||
1655 | +float32 HELPER(rsqrts_f32)(float32 a, float32 b, CPUARMState *env) | ||
1656 | +{ | ||
1657 | + float_status *s = &env->vfp.standard_fp_status; | ||
1658 | + float32 product; | ||
1659 | + if ((float32_is_infinity(a) && float32_is_zero_or_denormal(b)) || | ||
1660 | + (float32_is_infinity(b) && float32_is_zero_or_denormal(a))) { | ||
1661 | + if (!(float32_is_zero(a) || float32_is_zero(b))) { | ||
1662 | + float_raise(float_flag_input_denormal, s); | ||
1663 | + } | ||
1664 | + return float32_one_point_five; | ||
1665 | + } | ||
1666 | + product = float32_mul(a, b, s); | ||
1667 | + return float32_div(float32_sub(float32_three, product, s), float32_two, s); | ||
1668 | +} | ||
1669 | + | ||
1670 | +/* NEON helpers. */ | ||
1671 | + | ||
1672 | +/* Constants 256 and 512 are used in some helpers; we avoid relying on | ||
1673 | + * int->float conversions at run-time. */ | ||
1674 | +#define float64_256 make_float64(0x4070000000000000LL) | ||
1675 | +#define float64_512 make_float64(0x4080000000000000LL) | ||
1676 | +#define float16_maxnorm make_float16(0x7bff) | ||
1677 | +#define float32_maxnorm make_float32(0x7f7fffff) | ||
1678 | +#define float64_maxnorm make_float64(0x7fefffffffffffffLL) | ||
1679 | + | ||
1680 | +/* Reciprocal functions | ||
1681 | + * | ||
1682 | + * The algorithm that must be used to calculate the estimate | ||
1683 | + * is specified by the ARM ARM, see FPRecipEstimate()/RecipEstimate | ||
1684 | + */ | ||
1685 | + | ||
1686 | +/* See RecipEstimate() | ||
1687 | + * | ||
1688 | + * input is a 9 bit fixed point number | ||
1689 | + * input range 256 .. 511 for a number from 0.5 <= x < 1.0. | ||
1690 | + * result range 256 .. 511 for a number from 1.0 to 511/256. | ||
1691 | + */ | ||
1692 | + | ||
1693 | +static int recip_estimate(int input) | ||
1694 | +{ | ||
1695 | + int a, b, r; | ||
1696 | + assert(256 <= input && input < 512); | ||
1697 | + a = (input * 2) + 1; | ||
1698 | + b = (1 << 19) / a; | ||
1699 | + r = (b + 1) >> 1; | ||
1700 | + assert(256 <= r && r < 512); | ||
1701 | + return r; | ||
1702 | +} | ||
1703 | + | ||
1704 | +/* | ||
1705 | + * Common wrapper to call recip_estimate | ||
1706 | + * | ||
1707 | + * The parameters are exponent and 64 bit fraction (without implicit | ||
1708 | + * bit) where the binary point is nominally at bit 52. Returns a | ||
1709 | + * float64 which can then be rounded to the appropriate size by the | ||
1710 | + * callee. | ||
1711 | + */ | ||
1712 | + | ||
1713 | +static uint64_t call_recip_estimate(int *exp, int exp_off, uint64_t frac) | ||
1714 | +{ | ||
1715 | + uint32_t scaled, estimate; | ||
1716 | + uint64_t result_frac; | ||
1717 | + int result_exp; | ||
1718 | + | ||
1719 | + /* Handle sub-normals */ | ||
1720 | + if (*exp == 0) { | ||
1721 | + if (extract64(frac, 51, 1) == 0) { | ||
1722 | + *exp = -1; | ||
1723 | + frac <<= 2; | ||
1724 | + } else { | ||
1725 | + frac <<= 1; | ||
1726 | + } | ||
1727 | + } | ||
1728 | + | ||
1729 | + /* scaled = UInt('1':fraction<51:44>) */ | ||
1730 | + scaled = deposit32(1 << 8, 0, 8, extract64(frac, 44, 8)); | ||
1731 | + estimate = recip_estimate(scaled); | ||
1732 | + | ||
1733 | + result_exp = exp_off - *exp; | ||
1734 | + result_frac = deposit64(0, 44, 8, estimate); | ||
1735 | + if (result_exp == 0) { | ||
1736 | + result_frac = deposit64(result_frac >> 1, 51, 1, 1); | ||
1737 | + } else if (result_exp == -1) { | ||
1738 | + result_frac = deposit64(result_frac >> 2, 50, 2, 1); | ||
1739 | + result_exp = 0; | ||
1740 | + } | ||
1741 | + | ||
1742 | + *exp = result_exp; | ||
1743 | + | ||
1744 | + return result_frac; | ||
1745 | +} | ||
1746 | + | ||
1747 | +static bool round_to_inf(float_status *fpst, bool sign_bit) | ||
1748 | +{ | ||
1749 | + switch (fpst->float_rounding_mode) { | ||
1750 | + case float_round_nearest_even: /* Round to Nearest */ | ||
1751 | + return true; | ||
1752 | + case float_round_up: /* Round to +Inf */ | ||
1753 | + return !sign_bit; | ||
1754 | + case float_round_down: /* Round to -Inf */ | ||
1755 | + return sign_bit; | ||
1756 | + case float_round_to_zero: /* Round to Zero */ | ||
1757 | + return false; | ||
1758 | + } | ||
1759 | + | ||
1760 | + g_assert_not_reached(); | ||
1761 | +} | ||
1762 | + | ||
1763 | +uint32_t HELPER(recpe_f16)(uint32_t input, void *fpstp) | ||
1764 | +{ | ||
1765 | + float_status *fpst = fpstp; | ||
1766 | + float16 f16 = float16_squash_input_denormal(input, fpst); | ||
1767 | + uint32_t f16_val = float16_val(f16); | ||
1768 | + uint32_t f16_sign = float16_is_neg(f16); | ||
1769 | + int f16_exp = extract32(f16_val, 10, 5); | ||
1770 | + uint32_t f16_frac = extract32(f16_val, 0, 10); | ||
1771 | + uint64_t f64_frac; | ||
1772 | + | ||
1773 | + if (float16_is_any_nan(f16)) { | ||
1774 | + float16 nan = f16; | ||
1775 | + if (float16_is_signaling_nan(f16, fpst)) { | ||
1776 | + float_raise(float_flag_invalid, fpst); | ||
1777 | + nan = float16_silence_nan(f16, fpst); | ||
1778 | + } | ||
1779 | + if (fpst->default_nan_mode) { | ||
1780 | + nan = float16_default_nan(fpst); | ||
1781 | + } | ||
1782 | + return nan; | ||
1783 | + } else if (float16_is_infinity(f16)) { | ||
1784 | + return float16_set_sign(float16_zero, float16_is_neg(f16)); | ||
1785 | + } else if (float16_is_zero(f16)) { | ||
1786 | + float_raise(float_flag_divbyzero, fpst); | ||
1787 | + return float16_set_sign(float16_infinity, float16_is_neg(f16)); | ||
1788 | + } else if (float16_abs(f16) < (1 << 8)) { | ||
1789 | + /* Abs(value) < 2.0^-16 */ | ||
1790 | + float_raise(float_flag_overflow | float_flag_inexact, fpst); | ||
1791 | + if (round_to_inf(fpst, f16_sign)) { | ||
1792 | + return float16_set_sign(float16_infinity, f16_sign); | ||
1793 | + } else { | ||
1794 | + return float16_set_sign(float16_maxnorm, f16_sign); | ||
1795 | + } | ||
1796 | + } else if (f16_exp >= 29 && fpst->flush_to_zero) { | ||
1797 | + float_raise(float_flag_underflow, fpst); | ||
1798 | + return float16_set_sign(float16_zero, float16_is_neg(f16)); | ||
1799 | + } | ||
1800 | + | ||
1801 | + f64_frac = call_recip_estimate(&f16_exp, 29, | ||
1802 | + ((uint64_t) f16_frac) << (52 - 10)); | ||
1803 | + | ||
1804 | + /* result = sign : result_exp<4:0> : fraction<51:42> */ | ||
1805 | + f16_val = deposit32(0, 15, 1, f16_sign); | ||
1806 | + f16_val = deposit32(f16_val, 10, 5, f16_exp); | ||
1807 | + f16_val = deposit32(f16_val, 0, 10, extract64(f64_frac, 52 - 10, 10)); | ||
1808 | + return make_float16(f16_val); | ||
1809 | +} | ||
1810 | + | ||
1811 | +float32 HELPER(recpe_f32)(float32 input, void *fpstp) | ||
1812 | +{ | ||
1813 | + float_status *fpst = fpstp; | ||
1814 | + float32 f32 = float32_squash_input_denormal(input, fpst); | ||
1815 | + uint32_t f32_val = float32_val(f32); | ||
1816 | + bool f32_sign = float32_is_neg(f32); | ||
1817 | + int f32_exp = extract32(f32_val, 23, 8); | ||
1818 | + uint32_t f32_frac = extract32(f32_val, 0, 23); | ||
1819 | + uint64_t f64_frac; | ||
1820 | + | ||
1821 | + if (float32_is_any_nan(f32)) { | ||
1822 | + float32 nan = f32; | ||
1823 | + if (float32_is_signaling_nan(f32, fpst)) { | ||
1824 | + float_raise(float_flag_invalid, fpst); | ||
1825 | + nan = float32_silence_nan(f32, fpst); | ||
1826 | + } | ||
1827 | + if (fpst->default_nan_mode) { | ||
1828 | + nan = float32_default_nan(fpst); | ||
1829 | + } | ||
1830 | + return nan; | ||
1831 | + } else if (float32_is_infinity(f32)) { | ||
1832 | + return float32_set_sign(float32_zero, float32_is_neg(f32)); | ||
1833 | + } else if (float32_is_zero(f32)) { | ||
1834 | + float_raise(float_flag_divbyzero, fpst); | ||
1835 | + return float32_set_sign(float32_infinity, float32_is_neg(f32)); | ||
1836 | + } else if (float32_abs(f32) < (1ULL << 21)) { | ||
1837 | + /* Abs(value) < 2.0^-128 */ | ||
1838 | + float_raise(float_flag_overflow | float_flag_inexact, fpst); | ||
1839 | + if (round_to_inf(fpst, f32_sign)) { | ||
1840 | + return float32_set_sign(float32_infinity, f32_sign); | ||
1841 | + } else { | ||
1842 | + return float32_set_sign(float32_maxnorm, f32_sign); | ||
1843 | + } | ||
1844 | + } else if (f32_exp >= 253 && fpst->flush_to_zero) { | ||
1845 | + float_raise(float_flag_underflow, fpst); | ||
1846 | + return float32_set_sign(float32_zero, float32_is_neg(f32)); | ||
1847 | + } | ||
1848 | + | ||
1849 | + f64_frac = call_recip_estimate(&f32_exp, 253, | ||
1850 | + ((uint64_t) f32_frac) << (52 - 23)); | ||
1851 | + | ||
1852 | + /* result = sign : result_exp<7:0> : fraction<51:29> */ | ||
1853 | + f32_val = deposit32(0, 31, 1, f32_sign); | ||
1854 | + f32_val = deposit32(f32_val, 23, 8, f32_exp); | ||
1855 | + f32_val = deposit32(f32_val, 0, 23, extract64(f64_frac, 52 - 23, 23)); | ||
1856 | + return make_float32(f32_val); | ||
1857 | +} | ||
1858 | + | ||
1859 | +float64 HELPER(recpe_f64)(float64 input, void *fpstp) | ||
1860 | +{ | ||
1861 | + float_status *fpst = fpstp; | ||
1862 | + float64 f64 = float64_squash_input_denormal(input, fpst); | ||
1863 | + uint64_t f64_val = float64_val(f64); | ||
1864 | + bool f64_sign = float64_is_neg(f64); | ||
1865 | + int f64_exp = extract64(f64_val, 52, 11); | ||
1866 | + uint64_t f64_frac = extract64(f64_val, 0, 52); | ||
1867 | + | ||
1868 | + /* Deal with any special cases */ | ||
1869 | + if (float64_is_any_nan(f64)) { | ||
1870 | + float64 nan = f64; | ||
1871 | + if (float64_is_signaling_nan(f64, fpst)) { | ||
1872 | + float_raise(float_flag_invalid, fpst); | ||
1873 | + nan = float64_silence_nan(f64, fpst); | ||
1874 | + } | ||
1875 | + if (fpst->default_nan_mode) { | ||
1876 | + nan = float64_default_nan(fpst); | ||
1877 | + } | ||
1878 | + return nan; | ||
1879 | + } else if (float64_is_infinity(f64)) { | ||
1880 | + return float64_set_sign(float64_zero, float64_is_neg(f64)); | ||
1881 | + } else if (float64_is_zero(f64)) { | ||
1882 | + float_raise(float_flag_divbyzero, fpst); | ||
1883 | + return float64_set_sign(float64_infinity, float64_is_neg(f64)); | ||
1884 | + } else if ((f64_val & ~(1ULL << 63)) < (1ULL << 50)) { | ||
1885 | + /* Abs(value) < 2.0^-1024 */ | ||
1886 | + float_raise(float_flag_overflow | float_flag_inexact, fpst); | ||
1887 | + if (round_to_inf(fpst, f64_sign)) { | ||
1888 | + return float64_set_sign(float64_infinity, f64_sign); | ||
1889 | + } else { | ||
1890 | + return float64_set_sign(float64_maxnorm, f64_sign); | ||
1891 | + } | ||
1892 | + } else if (f64_exp >= 2045 && fpst->flush_to_zero) { | ||
1893 | + float_raise(float_flag_underflow, fpst); | ||
1894 | + return float64_set_sign(float64_zero, float64_is_neg(f64)); | ||
1895 | + } | ||
1896 | + | ||
1897 | + f64_frac = call_recip_estimate(&f64_exp, 2045, f64_frac); | ||
1898 | + | ||
1899 | + /* result = sign : result_exp<10:0> : fraction<51:0>; */ | ||
1900 | + f64_val = deposit64(0, 63, 1, f64_sign); | ||
1901 | + f64_val = deposit64(f64_val, 52, 11, f64_exp); | ||
1902 | + f64_val = deposit64(f64_val, 0, 52, f64_frac); | ||
1903 | + return make_float64(f64_val); | ||
1904 | +} | ||
1905 | + | ||
1906 | +/* The algorithm that must be used to calculate the estimate | ||
1907 | + * is specified by the ARM ARM. | ||
1908 | + */ | ||
1909 | + | ||
1910 | +static int do_recip_sqrt_estimate(int a) | ||
1911 | +{ | ||
1912 | + int b, estimate; | ||
1913 | + | ||
1914 | + assert(128 <= a && a < 512); | ||
1915 | + if (a < 256) { | ||
1916 | + a = a * 2 + 1; | ||
1917 | + } else { | ||
1918 | + a = (a >> 1) << 1; | ||
1919 | + a = (a + 1) * 2; | ||
1920 | + } | ||
1921 | + b = 512; | ||
1922 | + while (a * (b + 1) * (b + 1) < (1 << 28)) { | ||
1923 | + b += 1; | ||
1924 | + } | ||
1925 | + estimate = (b + 1) / 2; | ||
1926 | + assert(256 <= estimate && estimate < 512); | ||
1927 | + | ||
1928 | + return estimate; | ||
1929 | +} | ||
1930 | + | ||
1931 | + | ||
1932 | +static uint64_t recip_sqrt_estimate(int *exp , int exp_off, uint64_t frac) | ||
1933 | +{ | ||
1934 | + int estimate; | ||
1935 | + uint32_t scaled; | ||
1936 | + | ||
1937 | + if (*exp == 0) { | ||
1938 | + while (extract64(frac, 51, 1) == 0) { | ||
1939 | + frac = frac << 1; | ||
1940 | + *exp -= 1; | ||
1941 | + } | ||
1942 | + frac = extract64(frac, 0, 51) << 1; | ||
1943 | + } | ||
1944 | + | ||
1945 | + if (*exp & 1) { | ||
1946 | + /* scaled = UInt('01':fraction<51:45>) */ | ||
1947 | + scaled = deposit32(1 << 7, 0, 7, extract64(frac, 45, 7)); | ||
1948 | + } else { | ||
1949 | + /* scaled = UInt('1':fraction<51:44>) */ | ||
1950 | + scaled = deposit32(1 << 8, 0, 8, extract64(frac, 44, 8)); | ||
1951 | + } | ||
1952 | + estimate = do_recip_sqrt_estimate(scaled); | ||
1953 | + | ||
1954 | + *exp = (exp_off - *exp) / 2; | ||
1955 | + return extract64(estimate, 0, 8) << 44; | ||
1956 | +} | ||
1957 | + | ||
1958 | +uint32_t HELPER(rsqrte_f16)(uint32_t input, void *fpstp) | ||
1959 | +{ | ||
1960 | + float_status *s = fpstp; | ||
1961 | + float16 f16 = float16_squash_input_denormal(input, s); | ||
1962 | + uint16_t val = float16_val(f16); | ||
1963 | + bool f16_sign = float16_is_neg(f16); | ||
1964 | + int f16_exp = extract32(val, 10, 5); | ||
1965 | + uint16_t f16_frac = extract32(val, 0, 10); | ||
1966 | + uint64_t f64_frac; | ||
1967 | + | ||
1968 | + if (float16_is_any_nan(f16)) { | ||
1969 | + float16 nan = f16; | ||
1970 | + if (float16_is_signaling_nan(f16, s)) { | ||
1971 | + float_raise(float_flag_invalid, s); | ||
1972 | + nan = float16_silence_nan(f16, s); | ||
1973 | + } | ||
1974 | + if (s->default_nan_mode) { | ||
1975 | + nan = float16_default_nan(s); | ||
1976 | + } | ||
1977 | + return nan; | ||
1978 | + } else if (float16_is_zero(f16)) { | ||
1979 | + float_raise(float_flag_divbyzero, s); | ||
1980 | + return float16_set_sign(float16_infinity, f16_sign); | ||
1981 | + } else if (f16_sign) { | ||
1982 | + float_raise(float_flag_invalid, s); | ||
1983 | + return float16_default_nan(s); | ||
1984 | + } else if (float16_is_infinity(f16)) { | ||
1985 | + return float16_zero; | ||
1986 | + } | ||
1987 | + | ||
1988 | + /* Scale and normalize to a double-precision value between 0.25 and 1.0, | ||
1989 | + * preserving the parity of the exponent. */ | ||
1990 | + | ||
1991 | + f64_frac = ((uint64_t) f16_frac) << (52 - 10); | ||
1992 | + | ||
1993 | + f64_frac = recip_sqrt_estimate(&f16_exp, 44, f64_frac); | ||
1994 | + | ||
1995 | + /* result = sign : result_exp<4:0> : estimate<7:0> : Zeros(2) */ | ||
1996 | + val = deposit32(0, 15, 1, f16_sign); | ||
1997 | + val = deposit32(val, 10, 5, f16_exp); | ||
1998 | + val = deposit32(val, 2, 8, extract64(f64_frac, 52 - 8, 8)); | ||
1999 | + return make_float16(val); | ||
2000 | +} | ||
2001 | + | ||
2002 | +float32 HELPER(rsqrte_f32)(float32 input, void *fpstp) | ||
2003 | +{ | ||
2004 | + float_status *s = fpstp; | ||
2005 | + float32 f32 = float32_squash_input_denormal(input, s); | ||
2006 | + uint32_t val = float32_val(f32); | ||
2007 | + uint32_t f32_sign = float32_is_neg(f32); | ||
2008 | + int f32_exp = extract32(val, 23, 8); | ||
2009 | + uint32_t f32_frac = extract32(val, 0, 23); | ||
2010 | + uint64_t f64_frac; | ||
2011 | + | ||
2012 | + if (float32_is_any_nan(f32)) { | ||
2013 | + float32 nan = f32; | ||
2014 | + if (float32_is_signaling_nan(f32, s)) { | ||
2015 | + float_raise(float_flag_invalid, s); | ||
2016 | + nan = float32_silence_nan(f32, s); | ||
2017 | + } | ||
2018 | + if (s->default_nan_mode) { | ||
2019 | + nan = float32_default_nan(s); | ||
2020 | + } | ||
2021 | + return nan; | ||
2022 | + } else if (float32_is_zero(f32)) { | ||
2023 | + float_raise(float_flag_divbyzero, s); | ||
2024 | + return float32_set_sign(float32_infinity, float32_is_neg(f32)); | ||
2025 | + } else if (float32_is_neg(f32)) { | ||
2026 | + float_raise(float_flag_invalid, s); | ||
2027 | + return float32_default_nan(s); | ||
2028 | + } else if (float32_is_infinity(f32)) { | ||
2029 | + return float32_zero; | ||
2030 | + } | ||
2031 | + | ||
2032 | + /* Scale and normalize to a double-precision value between 0.25 and 1.0, | ||
2033 | + * preserving the parity of the exponent. */ | ||
2034 | + | ||
2035 | + f64_frac = ((uint64_t) f32_frac) << 29; | ||
2036 | + | ||
2037 | + f64_frac = recip_sqrt_estimate(&f32_exp, 380, f64_frac); | ||
2038 | + | ||
2039 | + /* result = sign : result_exp<4:0> : estimate<7:0> : Zeros(15) */ | ||
2040 | + val = deposit32(0, 31, 1, f32_sign); | ||
2041 | + val = deposit32(val, 23, 8, f32_exp); | ||
2042 | + val = deposit32(val, 15, 8, extract64(f64_frac, 52 - 8, 8)); | ||
2043 | + return make_float32(val); | ||
2044 | +} | ||
2045 | + | ||
2046 | +float64 HELPER(rsqrte_f64)(float64 input, void *fpstp) | ||
2047 | +{ | ||
2048 | + float_status *s = fpstp; | ||
2049 | + float64 f64 = float64_squash_input_denormal(input, s); | ||
2050 | + uint64_t val = float64_val(f64); | ||
2051 | + bool f64_sign = float64_is_neg(f64); | ||
2052 | + int f64_exp = extract64(val, 52, 11); | ||
2053 | + uint64_t f64_frac = extract64(val, 0, 52); | ||
2054 | + | ||
2055 | + if (float64_is_any_nan(f64)) { | ||
2056 | + float64 nan = f64; | ||
2057 | + if (float64_is_signaling_nan(f64, s)) { | ||
2058 | + float_raise(float_flag_invalid, s); | ||
2059 | + nan = float64_silence_nan(f64, s); | ||
2060 | + } | ||
2061 | + if (s->default_nan_mode) { | ||
2062 | + nan = float64_default_nan(s); | ||
2063 | + } | ||
2064 | + return nan; | ||
2065 | + } else if (float64_is_zero(f64)) { | ||
2066 | + float_raise(float_flag_divbyzero, s); | ||
2067 | + return float64_set_sign(float64_infinity, float64_is_neg(f64)); | ||
2068 | + } else if (float64_is_neg(f64)) { | ||
2069 | + float_raise(float_flag_invalid, s); | ||
2070 | + return float64_default_nan(s); | ||
2071 | + } else if (float64_is_infinity(f64)) { | ||
2072 | + return float64_zero; | ||
2073 | + } | ||
2074 | + | ||
2075 | + f64_frac = recip_sqrt_estimate(&f64_exp, 3068, f64_frac); | ||
2076 | + | ||
2077 | + /* result = sign : result_exp<4:0> : estimate<7:0> : Zeros(44) */ | ||
2078 | + val = deposit64(0, 61, 1, f64_sign); | ||
2079 | + val = deposit64(val, 52, 11, f64_exp); | ||
2080 | + val = deposit64(val, 44, 8, extract64(f64_frac, 52 - 8, 8)); | ||
2081 | + return make_float64(val); | ||
2082 | +} | ||
2083 | + | ||
2084 | +uint32_t HELPER(recpe_u32)(uint32_t a, void *fpstp) | ||
2085 | +{ | ||
2086 | + /* float_status *s = fpstp; */ | ||
2087 | + int input, estimate; | ||
2088 | + | ||
2089 | + if ((a & 0x80000000) == 0) { | ||
2090 | + return 0xffffffff; | ||
2091 | + } | ||
2092 | + | ||
2093 | + input = extract32(a, 23, 9); | ||
2094 | + estimate = recip_estimate(input); | ||
2095 | + | ||
2096 | + return deposit32(0, (32 - 9), 9, estimate); | ||
2097 | +} | ||
2098 | + | ||
2099 | +uint32_t HELPER(rsqrte_u32)(uint32_t a, void *fpstp) | ||
2100 | +{ | ||
2101 | + int estimate; | ||
2102 | + | ||
2103 | + if ((a & 0xc0000000) == 0) { | ||
2104 | + return 0xffffffff; | ||
2105 | + } | ||
2106 | + | ||
2107 | + estimate = do_recip_sqrt_estimate(extract32(a, 23, 9)); | ||
2108 | + | ||
2109 | + return deposit32(0, 23, 9, estimate); | ||
2110 | +} | ||
2111 | + | ||
2112 | +/* VFPv4 fused multiply-accumulate */ | ||
2113 | +float32 VFP_HELPER(muladd, s)(float32 a, float32 b, float32 c, void *fpstp) | ||
2114 | +{ | ||
2115 | + float_status *fpst = fpstp; | ||
2116 | + return float32_muladd(a, b, c, 0, fpst); | ||
2117 | +} | ||
2118 | + | ||
2119 | +float64 VFP_HELPER(muladd, d)(float64 a, float64 b, float64 c, void *fpstp) | ||
2120 | +{ | ||
2121 | + float_status *fpst = fpstp; | ||
2122 | + return float64_muladd(a, b, c, 0, fpst); | ||
2123 | +} | ||
2124 | + | ||
2125 | +/* ARMv8 round to integral */ | ||
2126 | +float32 HELPER(rints_exact)(float32 x, void *fp_status) | ||
2127 | +{ | ||
2128 | + return float32_round_to_int(x, fp_status); | ||
2129 | +} | ||
2130 | + | ||
2131 | +float64 HELPER(rintd_exact)(float64 x, void *fp_status) | ||
2132 | +{ | ||
2133 | + return float64_round_to_int(x, fp_status); | ||
2134 | +} | ||
2135 | + | ||
2136 | +float32 HELPER(rints)(float32 x, void *fp_status) | ||
2137 | +{ | ||
2138 | + int old_flags = get_float_exception_flags(fp_status), new_flags; | ||
2139 | + float32 ret; | ||
2140 | + | ||
2141 | + ret = float32_round_to_int(x, fp_status); | ||
2142 | + | ||
2143 | + /* Suppress any inexact exceptions the conversion produced */ | ||
2144 | + if (!(old_flags & float_flag_inexact)) { | ||
2145 | + new_flags = get_float_exception_flags(fp_status); | ||
2146 | + set_float_exception_flags(new_flags & ~float_flag_inexact, fp_status); | ||
2147 | + } | ||
2148 | + | ||
2149 | + return ret; | ||
2150 | +} | ||
2151 | + | ||
2152 | +float64 HELPER(rintd)(float64 x, void *fp_status) | ||
2153 | +{ | ||
2154 | + int old_flags = get_float_exception_flags(fp_status), new_flags; | ||
2155 | + float64 ret; | ||
2156 | + | ||
2157 | + ret = float64_round_to_int(x, fp_status); | ||
2158 | + | ||
2159 | + new_flags = get_float_exception_flags(fp_status); | ||
2160 | + | ||
2161 | + /* Suppress any inexact exceptions the conversion produced */ | ||
2162 | + if (!(old_flags & float_flag_inexact)) { | ||
2163 | + new_flags = get_float_exception_flags(fp_status); | ||
2164 | + set_float_exception_flags(new_flags & ~float_flag_inexact, fp_status); | ||
2165 | + } | ||
2166 | + | ||
2167 | + return ret; | ||
2168 | +} | ||
2169 | + | ||
2170 | +/* Convert ARM rounding mode to softfloat */ | ||
2171 | +int arm_rmode_to_sf(int rmode) | ||
2172 | +{ | ||
2173 | + switch (rmode) { | ||
2174 | + case FPROUNDING_TIEAWAY: | ||
2175 | + rmode = float_round_ties_away; | ||
2176 | + break; | ||
2177 | + case FPROUNDING_ODD: | ||
2178 | + /* FIXME: add support for TIEAWAY and ODD */ | ||
2179 | + qemu_log_mask(LOG_UNIMP, "arm: unimplemented rounding mode: %d\n", | ||
2180 | + rmode); | ||
2181 | + /* fall through for now */ | ||
2182 | + case FPROUNDING_TIEEVEN: | ||
2183 | + default: | ||
2184 | + rmode = float_round_nearest_even; | ||
2185 | + break; | ||
2186 | + case FPROUNDING_POSINF: | ||
2187 | + rmode = float_round_up; | ||
2188 | + break; | ||
2189 | + case FPROUNDING_NEGINF: | ||
2190 | + rmode = float_round_down; | ||
2191 | + break; | ||
2192 | + case FPROUNDING_ZERO: | ||
2193 | + rmode = float_round_to_zero; | ||
2194 | + break; | ||
2195 | + } | ||
2196 | + return rmode; | ||
2197 | +} | ||
2198 | -- | 49 | -- |
2199 | 2.20.1 | 50 | 2.20.1 |
2200 | 51 | ||
2201 | 52 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | 1 | From: Richard Henderson <richard.henderson@linaro.org> | |
2 | |||
3 | Shuffle the order of the checks so that we test the ISA | ||
4 | before we test anything else, such as the register arguments. | ||
5 | |||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20200214181547.21408-9-richard.henderson@linaro.org | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | target/arm/translate-vfp.inc.c | 144 ++++++++++++++++----------------- | ||
12 | 1 file changed, 72 insertions(+), 72 deletions(-) | ||
13 | |||
14 | diff --git a/target/arm/translate-vfp.inc.c b/target/arm/translate-vfp.inc.c | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/target/arm/translate-vfp.inc.c | ||
17 | +++ b/target/arm/translate-vfp.inc.c | ||
18 | @@ -XXX,XX +XXX,XX @@ static bool trans_VSEL(DisasContext *s, arg_VSEL *a) | ||
19 | return false; | ||
20 | } | ||
21 | |||
22 | - /* UNDEF accesses to D16-D31 if they don't exist */ | ||
23 | - if (dp && !dc_isar_feature(aa32_simd_r32, s) && | ||
24 | - ((a->vm | a->vn | a->vd) & 0x10)) { | ||
25 | + if (dp && !dc_isar_feature(aa32_fpdp_v2, s)) { | ||
26 | return false; | ||
27 | } | ||
28 | |||
29 | - if (dp && !dc_isar_feature(aa32_fpdp_v2, s)) { | ||
30 | + /* UNDEF accesses to D16-D31 if they don't exist */ | ||
31 | + if (dp && !dc_isar_feature(aa32_simd_r32, s) && | ||
32 | + ((a->vm | a->vn | a->vd) & 0x10)) { | ||
33 | return false; | ||
34 | } | ||
35 | |||
36 | @@ -XXX,XX +XXX,XX @@ static bool trans_VMINMAXNM(DisasContext *s, arg_VMINMAXNM *a) | ||
37 | return false; | ||
38 | } | ||
39 | |||
40 | - /* UNDEF accesses to D16-D31 if they don't exist */ | ||
41 | - if (dp && !dc_isar_feature(aa32_simd_r32, s) && | ||
42 | - ((a->vm | a->vn | a->vd) & 0x10)) { | ||
43 | + if (dp && !dc_isar_feature(aa32_fpdp_v2, s)) { | ||
44 | return false; | ||
45 | } | ||
46 | |||
47 | - if (dp && !dc_isar_feature(aa32_fpdp_v2, s)) { | ||
48 | + /* UNDEF accesses to D16-D31 if they don't exist */ | ||
49 | + if (dp && !dc_isar_feature(aa32_simd_r32, s) && | ||
50 | + ((a->vm | a->vn | a->vd) & 0x10)) { | ||
51 | return false; | ||
52 | } | ||
53 | |||
54 | @@ -XXX,XX +XXX,XX @@ static bool trans_VRINT(DisasContext *s, arg_VRINT *a) | ||
55 | return false; | ||
56 | } | ||
57 | |||
58 | - /* UNDEF accesses to D16-D31 if they don't exist */ | ||
59 | - if (dp && !dc_isar_feature(aa32_simd_r32, s) && | ||
60 | - ((a->vm | a->vd) & 0x10)) { | ||
61 | + if (dp && !dc_isar_feature(aa32_fpdp_v2, s)) { | ||
62 | return false; | ||
63 | } | ||
64 | |||
65 | - if (dp && !dc_isar_feature(aa32_fpdp_v2, s)) { | ||
66 | + /* UNDEF accesses to D16-D31 if they don't exist */ | ||
67 | + if (dp && !dc_isar_feature(aa32_simd_r32, s) && | ||
68 | + ((a->vm | a->vd) & 0x10)) { | ||
69 | return false; | ||
70 | } | ||
71 | |||
72 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT(DisasContext *s, arg_VCVT *a) | ||
73 | return false; | ||
74 | } | ||
75 | |||
76 | - /* UNDEF accesses to D16-D31 if they don't exist */ | ||
77 | - if (dp && !dc_isar_feature(aa32_simd_r32, s) && (a->vm & 0x10)) { | ||
78 | + if (dp && !dc_isar_feature(aa32_fpdp_v2, s)) { | ||
79 | return false; | ||
80 | } | ||
81 | |||
82 | - if (dp && !dc_isar_feature(aa32_fpdp_v2, s)) { | ||
83 | + /* UNDEF accesses to D16-D31 if they don't exist */ | ||
84 | + if (dp && !dc_isar_feature(aa32_simd_r32, s) && (a->vm & 0x10)) { | ||
85 | return false; | ||
86 | } | ||
87 | |||
88 | @@ -XXX,XX +XXX,XX @@ static bool do_vfp_3op_dp(DisasContext *s, VFPGen3OpDPFn *fn, | ||
89 | TCGv_i64 f0, f1, fd; | ||
90 | TCGv_ptr fpst; | ||
91 | |||
92 | - /* UNDEF accesses to D16-D31 if they don't exist */ | ||
93 | - if (!dc_isar_feature(aa32_simd_r32, s) && ((vd | vn | vm) & 0x10)) { | ||
94 | + if (!dc_isar_feature(aa32_fpdp_v2, s)) { | ||
95 | return false; | ||
96 | } | ||
97 | |||
98 | - if (!dc_isar_feature(aa32_fpdp_v2, s)) { | ||
99 | + /* UNDEF accesses to D16-D31 if they don't exist */ | ||
100 | + if (!dc_isar_feature(aa32_simd_r32, s) && ((vd | vn | vm) & 0x10)) { | ||
101 | return false; | ||
102 | } | ||
103 | |||
104 | @@ -XXX,XX +XXX,XX @@ static bool do_vfp_2op_dp(DisasContext *s, VFPGen2OpDPFn *fn, int vd, int vm) | ||
105 | int veclen = s->vec_len; | ||
106 | TCGv_i64 f0, fd; | ||
107 | |||
108 | - /* UNDEF accesses to D16-D31 if they don't exist */ | ||
109 | - if (!dc_isar_feature(aa32_simd_r32, s) && ((vd | vm) & 0x10)) { | ||
110 | + if (!dc_isar_feature(aa32_fpdp_v2, s)) { | ||
111 | return false; | ||
112 | } | ||
113 | |||
114 | - if (!dc_isar_feature(aa32_fpdp_v2, s)) { | ||
115 | + /* UNDEF accesses to D16-D31 if they don't exist */ | ||
116 | + if (!dc_isar_feature(aa32_simd_r32, s) && ((vd | vm) & 0x10)) { | ||
117 | return false; | ||
118 | } | ||
119 | |||
120 | @@ -XXX,XX +XXX,XX @@ static bool trans_VFM_dp(DisasContext *s, arg_VFM_dp *a) | ||
121 | return false; | ||
122 | } | ||
123 | |||
124 | - /* UNDEF accesses to D16-D31 if they don't exist. */ | ||
125 | - if (!dc_isar_feature(aa32_simd_r32, s) && | ||
126 | - ((a->vd | a->vn | a->vm) & 0x10)) { | ||
127 | + if (!dc_isar_feature(aa32_fpdp_v2, s)) { | ||
128 | return false; | ||
129 | } | ||
130 | |||
131 | - if (!dc_isar_feature(aa32_fpdp_v2, s)) { | ||
132 | + /* UNDEF accesses to D16-D31 if they don't exist. */ | ||
133 | + if (!dc_isar_feature(aa32_simd_r32, s) && | ||
134 | + ((a->vd | a->vn | a->vm) & 0x10)) { | ||
135 | return false; | ||
136 | } | ||
137 | |||
138 | @@ -XXX,XX +XXX,XX @@ static bool trans_VMOV_imm_dp(DisasContext *s, arg_VMOV_imm_dp *a) | ||
139 | |||
140 | vd = a->vd; | ||
141 | |||
142 | - /* UNDEF accesses to D16-D31 if they don't exist. */ | ||
143 | - if (!dc_isar_feature(aa32_simd_r32, s) && (vd & 0x10)) { | ||
144 | + if (!dc_isar_feature(aa32_fpdp_v2, s)) { | ||
145 | return false; | ||
146 | } | ||
147 | |||
148 | - if (!dc_isar_feature(aa32_fpdp_v2, s)) { | ||
149 | + /* UNDEF accesses to D16-D31 if they don't exist. */ | ||
150 | + if (!dc_isar_feature(aa32_simd_r32, s) && (vd & 0x10)) { | ||
151 | return false; | ||
152 | } | ||
153 | |||
154 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCMP_dp(DisasContext *s, arg_VCMP_dp *a) | ||
155 | { | ||
156 | TCGv_i64 vd, vm; | ||
157 | |||
158 | + if (!dc_isar_feature(aa32_fpdp_v2, s)) { | ||
159 | + return false; | ||
160 | + } | ||
161 | + | ||
162 | /* Vm/M bits must be zero for the Z variant */ | ||
163 | if (a->z && a->vm != 0) { | ||
164 | return false; | ||
165 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCMP_dp(DisasContext *s, arg_VCMP_dp *a) | ||
166 | return false; | ||
167 | } | ||
168 | |||
169 | - if (!dc_isar_feature(aa32_fpdp_v2, s)) { | ||
170 | - return false; | ||
171 | - } | ||
172 | - | ||
173 | if (!vfp_access_check(s)) { | ||
174 | return true; | ||
175 | } | ||
176 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_f64_f16(DisasContext *s, arg_VCVT_f64_f16 *a) | ||
177 | TCGv_i32 tmp; | ||
178 | TCGv_i64 vd; | ||
179 | |||
180 | + if (!dc_isar_feature(aa32_fpdp_v2, s)) { | ||
181 | + return false; | ||
182 | + } | ||
183 | + | ||
184 | if (!dc_isar_feature(aa32_fp16_dpconv, s)) { | ||
185 | return false; | ||
186 | } | ||
187 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_f64_f16(DisasContext *s, arg_VCVT_f64_f16 *a) | ||
188 | return false; | ||
189 | } | ||
190 | |||
191 | - if (!dc_isar_feature(aa32_fpdp_v2, s)) { | ||
192 | - return false; | ||
193 | - } | ||
194 | - | ||
195 | if (!vfp_access_check(s)) { | ||
196 | return true; | ||
197 | } | ||
198 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_f16_f64(DisasContext *s, arg_VCVT_f16_f64 *a) | ||
199 | TCGv_i32 tmp; | ||
200 | TCGv_i64 vm; | ||
201 | |||
202 | + if (!dc_isar_feature(aa32_fpdp_v2, s)) { | ||
203 | + return false; | ||
204 | + } | ||
205 | + | ||
206 | if (!dc_isar_feature(aa32_fp16_dpconv, s)) { | ||
207 | return false; | ||
208 | } | ||
209 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_f16_f64(DisasContext *s, arg_VCVT_f16_f64 *a) | ||
210 | return false; | ||
211 | } | ||
212 | |||
213 | - if (!dc_isar_feature(aa32_fpdp_v2, s)) { | ||
214 | - return false; | ||
215 | - } | ||
216 | - | ||
217 | if (!vfp_access_check(s)) { | ||
218 | return true; | ||
219 | } | ||
220 | @@ -XXX,XX +XXX,XX @@ static bool trans_VRINTR_dp(DisasContext *s, arg_VRINTR_dp *a) | ||
221 | TCGv_ptr fpst; | ||
222 | TCGv_i64 tmp; | ||
223 | |||
224 | + if (!dc_isar_feature(aa32_fpdp_v2, s)) { | ||
225 | + return false; | ||
226 | + } | ||
227 | + | ||
228 | if (!dc_isar_feature(aa32_vrint, s)) { | ||
229 | return false; | ||
230 | } | ||
231 | @@ -XXX,XX +XXX,XX @@ static bool trans_VRINTR_dp(DisasContext *s, arg_VRINTR_dp *a) | ||
232 | return false; | ||
233 | } | ||
234 | |||
235 | - if (!dc_isar_feature(aa32_fpdp_v2, s)) { | ||
236 | - return false; | ||
237 | - } | ||
238 | - | ||
239 | if (!vfp_access_check(s)) { | ||
240 | return true; | ||
241 | } | ||
242 | @@ -XXX,XX +XXX,XX @@ static bool trans_VRINTZ_dp(DisasContext *s, arg_VRINTZ_dp *a) | ||
243 | TCGv_i64 tmp; | ||
244 | TCGv_i32 tcg_rmode; | ||
245 | |||
246 | + if (!dc_isar_feature(aa32_fpdp_v2, s)) { | ||
247 | + return false; | ||
248 | + } | ||
249 | + | ||
250 | if (!dc_isar_feature(aa32_vrint, s)) { | ||
251 | return false; | ||
252 | } | ||
253 | @@ -XXX,XX +XXX,XX @@ static bool trans_VRINTZ_dp(DisasContext *s, arg_VRINTZ_dp *a) | ||
254 | return false; | ||
255 | } | ||
256 | |||
257 | - if (!dc_isar_feature(aa32_fpdp_v2, s)) { | ||
258 | - return false; | ||
259 | - } | ||
260 | - | ||
261 | if (!vfp_access_check(s)) { | ||
262 | return true; | ||
263 | } | ||
264 | @@ -XXX,XX +XXX,XX @@ static bool trans_VRINTX_dp(DisasContext *s, arg_VRINTX_dp *a) | ||
265 | TCGv_ptr fpst; | ||
266 | TCGv_i64 tmp; | ||
267 | |||
268 | + if (!dc_isar_feature(aa32_fpdp_v2, s)) { | ||
269 | + return false; | ||
270 | + } | ||
271 | + | ||
272 | if (!dc_isar_feature(aa32_vrint, s)) { | ||
273 | return false; | ||
274 | } | ||
275 | @@ -XXX,XX +XXX,XX @@ static bool trans_VRINTX_dp(DisasContext *s, arg_VRINTX_dp *a) | ||
276 | return false; | ||
277 | } | ||
278 | |||
279 | - if (!dc_isar_feature(aa32_fpdp_v2, s)) { | ||
280 | - return false; | ||
281 | - } | ||
282 | - | ||
283 | if (!vfp_access_check(s)) { | ||
284 | return true; | ||
285 | } | ||
286 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_sp(DisasContext *s, arg_VCVT_sp *a) | ||
287 | TCGv_i64 vd; | ||
288 | TCGv_i32 vm; | ||
289 | |||
290 | - /* UNDEF accesses to D16-D31 if they don't exist. */ | ||
291 | - if (!dc_isar_feature(aa32_simd_r32, s) && (a->vd & 0x10)) { | ||
292 | + if (!dc_isar_feature(aa32_fpdp_v2, s)) { | ||
293 | return false; | ||
294 | } | ||
295 | |||
296 | - if (!dc_isar_feature(aa32_fpdp_v2, s)) { | ||
297 | + /* UNDEF accesses to D16-D31 if they don't exist. */ | ||
298 | + if (!dc_isar_feature(aa32_simd_r32, s) && (a->vd & 0x10)) { | ||
299 | return false; | ||
300 | } | ||
301 | |||
302 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_dp(DisasContext *s, arg_VCVT_dp *a) | ||
303 | TCGv_i64 vm; | ||
304 | TCGv_i32 vd; | ||
305 | |||
306 | - /* UNDEF accesses to D16-D31 if they don't exist. */ | ||
307 | - if (!dc_isar_feature(aa32_simd_r32, s) && (a->vm & 0x10)) { | ||
308 | + if (!dc_isar_feature(aa32_fpdp_v2, s)) { | ||
309 | return false; | ||
310 | } | ||
311 | |||
312 | - if (!dc_isar_feature(aa32_fpdp_v2, s)) { | ||
313 | + /* UNDEF accesses to D16-D31 if they don't exist. */ | ||
314 | + if (!dc_isar_feature(aa32_simd_r32, s) && (a->vm & 0x10)) { | ||
315 | return false; | ||
316 | } | ||
317 | |||
318 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_int_dp(DisasContext *s, arg_VCVT_int_dp *a) | ||
319 | TCGv_i64 vd; | ||
320 | TCGv_ptr fpst; | ||
321 | |||
322 | - /* UNDEF accesses to D16-D31 if they don't exist. */ | ||
323 | - if (!dc_isar_feature(aa32_simd_r32, s) && (a->vd & 0x10)) { | ||
324 | + if (!dc_isar_feature(aa32_fpdp_v2, s)) { | ||
325 | return false; | ||
326 | } | ||
327 | |||
328 | - if (!dc_isar_feature(aa32_fpdp_v2, s)) { | ||
329 | + /* UNDEF accesses to D16-D31 if they don't exist. */ | ||
330 | + if (!dc_isar_feature(aa32_simd_r32, s) && (a->vd & 0x10)) { | ||
331 | return false; | ||
332 | } | ||
333 | |||
334 | @@ -XXX,XX +XXX,XX @@ static bool trans_VJCVT(DisasContext *s, arg_VJCVT *a) | ||
335 | TCGv_i32 vd; | ||
336 | TCGv_i64 vm; | ||
337 | |||
338 | + if (!dc_isar_feature(aa32_fpdp_v2, s)) { | ||
339 | + return false; | ||
340 | + } | ||
341 | + | ||
342 | if (!dc_isar_feature(aa32_jscvt, s)) { | ||
343 | return false; | ||
344 | } | ||
345 | @@ -XXX,XX +XXX,XX @@ static bool trans_VJCVT(DisasContext *s, arg_VJCVT *a) | ||
346 | return false; | ||
347 | } | ||
348 | |||
349 | - if (!dc_isar_feature(aa32_fpdp_v2, s)) { | ||
350 | - return false; | ||
351 | - } | ||
352 | - | ||
353 | if (!vfp_access_check(s)) { | ||
354 | return true; | ||
355 | } | ||
356 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_fix_dp(DisasContext *s, arg_VCVT_fix_dp *a) | ||
357 | TCGv_ptr fpst; | ||
358 | int frac_bits; | ||
359 | |||
360 | + if (!dc_isar_feature(aa32_fpdp_v2, s)) { | ||
361 | + return false; | ||
362 | + } | ||
363 | + | ||
364 | if (!arm_dc_feature(s, ARM_FEATURE_VFP3)) { | ||
365 | return false; | ||
366 | } | ||
367 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_fix_dp(DisasContext *s, arg_VCVT_fix_dp *a) | ||
368 | return false; | ||
369 | } | ||
370 | |||
371 | - if (!dc_isar_feature(aa32_fpdp_v2, s)) { | ||
372 | - return false; | ||
373 | - } | ||
374 | - | ||
375 | if (!vfp_access_check(s)) { | ||
376 | return true; | ||
377 | } | ||
378 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_dp_int(DisasContext *s, arg_VCVT_dp_int *a) | ||
379 | TCGv_i64 vm; | ||
380 | TCGv_ptr fpst; | ||
381 | |||
382 | - /* UNDEF accesses to D16-D31 if they don't exist. */ | ||
383 | - if (!dc_isar_feature(aa32_simd_r32, s) && (a->vm & 0x10)) { | ||
384 | + if (!dc_isar_feature(aa32_fpdp_v2, s)) { | ||
385 | return false; | ||
386 | } | ||
387 | |||
388 | - if (!dc_isar_feature(aa32_fpdp_v2, s)) { | ||
389 | + /* UNDEF accesses to D16-D31 if they don't exist. */ | ||
390 | + if (!dc_isar_feature(aa32_simd_r32, s) && (a->vm & 0x10)) { | ||
391 | return false; | ||
392 | } | ||
393 | |||
394 | -- | ||
395 | 2.20.1 | ||
396 | |||
397 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
1 | 2 | ||
3 | Sort this check to the start of a trans_* function. | ||
4 | Merge this with any existing test for fpdp_v2. | ||
5 | |||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20200214181547.21408-10-richard.henderson@linaro.org | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | target/arm/translate-vfp.inc.c | 24 ++++++++---------------- | ||
12 | 1 file changed, 8 insertions(+), 16 deletions(-) | ||
13 | |||
14 | diff --git a/target/arm/translate-vfp.inc.c b/target/arm/translate-vfp.inc.c | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/target/arm/translate-vfp.inc.c | ||
17 | +++ b/target/arm/translate-vfp.inc.c | ||
18 | @@ -XXX,XX +XXX,XX @@ static bool trans_VMSR_VMRS(DisasContext *s, arg_VMSR_VMRS *a) | ||
19 | * VFPv2 allows access to FPSID from userspace; VFPv3 restricts | ||
20 | * all ID registers to privileged access only. | ||
21 | */ | ||
22 | - if (IS_USER(s) && arm_dc_feature(s, ARM_FEATURE_VFP3)) { | ||
23 | + if (IS_USER(s) && dc_isar_feature(aa32_fpsp_v3, s)) { | ||
24 | return false; | ||
25 | } | ||
26 | ignore_vfp_enabled = true; | ||
27 | @@ -XXX,XX +XXX,XX @@ static bool trans_VMSR_VMRS(DisasContext *s, arg_VMSR_VMRS *a) | ||
28 | case ARM_VFP_FPINST: | ||
29 | case ARM_VFP_FPINST2: | ||
30 | /* Not present in VFPv3 */ | ||
31 | - if (IS_USER(s) || arm_dc_feature(s, ARM_FEATURE_VFP3)) { | ||
32 | + if (IS_USER(s) || dc_isar_feature(aa32_fpsp_v3, s)) { | ||
33 | return false; | ||
34 | } | ||
35 | break; | ||
36 | @@ -XXX,XX +XXX,XX @@ static bool trans_VMOV_imm_sp(DisasContext *s, arg_VMOV_imm_sp *a) | ||
37 | |||
38 | vd = a->vd; | ||
39 | |||
40 | - if (!dc_isar_feature(aa32_fpshvec, s) && | ||
41 | - (veclen != 0 || s->vec_stride != 0)) { | ||
42 | + if (!dc_isar_feature(aa32_fpsp_v3, s)) { | ||
43 | return false; | ||
44 | } | ||
45 | |||
46 | - if (!arm_dc_feature(s, ARM_FEATURE_VFP3)) { | ||
47 | + if (!dc_isar_feature(aa32_fpshvec, s) && | ||
48 | + (veclen != 0 || s->vec_stride != 0)) { | ||
49 | return false; | ||
50 | } | ||
51 | |||
52 | @@ -XXX,XX +XXX,XX @@ static bool trans_VMOV_imm_dp(DisasContext *s, arg_VMOV_imm_dp *a) | ||
53 | |||
54 | vd = a->vd; | ||
55 | |||
56 | - if (!dc_isar_feature(aa32_fpdp_v2, s)) { | ||
57 | + if (!dc_isar_feature(aa32_fpdp_v3, s)) { | ||
58 | return false; | ||
59 | } | ||
60 | |||
61 | @@ -XXX,XX +XXX,XX @@ static bool trans_VMOV_imm_dp(DisasContext *s, arg_VMOV_imm_dp *a) | ||
62 | return false; | ||
63 | } | ||
64 | |||
65 | - if (!arm_dc_feature(s, ARM_FEATURE_VFP3)) { | ||
66 | - return false; | ||
67 | - } | ||
68 | - | ||
69 | if (!vfp_access_check(s)) { | ||
70 | return true; | ||
71 | } | ||
72 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_fix_sp(DisasContext *s, arg_VCVT_fix_sp *a) | ||
73 | TCGv_ptr fpst; | ||
74 | int frac_bits; | ||
75 | |||
76 | - if (!arm_dc_feature(s, ARM_FEATURE_VFP3)) { | ||
77 | + if (!dc_isar_feature(aa32_fpsp_v3, s)) { | ||
78 | return false; | ||
79 | } | ||
80 | |||
81 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_fix_dp(DisasContext *s, arg_VCVT_fix_dp *a) | ||
82 | TCGv_ptr fpst; | ||
83 | int frac_bits; | ||
84 | |||
85 | - if (!dc_isar_feature(aa32_fpdp_v2, s)) { | ||
86 | - return false; | ||
87 | - } | ||
88 | - | ||
89 | - if (!arm_dc_feature(s, ARM_FEATURE_VFP3)) { | ||
90 | + if (!dc_isar_feature(aa32_fpdp_v3, s)) { | ||
91 | return false; | ||
92 | } | ||
93 | |||
94 | -- | ||
95 | 2.20.1 | ||
96 | |||
97 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | 1 | From: Richard Henderson <richard.henderson@linaro.org> | |
2 | |||
3 | We will eventually remove the early ARM_FEATURE_VFP test, | ||
4 | so add a proper test for each trans_* that does not already | ||
5 | have another ISA test. | ||
6 | |||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20200214181547.21408-11-richard.henderson@linaro.org | ||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | target/arm/translate-vfp.inc.c | 78 ++++++++++++++++++++++++++++++---- | ||
13 | 1 file changed, 69 insertions(+), 9 deletions(-) | ||
14 | |||
15 | diff --git a/target/arm/translate-vfp.inc.c b/target/arm/translate-vfp.inc.c | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/target/arm/translate-vfp.inc.c | ||
18 | +++ b/target/arm/translate-vfp.inc.c | ||
19 | @@ -XXX,XX +XXX,XX @@ static bool trans_VMOV_to_gp(DisasContext *s, arg_VMOV_to_gp *a) | ||
20 | int pass; | ||
21 | uint32_t offset; | ||
22 | |||
23 | + /* SIZE == 2 is a VFP instruction; otherwise NEON. */ | ||
24 | + if (a->size == 2 | ||
25 | + ? !dc_isar_feature(aa32_fpsp_v2, s) | ||
26 | + : !arm_dc_feature(s, ARM_FEATURE_NEON)) { | ||
27 | + return false; | ||
28 | + } | ||
29 | + | ||
30 | /* UNDEF accesses to D16-D31 if they don't exist */ | ||
31 | if (!dc_isar_feature(aa32_simd_r32, s) && (a->vn & 0x10)) { | ||
32 | return false; | ||
33 | @@ -XXX,XX +XXX,XX @@ static bool trans_VMOV_to_gp(DisasContext *s, arg_VMOV_to_gp *a) | ||
34 | pass = extract32(offset, 2, 1); | ||
35 | offset = extract32(offset, 0, 2) * 8; | ||
36 | |||
37 | - if (a->size != 2 && !arm_dc_feature(s, ARM_FEATURE_NEON)) { | ||
38 | - return false; | ||
39 | - } | ||
40 | - | ||
41 | if (!vfp_access_check(s)) { | ||
42 | return true; | ||
43 | } | ||
44 | @@ -XXX,XX +XXX,XX @@ static bool trans_VMOV_from_gp(DisasContext *s, arg_VMOV_from_gp *a) | ||
45 | int pass; | ||
46 | uint32_t offset; | ||
47 | |||
48 | + /* SIZE == 2 is a VFP instruction; otherwise NEON. */ | ||
49 | + if (a->size == 2 | ||
50 | + ? !dc_isar_feature(aa32_fpsp_v2, s) | ||
51 | + : !arm_dc_feature(s, ARM_FEATURE_NEON)) { | ||
52 | + return false; | ||
53 | + } | ||
54 | + | ||
55 | /* UNDEF accesses to D16-D31 if they don't exist */ | ||
56 | if (!dc_isar_feature(aa32_simd_r32, s) && (a->vn & 0x10)) { | ||
57 | return false; | ||
58 | @@ -XXX,XX +XXX,XX @@ static bool trans_VMOV_from_gp(DisasContext *s, arg_VMOV_from_gp *a) | ||
59 | pass = extract32(offset, 2, 1); | ||
60 | offset = extract32(offset, 0, 2) * 8; | ||
61 | |||
62 | - if (a->size != 2 && !arm_dc_feature(s, ARM_FEATURE_NEON)) { | ||
63 | - return false; | ||
64 | - } | ||
65 | - | ||
66 | if (!vfp_access_check(s)) { | ||
67 | return true; | ||
68 | } | ||
69 | @@ -XXX,XX +XXX,XX @@ static bool trans_VMSR_VMRS(DisasContext *s, arg_VMSR_VMRS *a) | ||
70 | TCGv_i32 tmp; | ||
71 | bool ignore_vfp_enabled = false; | ||
72 | |||
73 | + if (!dc_isar_feature(aa32_fpsp_v2, s)) { | ||
74 | + return false; | ||
75 | + } | ||
76 | + | ||
77 | if (arm_dc_feature(s, ARM_FEATURE_M)) { | ||
78 | /* | ||
79 | * The only M-profile VFP vmrs/vmsr sysreg is FPSCR. | ||
80 | @@ -XXX,XX +XXX,XX @@ static bool trans_VMOV_single(DisasContext *s, arg_VMOV_single *a) | ||
81 | { | ||
82 | TCGv_i32 tmp; | ||
83 | |||
84 | + if (!dc_isar_feature(aa32_fpsp_v2, s)) { | ||
85 | + return false; | ||
86 | + } | ||
87 | + | ||
88 | if (!vfp_access_check(s)) { | ||
89 | return true; | ||
90 | } | ||
91 | @@ -XXX,XX +XXX,XX @@ static bool trans_VMOV_64_sp(DisasContext *s, arg_VMOV_64_sp *a) | ||
92 | { | ||
93 | TCGv_i32 tmp; | ||
94 | |||
95 | + if (!dc_isar_feature(aa32_fpsp_v2, s)) { | ||
96 | + return false; | ||
97 | + } | ||
98 | + | ||
99 | /* | ||
100 | * VMOV between two general-purpose registers and two single precision | ||
101 | * floating point registers | ||
102 | @@ -XXX,XX +XXX,XX @@ static bool trans_VMOV_64_dp(DisasContext *s, arg_VMOV_64_dp *a) | ||
103 | |||
104 | /* | ||
105 | * VMOV between two general-purpose registers and one double precision | ||
106 | - * floating point register | ||
107 | + * floating point register. Note that this does not require support | ||
108 | + * for double precision arithmetic. | ||
109 | */ | ||
110 | + if (!dc_isar_feature(aa32_fpsp_v2, s)) { | ||
111 | + return false; | ||
112 | + } | ||
113 | |||
114 | /* UNDEF accesses to D16-D31 if they don't exist */ | ||
115 | if (!dc_isar_feature(aa32_simd_r32, s) && (a->vm & 0x10)) { | ||
116 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLDR_VSTR_sp(DisasContext *s, arg_VLDR_VSTR_sp *a) | ||
117 | uint32_t offset; | ||
118 | TCGv_i32 addr, tmp; | ||
119 | |||
120 | + if (!dc_isar_feature(aa32_fpsp_v2, s)) { | ||
121 | + return false; | ||
122 | + } | ||
123 | + | ||
124 | if (!vfp_access_check(s)) { | ||
125 | return true; | ||
126 | } | ||
127 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLDR_VSTR_dp(DisasContext *s, arg_VLDR_VSTR_dp *a) | ||
128 | TCGv_i32 addr; | ||
129 | TCGv_i64 tmp; | ||
130 | |||
131 | + /* Note that this does not require support for double arithmetic. */ | ||
132 | + if (!dc_isar_feature(aa32_fpsp_v2, s)) { | ||
133 | + return false; | ||
134 | + } | ||
135 | + | ||
136 | /* UNDEF accesses to D16-D31 if they don't exist */ | ||
137 | if (!dc_isar_feature(aa32_simd_r32, s) && (a->vd & 0x10)) { | ||
138 | return false; | ||
139 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLDM_VSTM_sp(DisasContext *s, arg_VLDM_VSTM_sp *a) | ||
140 | TCGv_i32 addr, tmp; | ||
141 | int i, n; | ||
142 | |||
143 | + if (!dc_isar_feature(aa32_fpsp_v2, s)) { | ||
144 | + return false; | ||
145 | + } | ||
146 | + | ||
147 | n = a->imm; | ||
148 | |||
149 | if (n == 0 || (a->vd + n) > 32) { | ||
150 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLDM_VSTM_dp(DisasContext *s, arg_VLDM_VSTM_dp *a) | ||
151 | TCGv_i64 tmp; | ||
152 | int i, n; | ||
153 | |||
154 | + /* Note that this does not require support for double arithmetic. */ | ||
155 | + if (!dc_isar_feature(aa32_fpsp_v2, s)) { | ||
156 | + return false; | ||
157 | + } | ||
158 | + | ||
159 | n = a->imm >> 1; | ||
160 | |||
161 | if (n == 0 || (a->vd + n) > 32 || n > 16) { | ||
162 | @@ -XXX,XX +XXX,XX @@ static bool do_vfp_3op_sp(DisasContext *s, VFPGen3OpSPFn *fn, | ||
163 | TCGv_i32 f0, f1, fd; | ||
164 | TCGv_ptr fpst; | ||
165 | |||
166 | + if (!dc_isar_feature(aa32_fpsp_v2, s)) { | ||
167 | + return false; | ||
168 | + } | ||
169 | + | ||
170 | if (!dc_isar_feature(aa32_fpshvec, s) && | ||
171 | (veclen != 0 || s->vec_stride != 0)) { | ||
172 | return false; | ||
173 | @@ -XXX,XX +XXX,XX @@ static bool do_vfp_2op_sp(DisasContext *s, VFPGen2OpSPFn *fn, int vd, int vm) | ||
174 | int veclen = s->vec_len; | ||
175 | TCGv_i32 f0, fd; | ||
176 | |||
177 | + if (!dc_isar_feature(aa32_fpsp_v2, s)) { | ||
178 | + return false; | ||
179 | + } | ||
180 | + | ||
181 | if (!dc_isar_feature(aa32_fpshvec, s) && | ||
182 | (veclen != 0 || s->vec_stride != 0)) { | ||
183 | return false; | ||
184 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCMP_sp(DisasContext *s, arg_VCMP_sp *a) | ||
185 | { | ||
186 | TCGv_i32 vd, vm; | ||
187 | |||
188 | + if (!dc_isar_feature(aa32_fpsp_v2, s)) { | ||
189 | + return false; | ||
190 | + } | ||
191 | + | ||
192 | /* Vm/M bits must be zero for the Z variant */ | ||
193 | if (a->z && a->vm != 0) { | ||
194 | return false; | ||
195 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_int_sp(DisasContext *s, arg_VCVT_int_sp *a) | ||
196 | TCGv_i32 vm; | ||
197 | TCGv_ptr fpst; | ||
198 | |||
199 | + if (!dc_isar_feature(aa32_fpsp_v2, s)) { | ||
200 | + return false; | ||
201 | + } | ||
202 | + | ||
203 | if (!vfp_access_check(s)) { | ||
204 | return true; | ||
205 | } | ||
206 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_sp_int(DisasContext *s, arg_VCVT_sp_int *a) | ||
207 | TCGv_i32 vm; | ||
208 | TCGv_ptr fpst; | ||
209 | |||
210 | + if (!dc_isar_feature(aa32_fpsp_v2, s)) { | ||
211 | + return false; | ||
212 | + } | ||
213 | + | ||
214 | if (!vfp_access_check(s)) { | ||
215 | return true; | ||
216 | } | ||
217 | -- | ||
218 | 2.20.1 | ||
219 | |||
220 | diff view generated by jsdifflib |