1 | target-arm queue. This has the "plumb txattrs through various | 1 | Nothing earth-shaking in here, just a lot of refactoring and cleanup |
---|---|---|---|
2 | bits of exec.c" patches, and a collection of bug fixes from | 2 | and a few bugfixes. I suspect I'll have another pullreq to come in |
3 | various people. | 3 | the early part of next week... |
4 | 4 | ||
5 | thanks | 5 | The following changes since commit 19591e9e0938ea5066984553c256a043bd5d822f: |
6 | -- PMM | ||
7 | 6 | ||
8 | 7 | Merge remote-tracking branch 'remotes/mst/tags/for_upstream' into staging (2020-08-27 16:59:02 +0100) | |
9 | |||
10 | The following changes since commit a3ac12fba028df90f7b3dbec924995c126c41022: | ||
11 | |||
12 | Merge remote-tracking branch 'remotes/ehabkost/tags/numa-next-pull-request' into staging (2018-05-31 11:12:36 +0100) | ||
13 | 8 | ||
14 | are available in the Git repository at: | 9 | are available in the Git repository at: |
15 | 10 | ||
16 | git://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20180531 | 11 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20200828 |
17 | 12 | ||
18 | for you to fetch changes up to 49d1dca0520ea71bc21867fab6647f474fcf857b: | 13 | for you to fetch changes up to ed78849d9711805bda37ee026018d6ee7a606d0e: |
19 | 14 | ||
20 | KVM: GIC: Fix memory leak due to calling kvm_init_irq_routing twice (2018-05-31 14:52:53 +0100) | 15 | target/arm: Convert sq{, r}dmulh to gvec for aa64 advsimd (2020-08-28 10:02:50 +0100) |
21 | 16 | ||
22 | ---------------------------------------------------------------- | 17 | ---------------------------------------------------------------- |
23 | target-arm queue: | 18 | target-arm queue: |
24 | * target/arm: Honour FPCR.FZ in FRECPX | 19 | * target/arm: Cleanup and refactoring preparatory to SVE2 |
25 | * MAINTAINERS: Add entries for newer MPS2 boards and devices | 20 | * armsse: Define ARMSSEClass correctly |
26 | * hw/intc/arm_gicv3: Fix APxR<n> register dispatching | 21 | * hw/misc/unimp: Improve information provided in log messages |
27 | * arm_gicv3_kvm: fix bug in writing zero bits back to the in-kernel | 22 | * hw/qdev-clock: Avoid calling qdev_connect_clock_in after DeviceRealize |
28 | GIC state | 23 | * hw/arm/xilinx_zynq: Call qdev_connect_clock_in() before DeviceRealize |
29 | * tcg: Fix helper function vs host abi for float16 | 24 | * hw/net/allwinner-sun8i-emac: Use AddressSpace for DMA transfers |
30 | * arm: fix qemu crash on startup with -bios option | 25 | * hw/sd/allwinner-sdhost: Use AddressSpace for DMA transfers |
31 | * arm: fix malloc type mismatch | 26 | * target/arm: Fill in the WnR syndrome bit in mte_check_fail |
32 | * xlnx-zdma: Correct mem leaks and memset to zero on desc unaligned errors | 27 | * target/arm: Clarify HCR_EL2 ARMCPRegInfo type |
33 | * Correct CPACR reset value for v7 cores | 28 | * hw/arm/musicpal: Use AddressSpace for DMA transfers |
34 | * memory.h: Improve IOMMU related documentation | 29 | * hw/clock: Minor cleanups |
35 | * exec: Plumb transaction attributes through various functions in | 30 | * hw/arm/sbsa-ref: fix typo breaking PCIe IRQs |
36 | preparation for allowing IOMMUs to see them | ||
37 | * vmstate.h: Provide VMSTATE_BOOL_SUB_ARRAY | ||
38 | * ARM: ACPI: Fix use-after-free due to memory realloc | ||
39 | * KVM: GIC: Fix memory leak due to calling kvm_init_irq_routing twice | ||
40 | 31 | ||
41 | ---------------------------------------------------------------- | 32 | ---------------------------------------------------------------- |
42 | Francisco Iglesias (1): | 33 | Eduardo Habkost (1): |
43 | xlnx-zdma: Correct mem leaks and memset to zero on desc unaligned errors | 34 | armsse: Define ARMSSEClass correctly |
44 | 35 | ||
45 | Igor Mammedov (1): | 36 | Graeme Gregory (1): |
46 | arm: fix qemu crash on startup with -bios option | 37 | hw/arm/sbsa-ref: fix typo breaking PCIe IRQs |
47 | 38 | ||
48 | Jan Kiszka (1): | 39 | Philippe Mathieu-Daudé (14): |
49 | hw/intc/arm_gicv3: Fix APxR<n> register dispatching | 40 | hw/clock: Remove unused clock_init*() functions |
41 | hw/clock: Let clock_set() return boolean value | ||
42 | hw/clock: Only propagate clock changes if the clock is changed | ||
43 | hw/arm/musicpal: Use AddressSpace for DMA transfers | ||
44 | target/arm: Clarify HCR_EL2 ARMCPRegInfo type | ||
45 | hw/sd/allwinner-sdhost: Use AddressSpace for DMA transfers | ||
46 | hw/net/allwinner-sun8i-emac: Use AddressSpace for DMA transfers | ||
47 | hw/arm/xilinx_zynq: Uninline cadence_uart_create() | ||
48 | hw/arm/xilinx_zynq: Call qdev_connect_clock_in() before DeviceRealize | ||
49 | hw/qdev-clock: Uninline qdev_connect_clock_in() | ||
50 | hw/qdev-clock: Avoid calling qdev_connect_clock_in after DeviceRealize | ||
51 | hw/misc/unimp: Display value after offset | ||
52 | hw/misc/unimp: Display the value with width of the access size | ||
53 | hw/misc/unimp: Display the offset with width of the region size | ||
50 | 54 | ||
51 | Paolo Bonzini (1): | 55 | Richard Henderson (19): |
52 | arm: fix malloc type mismatch | 56 | target/arm: Pass the entire mte descriptor to mte_check_fail |
57 | target/arm: Fill in the WnR syndrome bit in mte_check_fail | ||
58 | qemu/int128: Add int128_lshift | ||
59 | target/arm: Split out gen_gvec_fn_zz | ||
60 | target/arm: Split out gen_gvec_fn_zzz, do_zzz_fn | ||
61 | target/arm: Rearrange {sve,fp}_check_access assert | ||
62 | target/arm: Merge do_vector2_p into do_mov_p | ||
63 | target/arm: Clean up 4-operand predicate expansion | ||
64 | target/arm: Use tcg_gen_gvec_bitsel for trans_SEL_pppp | ||
65 | target/arm: Split out gen_gvec_ool_zzzp | ||
66 | target/arm: Merge helper_sve_clr_* and helper_sve_movz_* | ||
67 | target/arm: Split out gen_gvec_ool_zzp | ||
68 | target/arm: Split out gen_gvec_ool_zzz | ||
69 | target/arm: Split out gen_gvec_ool_zz | ||
70 | target/arm: Tidy SVE tszimm shift formats | ||
71 | target/arm: Generalize inl_qrdmlah_* helper functions | ||
72 | target/arm: Convert integer multiply (indexed) to gvec for aa64 advsimd | ||
73 | target/arm: Convert integer multiply-add (indexed) to gvec for aa64 advsimd | ||
74 | target/arm: Convert sq{, r}dmulh to gvec for aa64 advsimd | ||
53 | 75 | ||
54 | Peter Maydell (17): | 76 | include/hw/arm/armsse.h | 2 +- |
55 | target/arm: Honour FPCR.FZ in FRECPX | 77 | include/hw/char/cadence_uart.h | 17 -- |
56 | MAINTAINERS: Add entries for newer MPS2 boards and devices | 78 | include/hw/clock.h | 30 +-- |
57 | Correct CPACR reset value for v7 cores | 79 | include/hw/misc/unimp.h | 1 + |
58 | memory.h: Improve IOMMU related documentation | 80 | include/hw/net/allwinner-sun8i-emac.h | 6 + |
59 | Make tb_invalidate_phys_addr() take a MemTxAttrs argument | 81 | include/hw/qdev-clock.h | 8 +- |
60 | Make address_space_translate{, _cached}() take a MemTxAttrs argument | 82 | include/hw/sd/allwinner-sdhost.h | 6 + |
61 | Make address_space_map() take a MemTxAttrs argument | 83 | include/qemu/int128.h | 16 ++ |
62 | Make address_space_access_valid() take a MemTxAttrs argument | 84 | target/arm/helper-sve.h | 5 - |
63 | Make flatview_extend_translation() take a MemTxAttrs argument | 85 | target/arm/helper.h | 28 +++ |
64 | Make memory_region_access_valid() take a MemTxAttrs argument | 86 | target/arm/translate.h | 1 + |
65 | Make MemoryRegion valid.accepts callback take a MemTxAttrs argument | 87 | target/arm/sve.decode | 35 ++- |
66 | Make flatview_access_valid() take a MemTxAttrs argument | 88 | hw/arm/allwinner-a10.c | 2 + |
67 | Make flatview_translate() take a MemTxAttrs argument | 89 | hw/arm/allwinner-h3.c | 4 + |
68 | Make address_space_get_iotlb_entry() take a MemTxAttrs argument | 90 | hw/arm/armsse.c | 1 + |
69 | Make flatview_do_translate() take a MemTxAttrs argument | 91 | hw/arm/musicpal.c | 45 ++-- |
70 | Make address_space_translate_iommu take a MemTxAttrs argument | 92 | hw/arm/sbsa-ref.c | 2 +- |
71 | vmstate.h: Provide VMSTATE_BOOL_SUB_ARRAY | 93 | hw/arm/xilinx_zynq.c | 24 +- |
94 | hw/core/clock.c | 7 +- | ||
95 | hw/core/qdev-clock.c | 6 + | ||
96 | hw/misc/unimp.c | 14 +- | ||
97 | hw/net/allwinner-sun8i-emac.c | 46 ++-- | ||
98 | hw/sd/allwinner-sdhost.c | 37 +++- | ||
99 | target/arm/helper.c | 1 - | ||
100 | target/arm/mte_helper.c | 19 +- | ||
101 | target/arm/sve_helper.c | 70 ++---- | ||
102 | target/arm/translate-a64.c | 110 ++++++++-- | ||
103 | target/arm/translate-sve.c | 399 ++++++++++++++-------------------- | ||
104 | target/arm/vec_helper.c | 182 +++++++++++----- | ||
105 | 29 files changed, 629 insertions(+), 495 deletions(-) | ||
72 | 106 | ||
73 | Richard Henderson (1): | ||
74 | tcg: Fix helper function vs host abi for float16 | ||
75 | |||
76 | Shannon Zhao (3): | ||
77 | arm_gicv3_kvm: increase clroffset accordingly | ||
78 | ARM: ACPI: Fix use-after-free due to memory realloc | ||
79 | KVM: GIC: Fix memory leak due to calling kvm_init_irq_routing twice | ||
80 | |||
81 | include/exec/exec-all.h | 5 +- | ||
82 | include/exec/helper-head.h | 2 +- | ||
83 | include/exec/memory-internal.h | 3 +- | ||
84 | include/exec/memory.h | 128 +++++++++++++++++++++++++++++++++++------ | ||
85 | include/migration/vmstate.h | 3 + | ||
86 | include/sysemu/dma.h | 6 +- | ||
87 | accel/tcg/translate-all.c | 4 +- | ||
88 | exec.c | 95 ++++++++++++++++++------------ | ||
89 | hw/arm/boot.c | 18 +++--- | ||
90 | hw/arm/virt-acpi-build.c | 20 +++++-- | ||
91 | hw/dma/xlnx-zdma.c | 10 +++- | ||
92 | hw/hppa/dino.c | 3 +- | ||
93 | hw/intc/arm_gic_kvm.c | 1 - | ||
94 | hw/intc/arm_gicv3_cpuif.c | 12 ++-- | ||
95 | hw/intc/arm_gicv3_kvm.c | 2 +- | ||
96 | hw/nvram/fw_cfg.c | 12 ++-- | ||
97 | hw/s390x/s390-pci-inst.c | 3 +- | ||
98 | hw/scsi/esp.c | 3 +- | ||
99 | hw/vfio/common.c | 3 +- | ||
100 | hw/virtio/vhost.c | 3 +- | ||
101 | hw/xen/xen_pt_msi.c | 3 +- | ||
102 | memory.c | 12 ++-- | ||
103 | memory_ldst.inc.c | 18 +++--- | ||
104 | target/arm/gdbstub.c | 3 +- | ||
105 | target/arm/helper-a64.c | 41 +++++++------ | ||
106 | target/arm/helper.c | 90 ++++++++++++++++------------- | ||
107 | target/ppc/mmu-hash64.c | 3 +- | ||
108 | target/riscv/helper.c | 2 +- | ||
109 | target/s390x/diag.c | 6 +- | ||
110 | target/s390x/excp_helper.c | 3 +- | ||
111 | target/s390x/mmu_helper.c | 3 +- | ||
112 | target/s390x/sigp.c | 3 +- | ||
113 | target/xtensa/op_helper.c | 3 +- | ||
114 | MAINTAINERS | 9 ++- | ||
115 | 34 files changed, 353 insertions(+), 182 deletions(-) | ||
116 | diff view generated by jsdifflib |
1 | From: Jan Kiszka <jan.kiszka@siemens.com> | 1 | From: Graeme Gregory <graeme@nuviainc.com> |
---|---|---|---|
2 | 2 | ||
3 | There was a nasty flip in identifying which register group an access is | 3 | Fixing a typo in a previous patch that translated an "i" to a 1 |
4 | targeting. The issue caused spuriously raised priorities of the guest | 4 | and therefore breaking the allocation of PCIe interrupts. This was |
5 | when handing CPUs over in the Jailhouse hypervisor. | 5 | discovered when virtio-net-pci devices ceased to function correctly. |
6 | 6 | ||
7 | Cc: qemu-stable@nongnu.org | 7 | Cc: qemu-stable@nongnu.org |
8 | Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> | 8 | Fixes: 48ba18e6d3f3 ("hw/arm/sbsa-ref: Simplify by moving the gic in the machine state") |
9 | Message-id: 28b927d3-da58-bce4-cc13-bfec7f9b1cb9@siemens.com | 9 | Signed-off-by: Graeme Gregory <graeme@nuviainc.com> |
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
11 | Message-id: 20200821083853.356490-1-graeme@nuviainc.com | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | --- | 13 | --- |
13 | hw/intc/arm_gicv3_cpuif.c | 12 ++++++------ | 14 | hw/arm/sbsa-ref.c | 2 +- |
14 | 1 file changed, 6 insertions(+), 6 deletions(-) | 15 | 1 file changed, 1 insertion(+), 1 deletion(-) |
15 | 16 | ||
16 | diff --git a/hw/intc/arm_gicv3_cpuif.c b/hw/intc/arm_gicv3_cpuif.c | 17 | diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c |
17 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/hw/intc/arm_gicv3_cpuif.c | 19 | --- a/hw/arm/sbsa-ref.c |
19 | +++ b/hw/intc/arm_gicv3_cpuif.c | 20 | +++ b/hw/arm/sbsa-ref.c |
20 | @@ -XXX,XX +XXX,XX @@ static uint64_t icv_ap_read(CPUARMState *env, const ARMCPRegInfo *ri) | 21 | @@ -XXX,XX +XXX,XX @@ static void create_pcie(SBSAMachineState *sms) |
21 | { | 22 | |
22 | GICv3CPUState *cs = icc_cs_from_env(env); | 23 | for (i = 0; i < GPEX_NUM_IRQS; i++) { |
23 | int regno = ri->opc2 & 3; | 24 | sysbus_connect_irq(SYS_BUS_DEVICE(dev), i, |
24 | - int grp = ri->crm & 1 ? GICV3_G0 : GICV3_G1NS; | 25 | - qdev_get_gpio_in(sms->gic, irq + 1)); |
25 | + int grp = (ri->crm & 1) ? GICV3_G1NS : GICV3_G0; | 26 | + qdev_get_gpio_in(sms->gic, irq + i)); |
26 | uint64_t value = cs->ich_apr[grp][regno]; | 27 | gpex_set_irq_num(GPEX_HOST(dev), i, irq + i); |
27 | 28 | } | |
28 | trace_gicv3_icv_ap_read(ri->crm & 1, regno, gicv3_redist_affid(cs), value); | ||
29 | @@ -XXX,XX +XXX,XX @@ static void icv_ap_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
30 | { | ||
31 | GICv3CPUState *cs = icc_cs_from_env(env); | ||
32 | int regno = ri->opc2 & 3; | ||
33 | - int grp = ri->crm & 1 ? GICV3_G0 : GICV3_G1NS; | ||
34 | + int grp = (ri->crm & 1) ? GICV3_G1NS : GICV3_G0; | ||
35 | |||
36 | trace_gicv3_icv_ap_write(ri->crm & 1, regno, gicv3_redist_affid(cs), value); | ||
37 | |||
38 | @@ -XXX,XX +XXX,XX @@ static uint64_t icc_ap_read(CPUARMState *env, const ARMCPRegInfo *ri) | ||
39 | uint64_t value; | ||
40 | |||
41 | int regno = ri->opc2 & 3; | ||
42 | - int grp = ri->crm & 1 ? GICV3_G0 : GICV3_G1; | ||
43 | + int grp = (ri->crm & 1) ? GICV3_G1 : GICV3_G0; | ||
44 | |||
45 | if (icv_access(env, grp == GICV3_G0 ? HCR_FMO : HCR_IMO)) { | ||
46 | return icv_ap_read(env, ri); | ||
47 | @@ -XXX,XX +XXX,XX @@ static void icc_ap_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
48 | GICv3CPUState *cs = icc_cs_from_env(env); | ||
49 | |||
50 | int regno = ri->opc2 & 3; | ||
51 | - int grp = ri->crm & 1 ? GICV3_G0 : GICV3_G1; | ||
52 | + int grp = (ri->crm & 1) ? GICV3_G1 : GICV3_G0; | ||
53 | |||
54 | if (icv_access(env, grp == GICV3_G0 ? HCR_FMO : HCR_IMO)) { | ||
55 | icv_ap_write(env, ri, value); | ||
56 | @@ -XXX,XX +XXX,XX @@ static uint64_t ich_ap_read(CPUARMState *env, const ARMCPRegInfo *ri) | ||
57 | { | ||
58 | GICv3CPUState *cs = icc_cs_from_env(env); | ||
59 | int regno = ri->opc2 & 3; | ||
60 | - int grp = ri->crm & 1 ? GICV3_G0 : GICV3_G1NS; | ||
61 | + int grp = (ri->crm & 1) ? GICV3_G1NS : GICV3_G0; | ||
62 | uint64_t value; | ||
63 | |||
64 | value = cs->ich_apr[grp][regno]; | ||
65 | @@ -XXX,XX +XXX,XX @@ static void ich_ap_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
66 | { | ||
67 | GICv3CPUState *cs = icc_cs_from_env(env); | ||
68 | int regno = ri->opc2 & 3; | ||
69 | - int grp = ri->crm & 1 ? GICV3_G0 : GICV3_G1NS; | ||
70 | + int grp = (ri->crm & 1) ? GICV3_G1NS : GICV3_G0; | ||
71 | |||
72 | trace_gicv3_ich_ap_write(ri->crm & 1, regno, gicv3_redist_affid(cs), value); | ||
73 | 29 | ||
74 | -- | 30 | -- |
75 | 2.17.1 | 31 | 2.20.1 |
76 | 32 | ||
77 | 33 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
1 | 2 | ||
3 | clock_init*() inlined funtions are simple wrappers around | ||
4 | clock_set*() and are not used. Remove them in favor of clock_set*(). | ||
5 | |||
6 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20200806123858.30058-2-f4bug@amsat.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | include/hw/clock.h | 13 ------------- | ||
12 | 1 file changed, 13 deletions(-) | ||
13 | |||
14 | diff --git a/include/hw/clock.h b/include/hw/clock.h | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/include/hw/clock.h | ||
17 | +++ b/include/hw/clock.h | ||
18 | @@ -XXX,XX +XXX,XX @@ static inline bool clock_is_enabled(const Clock *clk) | ||
19 | return clock_get(clk) != 0; | ||
20 | } | ||
21 | |||
22 | -static inline void clock_init(Clock *clk, uint64_t value) | ||
23 | -{ | ||
24 | - clock_set(clk, value); | ||
25 | -} | ||
26 | -static inline void clock_init_hz(Clock *clk, uint64_t value) | ||
27 | -{ | ||
28 | - clock_set_hz(clk, value); | ||
29 | -} | ||
30 | -static inline void clock_init_ns(Clock *clk, uint64_t value) | ||
31 | -{ | ||
32 | - clock_set_ns(clk, value); | ||
33 | -} | ||
34 | - | ||
35 | #endif /* QEMU_HW_CLOCK_H */ | ||
36 | -- | ||
37 | 2.20.1 | ||
38 | |||
39 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
1 | 2 | ||
3 | Let clock_set() return a boolean value whether the clock | ||
4 | has been updated or not. | ||
5 | |||
6 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20200806123858.30058-3-f4bug@amsat.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | include/hw/clock.h | 12 +++++++----- | ||
12 | hw/core/clock.c | 7 ++++++- | ||
13 | 2 files changed, 13 insertions(+), 6 deletions(-) | ||
14 | |||
15 | diff --git a/include/hw/clock.h b/include/hw/clock.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/include/hw/clock.h | ||
18 | +++ b/include/hw/clock.h | ||
19 | @@ -XXX,XX +XXX,XX @@ void clock_set_source(Clock *clk, Clock *src); | ||
20 | * @value: the clock's value, 0 means unclocked | ||
21 | * | ||
22 | * Set the local cached period value of @clk to @value. | ||
23 | + * | ||
24 | + * @return: true if the clock is changed. | ||
25 | */ | ||
26 | -void clock_set(Clock *clk, uint64_t value); | ||
27 | +bool clock_set(Clock *clk, uint64_t value); | ||
28 | |||
29 | -static inline void clock_set_hz(Clock *clk, unsigned hz) | ||
30 | +static inline bool clock_set_hz(Clock *clk, unsigned hz) | ||
31 | { | ||
32 | - clock_set(clk, CLOCK_PERIOD_FROM_HZ(hz)); | ||
33 | + return clock_set(clk, CLOCK_PERIOD_FROM_HZ(hz)); | ||
34 | } | ||
35 | |||
36 | -static inline void clock_set_ns(Clock *clk, unsigned ns) | ||
37 | +static inline bool clock_set_ns(Clock *clk, unsigned ns) | ||
38 | { | ||
39 | - clock_set(clk, CLOCK_PERIOD_FROM_NS(ns)); | ||
40 | + return clock_set(clk, CLOCK_PERIOD_FROM_NS(ns)); | ||
41 | } | ||
42 | |||
43 | /** | ||
44 | diff --git a/hw/core/clock.c b/hw/core/clock.c | ||
45 | index XXXXXXX..XXXXXXX 100644 | ||
46 | --- a/hw/core/clock.c | ||
47 | +++ b/hw/core/clock.c | ||
48 | @@ -XXX,XX +XXX,XX @@ void clock_clear_callback(Clock *clk) | ||
49 | clock_set_callback(clk, NULL, NULL); | ||
50 | } | ||
51 | |||
52 | -void clock_set(Clock *clk, uint64_t period) | ||
53 | +bool clock_set(Clock *clk, uint64_t period) | ||
54 | { | ||
55 | + if (clk->period == period) { | ||
56 | + return false; | ||
57 | + } | ||
58 | trace_clock_set(CLOCK_PATH(clk), CLOCK_PERIOD_TO_NS(clk->period), | ||
59 | CLOCK_PERIOD_TO_NS(period)); | ||
60 | clk->period = period; | ||
61 | + | ||
62 | + return true; | ||
63 | } | ||
64 | |||
65 | static void clock_propagate_period(Clock *clk, bool call_callbacks) | ||
66 | -- | ||
67 | 2.20.1 | ||
68 | |||
69 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
1 | 2 | ||
3 | Avoid propagating the clock change when the clock does not change. | ||
4 | |||
5 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20200806123858.30058-4-f4bug@amsat.org | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | --- | ||
10 | include/hw/clock.h | 5 +++-- | ||
11 | 1 file changed, 3 insertions(+), 2 deletions(-) | ||
12 | |||
13 | diff --git a/include/hw/clock.h b/include/hw/clock.h | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/include/hw/clock.h | ||
16 | +++ b/include/hw/clock.h | ||
17 | @@ -XXX,XX +XXX,XX @@ void clock_propagate(Clock *clk); | ||
18 | */ | ||
19 | static inline void clock_update(Clock *clk, uint64_t value) | ||
20 | { | ||
21 | - clock_set(clk, value); | ||
22 | - clock_propagate(clk); | ||
23 | + if (clock_set(clk, value)) { | ||
24 | + clock_propagate(clk); | ||
25 | + } | ||
26 | } | ||
27 | |||
28 | static inline void clock_update_hz(Clock *clk, unsigned hz) | ||
29 | -- | ||
30 | 2.20.1 | ||
31 | |||
32 | diff view generated by jsdifflib |
1 | Add more detail to the documentation for memory_region_init_iommu() | 1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> |
---|---|---|---|
2 | and other IOMMU-related functions and data structures. | ||
3 | 2 | ||
3 | Allow the device to execute the DMA transfers in a different | ||
4 | AddressSpace. | ||
5 | |||
6 | We keep using the system_memory address space, but via the | ||
7 | proper dma_memory_access() API. | ||
8 | |||
9 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
11 | Message-id: 20200814125533.4047-1-f4bug@amsat.org | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
7 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | ||
8 | Message-id: 20180521140402.23318-2-peter.maydell@linaro.org | ||
9 | --- | 13 | --- |
10 | include/exec/memory.h | 105 ++++++++++++++++++++++++++++++++++++++---- | 14 | hw/arm/musicpal.c | 45 +++++++++++++++++++++++++++++++-------------- |
11 | 1 file changed, 95 insertions(+), 10 deletions(-) | 15 | 1 file changed, 31 insertions(+), 14 deletions(-) |
12 | 16 | ||
13 | diff --git a/include/exec/memory.h b/include/exec/memory.h | 17 | diff --git a/hw/arm/musicpal.c b/hw/arm/musicpal.c |
14 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/include/exec/memory.h | 19 | --- a/hw/arm/musicpal.c |
16 | +++ b/include/exec/memory.h | 20 | +++ b/hw/arm/musicpal.c |
17 | @@ -XXX,XX +XXX,XX @@ enum IOMMUMemoryRegionAttr { | 21 | @@ -XXX,XX +XXX,XX @@ |
18 | IOMMU_ATTR_SPAPR_TCE_FD | 22 | #include "hw/audio/wm8750.h" |
23 | #include "sysemu/block-backend.h" | ||
24 | #include "sysemu/runstate.h" | ||
25 | +#include "sysemu/dma.h" | ||
26 | #include "exec/address-spaces.h" | ||
27 | #include "ui/pixel_ops.h" | ||
28 | #include "qemu/cutils.h" | ||
29 | @@ -XXX,XX +XXX,XX @@ typedef struct mv88w8618_eth_state { | ||
30 | |||
31 | MemoryRegion iomem; | ||
32 | qemu_irq irq; | ||
33 | + MemoryRegion *dma_mr; | ||
34 | + AddressSpace dma_as; | ||
35 | uint32_t smir; | ||
36 | uint32_t icr; | ||
37 | uint32_t imr; | ||
38 | @@ -XXX,XX +XXX,XX @@ typedef struct mv88w8618_eth_state { | ||
39 | NICConf conf; | ||
40 | } mv88w8618_eth_state; | ||
41 | |||
42 | -static void eth_rx_desc_put(uint32_t addr, mv88w8618_rx_desc *desc) | ||
43 | +static void eth_rx_desc_put(AddressSpace *dma_as, uint32_t addr, | ||
44 | + mv88w8618_rx_desc *desc) | ||
45 | { | ||
46 | cpu_to_le32s(&desc->cmdstat); | ||
47 | cpu_to_le16s(&desc->bytes); | ||
48 | cpu_to_le16s(&desc->buffer_size); | ||
49 | cpu_to_le32s(&desc->buffer); | ||
50 | cpu_to_le32s(&desc->next); | ||
51 | - cpu_physical_memory_write(addr, desc, sizeof(*desc)); | ||
52 | + dma_memory_write(dma_as, addr, desc, sizeof(*desc)); | ||
53 | } | ||
54 | |||
55 | -static void eth_rx_desc_get(uint32_t addr, mv88w8618_rx_desc *desc) | ||
56 | +static void eth_rx_desc_get(AddressSpace *dma_as, uint32_t addr, | ||
57 | + mv88w8618_rx_desc *desc) | ||
58 | { | ||
59 | - cpu_physical_memory_read(addr, desc, sizeof(*desc)); | ||
60 | + dma_memory_read(dma_as, addr, desc, sizeof(*desc)); | ||
61 | le32_to_cpus(&desc->cmdstat); | ||
62 | le16_to_cpus(&desc->bytes); | ||
63 | le16_to_cpus(&desc->buffer_size); | ||
64 | @@ -XXX,XX +XXX,XX @@ static ssize_t eth_receive(NetClientState *nc, const uint8_t *buf, size_t size) | ||
65 | continue; | ||
66 | } | ||
67 | do { | ||
68 | - eth_rx_desc_get(desc_addr, &desc); | ||
69 | + eth_rx_desc_get(&s->dma_as, desc_addr, &desc); | ||
70 | if ((desc.cmdstat & MP_ETH_RX_OWN) && desc.buffer_size >= size) { | ||
71 | - cpu_physical_memory_write(desc.buffer + s->vlan_header, | ||
72 | + dma_memory_write(&s->dma_as, desc.buffer + s->vlan_header, | ||
73 | buf, size); | ||
74 | desc.bytes = size + s->vlan_header; | ||
75 | desc.cmdstat &= ~MP_ETH_RX_OWN; | ||
76 | @@ -XXX,XX +XXX,XX @@ static ssize_t eth_receive(NetClientState *nc, const uint8_t *buf, size_t size) | ||
77 | if (s->icr & s->imr) { | ||
78 | qemu_irq_raise(s->irq); | ||
79 | } | ||
80 | - eth_rx_desc_put(desc_addr, &desc); | ||
81 | + eth_rx_desc_put(&s->dma_as, desc_addr, &desc); | ||
82 | return size; | ||
83 | } | ||
84 | desc_addr = desc.next; | ||
85 | @@ -XXX,XX +XXX,XX @@ static ssize_t eth_receive(NetClientState *nc, const uint8_t *buf, size_t size) | ||
86 | return size; | ||
87 | } | ||
88 | |||
89 | -static void eth_tx_desc_put(uint32_t addr, mv88w8618_tx_desc *desc) | ||
90 | +static void eth_tx_desc_put(AddressSpace *dma_as, uint32_t addr, | ||
91 | + mv88w8618_tx_desc *desc) | ||
92 | { | ||
93 | cpu_to_le32s(&desc->cmdstat); | ||
94 | cpu_to_le16s(&desc->res); | ||
95 | cpu_to_le16s(&desc->bytes); | ||
96 | cpu_to_le32s(&desc->buffer); | ||
97 | cpu_to_le32s(&desc->next); | ||
98 | - cpu_physical_memory_write(addr, desc, sizeof(*desc)); | ||
99 | + dma_memory_write(dma_as, addr, desc, sizeof(*desc)); | ||
100 | } | ||
101 | |||
102 | -static void eth_tx_desc_get(uint32_t addr, mv88w8618_tx_desc *desc) | ||
103 | +static void eth_tx_desc_get(AddressSpace *dma_as, uint32_t addr, | ||
104 | + mv88w8618_tx_desc *desc) | ||
105 | { | ||
106 | - cpu_physical_memory_read(addr, desc, sizeof(*desc)); | ||
107 | + dma_memory_read(dma_as, addr, desc, sizeof(*desc)); | ||
108 | le32_to_cpus(&desc->cmdstat); | ||
109 | le16_to_cpus(&desc->res); | ||
110 | le16_to_cpus(&desc->bytes); | ||
111 | @@ -XXX,XX +XXX,XX @@ static void eth_send(mv88w8618_eth_state *s, int queue_index) | ||
112 | int len; | ||
113 | |||
114 | do { | ||
115 | - eth_tx_desc_get(desc_addr, &desc); | ||
116 | + eth_tx_desc_get(&s->dma_as, desc_addr, &desc); | ||
117 | next_desc = desc.next; | ||
118 | if (desc.cmdstat & MP_ETH_TX_OWN) { | ||
119 | len = desc.bytes; | ||
120 | if (len < 2048) { | ||
121 | - cpu_physical_memory_read(desc.buffer, buf, len); | ||
122 | + dma_memory_read(&s->dma_as, desc.buffer, buf, len); | ||
123 | qemu_send_packet(qemu_get_queue(s->nic), buf, len); | ||
124 | } | ||
125 | desc.cmdstat &= ~MP_ETH_TX_OWN; | ||
126 | s->icr |= 1 << (MP_ETH_IRQ_TXLO_BIT - queue_index); | ||
127 | - eth_tx_desc_put(desc_addr, &desc); | ||
128 | + eth_tx_desc_put(&s->dma_as, desc_addr, &desc); | ||
129 | } | ||
130 | desc_addr = next_desc; | ||
131 | } while (desc_addr != s->tx_queue[queue_index]); | ||
132 | @@ -XXX,XX +XXX,XX @@ static void mv88w8618_eth_realize(DeviceState *dev, Error **errp) | ||
133 | { | ||
134 | mv88w8618_eth_state *s = MV88W8618_ETH(dev); | ||
135 | |||
136 | + if (!s->dma_mr) { | ||
137 | + error_setg(errp, TYPE_MV88W8618_ETH " 'dma-memory' link not set"); | ||
138 | + return; | ||
139 | + } | ||
140 | + | ||
141 | + address_space_init(&s->dma_as, s->dma_mr, "emac-dma"); | ||
142 | s->nic = qemu_new_nic(&net_mv88w8618_info, &s->conf, | ||
143 | object_get_typename(OBJECT(dev)), dev->id, s); | ||
144 | } | ||
145 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription mv88w8618_eth_vmsd = { | ||
146 | |||
147 | static Property mv88w8618_eth_properties[] = { | ||
148 | DEFINE_NIC_PROPERTIES(mv88w8618_eth_state, conf), | ||
149 | + DEFINE_PROP_LINK("dma-memory", mv88w8618_eth_state, dma_mr, | ||
150 | + TYPE_MEMORY_REGION, MemoryRegion *), | ||
151 | DEFINE_PROP_END_OF_LIST(), | ||
19 | }; | 152 | }; |
20 | 153 | ||
21 | +/** | 154 | @@ -XXX,XX +XXX,XX @@ static void musicpal_init(MachineState *machine) |
22 | + * IOMMUMemoryRegionClass: | 155 | qemu_check_nic_model(&nd_table[0], "mv88w8618"); |
23 | + * | 156 | dev = qdev_new(TYPE_MV88W8618_ETH); |
24 | + * All IOMMU implementations need to subclass TYPE_IOMMU_MEMORY_REGION | 157 | qdev_set_nic_properties(dev, &nd_table[0]); |
25 | + * and provide an implementation of at least the @translate method here | 158 | + object_property_set_link(OBJECT(dev), "dma-memory", |
26 | + * to handle requests to the memory region. Other methods are optional. | 159 | + OBJECT(get_system_memory()), &error_fatal); |
27 | + * | 160 | sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); |
28 | + * The IOMMU implementation must use the IOMMU notifier infrastructure | 161 | sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, MP_ETH_BASE); |
29 | + * to report whenever mappings are changed, by calling | 162 | sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, pic[MP_ETH_IRQ]); |
30 | + * memory_region_notify_iommu() (or, if necessary, by calling | ||
31 | + * memory_region_notify_one() for each registered notifier). | ||
32 | + */ | ||
33 | typedef struct IOMMUMemoryRegionClass { | ||
34 | /* private */ | ||
35 | struct DeviceClass parent_class; | ||
36 | |||
37 | /* | ||
38 | - * Return a TLB entry that contains a given address. Flag should | ||
39 | - * be the access permission of this translation operation. We can | ||
40 | - * set flag to IOMMU_NONE to mean that we don't need any | ||
41 | - * read/write permission checks, like, when for region replay. | ||
42 | + * Return a TLB entry that contains a given address. | ||
43 | + * | ||
44 | + * The IOMMUAccessFlags indicated via @flag are optional and may | ||
45 | + * be specified as IOMMU_NONE to indicate that the caller needs | ||
46 | + * the full translation information for both reads and writes. If | ||
47 | + * the access flags are specified then the IOMMU implementation | ||
48 | + * may use this as an optimization, to stop doing a page table | ||
49 | + * walk as soon as it knows that the requested permissions are not | ||
50 | + * allowed. If IOMMU_NONE is passed then the IOMMU must do the | ||
51 | + * full page table walk and report the permissions in the returned | ||
52 | + * IOMMUTLBEntry. (Note that this implies that an IOMMU may not | ||
53 | + * return different mappings for reads and writes.) | ||
54 | + * | ||
55 | + * The returned information remains valid while the caller is | ||
56 | + * holding the big QEMU lock or is inside an RCU critical section; | ||
57 | + * if the caller wishes to cache the mapping beyond that it must | ||
58 | + * register an IOMMU notifier so it can invalidate its cached | ||
59 | + * information when the IOMMU mapping changes. | ||
60 | + * | ||
61 | + * @iommu: the IOMMUMemoryRegion | ||
62 | + * @hwaddr: address to be translated within the memory region | ||
63 | + * @flag: requested access permissions | ||
64 | */ | ||
65 | IOMMUTLBEntry (*translate)(IOMMUMemoryRegion *iommu, hwaddr addr, | ||
66 | IOMMUAccessFlags flag); | ||
67 | - /* Returns minimum supported page size */ | ||
68 | + /* Returns minimum supported page size in bytes. | ||
69 | + * If this method is not provided then the minimum is assumed to | ||
70 | + * be TARGET_PAGE_SIZE. | ||
71 | + * | ||
72 | + * @iommu: the IOMMUMemoryRegion | ||
73 | + */ | ||
74 | uint64_t (*get_min_page_size)(IOMMUMemoryRegion *iommu); | ||
75 | - /* Called when IOMMU Notifier flag changed */ | ||
76 | + /* Called when IOMMU Notifier flag changes (ie when the set of | ||
77 | + * events which IOMMU users are requesting notification for changes). | ||
78 | + * Optional method -- need not be provided if the IOMMU does not | ||
79 | + * need to know exactly which events must be notified. | ||
80 | + * | ||
81 | + * @iommu: the IOMMUMemoryRegion | ||
82 | + * @old_flags: events which previously needed to be notified | ||
83 | + * @new_flags: events which now need to be notified | ||
84 | + */ | ||
85 | void (*notify_flag_changed)(IOMMUMemoryRegion *iommu, | ||
86 | IOMMUNotifierFlag old_flags, | ||
87 | IOMMUNotifierFlag new_flags); | ||
88 | - /* Set this up to provide customized IOMMU replay function */ | ||
89 | + /* Called to handle memory_region_iommu_replay(). | ||
90 | + * | ||
91 | + * The default implementation of memory_region_iommu_replay() is to | ||
92 | + * call the IOMMU translate method for every page in the address space | ||
93 | + * with flag == IOMMU_NONE and then call the notifier if translate | ||
94 | + * returns a valid mapping. If this method is implemented then it | ||
95 | + * overrides the default behaviour, and must provide the full semantics | ||
96 | + * of memory_region_iommu_replay(), by calling @notifier for every | ||
97 | + * translation present in the IOMMU. | ||
98 | + * | ||
99 | + * Optional method -- an IOMMU only needs to provide this method | ||
100 | + * if the default is inefficient or produces undesirable side effects. | ||
101 | + * | ||
102 | + * Note: this is not related to record-and-replay functionality. | ||
103 | + */ | ||
104 | void (*replay)(IOMMUMemoryRegion *iommu, IOMMUNotifier *notifier); | ||
105 | |||
106 | - /* Get IOMMU misc attributes */ | ||
107 | - int (*get_attr)(IOMMUMemoryRegion *iommu, enum IOMMUMemoryRegionAttr, | ||
108 | + /* Get IOMMU misc attributes. This is an optional method that | ||
109 | + * can be used to allow users of the IOMMU to get implementation-specific | ||
110 | + * information. The IOMMU implements this method to handle calls | ||
111 | + * by IOMMU users to memory_region_iommu_get_attr() by filling in | ||
112 | + * the arbitrary data pointer for any IOMMUMemoryRegionAttr values that | ||
113 | + * the IOMMU supports. If the method is unimplemented then | ||
114 | + * memory_region_iommu_get_attr() will always return -EINVAL. | ||
115 | + * | ||
116 | + * @iommu: the IOMMUMemoryRegion | ||
117 | + * @attr: attribute being queried | ||
118 | + * @data: memory to fill in with the attribute data | ||
119 | + * | ||
120 | + * Returns 0 on success, or a negative errno; in particular | ||
121 | + * returns -EINVAL for unrecognized or unimplemented attribute types. | ||
122 | + */ | ||
123 | + int (*get_attr)(IOMMUMemoryRegion *iommu, enum IOMMUMemoryRegionAttr attr, | ||
124 | void *data); | ||
125 | } IOMMUMemoryRegionClass; | ||
126 | |||
127 | @@ -XXX,XX +XXX,XX @@ static inline void memory_region_init_reservation(MemoryRegion *mr, | ||
128 | * An IOMMU region translates addresses and forwards accesses to a target | ||
129 | * memory region. | ||
130 | * | ||
131 | + * The IOMMU implementation must define a subclass of TYPE_IOMMU_MEMORY_REGION. | ||
132 | + * @_iommu_mr should be a pointer to enough memory for an instance of | ||
133 | + * that subclass, @instance_size is the size of that subclass, and | ||
134 | + * @mrtypename is its name. This function will initialize @_iommu_mr as an | ||
135 | + * instance of the subclass, and its methods will then be called to handle | ||
136 | + * accesses to the memory region. See the documentation of | ||
137 | + * #IOMMUMemoryRegionClass for further details. | ||
138 | + * | ||
139 | * @_iommu_mr: the #IOMMUMemoryRegion to be initialized | ||
140 | * @instance_size: the IOMMUMemoryRegion subclass instance size | ||
141 | * @mrtypename: the type name of the #IOMMUMemoryRegion | ||
142 | @@ -XXX,XX +XXX,XX @@ void memory_region_register_iommu_notifier(MemoryRegion *mr, | ||
143 | * a notifier with the minimum page granularity returned by | ||
144 | * mr->iommu_ops->get_page_size(). | ||
145 | * | ||
146 | + * Note: this is not related to record-and-replay functionality. | ||
147 | + * | ||
148 | * @iommu_mr: the memory region to observe | ||
149 | * @n: the notifier to which to replay iommu mappings | ||
150 | */ | ||
151 | @@ -XXX,XX +XXX,XX @@ void memory_region_iommu_replay(IOMMUMemoryRegion *iommu_mr, IOMMUNotifier *n); | ||
152 | * memory_region_iommu_replay_all: replay existing IOMMU translations | ||
153 | * to all the notifiers registered. | ||
154 | * | ||
155 | + * Note: this is not related to record-and-replay functionality. | ||
156 | + * | ||
157 | * @iommu_mr: the memory region to observe | ||
158 | */ | ||
159 | void memory_region_iommu_replay_all(IOMMUMemoryRegion *iommu_mr); | ||
160 | @@ -XXX,XX +XXX,XX @@ void memory_region_unregister_iommu_notifier(MemoryRegion *mr, | ||
161 | * memory_region_iommu_get_attr: return an IOMMU attr if get_attr() is | ||
162 | * defined on the IOMMU. | ||
163 | * | ||
164 | - * Returns 0 if succeded, error code otherwise. | ||
165 | + * Returns 0 on success, or a negative errno otherwise. In particular, | ||
166 | + * -EINVAL indicates that the IOMMU does not support the requested | ||
167 | + * attribute. | ||
168 | * | ||
169 | * @iommu_mr: the memory region | ||
170 | * @attr: the requested attribute | ||
171 | -- | 163 | -- |
172 | 2.17.1 | 164 | 2.20.1 |
173 | 165 | ||
174 | 166 | diff view generated by jsdifflib |
1 | In commit f0aff255700 we made cpacr_write() enforce that some CPACR | 1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> |
---|---|---|---|
2 | bits are RAZ/WI and some are RAO/WI for ARMv7 cores. Unfortunately | ||
3 | we forgot to also update the register's reset value. The effect | ||
4 | was that (a) a guest that read CPACR on reset would not see ones in | ||
5 | the RAO bits, and (b) if you did a migration before the guest did | ||
6 | a write to the CPACR then the migration would fail because the | ||
7 | destination would enforce the RAO bits and then complain that they | ||
8 | didn't match the zero value from the source. | ||
9 | 2 | ||
10 | Implement reset for the CPACR using a custom reset function | 3 | In commit ce4afed839 ("target/arm: Implement AArch32 HCR and HCR2") |
11 | that just calls cpacr_write(), to avoid having to duplicate | 4 | the HCR_EL2 register has been changed from type NO_RAW (no underlying |
12 | the logic for which bits are RAO. | 5 | state and does not support raw access for state saving/loading) to |
6 | type CONST (TCG can assume the value to be constant), removing the | ||
7 | read/write accessors. | ||
8 | We forgot to remove the previous type ARM_CP_NO_RAW. This is not | ||
9 | really a problem since the field is overwritten. However it makes | ||
10 | code review confuse, so remove it. | ||
13 | 11 | ||
14 | This bug would affect migration for TCG CPUs which are ARMv7 | 12 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
15 | with VFP but without one of Neon or VFPv3. | 13 | Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> |
16 | 14 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | |
17 | Reported-by: Cédric Le Goater <clg@kaod.org> | 15 | Message-id: 20200812111223.7787-1-f4bug@amsat.org |
18 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
19 | Tested-by: Cédric Le Goater <clg@kaod.org> | ||
20 | Message-id: 20180522173713.26282-1-peter.maydell@linaro.org | ||
21 | --- | 17 | --- |
22 | target/arm/helper.c | 10 +++++++++- | 18 | target/arm/helper.c | 1 - |
23 | 1 file changed, 9 insertions(+), 1 deletion(-) | 19 | 1 file changed, 1 deletion(-) |
24 | 20 | ||
25 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 21 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
26 | index XXXXXXX..XXXXXXX 100644 | 22 | index XXXXXXX..XXXXXXX 100644 |
27 | --- a/target/arm/helper.c | 23 | --- a/target/arm/helper.c |
28 | +++ b/target/arm/helper.c | 24 | +++ b/target/arm/helper.c |
29 | @@ -XXX,XX +XXX,XX @@ static void cpacr_write(CPUARMState *env, const ARMCPRegInfo *ri, | 25 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo el3_no_el2_cp_reginfo[] = { |
30 | env->cp15.cpacr_el1 = value; | 26 | .access = PL2_RW, |
31 | } | 27 | .readfn = arm_cp_read_zero, .writefn = arm_cp_write_ignore }, |
32 | 28 | { .name = "HCR_EL2", .state = ARM_CP_STATE_BOTH, | |
33 | +static void cpacr_reset(CPUARMState *env, const ARMCPRegInfo *ri) | 29 | - .type = ARM_CP_NO_RAW, |
34 | +{ | 30 | .opc0 = 3, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 0, |
35 | + /* Call cpacr_write() so that we reset with the correct RAO bits set | 31 | .access = PL2_RW, |
36 | + * for our CPU features. | 32 | .type = ARM_CP_CONST, .resetvalue = 0 }, |
37 | + */ | ||
38 | + cpacr_write(env, ri, 0); | ||
39 | +} | ||
40 | + | ||
41 | static CPAccessResult cpacr_access(CPUARMState *env, const ARMCPRegInfo *ri, | ||
42 | bool isread) | ||
43 | { | ||
44 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v6_cp_reginfo[] = { | ||
45 | { .name = "CPACR", .state = ARM_CP_STATE_BOTH, .opc0 = 3, | ||
46 | .crn = 1, .crm = 0, .opc1 = 0, .opc2 = 2, .accessfn = cpacr_access, | ||
47 | .access = PL1_RW, .fieldoffset = offsetof(CPUARMState, cp15.cpacr_el1), | ||
48 | - .resetvalue = 0, .writefn = cpacr_write }, | ||
49 | + .resetfn = cpacr_reset, .writefn = cpacr_write }, | ||
50 | REGINFO_SENTINEL | ||
51 | }; | ||
52 | |||
53 | -- | 33 | -- |
54 | 2.17.1 | 34 | 2.20.1 |
55 | 35 | ||
56 | 36 | diff view generated by jsdifflib |
1 | The FRECPX instructions should (like most other floating point operations) | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | honour the FPCR.FZ bit which specifies whether input denormals should | ||
3 | be flushed to zero (or FZ16 for the half-precision version). | ||
4 | We forgot to implement this, which doesn't affect the results (since | ||
5 | the calculation doesn't actually care about the mantissa bits) but did | ||
6 | mean we were failing to set the FPSR.IDC bit. | ||
7 | 2 | ||
3 | We need more information than just the mmu_idx in order | ||
4 | to create the proper exception syndrome. Only change the | ||
5 | function signature so far. | ||
6 | |||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20200813200816.3037186-2-richard.henderson@linaro.org | ||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
10 | Message-id: 20180521172712.19930-1-peter.maydell@linaro.org | ||
11 | --- | 11 | --- |
12 | target/arm/helper-a64.c | 6 ++++++ | 12 | target/arm/mte_helper.c | 10 +++++----- |
13 | 1 file changed, 6 insertions(+) | 13 | 1 file changed, 5 insertions(+), 5 deletions(-) |
14 | 14 | ||
15 | diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c | 15 | diff --git a/target/arm/mte_helper.c b/target/arm/mte_helper.c |
16 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/helper-a64.c | 17 | --- a/target/arm/mte_helper.c |
18 | +++ b/target/arm/helper-a64.c | 18 | +++ b/target/arm/mte_helper.c |
19 | @@ -XXX,XX +XXX,XX @@ float16 HELPER(frecpx_f16)(float16 a, void *fpstp) | 19 | @@ -XXX,XX +XXX,XX @@ void HELPER(stzgm_tags)(CPUARMState *env, uint64_t ptr, uint64_t val) |
20 | return nan; | 20 | } |
21 | |||
22 | /* Record a tag check failure. */ | ||
23 | -static void mte_check_fail(CPUARMState *env, int mmu_idx, | ||
24 | +static void mte_check_fail(CPUARMState *env, uint32_t desc, | ||
25 | uint64_t dirty_ptr, uintptr_t ra) | ||
26 | { | ||
27 | + int mmu_idx = FIELD_EX32(desc, MTEDESC, MIDX); | ||
28 | ARMMMUIdx arm_mmu_idx = core_to_aa64_mmu_idx(mmu_idx); | ||
29 | int el, reg_el, tcf, select; | ||
30 | uint64_t sctlr; | ||
31 | @@ -XXX,XX +XXX,XX @@ uint64_t mte_check1(CPUARMState *env, uint32_t desc, | ||
21 | } | 32 | } |
22 | 33 | ||
23 | + a = float16_squash_input_denormal(a, fpst); | 34 | if (unlikely(!mte_probe1_int(env, desc, ptr, ra, bit55))) { |
24 | + | 35 | - int mmu_idx = FIELD_EX32(desc, MTEDESC, MIDX); |
25 | val16 = float16_val(a); | 36 | - mte_check_fail(env, mmu_idx, ptr, ra); |
26 | sbit = 0x8000 & val16; | 37 | + mte_check_fail(env, desc, ptr, ra); |
27 | exp = extract32(val16, 10, 5); | ||
28 | @@ -XXX,XX +XXX,XX @@ float32 HELPER(frecpx_f32)(float32 a, void *fpstp) | ||
29 | return nan; | ||
30 | } | 38 | } |
31 | 39 | ||
32 | + a = float32_squash_input_denormal(a, fpst); | 40 | return useronly_clean_ptr(ptr); |
33 | + | 41 | @@ -XXX,XX +XXX,XX @@ uint64_t mte_checkN(CPUARMState *env, uint32_t desc, |
34 | val32 = float32_val(a); | 42 | |
35 | sbit = 0x80000000ULL & val32; | 43 | fail_ofs = tag_first + n * TAG_GRANULE - ptr; |
36 | exp = extract32(val32, 23, 8); | 44 | fail_ofs = ROUND_UP(fail_ofs, esize); |
37 | @@ -XXX,XX +XXX,XX @@ float64 HELPER(frecpx_f64)(float64 a, void *fpstp) | 45 | - mte_check_fail(env, mmu_idx, ptr + fail_ofs, ra); |
38 | return nan; | 46 | + mte_check_fail(env, desc, ptr + fail_ofs, ra); |
39 | } | 47 | } |
40 | 48 | ||
41 | + a = float64_squash_input_denormal(a, fpst); | 49 | done: |
42 | + | 50 | @@ -XXX,XX +XXX,XX @@ uint64_t HELPER(mte_check_zva)(CPUARMState *env, uint32_t desc, uint64_t ptr) |
43 | val64 = float64_val(a); | 51 | fail: |
44 | sbit = 0x8000000000000000ULL & val64; | 52 | /* Locate the first nibble that differs. */ |
45 | exp = extract64(float64_val(a), 52, 11); | 53 | i = ctz64(mem_tag ^ ptr_tag) >> 4; |
54 | - mte_check_fail(env, mmu_idx, align_ptr + i * TAG_GRANULE, ra); | ||
55 | + mte_check_fail(env, desc, align_ptr + i * TAG_GRANULE, ra); | ||
56 | |||
57 | done: | ||
58 | return useronly_clean_ptr(ptr); | ||
46 | -- | 59 | -- |
47 | 2.17.1 | 60 | 2.20.1 |
48 | 61 | ||
49 | 62 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
1 | 2 | ||
3 | According to AArch64.TagCheckFault, none of the other ISS values are | ||
4 | provided, so we do not need to go so far as merge_syn_data_abort. | ||
5 | But we were missing the WnR bit. | ||
6 | |||
7 | Tested-by: Andrey Konovalov <andreyknvl@google.com> | ||
8 | Reported-by: Andrey Konovalov <andreyknvl@google.com> | ||
9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
10 | Message-id: 20200813200816.3037186-3-richard.henderson@linaro.org | ||
11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | --- | ||
14 | target/arm/mte_helper.c | 9 +++++---- | ||
15 | 1 file changed, 5 insertions(+), 4 deletions(-) | ||
16 | |||
17 | diff --git a/target/arm/mte_helper.c b/target/arm/mte_helper.c | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/target/arm/mte_helper.c | ||
20 | +++ b/target/arm/mte_helper.c | ||
21 | @@ -XXX,XX +XXX,XX @@ static void mte_check_fail(CPUARMState *env, uint32_t desc, | ||
22 | { | ||
23 | int mmu_idx = FIELD_EX32(desc, MTEDESC, MIDX); | ||
24 | ARMMMUIdx arm_mmu_idx = core_to_aa64_mmu_idx(mmu_idx); | ||
25 | - int el, reg_el, tcf, select; | ||
26 | + int el, reg_el, tcf, select, is_write, syn; | ||
27 | uint64_t sctlr; | ||
28 | |||
29 | reg_el = regime_el(env, arm_mmu_idx); | ||
30 | @@ -XXX,XX +XXX,XX @@ static void mte_check_fail(CPUARMState *env, uint32_t desc, | ||
31 | */ | ||
32 | cpu_restore_state(env_cpu(env), ra, true); | ||
33 | env->exception.vaddress = dirty_ptr; | ||
34 | - raise_exception(env, EXCP_DATA_ABORT, | ||
35 | - syn_data_abort_no_iss(el != 0, 0, 0, 0, 0, 0, 0x11), | ||
36 | - exception_target_el(env)); | ||
37 | + | ||
38 | + is_write = FIELD_EX32(desc, MTEDESC, WRITE); | ||
39 | + syn = syn_data_abort_no_iss(el != 0, 0, 0, 0, 0, is_write, 0x11); | ||
40 | + raise_exception(env, EXCP_DATA_ABORT, syn, exception_target_el(env)); | ||
41 | /* noreturn, but fall through to the assert anyway */ | ||
42 | |||
43 | case 0: | ||
44 | -- | ||
45 | 2.20.1 | ||
46 | |||
47 | diff view generated by jsdifflib |
1 | From: Shannon Zhao <zhaoshenglong@huawei.com> | 1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> |
---|---|---|---|
2 | 2 | ||
3 | acpi_data_push uses g_array_set_size to resize the memory size. If there | 3 | Allow the device to execute the DMA transfers in a different |
4 | is no enough contiguous memory, the address will be changed. So previous | 4 | AddressSpace. |
5 | pointer could not be used any more. It must update the pointer and use | ||
6 | the new one. | ||
7 | 5 | ||
8 | Also, previous codes wrongly use le32 conversion of iort->node_offset | 6 | The A10 and H3 SoC keep using the system_memory address space, |
9 | for subsequent computations that will result incorrect value if host is | 7 | but via the proper dma_memory_access() API. |
10 | not litlle endian. So use the non-converted one instead. | ||
11 | 8 | ||
12 | Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com> | 9 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
13 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | 10 | Tested-by: Niek Linnenbank <nieklinnenbank@gmail.com> |
14 | Message-id: 1527663951-14552-1-git-send-email-zhaoshenglong@huawei.com | 11 | Reviewed-by: Niek Linnenbank <nieklinnenbank@gmail.com> |
12 | Message-id: 20200814110057.307-1-f4bug@amsat.org | ||
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
16 | --- | 14 | --- |
17 | hw/arm/virt-acpi-build.c | 20 +++++++++++++++----- | 15 | include/hw/sd/allwinner-sdhost.h | 6 ++++++ |
18 | 1 file changed, 15 insertions(+), 5 deletions(-) | 16 | hw/arm/allwinner-a10.c | 2 ++ |
17 | hw/arm/allwinner-h3.c | 2 ++ | ||
18 | hw/sd/allwinner-sdhost.c | 37 ++++++++++++++++++++++++++------ | ||
19 | 4 files changed, 41 insertions(+), 6 deletions(-) | ||
19 | 20 | ||
20 | diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c | 21 | diff --git a/include/hw/sd/allwinner-sdhost.h b/include/hw/sd/allwinner-sdhost.h |
21 | index XXXXXXX..XXXXXXX 100644 | 22 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/hw/arm/virt-acpi-build.c | 23 | --- a/include/hw/sd/allwinner-sdhost.h |
23 | +++ b/hw/arm/virt-acpi-build.c | 24 | +++ b/include/hw/sd/allwinner-sdhost.h |
24 | @@ -XXX,XX +XXX,XX @@ build_iort(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) | 25 | @@ -XXX,XX +XXX,XX @@ typedef struct AwSdHostState { |
25 | AcpiIortItsGroup *its; | 26 | /** Interrupt output signal to notify CPU */ |
26 | AcpiIortTable *iort; | 27 | qemu_irq irq; |
27 | AcpiIortSmmu3 *smmu; | 28 | |
28 | - size_t node_size, iort_length, smmu_offset = 0; | 29 | + /** Memory region where DMA transfers are done */ |
29 | + size_t node_size, iort_node_offset, iort_length, smmu_offset = 0; | 30 | + MemoryRegion *dma_mr; |
30 | AcpiIortRC *rc; | 31 | + |
31 | 32 | + /** Address space used internally for DMA transfers */ | |
32 | iort = acpi_data_push(table_data, sizeof(*iort)); | 33 | + AddressSpace dma_as; |
33 | @@ -XXX,XX +XXX,XX @@ build_iort(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) | 34 | + |
34 | 35 | /** Number of bytes left in current DMA transfer */ | |
35 | iort_length = sizeof(*iort); | 36 | uint32_t transfer_cnt; |
36 | iort->node_count = cpu_to_le32(nb_nodes); | 37 | |
37 | - iort->node_offset = cpu_to_le32(sizeof(*iort)); | 38 | diff --git a/hw/arm/allwinner-a10.c b/hw/arm/allwinner-a10.c |
38 | + /* | 39 | index XXXXXXX..XXXXXXX 100644 |
39 | + * Use a copy in case table_data->data moves during acpi_data_push | 40 | --- a/hw/arm/allwinner-a10.c |
40 | + * operations. | 41 | +++ b/hw/arm/allwinner-a10.c |
41 | + */ | 42 | @@ -XXX,XX +XXX,XX @@ static void aw_a10_realize(DeviceState *dev, Error **errp) |
42 | + iort_node_offset = sizeof(*iort); | ||
43 | + iort->node_offset = cpu_to_le32(iort_node_offset); | ||
44 | |||
45 | /* ITS group node */ | ||
46 | node_size = sizeof(*its) + sizeof(uint32_t); | ||
47 | @@ -XXX,XX +XXX,XX @@ build_iort(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) | ||
48 | int irq = vms->irqmap[VIRT_SMMU]; | ||
49 | |||
50 | /* SMMUv3 node */ | ||
51 | - smmu_offset = iort->node_offset + node_size; | ||
52 | + smmu_offset = iort_node_offset + node_size; | ||
53 | node_size = sizeof(*smmu) + sizeof(*idmap); | ||
54 | iort_length += node_size; | ||
55 | smmu = acpi_data_push(table_data, node_size); | ||
56 | @@ -XXX,XX +XXX,XX @@ build_iort(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) | ||
57 | idmap->id_count = cpu_to_le32(0xFFFF); | ||
58 | idmap->output_base = 0; | ||
59 | /* output IORT node is the ITS group node (the first node) */ | ||
60 | - idmap->output_reference = cpu_to_le32(iort->node_offset); | ||
61 | + idmap->output_reference = cpu_to_le32(iort_node_offset); | ||
62 | } | 43 | } |
63 | 44 | ||
64 | /* Root Complex Node */ | 45 | /* SD/MMC */ |
65 | @@ -XXX,XX +XXX,XX @@ build_iort(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) | 46 | + object_property_set_link(OBJECT(&s->mmc0), "dma-memory", |
66 | idmap->output_reference = cpu_to_le32(smmu_offset); | 47 | + OBJECT(get_system_memory()), &error_fatal); |
67 | } else { | 48 | sysbus_realize(SYS_BUS_DEVICE(&s->mmc0), &error_fatal); |
68 | /* output IORT node is the ITS group node (the first node) */ | 49 | sysbus_mmio_map(SYS_BUS_DEVICE(&s->mmc0), 0, AW_A10_MMC0_BASE); |
69 | - idmap->output_reference = cpu_to_le32(iort->node_offset); | 50 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->mmc0), 0, qdev_get_gpio_in(dev, 32)); |
70 | + idmap->output_reference = cpu_to_le32(iort_node_offset); | 51 | diff --git a/hw/arm/allwinner-h3.c b/hw/arm/allwinner-h3.c |
52 | index XXXXXXX..XXXXXXX 100644 | ||
53 | --- a/hw/arm/allwinner-h3.c | ||
54 | +++ b/hw/arm/allwinner-h3.c | ||
55 | @@ -XXX,XX +XXX,XX @@ static void allwinner_h3_realize(DeviceState *dev, Error **errp) | ||
56 | sysbus_mmio_map(SYS_BUS_DEVICE(&s->sid), 0, s->memmap[AW_H3_SID]); | ||
57 | |||
58 | /* SD/MMC */ | ||
59 | + object_property_set_link(OBJECT(&s->mmc0), "dma-memory", | ||
60 | + OBJECT(get_system_memory()), &error_fatal); | ||
61 | sysbus_realize(SYS_BUS_DEVICE(&s->mmc0), &error_fatal); | ||
62 | sysbus_mmio_map(SYS_BUS_DEVICE(&s->mmc0), 0, s->memmap[AW_H3_MMC0]); | ||
63 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->mmc0), 0, | ||
64 | diff --git a/hw/sd/allwinner-sdhost.c b/hw/sd/allwinner-sdhost.c | ||
65 | index XXXXXXX..XXXXXXX 100644 | ||
66 | --- a/hw/sd/allwinner-sdhost.c | ||
67 | +++ b/hw/sd/allwinner-sdhost.c | ||
68 | @@ -XXX,XX +XXX,XX @@ | ||
69 | #include "qemu/log.h" | ||
70 | #include "qemu/module.h" | ||
71 | #include "qemu/units.h" | ||
72 | +#include "qapi/error.h" | ||
73 | #include "sysemu/blockdev.h" | ||
74 | +#include "sysemu/dma.h" | ||
75 | +#include "hw/qdev-properties.h" | ||
76 | #include "hw/irq.h" | ||
77 | #include "hw/sd/allwinner-sdhost.h" | ||
78 | #include "migration/vmstate.h" | ||
79 | @@ -XXX,XX +XXX,XX @@ static uint32_t allwinner_sdhost_process_desc(AwSdHostState *s, | ||
80 | uint8_t buf[1024]; | ||
81 | |||
82 | /* Read descriptor */ | ||
83 | - cpu_physical_memory_read(desc_addr, desc, sizeof(*desc)); | ||
84 | + dma_memory_read(&s->dma_as, desc_addr, desc, sizeof(*desc)); | ||
85 | if (desc->size == 0) { | ||
86 | desc->size = klass->max_desc_size; | ||
87 | } else if (desc->size > klass->max_desc_size) { | ||
88 | @@ -XXX,XX +XXX,XX @@ static uint32_t allwinner_sdhost_process_desc(AwSdHostState *s, | ||
89 | |||
90 | /* Write to SD bus */ | ||
91 | if (is_write) { | ||
92 | - cpu_physical_memory_read((desc->addr & DESC_SIZE_MASK) + num_done, | ||
93 | - buf, buf_bytes); | ||
94 | + dma_memory_read(&s->dma_as, | ||
95 | + (desc->addr & DESC_SIZE_MASK) + num_done, | ||
96 | + buf, buf_bytes); | ||
97 | sdbus_write_data(&s->sdbus, buf, buf_bytes); | ||
98 | |||
99 | /* Read from SD bus */ | ||
100 | } else { | ||
101 | sdbus_read_data(&s->sdbus, buf, buf_bytes); | ||
102 | - cpu_physical_memory_write((desc->addr & DESC_SIZE_MASK) + num_done, | ||
103 | - buf, buf_bytes); | ||
104 | + dma_memory_write(&s->dma_as, | ||
105 | + (desc->addr & DESC_SIZE_MASK) + num_done, | ||
106 | + buf, buf_bytes); | ||
107 | } | ||
108 | num_done += buf_bytes; | ||
71 | } | 109 | } |
72 | 110 | ||
73 | + /* | 111 | /* Clear hold flag and flush descriptor */ |
74 | + * Update the pointer address in case table_data->data moves during above | 112 | desc->status &= ~DESC_STATUS_HOLD; |
75 | + * acpi_data_push operations. | 113 | - cpu_physical_memory_write(desc_addr, desc, sizeof(*desc)); |
76 | + */ | 114 | + dma_memory_write(&s->dma_as, desc_addr, desc, sizeof(*desc)); |
77 | + iort = (AcpiIortTable *)(table_data->data + iort_start); | 115 | |
78 | iort->length = cpu_to_le32(iort_length); | 116 | return num_done; |
79 | 117 | } | |
80 | build_header(linker, table_data, (void *)(table_data->data + iort_start), | 118 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_allwinner_sdhost = { |
119 | } | ||
120 | }; | ||
121 | |||
122 | +static Property allwinner_sdhost_properties[] = { | ||
123 | + DEFINE_PROP_LINK("dma-memory", AwSdHostState, dma_mr, | ||
124 | + TYPE_MEMORY_REGION, MemoryRegion *), | ||
125 | + DEFINE_PROP_END_OF_LIST(), | ||
126 | +}; | ||
127 | + | ||
128 | static void allwinner_sdhost_init(Object *obj) | ||
129 | { | ||
130 | AwSdHostState *s = AW_SDHOST(obj); | ||
131 | @@ -XXX,XX +XXX,XX @@ static void allwinner_sdhost_init(Object *obj) | ||
132 | sysbus_init_irq(SYS_BUS_DEVICE(s), &s->irq); | ||
133 | } | ||
134 | |||
135 | +static void allwinner_sdhost_realize(DeviceState *dev, Error **errp) | ||
136 | +{ | ||
137 | + AwSdHostState *s = AW_SDHOST(dev); | ||
138 | + | ||
139 | + if (!s->dma_mr) { | ||
140 | + error_setg(errp, TYPE_AW_SDHOST " 'dma-memory' link not set"); | ||
141 | + return; | ||
142 | + } | ||
143 | + | ||
144 | + address_space_init(&s->dma_as, s->dma_mr, "sdhost-dma"); | ||
145 | +} | ||
146 | + | ||
147 | static void allwinner_sdhost_reset(DeviceState *dev) | ||
148 | { | ||
149 | AwSdHostState *s = AW_SDHOST(dev); | ||
150 | @@ -XXX,XX +XXX,XX @@ static void allwinner_sdhost_class_init(ObjectClass *klass, void *data) | ||
151 | |||
152 | dc->reset = allwinner_sdhost_reset; | ||
153 | dc->vmsd = &vmstate_allwinner_sdhost; | ||
154 | + dc->realize = allwinner_sdhost_realize; | ||
155 | + device_class_set_props(dc, allwinner_sdhost_properties); | ||
156 | } | ||
157 | |||
158 | static void allwinner_sdhost_sun4i_class_init(ObjectClass *klass, void *data) | ||
81 | -- | 159 | -- |
82 | 2.17.1 | 160 | 2.20.1 |
83 | 161 | ||
84 | 162 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | 1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | |
2 | |||
3 | Allow the device to execute the DMA transfers in a different | ||
4 | AddressSpace. | ||
5 | |||
6 | The H3 SoC keeps using the system_memory address space, | ||
7 | but via the proper dma_memory_access() API. | ||
8 | |||
9 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
11 | Reviewed-by: Niek Linnenbank <nieklinnenbank@gmail.com> | ||
12 | Tested-by: Niek Linnenbank <nieklinnenbank@gmail.com> | ||
13 | Message-id: 20200814122907.27732-1-f4bug@amsat.org | ||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
15 | --- | ||
16 | include/hw/net/allwinner-sun8i-emac.h | 6 ++++ | ||
17 | hw/arm/allwinner-h3.c | 2 ++ | ||
18 | hw/net/allwinner-sun8i-emac.c | 46 +++++++++++++++++---------- | ||
19 | 3 files changed, 38 insertions(+), 16 deletions(-) | ||
20 | |||
21 | diff --git a/include/hw/net/allwinner-sun8i-emac.h b/include/hw/net/allwinner-sun8i-emac.h | ||
22 | index XXXXXXX..XXXXXXX 100644 | ||
23 | --- a/include/hw/net/allwinner-sun8i-emac.h | ||
24 | +++ b/include/hw/net/allwinner-sun8i-emac.h | ||
25 | @@ -XXX,XX +XXX,XX @@ typedef struct AwSun8iEmacState { | ||
26 | /** Interrupt output signal to notify CPU */ | ||
27 | qemu_irq irq; | ||
28 | |||
29 | + /** Memory region where DMA transfers are done */ | ||
30 | + MemoryRegion *dma_mr; | ||
31 | + | ||
32 | + /** Address space used internally for DMA transfers */ | ||
33 | + AddressSpace dma_as; | ||
34 | + | ||
35 | /** Generic Network Interface Controller (NIC) for networking API */ | ||
36 | NICState *nic; | ||
37 | |||
38 | diff --git a/hw/arm/allwinner-h3.c b/hw/arm/allwinner-h3.c | ||
39 | index XXXXXXX..XXXXXXX 100644 | ||
40 | --- a/hw/arm/allwinner-h3.c | ||
41 | +++ b/hw/arm/allwinner-h3.c | ||
42 | @@ -XXX,XX +XXX,XX @@ static void allwinner_h3_realize(DeviceState *dev, Error **errp) | ||
43 | qemu_check_nic_model(&nd_table[0], TYPE_AW_SUN8I_EMAC); | ||
44 | qdev_set_nic_properties(DEVICE(&s->emac), &nd_table[0]); | ||
45 | } | ||
46 | + object_property_set_link(OBJECT(&s->emac), "dma-memory", | ||
47 | + OBJECT(get_system_memory()), &error_fatal); | ||
48 | sysbus_realize(SYS_BUS_DEVICE(&s->emac), &error_fatal); | ||
49 | sysbus_mmio_map(SYS_BUS_DEVICE(&s->emac), 0, s->memmap[AW_H3_EMAC]); | ||
50 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->emac), 0, | ||
51 | diff --git a/hw/net/allwinner-sun8i-emac.c b/hw/net/allwinner-sun8i-emac.c | ||
52 | index XXXXXXX..XXXXXXX 100644 | ||
53 | --- a/hw/net/allwinner-sun8i-emac.c | ||
54 | +++ b/hw/net/allwinner-sun8i-emac.c | ||
55 | @@ -XXX,XX +XXX,XX @@ | ||
56 | |||
57 | #include "qemu/osdep.h" | ||
58 | #include "qemu/units.h" | ||
59 | +#include "qapi/error.h" | ||
60 | #include "hw/sysbus.h" | ||
61 | #include "migration/vmstate.h" | ||
62 | #include "net/net.h" | ||
63 | @@ -XXX,XX +XXX,XX @@ | ||
64 | #include "net/checksum.h" | ||
65 | #include "qemu/module.h" | ||
66 | #include "exec/cpu-common.h" | ||
67 | +#include "sysemu/dma.h" | ||
68 | #include "hw/net/allwinner-sun8i-emac.h" | ||
69 | |||
70 | /* EMAC register offsets */ | ||
71 | @@ -XXX,XX +XXX,XX @@ static void allwinner_sun8i_emac_update_irq(AwSun8iEmacState *s) | ||
72 | qemu_set_irq(s->irq, (s->int_sta & s->int_en) != 0); | ||
73 | } | ||
74 | |||
75 | -static uint32_t allwinner_sun8i_emac_next_desc(FrameDescriptor *desc, | ||
76 | +static uint32_t allwinner_sun8i_emac_next_desc(AwSun8iEmacState *s, | ||
77 | + FrameDescriptor *desc, | ||
78 | size_t min_size) | ||
79 | { | ||
80 | uint32_t paddr = desc->next; | ||
81 | |||
82 | - cpu_physical_memory_read(paddr, desc, sizeof(*desc)); | ||
83 | + dma_memory_read(&s->dma_as, paddr, desc, sizeof(*desc)); | ||
84 | |||
85 | if ((desc->status & DESC_STATUS_CTL) && | ||
86 | (desc->status2 & DESC_STATUS2_BUF_SIZE_MASK) >= min_size) { | ||
87 | @@ -XXX,XX +XXX,XX @@ static uint32_t allwinner_sun8i_emac_next_desc(FrameDescriptor *desc, | ||
88 | } | ||
89 | } | ||
90 | |||
91 | -static uint32_t allwinner_sun8i_emac_get_desc(FrameDescriptor *desc, | ||
92 | +static uint32_t allwinner_sun8i_emac_get_desc(AwSun8iEmacState *s, | ||
93 | + FrameDescriptor *desc, | ||
94 | uint32_t start_addr, | ||
95 | size_t min_size) | ||
96 | { | ||
97 | @@ -XXX,XX +XXX,XX @@ static uint32_t allwinner_sun8i_emac_get_desc(FrameDescriptor *desc, | ||
98 | |||
99 | /* Note that the list is a cycle. Last entry points back to the head. */ | ||
100 | while (desc_addr != 0) { | ||
101 | - cpu_physical_memory_read(desc_addr, desc, sizeof(*desc)); | ||
102 | + dma_memory_read(&s->dma_as, desc_addr, desc, sizeof(*desc)); | ||
103 | |||
104 | if ((desc->status & DESC_STATUS_CTL) && | ||
105 | (desc->status2 & DESC_STATUS2_BUF_SIZE_MASK) >= min_size) { | ||
106 | @@ -XXX,XX +XXX,XX @@ static uint32_t allwinner_sun8i_emac_rx_desc(AwSun8iEmacState *s, | ||
107 | FrameDescriptor *desc, | ||
108 | size_t min_size) | ||
109 | { | ||
110 | - return allwinner_sun8i_emac_get_desc(desc, s->rx_desc_curr, min_size); | ||
111 | + return allwinner_sun8i_emac_get_desc(s, desc, s->rx_desc_curr, min_size); | ||
112 | } | ||
113 | |||
114 | static uint32_t allwinner_sun8i_emac_tx_desc(AwSun8iEmacState *s, | ||
115 | FrameDescriptor *desc, | ||
116 | size_t min_size) | ||
117 | { | ||
118 | - return allwinner_sun8i_emac_get_desc(desc, s->tx_desc_head, min_size); | ||
119 | + return allwinner_sun8i_emac_get_desc(s, desc, s->tx_desc_head, min_size); | ||
120 | } | ||
121 | |||
122 | -static void allwinner_sun8i_emac_flush_desc(FrameDescriptor *desc, | ||
123 | +static void allwinner_sun8i_emac_flush_desc(AwSun8iEmacState *s, | ||
124 | + FrameDescriptor *desc, | ||
125 | uint32_t phys_addr) | ||
126 | { | ||
127 | - cpu_physical_memory_write(phys_addr, desc, sizeof(*desc)); | ||
128 | + dma_memory_write(&s->dma_as, phys_addr, desc, sizeof(*desc)); | ||
129 | } | ||
130 | |||
131 | static bool allwinner_sun8i_emac_can_receive(NetClientState *nc) | ||
132 | @@ -XXX,XX +XXX,XX @@ static ssize_t allwinner_sun8i_emac_receive(NetClientState *nc, | ||
133 | << RX_DESC_STATUS_FRM_LEN_SHIFT; | ||
134 | } | ||
135 | |||
136 | - cpu_physical_memory_write(desc.addr, buf, desc_bytes); | ||
137 | - allwinner_sun8i_emac_flush_desc(&desc, s->rx_desc_curr); | ||
138 | + dma_memory_write(&s->dma_as, desc.addr, buf, desc_bytes); | ||
139 | + allwinner_sun8i_emac_flush_desc(s, &desc, s->rx_desc_curr); | ||
140 | trace_allwinner_sun8i_emac_receive(s->rx_desc_curr, desc.addr, | ||
141 | desc_bytes); | ||
142 | |||
143 | @@ -XXX,XX +XXX,XX @@ static ssize_t allwinner_sun8i_emac_receive(NetClientState *nc, | ||
144 | bytes_left -= desc_bytes; | ||
145 | |||
146 | /* Move to the next descriptor */ | ||
147 | - s->rx_desc_curr = allwinner_sun8i_emac_next_desc(&desc, 64); | ||
148 | + s->rx_desc_curr = allwinner_sun8i_emac_next_desc(s, &desc, 64); | ||
149 | if (!s->rx_desc_curr) { | ||
150 | /* Not enough buffer space available */ | ||
151 | s->int_sta |= INT_STA_RX_BUF_UA; | ||
152 | @@ -XXX,XX +XXX,XX @@ static void allwinner_sun8i_emac_transmit(AwSun8iEmacState *s) | ||
153 | desc.status |= TX_DESC_STATUS_LENGTH_ERR; | ||
154 | break; | ||
155 | } | ||
156 | - cpu_physical_memory_read(desc.addr, packet_buf + packet_bytes, bytes); | ||
157 | + dma_memory_read(&s->dma_as, desc.addr, packet_buf + packet_bytes, bytes); | ||
158 | packet_bytes += bytes; | ||
159 | desc.status &= ~DESC_STATUS_CTL; | ||
160 | - allwinner_sun8i_emac_flush_desc(&desc, s->tx_desc_curr); | ||
161 | + allwinner_sun8i_emac_flush_desc(s, &desc, s->tx_desc_curr); | ||
162 | |||
163 | /* After the last descriptor, send the packet */ | ||
164 | if (desc.status2 & TX_DESC_STATUS2_LAST_DESC) { | ||
165 | @@ -XXX,XX +XXX,XX @@ static void allwinner_sun8i_emac_transmit(AwSun8iEmacState *s) | ||
166 | packet_bytes = 0; | ||
167 | transmitted++; | ||
168 | } | ||
169 | - s->tx_desc_curr = allwinner_sun8i_emac_next_desc(&desc, 0); | ||
170 | + s->tx_desc_curr = allwinner_sun8i_emac_next_desc(s, &desc, 0); | ||
171 | } | ||
172 | |||
173 | /* Raise transmit completed interrupt */ | ||
174 | @@ -XXX,XX +XXX,XX @@ static uint64_t allwinner_sun8i_emac_read(void *opaque, hwaddr offset, | ||
175 | break; | ||
176 | case REG_TX_CUR_BUF: /* Transmit Current Buffer */ | ||
177 | if (s->tx_desc_curr != 0) { | ||
178 | - cpu_physical_memory_read(s->tx_desc_curr, &desc, sizeof(desc)); | ||
179 | + dma_memory_read(&s->dma_as, s->tx_desc_curr, &desc, sizeof(desc)); | ||
180 | value = desc.addr; | ||
181 | } else { | ||
182 | value = 0; | ||
183 | @@ -XXX,XX +XXX,XX @@ static uint64_t allwinner_sun8i_emac_read(void *opaque, hwaddr offset, | ||
184 | break; | ||
185 | case REG_RX_CUR_BUF: /* Receive Current Buffer */ | ||
186 | if (s->rx_desc_curr != 0) { | ||
187 | - cpu_physical_memory_read(s->rx_desc_curr, &desc, sizeof(desc)); | ||
188 | + dma_memory_read(&s->dma_as, s->rx_desc_curr, &desc, sizeof(desc)); | ||
189 | value = desc.addr; | ||
190 | } else { | ||
191 | value = 0; | ||
192 | @@ -XXX,XX +XXX,XX @@ static void allwinner_sun8i_emac_realize(DeviceState *dev, Error **errp) | ||
193 | { | ||
194 | AwSun8iEmacState *s = AW_SUN8I_EMAC(dev); | ||
195 | |||
196 | + if (!s->dma_mr) { | ||
197 | + error_setg(errp, TYPE_AW_SUN8I_EMAC " 'dma-memory' link not set"); | ||
198 | + return; | ||
199 | + } | ||
200 | + | ||
201 | + address_space_init(&s->dma_as, s->dma_mr, "emac-dma"); | ||
202 | + | ||
203 | qemu_macaddr_default_if_unset(&s->conf.macaddr); | ||
204 | s->nic = qemu_new_nic(&net_allwinner_sun8i_emac_info, &s->conf, | ||
205 | object_get_typename(OBJECT(dev)), dev->id, s); | ||
206 | @@ -XXX,XX +XXX,XX @@ static void allwinner_sun8i_emac_realize(DeviceState *dev, Error **errp) | ||
207 | static Property allwinner_sun8i_emac_properties[] = { | ||
208 | DEFINE_NIC_PROPERTIES(AwSun8iEmacState, conf), | ||
209 | DEFINE_PROP_UINT8("phy-addr", AwSun8iEmacState, mii_phy_addr, 0), | ||
210 | + DEFINE_PROP_LINK("dma-memory", AwSun8iEmacState, dma_mr, | ||
211 | + TYPE_MEMORY_REGION, MemoryRegion *), | ||
212 | DEFINE_PROP_END_OF_LIST(), | ||
213 | }; | ||
214 | |||
215 | -- | ||
216 | 2.20.1 | ||
217 | |||
218 | diff view generated by jsdifflib |
1 | Provide a VMSTATE_BOOL_SUB_ARRAY to go with VMSTATE_UINT8_SUB_ARRAY | 1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> |
---|---|---|---|
2 | and friends. | ||
3 | 2 | ||
3 | As we want to call qdev_connect_clock_in() before the device | ||
4 | is realized, we need to uninline cadence_uart_create() first. | ||
5 | |||
6 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
7 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
8 | Message-id: 20200803105647.22223-2-f4bug@amsat.org | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
6 | Message-id: 20180521140402.23318-23-peter.maydell@linaro.org | ||
7 | --- | 10 | --- |
8 | include/migration/vmstate.h | 3 +++ | 11 | include/hw/char/cadence_uart.h | 17 ----------------- |
9 | 1 file changed, 3 insertions(+) | 12 | hw/arm/xilinx_zynq.c | 14 ++++++++++++-- |
13 | 2 files changed, 12 insertions(+), 19 deletions(-) | ||
10 | 14 | ||
11 | diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h | 15 | diff --git a/include/hw/char/cadence_uart.h b/include/hw/char/cadence_uart.h |
12 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/include/migration/vmstate.h | 17 | --- a/include/hw/char/cadence_uart.h |
14 | +++ b/include/migration/vmstate.h | 18 | +++ b/include/hw/char/cadence_uart.h |
15 | @@ -XXX,XX +XXX,XX @@ extern const VMStateInfo vmstate_info_qtailq; | 19 | @@ -XXX,XX +XXX,XX @@ typedef struct { |
16 | #define VMSTATE_BOOL_ARRAY(_f, _s, _n) \ | 20 | Clock *refclk; |
17 | VMSTATE_BOOL_ARRAY_V(_f, _s, _n, 0) | 21 | } CadenceUARTState; |
18 | 22 | ||
19 | +#define VMSTATE_BOOL_SUB_ARRAY(_f, _s, _start, _num) \ | 23 | -static inline DeviceState *cadence_uart_create(hwaddr addr, |
20 | + VMSTATE_SUB_ARRAY(_f, _s, _start, _num, 0, vmstate_info_bool, bool) | 24 | - qemu_irq irq, |
21 | + | 25 | - Chardev *chr) |
22 | #define VMSTATE_UINT16_ARRAY_V(_f, _s, _n, _v) \ | 26 | -{ |
23 | VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_uint16, uint16_t) | 27 | - DeviceState *dev; |
28 | - SysBusDevice *s; | ||
29 | - | ||
30 | - dev = qdev_new(TYPE_CADENCE_UART); | ||
31 | - s = SYS_BUS_DEVICE(dev); | ||
32 | - qdev_prop_set_chr(dev, "chardev", chr); | ||
33 | - sysbus_realize_and_unref(s, &error_fatal); | ||
34 | - sysbus_mmio_map(s, 0, addr); | ||
35 | - sysbus_connect_irq(s, 0, irq); | ||
36 | - | ||
37 | - return dev; | ||
38 | -} | ||
39 | - | ||
40 | #endif | ||
41 | diff --git a/hw/arm/xilinx_zynq.c b/hw/arm/xilinx_zynq.c | ||
42 | index XXXXXXX..XXXXXXX 100644 | ||
43 | --- a/hw/arm/xilinx_zynq.c | ||
44 | +++ b/hw/arm/xilinx_zynq.c | ||
45 | @@ -XXX,XX +XXX,XX @@ static void zynq_init(MachineState *machine) | ||
46 | sysbus_create_simple(TYPE_CHIPIDEA, 0xE0002000, pic[53 - IRQ_OFFSET]); | ||
47 | sysbus_create_simple(TYPE_CHIPIDEA, 0xE0003000, pic[76 - IRQ_OFFSET]); | ||
48 | |||
49 | - dev = cadence_uart_create(0xE0000000, pic[59 - IRQ_OFFSET], serial_hd(0)); | ||
50 | + dev = qdev_new(TYPE_CADENCE_UART); | ||
51 | + busdev = SYS_BUS_DEVICE(dev); | ||
52 | + qdev_prop_set_chr(dev, "chardev", serial_hd(0)); | ||
53 | + sysbus_realize_and_unref(busdev, &error_fatal); | ||
54 | + sysbus_mmio_map(busdev, 0, 0xE0000000); | ||
55 | + sysbus_connect_irq(busdev, 0, pic[59 - IRQ_OFFSET]); | ||
56 | qdev_connect_clock_in(dev, "refclk", | ||
57 | qdev_get_clock_out(slcr, "uart0_ref_clk")); | ||
58 | - dev = cadence_uart_create(0xE0001000, pic[82 - IRQ_OFFSET], serial_hd(1)); | ||
59 | + dev = qdev_new(TYPE_CADENCE_UART); | ||
60 | + busdev = SYS_BUS_DEVICE(dev); | ||
61 | + qdev_prop_set_chr(dev, "chardev", serial_hd(1)); | ||
62 | + sysbus_realize_and_unref(busdev, &error_fatal); | ||
63 | + sysbus_mmio_map(busdev, 0, 0xE0001000); | ||
64 | + sysbus_connect_irq(busdev, 0, pic[82 - IRQ_OFFSET]); | ||
65 | qdev_connect_clock_in(dev, "refclk", | ||
66 | qdev_get_clock_out(slcr, "uart1_ref_clk")); | ||
24 | 67 | ||
25 | -- | 68 | -- |
26 | 2.17.1 | 69 | 2.20.1 |
27 | 70 | ||
28 | 71 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
1 | 2 | ||
3 | Clock canonical name is set in device_set_realized (see the block | ||
4 | added to hw/core/qdev.c in commit 0e6934f264). | ||
5 | If we connect a clock after the device is realized, this code is | ||
6 | not executed. This is currently not a problem as this name is only | ||
7 | used for trace events, however this disrupt tracing. | ||
8 | |||
9 | Fix by calling qdev_connect_clock_in() before realizing. | ||
10 | |||
11 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
12 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
13 | Message-id: 20200803105647.22223-3-f4bug@amsat.org | ||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
15 | --- | ||
16 | hw/arm/xilinx_zynq.c | 18 +++++++++--------- | ||
17 | 1 file changed, 9 insertions(+), 9 deletions(-) | ||
18 | |||
19 | diff --git a/hw/arm/xilinx_zynq.c b/hw/arm/xilinx_zynq.c | ||
20 | index XXXXXXX..XXXXXXX 100644 | ||
21 | --- a/hw/arm/xilinx_zynq.c | ||
22 | +++ b/hw/arm/xilinx_zynq.c | ||
23 | @@ -XXX,XX +XXX,XX @@ static void zynq_init(MachineState *machine) | ||
24 | 1, 0x0066, 0x0022, 0x0000, 0x0000, 0x0555, 0x2aa, | ||
25 | 0); | ||
26 | |||
27 | - /* Create slcr, keep a pointer to connect clocks */ | ||
28 | - slcr = qdev_new("xilinx,zynq_slcr"); | ||
29 | - sysbus_realize_and_unref(SYS_BUS_DEVICE(slcr), &error_fatal); | ||
30 | - sysbus_mmio_map(SYS_BUS_DEVICE(slcr), 0, 0xF8000000); | ||
31 | - | ||
32 | /* Create the main clock source, and feed slcr with it */ | ||
33 | zynq_machine->ps_clk = CLOCK(object_new(TYPE_CLOCK)); | ||
34 | object_property_add_child(OBJECT(zynq_machine), "ps_clk", | ||
35 | OBJECT(zynq_machine->ps_clk)); | ||
36 | object_unref(OBJECT(zynq_machine->ps_clk)); | ||
37 | clock_set_hz(zynq_machine->ps_clk, PS_CLK_FREQUENCY); | ||
38 | + | ||
39 | + /* Create slcr, keep a pointer to connect clocks */ | ||
40 | + slcr = qdev_new("xilinx,zynq_slcr"); | ||
41 | qdev_connect_clock_in(slcr, "ps_clk", zynq_machine->ps_clk); | ||
42 | + sysbus_realize_and_unref(SYS_BUS_DEVICE(slcr), &error_fatal); | ||
43 | + sysbus_mmio_map(SYS_BUS_DEVICE(slcr), 0, 0xF8000000); | ||
44 | |||
45 | dev = qdev_new(TYPE_A9MPCORE_PRIV); | ||
46 | qdev_prop_set_uint32(dev, "num-cpu", 1); | ||
47 | @@ -XXX,XX +XXX,XX @@ static void zynq_init(MachineState *machine) | ||
48 | dev = qdev_new(TYPE_CADENCE_UART); | ||
49 | busdev = SYS_BUS_DEVICE(dev); | ||
50 | qdev_prop_set_chr(dev, "chardev", serial_hd(0)); | ||
51 | + qdev_connect_clock_in(dev, "refclk", | ||
52 | + qdev_get_clock_out(slcr, "uart0_ref_clk")); | ||
53 | sysbus_realize_and_unref(busdev, &error_fatal); | ||
54 | sysbus_mmio_map(busdev, 0, 0xE0000000); | ||
55 | sysbus_connect_irq(busdev, 0, pic[59 - IRQ_OFFSET]); | ||
56 | - qdev_connect_clock_in(dev, "refclk", | ||
57 | - qdev_get_clock_out(slcr, "uart0_ref_clk")); | ||
58 | dev = qdev_new(TYPE_CADENCE_UART); | ||
59 | busdev = SYS_BUS_DEVICE(dev); | ||
60 | qdev_prop_set_chr(dev, "chardev", serial_hd(1)); | ||
61 | + qdev_connect_clock_in(dev, "refclk", | ||
62 | + qdev_get_clock_out(slcr, "uart1_ref_clk")); | ||
63 | sysbus_realize_and_unref(busdev, &error_fatal); | ||
64 | sysbus_mmio_map(busdev, 0, 0xE0001000); | ||
65 | sysbus_connect_irq(busdev, 0, pic[82 - IRQ_OFFSET]); | ||
66 | - qdev_connect_clock_in(dev, "refclk", | ||
67 | - qdev_get_clock_out(slcr, "uart1_ref_clk")); | ||
68 | |||
69 | sysbus_create_varargs("cadence_ttc", 0xF8001000, | ||
70 | pic[42-IRQ_OFFSET], pic[43-IRQ_OFFSET], pic[44-IRQ_OFFSET], NULL); | ||
71 | -- | ||
72 | 2.20.1 | ||
73 | |||
74 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
1 | 2 | ||
3 | We want to assert the device is not realized. To avoid overloading | ||
4 | this header including "hw/qdev-core.h", uninline the function first. | ||
5 | |||
6 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
7 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
8 | Message-id: 20200803105647.22223-4-f4bug@amsat.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | include/hw/qdev-clock.h | 6 +----- | ||
12 | hw/core/qdev-clock.c | 5 +++++ | ||
13 | 2 files changed, 6 insertions(+), 5 deletions(-) | ||
14 | |||
15 | diff --git a/include/hw/qdev-clock.h b/include/hw/qdev-clock.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/include/hw/qdev-clock.h | ||
18 | +++ b/include/hw/qdev-clock.h | ||
19 | @@ -XXX,XX +XXX,XX @@ Clock *qdev_get_clock_out(DeviceState *dev, const char *name); | ||
20 | * Set the source clock of input clock @name of device @dev to @source. | ||
21 | * @source period update will be propagated to @name clock. | ||
22 | */ | ||
23 | -static inline void qdev_connect_clock_in(DeviceState *dev, const char *name, | ||
24 | - Clock *source) | ||
25 | -{ | ||
26 | - clock_set_source(qdev_get_clock_in(dev, name), source); | ||
27 | -} | ||
28 | +void qdev_connect_clock_in(DeviceState *dev, const char *name, Clock *source); | ||
29 | |||
30 | /** | ||
31 | * qdev_alias_clock: | ||
32 | diff --git a/hw/core/qdev-clock.c b/hw/core/qdev-clock.c | ||
33 | index XXXXXXX..XXXXXXX 100644 | ||
34 | --- a/hw/core/qdev-clock.c | ||
35 | +++ b/hw/core/qdev-clock.c | ||
36 | @@ -XXX,XX +XXX,XX @@ Clock *qdev_alias_clock(DeviceState *dev, const char *name, | ||
37 | |||
38 | return ncl->clock; | ||
39 | } | ||
40 | + | ||
41 | +void qdev_connect_clock_in(DeviceState *dev, const char *name, Clock *source) | ||
42 | +{ | ||
43 | + clock_set_source(qdev_get_clock_in(dev, name), source); | ||
44 | +} | ||
45 | -- | ||
46 | 2.20.1 | ||
47 | |||
48 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
1 | 2 | ||
3 | Clock canonical name is set in device_set_realized (see the block | ||
4 | added to hw/core/qdev.c in commit 0e6934f264). | ||
5 | If we connect a clock after the device is realized, this code is | ||
6 | not executed. This is currently not a problem as this name is only | ||
7 | used for trace events, however this disrupt tracing. | ||
8 | |||
9 | Add a comment to document qdev_connect_clock_in() must be called | ||
10 | before the device is realized, and assert this condition. | ||
11 | |||
12 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
13 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
14 | Message-id: 20200803105647.22223-5-f4bug@amsat.org | ||
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
16 | --- | ||
17 | include/hw/qdev-clock.h | 2 ++ | ||
18 | hw/core/qdev-clock.c | 1 + | ||
19 | 2 files changed, 3 insertions(+) | ||
20 | |||
21 | diff --git a/include/hw/qdev-clock.h b/include/hw/qdev-clock.h | ||
22 | index XXXXXXX..XXXXXXX 100644 | ||
23 | --- a/include/hw/qdev-clock.h | ||
24 | +++ b/include/hw/qdev-clock.h | ||
25 | @@ -XXX,XX +XXX,XX @@ Clock *qdev_get_clock_out(DeviceState *dev, const char *name); | ||
26 | * | ||
27 | * Set the source clock of input clock @name of device @dev to @source. | ||
28 | * @source period update will be propagated to @name clock. | ||
29 | + * | ||
30 | + * Must be called before @dev is realized. | ||
31 | */ | ||
32 | void qdev_connect_clock_in(DeviceState *dev, const char *name, Clock *source); | ||
33 | |||
34 | diff --git a/hw/core/qdev-clock.c b/hw/core/qdev-clock.c | ||
35 | index XXXXXXX..XXXXXXX 100644 | ||
36 | --- a/hw/core/qdev-clock.c | ||
37 | +++ b/hw/core/qdev-clock.c | ||
38 | @@ -XXX,XX +XXX,XX @@ Clock *qdev_alias_clock(DeviceState *dev, const char *name, | ||
39 | |||
40 | void qdev_connect_clock_in(DeviceState *dev, const char *name, Clock *source) | ||
41 | { | ||
42 | + assert(!dev->realized); | ||
43 | clock_set_source(qdev_get_clock_in(dev, name), source); | ||
44 | } | ||
45 | -- | ||
46 | 2.20.1 | ||
47 | |||
48 | diff view generated by jsdifflib |
1 | From: Shannon Zhao <zhaoshenglong@huawei.com> | 1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> |
---|---|---|---|
2 | 2 | ||
3 | kvm_irqchip_create called by kvm_init will call kvm_init_irq_routing to | 3 | To better align the read/write accesses, display the value after |
4 | initialize global capability variables. If we call kvm_init_irq_routing in | 4 | the offset (read accesses only display the offset). |
5 | GIC realize function, previous allocated memory will leak. | ||
6 | 5 | ||
7 | Fix this by deleting the unnecessary call. | 6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
8 | 7 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | |
9 | Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com> | 8 | Message-id: 20200812190206.31595-2-f4bug@amsat.org |
10 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | ||
11 | Message-id: 1527750994-14360-1-git-send-email-zhaoshenglong@huawei.com | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | --- | 10 | --- |
14 | hw/intc/arm_gic_kvm.c | 1 - | 11 | hw/misc/unimp.c | 8 ++++---- |
15 | hw/intc/arm_gicv3_kvm.c | 1 - | 12 | 1 file changed, 4 insertions(+), 4 deletions(-) |
16 | 2 files changed, 2 deletions(-) | ||
17 | 13 | ||
18 | diff --git a/hw/intc/arm_gic_kvm.c b/hw/intc/arm_gic_kvm.c | 14 | diff --git a/hw/misc/unimp.c b/hw/misc/unimp.c |
19 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/hw/intc/arm_gic_kvm.c | 16 | --- a/hw/misc/unimp.c |
21 | +++ b/hw/intc/arm_gic_kvm.c | 17 | +++ b/hw/misc/unimp.c |
22 | @@ -XXX,XX +XXX,XX @@ static void kvm_arm_gic_realize(DeviceState *dev, Error **errp) | 18 | @@ -XXX,XX +XXX,XX @@ static uint64_t unimp_read(void *opaque, hwaddr offset, unsigned size) |
23 | 19 | { | |
24 | if (kvm_has_gsi_routing()) { | 20 | UnimplementedDeviceState *s = UNIMPLEMENTED_DEVICE(opaque); |
25 | /* set up irq routing */ | 21 | |
26 | - kvm_init_irq_routing(kvm_state); | 22 | - qemu_log_mask(LOG_UNIMP, "%s: unimplemented device read " |
27 | for (i = 0; i < s->num_irq - GIC_INTERNAL; ++i) { | 23 | + qemu_log_mask(LOG_UNIMP, "%s: unimplemented device read " |
28 | kvm_irqchip_add_irq_route(kvm_state, i, 0, i); | 24 | "(size %d, offset 0x%" HWADDR_PRIx ")\n", |
29 | } | 25 | s->name, size, offset); |
30 | diff --git a/hw/intc/arm_gicv3_kvm.c b/hw/intc/arm_gicv3_kvm.c | 26 | return 0; |
31 | index XXXXXXX..XXXXXXX 100644 | 27 | @@ -XXX,XX +XXX,XX @@ static void unimp_write(void *opaque, hwaddr offset, |
32 | --- a/hw/intc/arm_gicv3_kvm.c | 28 | UnimplementedDeviceState *s = UNIMPLEMENTED_DEVICE(opaque); |
33 | +++ b/hw/intc/arm_gicv3_kvm.c | 29 | |
34 | @@ -XXX,XX +XXX,XX @@ static void kvm_arm_gicv3_realize(DeviceState *dev, Error **errp) | 30 | qemu_log_mask(LOG_UNIMP, "%s: unimplemented device write " |
35 | 31 | - "(size %d, value 0x%" PRIx64 | |
36 | if (kvm_has_gsi_routing()) { | 32 | - ", offset 0x%" HWADDR_PRIx ")\n", |
37 | /* set up irq routing */ | 33 | - s->name, size, value, offset); |
38 | - kvm_init_irq_routing(kvm_state); | 34 | + "(size %d, offset 0x%" HWADDR_PRIx |
39 | for (i = 0; i < s->num_irq - GIC_INTERNAL; ++i) { | 35 | + ", value 0x%" PRIx64 ")\n", |
40 | kvm_irqchip_add_irq_route(kvm_state, i, 0, i); | 36 | + s->name, size, offset, value); |
41 | } | 37 | } |
38 | |||
39 | static const MemoryRegionOps unimp_ops = { | ||
42 | -- | 40 | -- |
43 | 2.17.1 | 41 | 2.20.1 |
44 | 42 | ||
45 | 43 | diff view generated by jsdifflib |
1 | As part of plumbing MemTxAttrs down to the IOMMU translate method, | 1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> |
---|---|---|---|
2 | add MemTxAttrs as an argument to address_space_translate_iommu(). | ||
3 | 2 | ||
3 | To quickly notice the access size, display the value with the | ||
4 | width of the access (i.e. 16-bit access is displayed 0x0000, | ||
5 | while 8-bit access 0x00). | ||
6 | |||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
9 | Message-id: 20200812190206.31595-3-f4bug@amsat.org | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20180521140402.23318-14-peter.maydell@linaro.org | ||
8 | --- | 11 | --- |
9 | exec.c | 8 +++++--- | 12 | hw/misc/unimp.c | 4 ++-- |
10 | 1 file changed, 5 insertions(+), 3 deletions(-) | 13 | 1 file changed, 2 insertions(+), 2 deletions(-) |
11 | 14 | ||
12 | diff --git a/exec.c b/exec.c | 15 | diff --git a/hw/misc/unimp.c b/hw/misc/unimp.c |
13 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
14 | --- a/exec.c | 17 | --- a/hw/misc/unimp.c |
15 | +++ b/exec.c | 18 | +++ b/hw/misc/unimp.c |
16 | @@ -XXX,XX +XXX,XX @@ address_space_translate_internal(AddressSpaceDispatch *d, hwaddr addr, hwaddr *x | 19 | @@ -XXX,XX +XXX,XX @@ static void unimp_write(void *opaque, hwaddr offset, |
17 | * @is_write: whether the translation operation is for write | 20 | |
18 | * @is_mmio: whether this can be MMIO, set true if it can | 21 | qemu_log_mask(LOG_UNIMP, "%s: unimplemented device write " |
19 | * @target_as: the address space targeted by the IOMMU | 22 | "(size %d, offset 0x%" HWADDR_PRIx |
20 | + * @attrs: transaction attributes | 23 | - ", value 0x%" PRIx64 ")\n", |
21 | * | 24 | - s->name, size, offset, value); |
22 | * This function is called from RCU critical section. It is the common | 25 | + ", value 0x%0*" PRIx64 ")\n", |
23 | * part of flatview_do_translate and address_space_translate_cached. | 26 | + s->name, size, offset, size << 1, value); |
24 | @@ -XXX,XX +XXX,XX @@ static MemoryRegionSection address_space_translate_iommu(IOMMUMemoryRegion *iomm | ||
25 | hwaddr *page_mask_out, | ||
26 | bool is_write, | ||
27 | bool is_mmio, | ||
28 | - AddressSpace **target_as) | ||
29 | + AddressSpace **target_as, | ||
30 | + MemTxAttrs attrs) | ||
31 | { | ||
32 | MemoryRegionSection *section; | ||
33 | hwaddr page_mask = (hwaddr)-1; | ||
34 | @@ -XXX,XX +XXX,XX @@ static MemoryRegionSection flatview_do_translate(FlatView *fv, | ||
35 | return address_space_translate_iommu(iommu_mr, xlat, | ||
36 | plen_out, page_mask_out, | ||
37 | is_write, is_mmio, | ||
38 | - target_as); | ||
39 | + target_as, attrs); | ||
40 | } | ||
41 | if (page_mask_out) { | ||
42 | /* Not behind an IOMMU, use default page size. */ | ||
43 | @@ -XXX,XX +XXX,XX @@ static inline MemoryRegion *address_space_translate_cached( | ||
44 | |||
45 | section = address_space_translate_iommu(iommu_mr, xlat, plen, | ||
46 | NULL, is_write, true, | ||
47 | - &target_as); | ||
48 | + &target_as, attrs); | ||
49 | return section.mr; | ||
50 | } | 27 | } |
51 | 28 | ||
29 | static const MemoryRegionOps unimp_ops = { | ||
52 | -- | 30 | -- |
53 | 2.17.1 | 31 | 2.20.1 |
54 | 32 | ||
55 | 33 | diff view generated by jsdifflib |
1 | As part of plumbing MemTxAttrs down to the IOMMU translate method, | 1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> |
---|---|---|---|
2 | add MemTxAttrs as an argument to flatview_translate(); all its | ||
3 | callers now have attrs available. | ||
4 | 2 | ||
3 | To have a better idea of how big is the region where the offset | ||
4 | belongs, display the value with the width of the region size | ||
5 | (i.e. a region of 0x1000 bytes uses 0x000 format). | ||
6 | |||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
9 | Message-id: 20200812190206.31595-4-f4bug@amsat.org | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20180521140402.23318-11-peter.maydell@linaro.org | ||
9 | --- | 11 | --- |
10 | include/exec/memory.h | 7 ++++--- | 12 | include/hw/misc/unimp.h | 1 + |
11 | exec.c | 17 +++++++++-------- | 13 | hw/misc/unimp.c | 10 ++++++---- |
12 | 2 files changed, 13 insertions(+), 11 deletions(-) | 14 | 2 files changed, 7 insertions(+), 4 deletions(-) |
13 | 15 | ||
14 | diff --git a/include/exec/memory.h b/include/exec/memory.h | 16 | diff --git a/include/hw/misc/unimp.h b/include/hw/misc/unimp.h |
15 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/include/exec/memory.h | 18 | --- a/include/hw/misc/unimp.h |
17 | +++ b/include/exec/memory.h | 19 | +++ b/include/hw/misc/unimp.h |
18 | @@ -XXX,XX +XXX,XX @@ IOMMUTLBEntry address_space_get_iotlb_entry(AddressSpace *as, hwaddr addr, | 20 | @@ -XXX,XX +XXX,XX @@ |
19 | */ | 21 | typedef struct { |
20 | MemoryRegion *flatview_translate(FlatView *fv, | 22 | SysBusDevice parent_obj; |
21 | hwaddr addr, hwaddr *xlat, | 23 | MemoryRegion iomem; |
22 | - hwaddr *len, bool is_write); | 24 | + unsigned offset_fmt_width; |
23 | + hwaddr *len, bool is_write, | 25 | char *name; |
24 | + MemTxAttrs attrs); | 26 | uint64_t size; |
25 | 27 | } UnimplementedDeviceState; | |
26 | static inline MemoryRegion *address_space_translate(AddressSpace *as, | 28 | diff --git a/hw/misc/unimp.c b/hw/misc/unimp.c |
27 | hwaddr addr, hwaddr *xlat, | 29 | index XXXXXXX..XXXXXXX 100644 |
28 | @@ -XXX,XX +XXX,XX @@ static inline MemoryRegion *address_space_translate(AddressSpace *as, | 30 | --- a/hw/misc/unimp.c |
29 | MemTxAttrs attrs) | 31 | +++ b/hw/misc/unimp.c |
30 | { | 32 | @@ -XXX,XX +XXX,XX @@ static uint64_t unimp_read(void *opaque, hwaddr offset, unsigned size) |
31 | return flatview_translate(address_space_to_flatview(as), | 33 | UnimplementedDeviceState *s = UNIMPLEMENTED_DEVICE(opaque); |
32 | - addr, xlat, len, is_write); | 34 | |
33 | + addr, xlat, len, is_write, attrs); | 35 | qemu_log_mask(LOG_UNIMP, "%s: unimplemented device read " |
36 | - "(size %d, offset 0x%" HWADDR_PRIx ")\n", | ||
37 | - s->name, size, offset); | ||
38 | + "(size %d, offset 0x%0*" HWADDR_PRIx ")\n", | ||
39 | + s->name, size, s->offset_fmt_width, offset); | ||
40 | return 0; | ||
34 | } | 41 | } |
35 | 42 | ||
36 | /* address_space_access_valid: check for validity of accessing an address | 43 | @@ -XXX,XX +XXX,XX @@ static void unimp_write(void *opaque, hwaddr offset, |
37 | @@ -XXX,XX +XXX,XX @@ MemTxResult address_space_read(AddressSpace *as, hwaddr addr, | 44 | UnimplementedDeviceState *s = UNIMPLEMENTED_DEVICE(opaque); |
38 | rcu_read_lock(); | 45 | |
39 | fv = address_space_to_flatview(as); | 46 | qemu_log_mask(LOG_UNIMP, "%s: unimplemented device write " |
40 | l = len; | 47 | - "(size %d, offset 0x%" HWADDR_PRIx |
41 | - mr = flatview_translate(fv, addr, &addr1, &l, false); | 48 | + "(size %d, offset 0x%0*" HWADDR_PRIx |
42 | + mr = flatview_translate(fv, addr, &addr1, &l, false, attrs); | 49 | ", value 0x%0*" PRIx64 ")\n", |
43 | if (len == l && memory_access_is_direct(mr, false)) { | 50 | - s->name, size, offset, size << 1, value); |
44 | ptr = qemu_map_ram_ptr(mr->ram_block, addr1); | 51 | + s->name, size, s->offset_fmt_width, offset, size << 1, value); |
45 | memcpy(buf, ptr, len); | 52 | } |
46 | diff --git a/exec.c b/exec.c | 53 | |
47 | index XXXXXXX..XXXXXXX 100644 | 54 | static const MemoryRegionOps unimp_ops = { |
48 | --- a/exec.c | 55 | @@ -XXX,XX +XXX,XX @@ static void unimp_realize(DeviceState *dev, Error **errp) |
49 | +++ b/exec.c | 56 | return; |
50 | @@ -XXX,XX +XXX,XX @@ iotlb_fail: | ||
51 | |||
52 | /* Called from RCU critical section */ | ||
53 | MemoryRegion *flatview_translate(FlatView *fv, hwaddr addr, hwaddr *xlat, | ||
54 | - hwaddr *plen, bool is_write) | ||
55 | + hwaddr *plen, bool is_write, | ||
56 | + MemTxAttrs attrs) | ||
57 | { | ||
58 | MemoryRegion *mr; | ||
59 | MemoryRegionSection section; | ||
60 | @@ -XXX,XX +XXX,XX @@ static MemTxResult flatview_write_continue(FlatView *fv, hwaddr addr, | ||
61 | } | ||
62 | |||
63 | l = len; | ||
64 | - mr = flatview_translate(fv, addr, &addr1, &l, true); | ||
65 | + mr = flatview_translate(fv, addr, &addr1, &l, true, attrs); | ||
66 | } | 57 | } |
67 | 58 | ||
68 | return result; | 59 | + s->offset_fmt_width = DIV_ROUND_UP(64 - clz64(s->size - 1), 4); |
69 | @@ -XXX,XX +XXX,XX @@ static MemTxResult flatview_write(FlatView *fv, hwaddr addr, MemTxAttrs attrs, | 60 | + |
70 | MemTxResult result = MEMTX_OK; | 61 | memory_region_init_io(&s->iomem, OBJECT(s), &unimp_ops, s, |
71 | 62 | s->name, s->size); | |
72 | l = len; | 63 | sysbus_init_mmio(SYS_BUS_DEVICE(s), &s->iomem); |
73 | - mr = flatview_translate(fv, addr, &addr1, &l, true); | ||
74 | + mr = flatview_translate(fv, addr, &addr1, &l, true, attrs); | ||
75 | result = flatview_write_continue(fv, addr, attrs, buf, len, | ||
76 | addr1, l, mr); | ||
77 | |||
78 | @@ -XXX,XX +XXX,XX @@ MemTxResult flatview_read_continue(FlatView *fv, hwaddr addr, | ||
79 | } | ||
80 | |||
81 | l = len; | ||
82 | - mr = flatview_translate(fv, addr, &addr1, &l, false); | ||
83 | + mr = flatview_translate(fv, addr, &addr1, &l, false, attrs); | ||
84 | } | ||
85 | |||
86 | return result; | ||
87 | @@ -XXX,XX +XXX,XX @@ static MemTxResult flatview_read(FlatView *fv, hwaddr addr, | ||
88 | MemoryRegion *mr; | ||
89 | |||
90 | l = len; | ||
91 | - mr = flatview_translate(fv, addr, &addr1, &l, false); | ||
92 | + mr = flatview_translate(fv, addr, &addr1, &l, false, attrs); | ||
93 | return flatview_read_continue(fv, addr, attrs, buf, len, | ||
94 | addr1, l, mr); | ||
95 | } | ||
96 | @@ -XXX,XX +XXX,XX @@ static bool flatview_access_valid(FlatView *fv, hwaddr addr, int len, | ||
97 | |||
98 | while (len > 0) { | ||
99 | l = len; | ||
100 | - mr = flatview_translate(fv, addr, &xlat, &l, is_write); | ||
101 | + mr = flatview_translate(fv, addr, &xlat, &l, is_write, attrs); | ||
102 | if (!memory_access_is_direct(mr, is_write)) { | ||
103 | l = memory_access_size(mr, l, addr); | ||
104 | if (!memory_region_access_valid(mr, xlat, l, is_write, attrs)) { | ||
105 | @@ -XXX,XX +XXX,XX @@ flatview_extend_translation(FlatView *fv, hwaddr addr, | ||
106 | |||
107 | len = target_len; | ||
108 | this_mr = flatview_translate(fv, addr, &xlat, | ||
109 | - &len, is_write); | ||
110 | + &len, is_write, attrs); | ||
111 | if (this_mr != mr || xlat != base + done) { | ||
112 | return done; | ||
113 | } | ||
114 | @@ -XXX,XX +XXX,XX @@ void *address_space_map(AddressSpace *as, | ||
115 | l = len; | ||
116 | rcu_read_lock(); | ||
117 | fv = address_space_to_flatview(as); | ||
118 | - mr = flatview_translate(fv, addr, &xlat, &l, is_write); | ||
119 | + mr = flatview_translate(fv, addr, &xlat, &l, is_write, attrs); | ||
120 | |||
121 | if (!memory_access_is_direct(mr, is_write)) { | ||
122 | if (atomic_xchg(&bounce.in_use, true)) { | ||
123 | -- | 64 | -- |
124 | 2.17.1 | 65 | 2.20.1 |
125 | 66 | ||
126 | 67 | diff view generated by jsdifflib |
1 | From: Shannon Zhao <zhaoshenglong@huawei.com> | 1 | From: Eduardo Habkost <ehabkost@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | It forgot to increase clroffset during the loop. So it only clear the | 3 | TYPE_ARM_SSE is a TYPE_SYS_BUS_DEVICE subclass, but |
4 | first 4 bytes. | 4 | ARMSSEClass::parent_class is declared as DeviceClass. |
5 | 5 | ||
6 | Fixes: 367b9f527becdd20ddf116e17a3c0c2bbc486920 | 6 | It never caused any problems by pure luck: |
7 | Cc: qemu-stable@nongnu.org | 7 | |
8 | Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com> | 8 | We were not setting class_size for TYPE_ARM_SSE, so class_size of |
9 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | 9 | TYPE_SYS_BUS_DEVICE was being used (sizeof(SysBusDeviceClass)). |
10 | Message-id: 1527047633-12368-1-git-send-email-zhaoshenglong@huawei.com | 10 | This made the system allocate enough memory for TYPE_ARM_SSE |
11 | devices even though ARMSSEClass was too small for a sysbus | ||
12 | device. | ||
13 | |||
14 | Additionally, the ARMSSEClass::info field ended up at the same | ||
15 | offset as SysBusDeviceClass::explicit_ofw_unit_address. This | ||
16 | would make sysbus_get_fw_dev_path() crash for the device. | ||
17 | Luckily, sysbus_get_fw_dev_path() never gets called for | ||
18 | TYPE_ARM_SSE devices, because qdev_get_fw_dev_path() is only used | ||
19 | by the boot device code, and TYPE_ARM_SSE devices don't appear at | ||
20 | the fw_boot_order list. | ||
21 | |||
22 | Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> | ||
23 | Message-id: 20200826181006.4097163-1-ehabkost@redhat.com | ||
11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 24 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 25 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | --- | 26 | --- |
14 | hw/intc/arm_gicv3_kvm.c | 1 + | 27 | include/hw/arm/armsse.h | 2 +- |
15 | 1 file changed, 1 insertion(+) | 28 | hw/arm/armsse.c | 1 + |
29 | 2 files changed, 2 insertions(+), 1 deletion(-) | ||
16 | 30 | ||
17 | diff --git a/hw/intc/arm_gicv3_kvm.c b/hw/intc/arm_gicv3_kvm.c | 31 | diff --git a/include/hw/arm/armsse.h b/include/hw/arm/armsse.h |
18 | index XXXXXXX..XXXXXXX 100644 | 32 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/hw/intc/arm_gicv3_kvm.c | 33 | --- a/include/hw/arm/armsse.h |
20 | +++ b/hw/intc/arm_gicv3_kvm.c | 34 | +++ b/include/hw/arm/armsse.h |
21 | @@ -XXX,XX +XXX,XX @@ static void kvm_dist_putbmp(GICv3State *s, uint32_t offset, | 35 | @@ -XXX,XX +XXX,XX @@ typedef struct ARMSSE { |
22 | if (clroffset != 0) { | 36 | typedef struct ARMSSEInfo ARMSSEInfo; |
23 | reg = 0; | 37 | |
24 | kvm_gicd_access(s, clroffset, ®, true); | 38 | typedef struct ARMSSEClass { |
25 | + clroffset += 4; | 39 | - DeviceClass parent_class; |
26 | } | 40 | + SysBusDeviceClass parent_class; |
27 | reg = *gic_bmp_ptr32(bmp, irq); | 41 | const ARMSSEInfo *info; |
28 | kvm_gicd_access(s, offset, ®, true); | 42 | } ARMSSEClass; |
43 | |||
44 | diff --git a/hw/arm/armsse.c b/hw/arm/armsse.c | ||
45 | index XXXXXXX..XXXXXXX 100644 | ||
46 | --- a/hw/arm/armsse.c | ||
47 | +++ b/hw/arm/armsse.c | ||
48 | @@ -XXX,XX +XXX,XX @@ static const TypeInfo armsse_info = { | ||
49 | .name = TYPE_ARMSSE, | ||
50 | .parent = TYPE_SYS_BUS_DEVICE, | ||
51 | .instance_size = sizeof(ARMSSE), | ||
52 | + .class_size = sizeof(ARMSSEClass), | ||
53 | .instance_init = armsse_init, | ||
54 | .abstract = true, | ||
55 | .interfaces = (InterfaceInfo[]) { | ||
29 | -- | 56 | -- |
30 | 2.17.1 | 57 | 2.20.1 |
31 | 58 | ||
32 | 59 | diff view generated by jsdifflib |
1 | As part of plumbing MemTxAttrs down to the IOMMU translate method, | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | add MemTxAttrs as an argument to flatview_do_translate(). | ||
3 | 2 | ||
3 | Add left-shift to match the existing right-shift. | ||
4 | |||
5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Message-id: 20200815013145.539409-2-richard.henderson@linaro.org | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20180521140402.23318-13-peter.maydell@linaro.org | ||
8 | --- | 9 | --- |
9 | exec.c | 9 ++++++--- | 10 | include/qemu/int128.h | 16 ++++++++++++++++ |
10 | 1 file changed, 6 insertions(+), 3 deletions(-) | 11 | 1 file changed, 16 insertions(+) |
11 | 12 | ||
12 | diff --git a/exec.c b/exec.c | 13 | diff --git a/include/qemu/int128.h b/include/qemu/int128.h |
13 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
14 | --- a/exec.c | 15 | --- a/include/qemu/int128.h |
15 | +++ b/exec.c | 16 | +++ b/include/qemu/int128.h |
16 | @@ -XXX,XX +XXX,XX @@ unassigned: | 17 | @@ -XXX,XX +XXX,XX @@ static inline Int128 int128_rshift(Int128 a, int n) |
17 | * @is_write: whether the translation operation is for write | 18 | return a >> n; |
18 | * @is_mmio: whether this can be MMIO, set true if it can | 19 | } |
19 | * @target_as: the address space targeted by the IOMMU | 20 | |
20 | + * @attrs: memory transaction attributes | 21 | +static inline Int128 int128_lshift(Int128 a, int n) |
21 | * | 22 | +{ |
22 | * This function is called from RCU critical section | 23 | + return a << n; |
23 | */ | 24 | +} |
24 | @@ -XXX,XX +XXX,XX @@ static MemoryRegionSection flatview_do_translate(FlatView *fv, | 25 | + |
25 | hwaddr *page_mask_out, | 26 | static inline Int128 int128_add(Int128 a, Int128 b) |
26 | bool is_write, | ||
27 | bool is_mmio, | ||
28 | - AddressSpace **target_as) | ||
29 | + AddressSpace **target_as, | ||
30 | + MemTxAttrs attrs) | ||
31 | { | 27 | { |
32 | MemoryRegionSection *section; | 28 | return a + b; |
33 | IOMMUMemoryRegion *iommu_mr; | 29 | @@ -XXX,XX +XXX,XX @@ static inline Int128 int128_rshift(Int128 a, int n) |
34 | @@ -XXX,XX +XXX,XX @@ IOMMUTLBEntry address_space_get_iotlb_entry(AddressSpace *as, hwaddr addr, | 30 | } |
35 | * but page mask. | 31 | } |
36 | */ | 32 | |
37 | section = flatview_do_translate(address_space_to_flatview(as), addr, &xlat, | 33 | +static inline Int128 int128_lshift(Int128 a, int n) |
38 | - NULL, &page_mask, is_write, false, &as); | 34 | +{ |
39 | + NULL, &page_mask, is_write, false, &as, | 35 | + uint64_t l = a.lo << (n & 63); |
40 | + attrs); | 36 | + if (n >= 64) { |
41 | 37 | + return int128_make128(0, l); | |
42 | /* Illegal translation */ | 38 | + } else if (n > 0) { |
43 | if (section.mr == &io_mem_unassigned) { | 39 | + return int128_make128(l, (a.hi << n) | (a.lo >> (64 - n))); |
44 | @@ -XXX,XX +XXX,XX @@ MemoryRegion *flatview_translate(FlatView *fv, hwaddr addr, hwaddr *xlat, | 40 | + } |
45 | 41 | + return a; | |
46 | /* This can be MMIO, so setup MMIO bit. */ | 42 | +} |
47 | section = flatview_do_translate(fv, addr, xlat, plen, NULL, | 43 | + |
48 | - is_write, true, &as); | 44 | static inline Int128 int128_add(Int128 a, Int128 b) |
49 | + is_write, true, &as, attrs); | 45 | { |
50 | mr = section.mr; | 46 | uint64_t lo = a.lo + b.lo; |
51 | |||
52 | if (xen_enabled() && memory_access_is_direct(mr, is_write)) { | ||
53 | -- | 47 | -- |
54 | 2.17.1 | 48 | 2.20.1 |
55 | 49 | ||
56 | 50 | diff view generated by jsdifflib |
1 | As part of plumbing MemTxAttrs down to the IOMMU translate method, | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | add MemTxAttrs as an argument to address_space_get_iotlb_entry(). | ||
3 | 2 | ||
3 | Model the new function on gen_gvec_fn2 in translate-a64.c, but | ||
4 | indicating which kind of register and in which order. Since there | ||
5 | is only one user of do_vector2_z, fold it into do_mov_z. | ||
6 | |||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Message-id: 20200815013145.539409-3-richard.henderson@linaro.org | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20180521140402.23318-12-peter.maydell@linaro.org | ||
8 | --- | 11 | --- |
9 | include/exec/memory.h | 2 +- | 12 | target/arm/translate-sve.c | 19 ++++++++++--------- |
10 | exec.c | 2 +- | 13 | 1 file changed, 10 insertions(+), 9 deletions(-) |
11 | hw/virtio/vhost.c | 3 ++- | ||
12 | 3 files changed, 4 insertions(+), 3 deletions(-) | ||
13 | 14 | ||
14 | diff --git a/include/exec/memory.h b/include/exec/memory.h | 15 | diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c |
15 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/include/exec/memory.h | 17 | --- a/target/arm/translate-sve.c |
17 | +++ b/include/exec/memory.h | 18 | +++ b/target/arm/translate-sve.c |
18 | @@ -XXX,XX +XXX,XX @@ void address_space_cache_destroy(MemoryRegionCache *cache); | 19 | @@ -XXX,XX +XXX,XX @@ static int pred_gvec_reg_size(DisasContext *s) |
19 | * entry. Should be called from an RCU critical section. | 20 | } |
20 | */ | 21 | |
21 | IOMMUTLBEntry address_space_get_iotlb_entry(AddressSpace *as, hwaddr addr, | 22 | /* Invoke a vector expander on two Zregs. */ |
22 | - bool is_write); | 23 | -static bool do_vector2_z(DisasContext *s, GVecGen2Fn *gvec_fn, |
23 | + bool is_write, MemTxAttrs attrs); | 24 | - int esz, int rd, int rn) |
24 | 25 | + | |
25 | /* address_space_translate: translate an address range into an address space | 26 | +static void gen_gvec_fn_zz(DisasContext *s, GVecGen2Fn *gvec_fn, |
26 | * into a MemoryRegion and an address range into that section. Should be | 27 | + int esz, int rd, int rn) |
27 | diff --git a/exec.c b/exec.c | ||
28 | index XXXXXXX..XXXXXXX 100644 | ||
29 | --- a/exec.c | ||
30 | +++ b/exec.c | ||
31 | @@ -XXX,XX +XXX,XX @@ static MemoryRegionSection flatview_do_translate(FlatView *fv, | ||
32 | |||
33 | /* Called from RCU critical section */ | ||
34 | IOMMUTLBEntry address_space_get_iotlb_entry(AddressSpace *as, hwaddr addr, | ||
35 | - bool is_write) | ||
36 | + bool is_write, MemTxAttrs attrs) | ||
37 | { | 28 | { |
38 | MemoryRegionSection section; | 29 | - if (sve_access_check(s)) { |
39 | hwaddr xlat, page_mask; | 30 | - unsigned vsz = vec_full_reg_size(s); |
40 | diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c | 31 | - gvec_fn(esz, vec_full_reg_offset(s, rd), |
41 | index XXXXXXX..XXXXXXX 100644 | 32 | - vec_full_reg_offset(s, rn), vsz, vsz); |
42 | --- a/hw/virtio/vhost.c | 33 | - } |
43 | +++ b/hw/virtio/vhost.c | 34 | - return true; |
44 | @@ -XXX,XX +XXX,XX @@ int vhost_device_iotlb_miss(struct vhost_dev *dev, uint64_t iova, int write) | 35 | + unsigned vsz = vec_full_reg_size(s); |
45 | trace_vhost_iotlb_miss(dev, 1); | 36 | + gvec_fn(esz, vec_full_reg_offset(s, rd), |
46 | 37 | + vec_full_reg_offset(s, rn), vsz, vsz); | |
47 | iotlb = address_space_get_iotlb_entry(dev->vdev->dma_as, | 38 | } |
48 | - iova, write); | 39 | |
49 | + iova, write, | 40 | /* Invoke a vector expander on three Zregs. */ |
50 | + MEMTXATTRS_UNSPECIFIED); | 41 | @@ -XXX,XX +XXX,XX @@ static bool do_vector3_z(DisasContext *s, GVecGen3Fn *gvec_fn, |
51 | if (iotlb.target_as != NULL) { | 42 | /* Invoke a vector move on two Zregs. */ |
52 | ret = vhost_memory_region_lookup(dev, iotlb.translated_addr, | 43 | static bool do_mov_z(DisasContext *s, int rd, int rn) |
53 | &uaddr, &len); | 44 | { |
45 | - return do_vector2_z(s, tcg_gen_gvec_mov, 0, rd, rn); | ||
46 | + if (sve_access_check(s)) { | ||
47 | + gen_gvec_fn_zz(s, tcg_gen_gvec_mov, MO_8, rd, rn); | ||
48 | + } | ||
49 | + return true; | ||
50 | } | ||
51 | |||
52 | /* Initialize a Zreg with replications of a 64-bit immediate. */ | ||
54 | -- | 53 | -- |
55 | 2.17.1 | 54 | 2.20.1 |
56 | 55 | ||
57 | 56 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Depending on the host abi, float16, aka uint16_t, values are | 3 | Model gen_gvec_fn_zzz on gen_gvec_fn3 in translate-a64.c, but |
4 | passed and returned either zero-extended in the host register | 4 | indicating which kind of register and in which order. |
5 | or with garbage at the top of the host register. | ||
6 | 5 | ||
7 | The tcg code generator has so far been assuming garbage, as that | 6 | Model do_zzz_fn on the other do_foo functions that take an |
8 | matches the x86 abi, but this is incorrect for other host abis. | 7 | argument set and verify sve enabled. |
9 | Further, target/arm has so far been assuming zero-extended results, | ||
10 | so that it may store the 16-bit value into a 32-bit slot with the | ||
11 | high 16-bits already clear. | ||
12 | 8 | ||
13 | Rectify both problems by mapping "f16" in the helper definition | ||
14 | to uint32_t instead of (a typedef for) uint16_t. This forces | ||
15 | the host compiler to assume garbage in the upper 16 bits on input | ||
16 | and to zero-extend the result on output. | ||
17 | |||
18 | Cc: qemu-stable@nongnu.org | ||
19 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
20 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
21 | Tested-by: Laurent Desnogues <laurent.desnogues@gmail.com> | ||
22 | Message-id: 20180522175629.24932-1-richard.henderson@linaro.org | ||
23 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
11 | Message-id: 20200815013145.539409-4-richard.henderson@linaro.org | ||
24 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
25 | --- | 13 | --- |
26 | include/exec/helper-head.h | 2 +- | 14 | target/arm/translate-sve.c | 43 +++++++++++++++++++++----------------- |
27 | target/arm/helper-a64.c | 35 +++++++++-------- | 15 | 1 file changed, 24 insertions(+), 19 deletions(-) |
28 | target/arm/helper.c | 80 +++++++++++++++++++------------------- | ||
29 | 3 files changed, 59 insertions(+), 58 deletions(-) | ||
30 | 16 | ||
31 | diff --git a/include/exec/helper-head.h b/include/exec/helper-head.h | 17 | diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c |
32 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
33 | --- a/include/exec/helper-head.h | 19 | --- a/target/arm/translate-sve.c |
34 | +++ b/include/exec/helper-head.h | 20 | +++ b/target/arm/translate-sve.c |
35 | @@ -XXX,XX +XXX,XX @@ | 21 | @@ -XXX,XX +XXX,XX @@ static void gen_gvec_fn_zz(DisasContext *s, GVecGen2Fn *gvec_fn, |
36 | #define dh_ctype_int int | ||
37 | #define dh_ctype_i64 uint64_t | ||
38 | #define dh_ctype_s64 int64_t | ||
39 | -#define dh_ctype_f16 float16 | ||
40 | +#define dh_ctype_f16 uint32_t | ||
41 | #define dh_ctype_f32 float32 | ||
42 | #define dh_ctype_f64 float64 | ||
43 | #define dh_ctype_ptr void * | ||
44 | diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c | ||
45 | index XXXXXXX..XXXXXXX 100644 | ||
46 | --- a/target/arm/helper-a64.c | ||
47 | +++ b/target/arm/helper-a64.c | ||
48 | @@ -XXX,XX +XXX,XX @@ static inline uint32_t float_rel_to_flags(int res) | ||
49 | return flags; | ||
50 | } | 22 | } |
51 | 23 | ||
52 | -uint64_t HELPER(vfp_cmph_a64)(float16 x, float16 y, void *fp_status) | 24 | /* Invoke a vector expander on three Zregs. */ |
53 | +uint64_t HELPER(vfp_cmph_a64)(uint32_t x, uint32_t y, void *fp_status) | 25 | -static bool do_vector3_z(DisasContext *s, GVecGen3Fn *gvec_fn, |
26 | - int esz, int rd, int rn, int rm) | ||
27 | +static void gen_gvec_fn_zzz(DisasContext *s, GVecGen3Fn *gvec_fn, | ||
28 | + int esz, int rd, int rn, int rm) | ||
54 | { | 29 | { |
55 | return float_rel_to_flags(float16_compare_quiet(x, y, fp_status)); | 30 | - if (sve_access_check(s)) { |
31 | - unsigned vsz = vec_full_reg_size(s); | ||
32 | - gvec_fn(esz, vec_full_reg_offset(s, rd), | ||
33 | - vec_full_reg_offset(s, rn), | ||
34 | - vec_full_reg_offset(s, rm), vsz, vsz); | ||
35 | - } | ||
36 | - return true; | ||
37 | + unsigned vsz = vec_full_reg_size(s); | ||
38 | + gvec_fn(esz, vec_full_reg_offset(s, rd), | ||
39 | + vec_full_reg_offset(s, rn), | ||
40 | + vec_full_reg_offset(s, rm), vsz, vsz); | ||
56 | } | 41 | } |
57 | 42 | ||
58 | -uint64_t HELPER(vfp_cmpeh_a64)(float16 x, float16 y, void *fp_status) | 43 | /* Invoke a vector move on two Zregs. */ |
59 | +uint64_t HELPER(vfp_cmpeh_a64)(uint32_t x, uint32_t y, void *fp_status) | 44 | @@ -XXX,XX +XXX,XX @@ const uint64_t pred_esz_masks[4] = { |
45 | *** SVE Logical - Unpredicated Group | ||
46 | */ | ||
47 | |||
48 | +static bool do_zzz_fn(DisasContext *s, arg_rrr_esz *a, GVecGen3Fn *gvec_fn) | ||
49 | +{ | ||
50 | + if (sve_access_check(s)) { | ||
51 | + gen_gvec_fn_zzz(s, gvec_fn, a->esz, a->rd, a->rn, a->rm); | ||
52 | + } | ||
53 | + return true; | ||
54 | +} | ||
55 | + | ||
56 | static bool trans_AND_zzz(DisasContext *s, arg_rrr_esz *a) | ||
60 | { | 57 | { |
61 | return float_rel_to_flags(float16_compare(x, y, fp_status)); | 58 | - return do_vector3_z(s, tcg_gen_gvec_and, 0, a->rd, a->rn, a->rm); |
59 | + return do_zzz_fn(s, a, tcg_gen_gvec_and); | ||
62 | } | 60 | } |
63 | @@ -XXX,XX +XXX,XX @@ uint64_t HELPER(neon_cgt_f64)(float64 a, float64 b, void *fpstp) | 61 | |
64 | #define float64_three make_float64(0x4008000000000000ULL) | 62 | static bool trans_ORR_zzz(DisasContext *s, arg_rrr_esz *a) |
65 | #define float64_one_point_five make_float64(0x3FF8000000000000ULL) | ||
66 | |||
67 | -float16 HELPER(recpsf_f16)(float16 a, float16 b, void *fpstp) | ||
68 | +uint32_t HELPER(recpsf_f16)(uint32_t a, uint32_t b, void *fpstp) | ||
69 | { | 63 | { |
70 | float_status *fpst = fpstp; | 64 | - return do_vector3_z(s, tcg_gen_gvec_or, 0, a->rd, a->rn, a->rm); |
71 | 65 | + return do_zzz_fn(s, a, tcg_gen_gvec_or); | |
72 | @@ -XXX,XX +XXX,XX @@ float64 HELPER(recpsf_f64)(float64 a, float64 b, void *fpstp) | ||
73 | return float64_muladd(a, b, float64_two, 0, fpst); | ||
74 | } | 66 | } |
75 | 67 | ||
76 | -float16 HELPER(rsqrtsf_f16)(float16 a, float16 b, void *fpstp) | 68 | static bool trans_EOR_zzz(DisasContext *s, arg_rrr_esz *a) |
77 | +uint32_t HELPER(rsqrtsf_f16)(uint32_t a, uint32_t b, void *fpstp) | ||
78 | { | 69 | { |
79 | float_status *fpst = fpstp; | 70 | - return do_vector3_z(s, tcg_gen_gvec_xor, 0, a->rd, a->rn, a->rm); |
80 | 71 | + return do_zzz_fn(s, a, tcg_gen_gvec_xor); | |
81 | @@ -XXX,XX +XXX,XX @@ uint64_t HELPER(neon_addlp_u16)(uint64_t a) | ||
82 | } | 72 | } |
83 | 73 | ||
84 | /* Floating-point reciprocal exponent - see FPRecpX in ARM ARM */ | 74 | static bool trans_BIC_zzz(DisasContext *s, arg_rrr_esz *a) |
85 | -float16 HELPER(frecpx_f16)(float16 a, void *fpstp) | ||
86 | +uint32_t HELPER(frecpx_f16)(uint32_t a, void *fpstp) | ||
87 | { | 75 | { |
88 | float_status *fpst = fpstp; | 76 | - return do_vector3_z(s, tcg_gen_gvec_andc, 0, a->rd, a->rn, a->rm); |
89 | uint16_t val16, sbit; | 77 | + return do_zzz_fn(s, a, tcg_gen_gvec_andc); |
90 | @@ -XXX,XX +XXX,XX @@ void HELPER(casp_be_parallel)(CPUARMState *env, uint32_t rs, uint64_t addr, | 78 | } |
91 | #define ADVSIMD_HELPER(name, suffix) HELPER(glue(glue(advsimd_, name), suffix)) | 79 | |
92 | 80 | /* | |
93 | #define ADVSIMD_HALFOP(name) \ | 81 | @@ -XXX,XX +XXX,XX @@ static bool trans_BIC_zzz(DisasContext *s, arg_rrr_esz *a) |
94 | -float16 ADVSIMD_HELPER(name, h)(float16 a, float16 b, void *fpstp) \ | 82 | |
95 | +uint32_t ADVSIMD_HELPER(name, h)(uint32_t a, uint32_t b, void *fpstp) \ | 83 | static bool trans_ADD_zzz(DisasContext *s, arg_rrr_esz *a) |
96 | { \ | ||
97 | float_status *fpst = fpstp; \ | ||
98 | return float16_ ## name(a, b, fpst); \ | ||
99 | @@ -XXX,XX +XXX,XX @@ ADVSIMD_HALFOP(mulx) | ||
100 | ADVSIMD_TWOHALFOP(mulx) | ||
101 | |||
102 | /* fused multiply-accumulate */ | ||
103 | -float16 HELPER(advsimd_muladdh)(float16 a, float16 b, float16 c, void *fpstp) | ||
104 | +uint32_t HELPER(advsimd_muladdh)(uint32_t a, uint32_t b, uint32_t c, | ||
105 | + void *fpstp) | ||
106 | { | 84 | { |
107 | float_status *fpst = fpstp; | 85 | - return do_vector3_z(s, tcg_gen_gvec_add, a->esz, a->rd, a->rn, a->rm); |
108 | return float16_muladd(a, b, c, 0, fpst); | 86 | + return do_zzz_fn(s, a, tcg_gen_gvec_add); |
109 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(advsimd_muladd2h)(uint32_t two_a, uint32_t two_b, | 87 | } |
110 | 88 | ||
111 | #define ADVSIMD_CMPRES(test) (test) ? 0xffff : 0 | 89 | static bool trans_SUB_zzz(DisasContext *s, arg_rrr_esz *a) |
112 | |||
113 | -uint32_t HELPER(advsimd_ceq_f16)(float16 a, float16 b, void *fpstp) | ||
114 | +uint32_t HELPER(advsimd_ceq_f16)(uint32_t a, uint32_t b, void *fpstp) | ||
115 | { | 90 | { |
116 | float_status *fpst = fpstp; | 91 | - return do_vector3_z(s, tcg_gen_gvec_sub, a->esz, a->rd, a->rn, a->rm); |
117 | int compare = float16_compare_quiet(a, b, fpst); | 92 | + return do_zzz_fn(s, a, tcg_gen_gvec_sub); |
118 | return ADVSIMD_CMPRES(compare == float_relation_equal); | ||
119 | } | 93 | } |
120 | 94 | ||
121 | -uint32_t HELPER(advsimd_cge_f16)(float16 a, float16 b, void *fpstp) | 95 | static bool trans_SQADD_zzz(DisasContext *s, arg_rrr_esz *a) |
122 | +uint32_t HELPER(advsimd_cge_f16)(uint32_t a, uint32_t b, void *fpstp) | ||
123 | { | 96 | { |
124 | float_status *fpst = fpstp; | 97 | - return do_vector3_z(s, tcg_gen_gvec_ssadd, a->esz, a->rd, a->rn, a->rm); |
125 | int compare = float16_compare(a, b, fpst); | 98 | + return do_zzz_fn(s, a, tcg_gen_gvec_ssadd); |
126 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(advsimd_cge_f16)(float16 a, float16 b, void *fpstp) | ||
127 | compare == float_relation_equal); | ||
128 | } | 99 | } |
129 | 100 | ||
130 | -uint32_t HELPER(advsimd_cgt_f16)(float16 a, float16 b, void *fpstp) | 101 | static bool trans_SQSUB_zzz(DisasContext *s, arg_rrr_esz *a) |
131 | +uint32_t HELPER(advsimd_cgt_f16)(uint32_t a, uint32_t b, void *fpstp) | ||
132 | { | 102 | { |
133 | float_status *fpst = fpstp; | 103 | - return do_vector3_z(s, tcg_gen_gvec_sssub, a->esz, a->rd, a->rn, a->rm); |
134 | int compare = float16_compare(a, b, fpst); | 104 | + return do_zzz_fn(s, a, tcg_gen_gvec_sssub); |
135 | return ADVSIMD_CMPRES(compare == float_relation_greater); | ||
136 | } | 105 | } |
137 | 106 | ||
138 | -uint32_t HELPER(advsimd_acge_f16)(float16 a, float16 b, void *fpstp) | 107 | static bool trans_UQADD_zzz(DisasContext *s, arg_rrr_esz *a) |
139 | +uint32_t HELPER(advsimd_acge_f16)(uint32_t a, uint32_t b, void *fpstp) | ||
140 | { | 108 | { |
141 | float_status *fpst = fpstp; | 109 | - return do_vector3_z(s, tcg_gen_gvec_usadd, a->esz, a->rd, a->rn, a->rm); |
142 | float16 f0 = float16_abs(a); | 110 | + return do_zzz_fn(s, a, tcg_gen_gvec_usadd); |
143 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(advsimd_acge_f16)(float16 a, float16 b, void *fpstp) | ||
144 | compare == float_relation_equal); | ||
145 | } | 111 | } |
146 | 112 | ||
147 | -uint32_t HELPER(advsimd_acgt_f16)(float16 a, float16 b, void *fpstp) | 113 | static bool trans_UQSUB_zzz(DisasContext *s, arg_rrr_esz *a) |
148 | +uint32_t HELPER(advsimd_acgt_f16)(uint32_t a, uint32_t b, void *fpstp) | ||
149 | { | 114 | { |
150 | float_status *fpst = fpstp; | 115 | - return do_vector3_z(s, tcg_gen_gvec_ussub, a->esz, a->rd, a->rn, a->rm); |
151 | float16 f0 = float16_abs(a); | 116 | + return do_zzz_fn(s, a, tcg_gen_gvec_ussub); |
152 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(advsimd_acgt_f16)(float16 a, float16 b, void *fpstp) | ||
153 | } | 117 | } |
154 | 118 | ||
155 | /* round to integral */ | 119 | /* |
156 | -float16 HELPER(advsimd_rinth_exact)(float16 x, void *fp_status) | ||
157 | +uint32_t HELPER(advsimd_rinth_exact)(uint32_t x, void *fp_status) | ||
158 | { | ||
159 | return float16_round_to_int(x, fp_status); | ||
160 | } | ||
161 | |||
162 | -float16 HELPER(advsimd_rinth)(float16 x, void *fp_status) | ||
163 | +uint32_t HELPER(advsimd_rinth)(uint32_t x, void *fp_status) | ||
164 | { | ||
165 | int old_flags = get_float_exception_flags(fp_status), new_flags; | ||
166 | float16 ret; | ||
167 | @@ -XXX,XX +XXX,XX @@ float16 HELPER(advsimd_rinth)(float16 x, void *fp_status) | ||
168 | * setting the mode appropriately before calling the helper. | ||
169 | */ | ||
170 | |||
171 | -uint32_t HELPER(advsimd_f16tosinth)(float16 a, void *fpstp) | ||
172 | +uint32_t HELPER(advsimd_f16tosinth)(uint32_t a, void *fpstp) | ||
173 | { | ||
174 | float_status *fpst = fpstp; | ||
175 | |||
176 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(advsimd_f16tosinth)(float16 a, void *fpstp) | ||
177 | return float16_to_int16(a, fpst); | ||
178 | } | ||
179 | |||
180 | -uint32_t HELPER(advsimd_f16touinth)(float16 a, void *fpstp) | ||
181 | +uint32_t HELPER(advsimd_f16touinth)(uint32_t a, void *fpstp) | ||
182 | { | ||
183 | float_status *fpst = fpstp; | ||
184 | |||
185 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(advsimd_f16touinth)(float16 a, void *fpstp) | ||
186 | * Square Root and Reciprocal square root | ||
187 | */ | ||
188 | |||
189 | -float16 HELPER(sqrt_f16)(float16 a, void *fpstp) | ||
190 | +uint32_t HELPER(sqrt_f16)(uint32_t a, void *fpstp) | ||
191 | { | ||
192 | float_status *s = fpstp; | ||
193 | |||
194 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
195 | index XXXXXXX..XXXXXXX 100644 | ||
196 | --- a/target/arm/helper.c | ||
197 | +++ b/target/arm/helper.c | ||
198 | @@ -XXX,XX +XXX,XX @@ DO_VFP_cmp(d, float64) | ||
199 | |||
200 | /* Integer to float and float to integer conversions */ | ||
201 | |||
202 | -#define CONV_ITOF(name, fsz, sign) \ | ||
203 | - float##fsz HELPER(name)(uint32_t x, void *fpstp) \ | ||
204 | -{ \ | ||
205 | - float_status *fpst = fpstp; \ | ||
206 | - return sign##int32_to_##float##fsz((sign##int32_t)x, fpst); \ | ||
207 | +#define CONV_ITOF(name, ftype, fsz, sign) \ | ||
208 | +ftype HELPER(name)(uint32_t x, void *fpstp) \ | ||
209 | +{ \ | ||
210 | + float_status *fpst = fpstp; \ | ||
211 | + return sign##int32_to_##float##fsz((sign##int32_t)x, fpst); \ | ||
212 | } | ||
213 | |||
214 | -#define CONV_FTOI(name, fsz, sign, round) \ | ||
215 | -uint32_t HELPER(name)(float##fsz x, void *fpstp) \ | ||
216 | -{ \ | ||
217 | - float_status *fpst = fpstp; \ | ||
218 | - if (float##fsz##_is_any_nan(x)) { \ | ||
219 | - float_raise(float_flag_invalid, fpst); \ | ||
220 | - return 0; \ | ||
221 | - } \ | ||
222 | - return float##fsz##_to_##sign##int32##round(x, fpst); \ | ||
223 | +#define CONV_FTOI(name, ftype, fsz, sign, round) \ | ||
224 | +uint32_t HELPER(name)(ftype x, void *fpstp) \ | ||
225 | +{ \ | ||
226 | + float_status *fpst = fpstp; \ | ||
227 | + if (float##fsz##_is_any_nan(x)) { \ | ||
228 | + float_raise(float_flag_invalid, fpst); \ | ||
229 | + return 0; \ | ||
230 | + } \ | ||
231 | + return float##fsz##_to_##sign##int32##round(x, fpst); \ | ||
232 | } | ||
233 | |||
234 | -#define FLOAT_CONVS(name, p, fsz, sign) \ | ||
235 | -CONV_ITOF(vfp_##name##to##p, fsz, sign) \ | ||
236 | -CONV_FTOI(vfp_to##name##p, fsz, sign, ) \ | ||
237 | -CONV_FTOI(vfp_to##name##z##p, fsz, sign, _round_to_zero) | ||
238 | +#define FLOAT_CONVS(name, p, ftype, fsz, sign) \ | ||
239 | + CONV_ITOF(vfp_##name##to##p, ftype, fsz, sign) \ | ||
240 | + CONV_FTOI(vfp_to##name##p, ftype, fsz, sign, ) \ | ||
241 | + CONV_FTOI(vfp_to##name##z##p, ftype, fsz, sign, _round_to_zero) | ||
242 | |||
243 | -FLOAT_CONVS(si, h, 16, ) | ||
244 | -FLOAT_CONVS(si, s, 32, ) | ||
245 | -FLOAT_CONVS(si, d, 64, ) | ||
246 | -FLOAT_CONVS(ui, h, 16, u) | ||
247 | -FLOAT_CONVS(ui, s, 32, u) | ||
248 | -FLOAT_CONVS(ui, d, 64, u) | ||
249 | +FLOAT_CONVS(si, h, uint32_t, 16, ) | ||
250 | +FLOAT_CONVS(si, s, float32, 32, ) | ||
251 | +FLOAT_CONVS(si, d, float64, 64, ) | ||
252 | +FLOAT_CONVS(ui, h, uint32_t, 16, u) | ||
253 | +FLOAT_CONVS(ui, s, float32, 32, u) | ||
254 | +FLOAT_CONVS(ui, d, float64, 64, u) | ||
255 | |||
256 | #undef CONV_ITOF | ||
257 | #undef CONV_FTOI | ||
258 | @@ -XXX,XX +XXX,XX @@ static float16 do_postscale_fp16(float64 f, int shift, float_status *fpst) | ||
259 | return float64_to_float16(float64_scalbn(f, -shift, fpst), true, fpst); | ||
260 | } | ||
261 | |||
262 | -float16 HELPER(vfp_sltoh)(uint32_t x, uint32_t shift, void *fpst) | ||
263 | +uint32_t HELPER(vfp_sltoh)(uint32_t x, uint32_t shift, void *fpst) | ||
264 | { | ||
265 | return do_postscale_fp16(int32_to_float64(x, fpst), shift, fpst); | ||
266 | } | ||
267 | |||
268 | -float16 HELPER(vfp_ultoh)(uint32_t x, uint32_t shift, void *fpst) | ||
269 | +uint32_t HELPER(vfp_ultoh)(uint32_t x, uint32_t shift, void *fpst) | ||
270 | { | ||
271 | return do_postscale_fp16(uint32_to_float64(x, fpst), shift, fpst); | ||
272 | } | ||
273 | |||
274 | -float16 HELPER(vfp_sqtoh)(uint64_t x, uint32_t shift, void *fpst) | ||
275 | +uint32_t HELPER(vfp_sqtoh)(uint64_t x, uint32_t shift, void *fpst) | ||
276 | { | ||
277 | return do_postscale_fp16(int64_to_float64(x, fpst), shift, fpst); | ||
278 | } | ||
279 | |||
280 | -float16 HELPER(vfp_uqtoh)(uint64_t x, uint32_t shift, void *fpst) | ||
281 | +uint32_t HELPER(vfp_uqtoh)(uint64_t x, uint32_t shift, void *fpst) | ||
282 | { | ||
283 | return do_postscale_fp16(uint64_to_float64(x, fpst), shift, fpst); | ||
284 | } | ||
285 | @@ -XXX,XX +XXX,XX @@ static float64 do_prescale_fp16(float16 f, int shift, float_status *fpst) | ||
286 | } | ||
287 | } | ||
288 | |||
289 | -uint32_t HELPER(vfp_toshh)(float16 x, uint32_t shift, void *fpst) | ||
290 | +uint32_t HELPER(vfp_toshh)(uint32_t x, uint32_t shift, void *fpst) | ||
291 | { | ||
292 | return float64_to_int16(do_prescale_fp16(x, shift, fpst), fpst); | ||
293 | } | ||
294 | |||
295 | -uint32_t HELPER(vfp_touhh)(float16 x, uint32_t shift, void *fpst) | ||
296 | +uint32_t HELPER(vfp_touhh)(uint32_t x, uint32_t shift, void *fpst) | ||
297 | { | ||
298 | return float64_to_uint16(do_prescale_fp16(x, shift, fpst), fpst); | ||
299 | } | ||
300 | |||
301 | -uint32_t HELPER(vfp_toslh)(float16 x, uint32_t shift, void *fpst) | ||
302 | +uint32_t HELPER(vfp_toslh)(uint32_t x, uint32_t shift, void *fpst) | ||
303 | { | ||
304 | return float64_to_int32(do_prescale_fp16(x, shift, fpst), fpst); | ||
305 | } | ||
306 | |||
307 | -uint32_t HELPER(vfp_toulh)(float16 x, uint32_t shift, void *fpst) | ||
308 | +uint32_t HELPER(vfp_toulh)(uint32_t x, uint32_t shift, void *fpst) | ||
309 | { | ||
310 | return float64_to_uint32(do_prescale_fp16(x, shift, fpst), fpst); | ||
311 | } | ||
312 | |||
313 | -uint64_t HELPER(vfp_tosqh)(float16 x, uint32_t shift, void *fpst) | ||
314 | +uint64_t HELPER(vfp_tosqh)(uint32_t x, uint32_t shift, void *fpst) | ||
315 | { | ||
316 | return float64_to_int64(do_prescale_fp16(x, shift, fpst), fpst); | ||
317 | } | ||
318 | |||
319 | -uint64_t HELPER(vfp_touqh)(float16 x, uint32_t shift, void *fpst) | ||
320 | +uint64_t HELPER(vfp_touqh)(uint32_t x, uint32_t shift, void *fpst) | ||
321 | { | ||
322 | return float64_to_uint64(do_prescale_fp16(x, shift, fpst), fpst); | ||
323 | } | ||
324 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(set_neon_rmode)(uint32_t rmode, CPUARMState *env) | ||
325 | } | ||
326 | |||
327 | /* Half precision conversions. */ | ||
328 | -float32 HELPER(vfp_fcvt_f16_to_f32)(float16 a, void *fpstp, uint32_t ahp_mode) | ||
329 | +float32 HELPER(vfp_fcvt_f16_to_f32)(uint32_t a, void *fpstp, uint32_t ahp_mode) | ||
330 | { | ||
331 | /* Squash FZ16 to 0 for the duration of conversion. In this case, | ||
332 | * it would affect flushing input denormals. | ||
333 | @@ -XXX,XX +XXX,XX @@ float32 HELPER(vfp_fcvt_f16_to_f32)(float16 a, void *fpstp, uint32_t ahp_mode) | ||
334 | return r; | ||
335 | } | ||
336 | |||
337 | -float16 HELPER(vfp_fcvt_f32_to_f16)(float32 a, void *fpstp, uint32_t ahp_mode) | ||
338 | +uint32_t HELPER(vfp_fcvt_f32_to_f16)(float32 a, void *fpstp, uint32_t ahp_mode) | ||
339 | { | ||
340 | /* Squash FZ16 to 0 for the duration of conversion. In this case, | ||
341 | * it would affect flushing output denormals. | ||
342 | @@ -XXX,XX +XXX,XX @@ float16 HELPER(vfp_fcvt_f32_to_f16)(float32 a, void *fpstp, uint32_t ahp_mode) | ||
343 | return r; | ||
344 | } | ||
345 | |||
346 | -float64 HELPER(vfp_fcvt_f16_to_f64)(float16 a, void *fpstp, uint32_t ahp_mode) | ||
347 | +float64 HELPER(vfp_fcvt_f16_to_f64)(uint32_t a, void *fpstp, uint32_t ahp_mode) | ||
348 | { | ||
349 | /* Squash FZ16 to 0 for the duration of conversion. In this case, | ||
350 | * it would affect flushing input denormals. | ||
351 | @@ -XXX,XX +XXX,XX @@ float64 HELPER(vfp_fcvt_f16_to_f64)(float16 a, void *fpstp, uint32_t ahp_mode) | ||
352 | return r; | ||
353 | } | ||
354 | |||
355 | -float16 HELPER(vfp_fcvt_f64_to_f16)(float64 a, void *fpstp, uint32_t ahp_mode) | ||
356 | +uint32_t HELPER(vfp_fcvt_f64_to_f16)(float64 a, void *fpstp, uint32_t ahp_mode) | ||
357 | { | ||
358 | /* Squash FZ16 to 0 for the duration of conversion. In this case, | ||
359 | * it would affect flushing output denormals. | ||
360 | @@ -XXX,XX +XXX,XX @@ static bool round_to_inf(float_status *fpst, bool sign_bit) | ||
361 | g_assert_not_reached(); | ||
362 | } | ||
363 | |||
364 | -float16 HELPER(recpe_f16)(float16 input, void *fpstp) | ||
365 | +uint32_t HELPER(recpe_f16)(uint32_t input, void *fpstp) | ||
366 | { | ||
367 | float_status *fpst = fpstp; | ||
368 | float16 f16 = float16_squash_input_denormal(input, fpst); | ||
369 | @@ -XXX,XX +XXX,XX @@ static uint64_t recip_sqrt_estimate(int *exp , int exp_off, uint64_t frac) | ||
370 | return extract64(estimate, 0, 8) << 44; | ||
371 | } | ||
372 | |||
373 | -float16 HELPER(rsqrte_f16)(float16 input, void *fpstp) | ||
374 | +uint32_t HELPER(rsqrte_f16)(uint32_t input, void *fpstp) | ||
375 | { | ||
376 | float_status *s = fpstp; | ||
377 | float16 f16 = float16_squash_input_denormal(input, s); | ||
378 | -- | 120 | -- |
379 | 2.17.1 | 121 | 2.20.1 |
380 | 122 | ||
381 | 123 | diff view generated by jsdifflib |
1 | As part of plumbing MemTxAttrs down to the IOMMU translate method, | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | add MemTxAttrs as an argument to address_space_access_valid(). | ||
3 | Its callers either have an attrs value to hand, or don't care | ||
4 | and can use MEMTXATTRS_UNSPECIFIED. | ||
5 | 2 | ||
3 | We want to ensure that access is checked by the time we ask | ||
4 | for a specific fp/vector register. We want to ensure that | ||
5 | we do not emit two lots of code to raise an exception. | ||
6 | |||
7 | But sometimes it's difficult to cleanly organize the code | ||
8 | such that we never pass through sve_check_access exactly once. | ||
9 | Allow multiple calls so long as the result is true, that is, | ||
10 | no exception to be raised. | ||
11 | |||
12 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
13 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
14 | Message-id: 20200815013145.539409-5-richard.henderson@linaro.org | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20180521140402.23318-6-peter.maydell@linaro.org | ||
10 | --- | 16 | --- |
11 | include/exec/memory.h | 4 +++- | 17 | target/arm/translate.h | 1 + |
12 | include/sysemu/dma.h | 3 ++- | 18 | target/arm/translate-a64.c | 27 ++++++++++++++++----------- |
13 | exec.c | 3 ++- | 19 | 2 files changed, 17 insertions(+), 11 deletions(-) |
14 | target/s390x/diag.c | 6 ++++-- | ||
15 | target/s390x/excp_helper.c | 3 ++- | ||
16 | target/s390x/mmu_helper.c | 3 ++- | ||
17 | target/s390x/sigp.c | 3 ++- | ||
18 | 7 files changed, 17 insertions(+), 8 deletions(-) | ||
19 | 20 | ||
20 | diff --git a/include/exec/memory.h b/include/exec/memory.h | 21 | diff --git a/target/arm/translate.h b/target/arm/translate.h |
21 | index XXXXXXX..XXXXXXX 100644 | 22 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/include/exec/memory.h | 23 | --- a/target/arm/translate.h |
23 | +++ b/include/exec/memory.h | 24 | +++ b/target/arm/translate.h |
24 | @@ -XXX,XX +XXX,XX @@ static inline MemoryRegion *address_space_translate(AddressSpace *as, | 25 | @@ -XXX,XX +XXX,XX @@ typedef struct DisasContext { |
25 | * @addr: address within that address space | 26 | * that it is set at the point where we actually touch the FP regs. |
26 | * @len: length of the area to be checked | 27 | */ |
27 | * @is_write: indicates the transfer direction | 28 | bool fp_access_checked; |
28 | + * @attrs: memory attributes | 29 | + bool sve_access_checked; |
30 | /* ARMv8 single-step state (this is distinct from the QEMU gdbstub | ||
31 | * single-step support). | ||
32 | */ | ||
33 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
34 | index XXXXXXX..XXXXXXX 100644 | ||
35 | --- a/target/arm/translate-a64.c | ||
36 | +++ b/target/arm/translate-a64.c | ||
37 | @@ -XXX,XX +XXX,XX @@ static void do_vec_ld(DisasContext *s, int destidx, int element, | ||
38 | * unallocated-encoding checks (otherwise the syndrome information | ||
39 | * for the resulting exception will be incorrect). | ||
29 | */ | 40 | */ |
30 | -bool address_space_access_valid(AddressSpace *as, hwaddr addr, int len, bool is_write); | 41 | -static inline bool fp_access_check(DisasContext *s) |
31 | +bool address_space_access_valid(AddressSpace *as, hwaddr addr, int len, | 42 | +static bool fp_access_check(DisasContext *s) |
32 | + bool is_write, MemTxAttrs attrs); | ||
33 | |||
34 | /* address_space_map: map a physical memory region into a host virtual address | ||
35 | * | ||
36 | diff --git a/include/sysemu/dma.h b/include/sysemu/dma.h | ||
37 | index XXXXXXX..XXXXXXX 100644 | ||
38 | --- a/include/sysemu/dma.h | ||
39 | +++ b/include/sysemu/dma.h | ||
40 | @@ -XXX,XX +XXX,XX @@ static inline bool dma_memory_valid(AddressSpace *as, | ||
41 | DMADirection dir) | ||
42 | { | 43 | { |
43 | return address_space_access_valid(as, addr, len, | 44 | - assert(!s->fp_access_checked); |
44 | - dir == DMA_DIRECTION_FROM_DEVICE); | 45 | - s->fp_access_checked = true; |
45 | + dir == DMA_DIRECTION_FROM_DEVICE, | 46 | + if (s->fp_excp_el) { |
46 | + MEMTXATTRS_UNSPECIFIED); | 47 | + assert(!s->fp_access_checked); |
48 | + s->fp_access_checked = true; | ||
49 | |||
50 | - if (!s->fp_excp_el) { | ||
51 | - return true; | ||
52 | + gen_exception_insn(s, s->pc_curr, EXCP_UDEF, | ||
53 | + syn_fp_access_trap(1, 0xe, false), s->fp_excp_el); | ||
54 | + return false; | ||
55 | } | ||
56 | - | ||
57 | - gen_exception_insn(s, s->pc_curr, EXCP_UDEF, | ||
58 | - syn_fp_access_trap(1, 0xe, false), s->fp_excp_el); | ||
59 | - return false; | ||
60 | + s->fp_access_checked = true; | ||
61 | + return true; | ||
47 | } | 62 | } |
48 | 63 | ||
49 | static inline int dma_memory_rw_relaxed(AddressSpace *as, dma_addr_t addr, | 64 | /* Check that SVE access is enabled. If it is, return true. |
50 | diff --git a/exec.c b/exec.c | 65 | @@ -XXX,XX +XXX,XX @@ static inline bool fp_access_check(DisasContext *s) |
51 | index XXXXXXX..XXXXXXX 100644 | 66 | bool sve_access_check(DisasContext *s) |
52 | --- a/exec.c | 67 | { |
53 | +++ b/exec.c | 68 | if (s->sve_excp_el) { |
54 | @@ -XXX,XX +XXX,XX @@ static bool flatview_access_valid(FlatView *fv, hwaddr addr, int len, | 69 | - gen_exception_insn(s, s->pc_curr, EXCP_UDEF, syn_sve_access_trap(), |
70 | - s->sve_excp_el); | ||
71 | + assert(!s->sve_access_checked); | ||
72 | + s->sve_access_checked = true; | ||
73 | + | ||
74 | + gen_exception_insn(s, s->pc_curr, EXCP_UDEF, | ||
75 | + syn_sve_access_trap(), s->sve_excp_el); | ||
76 | return false; | ||
77 | } | ||
78 | + s->sve_access_checked = true; | ||
79 | return fp_access_check(s); | ||
55 | } | 80 | } |
56 | 81 | ||
57 | bool address_space_access_valid(AddressSpace *as, hwaddr addr, | 82 | @@ -XXX,XX +XXX,XX @@ static void disas_a64_insn(CPUARMState *env, DisasContext *s) |
58 | - int len, bool is_write) | 83 | s->base.pc_next += 4; |
59 | + int len, bool is_write, | 84 | |
60 | + MemTxAttrs attrs) | 85 | s->fp_access_checked = false; |
61 | { | 86 | + s->sve_access_checked = false; |
62 | FlatView *fv; | 87 | |
63 | bool result; | 88 | if (dc_isar_feature(aa64_bti, s)) { |
64 | diff --git a/target/s390x/diag.c b/target/s390x/diag.c | 89 | if (s->base.num_insns == 1) { |
65 | index XXXXXXX..XXXXXXX 100644 | ||
66 | --- a/target/s390x/diag.c | ||
67 | +++ b/target/s390x/diag.c | ||
68 | @@ -XXX,XX +XXX,XX @@ void handle_diag_308(CPUS390XState *env, uint64_t r1, uint64_t r3, uintptr_t ra) | ||
69 | return; | ||
70 | } | ||
71 | if (!address_space_access_valid(&address_space_memory, addr, | ||
72 | - sizeof(IplParameterBlock), false)) { | ||
73 | + sizeof(IplParameterBlock), false, | ||
74 | + MEMTXATTRS_UNSPECIFIED)) { | ||
75 | s390_program_interrupt(env, PGM_ADDRESSING, ILEN_AUTO, ra); | ||
76 | return; | ||
77 | } | ||
78 | @@ -XXX,XX +XXX,XX @@ out: | ||
79 | return; | ||
80 | } | ||
81 | if (!address_space_access_valid(&address_space_memory, addr, | ||
82 | - sizeof(IplParameterBlock), true)) { | ||
83 | + sizeof(IplParameterBlock), true, | ||
84 | + MEMTXATTRS_UNSPECIFIED)) { | ||
85 | s390_program_interrupt(env, PGM_ADDRESSING, ILEN_AUTO, ra); | ||
86 | return; | ||
87 | } | ||
88 | diff --git a/target/s390x/excp_helper.c b/target/s390x/excp_helper.c | ||
89 | index XXXXXXX..XXXXXXX 100644 | ||
90 | --- a/target/s390x/excp_helper.c | ||
91 | +++ b/target/s390x/excp_helper.c | ||
92 | @@ -XXX,XX +XXX,XX @@ int s390_cpu_handle_mmu_fault(CPUState *cs, vaddr orig_vaddr, int size, | ||
93 | |||
94 | /* check out of RAM access */ | ||
95 | if (!address_space_access_valid(&address_space_memory, raddr, | ||
96 | - TARGET_PAGE_SIZE, rw)) { | ||
97 | + TARGET_PAGE_SIZE, rw, | ||
98 | + MEMTXATTRS_UNSPECIFIED)) { | ||
99 | DPRINTF("%s: raddr %" PRIx64 " > ram_size %" PRIx64 "\n", __func__, | ||
100 | (uint64_t)raddr, (uint64_t)ram_size); | ||
101 | trigger_pgm_exception(env, PGM_ADDRESSING, ILEN_AUTO); | ||
102 | diff --git a/target/s390x/mmu_helper.c b/target/s390x/mmu_helper.c | ||
103 | index XXXXXXX..XXXXXXX 100644 | ||
104 | --- a/target/s390x/mmu_helper.c | ||
105 | +++ b/target/s390x/mmu_helper.c | ||
106 | @@ -XXX,XX +XXX,XX @@ static int translate_pages(S390CPU *cpu, vaddr addr, int nr_pages, | ||
107 | return ret; | ||
108 | } | ||
109 | if (!address_space_access_valid(&address_space_memory, pages[i], | ||
110 | - TARGET_PAGE_SIZE, is_write)) { | ||
111 | + TARGET_PAGE_SIZE, is_write, | ||
112 | + MEMTXATTRS_UNSPECIFIED)) { | ||
113 | trigger_access_exception(env, PGM_ADDRESSING, ILEN_AUTO, 0); | ||
114 | return -EFAULT; | ||
115 | } | ||
116 | diff --git a/target/s390x/sigp.c b/target/s390x/sigp.c | ||
117 | index XXXXXXX..XXXXXXX 100644 | ||
118 | --- a/target/s390x/sigp.c | ||
119 | +++ b/target/s390x/sigp.c | ||
120 | @@ -XXX,XX +XXX,XX @@ static void sigp_set_prefix(CPUState *cs, run_on_cpu_data arg) | ||
121 | cpu_synchronize_state(cs); | ||
122 | |||
123 | if (!address_space_access_valid(&address_space_memory, addr, | ||
124 | - sizeof(struct LowCore), false)) { | ||
125 | + sizeof(struct LowCore), false, | ||
126 | + MEMTXATTRS_UNSPECIFIED)) { | ||
127 | set_sigp_status(si, SIGP_STAT_INVALID_PARAMETER); | ||
128 | return; | ||
129 | } | ||
130 | -- | 90 | -- |
131 | 2.17.1 | 91 | 2.20.1 |
132 | 92 | ||
133 | 93 | diff view generated by jsdifflib |
1 | As part of plumbing MemTxAttrs down to the IOMMU translate method, | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | add MemTxAttrs as an argument to flatview_access_valid(). | ||
3 | Its callers now all have an attrs value to hand, so we can | ||
4 | correct our earlier temporary use of MEMTXATTRS_UNSPECIFIED. | ||
5 | 2 | ||
3 | This is the only user of the function. | ||
4 | |||
5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Message-id: 20200815013145.539409-6-richard.henderson@linaro.org | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20180521140402.23318-10-peter.maydell@linaro.org | ||
10 | --- | 9 | --- |
11 | exec.c | 12 +++++------- | 10 | target/arm/translate-sve.c | 19 ++++++------------- |
12 | 1 file changed, 5 insertions(+), 7 deletions(-) | 11 | 1 file changed, 6 insertions(+), 13 deletions(-) |
13 | 12 | ||
14 | diff --git a/exec.c b/exec.c | 13 | diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c |
15 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/exec.c | 15 | --- a/target/arm/translate-sve.c |
17 | +++ b/exec.c | 16 | +++ b/target/arm/translate-sve.c |
18 | @@ -XXX,XX +XXX,XX @@ static MemTxResult flatview_read(FlatView *fv, hwaddr addr, | 17 | @@ -XXX,XX +XXX,XX @@ static void do_dupi_z(DisasContext *s, int rd, uint64_t word) |
19 | static MemTxResult flatview_write(FlatView *fv, hwaddr addr, MemTxAttrs attrs, | 18 | tcg_gen_gvec_dup_imm(MO_64, vec_full_reg_offset(s, rd), vsz, vsz, word); |
20 | const uint8_t *buf, int len); | ||
21 | static bool flatview_access_valid(FlatView *fv, hwaddr addr, int len, | ||
22 | - bool is_write); | ||
23 | + bool is_write, MemTxAttrs attrs); | ||
24 | |||
25 | static MemTxResult subpage_read(void *opaque, hwaddr addr, uint64_t *data, | ||
26 | unsigned len, MemTxAttrs attrs) | ||
27 | @@ -XXX,XX +XXX,XX @@ static bool subpage_accepts(void *opaque, hwaddr addr, | ||
28 | #endif | ||
29 | |||
30 | return flatview_access_valid(subpage->fv, addr + subpage->base, | ||
31 | - len, is_write); | ||
32 | + len, is_write, attrs); | ||
33 | } | 19 | } |
34 | 20 | ||
35 | static const MemoryRegionOps subpage_ops = { | 21 | -/* Invoke a vector expander on two Pregs. */ |
36 | @@ -XXX,XX +XXX,XX @@ static void cpu_notify_map_clients(void) | 22 | -static bool do_vector2_p(DisasContext *s, GVecGen2Fn *gvec_fn, |
23 | - int esz, int rd, int rn) | ||
24 | -{ | ||
25 | - if (sve_access_check(s)) { | ||
26 | - unsigned psz = pred_gvec_reg_size(s); | ||
27 | - gvec_fn(esz, pred_full_reg_offset(s, rd), | ||
28 | - pred_full_reg_offset(s, rn), psz, psz); | ||
29 | - } | ||
30 | - return true; | ||
31 | -} | ||
32 | - | ||
33 | /* Invoke a vector expander on three Pregs. */ | ||
34 | static bool do_vector3_p(DisasContext *s, GVecGen3Fn *gvec_fn, | ||
35 | int esz, int rd, int rn, int rm) | ||
36 | @@ -XXX,XX +XXX,XX @@ static bool do_vecop4_p(DisasContext *s, const GVecGen4 *gvec_op, | ||
37 | /* Invoke a vector move on two Pregs. */ | ||
38 | static bool do_mov_p(DisasContext *s, int rd, int rn) | ||
39 | { | ||
40 | - return do_vector2_p(s, tcg_gen_gvec_mov, 0, rd, rn); | ||
41 | + if (sve_access_check(s)) { | ||
42 | + unsigned psz = pred_gvec_reg_size(s); | ||
43 | + tcg_gen_gvec_mov(MO_8, pred_full_reg_offset(s, rd), | ||
44 | + pred_full_reg_offset(s, rn), psz, psz); | ||
45 | + } | ||
46 | + return true; | ||
37 | } | 47 | } |
38 | 48 | ||
39 | static bool flatview_access_valid(FlatView *fv, hwaddr addr, int len, | 49 | /* Set the cpu flags as per a return from an SVE helper. */ |
40 | - bool is_write) | ||
41 | + bool is_write, MemTxAttrs attrs) | ||
42 | { | ||
43 | MemoryRegion *mr; | ||
44 | hwaddr l, xlat; | ||
45 | @@ -XXX,XX +XXX,XX @@ static bool flatview_access_valid(FlatView *fv, hwaddr addr, int len, | ||
46 | mr = flatview_translate(fv, addr, &xlat, &l, is_write); | ||
47 | if (!memory_access_is_direct(mr, is_write)) { | ||
48 | l = memory_access_size(mr, l, addr); | ||
49 | - /* When our callers all have attrs we'll pass them through here */ | ||
50 | - if (!memory_region_access_valid(mr, xlat, l, is_write, | ||
51 | - MEMTXATTRS_UNSPECIFIED)) { | ||
52 | + if (!memory_region_access_valid(mr, xlat, l, is_write, attrs)) { | ||
53 | return false; | ||
54 | } | ||
55 | } | ||
56 | @@ -XXX,XX +XXX,XX @@ bool address_space_access_valid(AddressSpace *as, hwaddr addr, | ||
57 | |||
58 | rcu_read_lock(); | ||
59 | fv = address_space_to_flatview(as); | ||
60 | - result = flatview_access_valid(fv, addr, len, is_write); | ||
61 | + result = flatview_access_valid(fv, addr, len, is_write, attrs); | ||
62 | rcu_read_unlock(); | ||
63 | return result; | ||
64 | } | ||
65 | -- | 50 | -- |
66 | 2.17.1 | 51 | 2.20.1 |
67 | 52 | ||
68 | 53 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | 1 | From: Richard Henderson <richard.henderson@linaro.org> | |
2 | |||
3 | Move the check for !S into do_pppp_flags, which allows to merge in | ||
4 | do_vecop4_p. Split out gen_gvec_fn_ppp without sve_access_check, | ||
5 | to mirror gen_gvec_fn_zzz. | ||
6 | |||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Message-id: 20200815013145.539409-7-richard.henderson@linaro.org | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | target/arm/translate-sve.c | 111 ++++++++++++++----------------------- | ||
13 | 1 file changed, 43 insertions(+), 68 deletions(-) | ||
14 | |||
15 | diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/target/arm/translate-sve.c | ||
18 | +++ b/target/arm/translate-sve.c | ||
19 | @@ -XXX,XX +XXX,XX @@ static void do_dupi_z(DisasContext *s, int rd, uint64_t word) | ||
20 | } | ||
21 | |||
22 | /* Invoke a vector expander on three Pregs. */ | ||
23 | -static bool do_vector3_p(DisasContext *s, GVecGen3Fn *gvec_fn, | ||
24 | - int esz, int rd, int rn, int rm) | ||
25 | +static void gen_gvec_fn_ppp(DisasContext *s, GVecGen3Fn *gvec_fn, | ||
26 | + int rd, int rn, int rm) | ||
27 | { | ||
28 | - if (sve_access_check(s)) { | ||
29 | - unsigned psz = pred_gvec_reg_size(s); | ||
30 | - gvec_fn(esz, pred_full_reg_offset(s, rd), | ||
31 | - pred_full_reg_offset(s, rn), | ||
32 | - pred_full_reg_offset(s, rm), psz, psz); | ||
33 | - } | ||
34 | - return true; | ||
35 | -} | ||
36 | - | ||
37 | -/* Invoke a vector operation on four Pregs. */ | ||
38 | -static bool do_vecop4_p(DisasContext *s, const GVecGen4 *gvec_op, | ||
39 | - int rd, int rn, int rm, int rg) | ||
40 | -{ | ||
41 | - if (sve_access_check(s)) { | ||
42 | - unsigned psz = pred_gvec_reg_size(s); | ||
43 | - tcg_gen_gvec_4(pred_full_reg_offset(s, rd), | ||
44 | - pred_full_reg_offset(s, rn), | ||
45 | - pred_full_reg_offset(s, rm), | ||
46 | - pred_full_reg_offset(s, rg), | ||
47 | - psz, psz, gvec_op); | ||
48 | - } | ||
49 | - return true; | ||
50 | + unsigned psz = pred_gvec_reg_size(s); | ||
51 | + gvec_fn(MO_64, pred_full_reg_offset(s, rd), | ||
52 | + pred_full_reg_offset(s, rn), | ||
53 | + pred_full_reg_offset(s, rm), psz, psz); | ||
54 | } | ||
55 | |||
56 | /* Invoke a vector move on two Pregs. */ | ||
57 | @@ -XXX,XX +XXX,XX @@ static bool do_pppp_flags(DisasContext *s, arg_rprr_s *a, | ||
58 | int mofs = pred_full_reg_offset(s, a->rm); | ||
59 | int gofs = pred_full_reg_offset(s, a->pg); | ||
60 | |||
61 | + if (!a->s) { | ||
62 | + tcg_gen_gvec_4(dofs, nofs, mofs, gofs, psz, psz, gvec_op); | ||
63 | + return true; | ||
64 | + } | ||
65 | + | ||
66 | if (psz == 8) { | ||
67 | /* Do the operation and the flags generation in temps. */ | ||
68 | TCGv_i64 pd = tcg_temp_new_i64(); | ||
69 | @@ -XXX,XX +XXX,XX @@ static bool trans_AND_pppp(DisasContext *s, arg_rprr_s *a) | ||
70 | .fno = gen_helper_sve_and_pppp, | ||
71 | .prefer_i64 = TCG_TARGET_REG_BITS == 64, | ||
72 | }; | ||
73 | - if (a->s) { | ||
74 | - return do_pppp_flags(s, a, &op); | ||
75 | - } else if (a->rn == a->rm) { | ||
76 | - if (a->pg == a->rn) { | ||
77 | - return do_mov_p(s, a->rd, a->rn); | ||
78 | - } else { | ||
79 | - return do_vector3_p(s, tcg_gen_gvec_and, 0, a->rd, a->rn, a->pg); | ||
80 | + | ||
81 | + if (!a->s) { | ||
82 | + if (!sve_access_check(s)) { | ||
83 | + return true; | ||
84 | + } | ||
85 | + if (a->rn == a->rm) { | ||
86 | + if (a->pg == a->rn) { | ||
87 | + do_mov_p(s, a->rd, a->rn); | ||
88 | + } else { | ||
89 | + gen_gvec_fn_ppp(s, tcg_gen_gvec_and, a->rd, a->rn, a->pg); | ||
90 | + } | ||
91 | + return true; | ||
92 | + } else if (a->pg == a->rn || a->pg == a->rm) { | ||
93 | + gen_gvec_fn_ppp(s, tcg_gen_gvec_and, a->rd, a->rn, a->rm); | ||
94 | + return true; | ||
95 | } | ||
96 | - } else if (a->pg == a->rn || a->pg == a->rm) { | ||
97 | - return do_vector3_p(s, tcg_gen_gvec_and, 0, a->rd, a->rn, a->rm); | ||
98 | - } else { | ||
99 | - return do_vecop4_p(s, &op, a->rd, a->rn, a->rm, a->pg); | ||
100 | } | ||
101 | + return do_pppp_flags(s, a, &op); | ||
102 | } | ||
103 | |||
104 | static void gen_bic_pg_i64(TCGv_i64 pd, TCGv_i64 pn, TCGv_i64 pm, TCGv_i64 pg) | ||
105 | @@ -XXX,XX +XXX,XX @@ static bool trans_BIC_pppp(DisasContext *s, arg_rprr_s *a) | ||
106 | .fno = gen_helper_sve_bic_pppp, | ||
107 | .prefer_i64 = TCG_TARGET_REG_BITS == 64, | ||
108 | }; | ||
109 | - if (a->s) { | ||
110 | - return do_pppp_flags(s, a, &op); | ||
111 | - } else if (a->pg == a->rn) { | ||
112 | - return do_vector3_p(s, tcg_gen_gvec_andc, 0, a->rd, a->rn, a->rm); | ||
113 | - } else { | ||
114 | - return do_vecop4_p(s, &op, a->rd, a->rn, a->rm, a->pg); | ||
115 | + | ||
116 | + if (!a->s && a->pg == a->rn) { | ||
117 | + if (sve_access_check(s)) { | ||
118 | + gen_gvec_fn_ppp(s, tcg_gen_gvec_andc, a->rd, a->rn, a->rm); | ||
119 | + } | ||
120 | + return true; | ||
121 | } | ||
122 | + return do_pppp_flags(s, a, &op); | ||
123 | } | ||
124 | |||
125 | static void gen_eor_pg_i64(TCGv_i64 pd, TCGv_i64 pn, TCGv_i64 pm, TCGv_i64 pg) | ||
126 | @@ -XXX,XX +XXX,XX @@ static bool trans_EOR_pppp(DisasContext *s, arg_rprr_s *a) | ||
127 | .fno = gen_helper_sve_eor_pppp, | ||
128 | .prefer_i64 = TCG_TARGET_REG_BITS == 64, | ||
129 | }; | ||
130 | - if (a->s) { | ||
131 | - return do_pppp_flags(s, a, &op); | ||
132 | - } else { | ||
133 | - return do_vecop4_p(s, &op, a->rd, a->rn, a->rm, a->pg); | ||
134 | - } | ||
135 | + return do_pppp_flags(s, a, &op); | ||
136 | } | ||
137 | |||
138 | static void gen_sel_pg_i64(TCGv_i64 pd, TCGv_i64 pn, TCGv_i64 pm, TCGv_i64 pg) | ||
139 | @@ -XXX,XX +XXX,XX @@ static bool trans_SEL_pppp(DisasContext *s, arg_rprr_s *a) | ||
140 | .fno = gen_helper_sve_sel_pppp, | ||
141 | .prefer_i64 = TCG_TARGET_REG_BITS == 64, | ||
142 | }; | ||
143 | + | ||
144 | if (a->s) { | ||
145 | return false; | ||
146 | - } else { | ||
147 | - return do_vecop4_p(s, &op, a->rd, a->rn, a->rm, a->pg); | ||
148 | } | ||
149 | + return do_pppp_flags(s, a, &op); | ||
150 | } | ||
151 | |||
152 | static void gen_orr_pg_i64(TCGv_i64 pd, TCGv_i64 pn, TCGv_i64 pm, TCGv_i64 pg) | ||
153 | @@ -XXX,XX +XXX,XX @@ static bool trans_ORR_pppp(DisasContext *s, arg_rprr_s *a) | ||
154 | .fno = gen_helper_sve_orr_pppp, | ||
155 | .prefer_i64 = TCG_TARGET_REG_BITS == 64, | ||
156 | }; | ||
157 | - if (a->s) { | ||
158 | - return do_pppp_flags(s, a, &op); | ||
159 | - } else if (a->pg == a->rn && a->rn == a->rm) { | ||
160 | + | ||
161 | + if (!a->s && a->pg == a->rn && a->rn == a->rm) { | ||
162 | return do_mov_p(s, a->rd, a->rn); | ||
163 | - } else { | ||
164 | - return do_vecop4_p(s, &op, a->rd, a->rn, a->rm, a->pg); | ||
165 | } | ||
166 | + return do_pppp_flags(s, a, &op); | ||
167 | } | ||
168 | |||
169 | static void gen_orn_pg_i64(TCGv_i64 pd, TCGv_i64 pn, TCGv_i64 pm, TCGv_i64 pg) | ||
170 | @@ -XXX,XX +XXX,XX @@ static bool trans_ORN_pppp(DisasContext *s, arg_rprr_s *a) | ||
171 | .fno = gen_helper_sve_orn_pppp, | ||
172 | .prefer_i64 = TCG_TARGET_REG_BITS == 64, | ||
173 | }; | ||
174 | - if (a->s) { | ||
175 | - return do_pppp_flags(s, a, &op); | ||
176 | - } else { | ||
177 | - return do_vecop4_p(s, &op, a->rd, a->rn, a->rm, a->pg); | ||
178 | - } | ||
179 | + return do_pppp_flags(s, a, &op); | ||
180 | } | ||
181 | |||
182 | static void gen_nor_pg_i64(TCGv_i64 pd, TCGv_i64 pn, TCGv_i64 pm, TCGv_i64 pg) | ||
183 | @@ -XXX,XX +XXX,XX @@ static bool trans_NOR_pppp(DisasContext *s, arg_rprr_s *a) | ||
184 | .fno = gen_helper_sve_nor_pppp, | ||
185 | .prefer_i64 = TCG_TARGET_REG_BITS == 64, | ||
186 | }; | ||
187 | - if (a->s) { | ||
188 | - return do_pppp_flags(s, a, &op); | ||
189 | - } else { | ||
190 | - return do_vecop4_p(s, &op, a->rd, a->rn, a->rm, a->pg); | ||
191 | - } | ||
192 | + return do_pppp_flags(s, a, &op); | ||
193 | } | ||
194 | |||
195 | static void gen_nand_pg_i64(TCGv_i64 pd, TCGv_i64 pn, TCGv_i64 pm, TCGv_i64 pg) | ||
196 | @@ -XXX,XX +XXX,XX @@ static bool trans_NAND_pppp(DisasContext *s, arg_rprr_s *a) | ||
197 | .fno = gen_helper_sve_nand_pppp, | ||
198 | .prefer_i64 = TCG_TARGET_REG_BITS == 64, | ||
199 | }; | ||
200 | - if (a->s) { | ||
201 | - return do_pppp_flags(s, a, &op); | ||
202 | - } else { | ||
203 | - return do_vecop4_p(s, &op, a->rd, a->rn, a->rm, a->pg); | ||
204 | - } | ||
205 | + return do_pppp_flags(s, a, &op); | ||
206 | } | ||
207 | |||
208 | /* | ||
209 | -- | ||
210 | 2.20.1 | ||
211 | |||
212 | diff view generated by jsdifflib |
1 | As part of plumbing MemTxAttrs down to the IOMMU translate method, | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | add MemTxAttrs as an argument to address_space_map(). | ||
3 | Its callers either have an attrs value to hand, or don't care | ||
4 | and can use MEMTXATTRS_UNSPECIFIED. | ||
5 | 2 | ||
3 | The gvec operation was added after the initial implementation | ||
4 | of the SEL instruction and was missed in the conversion. | ||
5 | |||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Message-id: 20200815013145.539409-8-richard.henderson@linaro.org | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20180521140402.23318-5-peter.maydell@linaro.org | ||
10 | --- | 10 | --- |
11 | include/exec/memory.h | 3 ++- | 11 | target/arm/translate-sve.c | 31 ++++++++----------------------- |
12 | include/sysemu/dma.h | 3 ++- | 12 | 1 file changed, 8 insertions(+), 23 deletions(-) |
13 | exec.c | 6 ++++-- | ||
14 | target/ppc/mmu-hash64.c | 3 ++- | ||
15 | 4 files changed, 10 insertions(+), 5 deletions(-) | ||
16 | 13 | ||
17 | diff --git a/include/exec/memory.h b/include/exec/memory.h | 14 | diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c |
18 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/include/exec/memory.h | 16 | --- a/target/arm/translate-sve.c |
20 | +++ b/include/exec/memory.h | 17 | +++ b/target/arm/translate-sve.c |
21 | @@ -XXX,XX +XXX,XX @@ bool address_space_access_valid(AddressSpace *as, hwaddr addr, int len, bool is_ | 18 | @@ -XXX,XX +XXX,XX @@ static bool trans_EOR_pppp(DisasContext *s, arg_rprr_s *a) |
22 | * @addr: address within that address space | 19 | return do_pppp_flags(s, a, &op); |
23 | * @plen: pointer to length of buffer; updated on return | ||
24 | * @is_write: indicates the transfer direction | ||
25 | + * @attrs: memory attributes | ||
26 | */ | ||
27 | void *address_space_map(AddressSpace *as, hwaddr addr, | ||
28 | - hwaddr *plen, bool is_write); | ||
29 | + hwaddr *plen, bool is_write, MemTxAttrs attrs); | ||
30 | |||
31 | /* address_space_unmap: Unmaps a memory region previously mapped by address_space_map() | ||
32 | * | ||
33 | diff --git a/include/sysemu/dma.h b/include/sysemu/dma.h | ||
34 | index XXXXXXX..XXXXXXX 100644 | ||
35 | --- a/include/sysemu/dma.h | ||
36 | +++ b/include/sysemu/dma.h | ||
37 | @@ -XXX,XX +XXX,XX @@ static inline void *dma_memory_map(AddressSpace *as, | ||
38 | hwaddr xlen = *len; | ||
39 | void *p; | ||
40 | |||
41 | - p = address_space_map(as, addr, &xlen, dir == DMA_DIRECTION_FROM_DEVICE); | ||
42 | + p = address_space_map(as, addr, &xlen, dir == DMA_DIRECTION_FROM_DEVICE, | ||
43 | + MEMTXATTRS_UNSPECIFIED); | ||
44 | *len = xlen; | ||
45 | return p; | ||
46 | } | 20 | } |
47 | diff --git a/exec.c b/exec.c | 21 | |
48 | index XXXXXXX..XXXXXXX 100644 | 22 | -static void gen_sel_pg_i64(TCGv_i64 pd, TCGv_i64 pn, TCGv_i64 pm, TCGv_i64 pg) |
49 | --- a/exec.c | 23 | -{ |
50 | +++ b/exec.c | 24 | - tcg_gen_and_i64(pn, pn, pg); |
51 | @@ -XXX,XX +XXX,XX @@ flatview_extend_translation(FlatView *fv, hwaddr addr, | 25 | - tcg_gen_andc_i64(pm, pm, pg); |
52 | void *address_space_map(AddressSpace *as, | 26 | - tcg_gen_or_i64(pd, pn, pm); |
53 | hwaddr addr, | 27 | -} |
54 | hwaddr *plen, | 28 | - |
55 | - bool is_write) | 29 | -static void gen_sel_pg_vec(unsigned vece, TCGv_vec pd, TCGv_vec pn, |
56 | + bool is_write, | 30 | - TCGv_vec pm, TCGv_vec pg) |
57 | + MemTxAttrs attrs) | 31 | -{ |
32 | - tcg_gen_and_vec(vece, pn, pn, pg); | ||
33 | - tcg_gen_andc_vec(vece, pm, pm, pg); | ||
34 | - tcg_gen_or_vec(vece, pd, pn, pm); | ||
35 | -} | ||
36 | - | ||
37 | static bool trans_SEL_pppp(DisasContext *s, arg_rprr_s *a) | ||
58 | { | 38 | { |
59 | hwaddr len = *plen; | 39 | - static const GVecGen4 op = { |
60 | hwaddr l, xlat; | 40 | - .fni8 = gen_sel_pg_i64, |
61 | @@ -XXX,XX +XXX,XX @@ void *cpu_physical_memory_map(hwaddr addr, | 41 | - .fniv = gen_sel_pg_vec, |
62 | hwaddr *plen, | 42 | - .fno = gen_helper_sve_sel_pppp, |
63 | int is_write) | 43 | - .prefer_i64 = TCG_TARGET_REG_BITS == 64, |
64 | { | 44 | - }; |
65 | - return address_space_map(&address_space_memory, addr, plen, is_write); | 45 | - |
66 | + return address_space_map(&address_space_memory, addr, plen, is_write, | 46 | if (a->s) { |
67 | + MEMTXATTRS_UNSPECIFIED); | 47 | return false; |
48 | } | ||
49 | - return do_pppp_flags(s, a, &op); | ||
50 | + if (sve_access_check(s)) { | ||
51 | + unsigned psz = pred_gvec_reg_size(s); | ||
52 | + tcg_gen_gvec_bitsel(MO_8, pred_full_reg_offset(s, a->rd), | ||
53 | + pred_full_reg_offset(s, a->pg), | ||
54 | + pred_full_reg_offset(s, a->rn), | ||
55 | + pred_full_reg_offset(s, a->rm), psz, psz); | ||
56 | + } | ||
57 | + return true; | ||
68 | } | 58 | } |
69 | 59 | ||
70 | void cpu_physical_memory_unmap(void *buffer, hwaddr len, | 60 | static void gen_orr_pg_i64(TCGv_i64 pd, TCGv_i64 pn, TCGv_i64 pm, TCGv_i64 pg) |
71 | diff --git a/target/ppc/mmu-hash64.c b/target/ppc/mmu-hash64.c | ||
72 | index XXXXXXX..XXXXXXX 100644 | ||
73 | --- a/target/ppc/mmu-hash64.c | ||
74 | +++ b/target/ppc/mmu-hash64.c | ||
75 | @@ -XXX,XX +XXX,XX @@ const ppc_hash_pte64_t *ppc_hash64_map_hptes(PowerPCCPU *cpu, | ||
76 | return NULL; | ||
77 | } | ||
78 | |||
79 | - hptes = address_space_map(CPU(cpu)->as, base + pte_offset, &plen, false); | ||
80 | + hptes = address_space_map(CPU(cpu)->as, base + pte_offset, &plen, false, | ||
81 | + MEMTXATTRS_UNSPECIFIED); | ||
82 | if (plen < (n * HASH_PTE_SIZE_64)) { | ||
83 | hw_error("%s: Unable to map all requested HPTEs\n", __func__); | ||
84 | } | ||
85 | -- | 61 | -- |
86 | 2.17.1 | 62 | 2.20.1 |
87 | 63 | ||
88 | 64 | diff view generated by jsdifflib |
1 | As part of plumbing MemTxAttrs down to the IOMMU translate method, | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | add MemTxAttrs as an argument to memory_region_access_valid(). | ||
3 | Its callers either have an attrs value to hand, or don't care | ||
4 | and can use MEMTXATTRS_UNSPECIFIED. | ||
5 | 2 | ||
6 | The callsite in flatview_access_valid() is part of a recursive | 3 | Model after gen_gvec_fn_zzz et al. |
7 | loop flatview_access_valid() -> memory_region_access_valid() -> | ||
8 | subpage_accepts() -> flatview_access_valid(); we make it pass | ||
9 | MEMTXATTRS_UNSPECIFIED for now, until the next several commits | ||
10 | have plumbed an attrs parameter through the rest of the loop | ||
11 | and we can add an attrs parameter to flatview_access_valid(). | ||
12 | 4 | ||
5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Message-id: 20200815013145.539409-9-richard.henderson@linaro.org | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
15 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
16 | Message-id: 20180521140402.23318-8-peter.maydell@linaro.org | ||
17 | --- | 9 | --- |
18 | include/exec/memory-internal.h | 3 ++- | 10 | target/arm/translate-sve.c | 35 ++++++++++++++++------------------- |
19 | exec.c | 4 +++- | 11 | 1 file changed, 16 insertions(+), 19 deletions(-) |
20 | hw/s390x/s390-pci-inst.c | 3 ++- | ||
21 | memory.c | 7 ++++--- | ||
22 | 4 files changed, 11 insertions(+), 6 deletions(-) | ||
23 | 12 | ||
24 | diff --git a/include/exec/memory-internal.h b/include/exec/memory-internal.h | 13 | diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c |
25 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
26 | --- a/include/exec/memory-internal.h | 15 | --- a/target/arm/translate-sve.c |
27 | +++ b/include/exec/memory-internal.h | 16 | +++ b/target/arm/translate-sve.c |
28 | @@ -XXX,XX +XXX,XX @@ void flatview_unref(FlatView *view); | 17 | @@ -XXX,XX +XXX,XX @@ static int pred_gvec_reg_size(DisasContext *s) |
29 | extern const MemoryRegionOps unassigned_mem_ops; | 18 | return size_for_gvec(pred_full_reg_size(s)); |
30 | 19 | } | |
31 | bool memory_region_access_valid(MemoryRegion *mr, hwaddr addr, | 20 | |
32 | - unsigned size, bool is_write); | 21 | -/* Invoke a vector expander on two Zregs. */ |
33 | + unsigned size, bool is_write, | 22 | +/* Invoke an out-of-line helper on 3 Zregs and a predicate. */ |
34 | + MemTxAttrs attrs); | 23 | +static void gen_gvec_ool_zzzp(DisasContext *s, gen_helper_gvec_4 *fn, |
35 | 24 | + int rd, int rn, int rm, int pg, int data) | |
36 | void flatview_add_to_dispatch(FlatView *fv, MemoryRegionSection *section); | 25 | +{ |
37 | AddressSpaceDispatch *address_space_dispatch_new(FlatView *fv); | 26 | + unsigned vsz = vec_full_reg_size(s); |
38 | diff --git a/exec.c b/exec.c | 27 | + tcg_gen_gvec_4_ool(vec_full_reg_offset(s, rd), |
39 | index XXXXXXX..XXXXXXX 100644 | 28 | + vec_full_reg_offset(s, rn), |
40 | --- a/exec.c | 29 | + vec_full_reg_offset(s, rm), |
41 | +++ b/exec.c | 30 | + pred_full_reg_offset(s, pg), |
42 | @@ -XXX,XX +XXX,XX @@ static bool flatview_access_valid(FlatView *fv, hwaddr addr, int len, | 31 | + vsz, vsz, data, fn); |
43 | mr = flatview_translate(fv, addr, &xlat, &l, is_write); | 32 | +} |
44 | if (!memory_access_is_direct(mr, is_write)) { | 33 | |
45 | l = memory_access_size(mr, l, addr); | 34 | +/* Invoke a vector expander on two Zregs. */ |
46 | - if (!memory_region_access_valid(mr, xlat, l, is_write)) { | 35 | static void gen_gvec_fn_zz(DisasContext *s, GVecGen2Fn *gvec_fn, |
47 | + /* When our callers all have attrs we'll pass them through here */ | 36 | int esz, int rd, int rn) |
48 | + if (!memory_region_access_valid(mr, xlat, l, is_write, | 37 | { |
49 | + MEMTXATTRS_UNSPECIFIED)) { | 38 | @@ -XXX,XX +XXX,XX @@ static bool trans_UQSUB_zzz(DisasContext *s, arg_rrr_esz *a) |
50 | return false; | 39 | |
51 | } | 40 | static bool do_zpzz_ool(DisasContext *s, arg_rprr_esz *a, gen_helper_gvec_4 *fn) |
52 | } | 41 | { |
53 | diff --git a/hw/s390x/s390-pci-inst.c b/hw/s390x/s390-pci-inst.c | 42 | - unsigned vsz = vec_full_reg_size(s); |
54 | index XXXXXXX..XXXXXXX 100644 | 43 | if (fn == NULL) { |
55 | --- a/hw/s390x/s390-pci-inst.c | 44 | return false; |
56 | +++ b/hw/s390x/s390-pci-inst.c | ||
57 | @@ -XXX,XX +XXX,XX @@ int pcistb_service_call(S390CPU *cpu, uint8_t r1, uint8_t r3, uint64_t gaddr, | ||
58 | mr = s390_get_subregion(mr, offset, len); | ||
59 | offset -= mr->addr; | ||
60 | |||
61 | - if (!memory_region_access_valid(mr, offset, len, true)) { | ||
62 | + if (!memory_region_access_valid(mr, offset, len, true, | ||
63 | + MEMTXATTRS_UNSPECIFIED)) { | ||
64 | s390_program_interrupt(env, PGM_OPERAND, 6, ra); | ||
65 | return 0; | ||
66 | } | 45 | } |
67 | diff --git a/memory.c b/memory.c | 46 | if (sve_access_check(s)) { |
68 | index XXXXXXX..XXXXXXX 100644 | 47 | - tcg_gen_gvec_4_ool(vec_full_reg_offset(s, a->rd), |
69 | --- a/memory.c | 48 | - vec_full_reg_offset(s, a->rn), |
70 | +++ b/memory.c | 49 | - vec_full_reg_offset(s, a->rm), |
71 | @@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps ram_device_mem_ops = { | 50 | - pred_full_reg_offset(s, a->pg), |
72 | bool memory_region_access_valid(MemoryRegion *mr, | 51 | - vsz, vsz, 0, fn); |
73 | hwaddr addr, | 52 | + gen_gvec_ool_zzzp(s, fn, a->rd, a->rn, a->rm, a->pg, 0); |
74 | unsigned size, | 53 | } |
75 | - bool is_write) | 54 | return true; |
76 | + bool is_write, | 55 | } |
77 | + MemTxAttrs attrs) | 56 | @@ -XXX,XX +XXX,XX @@ static void do_sel_z(DisasContext *s, int rd, int rn, int rm, int pg, int esz) |
57 | gen_helper_sve_sel_zpzz_b, gen_helper_sve_sel_zpzz_h, | ||
58 | gen_helper_sve_sel_zpzz_s, gen_helper_sve_sel_zpzz_d | ||
59 | }; | ||
60 | - unsigned vsz = vec_full_reg_size(s); | ||
61 | - tcg_gen_gvec_4_ool(vec_full_reg_offset(s, rd), | ||
62 | - vec_full_reg_offset(s, rn), | ||
63 | - vec_full_reg_offset(s, rm), | ||
64 | - pred_full_reg_offset(s, pg), | ||
65 | - vsz, vsz, 0, fns[esz]); | ||
66 | + gen_gvec_ool_zzzp(s, fns[esz], rd, rn, rm, pg, 0); | ||
67 | } | ||
68 | |||
69 | #define DO_ZPZZ(NAME, name) \ | ||
70 | @@ -XXX,XX +XXX,XX @@ static bool trans_RBIT(DisasContext *s, arg_rpr_esz *a) | ||
71 | static bool trans_SPLICE(DisasContext *s, arg_rprr_esz *a) | ||
78 | { | 72 | { |
79 | int access_size_min, access_size_max; | 73 | if (sve_access_check(s)) { |
80 | int access_size, i; | 74 | - unsigned vsz = vec_full_reg_size(s); |
81 | @@ -XXX,XX +XXX,XX @@ MemTxResult memory_region_dispatch_read(MemoryRegion *mr, | 75 | - tcg_gen_gvec_4_ool(vec_full_reg_offset(s, a->rd), |
82 | { | 76 | - vec_full_reg_offset(s, a->rn), |
83 | MemTxResult r; | 77 | - vec_full_reg_offset(s, a->rm), |
84 | 78 | - pred_full_reg_offset(s, a->pg), | |
85 | - if (!memory_region_access_valid(mr, addr, size, false)) { | 79 | - vsz, vsz, a->esz, gen_helper_sve_splice); |
86 | + if (!memory_region_access_valid(mr, addr, size, false, attrs)) { | 80 | + gen_gvec_ool_zzzp(s, gen_helper_sve_splice, |
87 | *pval = unassigned_mem_read(mr, addr, size); | 81 | + a->rd, a->rn, a->rm, a->pg, 0); |
88 | return MEMTX_DECODE_ERROR; | ||
89 | } | 82 | } |
90 | @@ -XXX,XX +XXX,XX @@ MemTxResult memory_region_dispatch_write(MemoryRegion *mr, | 83 | return true; |
91 | unsigned size, | 84 | } |
92 | MemTxAttrs attrs) | ||
93 | { | ||
94 | - if (!memory_region_access_valid(mr, addr, size, true)) { | ||
95 | + if (!memory_region_access_valid(mr, addr, size, true, attrs)) { | ||
96 | unassigned_mem_write(mr, addr, data, size); | ||
97 | return MEMTX_DECODE_ERROR; | ||
98 | } | ||
99 | -- | 85 | -- |
100 | 2.17.1 | 86 | 2.20.1 |
101 | 87 | ||
102 | 88 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | 1 | From: Richard Henderson <richard.henderson@linaro.org> | |
2 | |||
3 | The existing clr functions have only one vector argument, and so | ||
4 | can only clear in place. The existing movz functions have two | ||
5 | vector arguments, and so can clear while moving. Merge them, with | ||
6 | a flag that controls the sense of active vs inactive elements | ||
7 | being cleared. | ||
8 | |||
9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | Message-id: 20200815013145.539409-10-richard.henderson@linaro.org | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | --- | ||
14 | target/arm/helper-sve.h | 5 --- | ||
15 | target/arm/sve_helper.c | 70 ++++++++------------------------------ | ||
16 | target/arm/translate-sve.c | 53 +++++++++++------------------ | ||
17 | 3 files changed, 34 insertions(+), 94 deletions(-) | ||
18 | |||
19 | diff --git a/target/arm/helper-sve.h b/target/arm/helper-sve.h | ||
20 | index XXXXXXX..XXXXXXX 100644 | ||
21 | --- a/target/arm/helper-sve.h | ||
22 | +++ b/target/arm/helper-sve.h | ||
23 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(sve_uminv_h, TCG_CALL_NO_RWG, i64, ptr, ptr, i32) | ||
24 | DEF_HELPER_FLAGS_3(sve_uminv_s, TCG_CALL_NO_RWG, i64, ptr, ptr, i32) | ||
25 | DEF_HELPER_FLAGS_3(sve_uminv_d, TCG_CALL_NO_RWG, i64, ptr, ptr, i32) | ||
26 | |||
27 | -DEF_HELPER_FLAGS_3(sve_clr_b, TCG_CALL_NO_RWG, void, ptr, ptr, i32) | ||
28 | -DEF_HELPER_FLAGS_3(sve_clr_h, TCG_CALL_NO_RWG, void, ptr, ptr, i32) | ||
29 | -DEF_HELPER_FLAGS_3(sve_clr_s, TCG_CALL_NO_RWG, void, ptr, ptr, i32) | ||
30 | -DEF_HELPER_FLAGS_3(sve_clr_d, TCG_CALL_NO_RWG, void, ptr, ptr, i32) | ||
31 | - | ||
32 | DEF_HELPER_FLAGS_4(sve_movz_b, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | ||
33 | DEF_HELPER_FLAGS_4(sve_movz_h, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | ||
34 | DEF_HELPER_FLAGS_4(sve_movz_s, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | ||
35 | diff --git a/target/arm/sve_helper.c b/target/arm/sve_helper.c | ||
36 | index XXXXXXX..XXXXXXX 100644 | ||
37 | --- a/target/arm/sve_helper.c | ||
38 | +++ b/target/arm/sve_helper.c | ||
39 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(sve_pnext)(void *vd, void *vg, uint32_t pred_desc) | ||
40 | return flags; | ||
41 | } | ||
42 | |||
43 | -/* Store zero into every active element of Zd. We will use this for two | ||
44 | - * and three-operand predicated instructions for which logic dictates a | ||
45 | - * zero result. In particular, logical shift by element size, which is | ||
46 | - * otherwise undefined on the host. | ||
47 | - * | ||
48 | - * For element sizes smaller than uint64_t, we use tables to expand | ||
49 | - * the N bits of the controlling predicate to a byte mask, and clear | ||
50 | - * those bytes. | ||
51 | +/* | ||
52 | + * Copy Zn into Zd, and store zero into inactive elements. | ||
53 | + * If inv, store zeros into the active elements. | ||
54 | */ | ||
55 | -void HELPER(sve_clr_b)(void *vd, void *vg, uint32_t desc) | ||
56 | -{ | ||
57 | - intptr_t i, opr_sz = simd_oprsz(desc) / 8; | ||
58 | - uint64_t *d = vd; | ||
59 | - uint8_t *pg = vg; | ||
60 | - for (i = 0; i < opr_sz; i += 1) { | ||
61 | - d[i] &= ~expand_pred_b(pg[H1(i)]); | ||
62 | - } | ||
63 | -} | ||
64 | - | ||
65 | -void HELPER(sve_clr_h)(void *vd, void *vg, uint32_t desc) | ||
66 | -{ | ||
67 | - intptr_t i, opr_sz = simd_oprsz(desc) / 8; | ||
68 | - uint64_t *d = vd; | ||
69 | - uint8_t *pg = vg; | ||
70 | - for (i = 0; i < opr_sz; i += 1) { | ||
71 | - d[i] &= ~expand_pred_h(pg[H1(i)]); | ||
72 | - } | ||
73 | -} | ||
74 | - | ||
75 | -void HELPER(sve_clr_s)(void *vd, void *vg, uint32_t desc) | ||
76 | -{ | ||
77 | - intptr_t i, opr_sz = simd_oprsz(desc) / 8; | ||
78 | - uint64_t *d = vd; | ||
79 | - uint8_t *pg = vg; | ||
80 | - for (i = 0; i < opr_sz; i += 1) { | ||
81 | - d[i] &= ~expand_pred_s(pg[H1(i)]); | ||
82 | - } | ||
83 | -} | ||
84 | - | ||
85 | -void HELPER(sve_clr_d)(void *vd, void *vg, uint32_t desc) | ||
86 | -{ | ||
87 | - intptr_t i, opr_sz = simd_oprsz(desc) / 8; | ||
88 | - uint64_t *d = vd; | ||
89 | - uint8_t *pg = vg; | ||
90 | - for (i = 0; i < opr_sz; i += 1) { | ||
91 | - if (pg[H1(i)] & 1) { | ||
92 | - d[i] = 0; | ||
93 | - } | ||
94 | - } | ||
95 | -} | ||
96 | - | ||
97 | -/* Copy Zn into Zd, and store zero into inactive elements. */ | ||
98 | void HELPER(sve_movz_b)(void *vd, void *vn, void *vg, uint32_t desc) | ||
99 | { | ||
100 | intptr_t i, opr_sz = simd_oprsz(desc) / 8; | ||
101 | + uint64_t inv = -(uint64_t)(simd_data(desc) & 1); | ||
102 | uint64_t *d = vd, *n = vn; | ||
103 | uint8_t *pg = vg; | ||
104 | + | ||
105 | for (i = 0; i < opr_sz; i += 1) { | ||
106 | - d[i] = n[i] & expand_pred_b(pg[H1(i)]); | ||
107 | + d[i] = n[i] & (expand_pred_b(pg[H1(i)]) ^ inv); | ||
108 | } | ||
109 | } | ||
110 | |||
111 | void HELPER(sve_movz_h)(void *vd, void *vn, void *vg, uint32_t desc) | ||
112 | { | ||
113 | intptr_t i, opr_sz = simd_oprsz(desc) / 8; | ||
114 | + uint64_t inv = -(uint64_t)(simd_data(desc) & 1); | ||
115 | uint64_t *d = vd, *n = vn; | ||
116 | uint8_t *pg = vg; | ||
117 | + | ||
118 | for (i = 0; i < opr_sz; i += 1) { | ||
119 | - d[i] = n[i] & expand_pred_h(pg[H1(i)]); | ||
120 | + d[i] = n[i] & (expand_pred_h(pg[H1(i)]) ^ inv); | ||
121 | } | ||
122 | } | ||
123 | |||
124 | void HELPER(sve_movz_s)(void *vd, void *vn, void *vg, uint32_t desc) | ||
125 | { | ||
126 | intptr_t i, opr_sz = simd_oprsz(desc) / 8; | ||
127 | + uint64_t inv = -(uint64_t)(simd_data(desc) & 1); | ||
128 | uint64_t *d = vd, *n = vn; | ||
129 | uint8_t *pg = vg; | ||
130 | + | ||
131 | for (i = 0; i < opr_sz; i += 1) { | ||
132 | - d[i] = n[i] & expand_pred_s(pg[H1(i)]); | ||
133 | + d[i] = n[i] & (expand_pred_s(pg[H1(i)]) ^ inv); | ||
134 | } | ||
135 | } | ||
136 | |||
137 | @@ -XXX,XX +XXX,XX @@ void HELPER(sve_movz_d)(void *vd, void *vn, void *vg, uint32_t desc) | ||
138 | intptr_t i, opr_sz = simd_oprsz(desc) / 8; | ||
139 | uint64_t *d = vd, *n = vn; | ||
140 | uint8_t *pg = vg; | ||
141 | + uint8_t inv = simd_data(desc); | ||
142 | + | ||
143 | for (i = 0; i < opr_sz; i += 1) { | ||
144 | - d[i] = n[i] & -(uint64_t)(pg[H1(i)] & 1); | ||
145 | + d[i] = n[i] & -(uint64_t)((pg[H1(i)] ^ inv) & 1); | ||
146 | } | ||
147 | } | ||
148 | |||
149 | diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c | ||
150 | index XXXXXXX..XXXXXXX 100644 | ||
151 | --- a/target/arm/translate-sve.c | ||
152 | +++ b/target/arm/translate-sve.c | ||
153 | @@ -XXX,XX +XXX,XX @@ static bool trans_SADDV(DisasContext *s, arg_rpr_esz *a) | ||
154 | *** SVE Shift by Immediate - Predicated Group | ||
155 | */ | ||
156 | |||
157 | -/* Store zero into every active element of Zd. We will use this for two | ||
158 | - * and three-operand predicated instructions for which logic dictates a | ||
159 | - * zero result. | ||
160 | +/* | ||
161 | + * Copy Zn into Zd, storing zeros into inactive elements. | ||
162 | + * If invert, store zeros into the active elements. | ||
163 | */ | ||
164 | -static bool do_clr_zp(DisasContext *s, int rd, int pg, int esz) | ||
165 | -{ | ||
166 | - static gen_helper_gvec_2 * const fns[4] = { | ||
167 | - gen_helper_sve_clr_b, gen_helper_sve_clr_h, | ||
168 | - gen_helper_sve_clr_s, gen_helper_sve_clr_d, | ||
169 | - }; | ||
170 | - if (sve_access_check(s)) { | ||
171 | - unsigned vsz = vec_full_reg_size(s); | ||
172 | - tcg_gen_gvec_2_ool(vec_full_reg_offset(s, rd), | ||
173 | - pred_full_reg_offset(s, pg), | ||
174 | - vsz, vsz, 0, fns[esz]); | ||
175 | - } | ||
176 | - return true; | ||
177 | -} | ||
178 | - | ||
179 | -/* Copy Zn into Zd, storing zeros into inactive elements. */ | ||
180 | -static void do_movz_zpz(DisasContext *s, int rd, int rn, int pg, int esz) | ||
181 | +static bool do_movz_zpz(DisasContext *s, int rd, int rn, int pg, | ||
182 | + int esz, bool invert) | ||
183 | { | ||
184 | static gen_helper_gvec_3 * const fns[4] = { | ||
185 | gen_helper_sve_movz_b, gen_helper_sve_movz_h, | ||
186 | gen_helper_sve_movz_s, gen_helper_sve_movz_d, | ||
187 | }; | ||
188 | - unsigned vsz = vec_full_reg_size(s); | ||
189 | - tcg_gen_gvec_3_ool(vec_full_reg_offset(s, rd), | ||
190 | - vec_full_reg_offset(s, rn), | ||
191 | - pred_full_reg_offset(s, pg), | ||
192 | - vsz, vsz, 0, fns[esz]); | ||
193 | + | ||
194 | + if (sve_access_check(s)) { | ||
195 | + unsigned vsz = vec_full_reg_size(s); | ||
196 | + tcg_gen_gvec_3_ool(vec_full_reg_offset(s, rd), | ||
197 | + vec_full_reg_offset(s, rn), | ||
198 | + pred_full_reg_offset(s, pg), | ||
199 | + vsz, vsz, invert, fns[esz]); | ||
200 | + } | ||
201 | + return true; | ||
202 | } | ||
203 | |||
204 | static bool do_zpzi_ool(DisasContext *s, arg_rpri_esz *a, | ||
205 | @@ -XXX,XX +XXX,XX @@ static bool trans_LSR_zpzi(DisasContext *s, arg_rpri_esz *a) | ||
206 | /* Shift by element size is architecturally valid. | ||
207 | For logical shifts, it is a zeroing operation. */ | ||
208 | if (a->imm >= (8 << a->esz)) { | ||
209 | - return do_clr_zp(s, a->rd, a->pg, a->esz); | ||
210 | + return do_movz_zpz(s, a->rd, a->rd, a->pg, a->esz, true); | ||
211 | } else { | ||
212 | return do_zpzi_ool(s, a, fns[a->esz]); | ||
213 | } | ||
214 | @@ -XXX,XX +XXX,XX @@ static bool trans_LSL_zpzi(DisasContext *s, arg_rpri_esz *a) | ||
215 | /* Shift by element size is architecturally valid. | ||
216 | For logical shifts, it is a zeroing operation. */ | ||
217 | if (a->imm >= (8 << a->esz)) { | ||
218 | - return do_clr_zp(s, a->rd, a->pg, a->esz); | ||
219 | + return do_movz_zpz(s, a->rd, a->rd, a->pg, a->esz, true); | ||
220 | } else { | ||
221 | return do_zpzi_ool(s, a, fns[a->esz]); | ||
222 | } | ||
223 | @@ -XXX,XX +XXX,XX @@ static bool trans_ASRD(DisasContext *s, arg_rpri_esz *a) | ||
224 | /* Shift by element size is architecturally valid. For arithmetic | ||
225 | right shift for division, it is a zeroing operation. */ | ||
226 | if (a->imm >= (8 << a->esz)) { | ||
227 | - return do_clr_zp(s, a->rd, a->pg, a->esz); | ||
228 | + return do_movz_zpz(s, a->rd, a->rd, a->pg, a->esz, true); | ||
229 | } else { | ||
230 | return do_zpzi_ool(s, a, fns[a->esz]); | ||
231 | } | ||
232 | @@ -XXX,XX +XXX,XX @@ static bool trans_LD1R_zpri(DisasContext *s, arg_rpri_load *a) | ||
233 | |||
234 | /* Zero the inactive elements. */ | ||
235 | gen_set_label(over); | ||
236 | - do_movz_zpz(s, a->rd, a->rd, a->pg, esz); | ||
237 | - return true; | ||
238 | + return do_movz_zpz(s, a->rd, a->rd, a->pg, esz, false); | ||
239 | } | ||
240 | |||
241 | static void do_st_zpa(DisasContext *s, int zt, int pg, TCGv_i64 addr, | ||
242 | @@ -XXX,XX +XXX,XX @@ static bool trans_MOVPRFX_m(DisasContext *s, arg_rpr_esz *a) | ||
243 | |||
244 | static bool trans_MOVPRFX_z(DisasContext *s, arg_rpr_esz *a) | ||
245 | { | ||
246 | - if (sve_access_check(s)) { | ||
247 | - do_movz_zpz(s, a->rd, a->rn, a->pg, a->esz); | ||
248 | - } | ||
249 | - return true; | ||
250 | + return do_movz_zpz(s, a->rd, a->rn, a->pg, a->esz, false); | ||
251 | } | ||
252 | -- | ||
253 | 2.20.1 | ||
254 | |||
255 | diff view generated by jsdifflib |
1 | As part of plumbing MemTxAttrs down to the IOMMU translate method, | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | add MemTxAttrs as an argument to flatview_extend_translation(). | ||
3 | Its callers either have an attrs value to hand, or don't care | ||
4 | and can use MEMTXATTRS_UNSPECIFIED. | ||
5 | 2 | ||
3 | Model after gen_gvec_fn_zzz et al. | ||
4 | |||
5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Message-id: 20200815013145.539409-11-richard.henderson@linaro.org | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20180521140402.23318-7-peter.maydell@linaro.org | ||
10 | --- | 9 | --- |
11 | exec.c | 15 ++++++++++----- | 10 | target/arm/translate-sve.c | 29 ++++++++++++++--------------- |
12 | 1 file changed, 10 insertions(+), 5 deletions(-) | 11 | 1 file changed, 14 insertions(+), 15 deletions(-) |
13 | 12 | ||
14 | diff --git a/exec.c b/exec.c | 13 | diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c |
15 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/exec.c | 15 | --- a/target/arm/translate-sve.c |
17 | +++ b/exec.c | 16 | +++ b/target/arm/translate-sve.c |
18 | @@ -XXX,XX +XXX,XX @@ bool address_space_access_valid(AddressSpace *as, hwaddr addr, | 17 | @@ -XXX,XX +XXX,XX @@ static int pred_gvec_reg_size(DisasContext *s) |
19 | 18 | return size_for_gvec(pred_full_reg_size(s)); | |
20 | static hwaddr | 19 | } |
21 | flatview_extend_translation(FlatView *fv, hwaddr addr, | 20 | |
22 | - hwaddr target_len, | 21 | +/* Invoke an out-of-line helper on 2 Zregs and a predicate. */ |
23 | - MemoryRegion *mr, hwaddr base, hwaddr len, | 22 | +static void gen_gvec_ool_zzp(DisasContext *s, gen_helper_gvec_3 *fn, |
24 | - bool is_write) | 23 | + int rd, int rn, int pg, int data) |
25 | + hwaddr target_len, | 24 | +{ |
26 | + MemoryRegion *mr, hwaddr base, hwaddr len, | 25 | + unsigned vsz = vec_full_reg_size(s); |
27 | + bool is_write, MemTxAttrs attrs) | 26 | + tcg_gen_gvec_3_ool(vec_full_reg_offset(s, rd), |
27 | + vec_full_reg_offset(s, rn), | ||
28 | + pred_full_reg_offset(s, pg), | ||
29 | + vsz, vsz, data, fn); | ||
30 | +} | ||
31 | + | ||
32 | /* Invoke an out-of-line helper on 3 Zregs and a predicate. */ | ||
33 | static void gen_gvec_ool_zzzp(DisasContext *s, gen_helper_gvec_4 *fn, | ||
34 | int rd, int rn, int rm, int pg, int data) | ||
35 | @@ -XXX,XX +XXX,XX @@ static bool do_zpz_ool(DisasContext *s, arg_rpr_esz *a, gen_helper_gvec_3 *fn) | ||
36 | return false; | ||
37 | } | ||
38 | if (sve_access_check(s)) { | ||
39 | - unsigned vsz = vec_full_reg_size(s); | ||
40 | - tcg_gen_gvec_3_ool(vec_full_reg_offset(s, a->rd), | ||
41 | - vec_full_reg_offset(s, a->rn), | ||
42 | - pred_full_reg_offset(s, a->pg), | ||
43 | - vsz, vsz, 0, fn); | ||
44 | + gen_gvec_ool_zzp(s, fn, a->rd, a->rn, a->pg, 0); | ||
45 | } | ||
46 | return true; | ||
47 | } | ||
48 | @@ -XXX,XX +XXX,XX @@ static bool do_movz_zpz(DisasContext *s, int rd, int rn, int pg, | ||
49 | }; | ||
50 | |||
51 | if (sve_access_check(s)) { | ||
52 | - unsigned vsz = vec_full_reg_size(s); | ||
53 | - tcg_gen_gvec_3_ool(vec_full_reg_offset(s, rd), | ||
54 | - vec_full_reg_offset(s, rn), | ||
55 | - pred_full_reg_offset(s, pg), | ||
56 | - vsz, vsz, invert, fns[esz]); | ||
57 | + gen_gvec_ool_zzp(s, fns[esz], rd, rn, pg, invert); | ||
58 | } | ||
59 | return true; | ||
60 | } | ||
61 | @@ -XXX,XX +XXX,XX @@ static bool do_zpzi_ool(DisasContext *s, arg_rpri_esz *a, | ||
62 | gen_helper_gvec_3 *fn) | ||
28 | { | 63 | { |
29 | hwaddr done = 0; | 64 | if (sve_access_check(s)) { |
30 | hwaddr xlat; | 65 | - unsigned vsz = vec_full_reg_size(s); |
31 | @@ -XXX,XX +XXX,XX @@ void *address_space_map(AddressSpace *as, | 66 | - tcg_gen_gvec_3_ool(vec_full_reg_offset(s, a->rd), |
32 | 67 | - vec_full_reg_offset(s, a->rn), | |
33 | memory_region_ref(mr); | 68 | - pred_full_reg_offset(s, a->pg), |
34 | *plen = flatview_extend_translation(fv, addr, len, mr, xlat, | 69 | - vsz, vsz, a->imm, fn); |
35 | - l, is_write); | 70 | + gen_gvec_ool_zzp(s, fn, a->rd, a->rn, a->pg, a->imm); |
36 | + l, is_write, attrs); | 71 | } |
37 | ptr = qemu_ram_ptr_length(mr->ram_block, xlat, plen, true); | 72 | return true; |
38 | rcu_read_unlock(); | 73 | } |
39 | |||
40 | @@ -XXX,XX +XXX,XX @@ int64_t address_space_cache_init(MemoryRegionCache *cache, | ||
41 | mr = cache->mrs.mr; | ||
42 | memory_region_ref(mr); | ||
43 | if (memory_access_is_direct(mr, is_write)) { | ||
44 | + /* We don't care about the memory attributes here as we're only | ||
45 | + * doing this if we found actual RAM, which behaves the same | ||
46 | + * regardless of attributes; so UNSPECIFIED is fine. | ||
47 | + */ | ||
48 | l = flatview_extend_translation(cache->fv, addr, len, mr, | ||
49 | - cache->xlat, l, is_write); | ||
50 | + cache->xlat, l, is_write, | ||
51 | + MEMTXATTRS_UNSPECIFIED); | ||
52 | cache->ptr = qemu_ram_ptr_length(mr->ram_block, cache->xlat, &l, true); | ||
53 | } else { | ||
54 | cache->ptr = NULL; | ||
55 | -- | 74 | -- |
56 | 2.17.1 | 75 | 2.20.1 |
57 | 76 | ||
58 | 77 | diff view generated by jsdifflib |
1 | As part of plumbing MemTxAttrs down to the IOMMU translate method, | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | add MemTxAttrs as an argument to address_space_translate() | ||
3 | and address_space_translate_cached(). Callers either have an | ||
4 | attrs value to hand, or don't care and can use MEMTXATTRS_UNSPECIFIED. | ||
5 | 2 | ||
3 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
4 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Message-id: 20200815013145.539409-12-richard.henderson@linaro.org | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20180521140402.23318-4-peter.maydell@linaro.org | ||
10 | --- | 7 | --- |
11 | include/exec/memory.h | 4 +++- | 8 | target/arm/translate-sve.c | 53 +++++++++++++------------------------- |
12 | accel/tcg/translate-all.c | 2 +- | 9 | 1 file changed, 18 insertions(+), 35 deletions(-) |
13 | exec.c | 14 +++++++++----- | ||
14 | hw/vfio/common.c | 3 ++- | ||
15 | memory_ldst.inc.c | 18 +++++++++--------- | ||
16 | target/riscv/helper.c | 2 +- | ||
17 | 6 files changed, 25 insertions(+), 18 deletions(-) | ||
18 | 10 | ||
19 | diff --git a/include/exec/memory.h b/include/exec/memory.h | 11 | diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c |
20 | index XXXXXXX..XXXXXXX 100644 | 12 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/include/exec/memory.h | 13 | --- a/target/arm/translate-sve.c |
22 | +++ b/include/exec/memory.h | 14 | +++ b/target/arm/translate-sve.c |
23 | @@ -XXX,XX +XXX,XX @@ IOMMUTLBEntry address_space_get_iotlb_entry(AddressSpace *as, hwaddr addr, | 15 | @@ -XXX,XX +XXX,XX @@ static int pred_gvec_reg_size(DisasContext *s) |
24 | * #MemoryRegion. | 16 | return size_for_gvec(pred_full_reg_size(s)); |
25 | * @len: pointer to length | 17 | } |
26 | * @is_write: indicates the transfer direction | 18 | |
27 | + * @attrs: memory attributes | 19 | +/* Invoke an out-of-line helper on 3 Zregs. */ |
28 | */ | 20 | +static void gen_gvec_ool_zzz(DisasContext *s, gen_helper_gvec_3 *fn, |
29 | MemoryRegion *flatview_translate(FlatView *fv, | 21 | + int rd, int rn, int rm, int data) |
30 | hwaddr addr, hwaddr *xlat, | 22 | +{ |
31 | @@ -XXX,XX +XXX,XX @@ MemoryRegion *flatview_translate(FlatView *fv, | 23 | + unsigned vsz = vec_full_reg_size(s); |
32 | 24 | + tcg_gen_gvec_3_ool(vec_full_reg_offset(s, rd), | |
33 | static inline MemoryRegion *address_space_translate(AddressSpace *as, | 25 | + vec_full_reg_offset(s, rn), |
34 | hwaddr addr, hwaddr *xlat, | 26 | + vec_full_reg_offset(s, rm), |
35 | - hwaddr *len, bool is_write) | 27 | + vsz, vsz, data, fn); |
36 | + hwaddr *len, bool is_write, | 28 | +} |
37 | + MemTxAttrs attrs) | 29 | + |
30 | /* Invoke an out-of-line helper on 2 Zregs and a predicate. */ | ||
31 | static void gen_gvec_ool_zzp(DisasContext *s, gen_helper_gvec_3 *fn, | ||
32 | int rd, int rn, int pg, int data) | ||
33 | @@ -XXX,XX +XXX,XX @@ static bool do_zzw_ool(DisasContext *s, arg_rrr_esz *a, gen_helper_gvec_3 *fn) | ||
34 | return false; | ||
35 | } | ||
36 | if (sve_access_check(s)) { | ||
37 | - unsigned vsz = vec_full_reg_size(s); | ||
38 | - tcg_gen_gvec_3_ool(vec_full_reg_offset(s, a->rd), | ||
39 | - vec_full_reg_offset(s, a->rn), | ||
40 | - vec_full_reg_offset(s, a->rm), | ||
41 | - vsz, vsz, 0, fn); | ||
42 | + gen_gvec_ool_zzz(s, fn, a->rd, a->rn, a->rm, 0); | ||
43 | } | ||
44 | return true; | ||
45 | } | ||
46 | @@ -XXX,XX +XXX,XX @@ static bool trans_RDVL(DisasContext *s, arg_RDVL *a) | ||
47 | static bool do_adr(DisasContext *s, arg_rrri *a, gen_helper_gvec_3 *fn) | ||
38 | { | 48 | { |
39 | return flatview_translate(address_space_to_flatview(as), | 49 | if (sve_access_check(s)) { |
40 | addr, xlat, len, is_write); | 50 | - unsigned vsz = vec_full_reg_size(s); |
41 | diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c | 51 | - tcg_gen_gvec_3_ool(vec_full_reg_offset(s, a->rd), |
42 | index XXXXXXX..XXXXXXX 100644 | 52 | - vec_full_reg_offset(s, a->rn), |
43 | --- a/accel/tcg/translate-all.c | 53 | - vec_full_reg_offset(s, a->rm), |
44 | +++ b/accel/tcg/translate-all.c | 54 | - vsz, vsz, a->imm, fn); |
45 | @@ -XXX,XX +XXX,XX @@ void tb_invalidate_phys_addr(AddressSpace *as, hwaddr addr, MemTxAttrs attrs) | 55 | + gen_gvec_ool_zzz(s, fn, a->rd, a->rn, a->rm, a->imm); |
46 | hwaddr l = 1; | 56 | } |
47 | 57 | return true; | |
48 | rcu_read_lock(); | 58 | } |
49 | - mr = address_space_translate(as, addr, &addr, &l, false); | 59 | @@ -XXX,XX +XXX,XX @@ static bool trans_FTSSEL(DisasContext *s, arg_rrr_esz *a) |
50 | + mr = address_space_translate(as, addr, &addr, &l, false, attrs); | 60 | return false; |
51 | if (!(memory_region_is_ram(mr) | 61 | } |
52 | || memory_region_is_romd(mr))) { | 62 | if (sve_access_check(s)) { |
53 | rcu_read_unlock(); | 63 | - unsigned vsz = vec_full_reg_size(s); |
54 | diff --git a/exec.c b/exec.c | 64 | - tcg_gen_gvec_3_ool(vec_full_reg_offset(s, a->rd), |
55 | index XXXXXXX..XXXXXXX 100644 | 65 | - vec_full_reg_offset(s, a->rn), |
56 | --- a/exec.c | 66 | - vec_full_reg_offset(s, a->rm), |
57 | +++ b/exec.c | 67 | - vsz, vsz, 0, fns[a->esz]); |
58 | @@ -XXX,XX +XXX,XX @@ static inline void cpu_physical_memory_write_rom_internal(AddressSpace *as, | 68 | + gen_gvec_ool_zzz(s, fns[a->esz], a->rd, a->rn, a->rm, 0); |
59 | rcu_read_lock(); | 69 | } |
60 | while (len > 0) { | 70 | return true; |
61 | l = len; | 71 | } |
62 | - mr = address_space_translate(as, addr, &addr1, &l, true); | 72 | @@ -XXX,XX +XXX,XX @@ static bool trans_TBL(DisasContext *s, arg_rrr_esz *a) |
63 | + mr = address_space_translate(as, addr, &addr1, &l, true, | 73 | }; |
64 | + MEMTXATTRS_UNSPECIFIED); | 74 | |
65 | 75 | if (sve_access_check(s)) { | |
66 | if (!(memory_region_is_ram(mr) || | 76 | - unsigned vsz = vec_full_reg_size(s); |
67 | memory_region_is_romd(mr))) { | 77 | - tcg_gen_gvec_3_ool(vec_full_reg_offset(s, a->rd), |
68 | @@ -XXX,XX +XXX,XX @@ void address_space_cache_destroy(MemoryRegionCache *cache) | 78 | - vec_full_reg_offset(s, a->rn), |
69 | */ | 79 | - vec_full_reg_offset(s, a->rm), |
70 | static inline MemoryRegion *address_space_translate_cached( | 80 | - vsz, vsz, 0, fns[a->esz]); |
71 | MemoryRegionCache *cache, hwaddr addr, hwaddr *xlat, | 81 | + gen_gvec_ool_zzz(s, fns[a->esz], a->rd, a->rn, a->rm, 0); |
72 | - hwaddr *plen, bool is_write) | 82 | } |
73 | + hwaddr *plen, bool is_write, MemTxAttrs attrs) | 83 | return true; |
84 | } | ||
85 | @@ -XXX,XX +XXX,XX @@ static bool do_zzz_data_ool(DisasContext *s, arg_rrr_esz *a, int data, | ||
86 | gen_helper_gvec_3 *fn) | ||
74 | { | 87 | { |
75 | MemoryRegionSection section; | 88 | if (sve_access_check(s)) { |
76 | MemoryRegion *mr; | 89 | - unsigned vsz = vec_full_reg_size(s); |
77 | @@ -XXX,XX +XXX,XX @@ address_space_read_cached_slow(MemoryRegionCache *cache, hwaddr addr, | 90 | - tcg_gen_gvec_3_ool(vec_full_reg_offset(s, a->rd), |
78 | MemoryRegion *mr; | 91 | - vec_full_reg_offset(s, a->rn), |
79 | 92 | - vec_full_reg_offset(s, a->rm), | |
80 | l = len; | 93 | - vsz, vsz, data, fn); |
81 | - mr = address_space_translate_cached(cache, addr, &addr1, &l, false); | 94 | + gen_gvec_ool_zzz(s, fn, a->rd, a->rn, a->rm, data); |
82 | + mr = address_space_translate_cached(cache, addr, &addr1, &l, false, | 95 | } |
83 | + MEMTXATTRS_UNSPECIFIED); | 96 | return true; |
84 | flatview_read_continue(cache->fv, | 97 | } |
85 | addr, MEMTXATTRS_UNSPECIFIED, buf, len, | 98 | @@ -XXX,XX +XXX,XX @@ static bool trans_DOT_zzz(DisasContext *s, arg_DOT_zzz *a) |
86 | addr1, l, mr); | 99 | }; |
87 | @@ -XXX,XX +XXX,XX @@ address_space_write_cached_slow(MemoryRegionCache *cache, hwaddr addr, | 100 | |
88 | MemoryRegion *mr; | 101 | if (sve_access_check(s)) { |
89 | 102 | - unsigned vsz = vec_full_reg_size(s); | |
90 | l = len; | 103 | - tcg_gen_gvec_3_ool(vec_full_reg_offset(s, a->rd), |
91 | - mr = address_space_translate_cached(cache, addr, &addr1, &l, true); | 104 | - vec_full_reg_offset(s, a->rn), |
92 | + mr = address_space_translate_cached(cache, addr, &addr1, &l, true, | 105 | - vec_full_reg_offset(s, a->rm), |
93 | + MEMTXATTRS_UNSPECIFIED); | 106 | - vsz, vsz, 0, fns[a->u][a->sz]); |
94 | flatview_write_continue(cache->fv, | 107 | + gen_gvec_ool_zzz(s, fns[a->u][a->sz], a->rd, a->rn, a->rm, 0); |
95 | addr, MEMTXATTRS_UNSPECIFIED, buf, len, | 108 | } |
96 | addr1, l, mr); | 109 | return true; |
97 | @@ -XXX,XX +XXX,XX @@ bool cpu_physical_memory_is_io(hwaddr phys_addr) | 110 | } |
98 | 111 | @@ -XXX,XX +XXX,XX @@ static bool trans_DOT_zzx(DisasContext *s, arg_DOT_zzx *a) | |
99 | rcu_read_lock(); | 112 | }; |
100 | mr = address_space_translate(&address_space_memory, | 113 | |
101 | - phys_addr, &phys_addr, &l, false); | 114 | if (sve_access_check(s)) { |
102 | + phys_addr, &phys_addr, &l, false, | 115 | - unsigned vsz = vec_full_reg_size(s); |
103 | + MEMTXATTRS_UNSPECIFIED); | 116 | - tcg_gen_gvec_3_ool(vec_full_reg_offset(s, a->rd), |
104 | 117 | - vec_full_reg_offset(s, a->rn), | |
105 | res = !(memory_region_is_ram(mr) || memory_region_is_romd(mr)); | 118 | - vec_full_reg_offset(s, a->rm), |
106 | rcu_read_unlock(); | 119 | - vsz, vsz, a->index, fns[a->u][a->sz]); |
107 | diff --git a/hw/vfio/common.c b/hw/vfio/common.c | 120 | + gen_gvec_ool_zzz(s, fns[a->u][a->sz], a->rd, a->rn, a->rm, a->index); |
108 | index XXXXXXX..XXXXXXX 100644 | 121 | } |
109 | --- a/hw/vfio/common.c | 122 | return true; |
110 | +++ b/hw/vfio/common.c | 123 | } |
111 | @@ -XXX,XX +XXX,XX @@ static bool vfio_get_vaddr(IOMMUTLBEntry *iotlb, void **vaddr, | ||
112 | */ | ||
113 | mr = address_space_translate(&address_space_memory, | ||
114 | iotlb->translated_addr, | ||
115 | - &xlat, &len, writable); | ||
116 | + &xlat, &len, writable, | ||
117 | + MEMTXATTRS_UNSPECIFIED); | ||
118 | if (!memory_region_is_ram(mr)) { | ||
119 | error_report("iommu map to non memory area %"HWADDR_PRIx"", | ||
120 | xlat); | ||
121 | diff --git a/memory_ldst.inc.c b/memory_ldst.inc.c | ||
122 | index XXXXXXX..XXXXXXX 100644 | ||
123 | --- a/memory_ldst.inc.c | ||
124 | +++ b/memory_ldst.inc.c | ||
125 | @@ -XXX,XX +XXX,XX @@ static inline uint32_t glue(address_space_ldl_internal, SUFFIX)(ARG1_DECL, | ||
126 | bool release_lock = false; | ||
127 | |||
128 | RCU_READ_LOCK(); | ||
129 | - mr = TRANSLATE(addr, &addr1, &l, false); | ||
130 | + mr = TRANSLATE(addr, &addr1, &l, false, attrs); | ||
131 | if (l < 4 || !IS_DIRECT(mr, false)) { | ||
132 | release_lock |= prepare_mmio_access(mr); | ||
133 | |||
134 | @@ -XXX,XX +XXX,XX @@ static inline uint64_t glue(address_space_ldq_internal, SUFFIX)(ARG1_DECL, | ||
135 | bool release_lock = false; | ||
136 | |||
137 | RCU_READ_LOCK(); | ||
138 | - mr = TRANSLATE(addr, &addr1, &l, false); | ||
139 | + mr = TRANSLATE(addr, &addr1, &l, false, attrs); | ||
140 | if (l < 8 || !IS_DIRECT(mr, false)) { | ||
141 | release_lock |= prepare_mmio_access(mr); | ||
142 | |||
143 | @@ -XXX,XX +XXX,XX @@ uint32_t glue(address_space_ldub, SUFFIX)(ARG1_DECL, | ||
144 | bool release_lock = false; | ||
145 | |||
146 | RCU_READ_LOCK(); | ||
147 | - mr = TRANSLATE(addr, &addr1, &l, false); | ||
148 | + mr = TRANSLATE(addr, &addr1, &l, false, attrs); | ||
149 | if (!IS_DIRECT(mr, false)) { | ||
150 | release_lock |= prepare_mmio_access(mr); | ||
151 | |||
152 | @@ -XXX,XX +XXX,XX @@ static inline uint32_t glue(address_space_lduw_internal, SUFFIX)(ARG1_DECL, | ||
153 | bool release_lock = false; | ||
154 | |||
155 | RCU_READ_LOCK(); | ||
156 | - mr = TRANSLATE(addr, &addr1, &l, false); | ||
157 | + mr = TRANSLATE(addr, &addr1, &l, false, attrs); | ||
158 | if (l < 2 || !IS_DIRECT(mr, false)) { | ||
159 | release_lock |= prepare_mmio_access(mr); | ||
160 | |||
161 | @@ -XXX,XX +XXX,XX @@ void glue(address_space_stl_notdirty, SUFFIX)(ARG1_DECL, | ||
162 | bool release_lock = false; | ||
163 | |||
164 | RCU_READ_LOCK(); | ||
165 | - mr = TRANSLATE(addr, &addr1, &l, true); | ||
166 | + mr = TRANSLATE(addr, &addr1, &l, true, attrs); | ||
167 | if (l < 4 || !IS_DIRECT(mr, true)) { | ||
168 | release_lock |= prepare_mmio_access(mr); | ||
169 | |||
170 | @@ -XXX,XX +XXX,XX @@ static inline void glue(address_space_stl_internal, SUFFIX)(ARG1_DECL, | ||
171 | bool release_lock = false; | ||
172 | |||
173 | RCU_READ_LOCK(); | ||
174 | - mr = TRANSLATE(addr, &addr1, &l, true); | ||
175 | + mr = TRANSLATE(addr, &addr1, &l, true, attrs); | ||
176 | if (l < 4 || !IS_DIRECT(mr, true)) { | ||
177 | release_lock |= prepare_mmio_access(mr); | ||
178 | |||
179 | @@ -XXX,XX +XXX,XX @@ void glue(address_space_stb, SUFFIX)(ARG1_DECL, | ||
180 | bool release_lock = false; | ||
181 | |||
182 | RCU_READ_LOCK(); | ||
183 | - mr = TRANSLATE(addr, &addr1, &l, true); | ||
184 | + mr = TRANSLATE(addr, &addr1, &l, true, attrs); | ||
185 | if (!IS_DIRECT(mr, true)) { | ||
186 | release_lock |= prepare_mmio_access(mr); | ||
187 | r = memory_region_dispatch_write(mr, addr1, val, 1, attrs); | ||
188 | @@ -XXX,XX +XXX,XX @@ static inline void glue(address_space_stw_internal, SUFFIX)(ARG1_DECL, | ||
189 | bool release_lock = false; | ||
190 | |||
191 | RCU_READ_LOCK(); | ||
192 | - mr = TRANSLATE(addr, &addr1, &l, true); | ||
193 | + mr = TRANSLATE(addr, &addr1, &l, true, attrs); | ||
194 | if (l < 2 || !IS_DIRECT(mr, true)) { | ||
195 | release_lock |= prepare_mmio_access(mr); | ||
196 | |||
197 | @@ -XXX,XX +XXX,XX @@ static void glue(address_space_stq_internal, SUFFIX)(ARG1_DECL, | ||
198 | bool release_lock = false; | ||
199 | |||
200 | RCU_READ_LOCK(); | ||
201 | - mr = TRANSLATE(addr, &addr1, &l, true); | ||
202 | + mr = TRANSLATE(addr, &addr1, &l, true, attrs); | ||
203 | if (l < 8 || !IS_DIRECT(mr, true)) { | ||
204 | release_lock |= prepare_mmio_access(mr); | ||
205 | |||
206 | diff --git a/target/riscv/helper.c b/target/riscv/helper.c | ||
207 | index XXXXXXX..XXXXXXX 100644 | ||
208 | --- a/target/riscv/helper.c | ||
209 | +++ b/target/riscv/helper.c | ||
210 | @@ -XXX,XX +XXX,XX @@ restart: | ||
211 | MemoryRegion *mr; | ||
212 | hwaddr l = sizeof(target_ulong), addr1; | ||
213 | mr = address_space_translate(cs->as, pte_addr, | ||
214 | - &addr1, &l, false); | ||
215 | + &addr1, &l, false, MEMTXATTRS_UNSPECIFIED); | ||
216 | if (memory_access_is_direct(mr, true)) { | ||
217 | target_ulong *pte_pa = | ||
218 | qemu_map_ram_ptr(mr->ram_block, addr1); | ||
219 | -- | 124 | -- |
220 | 2.17.1 | 125 | 2.20.1 |
221 | 126 | ||
222 | 127 | diff view generated by jsdifflib |
1 | From: Francisco Iglesias <frasse.iglesias@gmail.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Coverity found that the string return by 'object_get_canonical_path' was not | 3 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
4 | being freed at two locations in the model (CID 1391294 and CID 1391293) and | ||
5 | also that a memset was being called with a value greater than the max of a byte | ||
6 | on the second argument (CID 1391286). This patch corrects this by adding the | ||
7 | freeing of the strings and also changing to memset to zero instead on | ||
8 | descriptor unaligned errors. | ||
9 | |||
10 | Signed-off-by: Francisco Iglesias <frasse.iglesias@gmail.com> | ||
11 | Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> | ||
12 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
13 | Message-id: 20180528184859.3530-1-frasse.iglesias@gmail.com | ||
14 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 4 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Message-id: 20200815013145.539409-13-richard.henderson@linaro.org | ||
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
16 | --- | 7 | --- |
17 | hw/dma/xlnx-zdma.c | 10 +++++++--- | 8 | target/arm/translate-sve.c | 20 ++++++++++++-------- |
18 | 1 file changed, 7 insertions(+), 3 deletions(-) | 9 | 1 file changed, 12 insertions(+), 8 deletions(-) |
19 | 10 | ||
20 | diff --git a/hw/dma/xlnx-zdma.c b/hw/dma/xlnx-zdma.c | 11 | diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c |
21 | index XXXXXXX..XXXXXXX 100644 | 12 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/hw/dma/xlnx-zdma.c | 13 | --- a/target/arm/translate-sve.c |
23 | +++ b/hw/dma/xlnx-zdma.c | 14 | +++ b/target/arm/translate-sve.c |
24 | @@ -XXX,XX +XXX,XX @@ static bool zdma_load_descriptor(XlnxZDMA *s, uint64_t addr, void *buf) | 15 | @@ -XXX,XX +XXX,XX @@ static int pred_gvec_reg_size(DisasContext *s) |
25 | qemu_log_mask(LOG_GUEST_ERROR, | 16 | return size_for_gvec(pred_full_reg_size(s)); |
26 | "zdma: unaligned descriptor at %" PRIx64, | 17 | } |
27 | addr); | 18 | |
28 | - memset(buf, 0xdeadbeef, sizeof(XlnxZDMADescr)); | 19 | +/* Invoke an out-of-line helper on 2 Zregs. */ |
29 | + memset(buf, 0x0, sizeof(XlnxZDMADescr)); | 20 | +static void gen_gvec_ool_zz(DisasContext *s, gen_helper_gvec_2 *fn, |
30 | s->error = true; | 21 | + int rd, int rn, int data) |
22 | +{ | ||
23 | + unsigned vsz = vec_full_reg_size(s); | ||
24 | + tcg_gen_gvec_2_ool(vec_full_reg_offset(s, rd), | ||
25 | + vec_full_reg_offset(s, rn), | ||
26 | + vsz, vsz, data, fn); | ||
27 | +} | ||
28 | + | ||
29 | /* Invoke an out-of-line helper on 3 Zregs. */ | ||
30 | static void gen_gvec_ool_zzz(DisasContext *s, gen_helper_gvec_3 *fn, | ||
31 | int rd, int rn, int rm, int data) | ||
32 | @@ -XXX,XX +XXX,XX @@ static bool trans_FEXPA(DisasContext *s, arg_rr_esz *a) | ||
31 | return false; | 33 | return false; |
32 | } | 34 | } |
33 | @@ -XXX,XX +XXX,XX @@ static uint64_t zdma_read(void *opaque, hwaddr addr, unsigned size) | 35 | if (sve_access_check(s)) { |
34 | RegisterInfo *r = &s->regs_info[addr / 4]; | 36 | - unsigned vsz = vec_full_reg_size(s); |
35 | 37 | - tcg_gen_gvec_2_ool(vec_full_reg_offset(s, a->rd), | |
36 | if (!r->data) { | 38 | - vec_full_reg_offset(s, a->rn), |
37 | + gchar *path = object_get_canonical_path(OBJECT(s)); | 39 | - vsz, vsz, 0, fns[a->esz]); |
38 | qemu_log("%s: Decode error: read from %" HWADDR_PRIx "\n", | 40 | + gen_gvec_ool_zz(s, fns[a->esz], a->rd, a->rn, 0); |
39 | - object_get_canonical_path(OBJECT(s)), | 41 | } |
40 | + path, | 42 | return true; |
41 | addr); | 43 | } |
42 | + g_free(path); | 44 | @@ -XXX,XX +XXX,XX @@ static bool trans_REV_v(DisasContext *s, arg_rr_esz *a) |
43 | ARRAY_FIELD_DP32(s->regs, ZDMA_CH_ISR, INV_APB, true); | 45 | }; |
44 | zdma_ch_imr_update_irq(s); | 46 | |
45 | return 0; | 47 | if (sve_access_check(s)) { |
46 | @@ -XXX,XX +XXX,XX @@ static void zdma_write(void *opaque, hwaddr addr, uint64_t value, | 48 | - unsigned vsz = vec_full_reg_size(s); |
47 | RegisterInfo *r = &s->regs_info[addr / 4]; | 49 | - tcg_gen_gvec_2_ool(vec_full_reg_offset(s, a->rd), |
48 | 50 | - vec_full_reg_offset(s, a->rn), | |
49 | if (!r->data) { | 51 | - vsz, vsz, 0, fns[a->esz]); |
50 | + gchar *path = object_get_canonical_path(OBJECT(s)); | 52 | + gen_gvec_ool_zz(s, fns[a->esz], a->rd, a->rn, 0); |
51 | qemu_log("%s: Decode error: write to %" HWADDR_PRIx "=%" PRIx64 "\n", | 53 | } |
52 | - object_get_canonical_path(OBJECT(s)), | 54 | return true; |
53 | + path, | 55 | } |
54 | addr, value); | ||
55 | + g_free(path); | ||
56 | ARRAY_FIELD_DP32(s->regs, ZDMA_CH_ISR, INV_APB, true); | ||
57 | zdma_ch_imr_update_irq(s); | ||
58 | return; | ||
59 | -- | 56 | -- |
60 | 2.17.1 | 57 | 2.20.1 |
61 | 58 | ||
62 | 59 | diff view generated by jsdifflib |
1 | From: Paolo Bonzini <pbonzini@redhat.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | cpregs_keys is an uint32_t* so the allocation should use uint32_t. | 3 | Rather than require the user to fill in the immediate (shl or shr), |
4 | g_new is even better because it is type-safe. | 4 | create full formats that include the immediate. |
5 | 5 | ||
6 | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> | 6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 8 | Message-id: 20200815013145.539409-14-richard.henderson@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 | target/arm/gdbstub.c | 3 +-- | 11 | target/arm/sve.decode | 35 ++++++++++++++++------------------- |
12 | 1 file changed, 1 insertion(+), 2 deletions(-) | 12 | 1 file changed, 16 insertions(+), 19 deletions(-) |
13 | 13 | ||
14 | diff --git a/target/arm/gdbstub.c b/target/arm/gdbstub.c | 14 | diff --git a/target/arm/sve.decode b/target/arm/sve.decode |
15 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/gdbstub.c | 16 | --- a/target/arm/sve.decode |
17 | +++ b/target/arm/gdbstub.c | 17 | +++ b/target/arm/sve.decode |
18 | @@ -XXX,XX +XXX,XX @@ int arm_gen_dynamic_xml(CPUState *cs) | 18 | @@ -XXX,XX +XXX,XX @@ |
19 | RegisterSysregXmlParam param = {cs, s}; | 19 | @rd_rn_i6 ........ ... rn:5 ..... imm:s6 rd:5 &rri |
20 | 20 | ||
21 | cpu->dyn_xml.num_cpregs = 0; | 21 | # Two register operand, one immediate operand, with predicate, |
22 | - cpu->dyn_xml.cpregs_keys = g_malloc(sizeof(uint32_t *) * | 22 | -# element size encoded as TSZHL. User must fill in imm. |
23 | - g_hash_table_size(cpu->cp_regs)); | 23 | -@rdn_pg_tszimm ........ .. ... ... ... pg:3 ..... rd:5 \ |
24 | + cpu->dyn_xml.cpregs_keys = g_new(uint32_t, g_hash_table_size(cpu->cp_regs)); | 24 | - &rpri_esz rn=%reg_movprfx esz=%tszimm_esz |
25 | g_string_printf(s, "<?xml version=\"1.0\"?>"); | 25 | +# element size encoded as TSZHL. |
26 | g_string_append_printf(s, "<!DOCTYPE target SYSTEM \"gdb-target.dtd\">"); | 26 | +@rdn_pg_tszimm_shl ........ .. ... ... ... pg:3 ..... rd:5 \ |
27 | g_string_append_printf(s, "<feature name=\"org.qemu.gdb.arm.sys.regs\">"); | 27 | + &rpri_esz rn=%reg_movprfx esz=%tszimm_esz imm=%tszimm_shl |
28 | +@rdn_pg_tszimm_shr ........ .. ... ... ... pg:3 ..... rd:5 \ | ||
29 | + &rpri_esz rn=%reg_movprfx esz=%tszimm_esz imm=%tszimm_shr | ||
30 | |||
31 | # Similarly without predicate. | ||
32 | -@rd_rn_tszimm ........ .. ... ... ...... rn:5 rd:5 \ | ||
33 | - &rri_esz esz=%tszimm16_esz | ||
34 | +@rd_rn_tszimm_shl ........ .. ... ... ...... rn:5 rd:5 \ | ||
35 | + &rri_esz esz=%tszimm16_esz imm=%tszimm16_shl | ||
36 | +@rd_rn_tszimm_shr ........ .. ... ... ...... rn:5 rd:5 \ | ||
37 | + &rri_esz esz=%tszimm16_esz imm=%tszimm16_shr | ||
38 | |||
39 | # Two register operand, one immediate operand, with 4-bit predicate. | ||
40 | # User must fill in imm. | ||
41 | @@ -XXX,XX +XXX,XX @@ UMINV 00000100 .. 001 011 001 ... ..... ..... @rd_pg_rn | ||
42 | ### SVE Shift by Immediate - Predicated Group | ||
43 | |||
44 | # SVE bitwise shift by immediate (predicated) | ||
45 | -ASR_zpzi 00000100 .. 000 000 100 ... .. ... ..... \ | ||
46 | - @rdn_pg_tszimm imm=%tszimm_shr | ||
47 | -LSR_zpzi 00000100 .. 000 001 100 ... .. ... ..... \ | ||
48 | - @rdn_pg_tszimm imm=%tszimm_shr | ||
49 | -LSL_zpzi 00000100 .. 000 011 100 ... .. ... ..... \ | ||
50 | - @rdn_pg_tszimm imm=%tszimm_shl | ||
51 | -ASRD 00000100 .. 000 100 100 ... .. ... ..... \ | ||
52 | - @rdn_pg_tszimm imm=%tszimm_shr | ||
53 | +ASR_zpzi 00000100 .. 000 000 100 ... .. ... ..... @rdn_pg_tszimm_shr | ||
54 | +LSR_zpzi 00000100 .. 000 001 100 ... .. ... ..... @rdn_pg_tszimm_shr | ||
55 | +LSL_zpzi 00000100 .. 000 011 100 ... .. ... ..... @rdn_pg_tszimm_shl | ||
56 | +ASRD 00000100 .. 000 100 100 ... .. ... ..... @rdn_pg_tszimm_shr | ||
57 | |||
58 | # SVE bitwise shift by vector (predicated) | ||
59 | ASR_zpzz 00000100 .. 010 000 100 ... ..... ..... @rdn_pg_rm | ||
60 | @@ -XXX,XX +XXX,XX @@ RDVL 00000100 101 11111 01010 imm:s6 rd:5 | ||
61 | ### SVE Bitwise Shift - Unpredicated Group | ||
62 | |||
63 | # SVE bitwise shift by immediate (unpredicated) | ||
64 | -ASR_zzi 00000100 .. 1 ..... 1001 00 ..... ..... \ | ||
65 | - @rd_rn_tszimm imm=%tszimm16_shr | ||
66 | -LSR_zzi 00000100 .. 1 ..... 1001 01 ..... ..... \ | ||
67 | - @rd_rn_tszimm imm=%tszimm16_shr | ||
68 | -LSL_zzi 00000100 .. 1 ..... 1001 11 ..... ..... \ | ||
69 | - @rd_rn_tszimm imm=%tszimm16_shl | ||
70 | +ASR_zzi 00000100 .. 1 ..... 1001 00 ..... ..... @rd_rn_tszimm_shr | ||
71 | +LSR_zzi 00000100 .. 1 ..... 1001 01 ..... ..... @rd_rn_tszimm_shr | ||
72 | +LSL_zzi 00000100 .. 1 ..... 1001 11 ..... ..... @rd_rn_tszimm_shl | ||
73 | |||
74 | # SVE bitwise shift by wide elements (unpredicated) | ||
75 | # Note esz != 3 | ||
28 | -- | 76 | -- |
29 | 2.17.1 | 77 | 2.20.1 |
30 | 78 | ||
31 | 79 | diff view generated by jsdifflib |
1 | As part of plumbing MemTxAttrs down to the IOMMU translate method, | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | add MemTxAttrs as an argument to the MemoryRegion valid.accepts | ||
3 | callback. We'll need this for subpage_accepts(). | ||
4 | 2 | ||
5 | We could take the approach we used with the read and write | 3 | Unify add/sub helpers and add a parameter for rounding. |
6 | callbacks and add new a new _with_attrs version, but since there | 4 | This will allow saturating non-rounding to reuse this code. |
7 | are so few implementations of the accepts hook we just change | ||
8 | them all. | ||
9 | 5 | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | [PMM: fixed accidental use of '=' rather than '+=' in do_sqrdmlah_s] | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Message-id: 20200815013145.539409-15-richard.henderson@linaro.org | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
12 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
13 | Message-id: 20180521140402.23318-9-peter.maydell@linaro.org | ||
14 | --- | 11 | --- |
15 | include/exec/memory.h | 3 ++- | 12 | target/arm/vec_helper.c | 80 +++++++++++++++-------------------------- |
16 | exec.c | 9 ++++++--- | 13 | 1 file changed, 29 insertions(+), 51 deletions(-) |
17 | hw/hppa/dino.c | 3 ++- | ||
18 | hw/nvram/fw_cfg.c | 12 ++++++++---- | ||
19 | hw/scsi/esp.c | 3 ++- | ||
20 | hw/xen/xen_pt_msi.c | 3 ++- | ||
21 | memory.c | 5 +++-- | ||
22 | 7 files changed, 25 insertions(+), 13 deletions(-) | ||
23 | 14 | ||
24 | diff --git a/include/exec/memory.h b/include/exec/memory.h | 15 | diff --git a/target/arm/vec_helper.c b/target/arm/vec_helper.c |
25 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
26 | --- a/include/exec/memory.h | 17 | --- a/target/arm/vec_helper.c |
27 | +++ b/include/exec/memory.h | 18 | +++ b/target/arm/vec_helper.c |
28 | @@ -XXX,XX +XXX,XX @@ struct MemoryRegionOps { | 19 | @@ -XXX,XX +XXX,XX @@ |
29 | * as a machine check exception). | 20 | #endif |
30 | */ | 21 | |
31 | bool (*accepts)(void *opaque, hwaddr addr, | 22 | /* Signed saturating rounding doubling multiply-accumulate high half, 16-bit */ |
32 | - unsigned size, bool is_write); | 23 | -static int16_t inl_qrdmlah_s16(int16_t src1, int16_t src2, |
33 | + unsigned size, bool is_write, | 24 | - int16_t src3, uint32_t *sat) |
34 | + MemTxAttrs attrs); | 25 | +static int16_t do_sqrdmlah_h(int16_t src1, int16_t src2, int16_t src3, |
35 | } valid; | 26 | + bool neg, bool round, uint32_t *sat) |
36 | /* Internal implementation constraints: */ | 27 | { |
37 | struct { | 28 | - /* Simplify: |
38 | diff --git a/exec.c b/exec.c | 29 | + /* |
39 | index XXXXXXX..XXXXXXX 100644 | 30 | + * Simplify: |
40 | --- a/exec.c | 31 | * = ((a3 << 16) + ((e1 * e2) << 1) + (1 << 15)) >> 16 |
41 | +++ b/exec.c | 32 | * = ((a3 << 15) + (e1 * e2) + (1 << 14)) >> 15 |
42 | @@ -XXX,XX +XXX,XX @@ static void notdirty_mem_write(void *opaque, hwaddr ram_addr, | 33 | */ |
34 | int32_t ret = (int32_t)src1 * src2; | ||
35 | - ret = ((int32_t)src3 << 15) + ret + (1 << 14); | ||
36 | + if (neg) { | ||
37 | + ret = -ret; | ||
38 | + } | ||
39 | + ret += ((int32_t)src3 << 15) + (round << 14); | ||
40 | ret >>= 15; | ||
41 | + | ||
42 | if (ret != (int16_t)ret) { | ||
43 | *sat = 1; | ||
44 | - ret = (ret < 0 ? -0x8000 : 0x7fff); | ||
45 | + ret = (ret < 0 ? INT16_MIN : INT16_MAX); | ||
46 | } | ||
47 | return ret; | ||
43 | } | 48 | } |
44 | 49 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(neon_qrdmlah_s16)(CPUARMState *env, uint32_t src1, | |
45 | static bool notdirty_mem_accepts(void *opaque, hwaddr addr, | 50 | uint32_t src2, uint32_t src3) |
46 | - unsigned size, bool is_write) | ||
47 | + unsigned size, bool is_write, | ||
48 | + MemTxAttrs attrs) | ||
49 | { | 51 | { |
50 | return is_write; | 52 | uint32_t *sat = &env->vfp.qc[0]; |
53 | - uint16_t e1 = inl_qrdmlah_s16(src1, src2, src3, sat); | ||
54 | - uint16_t e2 = inl_qrdmlah_s16(src1 >> 16, src2 >> 16, src3 >> 16, sat); | ||
55 | + uint16_t e1 = do_sqrdmlah_h(src1, src2, src3, false, true, sat); | ||
56 | + uint16_t e2 = do_sqrdmlah_h(src1 >> 16, src2 >> 16, src3 >> 16, | ||
57 | + false, true, sat); | ||
58 | return deposit32(e1, 16, 16, e2); | ||
51 | } | 59 | } |
52 | @@ -XXX,XX +XXX,XX @@ static MemTxResult subpage_write(void *opaque, hwaddr addr, | 60 | |
61 | @@ -XXX,XX +XXX,XX @@ void HELPER(gvec_qrdmlah_s16)(void *vd, void *vn, void *vm, | ||
62 | uintptr_t i; | ||
63 | |||
64 | for (i = 0; i < opr_sz / 2; ++i) { | ||
65 | - d[i] = inl_qrdmlah_s16(n[i], m[i], d[i], vq); | ||
66 | + d[i] = do_sqrdmlah_h(n[i], m[i], d[i], false, true, vq); | ||
67 | } | ||
68 | clear_tail(d, opr_sz, simd_maxsz(desc)); | ||
53 | } | 69 | } |
54 | 70 | ||
55 | static bool subpage_accepts(void *opaque, hwaddr addr, | 71 | -/* Signed saturating rounding doubling multiply-subtract high half, 16-bit */ |
56 | - unsigned len, bool is_write) | 72 | -static int16_t inl_qrdmlsh_s16(int16_t src1, int16_t src2, |
57 | + unsigned len, bool is_write, | 73 | - int16_t src3, uint32_t *sat) |
58 | + MemTxAttrs attrs) | 74 | -{ |
75 | - /* Similarly, using subtraction: | ||
76 | - * = ((a3 << 16) - ((e1 * e2) << 1) + (1 << 15)) >> 16 | ||
77 | - * = ((a3 << 15) - (e1 * e2) + (1 << 14)) >> 15 | ||
78 | - */ | ||
79 | - int32_t ret = (int32_t)src1 * src2; | ||
80 | - ret = ((int32_t)src3 << 15) - ret + (1 << 14); | ||
81 | - ret >>= 15; | ||
82 | - if (ret != (int16_t)ret) { | ||
83 | - *sat = 1; | ||
84 | - ret = (ret < 0 ? -0x8000 : 0x7fff); | ||
85 | - } | ||
86 | - return ret; | ||
87 | -} | ||
88 | - | ||
89 | uint32_t HELPER(neon_qrdmlsh_s16)(CPUARMState *env, uint32_t src1, | ||
90 | uint32_t src2, uint32_t src3) | ||
59 | { | 91 | { |
60 | subpage_t *subpage = opaque; | 92 | uint32_t *sat = &env->vfp.qc[0]; |
61 | #if defined(DEBUG_SUBPAGE) | 93 | - uint16_t e1 = inl_qrdmlsh_s16(src1, src2, src3, sat); |
62 | @@ -XXX,XX +XXX,XX @@ static void readonly_mem_write(void *opaque, hwaddr addr, | 94 | - uint16_t e2 = inl_qrdmlsh_s16(src1 >> 16, src2 >> 16, src3 >> 16, sat); |
95 | + uint16_t e1 = do_sqrdmlah_h(src1, src2, src3, true, true, sat); | ||
96 | + uint16_t e2 = do_sqrdmlah_h(src1 >> 16, src2 >> 16, src3 >> 16, | ||
97 | + true, true, sat); | ||
98 | return deposit32(e1, 16, 16, e2); | ||
63 | } | 99 | } |
64 | 100 | ||
65 | static bool readonly_mem_accepts(void *opaque, hwaddr addr, | 101 | @@ -XXX,XX +XXX,XX @@ void HELPER(gvec_qrdmlsh_s16)(void *vd, void *vn, void *vm, |
66 | - unsigned size, bool is_write) | 102 | uintptr_t i; |
67 | + unsigned size, bool is_write, | 103 | |
68 | + MemTxAttrs attrs) | 104 | for (i = 0; i < opr_sz / 2; ++i) { |
105 | - d[i] = inl_qrdmlsh_s16(n[i], m[i], d[i], vq); | ||
106 | + d[i] = do_sqrdmlah_h(n[i], m[i], d[i], true, true, vq); | ||
107 | } | ||
108 | clear_tail(d, opr_sz, simd_maxsz(desc)); | ||
109 | } | ||
110 | |||
111 | /* Signed saturating rounding doubling multiply-accumulate high half, 32-bit */ | ||
112 | -static int32_t inl_qrdmlah_s32(int32_t src1, int32_t src2, | ||
113 | - int32_t src3, uint32_t *sat) | ||
114 | +static int32_t do_sqrdmlah_s(int32_t src1, int32_t src2, int32_t src3, | ||
115 | + bool neg, bool round, uint32_t *sat) | ||
69 | { | 116 | { |
70 | return is_write; | 117 | /* Simplify similarly to int_qrdmlah_s16 above. */ |
118 | int64_t ret = (int64_t)src1 * src2; | ||
119 | - ret = ((int64_t)src3 << 31) + ret + (1 << 30); | ||
120 | + if (neg) { | ||
121 | + ret = -ret; | ||
122 | + } | ||
123 | + ret += ((int64_t)src3 << 31) + (round << 30); | ||
124 | ret >>= 31; | ||
125 | + | ||
126 | if (ret != (int32_t)ret) { | ||
127 | *sat = 1; | ||
128 | ret = (ret < 0 ? INT32_MIN : INT32_MAX); | ||
129 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(neon_qrdmlah_s32)(CPUARMState *env, int32_t src1, | ||
130 | int32_t src2, int32_t src3) | ||
131 | { | ||
132 | uint32_t *sat = &env->vfp.qc[0]; | ||
133 | - return inl_qrdmlah_s32(src1, src2, src3, sat); | ||
134 | + return do_sqrdmlah_s(src1, src2, src3, false, true, sat); | ||
71 | } | 135 | } |
72 | diff --git a/hw/hppa/dino.c b/hw/hppa/dino.c | 136 | |
73 | index XXXXXXX..XXXXXXX 100644 | 137 | void HELPER(gvec_qrdmlah_s32)(void *vd, void *vn, void *vm, |
74 | --- a/hw/hppa/dino.c | 138 | @@ -XXX,XX +XXX,XX @@ void HELPER(gvec_qrdmlah_s32)(void *vd, void *vn, void *vm, |
75 | +++ b/hw/hppa/dino.c | 139 | uintptr_t i; |
76 | @@ -XXX,XX +XXX,XX @@ static void gsc_to_pci_forwarding(DinoState *s) | 140 | |
141 | for (i = 0; i < opr_sz / 4; ++i) { | ||
142 | - d[i] = inl_qrdmlah_s32(n[i], m[i], d[i], vq); | ||
143 | + d[i] = do_sqrdmlah_s(n[i], m[i], d[i], false, true, vq); | ||
144 | } | ||
145 | clear_tail(d, opr_sz, simd_maxsz(desc)); | ||
77 | } | 146 | } |
78 | 147 | ||
79 | static bool dino_chip_mem_valid(void *opaque, hwaddr addr, | 148 | -/* Signed saturating rounding doubling multiply-subtract high half, 32-bit */ |
80 | - unsigned size, bool is_write) | 149 | -static int32_t inl_qrdmlsh_s32(int32_t src1, int32_t src2, |
81 | + unsigned size, bool is_write, | 150 | - int32_t src3, uint32_t *sat) |
82 | + MemTxAttrs attrs) | 151 | -{ |
152 | - /* Simplify similarly to int_qrdmlsh_s16 above. */ | ||
153 | - int64_t ret = (int64_t)src1 * src2; | ||
154 | - ret = ((int64_t)src3 << 31) - ret + (1 << 30); | ||
155 | - ret >>= 31; | ||
156 | - if (ret != (int32_t)ret) { | ||
157 | - *sat = 1; | ||
158 | - ret = (ret < 0 ? INT32_MIN : INT32_MAX); | ||
159 | - } | ||
160 | - return ret; | ||
161 | -} | ||
162 | - | ||
163 | uint32_t HELPER(neon_qrdmlsh_s32)(CPUARMState *env, int32_t src1, | ||
164 | int32_t src2, int32_t src3) | ||
83 | { | 165 | { |
84 | switch (addr) { | 166 | uint32_t *sat = &env->vfp.qc[0]; |
85 | case DINO_IAR0: | 167 | - return inl_qrdmlsh_s32(src1, src2, src3, sat); |
86 | diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c | 168 | + return do_sqrdmlah_s(src1, src2, src3, true, true, sat); |
87 | index XXXXXXX..XXXXXXX 100644 | ||
88 | --- a/hw/nvram/fw_cfg.c | ||
89 | +++ b/hw/nvram/fw_cfg.c | ||
90 | @@ -XXX,XX +XXX,XX @@ static void fw_cfg_dma_mem_write(void *opaque, hwaddr addr, | ||
91 | } | 169 | } |
92 | 170 | ||
93 | static bool fw_cfg_dma_mem_valid(void *opaque, hwaddr addr, | 171 | void HELPER(gvec_qrdmlsh_s32)(void *vd, void *vn, void *vm, |
94 | - unsigned size, bool is_write) | 172 | @@ -XXX,XX +XXX,XX @@ void HELPER(gvec_qrdmlsh_s32)(void *vd, void *vn, void *vm, |
95 | + unsigned size, bool is_write, | 173 | uintptr_t i; |
96 | + MemTxAttrs attrs) | 174 | |
97 | { | 175 | for (i = 0; i < opr_sz / 4; ++i) { |
98 | return !is_write || ((size == 4 && (addr == 0 || addr == 4)) || | 176 | - d[i] = inl_qrdmlsh_s32(n[i], m[i], d[i], vq); |
99 | (size == 8 && addr == 0)); | 177 | + d[i] = do_sqrdmlah_s(n[i], m[i], d[i], true, true, vq); |
178 | } | ||
179 | clear_tail(d, opr_sz, simd_maxsz(desc)); | ||
100 | } | 180 | } |
101 | |||
102 | static bool fw_cfg_data_mem_valid(void *opaque, hwaddr addr, | ||
103 | - unsigned size, bool is_write) | ||
104 | + unsigned size, bool is_write, | ||
105 | + MemTxAttrs attrs) | ||
106 | { | ||
107 | return addr == 0; | ||
108 | } | ||
109 | @@ -XXX,XX +XXX,XX @@ static void fw_cfg_ctl_mem_write(void *opaque, hwaddr addr, | ||
110 | } | ||
111 | |||
112 | static bool fw_cfg_ctl_mem_valid(void *opaque, hwaddr addr, | ||
113 | - unsigned size, bool is_write) | ||
114 | + unsigned size, bool is_write, | ||
115 | + MemTxAttrs attrs) | ||
116 | { | ||
117 | return is_write && size == 2; | ||
118 | } | ||
119 | @@ -XXX,XX +XXX,XX @@ static void fw_cfg_comb_write(void *opaque, hwaddr addr, | ||
120 | } | ||
121 | |||
122 | static bool fw_cfg_comb_valid(void *opaque, hwaddr addr, | ||
123 | - unsigned size, bool is_write) | ||
124 | + unsigned size, bool is_write, | ||
125 | + MemTxAttrs attrs) | ||
126 | { | ||
127 | return (size == 1) || (is_write && size == 2); | ||
128 | } | ||
129 | diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c | ||
130 | index XXXXXXX..XXXXXXX 100644 | ||
131 | --- a/hw/scsi/esp.c | ||
132 | +++ b/hw/scsi/esp.c | ||
133 | @@ -XXX,XX +XXX,XX @@ void esp_reg_write(ESPState *s, uint32_t saddr, uint64_t val) | ||
134 | } | ||
135 | |||
136 | static bool esp_mem_accepts(void *opaque, hwaddr addr, | ||
137 | - unsigned size, bool is_write) | ||
138 | + unsigned size, bool is_write, | ||
139 | + MemTxAttrs attrs) | ||
140 | { | ||
141 | return (size == 1) || (is_write && size == 4); | ||
142 | } | ||
143 | diff --git a/hw/xen/xen_pt_msi.c b/hw/xen/xen_pt_msi.c | ||
144 | index XXXXXXX..XXXXXXX 100644 | ||
145 | --- a/hw/xen/xen_pt_msi.c | ||
146 | +++ b/hw/xen/xen_pt_msi.c | ||
147 | @@ -XXX,XX +XXX,XX @@ static uint64_t pci_msix_read(void *opaque, hwaddr addr, | ||
148 | } | ||
149 | |||
150 | static bool pci_msix_accepts(void *opaque, hwaddr addr, | ||
151 | - unsigned size, bool is_write) | ||
152 | + unsigned size, bool is_write, | ||
153 | + MemTxAttrs attrs) | ||
154 | { | ||
155 | return !(addr & (size - 1)); | ||
156 | } | ||
157 | diff --git a/memory.c b/memory.c | ||
158 | index XXXXXXX..XXXXXXX 100644 | ||
159 | --- a/memory.c | ||
160 | +++ b/memory.c | ||
161 | @@ -XXX,XX +XXX,XX @@ static void unassigned_mem_write(void *opaque, hwaddr addr, | ||
162 | } | ||
163 | |||
164 | static bool unassigned_mem_accepts(void *opaque, hwaddr addr, | ||
165 | - unsigned size, bool is_write) | ||
166 | + unsigned size, bool is_write, | ||
167 | + MemTxAttrs attrs) | ||
168 | { | ||
169 | return false; | ||
170 | } | ||
171 | @@ -XXX,XX +XXX,XX @@ bool memory_region_access_valid(MemoryRegion *mr, | ||
172 | access_size = MAX(MIN(size, access_size_max), access_size_min); | ||
173 | for (i = 0; i < size; i += access_size) { | ||
174 | if (!mr->ops->valid.accepts(mr->opaque, addr + i, access_size, | ||
175 | - is_write)) { | ||
176 | + is_write, attrs)) { | ||
177 | return false; | ||
178 | } | ||
179 | } | ||
180 | -- | 181 | -- |
181 | 2.17.1 | 182 | 2.20.1 |
182 | 183 | ||
183 | 184 | diff view generated by jsdifflib |
1 | From: Igor Mammedov <imammedo@redhat.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | When QEMU is started with following CLI | 3 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
4 | -machine virt,gic-version=3,accel=kvm -cpu host -bios AAVMF_CODE.fd | ||
5 | it crashes with abort at | ||
6 | accel/kvm/kvm-all.c:2164: | ||
7 | KVM_SET_DEVICE_ATTR failed: Group 6 attr 0x000000000000c665: Invalid argument | ||
8 | |||
9 | Which is caused by implicit dependency of kvm_arm_gicv3_reset() on | ||
10 | arm_gicv3_icc_reset() where the later is called by CPU reset | ||
11 | reset callback. | ||
12 | |||
13 | However commit: | ||
14 | 3b77f6c arm/boot: split load_dtb() from arm_load_kernel() | ||
15 | broke CPU reset callback registration in case | ||
16 | |||
17 | arm_load_kernel() | ||
18 | ... | ||
19 | if (!info->kernel_filename || info->firmware_loaded) | ||
20 | |||
21 | branch is taken, i.e. it's sufficient to provide a firmware | ||
22 | or do not provide kernel on CLI to skip cpu reset callback | ||
23 | registration, where before offending commit the callback | ||
24 | has been registered unconditionally. | ||
25 | |||
26 | Fix it by registering the callback right at the beginning of | ||
27 | arm_load_kernel() unconditionally instead of doing it at the end. | ||
28 | |||
29 | NOTE: | ||
30 | we probably should eliminate that dependency anyways as well as | ||
31 | separate arch CPU reset parts from arm_load_kernel() into CPU | ||
32 | itself, but that refactoring that I probably would have to do | ||
33 | anyways later for CPU hotplug to work. | ||
34 | |||
35 | Reported-by: Auger Eric <eric.auger@redhat.com> | ||
36 | Signed-off-by: Igor Mammedov <imammedo@redhat.com> | ||
37 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | ||
38 | Tested-by: Eric Auger <eric.auger@redhat.com> | ||
39 | Message-id: 1527070950-208350-1-git-send-email-imammedo@redhat.com | ||
40 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 4 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Message-id: 20200815013145.539409-19-richard.henderson@linaro.org | ||
41 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
42 | --- | 7 | --- |
43 | hw/arm/boot.c | 18 +++++++++--------- | 8 | target/arm/helper.h | 4 ++++ |
44 | 1 file changed, 9 insertions(+), 9 deletions(-) | 9 | target/arm/translate-a64.c | 16 ++++++++++++++++ |
10 | target/arm/vec_helper.c | 29 +++++++++++++++++++++++++---- | ||
11 | 3 files changed, 45 insertions(+), 4 deletions(-) | ||
45 | 12 | ||
46 | diff --git a/hw/arm/boot.c b/hw/arm/boot.c | 13 | diff --git a/target/arm/helper.h b/target/arm/helper.h |
47 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
48 | --- a/hw/arm/boot.c | 15 | --- a/target/arm/helper.h |
49 | +++ b/hw/arm/boot.c | 16 | +++ b/target/arm/helper.h |
50 | @@ -XXX,XX +XXX,XX @@ void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info) | 17 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(gvec_uaba_h, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) |
51 | static const ARMInsnFixup *primary_loader; | 18 | DEF_HELPER_FLAGS_4(gvec_uaba_s, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) |
52 | AddressSpace *as = arm_boot_address_space(cpu, info); | 19 | DEF_HELPER_FLAGS_4(gvec_uaba_d, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) |
53 | 20 | ||
54 | + /* CPU objects (unlike devices) are not automatically reset on system | 21 | +DEF_HELPER_FLAGS_4(gvec_mul_idx_h, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) |
55 | + * reset, so we must always register a handler to do so. If we're | 22 | +DEF_HELPER_FLAGS_4(gvec_mul_idx_s, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) |
56 | + * actually loading a kernel, the handler is also responsible for | 23 | +DEF_HELPER_FLAGS_4(gvec_mul_idx_d, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) |
57 | + * arranging that we start it correctly. | ||
58 | + */ | ||
59 | + for (cs = first_cpu; cs; cs = CPU_NEXT(cs)) { | ||
60 | + qemu_register_reset(do_cpu_reset, ARM_CPU(cs)); | ||
61 | + } | ||
62 | + | 24 | + |
63 | /* The board code is not supposed to set secure_board_setup unless | 25 | #ifdef TARGET_AARCH64 |
64 | * running its code in secure mode is actually possible, and KVM | 26 | #include "helper-a64.h" |
65 | * doesn't support secure. | 27 | #include "helper-sve.h" |
66 | @@ -XXX,XX +XXX,XX @@ void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info) | 28 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c |
67 | ARM_CPU(cs)->env.boot_info = info; | 29 | index XXXXXXX..XXXXXXX 100644 |
30 | --- a/target/arm/translate-a64.c | ||
31 | +++ b/target/arm/translate-a64.c | ||
32 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_indexed(DisasContext *s, uint32_t insn) | ||
33 | data, gen_helper_gvec_fmlal_idx_a64); | ||
34 | } | ||
35 | return; | ||
36 | + | ||
37 | + case 0x08: /* MUL */ | ||
38 | + if (!is_long && !is_scalar) { | ||
39 | + static gen_helper_gvec_3 * const fns[3] = { | ||
40 | + gen_helper_gvec_mul_idx_h, | ||
41 | + gen_helper_gvec_mul_idx_s, | ||
42 | + gen_helper_gvec_mul_idx_d, | ||
43 | + }; | ||
44 | + tcg_gen_gvec_3_ool(vec_full_reg_offset(s, rd), | ||
45 | + vec_full_reg_offset(s, rn), | ||
46 | + vec_full_reg_offset(s, rm), | ||
47 | + is_q ? 16 : 8, vec_full_reg_size(s), | ||
48 | + index, fns[size - 1]); | ||
49 | + return; | ||
50 | + } | ||
51 | + break; | ||
68 | } | 52 | } |
69 | 53 | ||
70 | - /* CPU objects (unlike devices) are not automatically reset on system | 54 | if (size == 3) { |
71 | - * reset, so we must always register a handler to do so. If we're | 55 | diff --git a/target/arm/vec_helper.c b/target/arm/vec_helper.c |
72 | - * actually loading a kernel, the handler is also responsible for | 56 | index XXXXXXX..XXXXXXX 100644 |
73 | - * arranging that we start it correctly. | 57 | --- a/target/arm/vec_helper.c |
74 | - */ | 58 | +++ b/target/arm/vec_helper.c |
75 | - for (cs = first_cpu; cs; cs = CPU_NEXT(cs)) { | 59 | @@ -XXX,XX +XXX,XX @@ DO_3OP(gvec_rsqrts_d, helper_rsqrtsf_f64, float64) |
76 | - qemu_register_reset(do_cpu_reset, ARM_CPU(cs)); | 60 | */ |
77 | - } | 61 | |
78 | - | 62 | #define DO_MUL_IDX(NAME, TYPE, H) \ |
79 | if (!info->skip_dtb_autoload && have_dtb(info)) { | 63 | +void HELPER(NAME)(void *vd, void *vn, void *vm, uint32_t desc) \ |
80 | if (arm_load_dtb(info->dtb_start, info, info->dtb_limit, as) < 0) { | 64 | +{ \ |
81 | exit(1); | 65 | + intptr_t i, j, oprsz = simd_oprsz(desc), segment = 16 / sizeof(TYPE); \ |
66 | + intptr_t idx = simd_data(desc); \ | ||
67 | + TYPE *d = vd, *n = vn, *m = vm; \ | ||
68 | + for (i = 0; i < oprsz / sizeof(TYPE); i += segment) { \ | ||
69 | + TYPE mm = m[H(i + idx)]; \ | ||
70 | + for (j = 0; j < segment; j++) { \ | ||
71 | + d[i + j] = n[i + j] * mm; \ | ||
72 | + } \ | ||
73 | + } \ | ||
74 | + clear_tail(d, oprsz, simd_maxsz(desc)); \ | ||
75 | +} | ||
76 | + | ||
77 | +DO_MUL_IDX(gvec_mul_idx_h, uint16_t, H2) | ||
78 | +DO_MUL_IDX(gvec_mul_idx_s, uint32_t, H4) | ||
79 | +DO_MUL_IDX(gvec_mul_idx_d, uint64_t, ) | ||
80 | + | ||
81 | +#undef DO_MUL_IDX | ||
82 | + | ||
83 | +#define DO_FMUL_IDX(NAME, TYPE, H) \ | ||
84 | void HELPER(NAME)(void *vd, void *vn, void *vm, void *stat, uint32_t desc) \ | ||
85 | { \ | ||
86 | intptr_t i, j, oprsz = simd_oprsz(desc), segment = 16 / sizeof(TYPE); \ | ||
87 | @@ -XXX,XX +XXX,XX @@ void HELPER(NAME)(void *vd, void *vn, void *vm, void *stat, uint32_t desc) \ | ||
88 | clear_tail(d, oprsz, simd_maxsz(desc)); \ | ||
89 | } | ||
90 | |||
91 | -DO_MUL_IDX(gvec_fmul_idx_h, float16, H2) | ||
92 | -DO_MUL_IDX(gvec_fmul_idx_s, float32, H4) | ||
93 | -DO_MUL_IDX(gvec_fmul_idx_d, float64, ) | ||
94 | +DO_FMUL_IDX(gvec_fmul_idx_h, float16, H2) | ||
95 | +DO_FMUL_IDX(gvec_fmul_idx_s, float32, H4) | ||
96 | +DO_FMUL_IDX(gvec_fmul_idx_d, float64, ) | ||
97 | |||
98 | -#undef DO_MUL_IDX | ||
99 | +#undef DO_FMUL_IDX | ||
100 | |||
101 | #define DO_FMLA_IDX(NAME, TYPE, H) \ | ||
102 | void HELPER(NAME)(void *vd, void *vn, void *vm, void *va, \ | ||
82 | -- | 103 | -- |
83 | 2.17.1 | 104 | 2.20.1 |
84 | 105 | ||
85 | 106 | diff view generated by jsdifflib |
1 | Add entries to MAINTAINERS to cover the newer MPS2 boards and | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | the new devices they use. | ||
3 | 2 | ||
3 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
4 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Message-id: 20200815013145.539409-20-richard.henderson@linaro.org | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Message-id: 20180518153157.14899-1-peter.maydell@linaro.org | ||
6 | --- | 7 | --- |
7 | MAINTAINERS | 9 +++++++-- | 8 | target/arm/helper.h | 14 ++++++++++++++ |
8 | 1 file changed, 7 insertions(+), 2 deletions(-) | 9 | target/arm/translate-a64.c | 34 ++++++++++++++++++++++++++++++++++ |
10 | target/arm/vec_helper.c | 25 +++++++++++++++++++++++++ | ||
11 | 3 files changed, 73 insertions(+) | ||
9 | 12 | ||
10 | diff --git a/MAINTAINERS b/MAINTAINERS | 13 | diff --git a/target/arm/helper.h b/target/arm/helper.h |
11 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
12 | --- a/MAINTAINERS | 15 | --- a/target/arm/helper.h |
13 | +++ b/MAINTAINERS | 16 | +++ b/target/arm/helper.h |
14 | @@ -XXX,XX +XXX,XX @@ F: hw/timer/cmsdk-apb-timer.c | 17 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(gvec_mul_idx_h, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) |
15 | F: include/hw/timer/cmsdk-apb-timer.h | 18 | DEF_HELPER_FLAGS_4(gvec_mul_idx_s, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) |
16 | F: hw/char/cmsdk-apb-uart.c | 19 | DEF_HELPER_FLAGS_4(gvec_mul_idx_d, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) |
17 | F: include/hw/char/cmsdk-apb-uart.h | 20 | |
18 | +F: hw/misc/tz-ppc.c | 21 | +DEF_HELPER_FLAGS_5(gvec_mla_idx_h, TCG_CALL_NO_RWG, |
19 | +F: include/hw/misc/tz-ppc.h | 22 | + void, ptr, ptr, ptr, ptr, i32) |
20 | 23 | +DEF_HELPER_FLAGS_5(gvec_mla_idx_s, TCG_CALL_NO_RWG, | |
21 | ARM cores | 24 | + void, ptr, ptr, ptr, ptr, i32) |
22 | M: Peter Maydell <peter.maydell@linaro.org> | 25 | +DEF_HELPER_FLAGS_5(gvec_mla_idx_d, TCG_CALL_NO_RWG, |
23 | @@ -XXX,XX +XXX,XX @@ M: Peter Maydell <peter.maydell@linaro.org> | 26 | + void, ptr, ptr, ptr, ptr, i32) |
24 | L: qemu-arm@nongnu.org | 27 | + |
25 | S: Maintained | 28 | +DEF_HELPER_FLAGS_5(gvec_mls_idx_h, TCG_CALL_NO_RWG, |
26 | F: hw/arm/mps2.c | 29 | + void, ptr, ptr, ptr, ptr, i32) |
27 | -F: hw/misc/mps2-scc.c | 30 | +DEF_HELPER_FLAGS_5(gvec_mls_idx_s, TCG_CALL_NO_RWG, |
28 | -F: include/hw/misc/mps2-scc.h | 31 | + void, ptr, ptr, ptr, ptr, i32) |
29 | +F: hw/arm/mps2-tz.c | 32 | +DEF_HELPER_FLAGS_5(gvec_mls_idx_d, TCG_CALL_NO_RWG, |
30 | +F: hw/misc/mps2-*.c | 33 | + void, ptr, ptr, ptr, ptr, i32) |
31 | +F: include/hw/misc/mps2-*.h | 34 | + |
32 | +F: hw/arm/iotkit.c | 35 | #ifdef TARGET_AARCH64 |
33 | +F: include/hw/arm/iotkit.h | 36 | #include "helper-a64.h" |
34 | 37 | #include "helper-sve.h" | |
35 | Musicpal | 38 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c |
36 | M: Jan Kiszka <jan.kiszka@web.de> | 39 | index XXXXXXX..XXXXXXX 100644 |
40 | --- a/target/arm/translate-a64.c | ||
41 | +++ b/target/arm/translate-a64.c | ||
42 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_indexed(DisasContext *s, uint32_t insn) | ||
43 | return; | ||
44 | } | ||
45 | break; | ||
46 | + | ||
47 | + case 0x10: /* MLA */ | ||
48 | + if (!is_long && !is_scalar) { | ||
49 | + static gen_helper_gvec_4 * const fns[3] = { | ||
50 | + gen_helper_gvec_mla_idx_h, | ||
51 | + gen_helper_gvec_mla_idx_s, | ||
52 | + gen_helper_gvec_mla_idx_d, | ||
53 | + }; | ||
54 | + tcg_gen_gvec_4_ool(vec_full_reg_offset(s, rd), | ||
55 | + vec_full_reg_offset(s, rn), | ||
56 | + vec_full_reg_offset(s, rm), | ||
57 | + vec_full_reg_offset(s, rd), | ||
58 | + is_q ? 16 : 8, vec_full_reg_size(s), | ||
59 | + index, fns[size - 1]); | ||
60 | + return; | ||
61 | + } | ||
62 | + break; | ||
63 | + | ||
64 | + case 0x14: /* MLS */ | ||
65 | + if (!is_long && !is_scalar) { | ||
66 | + static gen_helper_gvec_4 * const fns[3] = { | ||
67 | + gen_helper_gvec_mls_idx_h, | ||
68 | + gen_helper_gvec_mls_idx_s, | ||
69 | + gen_helper_gvec_mls_idx_d, | ||
70 | + }; | ||
71 | + tcg_gen_gvec_4_ool(vec_full_reg_offset(s, rd), | ||
72 | + vec_full_reg_offset(s, rn), | ||
73 | + vec_full_reg_offset(s, rm), | ||
74 | + vec_full_reg_offset(s, rd), | ||
75 | + is_q ? 16 : 8, vec_full_reg_size(s), | ||
76 | + index, fns[size - 1]); | ||
77 | + return; | ||
78 | + } | ||
79 | + break; | ||
80 | } | ||
81 | |||
82 | if (size == 3) { | ||
83 | diff --git a/target/arm/vec_helper.c b/target/arm/vec_helper.c | ||
84 | index XXXXXXX..XXXXXXX 100644 | ||
85 | --- a/target/arm/vec_helper.c | ||
86 | +++ b/target/arm/vec_helper.c | ||
87 | @@ -XXX,XX +XXX,XX @@ DO_MUL_IDX(gvec_mul_idx_d, uint64_t, ) | ||
88 | |||
89 | #undef DO_MUL_IDX | ||
90 | |||
91 | +#define DO_MLA_IDX(NAME, TYPE, OP, H) \ | ||
92 | +void HELPER(NAME)(void *vd, void *vn, void *vm, void *va, uint32_t desc) \ | ||
93 | +{ \ | ||
94 | + intptr_t i, j, oprsz = simd_oprsz(desc), segment = 16 / sizeof(TYPE); \ | ||
95 | + intptr_t idx = simd_data(desc); \ | ||
96 | + TYPE *d = vd, *n = vn, *m = vm, *a = va; \ | ||
97 | + for (i = 0; i < oprsz / sizeof(TYPE); i += segment) { \ | ||
98 | + TYPE mm = m[H(i + idx)]; \ | ||
99 | + for (j = 0; j < segment; j++) { \ | ||
100 | + d[i + j] = a[i + j] OP n[i + j] * mm; \ | ||
101 | + } \ | ||
102 | + } \ | ||
103 | + clear_tail(d, oprsz, simd_maxsz(desc)); \ | ||
104 | +} | ||
105 | + | ||
106 | +DO_MLA_IDX(gvec_mla_idx_h, uint16_t, +, H2) | ||
107 | +DO_MLA_IDX(gvec_mla_idx_s, uint32_t, +, H4) | ||
108 | +DO_MLA_IDX(gvec_mla_idx_d, uint64_t, +, ) | ||
109 | + | ||
110 | +DO_MLA_IDX(gvec_mls_idx_h, uint16_t, -, H2) | ||
111 | +DO_MLA_IDX(gvec_mls_idx_s, uint32_t, -, H4) | ||
112 | +DO_MLA_IDX(gvec_mls_idx_d, uint64_t, -, ) | ||
113 | + | ||
114 | +#undef DO_MLA_IDX | ||
115 | + | ||
116 | #define DO_FMUL_IDX(NAME, TYPE, H) \ | ||
117 | void HELPER(NAME)(void *vd, void *vn, void *vm, void *stat, uint32_t desc) \ | ||
118 | { \ | ||
37 | -- | 119 | -- |
38 | 2.17.1 | 120 | 2.20.1 |
39 | 121 | ||
40 | 122 | diff view generated by jsdifflib |
1 | As part of plumbing MemTxAttrs down to the IOMMU translate method, | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | add MemTxAttrs as an argument to tb_invalidate_phys_addr(). | ||
3 | Its callers either have an attrs value to hand, or don't care | ||
4 | and can use MEMTXATTRS_UNSPECIFIED. | ||
5 | 2 | ||
3 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
4 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Message-id: 20200815013145.539409-21-richard.henderson@linaro.org | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
9 | Message-id: 20180521140402.23318-3-peter.maydell@linaro.org | ||
10 | --- | 7 | --- |
11 | include/exec/exec-all.h | 5 +++-- | 8 | target/arm/helper.h | 10 ++++++++ |
12 | accel/tcg/translate-all.c | 2 +- | 9 | target/arm/translate-a64.c | 33 ++++++++++++++++++-------- |
13 | exec.c | 2 +- | 10 | target/arm/vec_helper.c | 48 ++++++++++++++++++++++++++++++++++++++ |
14 | target/xtensa/op_helper.c | 3 ++- | 11 | 3 files changed, 81 insertions(+), 10 deletions(-) |
15 | 4 files changed, 7 insertions(+), 5 deletions(-) | ||
16 | 12 | ||
17 | diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h | 13 | diff --git a/target/arm/helper.h b/target/arm/helper.h |
18 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/include/exec/exec-all.h | 15 | --- a/target/arm/helper.h |
20 | +++ b/include/exec/exec-all.h | 16 | +++ b/target/arm/helper.h |
21 | @@ -XXX,XX +XXX,XX @@ void tlb_set_page_with_attrs(CPUState *cpu, target_ulong vaddr, | 17 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_5(gvec_mls_idx_s, TCG_CALL_NO_RWG, |
22 | void tlb_set_page(CPUState *cpu, target_ulong vaddr, | 18 | DEF_HELPER_FLAGS_5(gvec_mls_idx_d, TCG_CALL_NO_RWG, |
23 | hwaddr paddr, int prot, | 19 | void, ptr, ptr, ptr, ptr, i32) |
24 | int mmu_idx, target_ulong size); | 20 | |
25 | -void tb_invalidate_phys_addr(AddressSpace *as, hwaddr addr); | 21 | +DEF_HELPER_FLAGS_5(neon_sqdmulh_h, TCG_CALL_NO_RWG, |
26 | +void tb_invalidate_phys_addr(AddressSpace *as, hwaddr addr, MemTxAttrs attrs); | 22 | + void, ptr, ptr, ptr, ptr, i32) |
27 | void probe_write(CPUArchState *env, target_ulong addr, int size, int mmu_idx, | 23 | +DEF_HELPER_FLAGS_5(neon_sqdmulh_s, TCG_CALL_NO_RWG, |
28 | uintptr_t retaddr); | 24 | + void, ptr, ptr, ptr, ptr, i32) |
29 | #else | 25 | + |
30 | @@ -XXX,XX +XXX,XX @@ static inline void tlb_flush_by_mmuidx_all_cpus_synced(CPUState *cpu, | 26 | +DEF_HELPER_FLAGS_5(neon_sqrdmulh_h, TCG_CALL_NO_RWG, |
31 | uint16_t idxmap) | 27 | + void, ptr, ptr, ptr, ptr, i32) |
32 | { | 28 | +DEF_HELPER_FLAGS_5(neon_sqrdmulh_s, TCG_CALL_NO_RWG, |
29 | + void, ptr, ptr, ptr, ptr, i32) | ||
30 | + | ||
31 | #ifdef TARGET_AARCH64 | ||
32 | #include "helper-a64.h" | ||
33 | #include "helper-sve.h" | ||
34 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
35 | index XXXXXXX..XXXXXXX 100644 | ||
36 | --- a/target/arm/translate-a64.c | ||
37 | +++ b/target/arm/translate-a64.c | ||
38 | @@ -XXX,XX +XXX,XX @@ static void gen_gvec_op3_fpst(DisasContext *s, bool is_q, int rd, int rn, | ||
39 | tcg_temp_free_ptr(fpst); | ||
33 | } | 40 | } |
34 | -static inline void tb_invalidate_phys_addr(AddressSpace *as, hwaddr addr) | 41 | |
35 | +static inline void tb_invalidate_phys_addr(AddressSpace *as, hwaddr addr, | 42 | +/* Expand a 3-operand + qc + operation using an out-of-line helper. */ |
36 | + MemTxAttrs attrs) | 43 | +static void gen_gvec_op3_qc(DisasContext *s, bool is_q, int rd, int rn, |
37 | { | 44 | + int rm, gen_helper_gvec_3_ptr *fn) |
45 | +{ | ||
46 | + TCGv_ptr qc_ptr = tcg_temp_new_ptr(); | ||
47 | + | ||
48 | + tcg_gen_addi_ptr(qc_ptr, cpu_env, offsetof(CPUARMState, vfp.qc)); | ||
49 | + tcg_gen_gvec_3_ptr(vec_full_reg_offset(s, rd), | ||
50 | + vec_full_reg_offset(s, rn), | ||
51 | + vec_full_reg_offset(s, rm), qc_ptr, | ||
52 | + is_q ? 16 : 8, vec_full_reg_size(s), 0, fn); | ||
53 | + tcg_temp_free_ptr(qc_ptr); | ||
54 | +} | ||
55 | + | ||
56 | /* Set ZF and NF based on a 64 bit result. This is alas fiddlier | ||
57 | * than the 32 bit equivalent. | ||
58 | */ | ||
59 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_3same_int(DisasContext *s, uint32_t insn) | ||
60 | gen_gvec_fn3(s, is_q, rd, rn, rm, gen_gvec_mla, size); | ||
61 | } | ||
62 | return; | ||
63 | + case 0x16: /* SQDMULH, SQRDMULH */ | ||
64 | + { | ||
65 | + static gen_helper_gvec_3_ptr * const fns[2][2] = { | ||
66 | + { gen_helper_neon_sqdmulh_h, gen_helper_neon_sqrdmulh_h }, | ||
67 | + { gen_helper_neon_sqdmulh_s, gen_helper_neon_sqrdmulh_s }, | ||
68 | + }; | ||
69 | + gen_gvec_op3_qc(s, is_q, rd, rn, rm, fns[size - 1][u]); | ||
70 | + } | ||
71 | + return; | ||
72 | case 0x11: | ||
73 | if (!u) { /* CMTST */ | ||
74 | gen_gvec_fn3(s, is_q, rd, rn, rm, gen_gvec_cmtst, size); | ||
75 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_3same_int(DisasContext *s, uint32_t insn) | ||
76 | genenvfn = fns[size][u]; | ||
77 | break; | ||
78 | } | ||
79 | - case 0x16: /* SQDMULH, SQRDMULH */ | ||
80 | - { | ||
81 | - static NeonGenTwoOpEnvFn * const fns[2][2] = { | ||
82 | - { gen_helper_neon_qdmulh_s16, gen_helper_neon_qrdmulh_s16 }, | ||
83 | - { gen_helper_neon_qdmulh_s32, gen_helper_neon_qrdmulh_s32 }, | ||
84 | - }; | ||
85 | - assert(size == 1 || size == 2); | ||
86 | - genenvfn = fns[size - 1][u]; | ||
87 | - break; | ||
88 | - } | ||
89 | default: | ||
90 | g_assert_not_reached(); | ||
91 | } | ||
92 | diff --git a/target/arm/vec_helper.c b/target/arm/vec_helper.c | ||
93 | index XXXXXXX..XXXXXXX 100644 | ||
94 | --- a/target/arm/vec_helper.c | ||
95 | +++ b/target/arm/vec_helper.c | ||
96 | @@ -XXX,XX +XXX,XX @@ void HELPER(gvec_qrdmlsh_s16)(void *vd, void *vn, void *vm, | ||
97 | clear_tail(d, opr_sz, simd_maxsz(desc)); | ||
38 | } | 98 | } |
39 | #endif | 99 | |
40 | diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c | 100 | +void HELPER(neon_sqdmulh_h)(void *vd, void *vn, void *vm, |
41 | index XXXXXXX..XXXXXXX 100644 | 101 | + void *vq, uint32_t desc) |
42 | --- a/accel/tcg/translate-all.c | 102 | +{ |
43 | +++ b/accel/tcg/translate-all.c | 103 | + intptr_t i, opr_sz = simd_oprsz(desc); |
44 | @@ -XXX,XX +XXX,XX @@ static TranslationBlock *tb_find_pc(uintptr_t tc_ptr) | 104 | + int16_t *d = vd, *n = vn, *m = vm; |
105 | + | ||
106 | + for (i = 0; i < opr_sz / 2; ++i) { | ||
107 | + d[i] = do_sqrdmlah_h(n[i], m[i], 0, false, false, vq); | ||
108 | + } | ||
109 | + clear_tail(d, opr_sz, simd_maxsz(desc)); | ||
110 | +} | ||
111 | + | ||
112 | +void HELPER(neon_sqrdmulh_h)(void *vd, void *vn, void *vm, | ||
113 | + void *vq, uint32_t desc) | ||
114 | +{ | ||
115 | + intptr_t i, opr_sz = simd_oprsz(desc); | ||
116 | + int16_t *d = vd, *n = vn, *m = vm; | ||
117 | + | ||
118 | + for (i = 0; i < opr_sz / 2; ++i) { | ||
119 | + d[i] = do_sqrdmlah_h(n[i], m[i], 0, false, true, vq); | ||
120 | + } | ||
121 | + clear_tail(d, opr_sz, simd_maxsz(desc)); | ||
122 | +} | ||
123 | + | ||
124 | /* Signed saturating rounding doubling multiply-accumulate high half, 32-bit */ | ||
125 | static int32_t do_sqrdmlah_s(int32_t src1, int32_t src2, int32_t src3, | ||
126 | bool neg, bool round, uint32_t *sat) | ||
127 | @@ -XXX,XX +XXX,XX @@ void HELPER(gvec_qrdmlsh_s32)(void *vd, void *vn, void *vm, | ||
128 | clear_tail(d, opr_sz, simd_maxsz(desc)); | ||
45 | } | 129 | } |
46 | 130 | ||
47 | #if !defined(CONFIG_USER_ONLY) | 131 | +void HELPER(neon_sqdmulh_s)(void *vd, void *vn, void *vm, |
48 | -void tb_invalidate_phys_addr(AddressSpace *as, hwaddr addr) | 132 | + void *vq, uint32_t desc) |
49 | +void tb_invalidate_phys_addr(AddressSpace *as, hwaddr addr, MemTxAttrs attrs) | 133 | +{ |
50 | { | 134 | + intptr_t i, opr_sz = simd_oprsz(desc); |
51 | ram_addr_t ram_addr; | 135 | + int32_t *d = vd, *n = vn, *m = vm; |
52 | MemoryRegion *mr; | 136 | + |
53 | diff --git a/exec.c b/exec.c | 137 | + for (i = 0; i < opr_sz / 4; ++i) { |
54 | index XXXXXXX..XXXXXXX 100644 | 138 | + d[i] = do_sqrdmlah_s(n[i], m[i], 0, false, false, vq); |
55 | --- a/exec.c | 139 | + } |
56 | +++ b/exec.c | 140 | + clear_tail(d, opr_sz, simd_maxsz(desc)); |
57 | @@ -XXX,XX +XXX,XX @@ static void breakpoint_invalidate(CPUState *cpu, target_ulong pc) | 141 | +} |
58 | if (phys != -1) { | 142 | + |
59 | /* Locks grabbed by tb_invalidate_phys_addr */ | 143 | +void HELPER(neon_sqrdmulh_s)(void *vd, void *vn, void *vm, |
60 | tb_invalidate_phys_addr(cpu->cpu_ases[asidx].as, | 144 | + void *vq, uint32_t desc) |
61 | - phys | (pc & ~TARGET_PAGE_MASK)); | 145 | +{ |
62 | + phys | (pc & ~TARGET_PAGE_MASK), attrs); | 146 | + intptr_t i, opr_sz = simd_oprsz(desc); |
63 | } | 147 | + int32_t *d = vd, *n = vn, *m = vm; |
64 | } | 148 | + |
65 | #endif | 149 | + for (i = 0; i < opr_sz / 4; ++i) { |
66 | diff --git a/target/xtensa/op_helper.c b/target/xtensa/op_helper.c | 150 | + d[i] = do_sqrdmlah_s(n[i], m[i], 0, false, true, vq); |
67 | index XXXXXXX..XXXXXXX 100644 | 151 | + } |
68 | --- a/target/xtensa/op_helper.c | 152 | + clear_tail(d, opr_sz, simd_maxsz(desc)); |
69 | +++ b/target/xtensa/op_helper.c | 153 | +} |
70 | @@ -XXX,XX +XXX,XX @@ static void tb_invalidate_virtual_addr(CPUXtensaState *env, uint32_t vaddr) | 154 | + |
71 | int ret = xtensa_get_physical_addr(env, false, vaddr, 2, 0, | 155 | /* Integer 8 and 16-bit dot-product. |
72 | &paddr, &page_size, &access); | 156 | * |
73 | if (ret == 0) { | 157 | * Note that for the loops herein, host endianness does not matter |
74 | - tb_invalidate_phys_addr(&address_space_memory, paddr); | ||
75 | + tb_invalidate_phys_addr(&address_space_memory, paddr, | ||
76 | + MEMTXATTRS_UNSPECIFIED); | ||
77 | } | ||
78 | } | ||
79 | |||
80 | -- | 158 | -- |
81 | 2.17.1 | 159 | 2.20.1 |
82 | 160 | ||
83 | 161 | diff view generated by jsdifflib |