1 | Last handful of arm patches before softfreeze... | 1 | Hi; here's another arm pullreq; by volume most of this is |
---|---|---|---|
2 | refactoring from me, but there are also some bugfixes and | ||
3 | other bits and pieces here. | ||
2 | 4 | ||
3 | The following changes since commit a98135f727595382e200d04c2996e868b7925a01: | 5 | thanks |
6 | -- PMM | ||
4 | 7 | ||
5 | Merge remote-tracking branch 'remotes/kraxel/tags/vga-20200316-pull-request' into staging (2020-03-16 14:55:59 +0000) | 8 | The following changes since commit ed734377ab3f3f3cc15d7aa301a87ab6370f2eed: |
9 | |||
10 | Merge tag 'linux-user-fix-gupnp-pull-request' of https://github.com/hdeller/qemu-hppa into staging (2025-01-24 14:43:07 -0500) | ||
6 | 11 | ||
7 | are available in the Git repository at: | 12 | are available in the Git repository at: |
8 | 13 | ||
9 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20200317 | 14 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20250128-1 |
10 | 15 | ||
11 | for you to fetch changes up to e88d3671e3bbd59d385838a4101ea19cdcf47309: | 16 | for you to fetch changes up to 664280abddcb3cacc9c6204706bb739fcc1316f7: |
12 | 17 | ||
13 | hw/arm/pxa2xx: Do not wire up OHCI for PXA255 (2020-03-17 11:36:48 +0000) | 18 | hw/usb/canokey: Fix buffer overflow for OUT packet (2025-01-28 18:40:19 +0000) |
14 | 19 | ||
15 | ---------------------------------------------------------------- | 20 | ---------------------------------------------------------------- |
16 | target-arm: | 21 | target-arm queue: |
17 | * hw/arm/pxa2xx: Do not wire up OHCI for PXA255 | 22 | * hw/arm: Remove various uses of first_cpu global |
18 | * aspeed/smc: Fix number of dummy cycles for FAST_READ_4 command | 23 | * hw/char/imx_serial: Fix reset value of UFCR register |
19 | * m25p80: Improve command handling for Jedec and unsupported commands | 24 | * hw/char/imx_serial: Update all state before restarting ageing timer |
20 | * hw/net/imx_fec: write TGSR and TCSR3 in imx_enet_write() | 25 | * hw/pci-host/designware: Expose MSI IRQ |
21 | * hw/arm/fsl-imx6, imx6ul: Wire up USB controllers | 26 | * hw/arm/stellaris: refactoring, cleanup |
22 | * hw/arm/fsl-imx6ul: Instantiate unimplemented pwm and can devices | 27 | * hw/arm/stellaris: map both I2C controllers |
28 | * tests/functional: Add a test for the arm microbit machine | ||
29 | * target/arm: arm_reset_sve_state() should set FPSR, not FPCR | ||
30 | * target/arm: refactorings preparatory to FEAT_AFP implementation | ||
31 | * fpu: Rename float_flag_input_denormal to float_flag_input_denormal_flushed | ||
32 | * fpu: Rename float_flag_output_denormal to float_flag_output_denormal_flushed | ||
33 | * hw/usb/canokey: Fix buffer overflow for OUT packet | ||
23 | 34 | ||
24 | ---------------------------------------------------------------- | 35 | ---------------------------------------------------------------- |
25 | Chen Qun (1): | 36 | Bernhard Beschow (3): |
26 | hw/net/imx_fec: write TGSR and TCSR3 in imx_enet_write() | 37 | hw/char/imx_serial: Fix reset value of UFCR register |
38 | hw/char/imx_serial: Update all state before restarting ageing timer | ||
39 | hw/pci-host/designware: Expose MSI IRQ | ||
27 | 40 | ||
28 | Guenter Roeck (10): | 41 | Hongren Zheng (1): |
29 | hw/usb: Add basic i.MX USB Phy support | 42 | hw/usb/canokey: Fix buffer overflow for OUT packet |
30 | hw/arm/fsl-imx6ul: Fix USB interrupt numbers | ||
31 | hw/arm/fsl-imx6ul: Instantiate unimplemented pwm and can devices | ||
32 | hw/arm/fsl-imx6ul: Wire up USB controllers | ||
33 | hw/arm/fsl-imx6: Wire up USB controllers | ||
34 | m25p80: Convert to support tracing | ||
35 | m25p80: Improve command handling for Jedec commands | ||
36 | m25p80: Improve command handling for unsupported commands | ||
37 | aspeed/smc: Fix number of dummy cycles for FAST_READ_4 command | ||
38 | hw/arm/pxa2xx: Do not wire up OHCI for PXA255 | ||
39 | 43 | ||
40 | hw/usb/Makefile.objs | 2 + | 44 | Peter Maydell (22): |
41 | include/hw/arm/fsl-imx6.h | 6 ++ | 45 | target/arm: arm_reset_sve_state() should set FPSR, not FPCR |
42 | include/hw/arm/fsl-imx6ul.h | 16 ++- | 46 | target/arm: Use FPSR_ constants in vfp_exceptbits_from_host() |
43 | include/hw/usb/imx-usb-phy.h | 53 ++++++++++ | 47 | target/arm: Use uint32_t in vfp_exceptbits_from_host() |
44 | hw/arm/fsl-imx6.c | 36 +++++++ | 48 | target/arm: Define new fp_status_a32 and fp_status_a64 |
45 | hw/arm/fsl-imx6ul.c | 49 ++++++++++ | 49 | target/arm: Use vfp.fp_status_a64 in A64-only helper functions |
46 | hw/arm/pxa2xx.c | 3 - | 50 | target/arm: Use fp_status_a64 or fp_status_a32 in is_ebf() |
47 | hw/block/m25p80.c | 58 +++++------ | 51 | target/arm: Use fp_status_a32 in vjvct helper |
48 | hw/net/imx_fec.c | 6 +- | 52 | target/arm: Use fp_status_a32 in vfp_cmp helpers |
49 | hw/ssi/aspeed_smc.c | 2 +- | 53 | target/arm: Use FPST_A32 in A32 decoder |
50 | hw/usb/imx-usb-phy.c | 225 +++++++++++++++++++++++++++++++++++++++++++ | 54 | target/arm: Use FPST_A64 in A64 decoder |
51 | MAINTAINERS | 2 + | 55 | target/arm: Remove now-unused vfp.fp_status and FPST_FPCR |
52 | hw/arm/Kconfig | 1 + | 56 | target/arm: Define new fp_status_f16_a32 and fp_status_f16_a64 |
53 | hw/block/trace-events | 16 +++ | 57 | target/arm: Use fp_status_f16_a32 in AArch32-only helpers |
54 | hw/usb/Kconfig | 5 + | 58 | target/arm: Use fp_status_f16_a64 in AArch64-only helpers |
55 | 15 files changed, 444 insertions(+), 36 deletions(-) | 59 | target/arm: Use FPST_A32_F16 in A32 decoder |
56 | create mode 100644 include/hw/usb/imx-usb-phy.h | 60 | target/arm: Use FPST_A64_F16 in A64 decoder |
57 | create mode 100644 hw/usb/imx-usb-phy.c | 61 | target/arm: Remove now-unused vfp.fp_status_f16 and FPST_FPCR_F16 |
62 | fpu: Rename float_flag_input_denormal to float_flag_input_denormal_flushed | ||
63 | fpu: Rename float_flag_output_denormal to float_flag_output_denormal_flushed | ||
64 | fpu: Fix a comment in softfloat-types.h | ||
65 | target/arm: Remove redundant advsimd float16 helpers | ||
66 | target/arm: Use FPST_A64_F16 for halfprec-to-other conversions | ||
58 | 67 | ||
68 | Philippe Mathieu-Daudé (9): | ||
69 | hw/arm/nrf51: Rename ARMv7MState 'cpu' -> 'armv7m' | ||
70 | hw/arm/stellaris: Add 'armv7m' local variable | ||
71 | hw/arm/v7m: Remove use of &first_cpu in machine_init() | ||
72 | hw/arm/stellaris: Link each board schematic | ||
73 | hw/arm/stellaris: Constify read-only arrays | ||
74 | hw/arm/stellaris: Remove incorrect unimplemented i2c-0 at 0x40002000 | ||
75 | hw/arm/stellaris: Replace magic numbers by definitions | ||
76 | hw/arm/stellaris: Use DEVCAP macro to access DeviceCapability registers | ||
77 | hw/arm/stellaris: Map both I2C controllers | ||
78 | |||
79 | Thomas Huth (1): | ||
80 | tests/functional: Add a test for the arm microbit machine | ||
81 | |||
82 | MAINTAINERS | 1 + | ||
83 | hw/usb/canokey.h | 4 -- | ||
84 | include/fpu/softfloat-types.h | 10 +-- | ||
85 | include/hw/arm/fsl-imx6.h | 4 +- | ||
86 | include/hw/arm/fsl-imx7.h | 4 +- | ||
87 | include/hw/arm/nrf51_soc.h | 2 +- | ||
88 | include/hw/char/imx_serial.h | 2 +- | ||
89 | include/hw/pci-host/designware.h | 1 + | ||
90 | target/arm/cpu.h | 12 ++-- | ||
91 | target/arm/tcg/helper-a64.h | 8 --- | ||
92 | target/arm/tcg/translate.h | 32 ++++++--- | ||
93 | fpu/softfloat.c | 6 +- | ||
94 | hw/arm/b-l475e-iot01a.c | 2 +- | ||
95 | hw/arm/fsl-imx6.c | 13 +++- | ||
96 | hw/arm/fsl-imx7.c | 13 +++- | ||
97 | hw/arm/microbit.c | 2 +- | ||
98 | hw/arm/mps2-tz.c | 2 +- | ||
99 | hw/arm/mps2.c | 2 +- | ||
100 | hw/arm/msf2-som.c | 2 +- | ||
101 | hw/arm/musca.c | 2 +- | ||
102 | hw/arm/netduino2.c | 2 +- | ||
103 | hw/arm/netduinoplus2.c | 2 +- | ||
104 | hw/arm/nrf51_soc.c | 18 ++--- | ||
105 | hw/arm/olimex-stm32-h405.c | 2 +- | ||
106 | hw/arm/stellaris.c | 118 +++++++++++++++++++----------- | ||
107 | hw/arm/stm32vldiscovery.c | 2 +- | ||
108 | hw/char/imx_serial.c | 7 +- | ||
109 | hw/pci-host/designware.c | 7 +- | ||
110 | hw/usb/canokey.c | 6 +- | ||
111 | target/arm/cpu.c | 6 +- | ||
112 | target/arm/helper.c | 2 +- | ||
113 | target/arm/tcg/helper-a64.c | 9 --- | ||
114 | target/arm/tcg/sme_helper.c | 6 +- | ||
115 | target/arm/tcg/sve_helper.c | 6 +- | ||
116 | target/arm/tcg/translate-a64.c | 103 ++++++++++++++------------- | ||
117 | target/arm/tcg/translate-sme.c | 4 +- | ||
118 | target/arm/tcg/translate-sve.c | 130 +++++++++++++++++----------------- | ||
119 | target/arm/tcg/translate-vfp.c | 78 ++++++++++---------- | ||
120 | target/arm/tcg/vec_helper.c | 22 +++--- | ||
121 | target/arm/vfp_helper.c | 73 +++++++++++-------- | ||
122 | target/i386/tcg/fpu_helper.c | 8 +-- | ||
123 | target/m68k/fpu_helper.c | 2 +- | ||
124 | target/mips/tcg/msa_helper.c | 4 +- | ||
125 | target/rx/op_helper.c | 4 +- | ||
126 | target/tricore/fpu_helper.c | 6 +- | ||
127 | fpu/softfloat-parts.c.inc | 4 +- | ||
128 | hw/arm/Kconfig | 2 + | ||
129 | tests/functional/meson.build | 1 + | ||
130 | tests/functional/test_arm_microbit.py | 31 ++++++++ | ||
131 | 49 files changed, 452 insertions(+), 337 deletions(-) | ||
132 | create mode 100755 tests/functional/test_arm_microbit.py | ||
133 | diff view generated by jsdifflib |
1 | From: Guenter Roeck <linux@roeck-us.net> | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | The Linux kernel recently started using FAST_READ_4 commands. | 3 | The ARMv7MState object is not simply a CPU, it also |
4 | This results in flash read failures. At the same time, the m25p80 | 4 | contains the NVIC, SysTick timer, and various MemoryRegions. |
5 | emulation is seen to read 8 more bytes than expected. Adjusting the | ||
6 | expected number of dummy cycles to match FAST_READ fixes the problem. | ||
7 | 5 | ||
8 | Fixes: f95c4bffdc4c ("aspeed/smc: snoop SPI transfers to fake dummy cycles") | 6 | Rename the field as 'armv7m', like other Cortex-M boards. |
9 | Reviewed-by: Cédric Le Goater <clg@kaod.org> | 7 | |
10 | Signed-off-by: Guenter Roeck <linux@roeck-us.net> | 8 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
11 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 9 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> |
10 | Message-id: 20250112225614.33723-2-philmd@linaro.org | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | --- | 12 | --- |
14 | hw/ssi/aspeed_smc.c | 2 +- | 13 | include/hw/arm/nrf51_soc.h | 2 +- |
15 | 1 file changed, 1 insertion(+), 1 deletion(-) | 14 | hw/arm/nrf51_soc.c | 18 +++++++++--------- |
15 | 2 files changed, 10 insertions(+), 10 deletions(-) | ||
16 | 16 | ||
17 | diff --git a/hw/ssi/aspeed_smc.c b/hw/ssi/aspeed_smc.c | 17 | diff --git a/include/hw/arm/nrf51_soc.h b/include/hw/arm/nrf51_soc.h |
18 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/hw/ssi/aspeed_smc.c | 19 | --- a/include/hw/arm/nrf51_soc.h |
20 | +++ b/hw/ssi/aspeed_smc.c | 20 | +++ b/include/hw/arm/nrf51_soc.h |
21 | @@ -XXX,XX +XXX,XX @@ static int aspeed_smc_num_dummies(uint8_t command) | 21 | @@ -XXX,XX +XXX,XX @@ struct NRF51State { |
22 | case FAST_READ: | 22 | SysBusDevice parent_obj; |
23 | case DOR: | 23 | |
24 | case QOR: | 24 | /*< public >*/ |
25 | + case FAST_READ_4: | 25 | - ARMv7MState cpu; |
26 | case DOR_4: | 26 | + ARMv7MState armv7m; |
27 | case QOR_4: | 27 | |
28 | return 1; | 28 | NRF51UARTState uart; |
29 | case DIOR: | 29 | NRF51RNGState rng; |
30 | - case FAST_READ_4: | 30 | diff --git a/hw/arm/nrf51_soc.c b/hw/arm/nrf51_soc.c |
31 | case DIOR_4: | 31 | index XXXXXXX..XXXXXXX 100644 |
32 | return 2; | 32 | --- a/hw/arm/nrf51_soc.c |
33 | case QIOR: | 33 | +++ b/hw/arm/nrf51_soc.c |
34 | @@ -XXX,XX +XXX,XX @@ static void nrf51_soc_realize(DeviceState *dev_soc, Error **errp) | ||
35 | } | ||
36 | /* This clock doesn't need migration because it is fixed-frequency */ | ||
37 | clock_set_hz(s->sysclk, HCLK_FRQ); | ||
38 | - qdev_connect_clock_in(DEVICE(&s->cpu), "cpuclk", s->sysclk); | ||
39 | + qdev_connect_clock_in(DEVICE(&s->armv7m), "cpuclk", s->sysclk); | ||
40 | /* | ||
41 | * This SoC has no systick device, so don't connect refclk. | ||
42 | * TODO: model the lack of systick (currently the armv7m object | ||
43 | * will always provide one). | ||
44 | */ | ||
45 | |||
46 | - object_property_set_link(OBJECT(&s->cpu), "memory", OBJECT(&s->container), | ||
47 | + object_property_set_link(OBJECT(&s->armv7m), "memory", OBJECT(&s->container), | ||
48 | &error_abort); | ||
49 | - if (!sysbus_realize(SYS_BUS_DEVICE(&s->cpu), errp)) { | ||
50 | + if (!sysbus_realize(SYS_BUS_DEVICE(&s->armv7m), errp)) { | ||
51 | return; | ||
52 | } | ||
53 | |||
54 | @@ -XXX,XX +XXX,XX @@ static void nrf51_soc_realize(DeviceState *dev_soc, Error **errp) | ||
55 | mr = sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->uart), 0); | ||
56 | memory_region_add_subregion_overlap(&s->container, NRF51_UART_BASE, mr, 0); | ||
57 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->uart), 0, | ||
58 | - qdev_get_gpio_in(DEVICE(&s->cpu), | ||
59 | + qdev_get_gpio_in(DEVICE(&s->armv7m), | ||
60 | BASE_TO_IRQ(NRF51_UART_BASE))); | ||
61 | |||
62 | /* RNG */ | ||
63 | @@ -XXX,XX +XXX,XX @@ static void nrf51_soc_realize(DeviceState *dev_soc, Error **errp) | ||
64 | mr = sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->rng), 0); | ||
65 | memory_region_add_subregion_overlap(&s->container, NRF51_RNG_BASE, mr, 0); | ||
66 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->rng), 0, | ||
67 | - qdev_get_gpio_in(DEVICE(&s->cpu), | ||
68 | + qdev_get_gpio_in(DEVICE(&s->armv7m), | ||
69 | BASE_TO_IRQ(NRF51_RNG_BASE))); | ||
70 | |||
71 | /* UICR, FICR, NVMC, FLASH */ | ||
72 | @@ -XXX,XX +XXX,XX @@ static void nrf51_soc_realize(DeviceState *dev_soc, Error **errp) | ||
73 | |||
74 | sysbus_mmio_map(SYS_BUS_DEVICE(&s->timer[i]), 0, base_addr); | ||
75 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->timer[i]), 0, | ||
76 | - qdev_get_gpio_in(DEVICE(&s->cpu), | ||
77 | + qdev_get_gpio_in(DEVICE(&s->armv7m), | ||
78 | BASE_TO_IRQ(base_addr))); | ||
79 | } | ||
80 | |||
81 | @@ -XXX,XX +XXX,XX @@ static void nrf51_soc_init(Object *obj) | ||
82 | |||
83 | memory_region_init(&s->container, obj, "nrf51-container", UINT64_MAX); | ||
84 | |||
85 | - object_initialize_child(OBJECT(s), "armv6m", &s->cpu, TYPE_ARMV7M); | ||
86 | - qdev_prop_set_string(DEVICE(&s->cpu), "cpu-type", | ||
87 | + object_initialize_child(OBJECT(s), "armv6m", &s->armv7m, TYPE_ARMV7M); | ||
88 | + qdev_prop_set_string(DEVICE(&s->armv7m), "cpu-type", | ||
89 | ARM_CPU_TYPE_NAME("cortex-m0")); | ||
90 | - qdev_prop_set_uint32(DEVICE(&s->cpu), "num-irq", 32); | ||
91 | + qdev_prop_set_uint32(DEVICE(&s->armv7m), "num-irq", 32); | ||
92 | |||
93 | object_initialize_child(obj, "uart", &s->uart, TYPE_NRF51_UART); | ||
94 | object_property_add_alias(obj, "serial0", OBJECT(&s->uart), "chardev"); | ||
34 | -- | 95 | -- |
35 | 2.20.1 | 96 | 2.34.1 |
36 | 97 | ||
37 | 98 | diff view generated by jsdifflib |
1 | From: Guenter Roeck <linux@roeck-us.net> | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | When requesting JEDEC data using the JEDEC_READ command, the Linux kernel | 3 | While the TYPE_ARMV7M object forward its NVIC interrupt lines, |
4 | always requests 6 bytes. The current implementation only returns three | 4 | it is somehow misleading to name it 'nvic'. Add the 'armv7m' |
5 | bytes, and interprets the remaining three bytes as new commands. | 5 | local variable for clarity, but also keep the 'nvic' variable |
6 | While this does not matter most of the time, it is at the very least | 6 | behaving like before when used for wiring IRQ lines. |
7 | confusing. To avoid the problem, always report up to 6 bytes of JEDEC | ||
8 | data. Fill remaining data with 0. | ||
9 | 7 | ||
10 | Signed-off-by: Guenter Roeck <linux@roeck-us.net> | 8 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
11 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
12 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | 9 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> |
13 | Reviewed-by: Cédric Le Goater <clg@kaod.org> | 10 | Message-id: 20250112225614.33723-3-philmd@linaro.org |
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
15 | --- | 12 | --- |
16 | hw/block/m25p80.c | 5 ++++- | 13 | hw/arm/stellaris.c | 21 +++++++++++---------- |
17 | 1 file changed, 4 insertions(+), 1 deletion(-) | 14 | 1 file changed, 11 insertions(+), 10 deletions(-) |
18 | 15 | ||
19 | diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c | 16 | diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c |
20 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/hw/block/m25p80.c | 18 | --- a/hw/arm/stellaris.c |
22 | +++ b/hw/block/m25p80.c | 19 | +++ b/hw/arm/stellaris.c |
23 | @@ -XXX,XX +XXX,XX @@ static void decode_new_cmd(Flash *s, uint32_t value) | 20 | @@ -XXX,XX +XXX,XX @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board) |
24 | for (i = 0; i < s->pi->id_len; i++) { | 21 | */ |
25 | s->data[i] = s->pi->id[i]; | 22 | |
26 | } | 23 | Object *soc_container; |
27 | + for (; i < SPI_NOR_MAX_ID_LEN; i++) { | 24 | - DeviceState *gpio_dev[7], *nvic; |
28 | + s->data[i] = 0; | 25 | + DeviceState *gpio_dev[7], *armv7m, *nvic; |
29 | + } | 26 | qemu_irq gpio_in[7][8]; |
30 | 27 | qemu_irq gpio_out[7][8]; | |
31 | - s->len = s->pi->id_len; | 28 | qemu_irq adc; |
32 | + s->len = SPI_NOR_MAX_ID_LEN; | 29 | @@ -XXX,XX +XXX,XX @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board) |
33 | s->pos = 0; | 30 | qdev_prop_set_uint32(ssys_dev, "dc4", board->dc4); |
34 | s->state = STATE_READING_DATA; | 31 | sysbus_realize_and_unref(SYS_BUS_DEVICE(ssys_dev), &error_fatal); |
35 | break; | 32 | |
33 | - nvic = qdev_new(TYPE_ARMV7M); | ||
34 | - object_property_add_child(soc_container, "v7m", OBJECT(nvic)); | ||
35 | - qdev_prop_set_uint32(nvic, "num-irq", NUM_IRQ_LINES); | ||
36 | - qdev_prop_set_uint8(nvic, "num-prio-bits", NUM_PRIO_BITS); | ||
37 | - qdev_prop_set_string(nvic, "cpu-type", ms->cpu_type); | ||
38 | - qdev_prop_set_bit(nvic, "enable-bitband", true); | ||
39 | - qdev_connect_clock_in(nvic, "cpuclk", | ||
40 | + armv7m = qdev_new(TYPE_ARMV7M); | ||
41 | + object_property_add_child(soc_container, "v7m", OBJECT(armv7m)); | ||
42 | + qdev_prop_set_uint32(armv7m, "num-irq", NUM_IRQ_LINES); | ||
43 | + qdev_prop_set_uint8(armv7m, "num-prio-bits", NUM_PRIO_BITS); | ||
44 | + qdev_prop_set_string(armv7m, "cpu-type", ms->cpu_type); | ||
45 | + qdev_prop_set_bit(armv7m, "enable-bitband", true); | ||
46 | + qdev_connect_clock_in(armv7m, "cpuclk", | ||
47 | qdev_get_clock_out(ssys_dev, "SYSCLK")); | ||
48 | /* This SoC does not connect the systick reference clock */ | ||
49 | - object_property_set_link(OBJECT(nvic), "memory", | ||
50 | + object_property_set_link(OBJECT(armv7m), "memory", | ||
51 | OBJECT(get_system_memory()), &error_abort); | ||
52 | /* This will exit with an error if the user passed us a bad cpu_type */ | ||
53 | - sysbus_realize_and_unref(SYS_BUS_DEVICE(nvic), &error_fatal); | ||
54 | + sysbus_realize_and_unref(SYS_BUS_DEVICE(armv7m), &error_fatal); | ||
55 | + nvic = armv7m; | ||
56 | |||
57 | /* Now we can wire up the IRQ and MMIO of the system registers */ | ||
58 | sysbus_mmio_map(SYS_BUS_DEVICE(ssys_dev), 0, 0x400fe000); | ||
36 | -- | 59 | -- |
37 | 2.20.1 | 60 | 2.34.1 |
38 | 61 | ||
39 | 62 | diff view generated by jsdifflib |
1 | From: Guenter Roeck <linux@roeck-us.net> | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | IMX6UL USB controllers are quite similar to IMX7 USB controllers. | 3 | When instanciating the machine model, the machine_init() |
4 | Wire them up the same way. | 4 | implementations usually create the CPUs, so have access |
5 | to its first CPU. Use that rather then the &first_cpu | ||
6 | global. | ||
5 | 7 | ||
6 | The only real difference is that wiring up phy devices is necessary | 8 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
7 | to avoid phy reset timeouts in the Linux kernel. | 9 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> |
8 | 10 | Reviewed-by: Samuel Tardieu <sam@rfc1149.net> | |
9 | Signed-off-by: Guenter Roeck <linux@roeck-us.net> | 11 | Message-id: 20250112225614.33723-4-philmd@linaro.org |
10 | Message-id: 20200313014551.12554-5-linux@roeck-us.net | ||
11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | --- | 13 | --- |
14 | include/hw/arm/fsl-imx6ul.h | 10 ++++++++++ | 14 | hw/arm/b-l475e-iot01a.c | 2 +- |
15 | hw/arm/fsl-imx6ul.c | 35 +++++++++++++++++++++++++++++++++++ | 15 | hw/arm/microbit.c | 2 +- |
16 | 2 files changed, 45 insertions(+) | 16 | hw/arm/mps2-tz.c | 2 +- |
17 | hw/arm/mps2.c | 2 +- | ||
18 | hw/arm/msf2-som.c | 2 +- | ||
19 | hw/arm/musca.c | 2 +- | ||
20 | hw/arm/netduino2.c | 2 +- | ||
21 | hw/arm/netduinoplus2.c | 2 +- | ||
22 | hw/arm/olimex-stm32-h405.c | 2 +- | ||
23 | hw/arm/stellaris.c | 2 +- | ||
24 | hw/arm/stm32vldiscovery.c | 2 +- | ||
25 | 11 files changed, 11 insertions(+), 11 deletions(-) | ||
17 | 26 | ||
18 | diff --git a/include/hw/arm/fsl-imx6ul.h b/include/hw/arm/fsl-imx6ul.h | 27 | diff --git a/hw/arm/b-l475e-iot01a.c b/hw/arm/b-l475e-iot01a.c |
19 | index XXXXXXX..XXXXXXX 100644 | 28 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/include/hw/arm/fsl-imx6ul.h | 29 | --- a/hw/arm/b-l475e-iot01a.c |
21 | +++ b/include/hw/arm/fsl-imx6ul.h | 30 | +++ b/hw/arm/b-l475e-iot01a.c |
22 | @@ -XXX,XX +XXX,XX @@ | 31 | @@ -XXX,XX +XXX,XX @@ static void bl475e_init(MachineState *machine) |
23 | #include "hw/sd/sdhci.h" | 32 | sysbus_realize(SYS_BUS_DEVICE(&s->soc), &error_fatal); |
24 | #include "hw/ssi/imx_spi.h" | 33 | |
25 | #include "hw/net/imx_fec.h" | 34 | sc = STM32L4X5_SOC_GET_CLASS(&s->soc); |
26 | +#include "hw/usb/chipidea.h" | 35 | - armv7m_load_kernel(ARM_CPU(first_cpu), machine->kernel_filename, 0, |
27 | +#include "hw/usb/imx-usb-phy.h" | 36 | + armv7m_load_kernel(s->soc.armv7m.cpu, machine->kernel_filename, 0, |
28 | #include "exec/memory.h" | 37 | sc->flash_size); |
29 | #include "cpu.h" | 38 | |
30 | 39 | if (object_class_by_name(TYPE_DM163)) { | |
31 | @@ -XXX,XX +XXX,XX @@ enum FslIMX6ULConfiguration { | 40 | diff --git a/hw/arm/microbit.c b/hw/arm/microbit.c |
32 | FSL_IMX6UL_NUM_I2CS = 4, | ||
33 | FSL_IMX6UL_NUM_ECSPIS = 4, | ||
34 | FSL_IMX6UL_NUM_ADCS = 2, | ||
35 | + FSL_IMX6UL_NUM_USB_PHYS = 2, | ||
36 | + FSL_IMX6UL_NUM_USBS = 2, | ||
37 | }; | ||
38 | |||
39 | typedef struct FslIMX6ULState { | ||
40 | @@ -XXX,XX +XXX,XX @@ typedef struct FslIMX6ULState { | ||
41 | IMXFECState eth[FSL_IMX6UL_NUM_ETHS]; | ||
42 | SDHCIState usdhc[FSL_IMX6UL_NUM_USDHCS]; | ||
43 | IMX2WdtState wdt[FSL_IMX6UL_NUM_WDTS]; | ||
44 | + IMXUSBPHYState usbphy[FSL_IMX6UL_NUM_USB_PHYS]; | ||
45 | + ChipideaState usb[FSL_IMX6UL_NUM_USBS]; | ||
46 | MemoryRegion rom; | ||
47 | MemoryRegion caam; | ||
48 | MemoryRegion ocram; | ||
49 | @@ -XXX,XX +XXX,XX @@ enum FslIMX6ULMemoryMap { | ||
50 | FSL_IMX6UL_EPIT2_ADDR = 0x020D4000, | ||
51 | FSL_IMX6UL_EPIT1_ADDR = 0x020D0000, | ||
52 | FSL_IMX6UL_SNVS_HP_ADDR = 0x020CC000, | ||
53 | + FSL_IMX6UL_USBPHY2_ADDR = 0x020CA000, | ||
54 | + FSL_IMX6UL_USBPHY2_SIZE = (4 * 1024), | ||
55 | + FSL_IMX6UL_USBPHY1_ADDR = 0x020C9000, | ||
56 | + FSL_IMX6UL_USBPHY1_SIZE = (4 * 1024), | ||
57 | FSL_IMX6UL_ANALOG_ADDR = 0x020C8000, | ||
58 | FSL_IMX6UL_CCM_ADDR = 0x020C4000, | ||
59 | FSL_IMX6UL_WDOG2_ADDR = 0x020C0000, | ||
60 | diff --git a/hw/arm/fsl-imx6ul.c b/hw/arm/fsl-imx6ul.c | ||
61 | index XXXXXXX..XXXXXXX 100644 | 41 | index XXXXXXX..XXXXXXX 100644 |
62 | --- a/hw/arm/fsl-imx6ul.c | 42 | --- a/hw/arm/microbit.c |
63 | +++ b/hw/arm/fsl-imx6ul.c | 43 | +++ b/hw/arm/microbit.c |
64 | @@ -XXX,XX +XXX,XX @@ | 44 | @@ -XXX,XX +XXX,XX @@ static void microbit_init(MachineState *machine) |
65 | #include "qapi/error.h" | 45 | memory_region_add_subregion_overlap(&s->nrf51.container, NRF51_TWI_BASE, |
66 | #include "hw/arm/fsl-imx6ul.h" | 46 | mr, -1); |
67 | #include "hw/misc/unimp.h" | 47 | |
68 | +#include "hw/usb/imx-usb-phy.h" | 48 | - armv7m_load_kernel(ARM_CPU(first_cpu), machine->kernel_filename, |
69 | #include "hw/boards.h" | 49 | + armv7m_load_kernel(s->nrf51.armv7m.cpu, machine->kernel_filename, |
70 | #include "sysemu/sysemu.h" | 50 | 0, s->nrf51.flash_size); |
71 | #include "qemu/error-report.h" | 51 | } |
72 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_init(Object *obj) | 52 | |
73 | TYPE_IMX_ENET); | 53 | diff --git a/hw/arm/mps2-tz.c b/hw/arm/mps2-tz.c |
54 | index XXXXXXX..XXXXXXX 100644 | ||
55 | --- a/hw/arm/mps2-tz.c | ||
56 | +++ b/hw/arm/mps2-tz.c | ||
57 | @@ -XXX,XX +XXX,XX @@ static void mps2tz_common_init(MachineState *machine) | ||
58 | mms->remap_irq); | ||
74 | } | 59 | } |
75 | 60 | ||
76 | + /* USB */ | 61 | - armv7m_load_kernel(ARM_CPU(first_cpu), machine->kernel_filename, |
77 | + for (i = 0; i < FSL_IMX6UL_NUM_USB_PHYS; i++) { | 62 | + armv7m_load_kernel(mms->iotkit.armv7m[0].cpu, machine->kernel_filename, |
78 | + snprintf(name, NAME_SIZE, "usbphy%d", i); | 63 | 0, boot_ram_size(mms)); |
79 | + sysbus_init_child_obj(obj, name, &s->usbphy[i], sizeof(s->usbphy[i]), | 64 | } |
80 | + TYPE_IMX_USBPHY); | 65 | |
81 | + } | 66 | diff --git a/hw/arm/mps2.c b/hw/arm/mps2.c |
82 | + for (i = 0; i < FSL_IMX6UL_NUM_USBS; i++) { | 67 | index XXXXXXX..XXXXXXX 100644 |
83 | + snprintf(name, NAME_SIZE, "usb%d", i); | 68 | --- a/hw/arm/mps2.c |
84 | + sysbus_init_child_obj(obj, name, &s->usb[i], sizeof(s->usb[i]), | 69 | +++ b/hw/arm/mps2.c |
85 | + TYPE_CHIPIDEA); | 70 | @@ -XXX,XX +XXX,XX @@ static void mps2_common_init(MachineState *machine) |
86 | + } | 71 | qdev_get_gpio_in(armv7m, |
87 | + | 72 | mmc->fpga_type == FPGA_AN511 ? 47 : 13)); |
88 | /* | 73 | |
89 | * SDHCI | 74 | - armv7m_load_kernel(ARM_CPU(first_cpu), machine->kernel_filename, |
90 | */ | 75 | + armv7m_load_kernel(mms->armv7m.cpu, machine->kernel_filename, |
91 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp) | 76 | 0, 0x400000); |
92 | FSL_IMX6UL_ENETn_TIMER_IRQ[i])); | 77 | } |
78 | |||
79 | diff --git a/hw/arm/msf2-som.c b/hw/arm/msf2-som.c | ||
80 | index XXXXXXX..XXXXXXX 100644 | ||
81 | --- a/hw/arm/msf2-som.c | ||
82 | +++ b/hw/arm/msf2-som.c | ||
83 | @@ -XXX,XX +XXX,XX @@ static void emcraft_sf2_s2s010_init(MachineState *machine) | ||
84 | cs_line = qdev_get_gpio_in_named(spi_flash, SSI_GPIO_CS, 0); | ||
85 | sysbus_connect_irq(SYS_BUS_DEVICE(&soc->spi[0]), 1, cs_line); | ||
86 | |||
87 | - armv7m_load_kernel(ARM_CPU(first_cpu), machine->kernel_filename, | ||
88 | + armv7m_load_kernel(soc->armv7m.cpu, machine->kernel_filename, | ||
89 | 0, soc->envm_size); | ||
90 | } | ||
91 | |||
92 | diff --git a/hw/arm/musca.c b/hw/arm/musca.c | ||
93 | index XXXXXXX..XXXXXXX 100644 | ||
94 | --- a/hw/arm/musca.c | ||
95 | +++ b/hw/arm/musca.c | ||
96 | @@ -XXX,XX +XXX,XX @@ static void musca_init(MachineState *machine) | ||
97 | "cfg_sec_resp", 0)); | ||
93 | } | 98 | } |
94 | 99 | ||
95 | + /* USB */ | 100 | - armv7m_load_kernel(ARM_CPU(first_cpu), machine->kernel_filename, |
96 | + for (i = 0; i < FSL_IMX6UL_NUM_USB_PHYS; i++) { | 101 | + armv7m_load_kernel(mms->sse.armv7m[0].cpu, machine->kernel_filename, |
97 | + object_property_set_bool(OBJECT(&s->usbphy[i]), true, "realized", | 102 | 0, 0x2000000); |
98 | + &error_abort); | 103 | } |
99 | + sysbus_mmio_map(SYS_BUS_DEVICE(&s->usbphy[i]), 0, | 104 | |
100 | + FSL_IMX6UL_USBPHY1_ADDR + i * 0x1000); | 105 | diff --git a/hw/arm/netduino2.c b/hw/arm/netduino2.c |
101 | + } | 106 | index XXXXXXX..XXXXXXX 100644 |
102 | + | 107 | --- a/hw/arm/netduino2.c |
103 | + for (i = 0; i < FSL_IMX6UL_NUM_USBS; i++) { | 108 | +++ b/hw/arm/netduino2.c |
104 | + static const int FSL_IMX6UL_USBn_IRQ[] = { | 109 | @@ -XXX,XX +XXX,XX @@ static void netduino2_init(MachineState *machine) |
105 | + FSL_IMX6UL_USB1_IRQ, | 110 | qdev_connect_clock_in(dev, "sysclk", sysclk); |
106 | + FSL_IMX6UL_USB2_IRQ, | 111 | sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); |
107 | + }; | 112 | |
108 | + object_property_set_bool(OBJECT(&s->usb[i]), true, "realized", | 113 | - armv7m_load_kernel(ARM_CPU(first_cpu), machine->kernel_filename, |
109 | + &error_abort); | 114 | + armv7m_load_kernel(STM32F205_SOC(dev)->armv7m.cpu, machine->kernel_filename, |
110 | + sysbus_mmio_map(SYS_BUS_DEVICE(&s->usb[i]), 0, | 115 | 0, FLASH_SIZE); |
111 | + FSL_IMX6UL_USBO2_USB_ADDR + i * 0x200); | 116 | } |
112 | + sysbus_connect_irq(SYS_BUS_DEVICE(&s->usb[i]), 0, | 117 | |
113 | + qdev_get_gpio_in(DEVICE(&s->a7mpcore), | 118 | diff --git a/hw/arm/netduinoplus2.c b/hw/arm/netduinoplus2.c |
114 | + FSL_IMX6UL_USBn_IRQ[i])); | 119 | index XXXXXXX..XXXXXXX 100644 |
115 | + } | 120 | --- a/hw/arm/netduinoplus2.c |
116 | + | 121 | +++ b/hw/arm/netduinoplus2.c |
117 | /* | 122 | @@ -XXX,XX +XXX,XX @@ static void netduinoplus2_init(MachineState *machine) |
118 | * USDHC | 123 | qdev_connect_clock_in(dev, "sysclk", sysclk); |
119 | */ | 124 | sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); |
125 | |||
126 | - armv7m_load_kernel(ARM_CPU(first_cpu), | ||
127 | + armv7m_load_kernel(STM32F405_SOC(dev)->armv7m.cpu, | ||
128 | machine->kernel_filename, | ||
129 | 0, FLASH_SIZE); | ||
130 | } | ||
131 | diff --git a/hw/arm/olimex-stm32-h405.c b/hw/arm/olimex-stm32-h405.c | ||
132 | index XXXXXXX..XXXXXXX 100644 | ||
133 | --- a/hw/arm/olimex-stm32-h405.c | ||
134 | +++ b/hw/arm/olimex-stm32-h405.c | ||
135 | @@ -XXX,XX +XXX,XX @@ static void olimex_stm32_h405_init(MachineState *machine) | ||
136 | qdev_connect_clock_in(dev, "sysclk", sysclk); | ||
137 | sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); | ||
138 | |||
139 | - armv7m_load_kernel(ARM_CPU(first_cpu), | ||
140 | + armv7m_load_kernel(STM32F405_SOC(dev)->armv7m.cpu, | ||
141 | machine->kernel_filename, | ||
142 | 0, FLASH_SIZE); | ||
143 | } | ||
144 | diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c | ||
145 | index XXXXXXX..XXXXXXX 100644 | ||
146 | --- a/hw/arm/stellaris.c | ||
147 | +++ b/hw/arm/stellaris.c | ||
148 | @@ -XXX,XX +XXX,XX @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board) | ||
149 | create_unimplemented_device("hibernation", 0x400fc000, 0x1000); | ||
150 | create_unimplemented_device("flash-control", 0x400fd000, 0x1000); | ||
151 | |||
152 | - armv7m_load_kernel(ARM_CPU(first_cpu), ms->kernel_filename, 0, flash_size); | ||
153 | + armv7m_load_kernel(ARMV7M(armv7m)->cpu, ms->kernel_filename, 0, flash_size); | ||
154 | } | ||
155 | |||
156 | /* FIXME: Figure out how to generate these from stellaris_boards. */ | ||
157 | diff --git a/hw/arm/stm32vldiscovery.c b/hw/arm/stm32vldiscovery.c | ||
158 | index XXXXXXX..XXXXXXX 100644 | ||
159 | --- a/hw/arm/stm32vldiscovery.c | ||
160 | +++ b/hw/arm/stm32vldiscovery.c | ||
161 | @@ -XXX,XX +XXX,XX @@ static void stm32vldiscovery_init(MachineState *machine) | ||
162 | qdev_connect_clock_in(dev, "sysclk", sysclk); | ||
163 | sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); | ||
164 | |||
165 | - armv7m_load_kernel(ARM_CPU(first_cpu), | ||
166 | + armv7m_load_kernel(STM32F100_SOC(dev)->armv7m.cpu, | ||
167 | machine->kernel_filename, | ||
168 | 0, FLASH_SIZE); | ||
169 | } | ||
120 | -- | 170 | -- |
121 | 2.20.1 | 171 | 2.34.1 |
122 | 172 | ||
123 | 173 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Bernhard Beschow <shentey@gmail.com> | ||
1 | 2 | ||
3 | The value of the UCFR register is respected when echoing characters to the | ||
4 | terminal, but its reset value is reserved. Fix the reset value to the one | ||
5 | documented in the datasheet. | ||
6 | |||
7 | While at it move the related attribute out of the section of unimplemented | ||
8 | registers since its value is actually respected. | ||
9 | |||
10 | Signed-off-by: Bernhard Beschow <shentey@gmail.com> | ||
11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | --- | ||
14 | include/hw/char/imx_serial.h | 2 +- | ||
15 | hw/char/imx_serial.c | 1 + | ||
16 | 2 files changed, 2 insertions(+), 1 deletion(-) | ||
17 | |||
18 | diff --git a/include/hw/char/imx_serial.h b/include/hw/char/imx_serial.h | ||
19 | index XXXXXXX..XXXXXXX 100644 | ||
20 | --- a/include/hw/char/imx_serial.h | ||
21 | +++ b/include/hw/char/imx_serial.h | ||
22 | @@ -XXX,XX +XXX,XX @@ struct IMXSerialState { | ||
23 | uint32_t ucr1; | ||
24 | uint32_t ucr2; | ||
25 | uint32_t uts1; | ||
26 | + uint32_t ufcr; | ||
27 | |||
28 | /* | ||
29 | * The registers below are implemented just so that the | ||
30 | * guest OS sees what it has written | ||
31 | */ | ||
32 | uint32_t onems; | ||
33 | - uint32_t ufcr; | ||
34 | uint32_t ubmr; | ||
35 | uint32_t ubrc; | ||
36 | uint32_t ucr3; | ||
37 | diff --git a/hw/char/imx_serial.c b/hw/char/imx_serial.c | ||
38 | index XXXXXXX..XXXXXXX 100644 | ||
39 | --- a/hw/char/imx_serial.c | ||
40 | +++ b/hw/char/imx_serial.c | ||
41 | @@ -XXX,XX +XXX,XX @@ static void imx_serial_reset(IMXSerialState *s) | ||
42 | s->ucr3 = 0x700; | ||
43 | s->ubmr = 0; | ||
44 | s->ubrc = 4; | ||
45 | + s->ufcr = BIT(11) | BIT(0); | ||
46 | |||
47 | fifo32_reset(&s->rx_fifo); | ||
48 | timer_del(&s->ageing_timer); | ||
49 | -- | ||
50 | 2.34.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Bernhard Beschow <shentey@gmail.com> | ||
1 | 2 | ||
3 | Fixes characters to be "echoed" after each keystroke rather than after every | ||
4 | other since imx_serial_rx_fifo_ageing_timer_restart() would see ~UTS1_RXEMPTY | ||
5 | only after every other keystroke. | ||
6 | |||
7 | Signed-off-by: Bernhard Beschow <shentey@gmail.com> | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | hw/char/imx_serial.c | 6 +++--- | ||
12 | 1 file changed, 3 insertions(+), 3 deletions(-) | ||
13 | |||
14 | diff --git a/hw/char/imx_serial.c b/hw/char/imx_serial.c | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/hw/char/imx_serial.c | ||
17 | +++ b/hw/char/imx_serial.c | ||
18 | @@ -XXX,XX +XXX,XX @@ static void imx_put_data(void *opaque, uint32_t value) | ||
19 | if (fifo32_num_used(&s->rx_fifo) >= rxtl) { | ||
20 | s->usr1 |= USR1_RRDY; | ||
21 | } | ||
22 | - | ||
23 | - imx_serial_rx_fifo_ageing_timer_restart(s); | ||
24 | - | ||
25 | s->usr2 |= USR2_RDR; | ||
26 | s->uts1 &= ~UTS1_RXEMPTY; | ||
27 | if (value & URXD_BRK) { | ||
28 | s->usr2 |= USR2_BRCD; | ||
29 | } | ||
30 | + | ||
31 | + imx_serial_rx_fifo_ageing_timer_restart(s); | ||
32 | + | ||
33 | imx_update(s); | ||
34 | } | ||
35 | |||
36 | -- | ||
37 | 2.34.1 | diff view generated by jsdifflib |
1 | From: Guenter Roeck <linux@roeck-us.net> | 1 | From: Bernhard Beschow <shentey@gmail.com> |
---|---|---|---|
2 | 2 | ||
3 | With this patch, the USB controllers on 'sabrelite' are detected | 3 | Fixes INTD and MSI interrupts poking the same IRQ line without keeping track of |
4 | and can be used to boot the system. | 4 | each other's IRQ level. Furthermore, SoCs such as the i.MX 8M Plus don't share |
5 | the MSI IRQ with the INTx lines, so expose it as a dedicated pin. | ||
5 | 6 | ||
6 | Signed-off-by: Guenter Roeck <linux@roeck-us.net> | 7 | Signed-off-by: Bernhard Beschow <shentey@gmail.com> |
7 | Message-id: 20200313014551.12554-6-linux@roeck-us.net | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 10 | --- |
11 | include/hw/arm/fsl-imx6.h | 6 ++++++ | 11 | include/hw/arm/fsl-imx6.h | 4 +++- |
12 | hw/arm/fsl-imx6.c | 36 ++++++++++++++++++++++++++++++++++++ | 12 | include/hw/arm/fsl-imx7.h | 4 +++- |
13 | 2 files changed, 42 insertions(+) | 13 | include/hw/pci-host/designware.h | 1 + |
14 | hw/arm/fsl-imx6.c | 13 ++++++++++++- | ||
15 | hw/arm/fsl-imx7.c | 13 ++++++++++++- | ||
16 | hw/pci-host/designware.c | 7 +++---- | ||
17 | hw/arm/Kconfig | 2 ++ | ||
18 | 7 files changed, 36 insertions(+), 8 deletions(-) | ||
14 | 19 | ||
15 | diff --git a/include/hw/arm/fsl-imx6.h b/include/hw/arm/fsl-imx6.h | 20 | diff --git a/include/hw/arm/fsl-imx6.h b/include/hw/arm/fsl-imx6.h |
16 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/include/hw/arm/fsl-imx6.h | 22 | --- a/include/hw/arm/fsl-imx6.h |
18 | +++ b/include/hw/arm/fsl-imx6.h | 23 | +++ b/include/hw/arm/fsl-imx6.h |
19 | @@ -XXX,XX +XXX,XX @@ | 24 | @@ -XXX,XX +XXX,XX @@ |
20 | #include "hw/sd/sdhci.h" | 25 | #include "hw/usb/chipidea.h" |
21 | #include "hw/ssi/imx_spi.h" | 26 | #include "hw/usb/imx-usb-phy.h" |
22 | #include "hw/net/imx_fec.h" | 27 | #include "hw/pci-host/designware.h" |
23 | +#include "hw/usb/chipidea.h" | 28 | +#include "hw/or-irq.h" |
24 | +#include "hw/usb/imx-usb-phy.h" | ||
25 | #include "exec/memory.h" | 29 | #include "exec/memory.h" |
26 | #include "cpu.h" | 30 | #include "cpu.h" |
27 | 31 | #include "qom/object.h" | |
32 | @@ -XXX,XX +XXX,XX @@ struct FslIMX6State { | ||
33 | ChipideaState usb[FSL_IMX6_NUM_USBS]; | ||
34 | IMXFECState eth; | ||
35 | DesignwarePCIEHost pcie; | ||
36 | + OrIRQState pcie4_msi_irq; | ||
37 | MemoryRegion rom; | ||
38 | MemoryRegion caam; | ||
39 | MemoryRegion ocram; | ||
40 | @@ -XXX,XX +XXX,XX @@ struct FslIMX6State { | ||
41 | #define FSL_IMX6_PCIE1_IRQ 120 | ||
42 | #define FSL_IMX6_PCIE2_IRQ 121 | ||
43 | #define FSL_IMX6_PCIE3_IRQ 122 | ||
44 | -#define FSL_IMX6_PCIE4_IRQ 123 | ||
45 | +#define FSL_IMX6_PCIE4_MSI_IRQ 123 | ||
46 | #define FSL_IMX6_DCIC1_IRQ 124 | ||
47 | #define FSL_IMX6_DCIC2_IRQ 125 | ||
48 | #define FSL_IMX6_MLB150_HIGH_IRQ 126 | ||
49 | diff --git a/include/hw/arm/fsl-imx7.h b/include/hw/arm/fsl-imx7.h | ||
50 | index XXXXXXX..XXXXXXX 100644 | ||
51 | --- a/include/hw/arm/fsl-imx7.h | ||
52 | +++ b/include/hw/arm/fsl-imx7.h | ||
28 | @@ -XXX,XX +XXX,XX @@ | 53 | @@ -XXX,XX +XXX,XX @@ |
29 | #define FSL_IMX6_NUM_ESDHCS 4 | 54 | #include "hw/net/imx_fec.h" |
30 | #define FSL_IMX6_NUM_ECSPIS 5 | 55 | #include "hw/pci-host/designware.h" |
31 | #define FSL_IMX6_NUM_WDTS 2 | 56 | #include "hw/usb/chipidea.h" |
32 | +#define FSL_IMX6_NUM_USB_PHYS 2 | 57 | +#include "hw/or-irq.h" |
33 | +#define FSL_IMX6_NUM_USBS 4 | 58 | #include "cpu.h" |
34 | 59 | #include "qom/object.h" | |
35 | typedef struct FslIMX6State { | 60 | #include "qemu/units.h" |
36 | /*< private >*/ | 61 | @@ -XXX,XX +XXX,XX @@ struct FslIMX7State { |
37 | @@ -XXX,XX +XXX,XX @@ typedef struct FslIMX6State { | 62 | IMX7GPRState gpr; |
38 | SDHCIState esdhc[FSL_IMX6_NUM_ESDHCS]; | 63 | ChipideaState usb[FSL_IMX7_NUM_USBS]; |
39 | IMXSPIState spi[FSL_IMX6_NUM_ECSPIS]; | 64 | DesignwarePCIEHost pcie; |
40 | IMX2WdtState wdt[FSL_IMX6_NUM_WDTS]; | 65 | + OrIRQState pcie4_msi_irq; |
41 | + IMXUSBPHYState usbphy[FSL_IMX6_NUM_USB_PHYS]; | 66 | MemoryRegion rom; |
42 | + ChipideaState usb[FSL_IMX6_NUM_USBS]; | 67 | MemoryRegion caam; |
43 | IMXFECState eth; | 68 | MemoryRegion ocram; |
44 | MemoryRegion rom; | 69 | @@ -XXX,XX +XXX,XX @@ enum FslIMX7IRQs { |
45 | MemoryRegion caam; | 70 | FSL_IMX7_PCI_INTA_IRQ = 125, |
71 | FSL_IMX7_PCI_INTB_IRQ = 124, | ||
72 | FSL_IMX7_PCI_INTC_IRQ = 123, | ||
73 | - FSL_IMX7_PCI_INTD_IRQ = 122, | ||
74 | + FSL_IMX7_PCI_INTD_MSI_IRQ = 122, | ||
75 | |||
76 | FSL_IMX7_UART7_IRQ = 126, | ||
77 | |||
78 | diff --git a/include/hw/pci-host/designware.h b/include/hw/pci-host/designware.h | ||
79 | index XXXXXXX..XXXXXXX 100644 | ||
80 | --- a/include/hw/pci-host/designware.h | ||
81 | +++ b/include/hw/pci-host/designware.h | ||
82 | @@ -XXX,XX +XXX,XX @@ struct DesignwarePCIEHost { | ||
83 | MemoryRegion io; | ||
84 | |||
85 | qemu_irq irqs[4]; | ||
86 | + qemu_irq msi; | ||
87 | } pci; | ||
88 | |||
89 | MemoryRegion mmio; | ||
46 | diff --git a/hw/arm/fsl-imx6.c b/hw/arm/fsl-imx6.c | 90 | diff --git a/hw/arm/fsl-imx6.c b/hw/arm/fsl-imx6.c |
47 | index XXXXXXX..XXXXXXX 100644 | 91 | index XXXXXXX..XXXXXXX 100644 |
48 | --- a/hw/arm/fsl-imx6.c | 92 | --- a/hw/arm/fsl-imx6.c |
49 | +++ b/hw/arm/fsl-imx6.c | 93 | +++ b/hw/arm/fsl-imx6.c |
94 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6_init(Object *obj) | ||
95 | object_initialize_child(obj, "eth", &s->eth, TYPE_IMX_ENET); | ||
96 | |||
97 | object_initialize_child(obj, "pcie", &s->pcie, TYPE_DESIGNWARE_PCIE_HOST); | ||
98 | + object_initialize_child(obj, "pcie4-msi-irq", &s->pcie4_msi_irq, | ||
99 | + TYPE_OR_IRQ); | ||
100 | } | ||
101 | |||
102 | static void fsl_imx6_realize(DeviceState *dev, Error **errp) | ||
103 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp) | ||
104 | sysbus_realize(SYS_BUS_DEVICE(&s->pcie), &error_abort); | ||
105 | sysbus_mmio_map(SYS_BUS_DEVICE(&s->pcie), 0, FSL_IMX6_PCIe_REG_ADDR); | ||
106 | |||
107 | + object_property_set_int(OBJECT(&s->pcie4_msi_irq), "num-lines", 2, | ||
108 | + &error_abort); | ||
109 | + qdev_realize(DEVICE(&s->pcie4_msi_irq), NULL, &error_abort); | ||
110 | + | ||
111 | + irq = qdev_get_gpio_in(DEVICE(&s->a9mpcore), FSL_IMX6_PCIE4_MSI_IRQ); | ||
112 | + qdev_connect_gpio_out(DEVICE(&s->pcie4_msi_irq), 0, irq); | ||
113 | + | ||
114 | irq = qdev_get_gpio_in(DEVICE(&s->a9mpcore), FSL_IMX6_PCIE1_IRQ); | ||
115 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->pcie), 0, irq); | ||
116 | irq = qdev_get_gpio_in(DEVICE(&s->a9mpcore), FSL_IMX6_PCIE2_IRQ); | ||
117 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->pcie), 1, irq); | ||
118 | irq = qdev_get_gpio_in(DEVICE(&s->a9mpcore), FSL_IMX6_PCIE3_IRQ); | ||
119 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->pcie), 2, irq); | ||
120 | - irq = qdev_get_gpio_in(DEVICE(&s->a9mpcore), FSL_IMX6_PCIE4_IRQ); | ||
121 | + irq = qdev_get_gpio_in(DEVICE(&s->pcie4_msi_irq), 0); | ||
122 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->pcie), 3, irq); | ||
123 | + irq = qdev_get_gpio_in(DEVICE(&s->pcie4_msi_irq), 1); | ||
124 | + sysbus_connect_irq(SYS_BUS_DEVICE(&s->pcie), 4, irq); | ||
125 | |||
126 | /* | ||
127 | * PCIe PHY | ||
128 | diff --git a/hw/arm/fsl-imx7.c b/hw/arm/fsl-imx7.c | ||
129 | index XXXXXXX..XXXXXXX 100644 | ||
130 | --- a/hw/arm/fsl-imx7.c | ||
131 | +++ b/hw/arm/fsl-imx7.c | ||
132 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_init(Object *obj) | ||
133 | * PCIE | ||
134 | */ | ||
135 | object_initialize_child(obj, "pcie", &s->pcie, TYPE_DESIGNWARE_PCIE_HOST); | ||
136 | + object_initialize_child(obj, "pcie4-msi-irq", &s->pcie4_msi_irq, | ||
137 | + TYPE_OR_IRQ); | ||
138 | |||
139 | /* | ||
140 | * USBs | ||
141 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) | ||
142 | sysbus_realize(SYS_BUS_DEVICE(&s->pcie), &error_abort); | ||
143 | sysbus_mmio_map(SYS_BUS_DEVICE(&s->pcie), 0, FSL_IMX7_PCIE_REG_ADDR); | ||
144 | |||
145 | + object_property_set_int(OBJECT(&s->pcie4_msi_irq), "num-lines", 2, | ||
146 | + &error_abort); | ||
147 | + qdev_realize(DEVICE(&s->pcie4_msi_irq), NULL, &error_abort); | ||
148 | + | ||
149 | + irq = qdev_get_gpio_in(DEVICE(&s->a7mpcore), FSL_IMX7_PCI_INTD_MSI_IRQ); | ||
150 | + qdev_connect_gpio_out(DEVICE(&s->pcie4_msi_irq), 0, irq); | ||
151 | + | ||
152 | irq = qdev_get_gpio_in(DEVICE(&s->a7mpcore), FSL_IMX7_PCI_INTA_IRQ); | ||
153 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->pcie), 0, irq); | ||
154 | irq = qdev_get_gpio_in(DEVICE(&s->a7mpcore), FSL_IMX7_PCI_INTB_IRQ); | ||
155 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->pcie), 1, irq); | ||
156 | irq = qdev_get_gpio_in(DEVICE(&s->a7mpcore), FSL_IMX7_PCI_INTC_IRQ); | ||
157 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->pcie), 2, irq); | ||
158 | - irq = qdev_get_gpio_in(DEVICE(&s->a7mpcore), FSL_IMX7_PCI_INTD_IRQ); | ||
159 | + irq = qdev_get_gpio_in(DEVICE(&s->pcie4_msi_irq), 0); | ||
160 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->pcie), 3, irq); | ||
161 | + irq = qdev_get_gpio_in(DEVICE(&s->pcie4_msi_irq), 1); | ||
162 | + sysbus_connect_irq(SYS_BUS_DEVICE(&s->pcie), 4, irq); | ||
163 | |||
164 | /* | ||
165 | * USBs | ||
166 | diff --git a/hw/pci-host/designware.c b/hw/pci-host/designware.c | ||
167 | index XXXXXXX..XXXXXXX 100644 | ||
168 | --- a/hw/pci-host/designware.c | ||
169 | +++ b/hw/pci-host/designware.c | ||
50 | @@ -XXX,XX +XXX,XX @@ | 170 | @@ -XXX,XX +XXX,XX @@ |
51 | #include "qemu/osdep.h" | 171 | #define DESIGNWARE_PCIE_ATU_DEVFN(x) (((x) >> 16) & 0xff) |
52 | #include "qapi/error.h" | 172 | #define DESIGNWARE_PCIE_ATU_UPPER_TARGET 0x91C |
53 | #include "hw/arm/fsl-imx6.h" | 173 | |
54 | +#include "hw/usb/imx-usb-phy.h" | 174 | -#define DESIGNWARE_PCIE_IRQ_MSI 3 |
55 | #include "hw/boards.h" | 175 | - |
56 | #include "hw/qdev-properties.h" | 176 | static DesignwarePCIEHost * |
57 | #include "sysemu/sysemu.h" | 177 | designware_pcie_root_to_host(DesignwarePCIERoot *root) |
58 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6_init(Object *obj) | 178 | { |
59 | TYPE_IMX_USDHC); | 179 | @@ -XXX,XX +XXX,XX @@ static void designware_pcie_root_msi_write(void *opaque, hwaddr addr, |
180 | root->msi.intr[0].status |= BIT(val) & root->msi.intr[0].enable; | ||
181 | |||
182 | if (root->msi.intr[0].status & ~root->msi.intr[0].mask) { | ||
183 | - qemu_set_irq(host->pci.irqs[DESIGNWARE_PCIE_IRQ_MSI], 1); | ||
184 | + qemu_set_irq(host->pci.msi, 1); | ||
60 | } | 185 | } |
61 | 186 | } | |
62 | + for (i = 0; i < FSL_IMX6_NUM_USB_PHYS; i++) { | 187 | |
63 | + snprintf(name, NAME_SIZE, "usbphy%d", i); | 188 | @@ -XXX,XX +XXX,XX @@ static void designware_pcie_root_config_write(PCIDevice *d, uint32_t address, |
64 | + sysbus_init_child_obj(obj, name, &s->usbphy[i], sizeof(s->usbphy[i]), | 189 | case DESIGNWARE_PCIE_MSI_INTR0_STATUS: |
65 | + TYPE_IMX_USBPHY); | 190 | root->msi.intr[0].status ^= val; |
66 | + } | 191 | if (!root->msi.intr[0].status) { |
67 | + for (i = 0; i < FSL_IMX6_NUM_USBS; i++) { | 192 | - qemu_set_irq(host->pci.irqs[DESIGNWARE_PCIE_IRQ_MSI], 0); |
68 | + snprintf(name, NAME_SIZE, "usb%d", i); | 193 | + qemu_set_irq(host->pci.msi, 0); |
69 | + sysbus_init_child_obj(obj, name, &s->usb[i], sizeof(s->usb[i]), | 194 | } |
70 | + TYPE_CHIPIDEA); | 195 | break; |
71 | + } | 196 | |
72 | + | 197 | @@ -XXX,XX +XXX,XX @@ static void designware_pcie_host_realize(DeviceState *dev, Error **errp) |
73 | for (i = 0; i < FSL_IMX6_NUM_ECSPIS; i++) { | 198 | for (i = 0; i < ARRAY_SIZE(s->pci.irqs); i++) { |
74 | snprintf(name, NAME_SIZE, "spi%d", i + 1); | 199 | sysbus_init_irq(sbd, &s->pci.irqs[i]); |
75 | sysbus_init_child_obj(obj, name, &s->spi[i], sizeof(s->spi[i]), | ||
76 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp) | ||
77 | esdhc_table[i].irq)); | ||
78 | } | 200 | } |
79 | 201 | + sysbus_init_irq(sbd, &s->pci.msi); | |
80 | + /* USB */ | 202 | |
81 | + for (i = 0; i < FSL_IMX6_NUM_USB_PHYS; i++) { | 203 | memory_region_init_io(&s->mmio, |
82 | + object_property_set_bool(OBJECT(&s->usbphy[i]), true, "realized", | 204 | OBJECT(s), |
83 | + &error_abort); | 205 | diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig |
84 | + sysbus_mmio_map(SYS_BUS_DEVICE(&s->usbphy[i]), 0, | 206 | index XXXXXXX..XXXXXXX 100644 |
85 | + FSL_IMX6_USBPHY1_ADDR + i * 0x1000); | 207 | --- a/hw/arm/Kconfig |
86 | + } | 208 | +++ b/hw/arm/Kconfig |
87 | + for (i = 0; i < FSL_IMX6_NUM_USBS; i++) { | 209 | @@ -XXX,XX +XXX,XX @@ config FSL_IMX6 |
88 | + static const int FSL_IMX6_USBn_IRQ[] = { | 210 | select PL310 # cache controller |
89 | + FSL_IMX6_USB_OTG_IRQ, | 211 | select PCI_EXPRESS_DESIGNWARE |
90 | + FSL_IMX6_USB_HOST1_IRQ, | 212 | select SDHCI |
91 | + FSL_IMX6_USB_HOST2_IRQ, | 213 | + select OR_IRQ |
92 | + FSL_IMX6_USB_HOST3_IRQ, | 214 | |
93 | + }; | 215 | config ASPEED_SOC |
94 | + | 216 | bool |
95 | + object_property_set_bool(OBJECT(&s->usb[i]), true, "realized", | 217 | @@ -XXX,XX +XXX,XX @@ config FSL_IMX7 |
96 | + &error_abort); | 218 | select WDT_IMX2 |
97 | + sysbus_mmio_map(SYS_BUS_DEVICE(&s->usb[i]), 0, | 219 | select PCI_EXPRESS_DESIGNWARE |
98 | + FSL_IMX6_USBOH3_USB_ADDR + i * 0x200); | 220 | select SDHCI |
99 | + sysbus_connect_irq(SYS_BUS_DEVICE(&s->usb[i]), 0, | 221 | + select OR_IRQ |
100 | + qdev_get_gpio_in(DEVICE(&s->a9mpcore), | 222 | select UNIMP |
101 | + FSL_IMX6_USBn_IRQ[i])); | 223 | |
102 | + } | 224 | config ARM_SMMUV3 |
103 | + | ||
104 | /* Initialize all ECSPI */ | ||
105 | for (i = 0; i < FSL_IMX6_NUM_ECSPIS; i++) { | ||
106 | static const struct { | ||
107 | -- | 225 | -- |
108 | 2.20.1 | 226 | 2.34.1 |
109 | |||
110 | diff view generated by jsdifflib |
1 | From: Chen Qun <kuhn.chenqun@huawei.com> | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | The current code causes clang static code analyzer generate warning: | 3 | Board schematic is useful to corroborate GPIOs/IRQs wiring. |
4 | hw/net/imx_fec.c:858:9: warning: Value stored to 'value' is never read | ||
5 | value = value & 0x0000000f; | ||
6 | ^ ~~~~~~~~~~~~~~~~~~ | ||
7 | hw/net/imx_fec.c:864:9: warning: Value stored to 'value' is never read | ||
8 | value = value & 0x000000fd; | ||
9 | ^ ~~~~~~~~~~~~~~~~~~ | ||
10 | 4 | ||
11 | According to the definition of the function, the two “value” assignments | 5 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
12 | should be written to registers. | ||
13 | |||
14 | Reported-by: Euler Robot <euler.robot@huawei.com> | ||
15 | Signed-off-by: Chen Qun <kuhn.chenqun@huawei.com> | ||
16 | Message-id: 20200313123242.13236-1-kuhn.chenqun@huawei.com | ||
17 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Message-id: 20250110160204.74997-2-philmd@linaro.org | ||
8 | [PMM: Use https:// URLs] | ||
18 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
19 | --- | 10 | --- |
20 | hw/net/imx_fec.c | 6 ++++-- | 11 | hw/arm/stellaris.c | 8 ++++++++ |
21 | 1 file changed, 4 insertions(+), 2 deletions(-) | 12 | 1 file changed, 8 insertions(+) |
22 | 13 | ||
23 | diff --git a/hw/net/imx_fec.c b/hw/net/imx_fec.c | 14 | diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c |
24 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
25 | --- a/hw/net/imx_fec.c | 16 | --- a/hw/arm/stellaris.c |
26 | +++ b/hw/net/imx_fec.c | 17 | +++ b/hw/arm/stellaris.c |
27 | @@ -XXX,XX +XXX,XX @@ static void imx_enet_write(IMXFECState *s, uint32_t index, uint32_t value) | 18 | @@ -XXX,XX +XXX,XX @@ static void lm3s6965evb_init(MachineState *machine) |
28 | break; | 19 | stellaris_init(machine, &stellaris_boards[1]); |
29 | case ENET_TGSR: | 20 | } |
30 | /* implement clear timer flag */ | 21 | |
31 | - value = value & 0x0000000f; | 22 | +/* |
32 | + s->regs[index] &= ~(value & 0x0000000f); /* all bits W1C */ | 23 | + * Stellaris LM3S811 Evaluation Board Schematics: |
33 | break; | 24 | + * https://www.ti.com/lit/ug/symlink/spmu030.pdf |
34 | case ENET_TCSR0: | 25 | + */ |
35 | case ENET_TCSR1: | 26 | static void lm3s811evb_class_init(ObjectClass *oc, void *data) |
36 | case ENET_TCSR2: | 27 | { |
37 | case ENET_TCSR3: | 28 | MachineClass *mc = MACHINE_CLASS(oc); |
38 | - value = value & 0x000000fd; | 29 | @@ -XXX,XX +XXX,XX @@ static const TypeInfo lm3s811evb_type = { |
39 | + s->regs[index] &= ~(value & 0x00000080); /* W1C bits */ | 30 | .class_init = lm3s811evb_class_init, |
40 | + s->regs[index] &= ~0x0000007d; /* writable fields */ | 31 | }; |
41 | + s->regs[index] |= (value & 0x0000007d); | 32 | |
42 | break; | 33 | +/* |
43 | case ENET_TCCR0: | 34 | + * Stellaris: LM3S6965 Evaluation Board Schematics: |
44 | case ENET_TCCR1: | 35 | + * https://www.ti.com/lit/ug/symlink/spmu029.pdf |
36 | + */ | ||
37 | static void lm3s6965evb_class_init(ObjectClass *oc, void *data) | ||
38 | { | ||
39 | MachineClass *mc = MACHINE_CLASS(oc); | ||
45 | -- | 40 | -- |
46 | 2.20.1 | 41 | 2.34.1 |
47 | 42 | ||
48 | 43 | diff view generated by jsdifflib |
1 | From: Guenter Roeck <linux@roeck-us.net> | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | USB1 and USB2 interrupt numbers were swapped. USB_PHY2 interrupt number | 3 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
4 | is 45. That didn't really matter up to now since the interrupts were not | ||
5 | used, but it needs to be fixed to be able to wire up the USB controllers. | ||
6 | |||
7 | Fixes: 31cbf933f0e ("i.MX6UL: Add i.MX6UL SOC") | ||
8 | Signed-off-by: Guenter Roeck <linux@roeck-us.net> | ||
9 | Message-id: 20200313014551.12554-3-linux@roeck-us.net | ||
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 4 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Message-id: 20250110160204.74997-3-philmd@linaro.org | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | --- | 7 | --- |
13 | include/hw/arm/fsl-imx6ul.h | 6 +++--- | 8 | hw/arm/stellaris.c | 6 +++--- |
14 | 1 file changed, 3 insertions(+), 3 deletions(-) | 9 | 1 file changed, 3 insertions(+), 3 deletions(-) |
15 | 10 | ||
16 | diff --git a/include/hw/arm/fsl-imx6ul.h b/include/hw/arm/fsl-imx6ul.h | 11 | diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c |
17 | index XXXXXXX..XXXXXXX 100644 | 12 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/include/hw/arm/fsl-imx6ul.h | 13 | --- a/hw/arm/stellaris.c |
19 | +++ b/include/hw/arm/fsl-imx6ul.h | 14 | +++ b/hw/arm/stellaris.c |
20 | @@ -XXX,XX +XXX,XX @@ enum FslIMX6ULIRQs { | 15 | @@ -XXX,XX +XXX,XX @@ static void ssys_update(ssys_state *s) |
21 | FSL_IMX6UL_UART7_IRQ = 39, | 16 | qemu_set_irq(s->irq, (s->int_status & s->int_mask) != 0); |
22 | FSL_IMX6UL_UART8_IRQ = 40, | 17 | } |
23 | 18 | ||
24 | - FSL_IMX6UL_USB1_IRQ = 42, | 19 | -static uint32_t pllcfg_sandstorm[16] = { |
25 | - FSL_IMX6UL_USB2_IRQ = 43, | 20 | +static const uint32_t pllcfg_sandstorm[16] = { |
26 | + FSL_IMX6UL_USB1_IRQ = 43, | 21 | 0x31c0, /* 1 Mhz */ |
27 | + FSL_IMX6UL_USB2_IRQ = 42, | 22 | 0x1ae0, /* 1.8432 Mhz */ |
28 | FSL_IMX6UL_USB_PHY1_IRQ = 44, | 23 | 0x18c0, /* 2 Mhz */ |
29 | - FSL_IMX6UL_USB_PHY2_IRQ = 44, | 24 | @@ -XXX,XX +XXX,XX @@ static uint32_t pllcfg_sandstorm[16] = { |
30 | + FSL_IMX6UL_USB_PHY2_IRQ = 45, | 25 | 0x585b /* 8.192 Mhz */ |
31 | 26 | }; | |
32 | FSL_IMX6UL_CAAM_JQ2_IRQ = 46, | 27 | |
33 | FSL_IMX6UL_CAAM_ERR_IRQ = 47, | 28 | -static uint32_t pllcfg_fury[16] = { |
29 | +static const uint32_t pllcfg_fury[16] = { | ||
30 | 0x3200, /* 1 Mhz */ | ||
31 | 0x1b20, /* 1.8432 Mhz */ | ||
32 | 0x1900, /* 2 Mhz */ | ||
33 | @@ -XXX,XX +XXX,XX @@ static void stellaris_adc_init(Object *obj) | ||
34 | } | ||
35 | |||
36 | /* Board init. */ | ||
37 | -static stellaris_board_info stellaris_boards[] = { | ||
38 | +static const stellaris_board_info stellaris_boards[] = { | ||
39 | { "LM3S811EVB", | ||
40 | 0, | ||
41 | 0x0032000e, | ||
34 | -- | 42 | -- |
35 | 2.20.1 | 43 | 2.34.1 |
36 | 44 | ||
37 | 45 | diff view generated by jsdifflib |
1 | From: Guenter Roeck <linux@roeck-us.net> | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Whenever an unsupported command is encountered, the current code | 3 | There is nothing mapped at 0x40002000. |
4 | interprets each transferred byte as new command. Most of the time, those | ||
5 | 'commands' are interpreted as new unknown commands. However, in rare | ||
6 | cases, it may be that for example address or length information | ||
7 | passed with the original command is by itself a valid command. | ||
8 | If that happens, the state machine may get completely confused and, | ||
9 | worst case, start writing data into the flash or even erase it. | ||
10 | 4 | ||
11 | To avoid the problem, transition into STATE_READING_DATA and keep | 5 | I2C#0 is already mapped at 0x40021000. |
12 | sending a value of 0 until the chip is deselected after encountering | ||
13 | an unsupported command. | ||
14 | 6 | ||
15 | Signed-off-by: Guenter Roeck <linux@roeck-us.net> | 7 | Remove the invalid mapping added in commits aecfbbc97a2 & 394c8bbfb7a. |
16 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 8 | |
17 | Reviewed-by: Cédric Le Goater <clg@kaod.org> | 9 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | Message-id: 20250110160204.74997-4-philmd@linaro.org | ||
18 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
19 | --- | 13 | --- |
20 | hw/block/m25p80.c | 5 +++++ | 14 | hw/arm/stellaris.c | 2 -- |
21 | 1 file changed, 5 insertions(+) | 15 | 1 file changed, 2 deletions(-) |
22 | 16 | ||
23 | diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c | 17 | diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c |
24 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
25 | --- a/hw/block/m25p80.c | 19 | --- a/hw/arm/stellaris.c |
26 | +++ b/hw/block/m25p80.c | 20 | +++ b/hw/arm/stellaris.c |
27 | @@ -XXX,XX +XXX,XX @@ static void decode_new_cmd(Flash *s, uint32_t value) | 21 | @@ -XXX,XX +XXX,XX @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board) |
28 | s->quad_enable = false; | 22 | * http://www.ti.com/lit/ds/symlink/lm3s6965.pdf |
29 | break; | 23 | * |
30 | default: | 24 | * 40000000 wdtimer |
31 | + s->pos = 0; | 25 | - * 40002000 i2c (unimplemented) |
32 | + s->len = 1; | 26 | * 40004000 GPIO |
33 | + s->state = STATE_READING_DATA; | 27 | * 40005000 GPIO |
34 | + s->data_read_loop = true; | 28 | * 40006000 GPIO |
35 | + s->data[0] = 0; | 29 | @@ -XXX,XX +XXX,XX @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board) |
36 | qemu_log_mask(LOG_GUEST_ERROR, "M25P80: Unknown cmd %x\n", value); | 30 | /* Add dummy regions for the devices we don't implement yet, |
37 | break; | 31 | * so guest accesses don't cause unlogged crashes. |
38 | } | 32 | */ |
33 | - create_unimplemented_device("i2c-0", 0x40002000, 0x1000); | ||
34 | create_unimplemented_device("i2c-2", 0x40021000, 0x1000); | ||
35 | create_unimplemented_device("PWM", 0x40028000, 0x1000); | ||
36 | create_unimplemented_device("QEI-0", 0x4002c000, 0x1000); | ||
39 | -- | 37 | -- |
40 | 2.20.1 | 38 | 2.34.1 |
41 | 39 | ||
42 | 40 | diff view generated by jsdifflib |
1 | From: Guenter Roeck <linux@roeck-us.net> | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | PXA255 does not support a USB OHCI controller, so don't wire it up. | 3 | Add definitions for the number of controllers. |
4 | 4 | ||
5 | Signed-off-by: Guenter Roeck <linux@roeck-us.net> | 5 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
6 | Message-id: 20200313160215.28155-1-linux@roeck-us.net | ||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Message-id: 20250110160204.74997-5-philmd@linaro.org | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | --- | 9 | --- |
10 | hw/arm/pxa2xx.c | 3 --- | 10 | hw/arm/stellaris.c | 25 +++++++++++++++---------- |
11 | 1 file changed, 3 deletions(-) | 11 | 1 file changed, 15 insertions(+), 10 deletions(-) |
12 | 12 | ||
13 | diff --git a/hw/arm/pxa2xx.c b/hw/arm/pxa2xx.c | 13 | diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c |
14 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/hw/arm/pxa2xx.c | 15 | --- a/hw/arm/stellaris.c |
16 | +++ b/hw/arm/pxa2xx.c | 16 | +++ b/hw/arm/stellaris.c |
17 | @@ -XXX,XX +XXX,XX @@ PXA2xxState *pxa255_init(MemoryRegion *address_space, unsigned int sdram_size) | 17 | @@ -XXX,XX +XXX,XX @@ |
18 | s->ssp[i] = (SSIBus *)qdev_get_child_bus(dev, "ssi"); | 18 | #define NUM_IRQ_LINES 64 |
19 | #define NUM_PRIO_BITS 3 | ||
20 | |||
21 | +#define NUM_GPIO 7 | ||
22 | +#define NUM_UART 4 | ||
23 | +#define NUM_GPTM 4 | ||
24 | +#define NUM_I2C 2 | ||
25 | + | ||
26 | typedef const struct { | ||
27 | const char *name; | ||
28 | uint32_t did0; | ||
29 | @@ -XXX,XX +XXX,XX @@ static const stellaris_board_info stellaris_boards[] = { | ||
30 | |||
31 | static void stellaris_init(MachineState *ms, stellaris_board_info *board) | ||
32 | { | ||
33 | - static const int uart_irq[] = {5, 6, 33, 34}; | ||
34 | - static const int timer_irq[] = {19, 21, 23, 35}; | ||
35 | - static const uint32_t gpio_addr[7] = | ||
36 | + static const int uart_irq[NUM_UART] = {5, 6, 33, 34}; | ||
37 | + static const int timer_irq[NUM_GPTM] = {19, 21, 23, 35}; | ||
38 | + static const uint32_t gpio_addr[NUM_GPIO] = | ||
39 | { 0x40004000, 0x40005000, 0x40006000, 0x40007000, | ||
40 | 0x40024000, 0x40025000, 0x40026000}; | ||
41 | - static const int gpio_irq[7] = {0, 1, 2, 3, 4, 30, 31}; | ||
42 | + static const int gpio_irq[NUM_GPIO] = {0, 1, 2, 3, 4, 30, 31}; | ||
43 | |||
44 | /* Memory map of SoC devices, from | ||
45 | * Stellaris LM3S6965 Microcontroller Data Sheet (rev I) | ||
46 | @@ -XXX,XX +XXX,XX @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board) | ||
47 | */ | ||
48 | |||
49 | Object *soc_container; | ||
50 | - DeviceState *gpio_dev[7], *armv7m, *nvic; | ||
51 | - qemu_irq gpio_in[7][8]; | ||
52 | - qemu_irq gpio_out[7][8]; | ||
53 | + DeviceState *gpio_dev[NUM_GPIO], *armv7m, *nvic; | ||
54 | + qemu_irq gpio_in[NUM_GPIO][8]; | ||
55 | + qemu_irq gpio_out[NUM_GPIO][8]; | ||
56 | qemu_irq adc; | ||
57 | int sram_size; | ||
58 | int flash_size; | ||
59 | @@ -XXX,XX +XXX,XX @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board) | ||
60 | } else { | ||
61 | adc = NULL; | ||
19 | } | 62 | } |
20 | 63 | - for (i = 0; i < 4; i++) { | |
21 | - sysbus_create_simple("sysbus-ohci", 0x4c000000, | 64 | + for (i = 0; i < NUM_GPTM; i++) { |
22 | - qdev_get_gpio_in(s->pic, PXA2XX_PIC_USBH1)); | 65 | if (board->dc2 & (0x10000 << i)) { |
23 | - | 66 | SysBusDevice *sbd; |
24 | s->pcmcia[0] = pxa2xx_pcmcia_init(address_space, 0x20000000); | 67 | |
25 | s->pcmcia[1] = pxa2xx_pcmcia_init(address_space, 0x30000000); | 68 | @@ -XXX,XX +XXX,XX @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board) |
69 | } | ||
70 | |||
71 | |||
72 | - for (i = 0; i < 7; i++) { | ||
73 | + for (i = 0; i < NUM_GPIO; i++) { | ||
74 | if (board->dc4 & (1 << i)) { | ||
75 | gpio_dev[i] = sysbus_create_simple("pl061_luminary", gpio_addr[i], | ||
76 | qdev_get_gpio_in(nvic, | ||
77 | @@ -XXX,XX +XXX,XX @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board) | ||
78 | } | ||
79 | } | ||
80 | |||
81 | - for (i = 0; i < 4; i++) { | ||
82 | + for (i = 0; i < NUM_UART; i++) { | ||
83 | if (board->dc2 & (1 << i)) { | ||
84 | SysBusDevice *sbd; | ||
26 | 85 | ||
27 | -- | 86 | -- |
28 | 2.20.1 | 87 | 2.34.1 |
29 | 88 | ||
30 | 89 | diff view generated by jsdifflib |
1 | From: Guenter Roeck <linux@roeck-us.net> | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | While at it, add some trace messages to help debug problems | 3 | Add definitions (DCx_periph) for the DeviceCapability bits, |
4 | seen when running the latest Linux kernel. | 4 | replace direct bitmask checks with the DEV_CAP() macro, |
5 | which use the extract/deposit API. | ||
5 | 6 | ||
6 | Signed-off-by: Guenter Roeck <linux@roeck-us.net> | 7 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
7 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | 9 | Message-id: 20250110160204.74997-6-philmd@linaro.org |
9 | Reviewed-by: Cédric Le Goater <clg@kaod.org> | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 11 | --- |
12 | hw/block/m25p80.c | 48 ++++++++++++++++++++----------------------- | 12 | hw/arm/stellaris.c | 37 +++++++++++++++++++++++++++++-------- |
13 | hw/block/trace-events | 16 +++++++++++++++ | 13 | 1 file changed, 29 insertions(+), 8 deletions(-) |
14 | 2 files changed, 38 insertions(+), 26 deletions(-) | ||
15 | 14 | ||
16 | diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c | 15 | diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c |
17 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/hw/block/m25p80.c | 17 | --- a/hw/arm/stellaris.c |
19 | +++ b/hw/block/m25p80.c | 18 | +++ b/hw/arm/stellaris.c |
20 | @@ -XXX,XX +XXX,XX @@ | 19 | @@ -XXX,XX +XXX,XX @@ |
21 | #include "qemu/module.h" | 20 | */ |
22 | #include "qemu/error-report.h" | 21 | |
22 | #include "qemu/osdep.h" | ||
23 | +#include "qemu/bitops.h" | ||
23 | #include "qapi/error.h" | 24 | #include "qapi/error.h" |
24 | - | 25 | #include "hw/core/split-irq.h" |
25 | -#ifndef M25P80_ERR_DEBUG | 26 | #include "hw/sysbus.h" |
26 | -#define M25P80_ERR_DEBUG 0 | 27 | @@ -XXX,XX +XXX,XX @@ |
27 | -#endif | 28 | #define NUM_GPTM 4 |
28 | - | 29 | #define NUM_I2C 2 |
29 | -#define DB_PRINT_L(level, ...) do { \ | 30 | |
30 | - if (M25P80_ERR_DEBUG > (level)) { \ | 31 | +/* |
31 | - fprintf(stderr, ": %s: ", __func__); \ | 32 | + * See Stellaris Data Sheet chapter 5.2.5 "System Control", |
32 | - fprintf(stderr, ## __VA_ARGS__); \ | 33 | + * Register 13 .. 17: Device Capabilities 0 .. 4 (DC0 .. DC4). |
33 | - } \ | 34 | + */ |
34 | -} while (0) | 35 | +#define DC1_WDT 3 |
35 | +#include "trace.h" | 36 | +#define DC1_HIB 6 |
36 | 37 | +#define DC1_MPU 7 | |
37 | /* Fields for FlashPartInfo->flags */ | 38 | +#define DC1_ADC 16 |
38 | 39 | +#define DC1_PWM 20 | |
39 | @@ -XXX,XX +XXX,XX @@ static void flash_erase(Flash *s, int offset, FlashCMD cmd) | 40 | +#define DC2_UART(n) (n) |
40 | abort(); | 41 | +#define DC2_SSI 4 |
42 | +#define DC2_QEI(n) (8 + n) | ||
43 | +#define DC2_I2C(n) (12 + 2 * n) | ||
44 | +#define DC2_GPTM(n) (16 + n) | ||
45 | +#define DC2_COMP(n) (24 + n) | ||
46 | +#define DC4_GPIO(n) (n) | ||
47 | +#define DC4_EMAC 28 | ||
48 | + | ||
49 | +#define DEV_CAP(_dc, _cap) extract32(board->dc##_dc, DC##_dc##_##_cap, 1) | ||
50 | + | ||
51 | typedef const struct { | ||
52 | const char *name; | ||
53 | uint32_t did0; | ||
54 | @@ -XXX,XX +XXX,XX @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board) | ||
55 | sysbus_mmio_map(SYS_BUS_DEVICE(ssys_dev), 0, 0x400fe000); | ||
56 | sysbus_connect_irq(SYS_BUS_DEVICE(ssys_dev), 0, qdev_get_gpio_in(nvic, 28)); | ||
57 | |||
58 | - if (board->dc1 & (1 << 16)) { | ||
59 | + if (DEV_CAP(1, ADC)) { | ||
60 | dev = sysbus_create_varargs(TYPE_STELLARIS_ADC, 0x40038000, | ||
61 | qdev_get_gpio_in(nvic, 14), | ||
62 | qdev_get_gpio_in(nvic, 15), | ||
63 | @@ -XXX,XX +XXX,XX @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board) | ||
64 | adc = NULL; | ||
41 | } | 65 | } |
42 | 66 | for (i = 0; i < NUM_GPTM; i++) { | |
43 | - DB_PRINT_L(0, "offset = %#x, len = %d\n", offset, len); | 67 | - if (board->dc2 & (0x10000 << i)) { |
44 | + trace_m25p80_flash_erase(s, offset, len); | 68 | + if (DEV_CAP(2, GPTM(i))) { |
45 | + | 69 | SysBusDevice *sbd; |
46 | if ((s->pi->flags & capa_to_assert) != capa_to_assert) { | 70 | |
47 | qemu_log_mask(LOG_GUEST_ERROR, "M25P80: %d erase size not supported by" | 71 | dev = qdev_new(TYPE_STELLARIS_GPTM); |
48 | " device\n", len); | 72 | @@ -XXX,XX +XXX,XX @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board) |
49 | @@ -XXX,XX +XXX,XX @@ void flash_write8(Flash *s, uint32_t addr, uint8_t data) | 73 | } |
50 | } | 74 | } |
51 | 75 | ||
52 | if ((prev ^ data) & data) { | 76 | - if (board->dc1 & (1 << 3)) { /* watchdog present */ |
53 | - DB_PRINT_L(1, "programming zero to one! addr=%" PRIx32 " %" PRIx8 | 77 | + if (DEV_CAP(1, WDT)) { |
54 | - " -> %" PRIx8 "\n", addr, prev, data); | 78 | dev = qdev_new(TYPE_LUMINARY_WATCHDOG); |
55 | + trace_m25p80_programming_zero_to_one(s, addr, prev, data); | 79 | object_property_add_child(soc_container, "wdg", OBJECT(dev)); |
80 | qdev_connect_clock_in(dev, "WDOGCLK", | ||
81 | @@ -XXX,XX +XXX,XX @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board) | ||
82 | |||
83 | |||
84 | for (i = 0; i < NUM_GPIO; i++) { | ||
85 | - if (board->dc4 & (1 << i)) { | ||
86 | + if (DEV_CAP(4, GPIO(i))) { | ||
87 | gpio_dev[i] = sysbus_create_simple("pl061_luminary", gpio_addr[i], | ||
88 | qdev_get_gpio_in(nvic, | ||
89 | gpio_irq[i])); | ||
90 | @@ -XXX,XX +XXX,XX @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board) | ||
91 | } | ||
56 | } | 92 | } |
57 | 93 | ||
58 | if (s->pi->flags & EEPROM) { | 94 | - if (board->dc2 & (1 << 12)) { |
59 | @@ -XXX,XX +XXX,XX @@ static void complete_collecting_data(Flash *s) | 95 | + if (DEV_CAP(2, I2C(0))) { |
60 | 96 | dev = sysbus_create_simple(TYPE_STELLARIS_I2C, 0x40020000, | |
61 | s->state = STATE_IDLE; | 97 | qdev_get_gpio_in(nvic, 8)); |
62 | 98 | i2c = (I2CBus *)qdev_get_child_bus(dev, "i2c"); | |
63 | + trace_m25p80_complete_collecting(s, s->cmd_in_progress, n, s->ear, | 99 | @@ -XXX,XX +XXX,XX @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board) |
64 | + s->cur_addr); | ||
65 | + | ||
66 | switch (s->cmd_in_progress) { | ||
67 | case DPP: | ||
68 | case QPP: | ||
69 | @@ -XXX,XX +XXX,XX @@ static void reset_memory(Flash *s) | ||
70 | break; | ||
71 | } | 100 | } |
72 | 101 | ||
73 | - DB_PRINT_L(0, "Reset done.\n"); | 102 | for (i = 0; i < NUM_UART; i++) { |
74 | + trace_m25p80_reset_done(s); | 103 | - if (board->dc2 & (1 << i)) { |
75 | } | 104 | + if (DEV_CAP(2, UART(i))) { |
76 | 105 | SysBusDevice *sbd; | |
77 | static void decode_fast_read_cmd(Flash *s) | 106 | |
78 | @@ -XXX,XX +XXX,XX @@ static void decode_qio_read_cmd(Flash *s) | 107 | dev = qdev_new("pl011_luminary"); |
79 | 108 | @@ -XXX,XX +XXX,XX @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board) | |
80 | static void decode_new_cmd(Flash *s, uint32_t value) | 109 | sysbus_connect_irq(sbd, 0, qdev_get_gpio_in(nvic, uart_irq[i])); |
81 | { | ||
82 | - s->cmd_in_progress = value; | ||
83 | int i; | ||
84 | - DB_PRINT_L(0, "decoded new command:%x\n", value); | ||
85 | + | ||
86 | + s->cmd_in_progress = value; | ||
87 | + trace_m25p80_command_decoded(s, value); | ||
88 | |||
89 | if (value != RESET_MEMORY) { | ||
90 | s->reset_enable = false; | ||
91 | @@ -XXX,XX +XXX,XX @@ static void decode_new_cmd(Flash *s, uint32_t value) | ||
92 | break; | ||
93 | |||
94 | case JEDEC_READ: | ||
95 | - DB_PRINT_L(0, "populated jedec code\n"); | ||
96 | + trace_m25p80_populated_jedec(s); | ||
97 | for (i = 0; i < s->pi->id_len; i++) { | ||
98 | s->data[i] = s->pi->id[i]; | ||
99 | } | 110 | } |
100 | @@ -XXX,XX +XXX,XX @@ static void decode_new_cmd(Flash *s, uint32_t value) | ||
101 | case BULK_ERASE_60: | ||
102 | case BULK_ERASE: | ||
103 | if (s->write_enable) { | ||
104 | - DB_PRINT_L(0, "chip erase\n"); | ||
105 | + trace_m25p80_chip_erase(s); | ||
106 | flash_erase(s, 0, BULK_ERASE); | ||
107 | } else { | ||
108 | qemu_log_mask(LOG_GUEST_ERROR, "M25P80: chip erase with write " | ||
109 | @@ -XXX,XX +XXX,XX @@ static int m25p80_cs(SSISlave *ss, bool select) | ||
110 | s->data_read_loop = false; | ||
111 | } | 111 | } |
112 | 112 | - if (board->dc2 & (1 << 4)) { | |
113 | - DB_PRINT_L(0, "%sselect\n", select ? "de" : ""); | 113 | + if (DEV_CAP(2, SSI)) { |
114 | + trace_m25p80_select(s, select ? "de" : ""); | 114 | dev = sysbus_create_simple("pl022", 0x40008000, |
115 | 115 | qdev_get_gpio_in(nvic, 7)); | |
116 | return 0; | 116 | if (board->peripherals & BP_OLED_SSI) { |
117 | } | 117 | @@ -XXX,XX +XXX,XX @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board) |
118 | @@ -XXX,XX +XXX,XX @@ static uint32_t m25p80_transfer8(SSISlave *ss, uint32_t tx) | 118 | qemu_irq_raise(gpio_out[GPIO_D][0]); |
119 | Flash *s = M25P80(ss); | ||
120 | uint32_t r = 0; | ||
121 | |||
122 | + trace_m25p80_transfer(s, s->state, s->len, s->needed_bytes, s->pos, | ||
123 | + s->cur_addr, (uint8_t)tx); | ||
124 | + | ||
125 | switch (s->state) { | ||
126 | |||
127 | case STATE_PAGE_PROGRAM: | ||
128 | - DB_PRINT_L(1, "page program cur_addr=%#" PRIx32 " data=%" PRIx8 "\n", | ||
129 | - s->cur_addr, (uint8_t)tx); | ||
130 | + trace_m25p80_page_program(s, s->cur_addr, (uint8_t)tx); | ||
131 | flash_write8(s, s->cur_addr, (uint8_t)tx); | ||
132 | s->cur_addr = (s->cur_addr + 1) & (s->size - 1); | ||
133 | break; | ||
134 | |||
135 | case STATE_READ: | ||
136 | r = s->storage[s->cur_addr]; | ||
137 | - DB_PRINT_L(1, "READ 0x%" PRIx32 "=%" PRIx8 "\n", s->cur_addr, | ||
138 | - (uint8_t)r); | ||
139 | + trace_m25p80_read_byte(s, s->cur_addr, (uint8_t)r); | ||
140 | s->cur_addr = (s->cur_addr + 1) & (s->size - 1); | ||
141 | break; | ||
142 | |||
143 | @@ -XXX,XX +XXX,XX @@ static uint32_t m25p80_transfer8(SSISlave *ss, uint32_t tx) | ||
144 | } | 119 | } |
145 | |||
146 | r = s->data[s->pos]; | ||
147 | + trace_m25p80_read_data(s, s->pos, (uint8_t)r); | ||
148 | s->pos++; | ||
149 | if (s->pos == s->len) { | ||
150 | s->pos = 0; | ||
151 | @@ -XXX,XX +XXX,XX @@ static void m25p80_realize(SSISlave *ss, Error **errp) | ||
152 | return; | ||
153 | } | ||
154 | |||
155 | - DB_PRINT_L(0, "Binding to IF_MTD drive\n"); | ||
156 | + trace_m25p80_binding(s); | ||
157 | s->storage = blk_blockalign(s->blk, s->size); | ||
158 | |||
159 | if (blk_pread(s->blk, 0, s->storage, s->size) != s->size) { | ||
160 | @@ -XXX,XX +XXX,XX @@ static void m25p80_realize(SSISlave *ss, Error **errp) | ||
161 | return; | ||
162 | } | ||
163 | } else { | ||
164 | - DB_PRINT_L(0, "No BDRV - binding to RAM\n"); | ||
165 | + trace_m25p80_binding_no_bdrv(s); | ||
166 | s->storage = blk_blockalign(NULL, s->size); | ||
167 | memset(s->storage, 0xFF, s->size); | ||
168 | } | 120 | } |
169 | diff --git a/hw/block/trace-events b/hw/block/trace-events | 121 | - if (board->dc4 & (1 << 28)) { |
170 | index XXXXXXX..XXXXXXX 100644 | 122 | + if (DEV_CAP(4, EMAC)) { |
171 | --- a/hw/block/trace-events | 123 | DeviceState *enet; |
172 | +++ b/hw/block/trace-events | 124 | |
173 | @@ -XXX,XX +XXX,XX @@ xen_block_blockdev_add(char *str) "%s" | 125 | enet = qdev_new("stellaris_enet"); |
174 | xen_block_blockdev_del(const char *node_name) "%s" | ||
175 | xen_block_device_create(unsigned int number) "%u" | ||
176 | xen_block_device_destroy(unsigned int number) "%u" | ||
177 | + | ||
178 | +# m25p80.c | ||
179 | +m25p80_flash_erase(void *s, int offset, uint32_t len) "[%p] offset = 0x%"PRIx32", len = %u" | ||
180 | +m25p80_programming_zero_to_one(void *s, uint32_t addr, uint8_t prev, uint8_t data) "[%p] programming zero to one! addr=0x%"PRIx32" 0x%"PRIx8" -> 0x%"PRIx8 | ||
181 | +m25p80_reset_done(void *s) "[%p] Reset done." | ||
182 | +m25p80_command_decoded(void *s, uint32_t cmd) "[%p] new command:0x%"PRIx32 | ||
183 | +m25p80_complete_collecting(void *s, uint32_t cmd, int n, uint8_t ear, uint32_t cur_addr) "[%p] decode cmd: 0x%"PRIx32" len %d ear 0x%"PRIx8" addr 0x%"PRIx32 | ||
184 | +m25p80_populated_jedec(void *s) "[%p] populated jedec code" | ||
185 | +m25p80_chip_erase(void *s) "[%p] chip erase" | ||
186 | +m25p80_select(void *s, const char *what) "[%p] %sselect" | ||
187 | +m25p80_page_program(void *s, uint32_t addr, uint8_t tx) "[%p] page program cur_addr=0x%"PRIx32" data=0x%"PRIx8 | ||
188 | +m25p80_transfer(void *s, uint8_t state, uint32_t len, uint8_t needed, uint32_t pos, uint32_t cur_addr, uint8_t t) "[%p] Transfer state 0x%"PRIx8" len 0x%"PRIx32" needed 0x%"PRIx8" pos 0x%"PRIx32" addr 0x%"PRIx32" tx 0x%"PRIx8 | ||
189 | +m25p80_read_byte(void *s, uint32_t addr, uint8_t v) "[%p] Read byte 0x%"PRIx32"=0x%"PRIx8 | ||
190 | +m25p80_read_data(void *s, uint32_t pos, uint8_t v) "[%p] Read data 0x%"PRIx32"=0x%"PRIx8 | ||
191 | +m25p80_binding(void *s) "[%p] Binding to IF_MTD drive" | ||
192 | +m25p80_binding_no_bdrv(void *s) "[%p] No BDRV - binding to RAM" | ||
193 | -- | 126 | -- |
194 | 2.20.1 | 127 | 2.34.1 |
195 | 128 | ||
196 | 129 | diff view generated by jsdifflib |
1 | From: Guenter Roeck <linux@roeck-us.net> | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Recent Linux kernels (post v4.20) crash due to accesses to flexcan | 3 | There are 2 I2C controllers, map them both, removing |
4 | and pwm controllers. Instantiate as unimplemented devices to work | 4 | the unimplemented one. Keep the OLED controller on the |
5 | around the problem. | 5 | first I2C bus. |
6 | 6 | ||
7 | Signed-off-by: Guenter Roeck <linux@roeck-us.net> | 7 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
8 | Message-id: 20200313014551.12554-4-linux@roeck-us.net | ||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Message-id: 20250110160204.74997-7-philmd@linaro.org | ||
10 | [PMM: tweak to appease maybe-use-uninitialized warning] | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 12 | --- |
12 | hw/arm/fsl-imx6ul.c | 14 ++++++++++++++ | 13 | hw/arm/stellaris.c | 21 +++++++++++++-------- |
13 | 1 file changed, 14 insertions(+) | 14 | 1 file changed, 13 insertions(+), 8 deletions(-) |
14 | 15 | ||
15 | diff --git a/hw/arm/fsl-imx6ul.c b/hw/arm/fsl-imx6ul.c | 16 | diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c |
16 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/hw/arm/fsl-imx6ul.c | 18 | --- a/hw/arm/stellaris.c |
18 | +++ b/hw/arm/fsl-imx6ul.c | 19 | +++ b/hw/arm/stellaris.c |
19 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp) | 20 | @@ -XXX,XX +XXX,XX @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board) |
21 | { 0x40004000, 0x40005000, 0x40006000, 0x40007000, | ||
22 | 0x40024000, 0x40025000, 0x40026000}; | ||
23 | static const int gpio_irq[NUM_GPIO] = {0, 1, 2, 3, 4, 30, 31}; | ||
24 | + static const uint32_t i2c_addr[NUM_I2C] = {0x40020000, 0x40021000}; | ||
25 | + static const int i2c_irq[NUM_I2C] = {8, 37}; | ||
26 | |||
27 | /* Memory map of SoC devices, from | ||
28 | * Stellaris LM3S6965 Microcontroller Data Sheet (rev I) | ||
29 | @@ -XXX,XX +XXX,XX @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board) | ||
30 | qemu_irq adc; | ||
31 | int sram_size; | ||
32 | int flash_size; | ||
33 | - I2CBus *i2c; | ||
34 | + DeviceState *i2c_dev[NUM_I2C] = { }; | ||
35 | DeviceState *dev; | ||
36 | DeviceState *ssys_dev; | ||
37 | int i; | ||
38 | @@ -XXX,XX +XXX,XX @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board) | ||
39 | } | ||
40 | } | ||
41 | |||
42 | - if (DEV_CAP(2, I2C(0))) { | ||
43 | - dev = sysbus_create_simple(TYPE_STELLARIS_I2C, 0x40020000, | ||
44 | - qdev_get_gpio_in(nvic, 8)); | ||
45 | - i2c = (I2CBus *)qdev_get_child_bus(dev, "i2c"); | ||
46 | - if (board->peripherals & BP_OLED_I2C) { | ||
47 | - i2c_slave_create_simple(i2c, "ssd0303", 0x3d); | ||
48 | + for (i = 0; i < NUM_I2C; i++) { | ||
49 | + if (DEV_CAP(2, I2C(i))) { | ||
50 | + i2c_dev[i] = sysbus_create_simple(TYPE_STELLARIS_I2C, i2c_addr[i], | ||
51 | + qdev_get_gpio_in(nvic, | ||
52 | + i2c_irq[i])); | ||
53 | } | ||
54 | } | ||
55 | + if (board->peripherals & BP_OLED_I2C) { | ||
56 | + I2CBus *bus = (I2CBus *)qdev_get_child_bus(i2c_dev[0], "i2c"); | ||
57 | + | ||
58 | + i2c_slave_create_simple(bus, "ssd0303", 0x3d); | ||
59 | + } | ||
60 | |||
61 | for (i = 0; i < NUM_UART; i++) { | ||
62 | if (DEV_CAP(2, UART(i))) { | ||
63 | @@ -XXX,XX +XXX,XX @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board) | ||
64 | /* Add dummy regions for the devices we don't implement yet, | ||
65 | * so guest accesses don't cause unlogged crashes. | ||
20 | */ | 66 | */ |
21 | create_unimplemented_device("sdma", FSL_IMX6UL_SDMA_ADDR, 0x4000); | 67 | - create_unimplemented_device("i2c-2", 0x40021000, 0x1000); |
22 | 68 | create_unimplemented_device("PWM", 0x40028000, 0x1000); | |
23 | + /* | 69 | create_unimplemented_device("QEI-0", 0x4002c000, 0x1000); |
24 | + * PWM | 70 | create_unimplemented_device("QEI-1", 0x4002d000, 0x1000); |
25 | + */ | ||
26 | + create_unimplemented_device("pwm1", FSL_IMX6UL_PWM1_ADDR, 0x4000); | ||
27 | + create_unimplemented_device("pwm2", FSL_IMX6UL_PWM2_ADDR, 0x4000); | ||
28 | + create_unimplemented_device("pwm3", FSL_IMX6UL_PWM3_ADDR, 0x4000); | ||
29 | + create_unimplemented_device("pwm4", FSL_IMX6UL_PWM4_ADDR, 0x4000); | ||
30 | + | ||
31 | + /* | ||
32 | + * CAN | ||
33 | + */ | ||
34 | + create_unimplemented_device("can1", FSL_IMX6UL_CAN1_ADDR, 0x4000); | ||
35 | + create_unimplemented_device("can2", FSL_IMX6UL_CAN2_ADDR, 0x4000); | ||
36 | + | ||
37 | /* | ||
38 | * APHB_DMA | ||
39 | */ | ||
40 | -- | 71 | -- |
41 | 2.20.1 | 72 | 2.34.1 |
42 | 73 | ||
43 | 74 | diff view generated by jsdifflib |
1 | From: Guenter Roeck <linux@roeck-us.net> | 1 | From: Thomas Huth <thuth@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | Add basic USB PHY support as implemented in i.MX23, i.MX28, i.MX6, | 3 | We don't have any functional tests for this machine yet, thus let's |
4 | and i.MX7 SoCs. | 4 | add a test with a MicroPython binary that is available online |
5 | (thanks to Joel Stanley for providing it, see: | ||
6 | https://www.mail-archive.com/qemu-devel@nongnu.org/msg606064.html ). | ||
5 | 7 | ||
6 | The only support really needed - at least to boot Linux - is support | 8 | Signed-off-by: Thomas Huth <thuth@redhat.com> |
7 | for soft reset, which needs to reset various registers to their initial | 9 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> |
8 | value. Otherwise, just record register values. | 10 | Message-id: 20250124101709.1591761-1-thuth@redhat.com |
9 | |||
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | Signed-off-by: Guenter Roeck <linux@roeck-us.net> | ||
12 | Message-id: 20200313014551.12554-2-linux@roeck-us.net | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | --- | 12 | --- |
15 | hw/usb/Makefile.objs | 2 + | 13 | MAINTAINERS | 1 + |
16 | include/hw/usb/imx-usb-phy.h | 53 +++++++++ | 14 | tests/functional/meson.build | 1 + |
17 | hw/usb/imx-usb-phy.c | 225 +++++++++++++++++++++++++++++++++++ | 15 | tests/functional/test_arm_microbit.py | 31 +++++++++++++++++++++++++++ |
18 | MAINTAINERS | 2 + | 16 | 3 files changed, 33 insertions(+) |
19 | hw/arm/Kconfig | 1 + | 17 | create mode 100755 tests/functional/test_arm_microbit.py |
20 | hw/usb/Kconfig | 5 + | ||
21 | 6 files changed, 288 insertions(+) | ||
22 | create mode 100644 include/hw/usb/imx-usb-phy.h | ||
23 | create mode 100644 hw/usb/imx-usb-phy.c | ||
24 | 18 | ||
25 | diff --git a/hw/usb/Makefile.objs b/hw/usb/Makefile.objs | ||
26 | index XXXXXXX..XXXXXXX 100644 | ||
27 | --- a/hw/usb/Makefile.objs | ||
28 | +++ b/hw/usb/Makefile.objs | ||
29 | @@ -XXX,XX +XXX,XX @@ common-obj-$(CONFIG_XEN) += xen-usb.o | ||
30 | xen-usb.o-cflags := $(LIBUSB_CFLAGS) | ||
31 | xen-usb.o-libs := $(LIBUSB_LIBS) | ||
32 | endif | ||
33 | + | ||
34 | +common-obj-$(CONFIG_IMX_USBPHY) += imx-usb-phy.o | ||
35 | diff --git a/include/hw/usb/imx-usb-phy.h b/include/hw/usb/imx-usb-phy.h | ||
36 | new file mode 100644 | ||
37 | index XXXXXXX..XXXXXXX | ||
38 | --- /dev/null | ||
39 | +++ b/include/hw/usb/imx-usb-phy.h | ||
40 | @@ -XXX,XX +XXX,XX @@ | ||
41 | +#ifndef IMX_USB_PHY_H | ||
42 | +#define IMX_USB_PHY_H | ||
43 | + | ||
44 | +#include "hw/sysbus.h" | ||
45 | +#include "qemu/bitops.h" | ||
46 | + | ||
47 | +enum IMXUsbPhyRegisters { | ||
48 | + USBPHY_PWD, | ||
49 | + USBPHY_PWD_SET, | ||
50 | + USBPHY_PWD_CLR, | ||
51 | + USBPHY_PWD_TOG, | ||
52 | + USBPHY_TX, | ||
53 | + USBPHY_TX_SET, | ||
54 | + USBPHY_TX_CLR, | ||
55 | + USBPHY_TX_TOG, | ||
56 | + USBPHY_RX, | ||
57 | + USBPHY_RX_SET, | ||
58 | + USBPHY_RX_CLR, | ||
59 | + USBPHY_RX_TOG, | ||
60 | + USBPHY_CTRL, | ||
61 | + USBPHY_CTRL_SET, | ||
62 | + USBPHY_CTRL_CLR, | ||
63 | + USBPHY_CTRL_TOG, | ||
64 | + USBPHY_STATUS, | ||
65 | + USBPHY_DEBUG = 0x14, | ||
66 | + USBPHY_DEBUG_SET, | ||
67 | + USBPHY_DEBUG_CLR, | ||
68 | + USBPHY_DEBUG_TOG, | ||
69 | + USBPHY_DEBUG0_STATUS, | ||
70 | + USBPHY_DEBUG1 = 0x1c, | ||
71 | + USBPHY_DEBUG1_SET, | ||
72 | + USBPHY_DEBUG1_CLR, | ||
73 | + USBPHY_DEBUG1_TOG, | ||
74 | + USBPHY_VERSION, | ||
75 | + USBPHY_MAX | ||
76 | +}; | ||
77 | + | ||
78 | +#define USBPHY_CTRL_SFTRST BIT(31) | ||
79 | + | ||
80 | +#define TYPE_IMX_USBPHY "imx.usbphy" | ||
81 | +#define IMX_USBPHY(obj) OBJECT_CHECK(IMXUSBPHYState, (obj), TYPE_IMX_USBPHY) | ||
82 | + | ||
83 | +typedef struct IMXUSBPHYState { | ||
84 | + /* <private> */ | ||
85 | + SysBusDevice parent_obj; | ||
86 | + | ||
87 | + /* <public> */ | ||
88 | + MemoryRegion iomem; | ||
89 | + | ||
90 | + uint32_t usbphy[USBPHY_MAX]; | ||
91 | +} IMXUSBPHYState; | ||
92 | + | ||
93 | +#endif /* IMX_USB_PHY_H */ | ||
94 | diff --git a/hw/usb/imx-usb-phy.c b/hw/usb/imx-usb-phy.c | ||
95 | new file mode 100644 | ||
96 | index XXXXXXX..XXXXXXX | ||
97 | --- /dev/null | ||
98 | +++ b/hw/usb/imx-usb-phy.c | ||
99 | @@ -XXX,XX +XXX,XX @@ | ||
100 | +/* | ||
101 | + * i.MX USB PHY | ||
102 | + * | ||
103 | + * Copyright (c) 2020 Guenter Roeck <linux@roeck-us.net> | ||
104 | + * | ||
105 | + * This work is licensed under the terms of the GNU GPL, version 2 or later. | ||
106 | + * See the COPYING file in the top-level directory. | ||
107 | + * | ||
108 | + * We need to implement basic reset control in the PHY control register. | ||
109 | + * For everything else, it is sufficient to set whatever is written. | ||
110 | + */ | ||
111 | + | ||
112 | +#include "qemu/osdep.h" | ||
113 | +#include "hw/usb/imx-usb-phy.h" | ||
114 | +#include "migration/vmstate.h" | ||
115 | +#include "qemu/log.h" | ||
116 | +#include "qemu/module.h" | ||
117 | + | ||
118 | +static const VMStateDescription vmstate_imx_usbphy = { | ||
119 | + .name = TYPE_IMX_USBPHY, | ||
120 | + .version_id = 1, | ||
121 | + .minimum_version_id = 1, | ||
122 | + .fields = (VMStateField[]) { | ||
123 | + VMSTATE_UINT32_ARRAY(usbphy, IMXUSBPHYState, USBPHY_MAX), | ||
124 | + VMSTATE_END_OF_LIST() | ||
125 | + }, | ||
126 | +}; | ||
127 | + | ||
128 | +static void imx_usbphy_softreset(IMXUSBPHYState *s) | ||
129 | +{ | ||
130 | + s->usbphy[USBPHY_PWD] = 0x001e1c00; | ||
131 | + s->usbphy[USBPHY_TX] = 0x10060607; | ||
132 | + s->usbphy[USBPHY_RX] = 0x00000000; | ||
133 | + s->usbphy[USBPHY_CTRL] = 0xc0200000; | ||
134 | +} | ||
135 | + | ||
136 | +static void imx_usbphy_reset(DeviceState *dev) | ||
137 | +{ | ||
138 | + IMXUSBPHYState *s = IMX_USBPHY(dev); | ||
139 | + | ||
140 | + s->usbphy[USBPHY_STATUS] = 0x00000000; | ||
141 | + s->usbphy[USBPHY_DEBUG] = 0x7f180000; | ||
142 | + s->usbphy[USBPHY_DEBUG0_STATUS] = 0x00000000; | ||
143 | + s->usbphy[USBPHY_DEBUG1] = 0x00001000; | ||
144 | + s->usbphy[USBPHY_VERSION] = 0x04020000; | ||
145 | + | ||
146 | + imx_usbphy_softreset(s); | ||
147 | +} | ||
148 | + | ||
149 | +static uint64_t imx_usbphy_read(void *opaque, hwaddr offset, unsigned size) | ||
150 | +{ | ||
151 | + IMXUSBPHYState *s = (IMXUSBPHYState *)opaque; | ||
152 | + uint32_t index = offset >> 2; | ||
153 | + uint32_t value; | ||
154 | + | ||
155 | + switch (index) { | ||
156 | + case USBPHY_PWD_SET: | ||
157 | + case USBPHY_TX_SET: | ||
158 | + case USBPHY_RX_SET: | ||
159 | + case USBPHY_CTRL_SET: | ||
160 | + case USBPHY_DEBUG_SET: | ||
161 | + case USBPHY_DEBUG1_SET: | ||
162 | + /* | ||
163 | + * All REG_NAME_SET register access are in fact targeting the | ||
164 | + * REG_NAME register. | ||
165 | + */ | ||
166 | + value = s->usbphy[index - 1]; | ||
167 | + break; | ||
168 | + case USBPHY_PWD_CLR: | ||
169 | + case USBPHY_TX_CLR: | ||
170 | + case USBPHY_RX_CLR: | ||
171 | + case USBPHY_CTRL_CLR: | ||
172 | + case USBPHY_DEBUG_CLR: | ||
173 | + case USBPHY_DEBUG1_CLR: | ||
174 | + /* | ||
175 | + * All REG_NAME_CLR register access are in fact targeting the | ||
176 | + * REG_NAME register. | ||
177 | + */ | ||
178 | + value = s->usbphy[index - 2]; | ||
179 | + break; | ||
180 | + case USBPHY_PWD_TOG: | ||
181 | + case USBPHY_TX_TOG: | ||
182 | + case USBPHY_RX_TOG: | ||
183 | + case USBPHY_CTRL_TOG: | ||
184 | + case USBPHY_DEBUG_TOG: | ||
185 | + case USBPHY_DEBUG1_TOG: | ||
186 | + /* | ||
187 | + * All REG_NAME_TOG register access are in fact targeting the | ||
188 | + * REG_NAME register. | ||
189 | + */ | ||
190 | + value = s->usbphy[index - 3]; | ||
191 | + break; | ||
192 | + default: | ||
193 | + value = s->usbphy[index]; | ||
194 | + break; | ||
195 | + } | ||
196 | + return (uint64_t)value; | ||
197 | +} | ||
198 | + | ||
199 | +static void imx_usbphy_write(void *opaque, hwaddr offset, uint64_t value, | ||
200 | + unsigned size) | ||
201 | +{ | ||
202 | + IMXUSBPHYState *s = (IMXUSBPHYState *)opaque; | ||
203 | + uint32_t index = offset >> 2; | ||
204 | + | ||
205 | + switch (index) { | ||
206 | + case USBPHY_CTRL: | ||
207 | + s->usbphy[index] = value; | ||
208 | + if (value & USBPHY_CTRL_SFTRST) { | ||
209 | + imx_usbphy_softreset(s); | ||
210 | + } | ||
211 | + break; | ||
212 | + case USBPHY_PWD: | ||
213 | + case USBPHY_TX: | ||
214 | + case USBPHY_RX: | ||
215 | + case USBPHY_STATUS: | ||
216 | + case USBPHY_DEBUG: | ||
217 | + case USBPHY_DEBUG1: | ||
218 | + s->usbphy[index] = value; | ||
219 | + break; | ||
220 | + case USBPHY_CTRL_SET: | ||
221 | + s->usbphy[index - 1] |= value; | ||
222 | + if (value & USBPHY_CTRL_SFTRST) { | ||
223 | + imx_usbphy_softreset(s); | ||
224 | + } | ||
225 | + break; | ||
226 | + case USBPHY_PWD_SET: | ||
227 | + case USBPHY_TX_SET: | ||
228 | + case USBPHY_RX_SET: | ||
229 | + case USBPHY_DEBUG_SET: | ||
230 | + case USBPHY_DEBUG1_SET: | ||
231 | + /* | ||
232 | + * All REG_NAME_SET register access are in fact targeting the | ||
233 | + * REG_NAME register. So we change the value of the REG_NAME | ||
234 | + * register, setting bits passed in the value. | ||
235 | + */ | ||
236 | + s->usbphy[index - 1] |= value; | ||
237 | + break; | ||
238 | + case USBPHY_PWD_CLR: | ||
239 | + case USBPHY_TX_CLR: | ||
240 | + case USBPHY_RX_CLR: | ||
241 | + case USBPHY_CTRL_CLR: | ||
242 | + case USBPHY_DEBUG_CLR: | ||
243 | + case USBPHY_DEBUG1_CLR: | ||
244 | + /* | ||
245 | + * All REG_NAME_CLR register access are in fact targeting the | ||
246 | + * REG_NAME register. So we change the value of the REG_NAME | ||
247 | + * register, unsetting bits passed in the value. | ||
248 | + */ | ||
249 | + s->usbphy[index - 2] &= ~value; | ||
250 | + break; | ||
251 | + case USBPHY_CTRL_TOG: | ||
252 | + s->usbphy[index - 3] ^= value; | ||
253 | + if ((value & USBPHY_CTRL_SFTRST) && | ||
254 | + (s->usbphy[index - 3] & USBPHY_CTRL_SFTRST)) { | ||
255 | + imx_usbphy_softreset(s); | ||
256 | + } | ||
257 | + break; | ||
258 | + case USBPHY_PWD_TOG: | ||
259 | + case USBPHY_TX_TOG: | ||
260 | + case USBPHY_RX_TOG: | ||
261 | + case USBPHY_DEBUG_TOG: | ||
262 | + case USBPHY_DEBUG1_TOG: | ||
263 | + /* | ||
264 | + * All REG_NAME_TOG register access are in fact targeting the | ||
265 | + * REG_NAME register. So we change the value of the REG_NAME | ||
266 | + * register, toggling bits passed in the value. | ||
267 | + */ | ||
268 | + s->usbphy[index - 3] ^= value; | ||
269 | + break; | ||
270 | + default: | ||
271 | + /* Other registers are read-only */ | ||
272 | + break; | ||
273 | + } | ||
274 | +} | ||
275 | + | ||
276 | +static const struct MemoryRegionOps imx_usbphy_ops = { | ||
277 | + .read = imx_usbphy_read, | ||
278 | + .write = imx_usbphy_write, | ||
279 | + .endianness = DEVICE_NATIVE_ENDIAN, | ||
280 | + .valid = { | ||
281 | + /* | ||
282 | + * Our device would not work correctly if the guest was doing | ||
283 | + * unaligned access. This might not be a limitation on the real | ||
284 | + * device but in practice there is no reason for a guest to access | ||
285 | + * this device unaligned. | ||
286 | + */ | ||
287 | + .min_access_size = 4, | ||
288 | + .max_access_size = 4, | ||
289 | + .unaligned = false, | ||
290 | + }, | ||
291 | +}; | ||
292 | + | ||
293 | +static void imx_usbphy_realize(DeviceState *dev, Error **errp) | ||
294 | +{ | ||
295 | + IMXUSBPHYState *s = IMX_USBPHY(dev); | ||
296 | + | ||
297 | + memory_region_init_io(&s->iomem, OBJECT(s), &imx_usbphy_ops, s, | ||
298 | + "imx-usbphy", 0x1000); | ||
299 | + sysbus_init_mmio(SYS_BUS_DEVICE(s), &s->iomem); | ||
300 | +} | ||
301 | + | ||
302 | +static void imx_usbphy_class_init(ObjectClass *klass, void *data) | ||
303 | +{ | ||
304 | + DeviceClass *dc = DEVICE_CLASS(klass); | ||
305 | + | ||
306 | + dc->reset = imx_usbphy_reset; | ||
307 | + dc->vmsd = &vmstate_imx_usbphy; | ||
308 | + dc->desc = "i.MX USB PHY Module"; | ||
309 | + dc->realize = imx_usbphy_realize; | ||
310 | +} | ||
311 | + | ||
312 | +static const TypeInfo imx_usbphy_info = { | ||
313 | + .name = TYPE_IMX_USBPHY, | ||
314 | + .parent = TYPE_SYS_BUS_DEVICE, | ||
315 | + .instance_size = sizeof(IMXUSBPHYState), | ||
316 | + .class_init = imx_usbphy_class_init, | ||
317 | +}; | ||
318 | + | ||
319 | +static void imx_usbphy_register_types(void) | ||
320 | +{ | ||
321 | + type_register_static(&imx_usbphy_info); | ||
322 | +} | ||
323 | + | ||
324 | +type_init(imx_usbphy_register_types) | ||
325 | diff --git a/MAINTAINERS b/MAINTAINERS | 19 | diff --git a/MAINTAINERS b/MAINTAINERS |
326 | index XXXXXXX..XXXXXXX 100644 | 20 | index XXXXXXX..XXXXXXX 100644 |
327 | --- a/MAINTAINERS | 21 | --- a/MAINTAINERS |
328 | +++ b/MAINTAINERS | 22 | +++ b/MAINTAINERS |
329 | @@ -XXX,XX +XXX,XX @@ F: hw/arm/sabrelite.c | 23 | @@ -XXX,XX +XXX,XX @@ F: hw/*/microbit*.c |
330 | F: hw/arm/fsl-imx6.c | 24 | F: include/hw/*/nrf51*.h |
331 | F: hw/misc/imx6_*.c | 25 | F: include/hw/*/microbit*.h |
332 | F: hw/ssi/imx_spi.c | 26 | F: tests/qtest/microbit-test.c |
333 | +F: hw/usb/imx-usb-phy.c | 27 | +F: tests/functional/test_arm_microbit.py |
334 | +F: include/hw/usb/imx-usb-phy.h | 28 | F: docs/system/arm/nrf.rst |
335 | F: include/hw/arm/fsl-imx6.h | 29 | |
336 | F: include/hw/misc/imx6_*.h | 30 | ARM PL011 Rust device |
337 | F: include/hw/ssi/imx_spi.h | 31 | diff --git a/tests/functional/meson.build b/tests/functional/meson.build |
338 | diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig | ||
339 | index XXXXXXX..XXXXXXX 100644 | 32 | index XXXXXXX..XXXXXXX 100644 |
340 | --- a/hw/arm/Kconfig | 33 | --- a/tests/functional/meson.build |
341 | +++ b/hw/arm/Kconfig | 34 | +++ b/tests/functional/meson.build |
342 | @@ -XXX,XX +XXX,XX @@ config FSL_IMX6 | 35 | @@ -XXX,XX +XXX,XX @@ tests_arm_system_thorough = [ |
343 | select IMX | 36 | 'arm_cubieboard', |
344 | select IMX_FEC | 37 | 'arm_emcraft_sf2', |
345 | select IMX_I2C | 38 | 'arm_integratorcp', |
346 | + select IMX_USBPHY | 39 | + 'arm_microbit', |
347 | select SDHCI | 40 | 'arm_orangepi', |
348 | 41 | 'arm_quanta_gsj', | |
349 | config ASPEED_SOC | 42 | 'arm_raspi2', |
350 | diff --git a/hw/usb/Kconfig b/hw/usb/Kconfig | 43 | diff --git a/tests/functional/test_arm_microbit.py b/tests/functional/test_arm_microbit.py |
351 | index XXXXXXX..XXXXXXX 100644 | 44 | new file mode 100755 |
352 | --- a/hw/usb/Kconfig | 45 | index XXXXXXX..XXXXXXX |
353 | +++ b/hw/usb/Kconfig | 46 | --- /dev/null |
354 | @@ -XXX,XX +XXX,XX @@ config USB_STORAGE_MTP | 47 | +++ b/tests/functional/test_arm_microbit.py |
355 | bool | 48 | @@ -XXX,XX +XXX,XX @@ |
356 | default y | 49 | +#!/usr/bin/env python3 |
357 | depends on USB | 50 | +# |
51 | +# SPDX-License-Identifier: GPL-2.0-or-later | ||
52 | +# | ||
53 | +# Copyright 2025, The QEMU Project Developers. | ||
54 | +# | ||
55 | +# A functional test that runs MicroPython on the arm microbit machine. | ||
358 | + | 56 | + |
359 | +config IMX_USBPHY | 57 | +from qemu_test import QemuSystemTest, Asset, exec_command_and_wait_for_pattern |
360 | + bool | 58 | +from qemu_test import wait_for_console_pattern |
361 | + default y | 59 | + |
362 | + depends on USB | 60 | + |
61 | +class MicrobitMachine(QemuSystemTest): | ||
62 | + | ||
63 | + ASSET_MICRO = Asset('https://ozlabs.org/~joel/microbit-micropython.hex', | ||
64 | + '021641f93dfb11767d4978dbb3ca7f475d1b13c69e7f4aec3382f212636bffd6') | ||
65 | + | ||
66 | + def test_arm_microbit(self): | ||
67 | + self.set_machine('microbit') | ||
68 | + | ||
69 | + micropython = self.ASSET_MICRO.fetch() | ||
70 | + self.vm.set_console() | ||
71 | + self.vm.add_args('-device', f'loader,file={micropython}') | ||
72 | + self.vm.launch() | ||
73 | + wait_for_console_pattern(self, 'Type "help()" for more information.') | ||
74 | + exec_command_and_wait_for_pattern(self, 'import machine as mch', '>>>') | ||
75 | + exec_command_and_wait_for_pattern(self, 'mch.reset()', 'MicroPython') | ||
76 | + wait_for_console_pattern(self, '>>>') | ||
77 | + | ||
78 | +if __name__ == '__main__': | ||
79 | + QemuSystemTest.main() | ||
363 | -- | 80 | -- |
364 | 2.20.1 | 81 | 2.34.1 |
365 | 82 | ||
366 | 83 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | The pseudocode ResetSVEState() does: | ||
2 | FPSR = ZeroExtend(0x0800009f<31:0>, 64); | ||
3 | but QEMU's arm_reset_sve_state() called vfp_set_fpcr() by accident. | ||
1 | 4 | ||
5 | Before the advent of FEAT_AFP, this was only setting a collection of | ||
6 | RES0 bits, which vfp_set_fpsr() would then ignore, so the only effect | ||
7 | was that we didn't actually set the FPSR the way we are supposed to | ||
8 | do. Once FEAT_AFP is implemented, setting the bottom bits of FPSR | ||
9 | will change the floating point behaviour. | ||
10 | |||
11 | Call vfp_set_fpsr(), as we ought to. | ||
12 | |||
13 | (Note for stable backports: commit 7f2a01e7368f9 moved this function | ||
14 | from sme_helper.c to helper.c, but it had the same bug before the | ||
15 | move too.) | ||
16 | |||
17 | Cc: qemu-stable@nongnu.org | ||
18 | Fixes: f84734b87461 ("target/arm: Implement SMSTART, SMSTOP") | ||
19 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
20 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
21 | Message-id: 20250124162836.2332150-4-peter.maydell@linaro.org | ||
22 | --- | ||
23 | target/arm/helper.c | 2 +- | ||
24 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
25 | |||
26 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
27 | index XXXXXXX..XXXXXXX 100644 | ||
28 | --- a/target/arm/helper.c | ||
29 | +++ b/target/arm/helper.c | ||
30 | @@ -XXX,XX +XXX,XX @@ static void arm_reset_sve_state(CPUARMState *env) | ||
31 | memset(env->vfp.zregs, 0, sizeof(env->vfp.zregs)); | ||
32 | /* Recall that FFR is stored as pregs[16]. */ | ||
33 | memset(env->vfp.pregs, 0, sizeof(env->vfp.pregs)); | ||
34 | - vfp_set_fpcr(env, 0x0800009f); | ||
35 | + vfp_set_fpsr(env, 0x0800009f); | ||
36 | } | ||
37 | |||
38 | void aarch64_set_svcr(CPUARMState *env, uint64_t new, uint64_t mask) | ||
39 | -- | ||
40 | 2.34.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Use the FPSR_ named constants in vfp_exceptbits_from_host(), | ||
2 | rather than hardcoded magic numbers. | ||
1 | 3 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20250124162836.2332150-5-peter.maydell@linaro.org | ||
7 | --- | ||
8 | target/arm/vfp_helper.c | 12 ++++++------ | ||
9 | 1 file changed, 6 insertions(+), 6 deletions(-) | ||
10 | |||
11 | diff --git a/target/arm/vfp_helper.c b/target/arm/vfp_helper.c | ||
12 | index XXXXXXX..XXXXXXX 100644 | ||
13 | --- a/target/arm/vfp_helper.c | ||
14 | +++ b/target/arm/vfp_helper.c | ||
15 | @@ -XXX,XX +XXX,XX @@ static inline int vfp_exceptbits_from_host(int host_bits) | ||
16 | int target_bits = 0; | ||
17 | |||
18 | if (host_bits & float_flag_invalid) { | ||
19 | - target_bits |= 1; | ||
20 | + target_bits |= FPSR_IOC; | ||
21 | } | ||
22 | if (host_bits & float_flag_divbyzero) { | ||
23 | - target_bits |= 2; | ||
24 | + target_bits |= FPSR_DZC; | ||
25 | } | ||
26 | if (host_bits & float_flag_overflow) { | ||
27 | - target_bits |= 4; | ||
28 | + target_bits |= FPSR_OFC; | ||
29 | } | ||
30 | if (host_bits & (float_flag_underflow | float_flag_output_denormal)) { | ||
31 | - target_bits |= 8; | ||
32 | + target_bits |= FPSR_UFC; | ||
33 | } | ||
34 | if (host_bits & float_flag_inexact) { | ||
35 | - target_bits |= 0x10; | ||
36 | + target_bits |= FPSR_IXC; | ||
37 | } | ||
38 | if (host_bits & float_flag_input_denormal) { | ||
39 | - target_bits |= 0x80; | ||
40 | + target_bits |= FPSR_IDC; | ||
41 | } | ||
42 | return target_bits; | ||
43 | } | ||
44 | -- | ||
45 | 2.34.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | In vfp_exceptbits_from_host(), we accumulate the FPSR flags in | ||
2 | an "int", and our return type is also "int". However, the only | ||
3 | callsite returns the same information as a uint32_t, and | ||
4 | more generally we handle FPSR values in the code as uint32_t, | ||
5 | not int. Bring this function in to line with that convention. | ||
1 | 6 | ||
7 | There is no behaviour change because none of the FPSR bits | ||
8 | we set in this function are bit 31. The input argument to | ||
9 | the function remains 'int' because that is the return type | ||
10 | of the softfloat get_float_exception_flags(). | ||
11 | |||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
14 | Message-id: 20250124162836.2332150-6-peter.maydell@linaro.org | ||
15 | --- | ||
16 | target/arm/vfp_helper.c | 4 ++-- | ||
17 | 1 file changed, 2 insertions(+), 2 deletions(-) | ||
18 | |||
19 | diff --git a/target/arm/vfp_helper.c b/target/arm/vfp_helper.c | ||
20 | index XXXXXXX..XXXXXXX 100644 | ||
21 | --- a/target/arm/vfp_helper.c | ||
22 | +++ b/target/arm/vfp_helper.c | ||
23 | @@ -XXX,XX +XXX,XX @@ | ||
24 | #ifdef CONFIG_TCG | ||
25 | |||
26 | /* Convert host exception flags to vfp form. */ | ||
27 | -static inline int vfp_exceptbits_from_host(int host_bits) | ||
28 | +static inline uint32_t vfp_exceptbits_from_host(int host_bits) | ||
29 | { | ||
30 | - int target_bits = 0; | ||
31 | + uint32_t target_bits = 0; | ||
32 | |||
33 | if (host_bits & float_flag_invalid) { | ||
34 | target_bits |= FPSR_IOC; | ||
35 | -- | ||
36 | 2.34.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | We want to split the existing fp_status in the Arm CPUState into | ||
2 | separate float_status fields for AArch32 and AArch64. (This is | ||
3 | because new control bits defined by FEAT_AFP only have an effect for | ||
4 | AArch64, not AArch32.) To make this split we will: | ||
5 | * define new fp_status_a32 and fp_status_a64 which have | ||
6 | identical behaviour to the existing fp_status | ||
7 | * move existing uses of fp_status to fp_status_a32 or | ||
8 | fp_status_a64 as appropriate | ||
9 | * delete the old fp_status when it has no uses left | ||
1 | 10 | ||
11 | In this patch we add the new float_status fields. | ||
12 | |||
13 | We will also need to split fp_status_f16, but we will do that | ||
14 | as a separate series of patches. | ||
15 | |||
16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
17 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
18 | Message-id: 20250124162836.2332150-7-peter.maydell@linaro.org | ||
19 | --- | ||
20 | target/arm/cpu.h | 4 ++++ | ||
21 | target/arm/tcg/translate.h | 12 ++++++++++++ | ||
22 | target/arm/cpu.c | 2 ++ | ||
23 | target/arm/vfp_helper.c | 12 ++++++++++++ | ||
24 | 4 files changed, 30 insertions(+) | ||
25 | |||
26 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
27 | index XXXXXXX..XXXXXXX 100644 | ||
28 | --- a/target/arm/cpu.h | ||
29 | +++ b/target/arm/cpu.h | ||
30 | @@ -XXX,XX +XXX,XX @@ typedef struct CPUArchState { | ||
31 | /* There are a number of distinct float control structures: | ||
32 | * | ||
33 | * fp_status: is the "normal" fp status. | ||
34 | + * fp_status_a32: is the "normal" fp status for AArch32 insns | ||
35 | + * fp_status_a64: is the "normal" fp status for AArch64 insns | ||
36 | * fp_status_fp16: used for half-precision calculations | ||
37 | * standard_fp_status : the ARM "Standard FPSCR Value" | ||
38 | * standard_fp_status_fp16 : used for half-precision | ||
39 | @@ -XXX,XX +XXX,XX @@ typedef struct CPUArchState { | ||
40 | * an explicit FPSCR read. | ||
41 | */ | ||
42 | float_status fp_status; | ||
43 | + float_status fp_status_a32; | ||
44 | + float_status fp_status_a64; | ||
45 | float_status fp_status_f16; | ||
46 | float_status standard_fp_status; | ||
47 | float_status standard_fp_status_f16; | ||
48 | diff --git a/target/arm/tcg/translate.h b/target/arm/tcg/translate.h | ||
49 | index XXXXXXX..XXXXXXX 100644 | ||
50 | --- a/target/arm/tcg/translate.h | ||
51 | +++ b/target/arm/tcg/translate.h | ||
52 | @@ -XXX,XX +XXX,XX @@ static inline CPUARMTBFlags arm_tbflags_from_tb(const TranslationBlock *tb) | ||
53 | */ | ||
54 | typedef enum ARMFPStatusFlavour { | ||
55 | FPST_FPCR, | ||
56 | + FPST_A32, | ||
57 | + FPST_A64, | ||
58 | FPST_FPCR_F16, | ||
59 | FPST_STD, | ||
60 | FPST_STD_F16, | ||
61 | @@ -XXX,XX +XXX,XX @@ typedef enum ARMFPStatusFlavour { | ||
62 | * | ||
63 | * FPST_FPCR | ||
64 | * for non-FP16 operations controlled by the FPCR | ||
65 | + * FPST_A32 | ||
66 | + * for AArch32 non-FP16 operations controlled by the FPCR | ||
67 | + * FPST_A64 | ||
68 | + * for AArch64 non-FP16 operations controlled by the FPCR | ||
69 | * FPST_FPCR_F16 | ||
70 | * for operations controlled by the FPCR where FPCR.FZ16 is to be used | ||
71 | * FPST_STD | ||
72 | @@ -XXX,XX +XXX,XX @@ static inline TCGv_ptr fpstatus_ptr(ARMFPStatusFlavour flavour) | ||
73 | case FPST_FPCR: | ||
74 | offset = offsetof(CPUARMState, vfp.fp_status); | ||
75 | break; | ||
76 | + case FPST_A32: | ||
77 | + offset = offsetof(CPUARMState, vfp.fp_status_a32); | ||
78 | + break; | ||
79 | + case FPST_A64: | ||
80 | + offset = offsetof(CPUARMState, vfp.fp_status_a64); | ||
81 | + break; | ||
82 | case FPST_FPCR_F16: | ||
83 | offset = offsetof(CPUARMState, vfp.fp_status_f16); | ||
84 | break; | ||
85 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | ||
86 | index XXXXXXX..XXXXXXX 100644 | ||
87 | --- a/target/arm/cpu.c | ||
88 | +++ b/target/arm/cpu.c | ||
89 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_reset_hold(Object *obj, ResetType type) | ||
90 | set_default_nan_mode(1, &env->vfp.standard_fp_status); | ||
91 | set_default_nan_mode(1, &env->vfp.standard_fp_status_f16); | ||
92 | arm_set_default_fp_behaviours(&env->vfp.fp_status); | ||
93 | + arm_set_default_fp_behaviours(&env->vfp.fp_status_a32); | ||
94 | + arm_set_default_fp_behaviours(&env->vfp.fp_status_a64); | ||
95 | arm_set_default_fp_behaviours(&env->vfp.standard_fp_status); | ||
96 | arm_set_default_fp_behaviours(&env->vfp.fp_status_f16); | ||
97 | arm_set_default_fp_behaviours(&env->vfp.standard_fp_status_f16); | ||
98 | diff --git a/target/arm/vfp_helper.c b/target/arm/vfp_helper.c | ||
99 | index XXXXXXX..XXXXXXX 100644 | ||
100 | --- a/target/arm/vfp_helper.c | ||
101 | +++ b/target/arm/vfp_helper.c | ||
102 | @@ -XXX,XX +XXX,XX @@ static uint32_t vfp_get_fpsr_from_host(CPUARMState *env) | ||
103 | uint32_t i; | ||
104 | |||
105 | i = get_float_exception_flags(&env->vfp.fp_status); | ||
106 | + i |= get_float_exception_flags(&env->vfp.fp_status_a32); | ||
107 | + i |= get_float_exception_flags(&env->vfp.fp_status_a64); | ||
108 | i |= get_float_exception_flags(&env->vfp.standard_fp_status); | ||
109 | /* FZ16 does not generate an input denormal exception. */ | ||
110 | i |= (get_float_exception_flags(&env->vfp.fp_status_f16) | ||
111 | @@ -XXX,XX +XXX,XX @@ static void vfp_clear_float_status_exc_flags(CPUARMState *env) | ||
112 | * be the architecturally up-to-date exception flag information first. | ||
113 | */ | ||
114 | set_float_exception_flags(0, &env->vfp.fp_status); | ||
115 | + set_float_exception_flags(0, &env->vfp.fp_status_a32); | ||
116 | + set_float_exception_flags(0, &env->vfp.fp_status_a64); | ||
117 | set_float_exception_flags(0, &env->vfp.fp_status_f16); | ||
118 | set_float_exception_flags(0, &env->vfp.standard_fp_status); | ||
119 | set_float_exception_flags(0, &env->vfp.standard_fp_status_f16); | ||
120 | @@ -XXX,XX +XXX,XX @@ static void vfp_set_fpcr_to_host(CPUARMState *env, uint32_t val, uint32_t mask) | ||
121 | break; | ||
122 | } | ||
123 | set_float_rounding_mode(i, &env->vfp.fp_status); | ||
124 | + set_float_rounding_mode(i, &env->vfp.fp_status_a32); | ||
125 | + set_float_rounding_mode(i, &env->vfp.fp_status_a64); | ||
126 | set_float_rounding_mode(i, &env->vfp.fp_status_f16); | ||
127 | } | ||
128 | if (changed & FPCR_FZ16) { | ||
129 | @@ -XXX,XX +XXX,XX @@ static void vfp_set_fpcr_to_host(CPUARMState *env, uint32_t val, uint32_t mask) | ||
130 | bool ftz_enabled = val & FPCR_FZ; | ||
131 | set_flush_to_zero(ftz_enabled, &env->vfp.fp_status); | ||
132 | set_flush_inputs_to_zero(ftz_enabled, &env->vfp.fp_status); | ||
133 | + set_flush_to_zero(ftz_enabled, &env->vfp.fp_status_a32); | ||
134 | + set_flush_inputs_to_zero(ftz_enabled, &env->vfp.fp_status_a32); | ||
135 | + set_flush_to_zero(ftz_enabled, &env->vfp.fp_status_a64); | ||
136 | + set_flush_inputs_to_zero(ftz_enabled, &env->vfp.fp_status_a64); | ||
137 | } | ||
138 | if (changed & FPCR_DN) { | ||
139 | bool dnan_enabled = val & FPCR_DN; | ||
140 | set_default_nan_mode(dnan_enabled, &env->vfp.fp_status); | ||
141 | + set_default_nan_mode(dnan_enabled, &env->vfp.fp_status_a32); | ||
142 | + set_default_nan_mode(dnan_enabled, &env->vfp.fp_status_a64); | ||
143 | set_default_nan_mode(dnan_enabled, &env->vfp.fp_status_f16); | ||
144 | } | ||
145 | } | ||
146 | -- | ||
147 | 2.34.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Switch from vfp.fp_status to vfp.fp_status_a64 for helpers which: | ||
2 | * directly reference an fp_status field | ||
3 | * are called only from the A64 decoder | ||
4 | * are not called inside a set_rmode/restore_rmode sequence | ||
1 | 5 | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Message-id: 20250124162836.2332150-8-peter.maydell@linaro.org | ||
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | --- | ||
10 | target/arm/tcg/sme_helper.c | 2 +- | ||
11 | target/arm/tcg/vec_helper.c | 8 ++++---- | ||
12 | 2 files changed, 5 insertions(+), 5 deletions(-) | ||
13 | |||
14 | diff --git a/target/arm/tcg/sme_helper.c b/target/arm/tcg/sme_helper.c | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/target/arm/tcg/sme_helper.c | ||
17 | +++ b/target/arm/tcg/sme_helper.c | ||
18 | @@ -XXX,XX +XXX,XX @@ void HELPER(sme_fmopa_h)(void *vza, void *vzn, void *vzm, void *vpn, | ||
19 | * round-to-odd -- see above. | ||
20 | */ | ||
21 | fpst_f16 = env->vfp.fp_status_f16; | ||
22 | - fpst_std = env->vfp.fp_status; | ||
23 | + fpst_std = env->vfp.fp_status_a64; | ||
24 | set_default_nan_mode(true, &fpst_std); | ||
25 | set_default_nan_mode(true, &fpst_f16); | ||
26 | fpst_odd = fpst_std; | ||
27 | diff --git a/target/arm/tcg/vec_helper.c b/target/arm/tcg/vec_helper.c | ||
28 | index XXXXXXX..XXXXXXX 100644 | ||
29 | --- a/target/arm/tcg/vec_helper.c | ||
30 | +++ b/target/arm/tcg/vec_helper.c | ||
31 | @@ -XXX,XX +XXX,XX @@ void HELPER(gvec_fmlal_a32)(void *vd, void *vn, void *vm, | ||
32 | void HELPER(gvec_fmlal_a64)(void *vd, void *vn, void *vm, | ||
33 | CPUARMState *env, uint32_t desc) | ||
34 | { | ||
35 | - do_fmlal(vd, vn, vm, &env->vfp.fp_status, desc, | ||
36 | + do_fmlal(vd, vn, vm, &env->vfp.fp_status_a64, desc, | ||
37 | get_flush_inputs_to_zero(&env->vfp.fp_status_f16)); | ||
38 | } | ||
39 | |||
40 | @@ -XXX,XX +XXX,XX @@ void HELPER(sve2_fmlal_zzzw_s)(void *vd, void *vn, void *vm, void *va, | ||
41 | intptr_t i, oprsz = simd_oprsz(desc); | ||
42 | uint16_t negn = extract32(desc, SIMD_DATA_SHIFT, 1) << 15; | ||
43 | intptr_t sel = extract32(desc, SIMD_DATA_SHIFT + 1, 1) * sizeof(float16); | ||
44 | - float_status *status = &env->vfp.fp_status; | ||
45 | + float_status *status = &env->vfp.fp_status_a64; | ||
46 | bool fz16 = get_flush_inputs_to_zero(&env->vfp.fp_status_f16); | ||
47 | |||
48 | for (i = 0; i < oprsz; i += sizeof(float32)) { | ||
49 | @@ -XXX,XX +XXX,XX @@ void HELPER(gvec_fmlal_idx_a32)(void *vd, void *vn, void *vm, | ||
50 | void HELPER(gvec_fmlal_idx_a64)(void *vd, void *vn, void *vm, | ||
51 | CPUARMState *env, uint32_t desc) | ||
52 | { | ||
53 | - do_fmlal_idx(vd, vn, vm, &env->vfp.fp_status, desc, | ||
54 | + do_fmlal_idx(vd, vn, vm, &env->vfp.fp_status_a64, desc, | ||
55 | get_flush_inputs_to_zero(&env->vfp.fp_status_f16)); | ||
56 | } | ||
57 | |||
58 | @@ -XXX,XX +XXX,XX @@ void HELPER(sve2_fmlal_zzxw_s)(void *vd, void *vn, void *vm, void *va, | ||
59 | uint16_t negn = extract32(desc, SIMD_DATA_SHIFT, 1) << 15; | ||
60 | intptr_t sel = extract32(desc, SIMD_DATA_SHIFT + 1, 1) * sizeof(float16); | ||
61 | intptr_t idx = extract32(desc, SIMD_DATA_SHIFT + 2, 3) * sizeof(float16); | ||
62 | - float_status *status = &env->vfp.fp_status; | ||
63 | + float_status *status = &env->vfp.fp_status_a64; | ||
64 | bool fz16 = get_flush_inputs_to_zero(&env->vfp.fp_status_f16); | ||
65 | |||
66 | for (i = 0; i < oprsz; i += 16) { | ||
67 | -- | ||
68 | 2.34.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | In is_ebf(), we might be called for A64 or A32, but we have | ||
2 | the CPUARMState* so we can select fp_status_a64 or | ||
3 | fp_status_a32 accordingly. | ||
1 | 4 | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | --- | ||
8 | target/arm/tcg/vec_helper.c | 2 +- | ||
9 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
10 | |||
11 | diff --git a/target/arm/tcg/vec_helper.c b/target/arm/tcg/vec_helper.c | ||
12 | index XXXXXXX..XXXXXXX 100644 | ||
13 | --- a/target/arm/tcg/vec_helper.c | ||
14 | +++ b/target/arm/tcg/vec_helper.c | ||
15 | @@ -XXX,XX +XXX,XX @@ bool is_ebf(CPUARMState *env, float_status *statusp, float_status *oddstatusp) | ||
16 | */ | ||
17 | bool ebf = is_a64(env) && env->vfp.fpcr & FPCR_EBF; | ||
18 | |||
19 | - *statusp = env->vfp.fp_status; | ||
20 | + *statusp = is_a64(env) ? env->vfp.fp_status_a64 : env->vfp.fp_status_a32; | ||
21 | set_default_nan_mode(true, statusp); | ||
22 | |||
23 | if (ebf) { | ||
24 | -- | ||
25 | 2.34.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Use fp_status_a32 in the vjcvt helper function; this is called only | ||
2 | from the A32/T32 decoder and is not used inside a | ||
3 | set_rmode/restore_rmode sequence. | ||
1 | 4 | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20250124162836.2332150-9-peter.maydell@linaro.org | ||
8 | --- | ||
9 | target/arm/vfp_helper.c | 2 +- | ||
10 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
11 | |||
12 | diff --git a/target/arm/vfp_helper.c b/target/arm/vfp_helper.c | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/target/arm/vfp_helper.c | ||
15 | +++ b/target/arm/vfp_helper.c | ||
16 | @@ -XXX,XX +XXX,XX @@ uint64_t HELPER(fjcvtzs)(float64 value, float_status *status) | ||
17 | |||
18 | uint32_t HELPER(vjcvt)(float64 value, CPUARMState *env) | ||
19 | { | ||
20 | - uint64_t pair = HELPER(fjcvtzs)(value, &env->vfp.fp_status); | ||
21 | + uint64_t pair = HELPER(fjcvtzs)(value, &env->vfp.fp_status_a32); | ||
22 | uint32_t result = pair; | ||
23 | uint32_t z = (pair >> 32) == 0; | ||
24 | |||
25 | -- | ||
26 | 2.34.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | The helpers vfp_cmps, vfp_cmpes, vfp_cmpd, vfp_cmped are used only from | ||
2 | the A32 decoder; the A64 decoder uses separate vfp_cmps_a64 etc helpers | ||
3 | (because for A64 we update the main NZCV flags and for A32 we update | ||
4 | the FPSCR NZCV flags). So we can make these helpers use the fp_status_a32 | ||
5 | field instead of fp_status. | ||
1 | 6 | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20250124162836.2332150-10-peter.maydell@linaro.org | ||
10 | --- | ||
11 | target/arm/vfp_helper.c | 4 ++-- | ||
12 | 1 file changed, 2 insertions(+), 2 deletions(-) | ||
13 | |||
14 | diff --git a/target/arm/vfp_helper.c b/target/arm/vfp_helper.c | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/target/arm/vfp_helper.c | ||
17 | +++ b/target/arm/vfp_helper.c | ||
18 | @@ -XXX,XX +XXX,XX @@ void VFP_HELPER(cmpe, P)(ARGTYPE a, ARGTYPE b, CPUARMState *env) \ | ||
19 | FLOATTYPE ## _compare(a, b, &env->vfp.FPST)); \ | ||
20 | } | ||
21 | DO_VFP_cmp(h, float16, dh_ctype_f16, fp_status_f16) | ||
22 | -DO_VFP_cmp(s, float32, float32, fp_status) | ||
23 | -DO_VFP_cmp(d, float64, float64, fp_status) | ||
24 | +DO_VFP_cmp(s, float32, float32, fp_status_a32) | ||
25 | +DO_VFP_cmp(d, float64, float64, fp_status_a32) | ||
26 | #undef DO_VFP_cmp | ||
27 | |||
28 | /* Integer to float and float to integer conversions */ | ||
29 | -- | ||
30 | 2.34.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | In the A32 decoder, use FPST_A32 rather than FPST_FPCR. By | ||
2 | doing an automated conversion of the whole file we avoid possibly | ||
3 | using more than one fpst value in a set_rmode/op/restore_rmode | ||
4 | sequence. | ||
1 | 5 | ||
6 | Patch created with | ||
7 | perl -p -i -e 's/FPST_FPCR(?!_)/FPST_A32/g' target/arm/tcg/translate-vfp.c | ||
8 | |||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
11 | Message-id: 20250124162836.2332150-11-peter.maydell@linaro.org | ||
12 | --- | ||
13 | target/arm/tcg/translate-vfp.c | 54 +++++++++++++++++----------------- | ||
14 | 1 file changed, 27 insertions(+), 27 deletions(-) | ||
15 | |||
16 | diff --git a/target/arm/tcg/translate-vfp.c b/target/arm/tcg/translate-vfp.c | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/target/arm/tcg/translate-vfp.c | ||
19 | +++ b/target/arm/tcg/translate-vfp.c | ||
20 | @@ -XXX,XX +XXX,XX @@ static bool trans_VRINT(DisasContext *s, arg_VRINT *a) | ||
21 | if (sz == 1) { | ||
22 | fpst = fpstatus_ptr(FPST_FPCR_F16); | ||
23 | } else { | ||
24 | - fpst = fpstatus_ptr(FPST_FPCR); | ||
25 | + fpst = fpstatus_ptr(FPST_A32); | ||
26 | } | ||
27 | |||
28 | tcg_rmode = gen_set_rmode(rounding, fpst); | ||
29 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT(DisasContext *s, arg_VCVT *a) | ||
30 | if (sz == 1) { | ||
31 | fpst = fpstatus_ptr(FPST_FPCR_F16); | ||
32 | } else { | ||
33 | - fpst = fpstatus_ptr(FPST_FPCR); | ||
34 | + fpst = fpstatus_ptr(FPST_A32); | ||
35 | } | ||
36 | |||
37 | tcg_shift = tcg_constant_i32(0); | ||
38 | @@ -XXX,XX +XXX,XX @@ static bool do_vfp_3op_sp(DisasContext *s, VFPGen3OpSPFn *fn, | ||
39 | f0 = tcg_temp_new_i32(); | ||
40 | f1 = tcg_temp_new_i32(); | ||
41 | fd = tcg_temp_new_i32(); | ||
42 | - fpst = fpstatus_ptr(FPST_FPCR); | ||
43 | + fpst = fpstatus_ptr(FPST_A32); | ||
44 | |||
45 | vfp_load_reg32(f0, vn); | ||
46 | vfp_load_reg32(f1, vm); | ||
47 | @@ -XXX,XX +XXX,XX @@ static bool do_vfp_3op_dp(DisasContext *s, VFPGen3OpDPFn *fn, | ||
48 | f0 = tcg_temp_new_i64(); | ||
49 | f1 = tcg_temp_new_i64(); | ||
50 | fd = tcg_temp_new_i64(); | ||
51 | - fpst = fpstatus_ptr(FPST_FPCR); | ||
52 | + fpst = fpstatus_ptr(FPST_A32); | ||
53 | |||
54 | vfp_load_reg64(f0, vn); | ||
55 | vfp_load_reg64(f1, vm); | ||
56 | @@ -XXX,XX +XXX,XX @@ static bool do_vfm_sp(DisasContext *s, arg_VFMA_sp *a, bool neg_n, bool neg_d) | ||
57 | /* VFNMA, VFNMS */ | ||
58 | gen_vfp_negs(vd, vd); | ||
59 | } | ||
60 | - fpst = fpstatus_ptr(FPST_FPCR); | ||
61 | + fpst = fpstatus_ptr(FPST_A32); | ||
62 | gen_helper_vfp_muladds(vd, vn, vm, vd, fpst); | ||
63 | vfp_store_reg32(vd, a->vd); | ||
64 | return true; | ||
65 | @@ -XXX,XX +XXX,XX @@ static bool do_vfm_dp(DisasContext *s, arg_VFMA_dp *a, bool neg_n, bool neg_d) | ||
66 | /* VFNMA, VFNMS */ | ||
67 | gen_vfp_negd(vd, vd); | ||
68 | } | ||
69 | - fpst = fpstatus_ptr(FPST_FPCR); | ||
70 | + fpst = fpstatus_ptr(FPST_A32); | ||
71 | gen_helper_vfp_muladdd(vd, vn, vm, vd, fpst); | ||
72 | vfp_store_reg64(vd, a->vd); | ||
73 | return true; | ||
74 | @@ -XXX,XX +XXX,XX @@ static void gen_VSQRT_hp(TCGv_i32 vd, TCGv_i32 vm) | ||
75 | |||
76 | static void gen_VSQRT_sp(TCGv_i32 vd, TCGv_i32 vm) | ||
77 | { | ||
78 | - gen_helper_vfp_sqrts(vd, vm, fpstatus_ptr(FPST_FPCR)); | ||
79 | + gen_helper_vfp_sqrts(vd, vm, fpstatus_ptr(FPST_A32)); | ||
80 | } | ||
81 | |||
82 | static void gen_VSQRT_dp(TCGv_i64 vd, TCGv_i64 vm) | ||
83 | { | ||
84 | - gen_helper_vfp_sqrtd(vd, vm, fpstatus_ptr(FPST_FPCR)); | ||
85 | + gen_helper_vfp_sqrtd(vd, vm, fpstatus_ptr(FPST_A32)); | ||
86 | } | ||
87 | |||
88 | DO_VFP_2OP(VSQRT, hp, gen_VSQRT_hp, aa32_fp16_arith) | ||
89 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_f32_f16(DisasContext *s, arg_VCVT_f32_f16 *a) | ||
90 | return true; | ||
91 | } | ||
92 | |||
93 | - fpst = fpstatus_ptr(FPST_FPCR); | ||
94 | + fpst = fpstatus_ptr(FPST_A32); | ||
95 | ahp_mode = get_ahp_flag(); | ||
96 | tmp = tcg_temp_new_i32(); | ||
97 | /* The T bit tells us if we want the low or high 16 bits of Vm */ | ||
98 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_f64_f16(DisasContext *s, arg_VCVT_f64_f16 *a) | ||
99 | return true; | ||
100 | } | ||
101 | |||
102 | - fpst = fpstatus_ptr(FPST_FPCR); | ||
103 | + fpst = fpstatus_ptr(FPST_A32); | ||
104 | ahp_mode = get_ahp_flag(); | ||
105 | tmp = tcg_temp_new_i32(); | ||
106 | /* The T bit tells us if we want the low or high 16 bits of Vm */ | ||
107 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_b16_f32(DisasContext *s, arg_VCVT_b16_f32 *a) | ||
108 | return true; | ||
109 | } | ||
110 | |||
111 | - fpst = fpstatus_ptr(FPST_FPCR); | ||
112 | + fpst = fpstatus_ptr(FPST_A32); | ||
113 | tmp = tcg_temp_new_i32(); | ||
114 | |||
115 | vfp_load_reg32(tmp, a->vm); | ||
116 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_f16_f32(DisasContext *s, arg_VCVT_f16_f32 *a) | ||
117 | return true; | ||
118 | } | ||
119 | |||
120 | - fpst = fpstatus_ptr(FPST_FPCR); | ||
121 | + fpst = fpstatus_ptr(FPST_A32); | ||
122 | ahp_mode = get_ahp_flag(); | ||
123 | tmp = tcg_temp_new_i32(); | ||
124 | |||
125 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_f16_f64(DisasContext *s, arg_VCVT_f16_f64 *a) | ||
126 | return true; | ||
127 | } | ||
128 | |||
129 | - fpst = fpstatus_ptr(FPST_FPCR); | ||
130 | + fpst = fpstatus_ptr(FPST_A32); | ||
131 | ahp_mode = get_ahp_flag(); | ||
132 | tmp = tcg_temp_new_i32(); | ||
133 | vm = tcg_temp_new_i64(); | ||
134 | @@ -XXX,XX +XXX,XX @@ static bool trans_VRINTR_sp(DisasContext *s, arg_VRINTR_sp *a) | ||
135 | |||
136 | tmp = tcg_temp_new_i32(); | ||
137 | vfp_load_reg32(tmp, a->vm); | ||
138 | - fpst = fpstatus_ptr(FPST_FPCR); | ||
139 | + fpst = fpstatus_ptr(FPST_A32); | ||
140 | gen_helper_rints(tmp, tmp, fpst); | ||
141 | vfp_store_reg32(tmp, a->vd); | ||
142 | return true; | ||
143 | @@ -XXX,XX +XXX,XX @@ static bool trans_VRINTR_dp(DisasContext *s, arg_VRINTR_dp *a) | ||
144 | |||
145 | tmp = tcg_temp_new_i64(); | ||
146 | vfp_load_reg64(tmp, a->vm); | ||
147 | - fpst = fpstatus_ptr(FPST_FPCR); | ||
148 | + fpst = fpstatus_ptr(FPST_A32); | ||
149 | gen_helper_rintd(tmp, tmp, fpst); | ||
150 | vfp_store_reg64(tmp, a->vd); | ||
151 | return true; | ||
152 | @@ -XXX,XX +XXX,XX @@ static bool trans_VRINTZ_sp(DisasContext *s, arg_VRINTZ_sp *a) | ||
153 | |||
154 | tmp = tcg_temp_new_i32(); | ||
155 | vfp_load_reg32(tmp, a->vm); | ||
156 | - fpst = fpstatus_ptr(FPST_FPCR); | ||
157 | + fpst = fpstatus_ptr(FPST_A32); | ||
158 | tcg_rmode = gen_set_rmode(FPROUNDING_ZERO, fpst); | ||
159 | gen_helper_rints(tmp, tmp, fpst); | ||
160 | gen_restore_rmode(tcg_rmode, fpst); | ||
161 | @@ -XXX,XX +XXX,XX @@ static bool trans_VRINTZ_dp(DisasContext *s, arg_VRINTZ_dp *a) | ||
162 | |||
163 | tmp = tcg_temp_new_i64(); | ||
164 | vfp_load_reg64(tmp, a->vm); | ||
165 | - fpst = fpstatus_ptr(FPST_FPCR); | ||
166 | + fpst = fpstatus_ptr(FPST_A32); | ||
167 | tcg_rmode = gen_set_rmode(FPROUNDING_ZERO, fpst); | ||
168 | gen_helper_rintd(tmp, tmp, fpst); | ||
169 | gen_restore_rmode(tcg_rmode, fpst); | ||
170 | @@ -XXX,XX +XXX,XX @@ static bool trans_VRINTX_sp(DisasContext *s, arg_VRINTX_sp *a) | ||
171 | |||
172 | tmp = tcg_temp_new_i32(); | ||
173 | vfp_load_reg32(tmp, a->vm); | ||
174 | - fpst = fpstatus_ptr(FPST_FPCR); | ||
175 | + fpst = fpstatus_ptr(FPST_A32); | ||
176 | gen_helper_rints_exact(tmp, tmp, fpst); | ||
177 | vfp_store_reg32(tmp, a->vd); | ||
178 | return true; | ||
179 | @@ -XXX,XX +XXX,XX @@ static bool trans_VRINTX_dp(DisasContext *s, arg_VRINTX_dp *a) | ||
180 | |||
181 | tmp = tcg_temp_new_i64(); | ||
182 | vfp_load_reg64(tmp, a->vm); | ||
183 | - fpst = fpstatus_ptr(FPST_FPCR); | ||
184 | + fpst = fpstatus_ptr(FPST_A32); | ||
185 | gen_helper_rintd_exact(tmp, tmp, fpst); | ||
186 | vfp_store_reg64(tmp, a->vd); | ||
187 | return true; | ||
188 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_sp(DisasContext *s, arg_VCVT_sp *a) | ||
189 | vm = tcg_temp_new_i32(); | ||
190 | vd = tcg_temp_new_i64(); | ||
191 | vfp_load_reg32(vm, a->vm); | ||
192 | - gen_helper_vfp_fcvtds(vd, vm, fpstatus_ptr(FPST_FPCR)); | ||
193 | + gen_helper_vfp_fcvtds(vd, vm, fpstatus_ptr(FPST_A32)); | ||
194 | vfp_store_reg64(vd, a->vd); | ||
195 | return true; | ||
196 | } | ||
197 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_dp(DisasContext *s, arg_VCVT_dp *a) | ||
198 | vd = tcg_temp_new_i32(); | ||
199 | vm = tcg_temp_new_i64(); | ||
200 | vfp_load_reg64(vm, a->vm); | ||
201 | - gen_helper_vfp_fcvtsd(vd, vm, fpstatus_ptr(FPST_FPCR)); | ||
202 | + gen_helper_vfp_fcvtsd(vd, vm, fpstatus_ptr(FPST_A32)); | ||
203 | vfp_store_reg32(vd, a->vd); | ||
204 | return true; | ||
205 | } | ||
206 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_int_sp(DisasContext *s, arg_VCVT_int_sp *a) | ||
207 | |||
208 | vm = tcg_temp_new_i32(); | ||
209 | vfp_load_reg32(vm, a->vm); | ||
210 | - fpst = fpstatus_ptr(FPST_FPCR); | ||
211 | + fpst = fpstatus_ptr(FPST_A32); | ||
212 | if (a->s) { | ||
213 | /* i32 -> f32 */ | ||
214 | gen_helper_vfp_sitos(vm, vm, fpst); | ||
215 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_int_dp(DisasContext *s, arg_VCVT_int_dp *a) | ||
216 | vm = tcg_temp_new_i32(); | ||
217 | vd = tcg_temp_new_i64(); | ||
218 | vfp_load_reg32(vm, a->vm); | ||
219 | - fpst = fpstatus_ptr(FPST_FPCR); | ||
220 | + fpst = fpstatus_ptr(FPST_A32); | ||
221 | if (a->s) { | ||
222 | /* i32 -> f64 */ | ||
223 | gen_helper_vfp_sitod(vd, vm, fpst); | ||
224 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_fix_sp(DisasContext *s, arg_VCVT_fix_sp *a) | ||
225 | vd = tcg_temp_new_i32(); | ||
226 | vfp_load_reg32(vd, a->vd); | ||
227 | |||
228 | - fpst = fpstatus_ptr(FPST_FPCR); | ||
229 | + fpst = fpstatus_ptr(FPST_A32); | ||
230 | shift = tcg_constant_i32(frac_bits); | ||
231 | |||
232 | /* Switch on op:U:sx bits */ | ||
233 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_fix_dp(DisasContext *s, arg_VCVT_fix_dp *a) | ||
234 | vd = tcg_temp_new_i64(); | ||
235 | vfp_load_reg64(vd, a->vd); | ||
236 | |||
237 | - fpst = fpstatus_ptr(FPST_FPCR); | ||
238 | + fpst = fpstatus_ptr(FPST_A32); | ||
239 | shift = tcg_constant_i32(frac_bits); | ||
240 | |||
241 | /* Switch on op:U:sx bits */ | ||
242 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_sp_int(DisasContext *s, arg_VCVT_sp_int *a) | ||
243 | return true; | ||
244 | } | ||
245 | |||
246 | - fpst = fpstatus_ptr(FPST_FPCR); | ||
247 | + fpst = fpstatus_ptr(FPST_A32); | ||
248 | vm = tcg_temp_new_i32(); | ||
249 | vfp_load_reg32(vm, a->vm); | ||
250 | |||
251 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_dp_int(DisasContext *s, arg_VCVT_dp_int *a) | ||
252 | return true; | ||
253 | } | ||
254 | |||
255 | - fpst = fpstatus_ptr(FPST_FPCR); | ||
256 | + fpst = fpstatus_ptr(FPST_A32); | ||
257 | vm = tcg_temp_new_i64(); | ||
258 | vd = tcg_temp_new_i32(); | ||
259 | vfp_load_reg64(vm, a->vm); | ||
260 | -- | ||
261 | 2.34.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | In the A64 decoder, use FPST_A64 rather than FPST_FPCR. By | ||
2 | doing an automated conversion of the whole file we avoid possibly | ||
3 | using more than one fpst value in a set_rmode/op/restore_rmode | ||
4 | sequence. | ||
1 | 5 | ||
6 | Patch created with | ||
7 | |||
8 | perl -p -i -e 's/FPST_FPCR(?!_)/FPST_A64/g' target/arm/tcg/translate-{a64,sve,sme}.c | ||
9 | |||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
12 | Message-id: 20250124162836.2332150-12-peter.maydell@linaro.org | ||
13 | --- | ||
14 | target/arm/tcg/translate-a64.c | 70 +++++++++++----------- | ||
15 | target/arm/tcg/translate-sme.c | 4 +- | ||
16 | target/arm/tcg/translate-sve.c | 106 ++++++++++++++++----------------- | ||
17 | 3 files changed, 90 insertions(+), 90 deletions(-) | ||
18 | |||
19 | diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c | ||
20 | index XXXXXXX..XXXXXXX 100644 | ||
21 | --- a/target/arm/tcg/translate-a64.c | ||
22 | +++ b/target/arm/tcg/translate-a64.c | ||
23 | @@ -XXX,XX +XXX,XX @@ static void gen_gvec_op3_fpst(DisasContext *s, bool is_q, int rd, int rn, | ||
24 | int rm, bool is_fp16, int data, | ||
25 | gen_helper_gvec_3_ptr *fn) | ||
26 | { | ||
27 | - TCGv_ptr fpst = fpstatus_ptr(is_fp16 ? FPST_FPCR_F16 : FPST_FPCR); | ||
28 | + TCGv_ptr fpst = fpstatus_ptr(is_fp16 ? FPST_FPCR_F16 : FPST_A64); | ||
29 | tcg_gen_gvec_3_ptr(vec_full_reg_offset(s, rd), | ||
30 | vec_full_reg_offset(s, rn), | ||
31 | vec_full_reg_offset(s, rm), fpst, | ||
32 | @@ -XXX,XX +XXX,XX @@ static void gen_gvec_op4_fpst(DisasContext *s, bool is_q, int rd, int rn, | ||
33 | int rm, int ra, bool is_fp16, int data, | ||
34 | gen_helper_gvec_4_ptr *fn) | ||
35 | { | ||
36 | - TCGv_ptr fpst = fpstatus_ptr(is_fp16 ? FPST_FPCR_F16 : FPST_FPCR); | ||
37 | + TCGv_ptr fpst = fpstatus_ptr(is_fp16 ? FPST_FPCR_F16 : FPST_A64); | ||
38 | tcg_gen_gvec_4_ptr(vec_full_reg_offset(s, rd), | ||
39 | vec_full_reg_offset(s, rn), | ||
40 | vec_full_reg_offset(s, rm), | ||
41 | @@ -XXX,XX +XXX,XX @@ static bool do_fp3_scalar(DisasContext *s, arg_rrr_e *a, const FPScalar *f) | ||
42 | if (fp_access_check(s)) { | ||
43 | TCGv_i64 t0 = read_fp_dreg(s, a->rn); | ||
44 | TCGv_i64 t1 = read_fp_dreg(s, a->rm); | ||
45 | - f->gen_d(t0, t0, t1, fpstatus_ptr(FPST_FPCR)); | ||
46 | + f->gen_d(t0, t0, t1, fpstatus_ptr(FPST_A64)); | ||
47 | write_fp_dreg(s, a->rd, t0); | ||
48 | } | ||
49 | break; | ||
50 | @@ -XXX,XX +XXX,XX @@ static bool do_fp3_scalar(DisasContext *s, arg_rrr_e *a, const FPScalar *f) | ||
51 | if (fp_access_check(s)) { | ||
52 | TCGv_i32 t0 = read_fp_sreg(s, a->rn); | ||
53 | TCGv_i32 t1 = read_fp_sreg(s, a->rm); | ||
54 | - f->gen_s(t0, t0, t1, fpstatus_ptr(FPST_FPCR)); | ||
55 | + f->gen_s(t0, t0, t1, fpstatus_ptr(FPST_A64)); | ||
56 | write_fp_sreg(s, a->rd, t0); | ||
57 | } | ||
58 | break; | ||
59 | @@ -XXX,XX +XXX,XX @@ static bool do_fcmp0_s(DisasContext *s, arg_rr_e *a, | ||
60 | TCGv_i64 t0 = read_fp_dreg(s, a->rn); | ||
61 | TCGv_i64 t1 = tcg_constant_i64(0); | ||
62 | if (swap) { | ||
63 | - f->gen_d(t0, t1, t0, fpstatus_ptr(FPST_FPCR)); | ||
64 | + f->gen_d(t0, t1, t0, fpstatus_ptr(FPST_A64)); | ||
65 | } else { | ||
66 | - f->gen_d(t0, t0, t1, fpstatus_ptr(FPST_FPCR)); | ||
67 | + f->gen_d(t0, t0, t1, fpstatus_ptr(FPST_A64)); | ||
68 | } | ||
69 | write_fp_dreg(s, a->rd, t0); | ||
70 | } | ||
71 | @@ -XXX,XX +XXX,XX @@ static bool do_fcmp0_s(DisasContext *s, arg_rr_e *a, | ||
72 | TCGv_i32 t0 = read_fp_sreg(s, a->rn); | ||
73 | TCGv_i32 t1 = tcg_constant_i32(0); | ||
74 | if (swap) { | ||
75 | - f->gen_s(t0, t1, t0, fpstatus_ptr(FPST_FPCR)); | ||
76 | + f->gen_s(t0, t1, t0, fpstatus_ptr(FPST_A64)); | ||
77 | } else { | ||
78 | - f->gen_s(t0, t0, t1, fpstatus_ptr(FPST_FPCR)); | ||
79 | + f->gen_s(t0, t0, t1, fpstatus_ptr(FPST_A64)); | ||
80 | } | ||
81 | write_fp_sreg(s, a->rd, t0); | ||
82 | } | ||
83 | @@ -XXX,XX +XXX,XX @@ static bool do_fp3_scalar_idx(DisasContext *s, arg_rrx_e *a, const FPScalar *f) | ||
84 | TCGv_i64 t1 = tcg_temp_new_i64(); | ||
85 | |||
86 | read_vec_element(s, t1, a->rm, a->idx, MO_64); | ||
87 | - f->gen_d(t0, t0, t1, fpstatus_ptr(FPST_FPCR)); | ||
88 | + f->gen_d(t0, t0, t1, fpstatus_ptr(FPST_A64)); | ||
89 | write_fp_dreg(s, a->rd, t0); | ||
90 | } | ||
91 | break; | ||
92 | @@ -XXX,XX +XXX,XX @@ static bool do_fp3_scalar_idx(DisasContext *s, arg_rrx_e *a, const FPScalar *f) | ||
93 | TCGv_i32 t1 = tcg_temp_new_i32(); | ||
94 | |||
95 | read_vec_element_i32(s, t1, a->rm, a->idx, MO_32); | ||
96 | - f->gen_s(t0, t0, t1, fpstatus_ptr(FPST_FPCR)); | ||
97 | + f->gen_s(t0, t0, t1, fpstatus_ptr(FPST_A64)); | ||
98 | write_fp_sreg(s, a->rd, t0); | ||
99 | } | ||
100 | break; | ||
101 | @@ -XXX,XX +XXX,XX @@ static bool do_fmla_scalar_idx(DisasContext *s, arg_rrx_e *a, bool neg) | ||
102 | if (neg) { | ||
103 | gen_vfp_negd(t1, t1); | ||
104 | } | ||
105 | - gen_helper_vfp_muladdd(t0, t1, t2, t0, fpstatus_ptr(FPST_FPCR)); | ||
106 | + gen_helper_vfp_muladdd(t0, t1, t2, t0, fpstatus_ptr(FPST_A64)); | ||
107 | write_fp_dreg(s, a->rd, t0); | ||
108 | } | ||
109 | break; | ||
110 | @@ -XXX,XX +XXX,XX @@ static bool do_fmla_scalar_idx(DisasContext *s, arg_rrx_e *a, bool neg) | ||
111 | if (neg) { | ||
112 | gen_vfp_negs(t1, t1); | ||
113 | } | ||
114 | - gen_helper_vfp_muladds(t0, t1, t2, t0, fpstatus_ptr(FPST_FPCR)); | ||
115 | + gen_helper_vfp_muladds(t0, t1, t2, t0, fpstatus_ptr(FPST_A64)); | ||
116 | write_fp_sreg(s, a->rd, t0); | ||
117 | } | ||
118 | break; | ||
119 | @@ -XXX,XX +XXX,XX @@ static bool do_fp3_scalar_pair(DisasContext *s, arg_rr_e *a, const FPScalar *f) | ||
120 | |||
121 | read_vec_element(s, t0, a->rn, 0, MO_64); | ||
122 | read_vec_element(s, t1, a->rn, 1, MO_64); | ||
123 | - f->gen_d(t0, t0, t1, fpstatus_ptr(FPST_FPCR)); | ||
124 | + f->gen_d(t0, t0, t1, fpstatus_ptr(FPST_A64)); | ||
125 | write_fp_dreg(s, a->rd, t0); | ||
126 | } | ||
127 | break; | ||
128 | @@ -XXX,XX +XXX,XX @@ static bool do_fp3_scalar_pair(DisasContext *s, arg_rr_e *a, const FPScalar *f) | ||
129 | |||
130 | read_vec_element_i32(s, t0, a->rn, 0, MO_32); | ||
131 | read_vec_element_i32(s, t1, a->rn, 1, MO_32); | ||
132 | - f->gen_s(t0, t0, t1, fpstatus_ptr(FPST_FPCR)); | ||
133 | + f->gen_s(t0, t0, t1, fpstatus_ptr(FPST_A64)); | ||
134 | write_fp_sreg(s, a->rd, t0); | ||
135 | } | ||
136 | break; | ||
137 | @@ -XXX,XX +XXX,XX @@ static bool do_fmadd(DisasContext *s, arg_rrrr_e *a, bool neg_a, bool neg_n) | ||
138 | if (neg_n) { | ||
139 | gen_vfp_negd(tn, tn); | ||
140 | } | ||
141 | - fpst = fpstatus_ptr(FPST_FPCR); | ||
142 | + fpst = fpstatus_ptr(FPST_A64); | ||
143 | gen_helper_vfp_muladdd(ta, tn, tm, ta, fpst); | ||
144 | write_fp_dreg(s, a->rd, ta); | ||
145 | } | ||
146 | @@ -XXX,XX +XXX,XX @@ static bool do_fmadd(DisasContext *s, arg_rrrr_e *a, bool neg_a, bool neg_n) | ||
147 | if (neg_n) { | ||
148 | gen_vfp_negs(tn, tn); | ||
149 | } | ||
150 | - fpst = fpstatus_ptr(FPST_FPCR); | ||
151 | + fpst = fpstatus_ptr(FPST_A64); | ||
152 | gen_helper_vfp_muladds(ta, tn, tm, ta, fpst); | ||
153 | write_fp_sreg(s, a->rd, ta); | ||
154 | } | ||
155 | @@ -XXX,XX +XXX,XX @@ static bool do_fp_reduction(DisasContext *s, arg_qrr_e *a, | ||
156 | if (fp_access_check(s)) { | ||
157 | MemOp esz = a->esz; | ||
158 | int elts = (a->q ? 16 : 8) >> esz; | ||
159 | - TCGv_ptr fpst = fpstatus_ptr(esz == MO_16 ? FPST_FPCR_F16 : FPST_FPCR); | ||
160 | + TCGv_ptr fpst = fpstatus_ptr(esz == MO_16 ? FPST_FPCR_F16 : FPST_A64); | ||
161 | TCGv_i32 res = do_reduction_op(s, a->rn, esz, 0, elts, fpst, fn); | ||
162 | write_fp_sreg(s, a->rd, res); | ||
163 | } | ||
164 | @@ -XXX,XX +XXX,XX @@ static void handle_fp_compare(DisasContext *s, int size, | ||
165 | bool cmp_with_zero, bool signal_all_nans) | ||
166 | { | ||
167 | TCGv_i64 tcg_flags = tcg_temp_new_i64(); | ||
168 | - TCGv_ptr fpst = fpstatus_ptr(size == MO_16 ? FPST_FPCR_F16 : FPST_FPCR); | ||
169 | + TCGv_ptr fpst = fpstatus_ptr(size == MO_16 ? FPST_FPCR_F16 : FPST_A64); | ||
170 | |||
171 | if (size == MO_64) { | ||
172 | TCGv_i64 tcg_vn, tcg_vm; | ||
173 | @@ -XXX,XX +XXX,XX @@ static bool do_fp1_scalar(DisasContext *s, arg_rr_e *a, | ||
174 | return check == 0; | ||
175 | } | ||
176 | |||
177 | - fpst = fpstatus_ptr(a->esz == MO_16 ? FPST_FPCR_F16 : FPST_FPCR); | ||
178 | + fpst = fpstatus_ptr(a->esz == MO_16 ? FPST_FPCR_F16 : FPST_A64); | ||
179 | if (rmode >= 0) { | ||
180 | tcg_rmode = gen_set_rmode(rmode, fpst); | ||
181 | } | ||
182 | @@ -XXX,XX +XXX,XX @@ static bool trans_FCVT_s_ds(DisasContext *s, arg_rr *a) | ||
183 | if (fp_access_check(s)) { | ||
184 | TCGv_i32 tcg_rn = read_fp_sreg(s, a->rn); | ||
185 | TCGv_i64 tcg_rd = tcg_temp_new_i64(); | ||
186 | - TCGv_ptr fpst = fpstatus_ptr(FPST_FPCR); | ||
187 | + TCGv_ptr fpst = fpstatus_ptr(FPST_A64); | ||
188 | |||
189 | gen_helper_vfp_fcvtds(tcg_rd, tcg_rn, fpst); | ||
190 | write_fp_dreg(s, a->rd, tcg_rd); | ||
191 | @@ -XXX,XX +XXX,XX @@ static bool trans_FCVT_s_hs(DisasContext *s, arg_rr *a) | ||
192 | if (fp_access_check(s)) { | ||
193 | TCGv_i32 tmp = read_fp_sreg(s, a->rn); | ||
194 | TCGv_i32 ahp = get_ahp_flag(); | ||
195 | - TCGv_ptr fpst = fpstatus_ptr(FPST_FPCR); | ||
196 | + TCGv_ptr fpst = fpstatus_ptr(FPST_A64); | ||
197 | |||
198 | gen_helper_vfp_fcvt_f32_to_f16(tmp, tmp, fpst, ahp); | ||
199 | /* write_fp_sreg is OK here because top half of result is zero */ | ||
200 | @@ -XXX,XX +XXX,XX @@ static bool trans_FCVT_s_sd(DisasContext *s, arg_rr *a) | ||
201 | if (fp_access_check(s)) { | ||
202 | TCGv_i64 tcg_rn = read_fp_dreg(s, a->rn); | ||
203 | TCGv_i32 tcg_rd = tcg_temp_new_i32(); | ||
204 | - TCGv_ptr fpst = fpstatus_ptr(FPST_FPCR); | ||
205 | + TCGv_ptr fpst = fpstatus_ptr(FPST_A64); | ||
206 | |||
207 | gen_helper_vfp_fcvtsd(tcg_rd, tcg_rn, fpst); | ||
208 | write_fp_sreg(s, a->rd, tcg_rd); | ||
209 | @@ -XXX,XX +XXX,XX @@ static bool trans_FCVT_s_hd(DisasContext *s, arg_rr *a) | ||
210 | TCGv_i64 tcg_rn = read_fp_dreg(s, a->rn); | ||
211 | TCGv_i32 tcg_rd = tcg_temp_new_i32(); | ||
212 | TCGv_i32 ahp = get_ahp_flag(); | ||
213 | - TCGv_ptr fpst = fpstatus_ptr(FPST_FPCR); | ||
214 | + TCGv_ptr fpst = fpstatus_ptr(FPST_A64); | ||
215 | |||
216 | gen_helper_vfp_fcvt_f64_to_f16(tcg_rd, tcg_rn, fpst, ahp); | ||
217 | /* write_fp_sreg is OK here because top half of tcg_rd is zero */ | ||
218 | @@ -XXX,XX +XXX,XX @@ static bool trans_FCVT_s_sh(DisasContext *s, arg_rr *a) | ||
219 | if (fp_access_check(s)) { | ||
220 | TCGv_i32 tcg_rn = read_fp_hreg(s, a->rn); | ||
221 | TCGv_i32 tcg_rd = tcg_temp_new_i32(); | ||
222 | - TCGv_ptr tcg_fpst = fpstatus_ptr(FPST_FPCR); | ||
223 | + TCGv_ptr tcg_fpst = fpstatus_ptr(FPST_A64); | ||
224 | TCGv_i32 tcg_ahp = get_ahp_flag(); | ||
225 | |||
226 | gen_helper_vfp_fcvt_f16_to_f32(tcg_rd, tcg_rn, tcg_fpst, tcg_ahp); | ||
227 | @@ -XXX,XX +XXX,XX @@ static bool trans_FCVT_s_dh(DisasContext *s, arg_rr *a) | ||
228 | if (fp_access_check(s)) { | ||
229 | TCGv_i32 tcg_rn = read_fp_hreg(s, a->rn); | ||
230 | TCGv_i64 tcg_rd = tcg_temp_new_i64(); | ||
231 | - TCGv_ptr tcg_fpst = fpstatus_ptr(FPST_FPCR); | ||
232 | + TCGv_ptr tcg_fpst = fpstatus_ptr(FPST_A64); | ||
233 | TCGv_i32 tcg_ahp = get_ahp_flag(); | ||
234 | |||
235 | gen_helper_vfp_fcvt_f16_to_f64(tcg_rd, tcg_rn, tcg_fpst, tcg_ahp); | ||
236 | @@ -XXX,XX +XXX,XX @@ static bool do_cvtf_scalar(DisasContext *s, MemOp esz, int rd, int shift, | ||
237 | TCGv_i32 tcg_shift, tcg_single; | ||
238 | TCGv_i64 tcg_double; | ||
239 | |||
240 | - tcg_fpstatus = fpstatus_ptr(esz == MO_16 ? FPST_FPCR_F16 : FPST_FPCR); | ||
241 | + tcg_fpstatus = fpstatus_ptr(esz == MO_16 ? FPST_FPCR_F16 : FPST_A64); | ||
242 | tcg_shift = tcg_constant_i32(shift); | ||
243 | |||
244 | switch (esz) { | ||
245 | @@ -XXX,XX +XXX,XX @@ static void do_fcvt_scalar(DisasContext *s, MemOp out, MemOp esz, | ||
246 | TCGv_ptr tcg_fpstatus; | ||
247 | TCGv_i32 tcg_shift, tcg_rmode, tcg_single; | ||
248 | |||
249 | - tcg_fpstatus = fpstatus_ptr(esz == MO_16 ? FPST_FPCR_F16 : FPST_FPCR); | ||
250 | + tcg_fpstatus = fpstatus_ptr(esz == MO_16 ? FPST_FPCR_F16 : FPST_A64); | ||
251 | tcg_shift = tcg_constant_i32(shift); | ||
252 | tcg_rmode = gen_set_rmode(rmode, tcg_fpstatus); | ||
253 | |||
254 | @@ -XXX,XX +XXX,XX @@ static bool trans_FJCVTZS(DisasContext *s, arg_FJCVTZS *a) | ||
255 | } | ||
256 | if (fp_access_check(s)) { | ||
257 | TCGv_i64 t = read_fp_dreg(s, a->rn); | ||
258 | - TCGv_ptr fpstatus = fpstatus_ptr(FPST_FPCR); | ||
259 | + TCGv_ptr fpstatus = fpstatus_ptr(FPST_A64); | ||
260 | |||
261 | gen_helper_fjcvtzs(t, t, fpstatus); | ||
262 | |||
263 | @@ -XXX,XX +XXX,XX @@ static void gen_fcvtxn_sd(TCGv_i64 d, TCGv_i64 n) | ||
264 | * with von Neumann rounding (round to odd) | ||
265 | */ | ||
266 | TCGv_i32 tmp = tcg_temp_new_i32(); | ||
267 | - gen_helper_fcvtx_f64_to_f32(tmp, n, fpstatus_ptr(FPST_FPCR)); | ||
268 | + gen_helper_fcvtx_f64_to_f32(tmp, n, fpstatus_ptr(FPST_A64)); | ||
269 | tcg_gen_extu_i32_i64(d, tmp); | ||
270 | } | ||
271 | |||
272 | @@ -XXX,XX +XXX,XX @@ static void gen_fcvtn_hs(TCGv_i64 d, TCGv_i64 n) | ||
273 | { | ||
274 | TCGv_i32 tcg_lo = tcg_temp_new_i32(); | ||
275 | TCGv_i32 tcg_hi = tcg_temp_new_i32(); | ||
276 | - TCGv_ptr fpst = fpstatus_ptr(FPST_FPCR); | ||
277 | + TCGv_ptr fpst = fpstatus_ptr(FPST_A64); | ||
278 | TCGv_i32 ahp = get_ahp_flag(); | ||
279 | |||
280 | tcg_gen_extr_i64_i32(tcg_lo, tcg_hi, n); | ||
281 | @@ -XXX,XX +XXX,XX @@ static void gen_fcvtn_hs(TCGv_i64 d, TCGv_i64 n) | ||
282 | static void gen_fcvtn_sd(TCGv_i64 d, TCGv_i64 n) | ||
283 | { | ||
284 | TCGv_i32 tmp = tcg_temp_new_i32(); | ||
285 | - TCGv_ptr fpst = fpstatus_ptr(FPST_FPCR); | ||
286 | + TCGv_ptr fpst = fpstatus_ptr(FPST_A64); | ||
287 | |||
288 | gen_helper_vfp_fcvtsd(tmp, n, fpst); | ||
289 | tcg_gen_extu_i32_i64(d, tmp); | ||
290 | @@ -XXX,XX +XXX,XX @@ TRANS(FCVTXN_v, do_2misc_narrow_vector, a, f_scalar_fcvtxn) | ||
291 | |||
292 | static void gen_bfcvtn_hs(TCGv_i64 d, TCGv_i64 n) | ||
293 | { | ||
294 | - TCGv_ptr fpst = fpstatus_ptr(FPST_FPCR); | ||
295 | + TCGv_ptr fpst = fpstatus_ptr(FPST_A64); | ||
296 | TCGv_i32 tmp = tcg_temp_new_i32(); | ||
297 | gen_helper_bfcvt_pair(tmp, n, fpst); | ||
298 | tcg_gen_extu_i32_i64(d, tmp); | ||
299 | @@ -XXX,XX +XXX,XX @@ static bool do_fp1_vector(DisasContext *s, arg_qrr_e *a, | ||
300 | return check == 0; | ||
301 | } | ||
302 | |||
303 | - fpst = fpstatus_ptr(a->esz == MO_16 ? FPST_FPCR_F16 : FPST_FPCR); | ||
304 | + fpst = fpstatus_ptr(a->esz == MO_16 ? FPST_FPCR_F16 : FPST_A64); | ||
305 | if (rmode >= 0) { | ||
306 | tcg_rmode = gen_set_rmode(rmode, fpst); | ||
307 | } | ||
308 | @@ -XXX,XX +XXX,XX @@ static bool do_gvec_op2_fpst(DisasContext *s, MemOp esz, bool is_q, | ||
309 | return check == 0; | ||
310 | } | ||
311 | |||
312 | - fpst = fpstatus_ptr(esz == MO_16 ? FPST_FPCR_F16 : FPST_FPCR); | ||
313 | + fpst = fpstatus_ptr(esz == MO_16 ? FPST_FPCR_F16 : FPST_A64); | ||
314 | tcg_gen_gvec_2_ptr(vec_full_reg_offset(s, rd), | ||
315 | vec_full_reg_offset(s, rn), fpst, | ||
316 | is_q ? 16 : 8, vec_full_reg_size(s), | ||
317 | @@ -XXX,XX +XXX,XX @@ static bool trans_FCVTL_v(DisasContext *s, arg_qrr_e *a) | ||
318 | return true; | ||
319 | } | ||
320 | |||
321 | - fpst = fpstatus_ptr(FPST_FPCR); | ||
322 | + fpst = fpstatus_ptr(FPST_A64); | ||
323 | if (a->esz == MO_64) { | ||
324 | /* 32 -> 64 bit fp conversion */ | ||
325 | TCGv_i64 tcg_res[2]; | ||
326 | diff --git a/target/arm/tcg/translate-sme.c b/target/arm/tcg/translate-sme.c | ||
327 | index XXXXXXX..XXXXXXX 100644 | ||
328 | --- a/target/arm/tcg/translate-sme.c | ||
329 | +++ b/target/arm/tcg/translate-sme.c | ||
330 | @@ -XXX,XX +XXX,XX @@ static bool do_outprod_env(DisasContext *s, arg_op *a, MemOp esz, | ||
331 | TRANS_FEAT(FMOPA_h, aa64_sme, do_outprod_env, a, | ||
332 | MO_32, gen_helper_sme_fmopa_h) | ||
333 | TRANS_FEAT(FMOPA_s, aa64_sme, do_outprod_fpst, a, | ||
334 | - MO_32, FPST_FPCR, gen_helper_sme_fmopa_s) | ||
335 | + MO_32, FPST_A64, gen_helper_sme_fmopa_s) | ||
336 | TRANS_FEAT(FMOPA_d, aa64_sme_f64f64, do_outprod_fpst, a, | ||
337 | - MO_64, FPST_FPCR, gen_helper_sme_fmopa_d) | ||
338 | + MO_64, FPST_A64, gen_helper_sme_fmopa_d) | ||
339 | |||
340 | TRANS_FEAT(BFMOPA, aa64_sme, do_outprod_env, a, MO_32, gen_helper_sme_bfmopa) | ||
341 | |||
342 | diff --git a/target/arm/tcg/translate-sve.c b/target/arm/tcg/translate-sve.c | ||
343 | index XXXXXXX..XXXXXXX 100644 | ||
344 | --- a/target/arm/tcg/translate-sve.c | ||
345 | +++ b/target/arm/tcg/translate-sve.c | ||
346 | @@ -XXX,XX +XXX,XX @@ static bool gen_gvec_fpst_arg_zz(DisasContext *s, gen_helper_gvec_2_ptr *fn, | ||
347 | arg_rr_esz *a, int data) | ||
348 | { | ||
349 | return gen_gvec_fpst_zz(s, fn, a->rd, a->rn, data, | ||
350 | - a->esz == MO_16 ? FPST_FPCR_F16 : FPST_FPCR); | ||
351 | + a->esz == MO_16 ? FPST_FPCR_F16 : FPST_A64); | ||
352 | } | ||
353 | |||
354 | /* Invoke an out-of-line helper on 3 Zregs. */ | ||
355 | @@ -XXX,XX +XXX,XX @@ static bool gen_gvec_fpst_arg_zzz(DisasContext *s, gen_helper_gvec_3_ptr *fn, | ||
356 | arg_rrr_esz *a, int data) | ||
357 | { | ||
358 | return gen_gvec_fpst_zzz(s, fn, a->rd, a->rn, a->rm, data, | ||
359 | - a->esz == MO_16 ? FPST_FPCR_F16 : FPST_FPCR); | ||
360 | + a->esz == MO_16 ? FPST_FPCR_F16 : FPST_A64); | ||
361 | } | ||
362 | |||
363 | /* Invoke an out-of-line helper on 4 Zregs. */ | ||
364 | @@ -XXX,XX +XXX,XX @@ static bool gen_gvec_fpst_arg_zpzz(DisasContext *s, gen_helper_gvec_4_ptr *fn, | ||
365 | arg_rprr_esz *a) | ||
366 | { | ||
367 | return gen_gvec_fpst_zzzp(s, fn, a->rd, a->rn, a->rm, a->pg, 0, | ||
368 | - a->esz == MO_16 ? FPST_FPCR_F16 : FPST_FPCR); | ||
369 | + a->esz == MO_16 ? FPST_FPCR_F16 : FPST_A64); | ||
370 | } | ||
371 | |||
372 | /* Invoke a vector expander on two Zregs and an immediate. */ | ||
373 | @@ -XXX,XX +XXX,XX @@ static bool do_FMLA_zzxz(DisasContext *s, arg_rrxr_esz *a, bool sub) | ||
374 | }; | ||
375 | return gen_gvec_fpst_zzzz(s, fns[a->esz], a->rd, a->rn, a->rm, a->ra, | ||
376 | (a->index << 1) | sub, | ||
377 | - a->esz == MO_16 ? FPST_FPCR_F16 : FPST_FPCR); | ||
378 | + a->esz == MO_16 ? FPST_FPCR_F16 : FPST_A64); | ||
379 | } | ||
380 | |||
381 | TRANS_FEAT(FMLA_zzxz, aa64_sve, do_FMLA_zzxz, a, false) | ||
382 | @@ -XXX,XX +XXX,XX @@ static gen_helper_gvec_3_ptr * const fmul_idx_fns[4] = { | ||
383 | }; | ||
384 | TRANS_FEAT(FMUL_zzx, aa64_sve, gen_gvec_fpst_zzz, | ||
385 | fmul_idx_fns[a->esz], a->rd, a->rn, a->rm, a->index, | ||
386 | - a->esz == MO_16 ? FPST_FPCR_F16 : FPST_FPCR) | ||
387 | + a->esz == MO_16 ? FPST_FPCR_F16 : FPST_A64) | ||
388 | |||
389 | /* | ||
390 | *** SVE Floating Point Fast Reduction Group | ||
391 | @@ -XXX,XX +XXX,XX @@ static bool do_reduce(DisasContext *s, arg_rpr_esz *a, | ||
392 | |||
393 | tcg_gen_addi_ptr(t_zn, tcg_env, vec_full_reg_offset(s, a->rn)); | ||
394 | tcg_gen_addi_ptr(t_pg, tcg_env, pred_full_reg_offset(s, a->pg)); | ||
395 | - status = fpstatus_ptr(a->esz == MO_16 ? FPST_FPCR_F16 : FPST_FPCR); | ||
396 | + status = fpstatus_ptr(a->esz == MO_16 ? FPST_FPCR_F16 : FPST_A64); | ||
397 | |||
398 | fn(temp, t_zn, t_pg, status, t_desc); | ||
399 | |||
400 | @@ -XXX,XX +XXX,XX @@ static bool do_ppz_fp(DisasContext *s, arg_rpr_esz *a, | ||
401 | if (sve_access_check(s)) { | ||
402 | unsigned vsz = vec_full_reg_size(s); | ||
403 | TCGv_ptr status = | ||
404 | - fpstatus_ptr(a->esz == MO_16 ? FPST_FPCR_F16 : FPST_FPCR); | ||
405 | + fpstatus_ptr(a->esz == MO_16 ? FPST_FPCR_F16 : FPST_A64); | ||
406 | |||
407 | tcg_gen_gvec_3_ptr(pred_full_reg_offset(s, a->rd), | ||
408 | vec_full_reg_offset(s, a->rn), | ||
409 | @@ -XXX,XX +XXX,XX @@ static gen_helper_gvec_3_ptr * const ftmad_fns[4] = { | ||
410 | }; | ||
411 | TRANS_FEAT_NONSTREAMING(FTMAD, aa64_sve, gen_gvec_fpst_zzz, | ||
412 | ftmad_fns[a->esz], a->rd, a->rn, a->rm, a->imm, | ||
413 | - a->esz == MO_16 ? FPST_FPCR_F16 : FPST_FPCR) | ||
414 | + a->esz == MO_16 ? FPST_FPCR_F16 : FPST_A64) | ||
415 | |||
416 | /* | ||
417 | *** SVE Floating Point Accumulating Reduction Group | ||
418 | @@ -XXX,XX +XXX,XX @@ static bool trans_FADDA(DisasContext *s, arg_rprr_esz *a) | ||
419 | t_pg = tcg_temp_new_ptr(); | ||
420 | tcg_gen_addi_ptr(t_rm, tcg_env, vec_full_reg_offset(s, a->rm)); | ||
421 | tcg_gen_addi_ptr(t_pg, tcg_env, pred_full_reg_offset(s, a->pg)); | ||
422 | - t_fpst = fpstatus_ptr(a->esz == MO_16 ? FPST_FPCR_F16 : FPST_FPCR); | ||
423 | + t_fpst = fpstatus_ptr(a->esz == MO_16 ? FPST_FPCR_F16 : FPST_A64); | ||
424 | t_desc = tcg_constant_i32(simd_desc(vsz, vsz, 0)); | ||
425 | |||
426 | fns[a->esz - 1](t_val, t_val, t_rm, t_pg, t_fpst, t_desc); | ||
427 | @@ -XXX,XX +XXX,XX @@ static void do_fp_scalar(DisasContext *s, int zd, int zn, int pg, bool is_fp16, | ||
428 | tcg_gen_addi_ptr(t_zn, tcg_env, vec_full_reg_offset(s, zn)); | ||
429 | tcg_gen_addi_ptr(t_pg, tcg_env, pred_full_reg_offset(s, pg)); | ||
430 | |||
431 | - status = fpstatus_ptr(is_fp16 ? FPST_FPCR_F16 : FPST_FPCR); | ||
432 | + status = fpstatus_ptr(is_fp16 ? FPST_FPCR_F16 : FPST_A64); | ||
433 | desc = tcg_constant_i32(simd_desc(vsz, vsz, 0)); | ||
434 | fn(t_zd, t_zn, t_pg, scalar, status, desc); | ||
435 | } | ||
436 | @@ -XXX,XX +XXX,XX @@ static bool do_fp_cmp(DisasContext *s, arg_rprr_esz *a, | ||
437 | } | ||
438 | if (sve_access_check(s)) { | ||
439 | unsigned vsz = vec_full_reg_size(s); | ||
440 | - TCGv_ptr status = fpstatus_ptr(a->esz == MO_16 ? FPST_FPCR_F16 : FPST_FPCR); | ||
441 | + TCGv_ptr status = fpstatus_ptr(a->esz == MO_16 ? FPST_FPCR_F16 : FPST_A64); | ||
442 | tcg_gen_gvec_4_ptr(pred_full_reg_offset(s, a->rd), | ||
443 | vec_full_reg_offset(s, a->rn), | ||
444 | vec_full_reg_offset(s, a->rm), | ||
445 | @@ -XXX,XX +XXX,XX @@ static gen_helper_gvec_4_ptr * const fcadd_fns[] = { | ||
446 | }; | ||
447 | TRANS_FEAT(FCADD, aa64_sve, gen_gvec_fpst_zzzp, fcadd_fns[a->esz], | ||
448 | a->rd, a->rn, a->rm, a->pg, a->rot, | ||
449 | - a->esz == MO_16 ? FPST_FPCR_F16 : FPST_FPCR) | ||
450 | + a->esz == MO_16 ? FPST_FPCR_F16 : FPST_A64) | ||
451 | |||
452 | #define DO_FMLA(NAME, name) \ | ||
453 | static gen_helper_gvec_5_ptr * const name##_fns[4] = { \ | ||
454 | @@ -XXX,XX +XXX,XX @@ TRANS_FEAT(FCADD, aa64_sve, gen_gvec_fpst_zzzp, fcadd_fns[a->esz], | ||
455 | }; \ | ||
456 | TRANS_FEAT(NAME, aa64_sve, gen_gvec_fpst_zzzzp, name##_fns[a->esz], \ | ||
457 | a->rd, a->rn, a->rm, a->ra, a->pg, 0, \ | ||
458 | - a->esz == MO_16 ? FPST_FPCR_F16 : FPST_FPCR) | ||
459 | + a->esz == MO_16 ? FPST_FPCR_F16 : FPST_A64) | ||
460 | |||
461 | DO_FMLA(FMLA_zpzzz, fmla_zpzzz) | ||
462 | DO_FMLA(FMLS_zpzzz, fmls_zpzzz) | ||
463 | @@ -XXX,XX +XXX,XX @@ static gen_helper_gvec_5_ptr * const fcmla_fns[4] = { | ||
464 | }; | ||
465 | TRANS_FEAT(FCMLA_zpzzz, aa64_sve, gen_gvec_fpst_zzzzp, fcmla_fns[a->esz], | ||
466 | a->rd, a->rn, a->rm, a->ra, a->pg, a->rot, | ||
467 | - a->esz == MO_16 ? FPST_FPCR_F16 : FPST_FPCR) | ||
468 | + a->esz == MO_16 ? FPST_FPCR_F16 : FPST_A64) | ||
469 | |||
470 | static gen_helper_gvec_4_ptr * const fcmla_idx_fns[4] = { | ||
471 | NULL, gen_helper_gvec_fcmlah_idx, gen_helper_gvec_fcmlas_idx, NULL | ||
472 | }; | ||
473 | TRANS_FEAT(FCMLA_zzxz, aa64_sve, gen_gvec_fpst_zzzz, fcmla_idx_fns[a->esz], | ||
474 | a->rd, a->rn, a->rm, a->ra, a->index * 4 + a->rot, | ||
475 | - a->esz == MO_16 ? FPST_FPCR_F16 : FPST_FPCR) | ||
476 | + a->esz == MO_16 ? FPST_FPCR_F16 : FPST_A64) | ||
477 | |||
478 | /* | ||
479 | *** SVE Floating Point Unary Operations Predicated Group | ||
480 | */ | ||
481 | |||
482 | TRANS_FEAT(FCVT_sh, aa64_sve, gen_gvec_fpst_arg_zpz, | ||
483 | - gen_helper_sve_fcvt_sh, a, 0, FPST_FPCR) | ||
484 | + gen_helper_sve_fcvt_sh, a, 0, FPST_A64) | ||
485 | TRANS_FEAT(FCVT_hs, aa64_sve, gen_gvec_fpst_arg_zpz, | ||
486 | - gen_helper_sve_fcvt_hs, a, 0, FPST_FPCR) | ||
487 | + gen_helper_sve_fcvt_hs, a, 0, FPST_A64) | ||
488 | |||
489 | TRANS_FEAT(BFCVT, aa64_sve_bf16, gen_gvec_fpst_arg_zpz, | ||
490 | - gen_helper_sve_bfcvt, a, 0, FPST_FPCR) | ||
491 | + gen_helper_sve_bfcvt, a, 0, FPST_A64) | ||
492 | |||
493 | TRANS_FEAT(FCVT_dh, aa64_sve, gen_gvec_fpst_arg_zpz, | ||
494 | - gen_helper_sve_fcvt_dh, a, 0, FPST_FPCR) | ||
495 | + gen_helper_sve_fcvt_dh, a, 0, FPST_A64) | ||
496 | TRANS_FEAT(FCVT_hd, aa64_sve, gen_gvec_fpst_arg_zpz, | ||
497 | - gen_helper_sve_fcvt_hd, a, 0, FPST_FPCR) | ||
498 | + gen_helper_sve_fcvt_hd, a, 0, FPST_A64) | ||
499 | TRANS_FEAT(FCVT_ds, aa64_sve, gen_gvec_fpst_arg_zpz, | ||
500 | - gen_helper_sve_fcvt_ds, a, 0, FPST_FPCR) | ||
501 | + gen_helper_sve_fcvt_ds, a, 0, FPST_A64) | ||
502 | TRANS_FEAT(FCVT_sd, aa64_sve, gen_gvec_fpst_arg_zpz, | ||
503 | - gen_helper_sve_fcvt_sd, a, 0, FPST_FPCR) | ||
504 | + gen_helper_sve_fcvt_sd, a, 0, FPST_A64) | ||
505 | |||
506 | TRANS_FEAT(FCVTZS_hh, aa64_sve, gen_gvec_fpst_arg_zpz, | ||
507 | gen_helper_sve_fcvtzs_hh, a, 0, FPST_FPCR_F16) | ||
508 | @@ -XXX,XX +XXX,XX @@ TRANS_FEAT(FCVTZU_hd, aa64_sve, gen_gvec_fpst_arg_zpz, | ||
509 | gen_helper_sve_fcvtzu_hd, a, 0, FPST_FPCR_F16) | ||
510 | |||
511 | TRANS_FEAT(FCVTZS_ss, aa64_sve, gen_gvec_fpst_arg_zpz, | ||
512 | - gen_helper_sve_fcvtzs_ss, a, 0, FPST_FPCR) | ||
513 | + gen_helper_sve_fcvtzs_ss, a, 0, FPST_A64) | ||
514 | TRANS_FEAT(FCVTZU_ss, aa64_sve, gen_gvec_fpst_arg_zpz, | ||
515 | - gen_helper_sve_fcvtzu_ss, a, 0, FPST_FPCR) | ||
516 | + gen_helper_sve_fcvtzu_ss, a, 0, FPST_A64) | ||
517 | TRANS_FEAT(FCVTZS_sd, aa64_sve, gen_gvec_fpst_arg_zpz, | ||
518 | - gen_helper_sve_fcvtzs_sd, a, 0, FPST_FPCR) | ||
519 | + gen_helper_sve_fcvtzs_sd, a, 0, FPST_A64) | ||
520 | TRANS_FEAT(FCVTZU_sd, aa64_sve, gen_gvec_fpst_arg_zpz, | ||
521 | - gen_helper_sve_fcvtzu_sd, a, 0, FPST_FPCR) | ||
522 | + gen_helper_sve_fcvtzu_sd, a, 0, FPST_A64) | ||
523 | TRANS_FEAT(FCVTZS_ds, aa64_sve, gen_gvec_fpst_arg_zpz, | ||
524 | - gen_helper_sve_fcvtzs_ds, a, 0, FPST_FPCR) | ||
525 | + gen_helper_sve_fcvtzs_ds, a, 0, FPST_A64) | ||
526 | TRANS_FEAT(FCVTZU_ds, aa64_sve, gen_gvec_fpst_arg_zpz, | ||
527 | - gen_helper_sve_fcvtzu_ds, a, 0, FPST_FPCR) | ||
528 | + gen_helper_sve_fcvtzu_ds, a, 0, FPST_A64) | ||
529 | |||
530 | TRANS_FEAT(FCVTZS_dd, aa64_sve, gen_gvec_fpst_arg_zpz, | ||
531 | - gen_helper_sve_fcvtzs_dd, a, 0, FPST_FPCR) | ||
532 | + gen_helper_sve_fcvtzs_dd, a, 0, FPST_A64) | ||
533 | TRANS_FEAT(FCVTZU_dd, aa64_sve, gen_gvec_fpst_arg_zpz, | ||
534 | - gen_helper_sve_fcvtzu_dd, a, 0, FPST_FPCR) | ||
535 | + gen_helper_sve_fcvtzu_dd, a, 0, FPST_A64) | ||
536 | |||
537 | static gen_helper_gvec_3_ptr * const frint_fns[] = { | ||
538 | NULL, | ||
539 | @@ -XXX,XX +XXX,XX @@ static gen_helper_gvec_3_ptr * const frint_fns[] = { | ||
540 | gen_helper_sve_frint_d | ||
541 | }; | ||
542 | TRANS_FEAT(FRINTI, aa64_sve, gen_gvec_fpst_arg_zpz, frint_fns[a->esz], | ||
543 | - a, 0, a->esz == MO_16 ? FPST_FPCR_F16 : FPST_FPCR) | ||
544 | + a, 0, a->esz == MO_16 ? FPST_FPCR_F16 : FPST_A64) | ||
545 | |||
546 | static gen_helper_gvec_3_ptr * const frintx_fns[] = { | ||
547 | NULL, | ||
548 | @@ -XXX,XX +XXX,XX @@ static gen_helper_gvec_3_ptr * const frintx_fns[] = { | ||
549 | gen_helper_sve_frintx_d | ||
550 | }; | ||
551 | TRANS_FEAT(FRINTX, aa64_sve, gen_gvec_fpst_arg_zpz, frintx_fns[a->esz], | ||
552 | - a, 0, a->esz == MO_16 ? FPST_FPCR_F16 : FPST_FPCR); | ||
553 | + a, 0, a->esz == MO_16 ? FPST_FPCR_F16 : FPST_A64); | ||
554 | |||
555 | static bool do_frint_mode(DisasContext *s, arg_rpr_esz *a, | ||
556 | ARMFPRounding mode, gen_helper_gvec_3_ptr *fn) | ||
557 | @@ -XXX,XX +XXX,XX @@ static bool do_frint_mode(DisasContext *s, arg_rpr_esz *a, | ||
558 | } | ||
559 | |||
560 | vsz = vec_full_reg_size(s); | ||
561 | - status = fpstatus_ptr(a->esz == MO_16 ? FPST_FPCR_F16 : FPST_FPCR); | ||
562 | + status = fpstatus_ptr(a->esz == MO_16 ? FPST_FPCR_F16 : FPST_A64); | ||
563 | tmode = gen_set_rmode(mode, status); | ||
564 | |||
565 | tcg_gen_gvec_3_ptr(vec_full_reg_offset(s, a->rd), | ||
566 | @@ -XXX,XX +XXX,XX @@ static gen_helper_gvec_3_ptr * const frecpx_fns[] = { | ||
567 | gen_helper_sve_frecpx_s, gen_helper_sve_frecpx_d, | ||
568 | }; | ||
569 | TRANS_FEAT(FRECPX, aa64_sve, gen_gvec_fpst_arg_zpz, frecpx_fns[a->esz], | ||
570 | - a, 0, a->esz == MO_16 ? FPST_FPCR_F16 : FPST_FPCR) | ||
571 | + a, 0, a->esz == MO_16 ? FPST_FPCR_F16 : FPST_A64) | ||
572 | |||
573 | static gen_helper_gvec_3_ptr * const fsqrt_fns[] = { | ||
574 | NULL, gen_helper_sve_fsqrt_h, | ||
575 | gen_helper_sve_fsqrt_s, gen_helper_sve_fsqrt_d, | ||
576 | }; | ||
577 | TRANS_FEAT(FSQRT, aa64_sve, gen_gvec_fpst_arg_zpz, fsqrt_fns[a->esz], | ||
578 | - a, 0, a->esz == MO_16 ? FPST_FPCR_F16 : FPST_FPCR) | ||
579 | + a, 0, a->esz == MO_16 ? FPST_FPCR_F16 : FPST_A64) | ||
580 | |||
581 | TRANS_FEAT(SCVTF_hh, aa64_sve, gen_gvec_fpst_arg_zpz, | ||
582 | gen_helper_sve_scvt_hh, a, 0, FPST_FPCR_F16) | ||
583 | @@ -XXX,XX +XXX,XX @@ TRANS_FEAT(SCVTF_dh, aa64_sve, gen_gvec_fpst_arg_zpz, | ||
584 | gen_helper_sve_scvt_dh, a, 0, FPST_FPCR_F16) | ||
585 | |||
586 | TRANS_FEAT(SCVTF_ss, aa64_sve, gen_gvec_fpst_arg_zpz, | ||
587 | - gen_helper_sve_scvt_ss, a, 0, FPST_FPCR) | ||
588 | + gen_helper_sve_scvt_ss, a, 0, FPST_A64) | ||
589 | TRANS_FEAT(SCVTF_ds, aa64_sve, gen_gvec_fpst_arg_zpz, | ||
590 | - gen_helper_sve_scvt_ds, a, 0, FPST_FPCR) | ||
591 | + gen_helper_sve_scvt_ds, a, 0, FPST_A64) | ||
592 | |||
593 | TRANS_FEAT(SCVTF_sd, aa64_sve, gen_gvec_fpst_arg_zpz, | ||
594 | - gen_helper_sve_scvt_sd, a, 0, FPST_FPCR) | ||
595 | + gen_helper_sve_scvt_sd, a, 0, FPST_A64) | ||
596 | TRANS_FEAT(SCVTF_dd, aa64_sve, gen_gvec_fpst_arg_zpz, | ||
597 | - gen_helper_sve_scvt_dd, a, 0, FPST_FPCR) | ||
598 | + gen_helper_sve_scvt_dd, a, 0, FPST_A64) | ||
599 | |||
600 | TRANS_FEAT(UCVTF_hh, aa64_sve, gen_gvec_fpst_arg_zpz, | ||
601 | gen_helper_sve_ucvt_hh, a, 0, FPST_FPCR_F16) | ||
602 | @@ -XXX,XX +XXX,XX @@ TRANS_FEAT(UCVTF_dh, aa64_sve, gen_gvec_fpst_arg_zpz, | ||
603 | gen_helper_sve_ucvt_dh, a, 0, FPST_FPCR_F16) | ||
604 | |||
605 | TRANS_FEAT(UCVTF_ss, aa64_sve, gen_gvec_fpst_arg_zpz, | ||
606 | - gen_helper_sve_ucvt_ss, a, 0, FPST_FPCR) | ||
607 | + gen_helper_sve_ucvt_ss, a, 0, FPST_A64) | ||
608 | TRANS_FEAT(UCVTF_ds, aa64_sve, gen_gvec_fpst_arg_zpz, | ||
609 | - gen_helper_sve_ucvt_ds, a, 0, FPST_FPCR) | ||
610 | + gen_helper_sve_ucvt_ds, a, 0, FPST_A64) | ||
611 | TRANS_FEAT(UCVTF_sd, aa64_sve, gen_gvec_fpst_arg_zpz, | ||
612 | - gen_helper_sve_ucvt_sd, a, 0, FPST_FPCR) | ||
613 | + gen_helper_sve_ucvt_sd, a, 0, FPST_A64) | ||
614 | |||
615 | TRANS_FEAT(UCVTF_dd, aa64_sve, gen_gvec_fpst_arg_zpz, | ||
616 | - gen_helper_sve_ucvt_dd, a, 0, FPST_FPCR) | ||
617 | + gen_helper_sve_ucvt_dd, a, 0, FPST_A64) | ||
618 | |||
619 | /* | ||
620 | *** SVE Memory - 32-bit Gather and Unsized Contiguous Group | ||
621 | @@ -XXX,XX +XXX,XX @@ DO_ZPZZ_FP(FMINP, aa64_sve2, sve2_fminp_zpzz) | ||
622 | |||
623 | TRANS_FEAT_NONSTREAMING(FMMLA_s, aa64_sve_f32mm, gen_gvec_fpst_zzzz, | ||
624 | gen_helper_fmmla_s, a->rd, a->rn, a->rm, a->ra, | ||
625 | - 0, FPST_FPCR) | ||
626 | + 0, FPST_A64) | ||
627 | TRANS_FEAT_NONSTREAMING(FMMLA_d, aa64_sve_f64mm, gen_gvec_fpst_zzzz, | ||
628 | gen_helper_fmmla_d, a->rd, a->rn, a->rm, a->ra, | ||
629 | - 0, FPST_FPCR) | ||
630 | + 0, FPST_A64) | ||
631 | |||
632 | static gen_helper_gvec_4 * const sqdmlal_zzzw_fns[] = { | ||
633 | NULL, gen_helper_sve2_sqdmlal_zzzw_h, | ||
634 | @@ -XXX,XX +XXX,XX @@ TRANS_FEAT_NONSTREAMING(RAX1, aa64_sve2_sha3, gen_gvec_fn_arg_zzz, | ||
635 | gen_gvec_rax1, a) | ||
636 | |||
637 | TRANS_FEAT(FCVTNT_sh, aa64_sve2, gen_gvec_fpst_arg_zpz, | ||
638 | - gen_helper_sve2_fcvtnt_sh, a, 0, FPST_FPCR) | ||
639 | + gen_helper_sve2_fcvtnt_sh, a, 0, FPST_A64) | ||
640 | TRANS_FEAT(FCVTNT_ds, aa64_sve2, gen_gvec_fpst_arg_zpz, | ||
641 | - gen_helper_sve2_fcvtnt_ds, a, 0, FPST_FPCR) | ||
642 | + gen_helper_sve2_fcvtnt_ds, a, 0, FPST_A64) | ||
643 | |||
644 | TRANS_FEAT(BFCVTNT, aa64_sve_bf16, gen_gvec_fpst_arg_zpz, | ||
645 | - gen_helper_sve_bfcvtnt, a, 0, FPST_FPCR) | ||
646 | + gen_helper_sve_bfcvtnt, a, 0, FPST_A64) | ||
647 | |||
648 | TRANS_FEAT(FCVTLT_hs, aa64_sve2, gen_gvec_fpst_arg_zpz, | ||
649 | - gen_helper_sve2_fcvtlt_hs, a, 0, FPST_FPCR) | ||
650 | + gen_helper_sve2_fcvtlt_hs, a, 0, FPST_A64) | ||
651 | TRANS_FEAT(FCVTLT_sd, aa64_sve2, gen_gvec_fpst_arg_zpz, | ||
652 | - gen_helper_sve2_fcvtlt_sd, a, 0, FPST_FPCR) | ||
653 | + gen_helper_sve2_fcvtlt_sd, a, 0, FPST_A64) | ||
654 | |||
655 | TRANS_FEAT(FCVTX_ds, aa64_sve2, do_frint_mode, a, | ||
656 | FPROUNDING_ODD, gen_helper_sve_fcvt_ds) | ||
657 | @@ -XXX,XX +XXX,XX @@ static gen_helper_gvec_3_ptr * const flogb_fns[] = { | ||
658 | gen_helper_flogb_s, gen_helper_flogb_d | ||
659 | }; | ||
660 | TRANS_FEAT(FLOGB, aa64_sve2, gen_gvec_fpst_arg_zpz, flogb_fns[a->esz], | ||
661 | - a, 0, a->esz == MO_16 ? FPST_FPCR_F16 : FPST_FPCR) | ||
662 | + a, 0, a->esz == MO_16 ? FPST_FPCR_F16 : FPST_A64) | ||
663 | |||
664 | static bool do_FMLAL_zzzw(DisasContext *s, arg_rrrr_esz *a, bool sub, bool sel) | ||
665 | { | ||
666 | @@ -XXX,XX +XXX,XX @@ TRANS_FEAT_NONSTREAMING(BFMMLA, aa64_sve_bf16, gen_gvec_env_arg_zzzz, | ||
667 | static bool do_BFMLAL_zzzw(DisasContext *s, arg_rrrr_esz *a, bool sel) | ||
668 | { | ||
669 | return gen_gvec_fpst_zzzz(s, gen_helper_gvec_bfmlal, | ||
670 | - a->rd, a->rn, a->rm, a->ra, sel, FPST_FPCR); | ||
671 | + a->rd, a->rn, a->rm, a->ra, sel, FPST_A64); | ||
672 | } | ||
673 | |||
674 | TRANS_FEAT(BFMLALB_zzzw, aa64_sve_bf16, do_BFMLAL_zzzw, a, false) | ||
675 | @@ -XXX,XX +XXX,XX @@ static bool do_BFMLAL_zzxw(DisasContext *s, arg_rrxr_esz *a, bool sel) | ||
676 | { | ||
677 | return gen_gvec_fpst_zzzz(s, gen_helper_gvec_bfmlal_idx, | ||
678 | a->rd, a->rn, a->rm, a->ra, | ||
679 | - (a->index << 1) | sel, FPST_FPCR); | ||
680 | + (a->index << 1) | sel, FPST_A64); | ||
681 | } | ||
682 | |||
683 | TRANS_FEAT(BFMLALB_zzxw, aa64_sve_bf16, do_BFMLAL_zzxw, a, false) | ||
684 | -- | ||
685 | 2.34.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Now we have moved all the uses of vfp.fp_status and FPST_FPCR | ||
2 | to either the A32 or A64 fields, we can remove these. | ||
1 | 3 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20250124162836.2332150-13-peter.maydell@linaro.org | ||
7 | --- | ||
8 | target/arm/cpu.h | 2 -- | ||
9 | target/arm/tcg/translate.h | 6 ------ | ||
10 | target/arm/cpu.c | 1 - | ||
11 | target/arm/vfp_helper.c | 8 +------- | ||
12 | 4 files changed, 1 insertion(+), 16 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 @@ typedef struct CPUArchState { | ||
19 | |||
20 | /* There are a number of distinct float control structures: | ||
21 | * | ||
22 | - * fp_status: is the "normal" fp status. | ||
23 | * fp_status_a32: is the "normal" fp status for AArch32 insns | ||
24 | * fp_status_a64: is the "normal" fp status for AArch64 insns | ||
25 | * fp_status_fp16: used for half-precision calculations | ||
26 | @@ -XXX,XX +XXX,XX @@ typedef struct CPUArchState { | ||
27 | * only thing which needs to read the exception flags being | ||
28 | * an explicit FPSCR read. | ||
29 | */ | ||
30 | - float_status fp_status; | ||
31 | float_status fp_status_a32; | ||
32 | float_status fp_status_a64; | ||
33 | float_status fp_status_f16; | ||
34 | diff --git a/target/arm/tcg/translate.h b/target/arm/tcg/translate.h | ||
35 | index XXXXXXX..XXXXXXX 100644 | ||
36 | --- a/target/arm/tcg/translate.h | ||
37 | +++ b/target/arm/tcg/translate.h | ||
38 | @@ -XXX,XX +XXX,XX @@ static inline CPUARMTBFlags arm_tbflags_from_tb(const TranslationBlock *tb) | ||
39 | * Enum for argument to fpstatus_ptr(). | ||
40 | */ | ||
41 | typedef enum ARMFPStatusFlavour { | ||
42 | - FPST_FPCR, | ||
43 | FPST_A32, | ||
44 | FPST_A64, | ||
45 | FPST_FPCR_F16, | ||
46 | @@ -XXX,XX +XXX,XX @@ typedef enum ARMFPStatusFlavour { | ||
47 | * been set up to point to the requested field in the CPU state struct. | ||
48 | * The options are: | ||
49 | * | ||
50 | - * FPST_FPCR | ||
51 | - * for non-FP16 operations controlled by the FPCR | ||
52 | * FPST_A32 | ||
53 | * for AArch32 non-FP16 operations controlled by the FPCR | ||
54 | * FPST_A64 | ||
55 | @@ -XXX,XX +XXX,XX @@ static inline TCGv_ptr fpstatus_ptr(ARMFPStatusFlavour flavour) | ||
56 | int offset; | ||
57 | |||
58 | switch (flavour) { | ||
59 | - case FPST_FPCR: | ||
60 | - offset = offsetof(CPUARMState, vfp.fp_status); | ||
61 | - break; | ||
62 | case FPST_A32: | ||
63 | offset = offsetof(CPUARMState, vfp.fp_status_a32); | ||
64 | break; | ||
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_reset_hold(Object *obj, ResetType type) | ||
70 | set_flush_inputs_to_zero(1, &env->vfp.standard_fp_status); | ||
71 | set_default_nan_mode(1, &env->vfp.standard_fp_status); | ||
72 | set_default_nan_mode(1, &env->vfp.standard_fp_status_f16); | ||
73 | - arm_set_default_fp_behaviours(&env->vfp.fp_status); | ||
74 | arm_set_default_fp_behaviours(&env->vfp.fp_status_a32); | ||
75 | arm_set_default_fp_behaviours(&env->vfp.fp_status_a64); | ||
76 | arm_set_default_fp_behaviours(&env->vfp.standard_fp_status); | ||
77 | diff --git a/target/arm/vfp_helper.c b/target/arm/vfp_helper.c | ||
78 | index XXXXXXX..XXXXXXX 100644 | ||
79 | --- a/target/arm/vfp_helper.c | ||
80 | +++ b/target/arm/vfp_helper.c | ||
81 | @@ -XXX,XX +XXX,XX @@ static inline uint32_t vfp_exceptbits_from_host(int host_bits) | ||
82 | |||
83 | static uint32_t vfp_get_fpsr_from_host(CPUARMState *env) | ||
84 | { | ||
85 | - uint32_t i; | ||
86 | + uint32_t i = 0; | ||
87 | |||
88 | - i = get_float_exception_flags(&env->vfp.fp_status); | ||
89 | i |= get_float_exception_flags(&env->vfp.fp_status_a32); | ||
90 | i |= get_float_exception_flags(&env->vfp.fp_status_a64); | ||
91 | i |= get_float_exception_flags(&env->vfp.standard_fp_status); | ||
92 | @@ -XXX,XX +XXX,XX @@ static void vfp_clear_float_status_exc_flags(CPUARMState *env) | ||
93 | * values. The caller should have arranged for env->vfp.fpsr to | ||
94 | * be the architecturally up-to-date exception flag information first. | ||
95 | */ | ||
96 | - set_float_exception_flags(0, &env->vfp.fp_status); | ||
97 | set_float_exception_flags(0, &env->vfp.fp_status_a32); | ||
98 | set_float_exception_flags(0, &env->vfp.fp_status_a64); | ||
99 | set_float_exception_flags(0, &env->vfp.fp_status_f16); | ||
100 | @@ -XXX,XX +XXX,XX @@ static void vfp_set_fpcr_to_host(CPUARMState *env, uint32_t val, uint32_t mask) | ||
101 | i = float_round_to_zero; | ||
102 | break; | ||
103 | } | ||
104 | - set_float_rounding_mode(i, &env->vfp.fp_status); | ||
105 | set_float_rounding_mode(i, &env->vfp.fp_status_a32); | ||
106 | set_float_rounding_mode(i, &env->vfp.fp_status_a64); | ||
107 | set_float_rounding_mode(i, &env->vfp.fp_status_f16); | ||
108 | @@ -XXX,XX +XXX,XX @@ static void vfp_set_fpcr_to_host(CPUARMState *env, uint32_t val, uint32_t mask) | ||
109 | } | ||
110 | if (changed & FPCR_FZ) { | ||
111 | bool ftz_enabled = val & FPCR_FZ; | ||
112 | - set_flush_to_zero(ftz_enabled, &env->vfp.fp_status); | ||
113 | - set_flush_inputs_to_zero(ftz_enabled, &env->vfp.fp_status); | ||
114 | set_flush_to_zero(ftz_enabled, &env->vfp.fp_status_a32); | ||
115 | set_flush_inputs_to_zero(ftz_enabled, &env->vfp.fp_status_a32); | ||
116 | set_flush_to_zero(ftz_enabled, &env->vfp.fp_status_a64); | ||
117 | @@ -XXX,XX +XXX,XX @@ static void vfp_set_fpcr_to_host(CPUARMState *env, uint32_t val, uint32_t mask) | ||
118 | } | ||
119 | if (changed & FPCR_DN) { | ||
120 | bool dnan_enabled = val & FPCR_DN; | ||
121 | - set_default_nan_mode(dnan_enabled, &env->vfp.fp_status); | ||
122 | set_default_nan_mode(dnan_enabled, &env->vfp.fp_status_a32); | ||
123 | set_default_nan_mode(dnan_enabled, &env->vfp.fp_status_a64); | ||
124 | set_default_nan_mode(dnan_enabled, &env->vfp.fp_status_f16); | ||
125 | -- | ||
126 | 2.34.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | As the first part of splitting the existing fp_status_f16 | ||
2 | into separate float_status fields for AArch32 and AArch64 | ||
3 | (so that we can make FEAT_AFP control bits apply only | ||
4 | for AArch64), define the two new fp_status_f16_a32 and | ||
5 | fp_status_f16_a64 fields, but don't use them yet. | ||
1 | 6 | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20250124162836.2332150-14-peter.maydell@linaro.org | ||
10 | --- | ||
11 | target/arm/cpu.h | 4 ++++ | ||
12 | target/arm/tcg/translate.h | 12 ++++++++++++ | ||
13 | target/arm/cpu.c | 2 ++ | ||
14 | target/arm/vfp_helper.c | 14 ++++++++++++++ | ||
15 | 4 files changed, 32 insertions(+) | ||
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 @@ typedef struct CPUArchState { | ||
22 | * fp_status_a32: is the "normal" fp status for AArch32 insns | ||
23 | * fp_status_a64: is the "normal" fp status for AArch64 insns | ||
24 | * fp_status_fp16: used for half-precision calculations | ||
25 | + * fp_status_fp16_a32: used for AArch32 half-precision calculations | ||
26 | + * fp_status_fp16_a64: used for AArch64 half-precision calculations | ||
27 | * standard_fp_status : the ARM "Standard FPSCR Value" | ||
28 | * standard_fp_status_fp16 : used for half-precision | ||
29 | * calculations with the ARM "Standard FPSCR Value" | ||
30 | @@ -XXX,XX +XXX,XX @@ typedef struct CPUArchState { | ||
31 | float_status fp_status_a32; | ||
32 | float_status fp_status_a64; | ||
33 | float_status fp_status_f16; | ||
34 | + float_status fp_status_f16_a32; | ||
35 | + float_status fp_status_f16_a64; | ||
36 | float_status standard_fp_status; | ||
37 | float_status standard_fp_status_f16; | ||
38 | |||
39 | diff --git a/target/arm/tcg/translate.h b/target/arm/tcg/translate.h | ||
40 | index XXXXXXX..XXXXXXX 100644 | ||
41 | --- a/target/arm/tcg/translate.h | ||
42 | +++ b/target/arm/tcg/translate.h | ||
43 | @@ -XXX,XX +XXX,XX @@ typedef enum ARMFPStatusFlavour { | ||
44 | FPST_A32, | ||
45 | FPST_A64, | ||
46 | FPST_FPCR_F16, | ||
47 | + FPST_A32_F16, | ||
48 | + FPST_A64_F16, | ||
49 | FPST_STD, | ||
50 | FPST_STD_F16, | ||
51 | } ARMFPStatusFlavour; | ||
52 | @@ -XXX,XX +XXX,XX @@ typedef enum ARMFPStatusFlavour { | ||
53 | * for AArch64 non-FP16 operations controlled by the FPCR | ||
54 | * FPST_FPCR_F16 | ||
55 | * for operations controlled by the FPCR where FPCR.FZ16 is to be used | ||
56 | + * FPST_A32_F16 | ||
57 | + * for AArch32 operations controlled by the FPCR where FPCR.FZ16 is to be used | ||
58 | + * FPST_A64_F16 | ||
59 | + * for AArch64 operations controlled by the FPCR where FPCR.FZ16 is to be used | ||
60 | * FPST_STD | ||
61 | * for A32/T32 Neon operations using the "standard FPSCR value" | ||
62 | * FPST_STD_F16 | ||
63 | @@ -XXX,XX +XXX,XX @@ static inline TCGv_ptr fpstatus_ptr(ARMFPStatusFlavour flavour) | ||
64 | case FPST_FPCR_F16: | ||
65 | offset = offsetof(CPUARMState, vfp.fp_status_f16); | ||
66 | break; | ||
67 | + case FPST_A32_F16: | ||
68 | + offset = offsetof(CPUARMState, vfp.fp_status_f16_a32); | ||
69 | + break; | ||
70 | + case FPST_A64_F16: | ||
71 | + offset = offsetof(CPUARMState, vfp.fp_status_f16_a64); | ||
72 | + break; | ||
73 | case FPST_STD: | ||
74 | offset = offsetof(CPUARMState, vfp.standard_fp_status); | ||
75 | break; | ||
76 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | ||
77 | index XXXXXXX..XXXXXXX 100644 | ||
78 | --- a/target/arm/cpu.c | ||
79 | +++ b/target/arm/cpu.c | ||
80 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_reset_hold(Object *obj, ResetType type) | ||
81 | arm_set_default_fp_behaviours(&env->vfp.fp_status_a64); | ||
82 | arm_set_default_fp_behaviours(&env->vfp.standard_fp_status); | ||
83 | arm_set_default_fp_behaviours(&env->vfp.fp_status_f16); | ||
84 | + arm_set_default_fp_behaviours(&env->vfp.fp_status_f16_a32); | ||
85 | + arm_set_default_fp_behaviours(&env->vfp.fp_status_f16_a64); | ||
86 | arm_set_default_fp_behaviours(&env->vfp.standard_fp_status_f16); | ||
87 | |||
88 | #ifndef CONFIG_USER_ONLY | ||
89 | diff --git a/target/arm/vfp_helper.c b/target/arm/vfp_helper.c | ||
90 | index XXXXXXX..XXXXXXX 100644 | ||
91 | --- a/target/arm/vfp_helper.c | ||
92 | +++ b/target/arm/vfp_helper.c | ||
93 | @@ -XXX,XX +XXX,XX @@ static uint32_t vfp_get_fpsr_from_host(CPUARMState *env) | ||
94 | /* FZ16 does not generate an input denormal exception. */ | ||
95 | i |= (get_float_exception_flags(&env->vfp.fp_status_f16) | ||
96 | & ~float_flag_input_denormal); | ||
97 | + i |= (get_float_exception_flags(&env->vfp.fp_status_f16_a32) | ||
98 | + & ~float_flag_input_denormal); | ||
99 | + i |= (get_float_exception_flags(&env->vfp.fp_status_f16_a64) | ||
100 | + & ~float_flag_input_denormal); | ||
101 | i |= (get_float_exception_flags(&env->vfp.standard_fp_status_f16) | ||
102 | & ~float_flag_input_denormal); | ||
103 | return vfp_exceptbits_from_host(i); | ||
104 | @@ -XXX,XX +XXX,XX @@ static void vfp_clear_float_status_exc_flags(CPUARMState *env) | ||
105 | set_float_exception_flags(0, &env->vfp.fp_status_a32); | ||
106 | set_float_exception_flags(0, &env->vfp.fp_status_a64); | ||
107 | set_float_exception_flags(0, &env->vfp.fp_status_f16); | ||
108 | + set_float_exception_flags(0, &env->vfp.fp_status_f16_a32); | ||
109 | + set_float_exception_flags(0, &env->vfp.fp_status_f16_a64); | ||
110 | set_float_exception_flags(0, &env->vfp.standard_fp_status); | ||
111 | set_float_exception_flags(0, &env->vfp.standard_fp_status_f16); | ||
112 | } | ||
113 | @@ -XXX,XX +XXX,XX @@ static void vfp_set_fpcr_to_host(CPUARMState *env, uint32_t val, uint32_t mask) | ||
114 | set_float_rounding_mode(i, &env->vfp.fp_status_a32); | ||
115 | set_float_rounding_mode(i, &env->vfp.fp_status_a64); | ||
116 | set_float_rounding_mode(i, &env->vfp.fp_status_f16); | ||
117 | + set_float_rounding_mode(i, &env->vfp.fp_status_f16_a32); | ||
118 | + set_float_rounding_mode(i, &env->vfp.fp_status_f16_a64); | ||
119 | } | ||
120 | if (changed & FPCR_FZ16) { | ||
121 | bool ftz_enabled = val & FPCR_FZ16; | ||
122 | set_flush_to_zero(ftz_enabled, &env->vfp.fp_status_f16); | ||
123 | + set_flush_to_zero(ftz_enabled, &env->vfp.fp_status_f16_a32); | ||
124 | + set_flush_to_zero(ftz_enabled, &env->vfp.fp_status_f16_a64); | ||
125 | set_flush_to_zero(ftz_enabled, &env->vfp.standard_fp_status_f16); | ||
126 | set_flush_inputs_to_zero(ftz_enabled, &env->vfp.fp_status_f16); | ||
127 | + set_flush_inputs_to_zero(ftz_enabled, &env->vfp.fp_status_f16_a32); | ||
128 | + set_flush_inputs_to_zero(ftz_enabled, &env->vfp.fp_status_f16_a64); | ||
129 | set_flush_inputs_to_zero(ftz_enabled, &env->vfp.standard_fp_status_f16); | ||
130 | } | ||
131 | if (changed & FPCR_FZ) { | ||
132 | @@ -XXX,XX +XXX,XX @@ static void vfp_set_fpcr_to_host(CPUARMState *env, uint32_t val, uint32_t mask) | ||
133 | set_default_nan_mode(dnan_enabled, &env->vfp.fp_status_a32); | ||
134 | set_default_nan_mode(dnan_enabled, &env->vfp.fp_status_a64); | ||
135 | set_default_nan_mode(dnan_enabled, &env->vfp.fp_status_f16); | ||
136 | + set_default_nan_mode(dnan_enabled, &env->vfp.fp_status_f16_a32); | ||
137 | + set_default_nan_mode(dnan_enabled, &env->vfp.fp_status_f16_a64); | ||
138 | } | ||
139 | } | ||
140 | |||
141 | -- | ||
142 | 2.34.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | We directly use fp_status_f16 in a handful of helpers that | ||
2 | are AArch32-specific; switch to fp_status_f16_a32 for these. | ||
1 | 3 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20250124162836.2332150-15-peter.maydell@linaro.org | ||
7 | --- | ||
8 | target/arm/tcg/vec_helper.c | 4 ++-- | ||
9 | target/arm/vfp_helper.c | 2 +- | ||
10 | 2 files changed, 3 insertions(+), 3 deletions(-) | ||
11 | |||
12 | diff --git a/target/arm/tcg/vec_helper.c b/target/arm/tcg/vec_helper.c | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/target/arm/tcg/vec_helper.c | ||
15 | +++ b/target/arm/tcg/vec_helper.c | ||
16 | @@ -XXX,XX +XXX,XX @@ void HELPER(gvec_fmlal_a32)(void *vd, void *vn, void *vm, | ||
17 | CPUARMState *env, uint32_t desc) | ||
18 | { | ||
19 | do_fmlal(vd, vn, vm, &env->vfp.standard_fp_status, desc, | ||
20 | - get_flush_inputs_to_zero(&env->vfp.fp_status_f16)); | ||
21 | + get_flush_inputs_to_zero(&env->vfp.fp_status_f16_a32)); | ||
22 | } | ||
23 | |||
24 | void HELPER(gvec_fmlal_a64)(void *vd, void *vn, void *vm, | ||
25 | @@ -XXX,XX +XXX,XX @@ void HELPER(gvec_fmlal_idx_a32)(void *vd, void *vn, void *vm, | ||
26 | CPUARMState *env, uint32_t desc) | ||
27 | { | ||
28 | do_fmlal_idx(vd, vn, vm, &env->vfp.standard_fp_status, desc, | ||
29 | - get_flush_inputs_to_zero(&env->vfp.fp_status_f16)); | ||
30 | + get_flush_inputs_to_zero(&env->vfp.fp_status_f16_a32)); | ||
31 | } | ||
32 | |||
33 | void HELPER(gvec_fmlal_idx_a64)(void *vd, void *vn, void *vm, | ||
34 | diff --git a/target/arm/vfp_helper.c b/target/arm/vfp_helper.c | ||
35 | index XXXXXXX..XXXXXXX 100644 | ||
36 | --- a/target/arm/vfp_helper.c | ||
37 | +++ b/target/arm/vfp_helper.c | ||
38 | @@ -XXX,XX +XXX,XX @@ void VFP_HELPER(cmpe, P)(ARGTYPE a, ARGTYPE b, CPUARMState *env) \ | ||
39 | softfloat_to_vfp_compare(env, \ | ||
40 | FLOATTYPE ## _compare(a, b, &env->vfp.FPST)); \ | ||
41 | } | ||
42 | -DO_VFP_cmp(h, float16, dh_ctype_f16, fp_status_f16) | ||
43 | +DO_VFP_cmp(h, float16, dh_ctype_f16, fp_status_f16_a32) | ||
44 | DO_VFP_cmp(s, float32, float32, fp_status_a32) | ||
45 | DO_VFP_cmp(d, float64, float64, fp_status_a32) | ||
46 | #undef DO_VFP_cmp | ||
47 | -- | ||
48 | 2.34.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | We directly use fp_status_f16 in a handful of helpers that are | ||
2 | AArch64-specific; switch to fp_status_f16_a64 for these. | ||
1 | 3 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20250124162836.2332150-16-peter.maydell@linaro.org | ||
7 | --- | ||
8 | target/arm/tcg/sme_helper.c | 4 ++-- | ||
9 | target/arm/tcg/vec_helper.c | 8 ++++---- | ||
10 | 2 files changed, 6 insertions(+), 6 deletions(-) | ||
11 | |||
12 | diff --git a/target/arm/tcg/sme_helper.c b/target/arm/tcg/sme_helper.c | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/target/arm/tcg/sme_helper.c | ||
15 | +++ b/target/arm/tcg/sme_helper.c | ||
16 | @@ -XXX,XX +XXX,XX @@ void HELPER(sme_fmopa_h)(void *vza, void *vzn, void *vzm, void *vpn, | ||
17 | float_status fpst_odd, fpst_std, fpst_f16; | ||
18 | |||
19 | /* | ||
20 | - * Make copies of fp_status and fp_status_f16, because this operation | ||
21 | + * Make copies of the fp status fields we use, because this operation | ||
22 | * does not update the cumulative fp exception status. It also | ||
23 | * produces default NaNs. We also need a second copy of fp_status with | ||
24 | * round-to-odd -- see above. | ||
25 | */ | ||
26 | - fpst_f16 = env->vfp.fp_status_f16; | ||
27 | + fpst_f16 = env->vfp.fp_status_f16_a64; | ||
28 | fpst_std = env->vfp.fp_status_a64; | ||
29 | set_default_nan_mode(true, &fpst_std); | ||
30 | set_default_nan_mode(true, &fpst_f16); | ||
31 | diff --git a/target/arm/tcg/vec_helper.c b/target/arm/tcg/vec_helper.c | ||
32 | index XXXXXXX..XXXXXXX 100644 | ||
33 | --- a/target/arm/tcg/vec_helper.c | ||
34 | +++ b/target/arm/tcg/vec_helper.c | ||
35 | @@ -XXX,XX +XXX,XX @@ void HELPER(gvec_fmlal_a64)(void *vd, void *vn, void *vm, | ||
36 | CPUARMState *env, uint32_t desc) | ||
37 | { | ||
38 | do_fmlal(vd, vn, vm, &env->vfp.fp_status_a64, desc, | ||
39 | - get_flush_inputs_to_zero(&env->vfp.fp_status_f16)); | ||
40 | + get_flush_inputs_to_zero(&env->vfp.fp_status_f16_a64)); | ||
41 | } | ||
42 | |||
43 | void HELPER(sve2_fmlal_zzzw_s)(void *vd, void *vn, void *vm, void *va, | ||
44 | @@ -XXX,XX +XXX,XX @@ void HELPER(sve2_fmlal_zzzw_s)(void *vd, void *vn, void *vm, void *va, | ||
45 | uint16_t negn = extract32(desc, SIMD_DATA_SHIFT, 1) << 15; | ||
46 | intptr_t sel = extract32(desc, SIMD_DATA_SHIFT + 1, 1) * sizeof(float16); | ||
47 | float_status *status = &env->vfp.fp_status_a64; | ||
48 | - bool fz16 = get_flush_inputs_to_zero(&env->vfp.fp_status_f16); | ||
49 | + bool fz16 = get_flush_inputs_to_zero(&env->vfp.fp_status_f16_a64); | ||
50 | |||
51 | for (i = 0; i < oprsz; i += sizeof(float32)) { | ||
52 | float16 nn_16 = *(float16 *)(vn + H1_2(i + sel)) ^ negn; | ||
53 | @@ -XXX,XX +XXX,XX @@ void HELPER(gvec_fmlal_idx_a64)(void *vd, void *vn, void *vm, | ||
54 | CPUARMState *env, uint32_t desc) | ||
55 | { | ||
56 | do_fmlal_idx(vd, vn, vm, &env->vfp.fp_status_a64, desc, | ||
57 | - get_flush_inputs_to_zero(&env->vfp.fp_status_f16)); | ||
58 | + get_flush_inputs_to_zero(&env->vfp.fp_status_f16_a64)); | ||
59 | } | ||
60 | |||
61 | void HELPER(sve2_fmlal_zzxw_s)(void *vd, void *vn, void *vm, void *va, | ||
62 | @@ -XXX,XX +XXX,XX @@ void HELPER(sve2_fmlal_zzxw_s)(void *vd, void *vn, void *vm, void *va, | ||
63 | intptr_t sel = extract32(desc, SIMD_DATA_SHIFT + 1, 1) * sizeof(float16); | ||
64 | intptr_t idx = extract32(desc, SIMD_DATA_SHIFT + 2, 3) * sizeof(float16); | ||
65 | float_status *status = &env->vfp.fp_status_a64; | ||
66 | - bool fz16 = get_flush_inputs_to_zero(&env->vfp.fp_status_f16); | ||
67 | + bool fz16 = get_flush_inputs_to_zero(&env->vfp.fp_status_f16_a64); | ||
68 | |||
69 | for (i = 0; i < oprsz; i += 16) { | ||
70 | float16 mm_16 = *(float16 *)(vm + i + idx); | ||
71 | -- | ||
72 | 2.34.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | In the A32 decoder, use FPST_A32_F16 rather than FPST_FPCR_F16. | ||
2 | By doing an automated conversion of the whole file we avoid possibly | ||
3 | using more than one fpst value in a set_rmode/op/restore_rmode | ||
4 | sequence. | ||
1 | 5 | ||
6 | Patch created with | ||
7 | perl -p -i -e 's/FPST_FPCR_F16(?!_)/FPST_A32_F16/g' target/arm/tcg/translate-vfp.c | ||
8 | |||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
11 | Message-id: 20250124162836.2332150-17-peter.maydell@linaro.org | ||
12 | --- | ||
13 | target/arm/tcg/translate-vfp.c | 24 ++++++++++++------------ | ||
14 | 1 file changed, 12 insertions(+), 12 deletions(-) | ||
15 | |||
16 | diff --git a/target/arm/tcg/translate-vfp.c b/target/arm/tcg/translate-vfp.c | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/target/arm/tcg/translate-vfp.c | ||
19 | +++ b/target/arm/tcg/translate-vfp.c | ||
20 | @@ -XXX,XX +XXX,XX @@ static bool trans_VRINT(DisasContext *s, arg_VRINT *a) | ||
21 | } | ||
22 | |||
23 | if (sz == 1) { | ||
24 | - fpst = fpstatus_ptr(FPST_FPCR_F16); | ||
25 | + fpst = fpstatus_ptr(FPST_A32_F16); | ||
26 | } else { | ||
27 | fpst = fpstatus_ptr(FPST_A32); | ||
28 | } | ||
29 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT(DisasContext *s, arg_VCVT *a) | ||
30 | } | ||
31 | |||
32 | if (sz == 1) { | ||
33 | - fpst = fpstatus_ptr(FPST_FPCR_F16); | ||
34 | + fpst = fpstatus_ptr(FPST_A32_F16); | ||
35 | } else { | ||
36 | fpst = fpstatus_ptr(FPST_A32); | ||
37 | } | ||
38 | @@ -XXX,XX +XXX,XX @@ static bool do_vfp_3op_hp(DisasContext *s, VFPGen3OpSPFn *fn, | ||
39 | /* | ||
40 | * Do a half-precision operation. Functionally this is | ||
41 | * the same as do_vfp_3op_sp(), except: | ||
42 | - * - it uses the FPST_FPCR_F16 | ||
43 | + * - it uses the FPST_A32_F16 | ||
44 | * - it doesn't need the VFP vector handling (fp16 is a | ||
45 | * v8 feature, and in v8 VFP vectors don't exist) | ||
46 | * - it does the aa32_fp16_arith feature test | ||
47 | @@ -XXX,XX +XXX,XX @@ static bool do_vfp_3op_hp(DisasContext *s, VFPGen3OpSPFn *fn, | ||
48 | f0 = tcg_temp_new_i32(); | ||
49 | f1 = tcg_temp_new_i32(); | ||
50 | fd = tcg_temp_new_i32(); | ||
51 | - fpst = fpstatus_ptr(FPST_FPCR_F16); | ||
52 | + fpst = fpstatus_ptr(FPST_A32_F16); | ||
53 | |||
54 | vfp_load_reg16(f0, vn); | ||
55 | vfp_load_reg16(f1, vm); | ||
56 | @@ -XXX,XX +XXX,XX @@ static bool do_vfm_hp(DisasContext *s, arg_VFMA_sp *a, bool neg_n, bool neg_d) | ||
57 | /* VFNMA, VFNMS */ | ||
58 | gen_vfp_negh(vd, vd); | ||
59 | } | ||
60 | - fpst = fpstatus_ptr(FPST_FPCR_F16); | ||
61 | + fpst = fpstatus_ptr(FPST_A32_F16); | ||
62 | gen_helper_vfp_muladdh(vd, vn, vm, vd, fpst); | ||
63 | vfp_store_reg32(vd, a->vd); | ||
64 | return true; | ||
65 | @@ -XXX,XX +XXX,XX @@ DO_VFP_2OP(VNEG, dp, gen_vfp_negd, aa32_fpdp_v2) | ||
66 | |||
67 | static void gen_VSQRT_hp(TCGv_i32 vd, TCGv_i32 vm) | ||
68 | { | ||
69 | - gen_helper_vfp_sqrth(vd, vm, fpstatus_ptr(FPST_FPCR_F16)); | ||
70 | + gen_helper_vfp_sqrth(vd, vm, fpstatus_ptr(FPST_A32_F16)); | ||
71 | } | ||
72 | |||
73 | static void gen_VSQRT_sp(TCGv_i32 vd, TCGv_i32 vm) | ||
74 | @@ -XXX,XX +XXX,XX @@ static bool trans_VRINTR_hp(DisasContext *s, arg_VRINTR_sp *a) | ||
75 | |||
76 | tmp = tcg_temp_new_i32(); | ||
77 | vfp_load_reg16(tmp, a->vm); | ||
78 | - fpst = fpstatus_ptr(FPST_FPCR_F16); | ||
79 | + fpst = fpstatus_ptr(FPST_A32_F16); | ||
80 | gen_helper_rinth(tmp, tmp, fpst); | ||
81 | vfp_store_reg32(tmp, a->vd); | ||
82 | return true; | ||
83 | @@ -XXX,XX +XXX,XX @@ static bool trans_VRINTZ_hp(DisasContext *s, arg_VRINTZ_sp *a) | ||
84 | |||
85 | tmp = tcg_temp_new_i32(); | ||
86 | vfp_load_reg16(tmp, a->vm); | ||
87 | - fpst = fpstatus_ptr(FPST_FPCR_F16); | ||
88 | + fpst = fpstatus_ptr(FPST_A32_F16); | ||
89 | tcg_rmode = gen_set_rmode(FPROUNDING_ZERO, fpst); | ||
90 | gen_helper_rinth(tmp, tmp, fpst); | ||
91 | gen_restore_rmode(tcg_rmode, fpst); | ||
92 | @@ -XXX,XX +XXX,XX @@ static bool trans_VRINTX_hp(DisasContext *s, arg_VRINTX_sp *a) | ||
93 | |||
94 | tmp = tcg_temp_new_i32(); | ||
95 | vfp_load_reg16(tmp, a->vm); | ||
96 | - fpst = fpstatus_ptr(FPST_FPCR_F16); | ||
97 | + fpst = fpstatus_ptr(FPST_A32_F16); | ||
98 | gen_helper_rinth_exact(tmp, tmp, fpst); | ||
99 | vfp_store_reg32(tmp, a->vd); | ||
100 | return true; | ||
101 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_int_hp(DisasContext *s, arg_VCVT_int_sp *a) | ||
102 | |||
103 | vm = tcg_temp_new_i32(); | ||
104 | vfp_load_reg32(vm, a->vm); | ||
105 | - fpst = fpstatus_ptr(FPST_FPCR_F16); | ||
106 | + fpst = fpstatus_ptr(FPST_A32_F16); | ||
107 | if (a->s) { | ||
108 | /* i32 -> f16 */ | ||
109 | gen_helper_vfp_sitoh(vm, vm, fpst); | ||
110 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_fix_hp(DisasContext *s, arg_VCVT_fix_sp *a) | ||
111 | vd = tcg_temp_new_i32(); | ||
112 | vfp_load_reg32(vd, a->vd); | ||
113 | |||
114 | - fpst = fpstatus_ptr(FPST_FPCR_F16); | ||
115 | + fpst = fpstatus_ptr(FPST_A32_F16); | ||
116 | shift = tcg_constant_i32(frac_bits); | ||
117 | |||
118 | /* Switch on op:U:sx bits */ | ||
119 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_hp_int(DisasContext *s, arg_VCVT_sp_int *a) | ||
120 | return true; | ||
121 | } | ||
122 | |||
123 | - fpst = fpstatus_ptr(FPST_FPCR_F16); | ||
124 | + fpst = fpstatus_ptr(FPST_A32_F16); | ||
125 | vm = tcg_temp_new_i32(); | ||
126 | vfp_load_reg16(vm, a->vm); | ||
127 | |||
128 | -- | ||
129 | 2.34.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | In the A32 decoder, use FPST_A64_F16 rather than FPST_FPCR_F16. | ||
2 | By doing an automated conversion of the whole file we avoid possibly | ||
3 | using more than one fpst value in a set_rmode/op/restore_rmode | ||
4 | sequence. | ||
1 | 5 | ||
6 | Patch created with | ||
7 | perl -p -i -e 's/FPST_FPCR_F16(?!_)/FPST_A64_F16/g' target/arm/tcg/translate-{a64,sve,sme}.c | ||
8 | |||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
11 | Message-id: 20250124162836.2332150-18-peter.maydell@linaro.org | ||
12 | --- | ||
13 | target/arm/tcg/translate-a64.c | 32 ++++++++--------- | ||
14 | target/arm/tcg/translate-sve.c | 66 +++++++++++++++++----------------- | ||
15 | 2 files changed, 49 insertions(+), 49 deletions(-) | ||
16 | |||
17 | diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/target/arm/tcg/translate-a64.c | ||
20 | +++ b/target/arm/tcg/translate-a64.c | ||
21 | @@ -XXX,XX +XXX,XX @@ static void gen_gvec_op3_fpst(DisasContext *s, bool is_q, int rd, int rn, | ||
22 | int rm, bool is_fp16, int data, | ||
23 | gen_helper_gvec_3_ptr *fn) | ||
24 | { | ||
25 | - TCGv_ptr fpst = fpstatus_ptr(is_fp16 ? FPST_FPCR_F16 : FPST_A64); | ||
26 | + TCGv_ptr fpst = fpstatus_ptr(is_fp16 ? FPST_A64_F16 : FPST_A64); | ||
27 | tcg_gen_gvec_3_ptr(vec_full_reg_offset(s, rd), | ||
28 | vec_full_reg_offset(s, rn), | ||
29 | vec_full_reg_offset(s, rm), fpst, | ||
30 | @@ -XXX,XX +XXX,XX @@ static void gen_gvec_op4_fpst(DisasContext *s, bool is_q, int rd, int rn, | ||
31 | int rm, int ra, bool is_fp16, int data, | ||
32 | gen_helper_gvec_4_ptr *fn) | ||
33 | { | ||
34 | - TCGv_ptr fpst = fpstatus_ptr(is_fp16 ? FPST_FPCR_F16 : FPST_A64); | ||
35 | + TCGv_ptr fpst = fpstatus_ptr(is_fp16 ? FPST_A64_F16 : FPST_A64); | ||
36 | tcg_gen_gvec_4_ptr(vec_full_reg_offset(s, rd), | ||
37 | vec_full_reg_offset(s, rn), | ||
38 | vec_full_reg_offset(s, rm), | ||
39 | @@ -XXX,XX +XXX,XX @@ static bool do_fp3_scalar(DisasContext *s, arg_rrr_e *a, const FPScalar *f) | ||
40 | if (fp_access_check(s)) { | ||
41 | TCGv_i32 t0 = read_fp_hreg(s, a->rn); | ||
42 | TCGv_i32 t1 = read_fp_hreg(s, a->rm); | ||
43 | - f->gen_h(t0, t0, t1, fpstatus_ptr(FPST_FPCR_F16)); | ||
44 | + f->gen_h(t0, t0, t1, fpstatus_ptr(FPST_A64_F16)); | ||
45 | write_fp_sreg(s, a->rd, t0); | ||
46 | } | ||
47 | break; | ||
48 | @@ -XXX,XX +XXX,XX @@ static bool do_fcmp0_s(DisasContext *s, arg_rr_e *a, | ||
49 | TCGv_i32 t0 = read_fp_hreg(s, a->rn); | ||
50 | TCGv_i32 t1 = tcg_constant_i32(0); | ||
51 | if (swap) { | ||
52 | - f->gen_h(t0, t1, t0, fpstatus_ptr(FPST_FPCR_F16)); | ||
53 | + f->gen_h(t0, t1, t0, fpstatus_ptr(FPST_A64_F16)); | ||
54 | } else { | ||
55 | - f->gen_h(t0, t0, t1, fpstatus_ptr(FPST_FPCR_F16)); | ||
56 | + f->gen_h(t0, t0, t1, fpstatus_ptr(FPST_A64_F16)); | ||
57 | } | ||
58 | write_fp_sreg(s, a->rd, t0); | ||
59 | } | ||
60 | @@ -XXX,XX +XXX,XX @@ static bool do_fp3_scalar_idx(DisasContext *s, arg_rrx_e *a, const FPScalar *f) | ||
61 | TCGv_i32 t1 = tcg_temp_new_i32(); | ||
62 | |||
63 | read_vec_element_i32(s, t1, a->rm, a->idx, MO_16); | ||
64 | - f->gen_h(t0, t0, t1, fpstatus_ptr(FPST_FPCR_F16)); | ||
65 | + f->gen_h(t0, t0, t1, fpstatus_ptr(FPST_A64_F16)); | ||
66 | write_fp_sreg(s, a->rd, t0); | ||
67 | } | ||
68 | break; | ||
69 | @@ -XXX,XX +XXX,XX @@ static bool do_fmla_scalar_idx(DisasContext *s, arg_rrx_e *a, bool neg) | ||
70 | gen_vfp_negh(t1, t1); | ||
71 | } | ||
72 | gen_helper_advsimd_muladdh(t0, t1, t2, t0, | ||
73 | - fpstatus_ptr(FPST_FPCR_F16)); | ||
74 | + fpstatus_ptr(FPST_A64_F16)); | ||
75 | write_fp_sreg(s, a->rd, t0); | ||
76 | } | ||
77 | break; | ||
78 | @@ -XXX,XX +XXX,XX @@ static bool do_fp3_scalar_pair(DisasContext *s, arg_rr_e *a, const FPScalar *f) | ||
79 | |||
80 | read_vec_element_i32(s, t0, a->rn, 0, MO_16); | ||
81 | read_vec_element_i32(s, t1, a->rn, 1, MO_16); | ||
82 | - f->gen_h(t0, t0, t1, fpstatus_ptr(FPST_FPCR_F16)); | ||
83 | + f->gen_h(t0, t0, t1, fpstatus_ptr(FPST_A64_F16)); | ||
84 | write_fp_sreg(s, a->rd, t0); | ||
85 | } | ||
86 | break; | ||
87 | @@ -XXX,XX +XXX,XX @@ static bool do_fmadd(DisasContext *s, arg_rrrr_e *a, bool neg_a, bool neg_n) | ||
88 | if (neg_n) { | ||
89 | gen_vfp_negh(tn, tn); | ||
90 | } | ||
91 | - fpst = fpstatus_ptr(FPST_FPCR_F16); | ||
92 | + fpst = fpstatus_ptr(FPST_A64_F16); | ||
93 | gen_helper_advsimd_muladdh(ta, tn, tm, ta, fpst); | ||
94 | write_fp_sreg(s, a->rd, ta); | ||
95 | } | ||
96 | @@ -XXX,XX +XXX,XX @@ static bool do_fp_reduction(DisasContext *s, arg_qrr_e *a, | ||
97 | if (fp_access_check(s)) { | ||
98 | MemOp esz = a->esz; | ||
99 | int elts = (a->q ? 16 : 8) >> esz; | ||
100 | - TCGv_ptr fpst = fpstatus_ptr(esz == MO_16 ? FPST_FPCR_F16 : FPST_A64); | ||
101 | + TCGv_ptr fpst = fpstatus_ptr(esz == MO_16 ? FPST_A64_F16 : FPST_A64); | ||
102 | TCGv_i32 res = do_reduction_op(s, a->rn, esz, 0, elts, fpst, fn); | ||
103 | write_fp_sreg(s, a->rd, res); | ||
104 | } | ||
105 | @@ -XXX,XX +XXX,XX @@ static void handle_fp_compare(DisasContext *s, int size, | ||
106 | bool cmp_with_zero, bool signal_all_nans) | ||
107 | { | ||
108 | TCGv_i64 tcg_flags = tcg_temp_new_i64(); | ||
109 | - TCGv_ptr fpst = fpstatus_ptr(size == MO_16 ? FPST_FPCR_F16 : FPST_A64); | ||
110 | + TCGv_ptr fpst = fpstatus_ptr(size == MO_16 ? FPST_A64_F16 : FPST_A64); | ||
111 | |||
112 | if (size == MO_64) { | ||
113 | TCGv_i64 tcg_vn, tcg_vm; | ||
114 | @@ -XXX,XX +XXX,XX @@ static bool do_fp1_scalar(DisasContext *s, arg_rr_e *a, | ||
115 | return check == 0; | ||
116 | } | ||
117 | |||
118 | - fpst = fpstatus_ptr(a->esz == MO_16 ? FPST_FPCR_F16 : FPST_A64); | ||
119 | + fpst = fpstatus_ptr(a->esz == MO_16 ? FPST_A64_F16 : FPST_A64); | ||
120 | if (rmode >= 0) { | ||
121 | tcg_rmode = gen_set_rmode(rmode, fpst); | ||
122 | } | ||
123 | @@ -XXX,XX +XXX,XX @@ static bool do_cvtf_scalar(DisasContext *s, MemOp esz, int rd, int shift, | ||
124 | TCGv_i32 tcg_shift, tcg_single; | ||
125 | TCGv_i64 tcg_double; | ||
126 | |||
127 | - tcg_fpstatus = fpstatus_ptr(esz == MO_16 ? FPST_FPCR_F16 : FPST_A64); | ||
128 | + tcg_fpstatus = fpstatus_ptr(esz == MO_16 ? FPST_A64_F16 : FPST_A64); | ||
129 | tcg_shift = tcg_constant_i32(shift); | ||
130 | |||
131 | switch (esz) { | ||
132 | @@ -XXX,XX +XXX,XX @@ static void do_fcvt_scalar(DisasContext *s, MemOp out, MemOp esz, | ||
133 | TCGv_ptr tcg_fpstatus; | ||
134 | TCGv_i32 tcg_shift, tcg_rmode, tcg_single; | ||
135 | |||
136 | - tcg_fpstatus = fpstatus_ptr(esz == MO_16 ? FPST_FPCR_F16 : FPST_A64); | ||
137 | + tcg_fpstatus = fpstatus_ptr(esz == MO_16 ? FPST_A64_F16 : FPST_A64); | ||
138 | tcg_shift = tcg_constant_i32(shift); | ||
139 | tcg_rmode = gen_set_rmode(rmode, tcg_fpstatus); | ||
140 | |||
141 | @@ -XXX,XX +XXX,XX @@ static bool do_fp1_vector(DisasContext *s, arg_qrr_e *a, | ||
142 | return check == 0; | ||
143 | } | ||
144 | |||
145 | - fpst = fpstatus_ptr(a->esz == MO_16 ? FPST_FPCR_F16 : FPST_A64); | ||
146 | + fpst = fpstatus_ptr(a->esz == MO_16 ? FPST_A64_F16 : FPST_A64); | ||
147 | if (rmode >= 0) { | ||
148 | tcg_rmode = gen_set_rmode(rmode, fpst); | ||
149 | } | ||
150 | @@ -XXX,XX +XXX,XX @@ static bool do_gvec_op2_fpst(DisasContext *s, MemOp esz, bool is_q, | ||
151 | return check == 0; | ||
152 | } | ||
153 | |||
154 | - fpst = fpstatus_ptr(esz == MO_16 ? FPST_FPCR_F16 : FPST_A64); | ||
155 | + fpst = fpstatus_ptr(esz == MO_16 ? FPST_A64_F16 : FPST_A64); | ||
156 | tcg_gen_gvec_2_ptr(vec_full_reg_offset(s, rd), | ||
157 | vec_full_reg_offset(s, rn), fpst, | ||
158 | is_q ? 16 : 8, vec_full_reg_size(s), | ||
159 | diff --git a/target/arm/tcg/translate-sve.c b/target/arm/tcg/translate-sve.c | ||
160 | index XXXXXXX..XXXXXXX 100644 | ||
161 | --- a/target/arm/tcg/translate-sve.c | ||
162 | +++ b/target/arm/tcg/translate-sve.c | ||
163 | @@ -XXX,XX +XXX,XX @@ static bool gen_gvec_fpst_arg_zz(DisasContext *s, gen_helper_gvec_2_ptr *fn, | ||
164 | arg_rr_esz *a, int data) | ||
165 | { | ||
166 | return gen_gvec_fpst_zz(s, fn, a->rd, a->rn, data, | ||
167 | - a->esz == MO_16 ? FPST_FPCR_F16 : FPST_A64); | ||
168 | + a->esz == MO_16 ? FPST_A64_F16 : FPST_A64); | ||
169 | } | ||
170 | |||
171 | /* Invoke an out-of-line helper on 3 Zregs. */ | ||
172 | @@ -XXX,XX +XXX,XX @@ static bool gen_gvec_fpst_arg_zzz(DisasContext *s, gen_helper_gvec_3_ptr *fn, | ||
173 | arg_rrr_esz *a, int data) | ||
174 | { | ||
175 | return gen_gvec_fpst_zzz(s, fn, a->rd, a->rn, a->rm, data, | ||
176 | - a->esz == MO_16 ? FPST_FPCR_F16 : FPST_A64); | ||
177 | + a->esz == MO_16 ? FPST_A64_F16 : FPST_A64); | ||
178 | } | ||
179 | |||
180 | /* Invoke an out-of-line helper on 4 Zregs. */ | ||
181 | @@ -XXX,XX +XXX,XX @@ static bool gen_gvec_fpst_arg_zpzz(DisasContext *s, gen_helper_gvec_4_ptr *fn, | ||
182 | arg_rprr_esz *a) | ||
183 | { | ||
184 | return gen_gvec_fpst_zzzp(s, fn, a->rd, a->rn, a->rm, a->pg, 0, | ||
185 | - a->esz == MO_16 ? FPST_FPCR_F16 : FPST_A64); | ||
186 | + a->esz == MO_16 ? FPST_A64_F16 : FPST_A64); | ||
187 | } | ||
188 | |||
189 | /* Invoke a vector expander on two Zregs and an immediate. */ | ||
190 | @@ -XXX,XX +XXX,XX @@ static bool do_FMLA_zzxz(DisasContext *s, arg_rrxr_esz *a, bool sub) | ||
191 | }; | ||
192 | return gen_gvec_fpst_zzzz(s, fns[a->esz], a->rd, a->rn, a->rm, a->ra, | ||
193 | (a->index << 1) | sub, | ||
194 | - a->esz == MO_16 ? FPST_FPCR_F16 : FPST_A64); | ||
195 | + a->esz == MO_16 ? FPST_A64_F16 : FPST_A64); | ||
196 | } | ||
197 | |||
198 | TRANS_FEAT(FMLA_zzxz, aa64_sve, do_FMLA_zzxz, a, false) | ||
199 | @@ -XXX,XX +XXX,XX @@ static gen_helper_gvec_3_ptr * const fmul_idx_fns[4] = { | ||
200 | }; | ||
201 | TRANS_FEAT(FMUL_zzx, aa64_sve, gen_gvec_fpst_zzz, | ||
202 | fmul_idx_fns[a->esz], a->rd, a->rn, a->rm, a->index, | ||
203 | - a->esz == MO_16 ? FPST_FPCR_F16 : FPST_A64) | ||
204 | + a->esz == MO_16 ? FPST_A64_F16 : FPST_A64) | ||
205 | |||
206 | /* | ||
207 | *** SVE Floating Point Fast Reduction Group | ||
208 | @@ -XXX,XX +XXX,XX @@ static bool do_reduce(DisasContext *s, arg_rpr_esz *a, | ||
209 | |||
210 | tcg_gen_addi_ptr(t_zn, tcg_env, vec_full_reg_offset(s, a->rn)); | ||
211 | tcg_gen_addi_ptr(t_pg, tcg_env, pred_full_reg_offset(s, a->pg)); | ||
212 | - status = fpstatus_ptr(a->esz == MO_16 ? FPST_FPCR_F16 : FPST_A64); | ||
213 | + status = fpstatus_ptr(a->esz == MO_16 ? FPST_A64_F16 : FPST_A64); | ||
214 | |||
215 | fn(temp, t_zn, t_pg, status, t_desc); | ||
216 | |||
217 | @@ -XXX,XX +XXX,XX @@ static bool do_ppz_fp(DisasContext *s, arg_rpr_esz *a, | ||
218 | if (sve_access_check(s)) { | ||
219 | unsigned vsz = vec_full_reg_size(s); | ||
220 | TCGv_ptr status = | ||
221 | - fpstatus_ptr(a->esz == MO_16 ? FPST_FPCR_F16 : FPST_A64); | ||
222 | + fpstatus_ptr(a->esz == MO_16 ? FPST_A64_F16 : FPST_A64); | ||
223 | |||
224 | tcg_gen_gvec_3_ptr(pred_full_reg_offset(s, a->rd), | ||
225 | vec_full_reg_offset(s, a->rn), | ||
226 | @@ -XXX,XX +XXX,XX @@ static gen_helper_gvec_3_ptr * const ftmad_fns[4] = { | ||
227 | }; | ||
228 | TRANS_FEAT_NONSTREAMING(FTMAD, aa64_sve, gen_gvec_fpst_zzz, | ||
229 | ftmad_fns[a->esz], a->rd, a->rn, a->rm, a->imm, | ||
230 | - a->esz == MO_16 ? FPST_FPCR_F16 : FPST_A64) | ||
231 | + a->esz == MO_16 ? FPST_A64_F16 : FPST_A64) | ||
232 | |||
233 | /* | ||
234 | *** SVE Floating Point Accumulating Reduction Group | ||
235 | @@ -XXX,XX +XXX,XX @@ static bool trans_FADDA(DisasContext *s, arg_rprr_esz *a) | ||
236 | t_pg = tcg_temp_new_ptr(); | ||
237 | tcg_gen_addi_ptr(t_rm, tcg_env, vec_full_reg_offset(s, a->rm)); | ||
238 | tcg_gen_addi_ptr(t_pg, tcg_env, pred_full_reg_offset(s, a->pg)); | ||
239 | - t_fpst = fpstatus_ptr(a->esz == MO_16 ? FPST_FPCR_F16 : FPST_A64); | ||
240 | + t_fpst = fpstatus_ptr(a->esz == MO_16 ? FPST_A64_F16 : FPST_A64); | ||
241 | t_desc = tcg_constant_i32(simd_desc(vsz, vsz, 0)); | ||
242 | |||
243 | fns[a->esz - 1](t_val, t_val, t_rm, t_pg, t_fpst, t_desc); | ||
244 | @@ -XXX,XX +XXX,XX @@ static void do_fp_scalar(DisasContext *s, int zd, int zn, int pg, bool is_fp16, | ||
245 | tcg_gen_addi_ptr(t_zn, tcg_env, vec_full_reg_offset(s, zn)); | ||
246 | tcg_gen_addi_ptr(t_pg, tcg_env, pred_full_reg_offset(s, pg)); | ||
247 | |||
248 | - status = fpstatus_ptr(is_fp16 ? FPST_FPCR_F16 : FPST_A64); | ||
249 | + status = fpstatus_ptr(is_fp16 ? FPST_A64_F16 : FPST_A64); | ||
250 | desc = tcg_constant_i32(simd_desc(vsz, vsz, 0)); | ||
251 | fn(t_zd, t_zn, t_pg, scalar, status, desc); | ||
252 | } | ||
253 | @@ -XXX,XX +XXX,XX @@ static bool do_fp_cmp(DisasContext *s, arg_rprr_esz *a, | ||
254 | } | ||
255 | if (sve_access_check(s)) { | ||
256 | unsigned vsz = vec_full_reg_size(s); | ||
257 | - TCGv_ptr status = fpstatus_ptr(a->esz == MO_16 ? FPST_FPCR_F16 : FPST_A64); | ||
258 | + TCGv_ptr status = fpstatus_ptr(a->esz == MO_16 ? FPST_A64_F16 : FPST_A64); | ||
259 | tcg_gen_gvec_4_ptr(pred_full_reg_offset(s, a->rd), | ||
260 | vec_full_reg_offset(s, a->rn), | ||
261 | vec_full_reg_offset(s, a->rm), | ||
262 | @@ -XXX,XX +XXX,XX @@ static gen_helper_gvec_4_ptr * const fcadd_fns[] = { | ||
263 | }; | ||
264 | TRANS_FEAT(FCADD, aa64_sve, gen_gvec_fpst_zzzp, fcadd_fns[a->esz], | ||
265 | a->rd, a->rn, a->rm, a->pg, a->rot, | ||
266 | - a->esz == MO_16 ? FPST_FPCR_F16 : FPST_A64) | ||
267 | + a->esz == MO_16 ? FPST_A64_F16 : FPST_A64) | ||
268 | |||
269 | #define DO_FMLA(NAME, name) \ | ||
270 | static gen_helper_gvec_5_ptr * const name##_fns[4] = { \ | ||
271 | @@ -XXX,XX +XXX,XX @@ TRANS_FEAT(FCADD, aa64_sve, gen_gvec_fpst_zzzp, fcadd_fns[a->esz], | ||
272 | }; \ | ||
273 | TRANS_FEAT(NAME, aa64_sve, gen_gvec_fpst_zzzzp, name##_fns[a->esz], \ | ||
274 | a->rd, a->rn, a->rm, a->ra, a->pg, 0, \ | ||
275 | - a->esz == MO_16 ? FPST_FPCR_F16 : FPST_A64) | ||
276 | + a->esz == MO_16 ? FPST_A64_F16 : FPST_A64) | ||
277 | |||
278 | DO_FMLA(FMLA_zpzzz, fmla_zpzzz) | ||
279 | DO_FMLA(FMLS_zpzzz, fmls_zpzzz) | ||
280 | @@ -XXX,XX +XXX,XX @@ static gen_helper_gvec_5_ptr * const fcmla_fns[4] = { | ||
281 | }; | ||
282 | TRANS_FEAT(FCMLA_zpzzz, aa64_sve, gen_gvec_fpst_zzzzp, fcmla_fns[a->esz], | ||
283 | a->rd, a->rn, a->rm, a->ra, a->pg, a->rot, | ||
284 | - a->esz == MO_16 ? FPST_FPCR_F16 : FPST_A64) | ||
285 | + a->esz == MO_16 ? FPST_A64_F16 : FPST_A64) | ||
286 | |||
287 | static gen_helper_gvec_4_ptr * const fcmla_idx_fns[4] = { | ||
288 | NULL, gen_helper_gvec_fcmlah_idx, gen_helper_gvec_fcmlas_idx, NULL | ||
289 | }; | ||
290 | TRANS_FEAT(FCMLA_zzxz, aa64_sve, gen_gvec_fpst_zzzz, fcmla_idx_fns[a->esz], | ||
291 | a->rd, a->rn, a->rm, a->ra, a->index * 4 + a->rot, | ||
292 | - a->esz == MO_16 ? FPST_FPCR_F16 : FPST_A64) | ||
293 | + a->esz == MO_16 ? FPST_A64_F16 : FPST_A64) | ||
294 | |||
295 | /* | ||
296 | *** SVE Floating Point Unary Operations Predicated Group | ||
297 | @@ -XXX,XX +XXX,XX @@ TRANS_FEAT(FCVT_sd, aa64_sve, gen_gvec_fpst_arg_zpz, | ||
298 | gen_helper_sve_fcvt_sd, a, 0, FPST_A64) | ||
299 | |||
300 | TRANS_FEAT(FCVTZS_hh, aa64_sve, gen_gvec_fpst_arg_zpz, | ||
301 | - gen_helper_sve_fcvtzs_hh, a, 0, FPST_FPCR_F16) | ||
302 | + gen_helper_sve_fcvtzs_hh, a, 0, FPST_A64_F16) | ||
303 | TRANS_FEAT(FCVTZU_hh, aa64_sve, gen_gvec_fpst_arg_zpz, | ||
304 | - gen_helper_sve_fcvtzu_hh, a, 0, FPST_FPCR_F16) | ||
305 | + gen_helper_sve_fcvtzu_hh, a, 0, FPST_A64_F16) | ||
306 | TRANS_FEAT(FCVTZS_hs, aa64_sve, gen_gvec_fpst_arg_zpz, | ||
307 | - gen_helper_sve_fcvtzs_hs, a, 0, FPST_FPCR_F16) | ||
308 | + gen_helper_sve_fcvtzs_hs, a, 0, FPST_A64_F16) | ||
309 | TRANS_FEAT(FCVTZU_hs, aa64_sve, gen_gvec_fpst_arg_zpz, | ||
310 | - gen_helper_sve_fcvtzu_hs, a, 0, FPST_FPCR_F16) | ||
311 | + gen_helper_sve_fcvtzu_hs, a, 0, FPST_A64_F16) | ||
312 | TRANS_FEAT(FCVTZS_hd, aa64_sve, gen_gvec_fpst_arg_zpz, | ||
313 | - gen_helper_sve_fcvtzs_hd, a, 0, FPST_FPCR_F16) | ||
314 | + gen_helper_sve_fcvtzs_hd, a, 0, FPST_A64_F16) | ||
315 | TRANS_FEAT(FCVTZU_hd, aa64_sve, gen_gvec_fpst_arg_zpz, | ||
316 | - gen_helper_sve_fcvtzu_hd, a, 0, FPST_FPCR_F16) | ||
317 | + gen_helper_sve_fcvtzu_hd, a, 0, FPST_A64_F16) | ||
318 | |||
319 | TRANS_FEAT(FCVTZS_ss, aa64_sve, gen_gvec_fpst_arg_zpz, | ||
320 | gen_helper_sve_fcvtzs_ss, a, 0, FPST_A64) | ||
321 | @@ -XXX,XX +XXX,XX @@ static gen_helper_gvec_3_ptr * const frint_fns[] = { | ||
322 | gen_helper_sve_frint_d | ||
323 | }; | ||
324 | TRANS_FEAT(FRINTI, aa64_sve, gen_gvec_fpst_arg_zpz, frint_fns[a->esz], | ||
325 | - a, 0, a->esz == MO_16 ? FPST_FPCR_F16 : FPST_A64) | ||
326 | + a, 0, a->esz == MO_16 ? FPST_A64_F16 : FPST_A64) | ||
327 | |||
328 | static gen_helper_gvec_3_ptr * const frintx_fns[] = { | ||
329 | NULL, | ||
330 | @@ -XXX,XX +XXX,XX @@ static gen_helper_gvec_3_ptr * const frintx_fns[] = { | ||
331 | gen_helper_sve_frintx_d | ||
332 | }; | ||
333 | TRANS_FEAT(FRINTX, aa64_sve, gen_gvec_fpst_arg_zpz, frintx_fns[a->esz], | ||
334 | - a, 0, a->esz == MO_16 ? FPST_FPCR_F16 : FPST_A64); | ||
335 | + a, 0, a->esz == MO_16 ? FPST_A64_F16 : FPST_A64); | ||
336 | |||
337 | static bool do_frint_mode(DisasContext *s, arg_rpr_esz *a, | ||
338 | ARMFPRounding mode, gen_helper_gvec_3_ptr *fn) | ||
339 | @@ -XXX,XX +XXX,XX @@ static bool do_frint_mode(DisasContext *s, arg_rpr_esz *a, | ||
340 | } | ||
341 | |||
342 | vsz = vec_full_reg_size(s); | ||
343 | - status = fpstatus_ptr(a->esz == MO_16 ? FPST_FPCR_F16 : FPST_A64); | ||
344 | + status = fpstatus_ptr(a->esz == MO_16 ? FPST_A64_F16 : FPST_A64); | ||
345 | tmode = gen_set_rmode(mode, status); | ||
346 | |||
347 | tcg_gen_gvec_3_ptr(vec_full_reg_offset(s, a->rd), | ||
348 | @@ -XXX,XX +XXX,XX @@ static gen_helper_gvec_3_ptr * const frecpx_fns[] = { | ||
349 | gen_helper_sve_frecpx_s, gen_helper_sve_frecpx_d, | ||
350 | }; | ||
351 | TRANS_FEAT(FRECPX, aa64_sve, gen_gvec_fpst_arg_zpz, frecpx_fns[a->esz], | ||
352 | - a, 0, a->esz == MO_16 ? FPST_FPCR_F16 : FPST_A64) | ||
353 | + a, 0, a->esz == MO_16 ? FPST_A64_F16 : FPST_A64) | ||
354 | |||
355 | static gen_helper_gvec_3_ptr * const fsqrt_fns[] = { | ||
356 | NULL, gen_helper_sve_fsqrt_h, | ||
357 | gen_helper_sve_fsqrt_s, gen_helper_sve_fsqrt_d, | ||
358 | }; | ||
359 | TRANS_FEAT(FSQRT, aa64_sve, gen_gvec_fpst_arg_zpz, fsqrt_fns[a->esz], | ||
360 | - a, 0, a->esz == MO_16 ? FPST_FPCR_F16 : FPST_A64) | ||
361 | + a, 0, a->esz == MO_16 ? FPST_A64_F16 : FPST_A64) | ||
362 | |||
363 | TRANS_FEAT(SCVTF_hh, aa64_sve, gen_gvec_fpst_arg_zpz, | ||
364 | - gen_helper_sve_scvt_hh, a, 0, FPST_FPCR_F16) | ||
365 | + gen_helper_sve_scvt_hh, a, 0, FPST_A64_F16) | ||
366 | TRANS_FEAT(SCVTF_sh, aa64_sve, gen_gvec_fpst_arg_zpz, | ||
367 | - gen_helper_sve_scvt_sh, a, 0, FPST_FPCR_F16) | ||
368 | + gen_helper_sve_scvt_sh, a, 0, FPST_A64_F16) | ||
369 | TRANS_FEAT(SCVTF_dh, aa64_sve, gen_gvec_fpst_arg_zpz, | ||
370 | - gen_helper_sve_scvt_dh, a, 0, FPST_FPCR_F16) | ||
371 | + gen_helper_sve_scvt_dh, a, 0, FPST_A64_F16) | ||
372 | |||
373 | TRANS_FEAT(SCVTF_ss, aa64_sve, gen_gvec_fpst_arg_zpz, | ||
374 | gen_helper_sve_scvt_ss, a, 0, FPST_A64) | ||
375 | @@ -XXX,XX +XXX,XX @@ TRANS_FEAT(SCVTF_dd, aa64_sve, gen_gvec_fpst_arg_zpz, | ||
376 | gen_helper_sve_scvt_dd, a, 0, FPST_A64) | ||
377 | |||
378 | TRANS_FEAT(UCVTF_hh, aa64_sve, gen_gvec_fpst_arg_zpz, | ||
379 | - gen_helper_sve_ucvt_hh, a, 0, FPST_FPCR_F16) | ||
380 | + gen_helper_sve_ucvt_hh, a, 0, FPST_A64_F16) | ||
381 | TRANS_FEAT(UCVTF_sh, aa64_sve, gen_gvec_fpst_arg_zpz, | ||
382 | - gen_helper_sve_ucvt_sh, a, 0, FPST_FPCR_F16) | ||
383 | + gen_helper_sve_ucvt_sh, a, 0, FPST_A64_F16) | ||
384 | TRANS_FEAT(UCVTF_dh, aa64_sve, gen_gvec_fpst_arg_zpz, | ||
385 | - gen_helper_sve_ucvt_dh, a, 0, FPST_FPCR_F16) | ||
386 | + gen_helper_sve_ucvt_dh, a, 0, FPST_A64_F16) | ||
387 | |||
388 | TRANS_FEAT(UCVTF_ss, aa64_sve, gen_gvec_fpst_arg_zpz, | ||
389 | gen_helper_sve_ucvt_ss, a, 0, FPST_A64) | ||
390 | @@ -XXX,XX +XXX,XX @@ static gen_helper_gvec_3_ptr * const flogb_fns[] = { | ||
391 | gen_helper_flogb_s, gen_helper_flogb_d | ||
392 | }; | ||
393 | TRANS_FEAT(FLOGB, aa64_sve2, gen_gvec_fpst_arg_zpz, flogb_fns[a->esz], | ||
394 | - a, 0, a->esz == MO_16 ? FPST_FPCR_F16 : FPST_A64) | ||
395 | + a, 0, a->esz == MO_16 ? FPST_A64_F16 : FPST_A64) | ||
396 | |||
397 | static bool do_FMLAL_zzzw(DisasContext *s, arg_rrrr_esz *a, bool sub, bool sel) | ||
398 | { | ||
399 | -- | ||
400 | 2.34.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Now we have moved all the uses of vfp.fp_status_f16 and FPST_FPCR_F16 | ||
2 | to the new A32 or A64 fields, we can remove these. | ||
1 | 3 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20250124162836.2332150-19-peter.maydell@linaro.org | ||
7 | --- | ||
8 | target/arm/cpu.h | 2 -- | ||
9 | target/arm/tcg/translate.h | 6 ------ | ||
10 | target/arm/cpu.c | 1 - | ||
11 | target/arm/vfp_helper.c | 7 ------- | ||
12 | 4 files changed, 16 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 @@ typedef struct CPUArchState { | ||
19 | * | ||
20 | * fp_status_a32: is the "normal" fp status for AArch32 insns | ||
21 | * fp_status_a64: is the "normal" fp status for AArch64 insns | ||
22 | - * fp_status_fp16: used for half-precision calculations | ||
23 | * fp_status_fp16_a32: used for AArch32 half-precision calculations | ||
24 | * fp_status_fp16_a64: used for AArch64 half-precision calculations | ||
25 | * standard_fp_status : the ARM "Standard FPSCR Value" | ||
26 | @@ -XXX,XX +XXX,XX @@ typedef struct CPUArchState { | ||
27 | */ | ||
28 | float_status fp_status_a32; | ||
29 | float_status fp_status_a64; | ||
30 | - float_status fp_status_f16; | ||
31 | float_status fp_status_f16_a32; | ||
32 | float_status fp_status_f16_a64; | ||
33 | float_status standard_fp_status; | ||
34 | diff --git a/target/arm/tcg/translate.h b/target/arm/tcg/translate.h | ||
35 | index XXXXXXX..XXXXXXX 100644 | ||
36 | --- a/target/arm/tcg/translate.h | ||
37 | +++ b/target/arm/tcg/translate.h | ||
38 | @@ -XXX,XX +XXX,XX @@ static inline CPUARMTBFlags arm_tbflags_from_tb(const TranslationBlock *tb) | ||
39 | typedef enum ARMFPStatusFlavour { | ||
40 | FPST_A32, | ||
41 | FPST_A64, | ||
42 | - FPST_FPCR_F16, | ||
43 | FPST_A32_F16, | ||
44 | FPST_A64_F16, | ||
45 | FPST_STD, | ||
46 | @@ -XXX,XX +XXX,XX @@ typedef enum ARMFPStatusFlavour { | ||
47 | * for AArch32 non-FP16 operations controlled by the FPCR | ||
48 | * FPST_A64 | ||
49 | * for AArch64 non-FP16 operations controlled by the FPCR | ||
50 | - * FPST_FPCR_F16 | ||
51 | - * for operations controlled by the FPCR where FPCR.FZ16 is to be used | ||
52 | * FPST_A32_F16 | ||
53 | * for AArch32 operations controlled by the FPCR where FPCR.FZ16 is to be used | ||
54 | * FPST_A64_F16 | ||
55 | @@ -XXX,XX +XXX,XX @@ static inline TCGv_ptr fpstatus_ptr(ARMFPStatusFlavour flavour) | ||
56 | case FPST_A64: | ||
57 | offset = offsetof(CPUARMState, vfp.fp_status_a64); | ||
58 | break; | ||
59 | - case FPST_FPCR_F16: | ||
60 | - offset = offsetof(CPUARMState, vfp.fp_status_f16); | ||
61 | - break; | ||
62 | case FPST_A32_F16: | ||
63 | offset = offsetof(CPUARMState, vfp.fp_status_f16_a32); | ||
64 | break; | ||
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_reset_hold(Object *obj, ResetType type) | ||
70 | arm_set_default_fp_behaviours(&env->vfp.fp_status_a32); | ||
71 | arm_set_default_fp_behaviours(&env->vfp.fp_status_a64); | ||
72 | arm_set_default_fp_behaviours(&env->vfp.standard_fp_status); | ||
73 | - arm_set_default_fp_behaviours(&env->vfp.fp_status_f16); | ||
74 | arm_set_default_fp_behaviours(&env->vfp.fp_status_f16_a32); | ||
75 | arm_set_default_fp_behaviours(&env->vfp.fp_status_f16_a64); | ||
76 | arm_set_default_fp_behaviours(&env->vfp.standard_fp_status_f16); | ||
77 | diff --git a/target/arm/vfp_helper.c b/target/arm/vfp_helper.c | ||
78 | index XXXXXXX..XXXXXXX 100644 | ||
79 | --- a/target/arm/vfp_helper.c | ||
80 | +++ b/target/arm/vfp_helper.c | ||
81 | @@ -XXX,XX +XXX,XX @@ static uint32_t vfp_get_fpsr_from_host(CPUARMState *env) | ||
82 | i |= get_float_exception_flags(&env->vfp.fp_status_a64); | ||
83 | i |= get_float_exception_flags(&env->vfp.standard_fp_status); | ||
84 | /* FZ16 does not generate an input denormal exception. */ | ||
85 | - i |= (get_float_exception_flags(&env->vfp.fp_status_f16) | ||
86 | - & ~float_flag_input_denormal); | ||
87 | i |= (get_float_exception_flags(&env->vfp.fp_status_f16_a32) | ||
88 | & ~float_flag_input_denormal); | ||
89 | i |= (get_float_exception_flags(&env->vfp.fp_status_f16_a64) | ||
90 | @@ -XXX,XX +XXX,XX @@ static void vfp_clear_float_status_exc_flags(CPUARMState *env) | ||
91 | */ | ||
92 | set_float_exception_flags(0, &env->vfp.fp_status_a32); | ||
93 | set_float_exception_flags(0, &env->vfp.fp_status_a64); | ||
94 | - set_float_exception_flags(0, &env->vfp.fp_status_f16); | ||
95 | set_float_exception_flags(0, &env->vfp.fp_status_f16_a32); | ||
96 | set_float_exception_flags(0, &env->vfp.fp_status_f16_a64); | ||
97 | set_float_exception_flags(0, &env->vfp.standard_fp_status); | ||
98 | @@ -XXX,XX +XXX,XX @@ static void vfp_set_fpcr_to_host(CPUARMState *env, uint32_t val, uint32_t mask) | ||
99 | } | ||
100 | set_float_rounding_mode(i, &env->vfp.fp_status_a32); | ||
101 | set_float_rounding_mode(i, &env->vfp.fp_status_a64); | ||
102 | - set_float_rounding_mode(i, &env->vfp.fp_status_f16); | ||
103 | set_float_rounding_mode(i, &env->vfp.fp_status_f16_a32); | ||
104 | set_float_rounding_mode(i, &env->vfp.fp_status_f16_a64); | ||
105 | } | ||
106 | if (changed & FPCR_FZ16) { | ||
107 | bool ftz_enabled = val & FPCR_FZ16; | ||
108 | - set_flush_to_zero(ftz_enabled, &env->vfp.fp_status_f16); | ||
109 | set_flush_to_zero(ftz_enabled, &env->vfp.fp_status_f16_a32); | ||
110 | set_flush_to_zero(ftz_enabled, &env->vfp.fp_status_f16_a64); | ||
111 | set_flush_to_zero(ftz_enabled, &env->vfp.standard_fp_status_f16); | ||
112 | - set_flush_inputs_to_zero(ftz_enabled, &env->vfp.fp_status_f16); | ||
113 | set_flush_inputs_to_zero(ftz_enabled, &env->vfp.fp_status_f16_a32); | ||
114 | set_flush_inputs_to_zero(ftz_enabled, &env->vfp.fp_status_f16_a64); | ||
115 | set_flush_inputs_to_zero(ftz_enabled, &env->vfp.standard_fp_status_f16); | ||
116 | @@ -XXX,XX +XXX,XX @@ static void vfp_set_fpcr_to_host(CPUARMState *env, uint32_t val, uint32_t mask) | ||
117 | bool dnan_enabled = val & FPCR_DN; | ||
118 | set_default_nan_mode(dnan_enabled, &env->vfp.fp_status_a32); | ||
119 | set_default_nan_mode(dnan_enabled, &env->vfp.fp_status_a64); | ||
120 | - set_default_nan_mode(dnan_enabled, &env->vfp.fp_status_f16); | ||
121 | set_default_nan_mode(dnan_enabled, &env->vfp.fp_status_f16_a32); | ||
122 | set_default_nan_mode(dnan_enabled, &env->vfp.fp_status_f16_a64); | ||
123 | } | ||
124 | -- | ||
125 | 2.34.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | 1 | Our float_flag_input_denormal exception flag is set when the fpu code | |
2 | flushes an input denormal to zero. This is what many guest | ||
3 | architectures (eg classic Arm behaviour) require, but it is not the | ||
4 | only donarmal-related reason we might want to set an exception flag. | ||
5 | The x86 behaviour (which we do not currently model correctly) wants | ||
6 | to see an exception flag when a denormal input is *not* flushed to | ||
7 | zero and is actually used in an arithmetic operation. Arm's FEAT_AFP | ||
8 | also wants these semantics. | ||
9 | |||
10 | Rename float_flag_input_denormal to float_flag_input_denormal_flushed | ||
11 | to make it clearer when it is set and to allow us to add a new | ||
12 | float_flag_input_denormal_used next to it for the x86/FEAT_AFP | ||
13 | semantics. | ||
14 | |||
15 | Commit created with | ||
16 | for f in `git grep -l float_flag_input_denormal`; do sed -i -e 's/float_flag_input_denormal/float_flag_input_denormal_flushed/' $f; done | ||
17 | |||
18 | and manual editing of softfloat-types.h and softfloat.c to clean | ||
19 | up the indentation afterwards and to fix a comment which wasn't | ||
20 | using the full name of the flag. | ||
21 | |||
22 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
23 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
24 | Message-id: 20250124162836.2332150-20-peter.maydell@linaro.org | ||
25 | --- | ||
26 | include/fpu/softfloat-types.h | 5 +++-- | ||
27 | fpu/softfloat.c | 4 ++-- | ||
28 | target/arm/tcg/sve_helper.c | 6 +++--- | ||
29 | target/arm/vfp_helper.c | 10 +++++----- | ||
30 | target/i386/tcg/fpu_helper.c | 6 +++--- | ||
31 | target/mips/tcg/msa_helper.c | 2 +- | ||
32 | target/rx/op_helper.c | 2 +- | ||
33 | fpu/softfloat-parts.c.inc | 2 +- | ||
34 | 8 files changed, 19 insertions(+), 18 deletions(-) | ||
35 | |||
36 | diff --git a/include/fpu/softfloat-types.h b/include/fpu/softfloat-types.h | ||
37 | index XXXXXXX..XXXXXXX 100644 | ||
38 | --- a/include/fpu/softfloat-types.h | ||
39 | +++ b/include/fpu/softfloat-types.h | ||
40 | @@ -XXX,XX +XXX,XX @@ enum { | ||
41 | float_flag_overflow = 0x0004, | ||
42 | float_flag_underflow = 0x0008, | ||
43 | float_flag_inexact = 0x0010, | ||
44 | - float_flag_input_denormal = 0x0020, | ||
45 | + /* We flushed an input denormal to 0 (because of flush_inputs_to_zero) */ | ||
46 | + float_flag_input_denormal_flushed = 0x0020, | ||
47 | float_flag_output_denormal = 0x0040, | ||
48 | float_flag_invalid_isi = 0x0080, /* inf - inf */ | ||
49 | float_flag_invalid_imz = 0x0100, /* inf * 0 */ | ||
50 | @@ -XXX,XX +XXX,XX @@ typedef struct float_status { | ||
51 | bool tininess_before_rounding; | ||
52 | /* should denormalised results go to zero and set the inexact flag? */ | ||
53 | bool flush_to_zero; | ||
54 | - /* should denormalised inputs go to zero and set the input_denormal flag? */ | ||
55 | + /* should denormalised inputs go to zero and set input_denormal_flushed? */ | ||
56 | bool flush_inputs_to_zero; | ||
57 | bool default_nan_mode; | ||
58 | /* | ||
59 | diff --git a/fpu/softfloat.c b/fpu/softfloat.c | ||
60 | index XXXXXXX..XXXXXXX 100644 | ||
61 | --- a/fpu/softfloat.c | ||
62 | +++ b/fpu/softfloat.c | ||
63 | @@ -XXX,XX +XXX,XX @@ this code that are retained. | ||
64 | if (unlikely(soft_t ## _is_denormal(*a))) { \ | ||
65 | *a = soft_t ## _set_sign(soft_t ## _zero, \ | ||
66 | soft_t ## _is_neg(*a)); \ | ||
67 | - float_raise(float_flag_input_denormal, s); \ | ||
68 | + float_raise(float_flag_input_denormal_flushed, s); \ | ||
69 | } \ | ||
70 | } | ||
71 | |||
72 | @@ -XXX,XX +XXX,XX @@ float128 float128_silence_nan(float128 a, float_status *status) | ||
73 | static bool parts_squash_denormal(FloatParts64 p, float_status *status) | ||
74 | { | ||
75 | if (p.exp == 0 && p.frac != 0) { | ||
76 | - float_raise(float_flag_input_denormal, status); | ||
77 | + float_raise(float_flag_input_denormal_flushed, status); | ||
78 | return true; | ||
79 | } | ||
80 | |||
81 | diff --git a/target/arm/tcg/sve_helper.c b/target/arm/tcg/sve_helper.c | ||
82 | index XXXXXXX..XXXXXXX 100644 | ||
83 | --- a/target/arm/tcg/sve_helper.c | ||
84 | +++ b/target/arm/tcg/sve_helper.c | ||
85 | @@ -XXX,XX +XXX,XX @@ static int16_t do_float16_logb_as_int(float16 a, float_status *s) | ||
86 | return -15 - clz32(frac); | ||
87 | } | ||
88 | /* flush to zero */ | ||
89 | - float_raise(float_flag_input_denormal, s); | ||
90 | + float_raise(float_flag_input_denormal_flushed, s); | ||
91 | } | ||
92 | } else if (unlikely(exp == 0x1f)) { | ||
93 | if (frac == 0) { | ||
94 | @@ -XXX,XX +XXX,XX @@ static int32_t do_float32_logb_as_int(float32 a, float_status *s) | ||
95 | return -127 - clz32(frac); | ||
96 | } | ||
97 | /* flush to zero */ | ||
98 | - float_raise(float_flag_input_denormal, s); | ||
99 | + float_raise(float_flag_input_denormal_flushed, s); | ||
100 | } | ||
101 | } else if (unlikely(exp == 0xff)) { | ||
102 | if (frac == 0) { | ||
103 | @@ -XXX,XX +XXX,XX @@ static int64_t do_float64_logb_as_int(float64 a, float_status *s) | ||
104 | return -1023 - clz64(frac); | ||
105 | } | ||
106 | /* flush to zero */ | ||
107 | - float_raise(float_flag_input_denormal, s); | ||
108 | + float_raise(float_flag_input_denormal_flushed, s); | ||
109 | } | ||
110 | } else if (unlikely(exp == 0x7ff)) { | ||
111 | if (frac == 0) { | ||
112 | diff --git a/target/arm/vfp_helper.c b/target/arm/vfp_helper.c | ||
113 | index XXXXXXX..XXXXXXX 100644 | ||
114 | --- a/target/arm/vfp_helper.c | ||
115 | +++ b/target/arm/vfp_helper.c | ||
116 | @@ -XXX,XX +XXX,XX @@ static inline uint32_t vfp_exceptbits_from_host(int host_bits) | ||
117 | if (host_bits & float_flag_inexact) { | ||
118 | target_bits |= FPSR_IXC; | ||
119 | } | ||
120 | - if (host_bits & float_flag_input_denormal) { | ||
121 | + if (host_bits & float_flag_input_denormal_flushed) { | ||
122 | target_bits |= FPSR_IDC; | ||
123 | } | ||
124 | return target_bits; | ||
125 | @@ -XXX,XX +XXX,XX @@ static uint32_t vfp_get_fpsr_from_host(CPUARMState *env) | ||
126 | i |= get_float_exception_flags(&env->vfp.standard_fp_status); | ||
127 | /* FZ16 does not generate an input denormal exception. */ | ||
128 | i |= (get_float_exception_flags(&env->vfp.fp_status_f16_a32) | ||
129 | - & ~float_flag_input_denormal); | ||
130 | + & ~float_flag_input_denormal_flushed); | ||
131 | i |= (get_float_exception_flags(&env->vfp.fp_status_f16_a64) | ||
132 | - & ~float_flag_input_denormal); | ||
133 | + & ~float_flag_input_denormal_flushed); | ||
134 | i |= (get_float_exception_flags(&env->vfp.standard_fp_status_f16) | ||
135 | - & ~float_flag_input_denormal); | ||
136 | + & ~float_flag_input_denormal_flushed); | ||
137 | return vfp_exceptbits_from_host(i); | ||
138 | } | ||
139 | |||
140 | @@ -XXX,XX +XXX,XX @@ uint64_t HELPER(fjcvtzs)(float64 value, float_status *status) | ||
141 | |||
142 | /* Normal inexact, denormal with flush-to-zero, or overflow or NaN */ | ||
143 | inexact = e_new & (float_flag_inexact | | ||
144 | - float_flag_input_denormal | | ||
145 | + float_flag_input_denormal_flushed | | ||
146 | float_flag_invalid); | ||
147 | |||
148 | /* While not inexact for IEEE FP, -0.0 is inexact for JavaScript. */ | ||
149 | diff --git a/target/i386/tcg/fpu_helper.c b/target/i386/tcg/fpu_helper.c | ||
150 | index XXXXXXX..XXXXXXX 100644 | ||
151 | --- a/target/i386/tcg/fpu_helper.c | ||
152 | +++ b/target/i386/tcg/fpu_helper.c | ||
153 | @@ -XXX,XX +XXX,XX @@ static void merge_exception_flags(CPUX86State *env, uint8_t old_flags) | ||
154 | (new_flags & float_flag_overflow ? FPUS_OE : 0) | | ||
155 | (new_flags & float_flag_underflow ? FPUS_UE : 0) | | ||
156 | (new_flags & float_flag_inexact ? FPUS_PE : 0) | | ||
157 | - (new_flags & float_flag_input_denormal ? FPUS_DE : 0))); | ||
158 | + (new_flags & float_flag_input_denormal_flushed ? FPUS_DE : 0))); | ||
159 | } | ||
160 | |||
161 | static inline floatx80 helper_fdiv(CPUX86State *env, floatx80 a, floatx80 b) | ||
162 | @@ -XXX,XX +XXX,XX @@ void helper_fxtract(CPUX86State *env) | ||
163 | int shift = clz64(temp.l.lower); | ||
164 | temp.l.lower <<= shift; | ||
165 | expdif = 1 - EXPBIAS - shift; | ||
166 | - float_raise(float_flag_input_denormal, &env->fp_status); | ||
167 | + float_raise(float_flag_input_denormal_flushed, &env->fp_status); | ||
168 | } else { | ||
169 | expdif = EXPD(temp) - EXPBIAS; | ||
170 | } | ||
171 | @@ -XXX,XX +XXX,XX @@ void update_mxcsr_from_sse_status(CPUX86State *env) | ||
172 | uint8_t flags = get_float_exception_flags(&env->sse_status); | ||
173 | /* | ||
174 | * The MXCSR denormal flag has opposite semantics to | ||
175 | - * float_flag_input_denormal (the softfloat code sets that flag | ||
176 | + * float_flag_input_denormal_flushed (the softfloat code sets that flag | ||
177 | * only when flushing input denormals to zero, but SSE sets it | ||
178 | * only when not flushing them to zero), so is not converted | ||
179 | * here. | ||
180 | diff --git a/target/mips/tcg/msa_helper.c b/target/mips/tcg/msa_helper.c | ||
181 | index XXXXXXX..XXXXXXX 100644 | ||
182 | --- a/target/mips/tcg/msa_helper.c | ||
183 | +++ b/target/mips/tcg/msa_helper.c | ||
184 | @@ -XXX,XX +XXX,XX @@ static inline int update_msacsr(CPUMIPSState *env, int action, int denormal) | ||
185 | enable = GET_FP_ENABLE(env->active_tc.msacsr) | FP_UNIMPLEMENTED; | ||
186 | |||
187 | /* Set Inexact (I) when flushing inputs to zero */ | ||
188 | - if ((ieee_exception_flags & float_flag_input_denormal) && | ||
189 | + if ((ieee_exception_flags & float_flag_input_denormal_flushed) && | ||
190 | (env->active_tc.msacsr & MSACSR_FS_MASK) != 0) { | ||
191 | if (action & CLEAR_IS_INEXACT) { | ||
192 | mips_exception_flags &= ~FP_INEXACT; | ||
193 | diff --git a/target/rx/op_helper.c b/target/rx/op_helper.c | ||
194 | index XXXXXXX..XXXXXXX 100644 | ||
195 | --- a/target/rx/op_helper.c | ||
196 | +++ b/target/rx/op_helper.c | ||
197 | @@ -XXX,XX +XXX,XX @@ static void update_fpsw(CPURXState *env, float32 ret, uintptr_t retaddr) | ||
198 | if (xcpt & float_flag_inexact) { | ||
199 | SET_FPSW(X); | ||
200 | } | ||
201 | - if ((xcpt & (float_flag_input_denormal | ||
202 | + if ((xcpt & (float_flag_input_denormal_flushed | ||
203 | | float_flag_output_denormal)) | ||
204 | && !FIELD_EX32(env->fpsw, FPSW, DN)) { | ||
205 | env->fpsw = FIELD_DP32(env->fpsw, FPSW, CE, 1); | ||
206 | diff --git a/fpu/softfloat-parts.c.inc b/fpu/softfloat-parts.c.inc | ||
207 | index XXXXXXX..XXXXXXX 100644 | ||
208 | --- a/fpu/softfloat-parts.c.inc | ||
209 | +++ b/fpu/softfloat-parts.c.inc | ||
210 | @@ -XXX,XX +XXX,XX @@ static void partsN(canonicalize)(FloatPartsN *p, float_status *status, | ||
211 | if (likely(frac_eqz(p))) { | ||
212 | p->cls = float_class_zero; | ||
213 | } else if (status->flush_inputs_to_zero) { | ||
214 | - float_raise(float_flag_input_denormal, status); | ||
215 | + float_raise(float_flag_input_denormal_flushed, status); | ||
216 | p->cls = float_class_zero; | ||
217 | frac_clear(p); | ||
218 | } else { | ||
219 | -- | ||
220 | 2.34.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Our float_flag_output_denormal exception flag is set when | ||
2 | the fpu code flushes an output denormal to zero. Rename | ||
3 | it to float_flag_output_denormal_flushed: | ||
4 | * this keeps it parallel with the flag for flushing | ||
5 | input denormals, which we just renamed | ||
6 | * it makes it clearer that it doesn't mean "set when | ||
7 | the output is a denormal" | ||
1 | 8 | ||
9 | Commit created with | ||
10 | for f in `git grep -l float_flag_output_denormal`; do sed -i -e 's/float_flag_output_denormal/float_flag_output_denormal_flushed/' $f; done | ||
11 | |||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
14 | Message-id: 20250124162836.2332150-21-peter.maydell@linaro.org | ||
15 | --- | ||
16 | include/fpu/softfloat-types.h | 3 ++- | ||
17 | fpu/softfloat.c | 2 +- | ||
18 | target/arm/vfp_helper.c | 2 +- | ||
19 | target/i386/tcg/fpu_helper.c | 2 +- | ||
20 | target/m68k/fpu_helper.c | 2 +- | ||
21 | target/mips/tcg/msa_helper.c | 2 +- | ||
22 | target/rx/op_helper.c | 2 +- | ||
23 | target/tricore/fpu_helper.c | 6 +++--- | ||
24 | fpu/softfloat-parts.c.inc | 2 +- | ||
25 | 9 files changed, 12 insertions(+), 11 deletions(-) | ||
26 | |||
27 | diff --git a/include/fpu/softfloat-types.h b/include/fpu/softfloat-types.h | ||
28 | index XXXXXXX..XXXXXXX 100644 | ||
29 | --- a/include/fpu/softfloat-types.h | ||
30 | +++ b/include/fpu/softfloat-types.h | ||
31 | @@ -XXX,XX +XXX,XX @@ enum { | ||
32 | float_flag_inexact = 0x0010, | ||
33 | /* We flushed an input denormal to 0 (because of flush_inputs_to_zero) */ | ||
34 | float_flag_input_denormal_flushed = 0x0020, | ||
35 | - float_flag_output_denormal = 0x0040, | ||
36 | + /* We flushed an output denormal to 0 (because of flush_to_zero) */ | ||
37 | + float_flag_output_denormal_flushed = 0x0040, | ||
38 | float_flag_invalid_isi = 0x0080, /* inf - inf */ | ||
39 | float_flag_invalid_imz = 0x0100, /* inf * 0 */ | ||
40 | float_flag_invalid_idi = 0x0200, /* inf / inf */ | ||
41 | diff --git a/fpu/softfloat.c b/fpu/softfloat.c | ||
42 | index XXXXXXX..XXXXXXX 100644 | ||
43 | --- a/fpu/softfloat.c | ||
44 | +++ b/fpu/softfloat.c | ||
45 | @@ -XXX,XX +XXX,XX @@ floatx80 roundAndPackFloatx80(FloatX80RoundPrec roundingPrecision, bool zSign, | ||
46 | } | ||
47 | if ( zExp <= 0 ) { | ||
48 | if (status->flush_to_zero) { | ||
49 | - float_raise(float_flag_output_denormal, status); | ||
50 | + float_raise(float_flag_output_denormal_flushed, status); | ||
51 | return packFloatx80(zSign, 0, 0); | ||
52 | } | ||
53 | isTiny = status->tininess_before_rounding | ||
54 | diff --git a/target/arm/vfp_helper.c b/target/arm/vfp_helper.c | ||
55 | index XXXXXXX..XXXXXXX 100644 | ||
56 | --- a/target/arm/vfp_helper.c | ||
57 | +++ b/target/arm/vfp_helper.c | ||
58 | @@ -XXX,XX +XXX,XX @@ static inline uint32_t vfp_exceptbits_from_host(int host_bits) | ||
59 | if (host_bits & float_flag_overflow) { | ||
60 | target_bits |= FPSR_OFC; | ||
61 | } | ||
62 | - if (host_bits & (float_flag_underflow | float_flag_output_denormal)) { | ||
63 | + if (host_bits & (float_flag_underflow | float_flag_output_denormal_flushed)) { | ||
64 | target_bits |= FPSR_UFC; | ||
65 | } | ||
66 | if (host_bits & float_flag_inexact) { | ||
67 | diff --git a/target/i386/tcg/fpu_helper.c b/target/i386/tcg/fpu_helper.c | ||
68 | index XXXXXXX..XXXXXXX 100644 | ||
69 | --- a/target/i386/tcg/fpu_helper.c | ||
70 | +++ b/target/i386/tcg/fpu_helper.c | ||
71 | @@ -XXX,XX +XXX,XX @@ void update_mxcsr_from_sse_status(CPUX86State *env) | ||
72 | (flags & float_flag_overflow ? FPUS_OE : 0) | | ||
73 | (flags & float_flag_underflow ? FPUS_UE : 0) | | ||
74 | (flags & float_flag_inexact ? FPUS_PE : 0) | | ||
75 | - (flags & float_flag_output_denormal ? FPUS_UE | FPUS_PE : | ||
76 | + (flags & float_flag_output_denormal_flushed ? FPUS_UE | FPUS_PE : | ||
77 | 0)); | ||
78 | } | ||
79 | |||
80 | diff --git a/target/m68k/fpu_helper.c b/target/m68k/fpu_helper.c | ||
81 | index XXXXXXX..XXXXXXX 100644 | ||
82 | --- a/target/m68k/fpu_helper.c | ||
83 | +++ b/target/m68k/fpu_helper.c | ||
84 | @@ -XXX,XX +XXX,XX @@ static int cpu_m68k_exceptbits_from_host(int host_bits) | ||
85 | if (host_bits & float_flag_overflow) { | ||
86 | target_bits |= 0x40; | ||
87 | } | ||
88 | - if (host_bits & (float_flag_underflow | float_flag_output_denormal)) { | ||
89 | + if (host_bits & (float_flag_underflow | float_flag_output_denormal_flushed)) { | ||
90 | target_bits |= 0x20; | ||
91 | } | ||
92 | if (host_bits & float_flag_divbyzero) { | ||
93 | diff --git a/target/mips/tcg/msa_helper.c b/target/mips/tcg/msa_helper.c | ||
94 | index XXXXXXX..XXXXXXX 100644 | ||
95 | --- a/target/mips/tcg/msa_helper.c | ||
96 | +++ b/target/mips/tcg/msa_helper.c | ||
97 | @@ -XXX,XX +XXX,XX @@ static inline int update_msacsr(CPUMIPSState *env, int action, int denormal) | ||
98 | } | ||
99 | |||
100 | /* Set Inexact (I) and Underflow (U) when flushing outputs to zero */ | ||
101 | - if ((ieee_exception_flags & float_flag_output_denormal) && | ||
102 | + if ((ieee_exception_flags & float_flag_output_denormal_flushed) && | ||
103 | (env->active_tc.msacsr & MSACSR_FS_MASK) != 0) { | ||
104 | mips_exception_flags |= FP_INEXACT; | ||
105 | if (action & CLEAR_FS_UNDERFLOW) { | ||
106 | diff --git a/target/rx/op_helper.c b/target/rx/op_helper.c | ||
107 | index XXXXXXX..XXXXXXX 100644 | ||
108 | --- a/target/rx/op_helper.c | ||
109 | +++ b/target/rx/op_helper.c | ||
110 | @@ -XXX,XX +XXX,XX @@ static void update_fpsw(CPURXState *env, float32 ret, uintptr_t retaddr) | ||
111 | SET_FPSW(X); | ||
112 | } | ||
113 | if ((xcpt & (float_flag_input_denormal_flushed | ||
114 | - | float_flag_output_denormal)) | ||
115 | + | float_flag_output_denormal_flushed)) | ||
116 | && !FIELD_EX32(env->fpsw, FPSW, DN)) { | ||
117 | env->fpsw = FIELD_DP32(env->fpsw, FPSW, CE, 1); | ||
118 | } | ||
119 | diff --git a/target/tricore/fpu_helper.c b/target/tricore/fpu_helper.c | ||
120 | index XXXXXXX..XXXXXXX 100644 | ||
121 | --- a/target/tricore/fpu_helper.c | ||
122 | +++ b/target/tricore/fpu_helper.c | ||
123 | @@ -XXX,XX +XXX,XX @@ static inline uint8_t f_get_excp_flags(CPUTriCoreState *env) | ||
124 | & (float_flag_invalid | ||
125 | | float_flag_overflow | ||
126 | | float_flag_underflow | ||
127 | - | float_flag_output_denormal | ||
128 | + | float_flag_output_denormal_flushed | ||
129 | | float_flag_divbyzero | ||
130 | | float_flag_inexact); | ||
131 | } | ||
132 | @@ -XXX,XX +XXX,XX @@ static void f_update_psw_flags(CPUTriCoreState *env, uint8_t flags) | ||
133 | some_excp = 1; | ||
134 | } | ||
135 | |||
136 | - if (flags & float_flag_underflow || flags & float_flag_output_denormal) { | ||
137 | + if (flags & float_flag_underflow || flags & float_flag_output_denormal_flushed) { | ||
138 | env->FPU_FU = 1 << 31; | ||
139 | some_excp = 1; | ||
140 | } | ||
141 | @@ -XXX,XX +XXX,XX @@ static void f_update_psw_flags(CPUTriCoreState *env, uint8_t flags) | ||
142 | some_excp = 1; | ||
143 | } | ||
144 | |||
145 | - if (flags & float_flag_inexact || flags & float_flag_output_denormal) { | ||
146 | + if (flags & float_flag_inexact || flags & float_flag_output_denormal_flushed) { | ||
147 | env->PSW |= 1 << 26; | ||
148 | some_excp = 1; | ||
149 | } | ||
150 | diff --git a/fpu/softfloat-parts.c.inc b/fpu/softfloat-parts.c.inc | ||
151 | index XXXXXXX..XXXXXXX 100644 | ||
152 | --- a/fpu/softfloat-parts.c.inc | ||
153 | +++ b/fpu/softfloat-parts.c.inc | ||
154 | @@ -XXX,XX +XXX,XX @@ static void partsN(uncanon_normal)(FloatPartsN *p, float_status *s, | ||
155 | } | ||
156 | frac_shr(p, frac_shift); | ||
157 | } else if (s->flush_to_zero) { | ||
158 | - flags |= float_flag_output_denormal; | ||
159 | + flags |= float_flag_output_denormal_flushed; | ||
160 | p->cls = float_class_zero; | ||
161 | exp = 0; | ||
162 | frac_clear(p); | ||
163 | -- | ||
164 | 2.34.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | In softfloat-types.h a comment documents that if the float_status | ||
2 | field flush_to_zero is set then we flush denormalised results to 0 | ||
3 | and set the inexact flag. This isn't correct: the status flag that | ||
4 | we set when flush_to_zero causes us to flush an output to zero is | ||
5 | float_flag_output_denormal_flushed. | ||
1 | 6 | ||
7 | Correct the comment. | ||
8 | |||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
11 | Message-id: 20250124162836.2332150-22-peter.maydell@linaro.org | ||
12 | --- | ||
13 | include/fpu/softfloat-types.h | 2 +- | ||
14 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
15 | |||
16 | diff --git a/include/fpu/softfloat-types.h b/include/fpu/softfloat-types.h | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/include/fpu/softfloat-types.h | ||
19 | +++ b/include/fpu/softfloat-types.h | ||
20 | @@ -XXX,XX +XXX,XX @@ typedef struct float_status { | ||
21 | Float3NaNPropRule float_3nan_prop_rule; | ||
22 | FloatInfZeroNaNRule float_infzeronan_rule; | ||
23 | bool tininess_before_rounding; | ||
24 | - /* should denormalised results go to zero and set the inexact flag? */ | ||
25 | + /* should denormalised results go to zero and set output_denormal_flushed? */ | ||
26 | bool flush_to_zero; | ||
27 | /* should denormalised inputs go to zero and set input_denormal_flushed? */ | ||
28 | bool flush_inputs_to_zero; | ||
29 | -- | ||
30 | 2.34.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | The advsimd_addh etc helpers defined in helper-a64.c are identical to | ||
2 | the vfp_addh etc helpers defined in helper-vfp.c: both take two | ||
3 | float16 inputs (in a uint32_t type) plus a float_status* and are | ||
4 | simple wrappers around the softfloat float16_* functions. | ||
1 | 5 | ||
6 | (The duplication seems to be a historical accident: we added the | ||
7 | advsimd helpers in 2018 as part of the A64 implementation, and at | ||
8 | that time there was no f16 emulation in A32. Then later we added the | ||
9 | A32 f16 handling by extending the existing VFP helper macros to | ||
10 | generate f16 versions as well as f32 and f64, and didn't realise we | ||
11 | could clean things up.) | ||
12 | |||
13 | Remove the now-unnecessary advsimd helpers and make the places that | ||
14 | generated calls to them use the vfp helpers instead. Many of the | ||
15 | helper functions were already unused. | ||
16 | |||
17 | (The remaining advsimd_ helpers are those which don't have vfp | ||
18 | versions.) | ||
19 | |||
20 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
21 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
22 | Message-id: 20250124162836.2332150-26-peter.maydell@linaro.org | ||
23 | --- | ||
24 | target/arm/tcg/helper-a64.h | 8 -------- | ||
25 | target/arm/tcg/helper-a64.c | 9 --------- | ||
26 | target/arm/tcg/translate-a64.c | 16 ++++++++-------- | ||
27 | 3 files changed, 8 insertions(+), 25 deletions(-) | ||
28 | |||
29 | diff --git a/target/arm/tcg/helper-a64.h b/target/arm/tcg/helper-a64.h | ||
30 | index XXXXXXX..XXXXXXX 100644 | ||
31 | --- a/target/arm/tcg/helper-a64.h | ||
32 | +++ b/target/arm/tcg/helper-a64.h | ||
33 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_2(frecpx_f16, TCG_CALL_NO_RWG, f16, f16, fpst) | ||
34 | DEF_HELPER_FLAGS_2(fcvtx_f64_to_f32, TCG_CALL_NO_RWG, f32, f64, fpst) | ||
35 | DEF_HELPER_FLAGS_3(crc32_64, TCG_CALL_NO_RWG_SE, i64, i64, i64, i32) | ||
36 | DEF_HELPER_FLAGS_3(crc32c_64, TCG_CALL_NO_RWG_SE, i64, i64, i64, i32) | ||
37 | -DEF_HELPER_FLAGS_3(advsimd_maxh, TCG_CALL_NO_RWG, f16, f16, f16, fpst) | ||
38 | -DEF_HELPER_FLAGS_3(advsimd_minh, TCG_CALL_NO_RWG, f16, f16, f16, fpst) | ||
39 | -DEF_HELPER_FLAGS_3(advsimd_maxnumh, TCG_CALL_NO_RWG, f16, f16, f16, fpst) | ||
40 | -DEF_HELPER_FLAGS_3(advsimd_minnumh, TCG_CALL_NO_RWG, f16, f16, f16, fpst) | ||
41 | -DEF_HELPER_3(advsimd_addh, f16, f16, f16, fpst) | ||
42 | -DEF_HELPER_3(advsimd_subh, f16, f16, f16, fpst) | ||
43 | -DEF_HELPER_3(advsimd_mulh, f16, f16, f16, fpst) | ||
44 | -DEF_HELPER_3(advsimd_divh, f16, f16, f16, fpst) | ||
45 | DEF_HELPER_3(advsimd_ceq_f16, i32, f16, f16, fpst) | ||
46 | DEF_HELPER_3(advsimd_cge_f16, i32, f16, f16, fpst) | ||
47 | DEF_HELPER_3(advsimd_cgt_f16, i32, f16, f16, fpst) | ||
48 | diff --git a/target/arm/tcg/helper-a64.c b/target/arm/tcg/helper-a64.c | ||
49 | index XXXXXXX..XXXXXXX 100644 | ||
50 | --- a/target/arm/tcg/helper-a64.c | ||
51 | +++ b/target/arm/tcg/helper-a64.c | ||
52 | @@ -XXX,XX +XXX,XX @@ uint32_t ADVSIMD_HELPER(name, h)(uint32_t a, uint32_t b, float_status *fpst) \ | ||
53 | return float16_ ## name(a, b, fpst); \ | ||
54 | } | ||
55 | |||
56 | -ADVSIMD_HALFOP(add) | ||
57 | -ADVSIMD_HALFOP(sub) | ||
58 | -ADVSIMD_HALFOP(mul) | ||
59 | -ADVSIMD_HALFOP(div) | ||
60 | -ADVSIMD_HALFOP(min) | ||
61 | -ADVSIMD_HALFOP(max) | ||
62 | -ADVSIMD_HALFOP(minnum) | ||
63 | -ADVSIMD_HALFOP(maxnum) | ||
64 | - | ||
65 | #define ADVSIMD_TWOHALFOP(name) \ | ||
66 | uint32_t ADVSIMD_HELPER(name, 2h)(uint32_t two_a, uint32_t two_b, \ | ||
67 | float_status *fpst) \ | ||
68 | diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c | ||
69 | index XXXXXXX..XXXXXXX 100644 | ||
70 | --- a/target/arm/tcg/translate-a64.c | ||
71 | +++ b/target/arm/tcg/translate-a64.c | ||
72 | @@ -XXX,XX +XXX,XX @@ static const FPScalar f_scalar_fmul = { | ||
73 | TRANS(FMUL_s, do_fp3_scalar, a, &f_scalar_fmul) | ||
74 | |||
75 | static const FPScalar f_scalar_fmax = { | ||
76 | - gen_helper_advsimd_maxh, | ||
77 | + gen_helper_vfp_maxh, | ||
78 | gen_helper_vfp_maxs, | ||
79 | gen_helper_vfp_maxd, | ||
80 | }; | ||
81 | TRANS(FMAX_s, do_fp3_scalar, a, &f_scalar_fmax) | ||
82 | |||
83 | static const FPScalar f_scalar_fmin = { | ||
84 | - gen_helper_advsimd_minh, | ||
85 | + gen_helper_vfp_minh, | ||
86 | gen_helper_vfp_mins, | ||
87 | gen_helper_vfp_mind, | ||
88 | }; | ||
89 | TRANS(FMIN_s, do_fp3_scalar, a, &f_scalar_fmin) | ||
90 | |||
91 | static const FPScalar f_scalar_fmaxnm = { | ||
92 | - gen_helper_advsimd_maxnumh, | ||
93 | + gen_helper_vfp_maxnumh, | ||
94 | gen_helper_vfp_maxnums, | ||
95 | gen_helper_vfp_maxnumd, | ||
96 | }; | ||
97 | TRANS(FMAXNM_s, do_fp3_scalar, a, &f_scalar_fmaxnm) | ||
98 | |||
99 | static const FPScalar f_scalar_fminnm = { | ||
100 | - gen_helper_advsimd_minnumh, | ||
101 | + gen_helper_vfp_minnumh, | ||
102 | gen_helper_vfp_minnums, | ||
103 | gen_helper_vfp_minnumd, | ||
104 | }; | ||
105 | @@ -XXX,XX +XXX,XX @@ static bool do_fp_reduction(DisasContext *s, arg_qrr_e *a, | ||
106 | return true; | ||
107 | } | ||
108 | |||
109 | -TRANS_FEAT(FMAXNMV_h, aa64_fp16, do_fp_reduction, a, gen_helper_advsimd_maxnumh) | ||
110 | -TRANS_FEAT(FMINNMV_h, aa64_fp16, do_fp_reduction, a, gen_helper_advsimd_minnumh) | ||
111 | -TRANS_FEAT(FMAXV_h, aa64_fp16, do_fp_reduction, a, gen_helper_advsimd_maxh) | ||
112 | -TRANS_FEAT(FMINV_h, aa64_fp16, do_fp_reduction, a, gen_helper_advsimd_minh) | ||
113 | +TRANS_FEAT(FMAXNMV_h, aa64_fp16, do_fp_reduction, a, gen_helper_vfp_maxnumh) | ||
114 | +TRANS_FEAT(FMINNMV_h, aa64_fp16, do_fp_reduction, a, gen_helper_vfp_minnumh) | ||
115 | +TRANS_FEAT(FMAXV_h, aa64_fp16, do_fp_reduction, a, gen_helper_vfp_maxh) | ||
116 | +TRANS_FEAT(FMINV_h, aa64_fp16, do_fp_reduction, a, gen_helper_vfp_minh) | ||
117 | |||
118 | TRANS(FMAXNMV_s, do_fp_reduction, a, gen_helper_vfp_maxnums) | ||
119 | TRANS(FMINNMV_s, do_fp_reduction, a, gen_helper_vfp_minnums) | ||
120 | -- | ||
121 | 2.34.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | We should be using the F16-specific float_status for conversions from | ||
2 | half-precision, because halfprec inputs never set Input Denormal. | ||
1 | 3 | ||
4 | Without FEAT_AHP, using the wrong fpst here had no effect, because | ||
5 | the only difference between the A64_F16 and A64 fpst is its handling | ||
6 | of flush-to-zero on input and output, and the helper functions | ||
7 | vfp_fcvt_f16_to_* and vfp_fcvt_*_to_f16 all explicitly squash the | ||
8 | relevant flushing flags, and flush_inputs_to_zero was the only way | ||
9 | that IDC could be set. | ||
10 | |||
11 | With FEAT_AHP, the FPCR.AH=1 behaviour sets IDC for | ||
12 | input_denormal_used, which we will only ignore in | ||
13 | vfp_get_fpsr_from_host() for the A64_F16 fpst; so it matters that we | ||
14 | use that one for f16 inputs (and the normal one for single/double to | ||
15 | f16 conversions). | ||
16 | |||
17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
18 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
19 | Message-id: 20250124162836.2332150-27-peter.maydell@linaro.org | ||
20 | --- | ||
21 | target/arm/tcg/translate-a64.c | 9 ++++++--- | ||
22 | target/arm/tcg/translate-sve.c | 4 ++-- | ||
23 | 2 files changed, 8 insertions(+), 5 deletions(-) | ||
24 | |||
25 | diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c | ||
26 | index XXXXXXX..XXXXXXX 100644 | ||
27 | --- a/target/arm/tcg/translate-a64.c | ||
28 | +++ b/target/arm/tcg/translate-a64.c | ||
29 | @@ -XXX,XX +XXX,XX @@ static bool trans_FCVT_s_sh(DisasContext *s, arg_rr *a) | ||
30 | if (fp_access_check(s)) { | ||
31 | TCGv_i32 tcg_rn = read_fp_hreg(s, a->rn); | ||
32 | TCGv_i32 tcg_rd = tcg_temp_new_i32(); | ||
33 | - TCGv_ptr tcg_fpst = fpstatus_ptr(FPST_A64); | ||
34 | + TCGv_ptr tcg_fpst = fpstatus_ptr(FPST_A64_F16); | ||
35 | TCGv_i32 tcg_ahp = get_ahp_flag(); | ||
36 | |||
37 | gen_helper_vfp_fcvt_f16_to_f32(tcg_rd, tcg_rn, tcg_fpst, tcg_ahp); | ||
38 | @@ -XXX,XX +XXX,XX @@ static bool trans_FCVT_s_dh(DisasContext *s, arg_rr *a) | ||
39 | if (fp_access_check(s)) { | ||
40 | TCGv_i32 tcg_rn = read_fp_hreg(s, a->rn); | ||
41 | TCGv_i64 tcg_rd = tcg_temp_new_i64(); | ||
42 | - TCGv_ptr tcg_fpst = fpstatus_ptr(FPST_A64); | ||
43 | + TCGv_ptr tcg_fpst = fpstatus_ptr(FPST_A64_F16); | ||
44 | TCGv_i32 tcg_ahp = get_ahp_flag(); | ||
45 | |||
46 | gen_helper_vfp_fcvt_f16_to_f64(tcg_rd, tcg_rn, tcg_fpst, tcg_ahp); | ||
47 | @@ -XXX,XX +XXX,XX @@ static bool trans_FCVTL_v(DisasContext *s, arg_qrr_e *a) | ||
48 | return true; | ||
49 | } | ||
50 | |||
51 | - fpst = fpstatus_ptr(FPST_A64); | ||
52 | if (a->esz == MO_64) { | ||
53 | /* 32 -> 64 bit fp conversion */ | ||
54 | TCGv_i64 tcg_res[2]; | ||
55 | TCGv_i32 tcg_op = tcg_temp_new_i32(); | ||
56 | int srcelt = a->q ? 2 : 0; | ||
57 | |||
58 | + fpst = fpstatus_ptr(FPST_A64); | ||
59 | + | ||
60 | for (pass = 0; pass < 2; pass++) { | ||
61 | tcg_res[pass] = tcg_temp_new_i64(); | ||
62 | read_vec_element_i32(s, tcg_op, a->rn, srcelt + pass, MO_32); | ||
63 | @@ -XXX,XX +XXX,XX @@ static bool trans_FCVTL_v(DisasContext *s, arg_qrr_e *a) | ||
64 | TCGv_i32 tcg_res[4]; | ||
65 | TCGv_i32 ahp = get_ahp_flag(); | ||
66 | |||
67 | + fpst = fpstatus_ptr(FPST_A64_F16); | ||
68 | + | ||
69 | for (pass = 0; pass < 4; pass++) { | ||
70 | tcg_res[pass] = tcg_temp_new_i32(); | ||
71 | read_vec_element_i32(s, tcg_res[pass], a->rn, srcelt + pass, MO_16); | ||
72 | diff --git a/target/arm/tcg/translate-sve.c b/target/arm/tcg/translate-sve.c | ||
73 | index XXXXXXX..XXXXXXX 100644 | ||
74 | --- a/target/arm/tcg/translate-sve.c | ||
75 | +++ b/target/arm/tcg/translate-sve.c | ||
76 | @@ -XXX,XX +XXX,XX @@ TRANS_FEAT(FCMLA_zzxz, aa64_sve, gen_gvec_fpst_zzzz, fcmla_idx_fns[a->esz], | ||
77 | TRANS_FEAT(FCVT_sh, aa64_sve, gen_gvec_fpst_arg_zpz, | ||
78 | gen_helper_sve_fcvt_sh, a, 0, FPST_A64) | ||
79 | TRANS_FEAT(FCVT_hs, aa64_sve, gen_gvec_fpst_arg_zpz, | ||
80 | - gen_helper_sve_fcvt_hs, a, 0, FPST_A64) | ||
81 | + gen_helper_sve_fcvt_hs, a, 0, FPST_A64_F16) | ||
82 | |||
83 | TRANS_FEAT(BFCVT, aa64_sve_bf16, gen_gvec_fpst_arg_zpz, | ||
84 | gen_helper_sve_bfcvt, a, 0, FPST_A64) | ||
85 | @@ -XXX,XX +XXX,XX @@ TRANS_FEAT(BFCVT, aa64_sve_bf16, gen_gvec_fpst_arg_zpz, | ||
86 | TRANS_FEAT(FCVT_dh, aa64_sve, gen_gvec_fpst_arg_zpz, | ||
87 | gen_helper_sve_fcvt_dh, a, 0, FPST_A64) | ||
88 | TRANS_FEAT(FCVT_hd, aa64_sve, gen_gvec_fpst_arg_zpz, | ||
89 | - gen_helper_sve_fcvt_hd, a, 0, FPST_A64) | ||
90 | + gen_helper_sve_fcvt_hd, a, 0, FPST_A64_F16) | ||
91 | TRANS_FEAT(FCVT_ds, aa64_sve, gen_gvec_fpst_arg_zpz, | ||
92 | gen_helper_sve_fcvt_ds, a, 0, FPST_A64) | ||
93 | TRANS_FEAT(FCVT_sd, aa64_sve, gen_gvec_fpst_arg_zpz, | ||
94 | -- | ||
95 | 2.34.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Hongren Zheng <i@zenithal.me> | ||
1 | 2 | ||
3 | When USBPacket in OUT direction has larger payload | ||
4 | than the ep_out_buffer (of size 512), a buffer overflow | ||
5 | would occur. | ||
6 | |||
7 | It could be fixed by limiting the size of usb_packet_copy | ||
8 | to be at most buffer size. Further optimization gets rid | ||
9 | of the ep_out_buffer and directly uses ep_out as the target | ||
10 | buffer. | ||
11 | |||
12 | This is reported by a security researcher who artificially | ||
13 | constructed an OUT packet of size 2047. The report has gone | ||
14 | through the QEMU security process, and as this device is for | ||
15 | testing purpose and no deployment of it in virtualization | ||
16 | environment is observed, it is triaged not to be a security bug. | ||
17 | |||
18 | Cc: qemu-stable@nongnu.org | ||
19 | Fixes: d7d34918551dc48 ("hw/usb: Add CanoKey Implementation") | ||
20 | Reported-by: Juan Jose Lopez Jaimez <thatjiaozi@gmail.com> | ||
21 | Signed-off-by: Hongren Zheng <i@zenithal.me> | ||
22 | Message-id: Z4TfMOrZz6IQYl_h@Sun | ||
23 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
24 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
25 | --- | ||
26 | hw/usb/canokey.h | 4 ---- | ||
27 | hw/usb/canokey.c | 6 +++--- | ||
28 | 2 files changed, 3 insertions(+), 7 deletions(-) | ||
29 | |||
30 | diff --git a/hw/usb/canokey.h b/hw/usb/canokey.h | ||
31 | index XXXXXXX..XXXXXXX 100644 | ||
32 | --- a/hw/usb/canokey.h | ||
33 | +++ b/hw/usb/canokey.h | ||
34 | @@ -XXX,XX +XXX,XX @@ | ||
35 | #define CANOKEY_EP_NUM 3 | ||
36 | /* BULK/INTR IN can be up to 1352 bytes, e.g. get key info */ | ||
37 | #define CANOKEY_EP_IN_BUFFER_SIZE 2048 | ||
38 | -/* BULK OUT can be up to 270 bytes, e.g. PIV import cert */ | ||
39 | -#define CANOKEY_EP_OUT_BUFFER_SIZE 512 | ||
40 | |||
41 | typedef enum { | ||
42 | CANOKEY_EP_IN_WAIT, | ||
43 | @@ -XXX,XX +XXX,XX @@ typedef struct CanoKeyState { | ||
44 | /* OUT pointer to canokey recv buffer */ | ||
45 | uint8_t *ep_out[CANOKEY_EP_NUM]; | ||
46 | uint32_t ep_out_size[CANOKEY_EP_NUM]; | ||
47 | - /* For large BULK OUT, multiple write to ep_out is needed */ | ||
48 | - uint8_t ep_out_buffer[CANOKEY_EP_NUM][CANOKEY_EP_OUT_BUFFER_SIZE]; | ||
49 | |||
50 | /* Properties */ | ||
51 | char *file; /* canokey-file */ | ||
52 | diff --git a/hw/usb/canokey.c b/hw/usb/canokey.c | ||
53 | index XXXXXXX..XXXXXXX 100644 | ||
54 | --- a/hw/usb/canokey.c | ||
55 | +++ b/hw/usb/canokey.c | ||
56 | @@ -XXX,XX +XXX,XX @@ static void canokey_handle_data(USBDevice *dev, USBPacket *p) | ||
57 | switch (p->pid) { | ||
58 | case USB_TOKEN_OUT: | ||
59 | trace_canokey_handle_data_out(ep_out, p->iov.size); | ||
60 | - usb_packet_copy(p, key->ep_out_buffer[ep_out], p->iov.size); | ||
61 | out_pos = 0; | ||
62 | + /* segment packet into (possibly multiple) ep_out */ | ||
63 | while (out_pos != p->iov.size) { | ||
64 | /* | ||
65 | * key->ep_out[ep_out] set by prepare_receive | ||
66 | @@ -XXX,XX +XXX,XX @@ static void canokey_handle_data(USBDevice *dev, USBPacket *p) | ||
67 | * to be the buffer length | ||
68 | */ | ||
69 | out_len = MIN(p->iov.size - out_pos, key->ep_out_size[ep_out]); | ||
70 | - memcpy(key->ep_out[ep_out], | ||
71 | - key->ep_out_buffer[ep_out] + out_pos, out_len); | ||
72 | + /* usb_packet_copy would update the pos offset internally */ | ||
73 | + usb_packet_copy(p, key->ep_out[ep_out], out_len); | ||
74 | out_pos += out_len; | ||
75 | /* update ep_out_size to actual len */ | ||
76 | key->ep_out_size[ep_out] = out_len; | ||
77 | -- | ||
78 | 2.34.1 | diff view generated by jsdifflib |