1 | Nothing too exciting, but does include the last bits of v8.1M support work. | 1 | This pullreq is (1) my GICv4 patches (2) most of the first third of RTH's |
---|---|---|---|
2 | cleanup patchset (3) one patch fixing an smmuv3 bug... | ||
2 | 3 | ||
4 | thanks | ||
3 | -- PMM | 5 | -- PMM |
4 | 6 | ||
5 | The following changes since commit e79de63ab1bd1f6550e7b915e433bec1ad1a870a: | 7 | The following changes since commit a74782936dc6e979ce371dabda4b1c05624ea87f: |
6 | 8 | ||
7 | Merge remote-tracking branch 'remotes/rth-gitlab/tags/pull-tcg-20210107' into staging (2021-01-07 20:34:05 +0000) | 9 | Merge tag 'pull-migration-20220421a' of https://gitlab.com/dagrh/qemu into staging (2022-04-21 18:48:18 -0700) |
8 | 10 | ||
9 | are available in the Git repository at: | 11 | are available in the Git repository at: |
10 | 12 | ||
11 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20210108 | 13 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20220422 |
12 | 14 | ||
13 | for you to fetch changes up to c9f8511ea8d2b80723af0fea1f716d752c1b5208: | 15 | for you to fetch changes up to 9792130613191c1e0c34109918c5e07b9f1429a5: |
14 | 16 | ||
15 | docs/system: arm: Add sabrelite board description (2021-01-08 15:13:39 +0000) | 17 | hw/arm/smmuv3: Pass the actual perm to returned IOMMUTLBEntry in smmuv3_translate() (2022-04-22 10:19:15 +0100) |
16 | 18 | ||
17 | ---------------------------------------------------------------- | 19 | ---------------------------------------------------------------- |
18 | target-arm queue: | 20 | target-arm queue: |
19 | * intc/arm_gic: Fix gic_irq_signaling_enabled() for vCPUs | 21 | * Implement GICv4 emulation |
20 | * target/arm: Fix MTE0_ACTIVE | 22 | * Some cleanup patches in target/arm |
21 | * target/arm: Implement v8.1M and Cortex-M55 model | 23 | * hw/arm/smmuv3: Pass the actual perm to returned IOMMUTLBEntry in smmuv3_translate() |
22 | * hw/arm/highbank: Drop dead KVM support code | ||
23 | * util/qemu-timer: Make timer_free() imply timer_del() | ||
24 | * various devices: Use ptimer_free() in finalize function | ||
25 | * docs/system: arm: Add sabrelite board description | ||
26 | * sabrelite: Minor fixes to allow booting U-Boot | ||
27 | 24 | ||
28 | ---------------------------------------------------------------- | 25 | ---------------------------------------------------------------- |
29 | Andrew Jones (1): | 26 | Peter Maydell (41): |
30 | hw/arm/virt: Remove virt machine state 'smp_cpus' | 27 | hw/intc/arm_gicv3_its: Add missing blank line |
28 | hw/intc/arm_gicv3: Sanity-check num-cpu property | ||
29 | hw/intc/arm_gicv3: Insist that redist region capacity matches CPU count | ||
30 | hw/intc/arm_gicv3: Report correct PIDR0 values for ID registers | ||
31 | target/arm/cpu.c: ignore VIRQ and VFIQ if no EL2 | ||
32 | hw/intc/arm_gicv3_its: Factor out "is intid a valid LPI ID?" | ||
33 | hw/intc/arm_gicv3_its: Implement GITS_BASER2 for GICv4 | ||
34 | hw/intc/arm_gicv3_its: Implement VMAPI and VMAPTI | ||
35 | hw/intc/arm_gicv3_its: Implement VMAPP | ||
36 | hw/intc/arm_gicv3_its: Distinguish success and error cases of CMD_CONTINUE | ||
37 | hw/intc/arm_gicv3_its: Factor out "find ITE given devid, eventid" | ||
38 | hw/intc/arm_gicv3_its: Factor out CTE lookup sequence | ||
39 | hw/intc/arm_gicv3_its: Split out process_its_cmd() physical interrupt code | ||
40 | hw/intc/arm_gicv3_its: Handle virtual interrupts in process_its_cmd() | ||
41 | hw/intc/arm_gicv3: Keep pointers to every connected ITS | ||
42 | hw/intc/arm_gicv3_its: Implement VMOVP | ||
43 | hw/intc/arm_gicv3_its: Implement VSYNC | ||
44 | hw/intc/arm_gicv3_its: Implement INV command properly | ||
45 | hw/intc/arm_gicv3_its: Implement INV for virtual interrupts | ||
46 | hw/intc/arm_gicv3_its: Implement VMOVI | ||
47 | hw/intc/arm_gicv3_its: Implement VINVALL | ||
48 | hw/intc/arm_gicv3: Implement GICv4's new redistributor frame | ||
49 | hw/intc/arm_gicv3: Implement new GICv4 redistributor registers | ||
50 | hw/intc/arm_gicv3_cpuif: Split "update vIRQ/vFIQ" from gicv3_cpuif_virt_update() | ||
51 | hw/intc/arm_gicv3_cpuif: Support vLPIs | ||
52 | hw/intc/arm_gicv3_cpuif: Don't recalculate maintenance irq unnecessarily | ||
53 | hw/intc/arm_gicv3_redist: Factor out "update hpplpi for one LPI" logic | ||
54 | hw/intc/arm_gicv3_redist: Factor out "update hpplpi for all LPIs" logic | ||
55 | hw/intc/arm_gicv3_redist: Recalculate hppvlpi on VPENDBASER writes | ||
56 | hw/intc/arm_gicv3_redist: Factor out "update bit in pending table" code | ||
57 | hw/intc/arm_gicv3_redist: Implement gicv3_redist_process_vlpi() | ||
58 | hw/intc/arm_gicv3_redist: Implement gicv3_redist_vlpi_pending() | ||
59 | hw/intc/arm_gicv3_redist: Use set_pending_table_bit() in mov handling | ||
60 | hw/intc/arm_gicv3_redist: Implement gicv3_redist_mov_vlpi() | ||
61 | hw/intc/arm_gicv3_redist: Implement gicv3_redist_vinvall() | ||
62 | hw/intc/arm_gicv3_redist: Implement gicv3_redist_inv_vlpi() | ||
63 | hw/intc/arm_gicv3: Update ID and feature registers for GICv4 | ||
64 | hw/intc/arm_gicv3: Allow 'revision' property to be set to 4 | ||
65 | hw/arm/virt: Use VIRT_GIC_VERSION_* enum values in create_gic() | ||
66 | hw/arm/virt: Abstract out calculation of redistributor region capacity | ||
67 | hw/arm/virt: Support TCG GICv4 | ||
31 | 68 | ||
32 | Bin Meng (4): | 69 | Richard Henderson (19): |
33 | hw/misc: imx6_ccm: Update PMU_MISC0 reset value | 70 | target/arm: Update ISAR fields for ARMv8.8 |
34 | hw/msic: imx6_ccm: Correct register value for silicon type | 71 | target/arm: Update SCR_EL3 bits to ARMv8.8 |
35 | hw/arm: sabrelite: Connect the Ethernet PHY at address 6 | 72 | target/arm: Update SCTLR bits to ARMv9.2 |
36 | docs/system: arm: Add sabrelite board description | 73 | target/arm: Change DisasContext.aarch64 to bool |
74 | target/arm: Change CPUArchState.aarch64 to bool | ||
75 | target/arm: Extend store_cpu_offset to take field size | ||
76 | target/arm: Change DisasContext.thumb to bool | ||
77 | target/arm: Change CPUArchState.thumb to bool | ||
78 | target/arm: Remove fpexc32_access | ||
79 | target/arm: Split out set_btype_raw | ||
80 | target/arm: Split out gen_rebuild_hflags | ||
81 | target/arm: Simplify GEN_SHIFT in translate.c | ||
82 | target/arm: Simplify gen_sar | ||
83 | target/arm: Simplify aa32 DISAS_WFI | ||
84 | target/arm: Use tcg_constant in translate-m-nocp.c | ||
85 | target/arm: Use tcg_constant in translate-neon.c | ||
86 | target/arm: Use smin/smax for do_sat_addsub_32 | ||
87 | target/arm: Use tcg_constant in translate-vfp.c | ||
88 | target/arm: Use tcg_constant_i32 in translate.h | ||
37 | 89 | ||
38 | Edgar E. Iglesias (1): | 90 | Xiang Chen (1): |
39 | intc/arm_gic: Fix gic_irq_signaling_enabled() for vCPUs | 91 | hw/arm/smmuv3: Pass the actual perm to returned IOMMUTLBEntry in smmuv3_translate() |
40 | 92 | ||
41 | Gan Qixin (7): | 93 | docs/system/arm/virt.rst | 5 +- |
42 | digic-timer: Use ptimer_free() in the finalize function to avoid memleaks | 94 | hw/intc/gicv3_internal.h | 231 ++++++++- |
43 | allwinner-a10-pit: Use ptimer_free() in the finalize function to avoid memleaks | 95 | include/hw/arm/virt.h | 19 +- |
44 | exynos4210_rtc: Use ptimer_free() in the finalize function to avoid memleaks | 96 | include/hw/intc/arm_gicv3_common.h | 13 + |
45 | exynos4210_pwm: Use ptimer_free() in the finalize function to avoid memleaks | 97 | include/hw/intc/arm_gicv3_its_common.h | 1 + |
46 | mss-timer: Use ptimer_free() in the finalize function to avoid memleaks | 98 | target/arm/cpu.h | 59 ++- |
47 | musicpal: Use ptimer_free() in the finalize function to avoid memleaks | 99 | target/arm/translate-a32.h | 13 +- |
48 | exynos4210_mct: Use ptimer_free() in the finalize function to avoid memleaks | 100 | target/arm/translate.h | 17 +- |
49 | 101 | hw/arm/smmuv3.c | 2 +- | |
50 | Peter Maydell (9): | 102 | hw/arm/virt.c | 102 +++- |
51 | hw/intc/armv7m_nvic: Correct handling of CCR.BFHFNMIGN | 103 | hw/intc/arm_gicv3_common.c | 54 +- |
52 | target/arm: Correct store of FPSCR value via FPCXT_S | 104 | hw/intc/arm_gicv3_cpuif.c | 195 ++++++-- |
53 | target/arm: Implement FPCXT_NS fp system register | 105 | hw/intc/arm_gicv3_dist.c | 7 +- |
54 | target/arm: Implement Cortex-M55 model | 106 | hw/intc/arm_gicv3_its.c | 876 +++++++++++++++++++++++++++------ |
55 | hw/arm/highbank: Drop dead KVM support code | 107 | hw/intc/arm_gicv3_its_kvm.c | 2 + |
56 | util/qemu-timer: Make timer_free() imply timer_del() | 108 | hw/intc/arm_gicv3_kvm.c | 5 + |
57 | scripts/coccinelle: New script to remove unnecessary timer_del() calls | 109 | hw/intc/arm_gicv3_redist.c | 480 +++++++++++++++--- |
58 | Remove superfluous timer_del() calls | 110 | linux-user/arm/cpu_loop.c | 2 +- |
59 | target/arm: Remove timer_del()/timer_deinit() before timer_free() | 111 | target/arm/cpu.c | 16 +- |
60 | 112 | target/arm/helper-a64.c | 4 +- | |
61 | Richard Henderson (1): | 113 | target/arm/helper.c | 19 +- |
62 | target/arm: Fix MTE0_ACTIVE | 114 | target/arm/hvf/hvf.c | 2 +- |
63 | 115 | target/arm/m_helper.c | 6 +- | |
64 | docs/system/arm/sabrelite.rst | 119 ++++++++++++++++++++++++++ | 116 | target/arm/op_helper.c | 13 - |
65 | docs/system/target-arm.rst | 1 + | 117 | target/arm/translate-a64.c | 50 +- |
66 | scripts/coccinelle/timer-del-timer-free.cocci | 18 ++++ | 118 | target/arm/translate-m-nocp.c | 12 +- |
67 | include/hw/arm/virt.h | 3 +- | 119 | target/arm/translate-neon.c | 21 +- |
68 | include/qemu/timer.h | 24 +++--- | 120 | target/arm/translate-sve.c | 9 +- |
69 | block/iscsi.c | 2 - | 121 | target/arm/translate-vfp.c | 76 +-- |
70 | block/nbd.c | 1 - | 122 | target/arm/translate.c | 101 ++-- |
71 | block/qcow2.c | 1 - | 123 | hw/intc/trace-events | 18 +- |
72 | hw/arm/highbank.c | 14 +-- | 124 | 31 files changed, 1890 insertions(+), 540 deletions(-) |
73 | hw/arm/musicpal.c | 12 +++ | ||
74 | hw/arm/sabrelite.c | 4 + | ||
75 | hw/arm/virt-acpi-build.c | 9 +- | ||
76 | hw/arm/virt.c | 21 +++-- | ||
77 | hw/block/nvme.c | 2 - | ||
78 | hw/char/serial.c | 2 - | ||
79 | hw/char/virtio-serial-bus.c | 2 - | ||
80 | hw/ide/core.c | 1 - | ||
81 | hw/input/hid.c | 1 - | ||
82 | hw/intc/apic.c | 1 - | ||
83 | hw/intc/arm_gic.c | 4 +- | ||
84 | hw/intc/armv7m_nvic.c | 15 ++++ | ||
85 | hw/intc/ioapic.c | 1 - | ||
86 | hw/ipmi/ipmi_bmc_extern.c | 1 - | ||
87 | hw/misc/imx6_ccm.c | 4 +- | ||
88 | hw/net/e1000.c | 3 - | ||
89 | hw/net/e1000e_core.c | 8 -- | ||
90 | hw/net/pcnet-pci.c | 1 - | ||
91 | hw/net/rtl8139.c | 1 - | ||
92 | hw/net/spapr_llan.c | 1 - | ||
93 | hw/net/virtio-net.c | 2 - | ||
94 | hw/rtc/exynos4210_rtc.c | 9 ++ | ||
95 | hw/s390x/s390-pci-inst.c | 1 - | ||
96 | hw/sd/sd.c | 1 - | ||
97 | hw/sd/sdhci.c | 2 - | ||
98 | hw/timer/allwinner-a10-pit.c | 11 +++ | ||
99 | hw/timer/digic-timer.c | 8 ++ | ||
100 | hw/timer/exynos4210_mct.c | 14 +++ | ||
101 | hw/timer/exynos4210_pwm.c | 11 +++ | ||
102 | hw/timer/mss-timer.c | 13 +++ | ||
103 | hw/usb/dev-hub.c | 1 - | ||
104 | hw/usb/hcd-ehci.c | 1 - | ||
105 | hw/usb/hcd-ohci-pci.c | 1 - | ||
106 | hw/usb/hcd-uhci.c | 1 - | ||
107 | hw/usb/hcd-xhci.c | 1 - | ||
108 | hw/usb/redirect.c | 1 - | ||
109 | hw/vfio/display.c | 1 - | ||
110 | hw/virtio/vhost-vsock-common.c | 1 - | ||
111 | hw/virtio/virtio-balloon.c | 1 - | ||
112 | hw/virtio/virtio-rng.c | 1 - | ||
113 | hw/watchdog/wdt_diag288.c | 1 - | ||
114 | hw/watchdog/wdt_i6300esb.c | 1 - | ||
115 | migration/colo.c | 1 - | ||
116 | monitor/hmp-cmds.c | 1 - | ||
117 | net/announce.c | 1 - | ||
118 | net/colo-compare.c | 1 - | ||
119 | net/slirp.c | 1 - | ||
120 | replay/replay-debugging.c | 1 - | ||
121 | target/arm/cpu.c | 2 - | ||
122 | target/arm/cpu_tcg.c | 42 +++++++++ | ||
123 | target/arm/helper.c | 2 +- | ||
124 | target/s390x/cpu.c | 2 - | ||
125 | ui/console.c | 1 - | ||
126 | ui/spice-core.c | 1 - | ||
127 | util/throttle.c | 1 - | ||
128 | target/arm/translate-vfp.c.inc | 114 ++++++++++++++++++++++-- | ||
129 | 65 files changed, 421 insertions(+), 111 deletions(-) | ||
130 | create mode 100644 docs/system/arm/sabrelite.rst | ||
131 | create mode 100644 scripts/coccinelle/timer-del-timer-free.cocci | ||
132 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | In commit b6f96009acc we split do_process_its_cmd() from | ||
2 | process_its_cmd(), but forgot the usual blank line between function | ||
3 | definitions. Add it. | ||
1 | 4 | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20220408141550.1271295-2-peter.maydell@linaro.org | ||
8 | --- | ||
9 | hw/intc/arm_gicv3_its.c | 1 + | ||
10 | 1 file changed, 1 insertion(+) | ||
11 | |||
12 | diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/hw/intc/arm_gicv3_its.c | ||
15 | +++ b/hw/intc/arm_gicv3_its.c | ||
16 | @@ -XXX,XX +XXX,XX @@ static ItsCmdResult do_process_its_cmd(GICv3ITSState *s, uint32_t devid, | ||
17 | } | ||
18 | return CMD_CONTINUE; | ||
19 | } | ||
20 | + | ||
21 | static ItsCmdResult process_its_cmd(GICv3ITSState *s, const uint64_t *cmdpkt, | ||
22 | ItsCmdType cmd) | ||
23 | { | ||
24 | -- | ||
25 | 2.25.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | In the GICv3 code we implicitly rely on there being at least one CPU | ||
2 | and thus at least one redistributor and CPU interface. Sanity-check | ||
3 | that the property the board code sets is not zero. | ||
1 | 4 | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20220408141550.1271295-3-peter.maydell@linaro.org | ||
8 | --- | ||
9 | hw/intc/arm_gicv3_common.c | 4 ++++ | ||
10 | 1 file changed, 4 insertions(+) | ||
11 | |||
12 | diff --git a/hw/intc/arm_gicv3_common.c b/hw/intc/arm_gicv3_common.c | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/hw/intc/arm_gicv3_common.c | ||
15 | +++ b/hw/intc/arm_gicv3_common.c | ||
16 | @@ -XXX,XX +XXX,XX @@ static void arm_gicv3_common_realize(DeviceState *dev, Error **errp) | ||
17 | s->num_irq, GIC_INTERNAL); | ||
18 | return; | ||
19 | } | ||
20 | + if (s->num_cpu == 0) { | ||
21 | + error_setg(errp, "num-cpu must be at least 1"); | ||
22 | + return; | ||
23 | + } | ||
24 | |||
25 | /* ITLinesNumber is represented as (N / 32) - 1, so this is an | ||
26 | * implementation imposed restriction, not an architectural one, | ||
27 | -- | ||
28 | 2.25.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Boards using the GICv3 need to configure it with both the total | ||
2 | number of CPUs and also the sizes of all the memory regions which | ||
3 | contain redistributors (one redistributor per CPU). At the moment | ||
4 | the GICv3 checks that the number of CPUs specified is not too many to | ||
5 | fit in the defined redistributor regions, but in fact the code | ||
6 | assumes that the two match exactly. For instance when we set the | ||
7 | GICR_TYPER.Last bit on the final redistributor in each region, we | ||
8 | assume that we don't need to consider the possibility of a region | ||
9 | being only half full of redistributors or even completely empty. We | ||
10 | also assume in gicv3_redist_read() and gicv3_redist_write() that we | ||
11 | can calculate the CPU index from the offset within the MemoryRegion | ||
12 | and that this will always be in range. | ||
1 | 13 | ||
14 | Fortunately all the board code sets the redistributor region sizes to | ||
15 | exactly match the CPU count, so this isn't a visible bug. We could | ||
16 | in theory make the GIC code handle non-full redistributor regions, or | ||
17 | have it automatically reduce the provided region sizes to match the | ||
18 | CPU count, but the simplest thing is just to strengthen the error | ||
19 | check and insist that the CPU count and redistributor region size | ||
20 | settings match exactly, since all the board code does that anyway. | ||
21 | |||
22 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
23 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
24 | Message-id: 20220408141550.1271295-4-peter.maydell@linaro.org | ||
25 | --- | ||
26 | hw/intc/arm_gicv3_common.c | 4 ++-- | ||
27 | 1 file changed, 2 insertions(+), 2 deletions(-) | ||
28 | |||
29 | diff --git a/hw/intc/arm_gicv3_common.c b/hw/intc/arm_gicv3_common.c | ||
30 | index XXXXXXX..XXXXXXX 100644 | ||
31 | --- a/hw/intc/arm_gicv3_common.c | ||
32 | +++ b/hw/intc/arm_gicv3_common.c | ||
33 | @@ -XXX,XX +XXX,XX @@ static void arm_gicv3_common_realize(DeviceState *dev, Error **errp) | ||
34 | for (i = 0; i < s->nb_redist_regions; i++) { | ||
35 | rdist_capacity += s->redist_region_count[i]; | ||
36 | } | ||
37 | - if (rdist_capacity < s->num_cpu) { | ||
38 | + if (rdist_capacity != s->num_cpu) { | ||
39 | error_setg(errp, "Capacity of the redist regions(%d) " | ||
40 | - "is less than number of vcpus(%d)", | ||
41 | + "does not match the number of vcpus(%d)", | ||
42 | rdist_capacity, s->num_cpu); | ||
43 | return; | ||
44 | } | ||
45 | -- | ||
46 | 2.25.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | We use the common function gicv3_idreg() to supply the CoreSight ID | ||
2 | register values for the GICv3 for the copies of these ID registers in | ||
3 | the distributor, redistributor and ITS register frames. This isn't | ||
4 | quite correct, because while most of the register values are the | ||
5 | same, the PIDR0 value should vary to indicate which of these three | ||
6 | frames it is. (You can see this and also the correct values of these | ||
7 | PIDR0 registers by looking at the GIC-600 or GIC-700 TRMs, for | ||
8 | example.) | ||
1 | 9 | ||
10 | Make gicv3_idreg() take an extra argument for the PIDR0 value. | ||
11 | |||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
14 | Message-id: 20220408141550.1271295-5-peter.maydell@linaro.org | ||
15 | --- | ||
16 | hw/intc/gicv3_internal.h | 15 +++++++++++++-- | ||
17 | hw/intc/arm_gicv3_dist.c | 2 +- | ||
18 | hw/intc/arm_gicv3_its.c | 2 +- | ||
19 | hw/intc/arm_gicv3_redist.c | 2 +- | ||
20 | 4 files changed, 16 insertions(+), 5 deletions(-) | ||
21 | |||
22 | diff --git a/hw/intc/gicv3_internal.h b/hw/intc/gicv3_internal.h | ||
23 | index XXXXXXX..XXXXXXX 100644 | ||
24 | --- a/hw/intc/gicv3_internal.h | ||
25 | +++ b/hw/intc/gicv3_internal.h | ||
26 | @@ -XXX,XX +XXX,XX @@ static inline uint32_t gicv3_iidr(void) | ||
27 | return 0x43b; | ||
28 | } | ||
29 | |||
30 | -static inline uint32_t gicv3_idreg(int regoffset) | ||
31 | +/* CoreSight PIDR0 values for ARM GICv3 implementations */ | ||
32 | +#define GICV3_PIDR0_DIST 0x92 | ||
33 | +#define GICV3_PIDR0_REDIST 0x93 | ||
34 | +#define GICV3_PIDR0_ITS 0x94 | ||
35 | + | ||
36 | +static inline uint32_t gicv3_idreg(int regoffset, uint8_t pidr0) | ||
37 | { | ||
38 | /* Return the value of the CoreSight ID register at the specified | ||
39 | * offset from the first ID register (as found in the distributor | ||
40 | @@ -XXX,XX +XXX,XX @@ static inline uint32_t gicv3_idreg(int regoffset) | ||
41 | static const uint8_t gicd_ids[] = { | ||
42 | 0x44, 0x00, 0x00, 0x00, 0x92, 0xB4, 0x3B, 0x00, 0x0D, 0xF0, 0x05, 0xB1 | ||
43 | }; | ||
44 | - return gicd_ids[regoffset / 4]; | ||
45 | + | ||
46 | + regoffset /= 4; | ||
47 | + | ||
48 | + if (regoffset == 4) { | ||
49 | + return pidr0; | ||
50 | + } | ||
51 | + return gicd_ids[regoffset]; | ||
52 | } | ||
53 | |||
54 | /** | ||
55 | diff --git a/hw/intc/arm_gicv3_dist.c b/hw/intc/arm_gicv3_dist.c | ||
56 | index XXXXXXX..XXXXXXX 100644 | ||
57 | --- a/hw/intc/arm_gicv3_dist.c | ||
58 | +++ b/hw/intc/arm_gicv3_dist.c | ||
59 | @@ -XXX,XX +XXX,XX @@ static bool gicd_readl(GICv3State *s, hwaddr offset, | ||
60 | } | ||
61 | case GICD_IDREGS ... GICD_IDREGS + 0x2f: | ||
62 | /* ID registers */ | ||
63 | - *data = gicv3_idreg(offset - GICD_IDREGS); | ||
64 | + *data = gicv3_idreg(offset - GICD_IDREGS, GICV3_PIDR0_DIST); | ||
65 | return true; | ||
66 | case GICD_SGIR: | ||
67 | /* WO registers, return unknown value */ | ||
68 | diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c | ||
69 | index XXXXXXX..XXXXXXX 100644 | ||
70 | --- a/hw/intc/arm_gicv3_its.c | ||
71 | +++ b/hw/intc/arm_gicv3_its.c | ||
72 | @@ -XXX,XX +XXX,XX @@ static bool its_readl(GICv3ITSState *s, hwaddr offset, | ||
73 | break; | ||
74 | case GITS_IDREGS ... GITS_IDREGS + 0x2f: | ||
75 | /* ID registers */ | ||
76 | - *data = gicv3_idreg(offset - GITS_IDREGS); | ||
77 | + *data = gicv3_idreg(offset - GITS_IDREGS, GICV3_PIDR0_ITS); | ||
78 | break; | ||
79 | case GITS_TYPER: | ||
80 | *data = extract64(s->typer, 0, 32); | ||
81 | diff --git a/hw/intc/arm_gicv3_redist.c b/hw/intc/arm_gicv3_redist.c | ||
82 | index XXXXXXX..XXXXXXX 100644 | ||
83 | --- a/hw/intc/arm_gicv3_redist.c | ||
84 | +++ b/hw/intc/arm_gicv3_redist.c | ||
85 | @@ -XXX,XX +XXX,XX @@ static MemTxResult gicr_readl(GICv3CPUState *cs, hwaddr offset, | ||
86 | *data = cs->gicr_nsacr; | ||
87 | return MEMTX_OK; | ||
88 | case GICR_IDREGS ... GICR_IDREGS + 0x2f: | ||
89 | - *data = gicv3_idreg(offset - GICR_IDREGS); | ||
90 | + *data = gicv3_idreg(offset - GICR_IDREGS, GICV3_PIDR0_REDIST); | ||
91 | return MEMTX_OK; | ||
92 | default: | ||
93 | return MEMTX_ERROR; | ||
94 | -- | ||
95 | 2.25.1 | diff view generated by jsdifflib |
1 | The Arm CPU finalize function uses a sequence of timer_del(), timer_deinit(), | 1 | In a GICv3, it is impossible for the GIC to deliver a VIRQ or VFIQ to |
---|---|---|---|
2 | timer_free() to free the timer. The timer_deinit() step in this was always | 2 | the CPU unless the CPU has EL2, because VIRQ and VFIQ are only |
3 | unnecessary, and now the timer_del() is implied by timer_free(), so we can | 3 | configurable via EL2-only system registers. Moreover, in our |
4 | collapse this down to simply calling timer_free(). | 4 | implementation we were only calculating and updating the state of the |
5 | VIRQ and VFIQ lines in gicv3_cpuif_virt_irq_fiq_update() when those | ||
6 | EL2 system registers changed. We were therefore able to assert in | ||
7 | arm_cpu_set_irq() that we didn't see a VIRQ or VFIQ line update if | ||
8 | EL2 wasn't present. | ||
9 | |||
10 | This assumption no longer holds with GICv4: | ||
11 | * even if the CPU does not have EL2 the guest is able to cause the | ||
12 | GIC to deliver a virtual LPI by programming the ITS (which is a | ||
13 | silly thing for it to do, but possible) | ||
14 | * because we now need to recalculate the state of the VIRQ and VFIQ | ||
15 | lines in more cases than just "some EL2 GIC sysreg was written", | ||
16 | we will see calls to arm_cpu_set_irq() for "VIRQ is 0, VFIQ is 0" | ||
17 | even if the guest is not using the virtual LPI parts of the ITS | ||
18 | |||
19 | Remove the assertions, and instead simply ignore the state of the | ||
20 | VIRQ and VFIQ lines if the CPU does not have EL2. | ||
5 | 21 | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 22 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 23 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
9 | Message-id: 20201215154107.3255-5-peter.maydell@linaro.org | 24 | Message-id: 20220408141550.1271295-6-peter.maydell@linaro.org |
10 | --- | 25 | --- |
11 | target/arm/cpu.c | 2 -- | 26 | target/arm/cpu.c | 12 ++++++++++-- |
12 | 1 file changed, 2 deletions(-) | 27 | 1 file changed, 10 insertions(+), 2 deletions(-) |
13 | 28 | ||
14 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | 29 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c |
15 | index XXXXXXX..XXXXXXX 100644 | 30 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/cpu.c | 31 | --- a/target/arm/cpu.c |
17 | +++ b/target/arm/cpu.c | 32 | +++ b/target/arm/cpu.c |
18 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_finalizefn(Object *obj) | 33 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_set_irq(void *opaque, int irq, int level) |
19 | } | 34 | [ARM_CPU_VFIQ] = CPU_INTERRUPT_VFIQ |
20 | #ifndef CONFIG_USER_ONLY | 35 | }; |
21 | if (cpu->pmu_timer) { | 36 | |
22 | - timer_del(cpu->pmu_timer); | 37 | + if (!arm_feature(env, ARM_FEATURE_EL2) && |
23 | - timer_deinit(cpu->pmu_timer); | 38 | + (irq == ARM_CPU_VIRQ || irq == ARM_CPU_VFIQ)) { |
24 | timer_free(cpu->pmu_timer); | 39 | + /* |
25 | } | 40 | + * The GIC might tell us about VIRQ and VFIQ state, but if we don't |
26 | #endif | 41 | + * have EL2 support we don't care. (Unless the guest is doing something |
42 | + * silly this will only be calls saying "level is still 0".) | ||
43 | + */ | ||
44 | + return; | ||
45 | + } | ||
46 | + | ||
47 | if (level) { | ||
48 | env->irq_line_state |= mask[irq]; | ||
49 | } else { | ||
50 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_set_irq(void *opaque, int irq, int level) | ||
51 | |||
52 | switch (irq) { | ||
53 | case ARM_CPU_VIRQ: | ||
54 | - assert(arm_feature(env, ARM_FEATURE_EL2)); | ||
55 | arm_cpu_update_virq(cpu); | ||
56 | break; | ||
57 | case ARM_CPU_VFIQ: | ||
58 | - assert(arm_feature(env, ARM_FEATURE_EL2)); | ||
59 | arm_cpu_update_vfiq(cpu); | ||
60 | break; | ||
61 | case ARM_CPU_IRQ: | ||
27 | -- | 62 | -- |
28 | 2.20.1 | 63 | 2.25.1 |
29 | |||
30 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | In process_mapti() we check interrupt IDs to see whether they are | ||
2 | in the valid LPI range. Factor this out into its own utility | ||
3 | function, as we're going to want it elsewhere too for GICv4. | ||
1 | 4 | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20220408141550.1271295-7-peter.maydell@linaro.org | ||
8 | --- | ||
9 | hw/intc/arm_gicv3_its.c | 10 +++++++--- | ||
10 | 1 file changed, 7 insertions(+), 3 deletions(-) | ||
11 | |||
12 | diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/hw/intc/arm_gicv3_its.c | ||
15 | +++ b/hw/intc/arm_gicv3_its.c | ||
16 | @@ -XXX,XX +XXX,XX @@ typedef enum ItsCmdResult { | ||
17 | CMD_CONTINUE = 1, | ||
18 | } ItsCmdResult; | ||
19 | |||
20 | +static inline bool intid_in_lpi_range(uint32_t id) | ||
21 | +{ | ||
22 | + return id >= GICV3_LPI_INTID_START && | ||
23 | + id < (1 << (GICD_TYPER_IDBITS + 1)); | ||
24 | +} | ||
25 | + | ||
26 | static uint64_t baser_base_addr(uint64_t value, uint32_t page_sz) | ||
27 | { | ||
28 | uint64_t result = 0; | ||
29 | @@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_mapti(GICv3ITSState *s, const uint64_t *cmdpkt, | ||
30 | uint32_t devid, eventid; | ||
31 | uint32_t pIntid = 0; | ||
32 | uint64_t num_eventids; | ||
33 | - uint32_t num_intids; | ||
34 | uint16_t icid = 0; | ||
35 | DTEntry dte; | ||
36 | ITEntry ite; | ||
37 | @@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_mapti(GICv3ITSState *s, const uint64_t *cmdpkt, | ||
38 | return CMD_STALL; | ||
39 | } | ||
40 | num_eventids = 1ULL << (dte.size + 1); | ||
41 | - num_intids = 1ULL << (GICD_TYPER_IDBITS + 1); | ||
42 | |||
43 | if (icid >= s->ct.num_entries) { | ||
44 | qemu_log_mask(LOG_GUEST_ERROR, | ||
45 | @@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_mapti(GICv3ITSState *s, const uint64_t *cmdpkt, | ||
46 | return CMD_CONTINUE; | ||
47 | } | ||
48 | |||
49 | - if (pIntid < GICV3_LPI_INTID_START || pIntid >= num_intids) { | ||
50 | + if (!intid_in_lpi_range(pIntid)) { | ||
51 | qemu_log_mask(LOG_GUEST_ERROR, | ||
52 | "%s: invalid interrupt ID 0x%x\n", __func__, pIntid); | ||
53 | return CMD_CONTINUE; | ||
54 | -- | ||
55 | 2.25.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | The GICv4 defines a new in-guest-memory table for the ITS: this is | ||
2 | the vPE table. Implement the new GITS_BASER2 register which the | ||
3 | guest uses to tell the ITS where the vPE table is located, including | ||
4 | the decode of the register fields into the TableDesc structure which | ||
5 | we do for the GITS_BASER<n> when the guest enables the ITS. | ||
1 | 6 | ||
7 | We guard provision of the new register with the its_feature_virtual() | ||
8 | function, which does a check of the GITS_TYPER.Virtual bit which | ||
9 | indicates presence of ITS support for virtual LPIs. Since this bit | ||
10 | is currently always zero, GICv4-specific features will not be | ||
11 | accessible to the guest yet. | ||
12 | |||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
14 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
15 | Message-id: 20220408141550.1271295-8-peter.maydell@linaro.org | ||
16 | --- | ||
17 | hw/intc/gicv3_internal.h | 16 ++++++++++++++++ | ||
18 | include/hw/intc/arm_gicv3_its_common.h | 1 + | ||
19 | hw/intc/arm_gicv3_its.c | 25 +++++++++++++++++++++++++ | ||
20 | 3 files changed, 42 insertions(+) | ||
21 | |||
22 | diff --git a/hw/intc/gicv3_internal.h b/hw/intc/gicv3_internal.h | ||
23 | index XXXXXXX..XXXXXXX 100644 | ||
24 | --- a/hw/intc/gicv3_internal.h | ||
25 | +++ b/hw/intc/gicv3_internal.h | ||
26 | @@ -XXX,XX +XXX,XX @@ FIELD(GITS_CTLR, ENABLED, 0, 1) | ||
27 | FIELD(GITS_CTLR, QUIESCENT, 31, 1) | ||
28 | |||
29 | FIELD(GITS_TYPER, PHYSICAL, 0, 1) | ||
30 | +FIELD(GITS_TYPER, VIRTUAL, 1, 1) | ||
31 | FIELD(GITS_TYPER, ITT_ENTRY_SIZE, 4, 4) | ||
32 | FIELD(GITS_TYPER, IDBITS, 8, 5) | ||
33 | FIELD(GITS_TYPER, DEVBITS, 13, 5) | ||
34 | @@ -XXX,XX +XXX,XX @@ FIELD(GITS_TYPER, CIL, 36, 1) | ||
35 | #define GITS_BASER_PAGESIZE_64K 2 | ||
36 | |||
37 | #define GITS_BASER_TYPE_DEVICE 1ULL | ||
38 | +#define GITS_BASER_TYPE_VPE 2ULL | ||
39 | #define GITS_BASER_TYPE_COLLECTION 4ULL | ||
40 | |||
41 | #define GITS_PAGE_SIZE_4K 0x1000 | ||
42 | @@ -XXX,XX +XXX,XX @@ FIELD(DTE, ITTADDR, 6, 44) | ||
43 | FIELD(CTE, VALID, 0, 1) | ||
44 | FIELD(CTE, RDBASE, 1, RDBASE_PROCNUM_LENGTH) | ||
45 | |||
46 | +/* | ||
47 | + * 8 bytes VPE table entry size: | ||
48 | + * Valid = 1 bit, VPTsize = 5 bits, VPTaddr = 36 bits, RDbase = 16 bits | ||
49 | + * | ||
50 | + * Field sizes for Valid and size are mandated; field sizes for RDbase | ||
51 | + * and VPT_addr are IMPDEF. | ||
52 | + */ | ||
53 | +#define GITS_VPE_SIZE 0x8ULL | ||
54 | + | ||
55 | +FIELD(VTE, VALID, 0, 1) | ||
56 | +FIELD(VTE, VPTSIZE, 1, 5) | ||
57 | +FIELD(VTE, VPTADDR, 6, 36) | ||
58 | +FIELD(VTE, RDBASE, 42, RDBASE_PROCNUM_LENGTH) | ||
59 | + | ||
60 | /* Special interrupt IDs */ | ||
61 | #define INTID_SECURE 1020 | ||
62 | #define INTID_NONSECURE 1021 | ||
63 | diff --git a/include/hw/intc/arm_gicv3_its_common.h b/include/hw/intc/arm_gicv3_its_common.h | ||
64 | index XXXXXXX..XXXXXXX 100644 | ||
65 | --- a/include/hw/intc/arm_gicv3_its_common.h | ||
66 | +++ b/include/hw/intc/arm_gicv3_its_common.h | ||
67 | @@ -XXX,XX +XXX,XX @@ struct GICv3ITSState { | ||
68 | |||
69 | TableDesc dt; | ||
70 | TableDesc ct; | ||
71 | + TableDesc vpet; | ||
72 | CmdQDesc cq; | ||
73 | |||
74 | Error *migration_blocker; | ||
75 | diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c | ||
76 | index XXXXXXX..XXXXXXX 100644 | ||
77 | --- a/hw/intc/arm_gicv3_its.c | ||
78 | +++ b/hw/intc/arm_gicv3_its.c | ||
79 | @@ -XXX,XX +XXX,XX @@ typedef enum ItsCmdResult { | ||
80 | CMD_CONTINUE = 1, | ||
81 | } ItsCmdResult; | ||
82 | |||
83 | +/* True if the ITS supports the GICv4 virtual LPI feature */ | ||
84 | +static bool its_feature_virtual(GICv3ITSState *s) | ||
85 | +{ | ||
86 | + return s->typer & R_GITS_TYPER_VIRTUAL_MASK; | ||
87 | +} | ||
88 | + | ||
89 | static inline bool intid_in_lpi_range(uint32_t id) | ||
90 | { | ||
91 | return id >= GICV3_LPI_INTID_START && | ||
92 | @@ -XXX,XX +XXX,XX @@ static void extract_table_params(GICv3ITSState *s) | ||
93 | idbits = 16; | ||
94 | } | ||
95 | break; | ||
96 | + case GITS_BASER_TYPE_VPE: | ||
97 | + td = &s->vpet; | ||
98 | + /* | ||
99 | + * For QEMU vPEIDs are always 16 bits. (GICv4.1 allows an | ||
100 | + * implementation to implement fewer bits and report this | ||
101 | + * via GICD_TYPER2.) | ||
102 | + */ | ||
103 | + idbits = 16; | ||
104 | + break; | ||
105 | default: | ||
106 | /* | ||
107 | * GITS_BASER<n>.TYPE is read-only, so GITS_BASER_RO_MASK | ||
108 | @@ -XXX,XX +XXX,XX @@ static void gicv3_its_reset(DeviceState *dev) | ||
109 | /* | ||
110 | * setting GITS_BASER0.Type = 0b001 (Device) | ||
111 | * GITS_BASER1.Type = 0b100 (Collection Table) | ||
112 | + * GITS_BASER2.Type = 0b010 (vPE) for GICv4 and later | ||
113 | * GITS_BASER<n>.Type,where n = 3 to 7 are 0b00 (Unimplemented) | ||
114 | * GITS_BASER<0,1>.Page_Size = 64KB | ||
115 | * and default translation table entry size to 16 bytes | ||
116 | @@ -XXX,XX +XXX,XX @@ static void gicv3_its_reset(DeviceState *dev) | ||
117 | GITS_BASER_PAGESIZE_64K); | ||
118 | s->baser[1] = FIELD_DP64(s->baser[1], GITS_BASER, ENTRYSIZE, | ||
119 | GITS_CTE_SIZE - 1); | ||
120 | + | ||
121 | + if (its_feature_virtual(s)) { | ||
122 | + s->baser[2] = FIELD_DP64(s->baser[2], GITS_BASER, TYPE, | ||
123 | + GITS_BASER_TYPE_VPE); | ||
124 | + s->baser[2] = FIELD_DP64(s->baser[2], GITS_BASER, PAGESIZE, | ||
125 | + GITS_BASER_PAGESIZE_64K); | ||
126 | + s->baser[2] = FIELD_DP64(s->baser[2], GITS_BASER, ENTRYSIZE, | ||
127 | + GITS_VPE_SIZE - 1); | ||
128 | + } | ||
129 | } | ||
130 | |||
131 | static void gicv3_its_post_load(GICv3ITSState *s) | ||
132 | -- | ||
133 | 2.25.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Implement the GICv4 VMAPI and VMAPTI commands. These write | ||
2 | an interrupt translation table entry that maps (DeviceID,EventID) | ||
3 | to (vPEID,vINTID,doorbell). The only difference between VMAPI | ||
4 | and VMAPTI is that VMAPI assumes vINTID == EventID rather than | ||
5 | both being specified in the command packet. | ||
1 | 6 | ||
7 | (This code won't be reachable until we allow the GIC version to be | ||
8 | set to 4. Support for reading this new virtual-interrupt DTE and | ||
9 | handling it correctly will be implemented in a later commit.) | ||
10 | |||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
13 | Message-id: 20220408141550.1271295-9-peter.maydell@linaro.org | ||
14 | --- | ||
15 | hw/intc/gicv3_internal.h | 9 ++++ | ||
16 | hw/intc/arm_gicv3_its.c | 91 ++++++++++++++++++++++++++++++++++++++++ | ||
17 | hw/intc/trace-events | 2 + | ||
18 | 3 files changed, 102 insertions(+) | ||
19 | |||
20 | diff --git a/hw/intc/gicv3_internal.h b/hw/intc/gicv3_internal.h | ||
21 | index XXXXXXX..XXXXXXX 100644 | ||
22 | --- a/hw/intc/gicv3_internal.h | ||
23 | +++ b/hw/intc/gicv3_internal.h | ||
24 | @@ -XXX,XX +XXX,XX @@ FIELD(GITS_TYPER, CIL, 36, 1) | ||
25 | #define GITS_CMD_INVALL 0x0D | ||
26 | #define GITS_CMD_MOVALL 0x0E | ||
27 | #define GITS_CMD_DISCARD 0x0F | ||
28 | +#define GITS_CMD_VMAPTI 0x2A | ||
29 | +#define GITS_CMD_VMAPI 0x2B | ||
30 | |||
31 | /* MAPC command fields */ | ||
32 | #define ICID_LENGTH 16 | ||
33 | @@ -XXX,XX +XXX,XX @@ FIELD(MOVI_0, DEVICEID, 32, 32) | ||
34 | FIELD(MOVI_1, EVENTID, 0, 32) | ||
35 | FIELD(MOVI_2, ICID, 0, 16) | ||
36 | |||
37 | +/* VMAPI, VMAPTI command fields */ | ||
38 | +FIELD(VMAPTI_0, DEVICEID, 32, 32) | ||
39 | +FIELD(VMAPTI_1, EVENTID, 0, 32) | ||
40 | +FIELD(VMAPTI_1, VPEID, 32, 16) | ||
41 | +FIELD(VMAPTI_2, VINTID, 0, 32) /* VMAPTI only */ | ||
42 | +FIELD(VMAPTI_2, DOORBELL, 32, 32) | ||
43 | + | ||
44 | /* | ||
45 | * 12 bytes Interrupt translation Table Entry size | ||
46 | * as per Table 5.3 in GICv3 spec | ||
47 | diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c | ||
48 | index XXXXXXX..XXXXXXX 100644 | ||
49 | --- a/hw/intc/arm_gicv3_its.c | ||
50 | +++ b/hw/intc/arm_gicv3_its.c | ||
51 | @@ -XXX,XX +XXX,XX @@ static inline bool intid_in_lpi_range(uint32_t id) | ||
52 | id < (1 << (GICD_TYPER_IDBITS + 1)); | ||
53 | } | ||
54 | |||
55 | +static inline bool valid_doorbell(uint32_t id) | ||
56 | +{ | ||
57 | + /* Doorbell fields may be an LPI, or 1023 to mean "no doorbell" */ | ||
58 | + return id == INTID_SPURIOUS || intid_in_lpi_range(id); | ||
59 | +} | ||
60 | + | ||
61 | static uint64_t baser_base_addr(uint64_t value, uint32_t page_sz) | ||
62 | { | ||
63 | uint64_t result = 0; | ||
64 | @@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_mapti(GICv3ITSState *s, const uint64_t *cmdpkt, | ||
65 | return update_ite(s, eventid, &dte, &ite) ? CMD_CONTINUE : CMD_STALL; | ||
66 | } | ||
67 | |||
68 | +static ItsCmdResult process_vmapti(GICv3ITSState *s, const uint64_t *cmdpkt, | ||
69 | + bool ignore_vintid) | ||
70 | +{ | ||
71 | + uint32_t devid, eventid, vintid, doorbell, vpeid; | ||
72 | + uint32_t num_eventids; | ||
73 | + DTEntry dte; | ||
74 | + ITEntry ite; | ||
75 | + | ||
76 | + if (!its_feature_virtual(s)) { | ||
77 | + return CMD_CONTINUE; | ||
78 | + } | ||
79 | + | ||
80 | + devid = FIELD_EX64(cmdpkt[0], VMAPTI_0, DEVICEID); | ||
81 | + eventid = FIELD_EX64(cmdpkt[1], VMAPTI_1, EVENTID); | ||
82 | + vpeid = FIELD_EX64(cmdpkt[1], VMAPTI_1, VPEID); | ||
83 | + doorbell = FIELD_EX64(cmdpkt[2], VMAPTI_2, DOORBELL); | ||
84 | + if (ignore_vintid) { | ||
85 | + vintid = eventid; | ||
86 | + trace_gicv3_its_cmd_vmapi(devid, eventid, vpeid, doorbell); | ||
87 | + } else { | ||
88 | + vintid = FIELD_EX64(cmdpkt[2], VMAPTI_2, VINTID); | ||
89 | + trace_gicv3_its_cmd_vmapti(devid, eventid, vpeid, vintid, doorbell); | ||
90 | + } | ||
91 | + | ||
92 | + if (devid >= s->dt.num_entries) { | ||
93 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
94 | + "%s: invalid DeviceID 0x%x (must be less than 0x%x)\n", | ||
95 | + __func__, devid, s->dt.num_entries); | ||
96 | + return CMD_CONTINUE; | ||
97 | + } | ||
98 | + | ||
99 | + if (get_dte(s, devid, &dte) != MEMTX_OK) { | ||
100 | + return CMD_STALL; | ||
101 | + } | ||
102 | + | ||
103 | + if (!dte.valid) { | ||
104 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
105 | + "%s: no entry in device table for DeviceID 0x%x\n", | ||
106 | + __func__, devid); | ||
107 | + return CMD_CONTINUE; | ||
108 | + } | ||
109 | + | ||
110 | + num_eventids = 1ULL << (dte.size + 1); | ||
111 | + | ||
112 | + if (eventid >= num_eventids) { | ||
113 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
114 | + "%s: EventID 0x%x too large for DeviceID 0x%x " | ||
115 | + "(must be less than 0x%x)\n", | ||
116 | + __func__, eventid, devid, num_eventids); | ||
117 | + return CMD_CONTINUE; | ||
118 | + } | ||
119 | + if (!intid_in_lpi_range(vintid)) { | ||
120 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
121 | + "%s: VIntID 0x%x not a valid LPI\n", | ||
122 | + __func__, vintid); | ||
123 | + return CMD_CONTINUE; | ||
124 | + } | ||
125 | + if (!valid_doorbell(doorbell)) { | ||
126 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
127 | + "%s: Doorbell %d not 1023 and not a valid LPI\n", | ||
128 | + __func__, doorbell); | ||
129 | + return CMD_CONTINUE; | ||
130 | + } | ||
131 | + if (vpeid >= s->vpet.num_entries) { | ||
132 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
133 | + "%s: VPEID 0x%x out of range (must be less than 0x%x)\n", | ||
134 | + __func__, vpeid, s->vpet.num_entries); | ||
135 | + return CMD_CONTINUE; | ||
136 | + } | ||
137 | + /* add ite entry to interrupt translation table */ | ||
138 | + ite.valid = true; | ||
139 | + ite.inttype = ITE_INTTYPE_VIRTUAL; | ||
140 | + ite.intid = vintid; | ||
141 | + ite.icid = 0; | ||
142 | + ite.doorbell = doorbell; | ||
143 | + ite.vpeid = vpeid; | ||
144 | + return update_ite(s, eventid, &dte, &ite) ? CMD_CONTINUE : CMD_STALL; | ||
145 | +} | ||
146 | + | ||
147 | /* | ||
148 | * Update the Collection Table entry for @icid to @cte. Returns true | ||
149 | * on success, false if there was a memory access error. | ||
150 | @@ -XXX,XX +XXX,XX @@ static void process_cmdq(GICv3ITSState *s) | ||
151 | case GITS_CMD_MOVALL: | ||
152 | result = process_movall(s, cmdpkt); | ||
153 | break; | ||
154 | + case GITS_CMD_VMAPTI: | ||
155 | + result = process_vmapti(s, cmdpkt, false); | ||
156 | + break; | ||
157 | + case GITS_CMD_VMAPI: | ||
158 | + result = process_vmapti(s, cmdpkt, true); | ||
159 | + break; | ||
160 | default: | ||
161 | trace_gicv3_its_cmd_unknown(cmd); | ||
162 | break; | ||
163 | diff --git a/hw/intc/trace-events b/hw/intc/trace-events | ||
164 | index XXXXXXX..XXXXXXX 100644 | ||
165 | --- a/hw/intc/trace-events | ||
166 | +++ b/hw/intc/trace-events | ||
167 | @@ -XXX,XX +XXX,XX @@ gicv3_its_cmd_mapti(uint32_t devid, uint32_t eventid, uint32_t icid, uint32_t in | ||
168 | gicv3_its_cmd_inv(void) "GICv3 ITS: command INV or INVALL" | ||
169 | gicv3_its_cmd_movall(uint64_t rd1, uint64_t rd2) "GICv3 ITS: command MOVALL RDbase1 0x%" PRIx64 " RDbase2 0x%" PRIx64 | ||
170 | gicv3_its_cmd_movi(uint32_t devid, uint32_t eventid, uint32_t icid) "GICv3 ITS: command MOVI DeviceID 0x%x EventID 0x%x ICID 0x%x" | ||
171 | +gicv3_its_cmd_vmapi(uint32_t devid, uint32_t eventid, uint32_t vpeid, uint32_t doorbell) "GICv3 ITS: command VMAPI DeviceID 0x%x EventID 0x%x vPEID 0x%x Dbell_pINTID 0x%x" | ||
172 | +gicv3_its_cmd_vmapti(uint32_t devid, uint32_t eventid, uint32_t vpeid, uint32_t vintid, uint32_t doorbell) "GICv3 ITS: command VMAPI DeviceID 0x%x EventID 0x%x vPEID 0x%x vINTID 0x%x Dbell_pINTID 0x%x" | ||
173 | gicv3_its_cmd_unknown(unsigned cmd) "GICv3 ITS: unknown command 0x%x" | ||
174 | gicv3_its_cte_read(uint32_t icid, int valid, uint32_t rdbase) "GICv3 ITS: Collection Table read for ICID 0x%x: valid %d RDBase 0x%x" | ||
175 | gicv3_its_cte_write(uint32_t icid, int valid, uint32_t rdbase) "GICv3 ITS: Collection Table write for ICID 0x%x: valid %d RDBase 0x%x" | ||
176 | -- | ||
177 | 2.25.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Implement the GICv4 VMAPP command, which writes an entry to the vPE | ||
2 | table. | ||
1 | 3 | ||
4 | For GICv4.1 this command has extra fields in the command packet | ||
5 | and additional behaviour. We define the 4.1-only fields with the | ||
6 | FIELD macro, but only implement the GICv4.0 version of the command. | ||
7 | |||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
10 | Message-id: 20220408141550.1271295-10-peter.maydell@linaro.org | ||
11 | --- | ||
12 | hw/intc/gicv3_internal.h | 12 ++++++ | ||
13 | hw/intc/arm_gicv3_its.c | 88 ++++++++++++++++++++++++++++++++++++++++ | ||
14 | hw/intc/trace-events | 2 + | ||
15 | 3 files changed, 102 insertions(+) | ||
16 | |||
17 | diff --git a/hw/intc/gicv3_internal.h b/hw/intc/gicv3_internal.h | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/hw/intc/gicv3_internal.h | ||
20 | +++ b/hw/intc/gicv3_internal.h | ||
21 | @@ -XXX,XX +XXX,XX @@ FIELD(GITS_TYPER, CIL, 36, 1) | ||
22 | #define GITS_CMD_INVALL 0x0D | ||
23 | #define GITS_CMD_MOVALL 0x0E | ||
24 | #define GITS_CMD_DISCARD 0x0F | ||
25 | +#define GITS_CMD_VMAPP 0x29 | ||
26 | #define GITS_CMD_VMAPTI 0x2A | ||
27 | #define GITS_CMD_VMAPI 0x2B | ||
28 | |||
29 | @@ -XXX,XX +XXX,XX @@ FIELD(VMAPTI_1, VPEID, 32, 16) | ||
30 | FIELD(VMAPTI_2, VINTID, 0, 32) /* VMAPTI only */ | ||
31 | FIELD(VMAPTI_2, DOORBELL, 32, 32) | ||
32 | |||
33 | +/* VMAPP command fields */ | ||
34 | +FIELD(VMAPP_0, ALLOC, 8, 1) /* GICv4.1 only */ | ||
35 | +FIELD(VMAPP_0, PTZ, 9, 1) /* GICv4.1 only */ | ||
36 | +FIELD(VMAPP_0, VCONFADDR, 16, 36) /* GICv4.1 only */ | ||
37 | +FIELD(VMAPP_1, DEFAULT_DOORBELL, 0, 32) /* GICv4.1 only */ | ||
38 | +FIELD(VMAPP_1, VPEID, 32, 16) | ||
39 | +FIELD(VMAPP_2, RDBASE, 16, 36) | ||
40 | +FIELD(VMAPP_2, V, 63, 1) | ||
41 | +FIELD(VMAPP_3, VPTSIZE, 0, 8) /* For GICv4.0, bits [7:6] are RES0 */ | ||
42 | +FIELD(VMAPP_3, VPTADDR, 16, 36) | ||
43 | + | ||
44 | /* | ||
45 | * 12 bytes Interrupt translation Table Entry size | ||
46 | * as per Table 5.3 in GICv3 spec | ||
47 | diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c | ||
48 | index XXXXXXX..XXXXXXX 100644 | ||
49 | --- a/hw/intc/arm_gicv3_its.c | ||
50 | +++ b/hw/intc/arm_gicv3_its.c | ||
51 | @@ -XXX,XX +XXX,XX @@ typedef struct ITEntry { | ||
52 | uint32_t vpeid; | ||
53 | } ITEntry; | ||
54 | |||
55 | +typedef struct VTEntry { | ||
56 | + bool valid; | ||
57 | + unsigned vptsize; | ||
58 | + uint32_t rdbase; | ||
59 | + uint64_t vptaddr; | ||
60 | +} VTEntry; | ||
61 | |||
62 | /* | ||
63 | * The ITS spec permits a range of CONSTRAINED UNPREDICTABLE options | ||
64 | @@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_movi(GICv3ITSState *s, const uint64_t *cmdpkt) | ||
65 | return update_ite(s, eventid, &dte, &old_ite) ? CMD_CONTINUE : CMD_STALL; | ||
66 | } | ||
67 | |||
68 | +/* | ||
69 | + * Update the vPE Table entry at index @vpeid with the entry @vte. | ||
70 | + * Returns true on success, false if there was a memory access error. | ||
71 | + */ | ||
72 | +static bool update_vte(GICv3ITSState *s, uint32_t vpeid, const VTEntry *vte) | ||
73 | +{ | ||
74 | + AddressSpace *as = &s->gicv3->dma_as; | ||
75 | + uint64_t entry_addr; | ||
76 | + uint64_t vteval = 0; | ||
77 | + MemTxResult res = MEMTX_OK; | ||
78 | + | ||
79 | + trace_gicv3_its_vte_write(vpeid, vte->valid, vte->vptsize, vte->vptaddr, | ||
80 | + vte->rdbase); | ||
81 | + | ||
82 | + if (vte->valid) { | ||
83 | + vteval = FIELD_DP64(vteval, VTE, VALID, 1); | ||
84 | + vteval = FIELD_DP64(vteval, VTE, VPTSIZE, vte->vptsize); | ||
85 | + vteval = FIELD_DP64(vteval, VTE, VPTADDR, vte->vptaddr); | ||
86 | + vteval = FIELD_DP64(vteval, VTE, RDBASE, vte->rdbase); | ||
87 | + } | ||
88 | + | ||
89 | + entry_addr = table_entry_addr(s, &s->vpet, vpeid, &res); | ||
90 | + if (res != MEMTX_OK) { | ||
91 | + return false; | ||
92 | + } | ||
93 | + if (entry_addr == -1) { | ||
94 | + /* No L2 table for this index: discard write and continue */ | ||
95 | + return true; | ||
96 | + } | ||
97 | + address_space_stq_le(as, entry_addr, vteval, MEMTXATTRS_UNSPECIFIED, &res); | ||
98 | + return res == MEMTX_OK; | ||
99 | +} | ||
100 | + | ||
101 | +static ItsCmdResult process_vmapp(GICv3ITSState *s, const uint64_t *cmdpkt) | ||
102 | +{ | ||
103 | + VTEntry vte; | ||
104 | + uint32_t vpeid; | ||
105 | + | ||
106 | + if (!its_feature_virtual(s)) { | ||
107 | + return CMD_CONTINUE; | ||
108 | + } | ||
109 | + | ||
110 | + vpeid = FIELD_EX64(cmdpkt[1], VMAPP_1, VPEID); | ||
111 | + vte.rdbase = FIELD_EX64(cmdpkt[2], VMAPP_2, RDBASE); | ||
112 | + vte.valid = FIELD_EX64(cmdpkt[2], VMAPP_2, V); | ||
113 | + vte.vptsize = FIELD_EX64(cmdpkt[3], VMAPP_3, VPTSIZE); | ||
114 | + vte.vptaddr = FIELD_EX64(cmdpkt[3], VMAPP_3, VPTADDR); | ||
115 | + | ||
116 | + trace_gicv3_its_cmd_vmapp(vpeid, vte.rdbase, vte.valid, | ||
117 | + vte.vptaddr, vte.vptsize); | ||
118 | + | ||
119 | + /* | ||
120 | + * For GICv4.0 the VPT_size field is only 5 bits, whereas we | ||
121 | + * define our field macros to include the full GICv4.1 8 bits. | ||
122 | + * The range check on VPT_size will catch the cases where | ||
123 | + * the guest set the RES0-in-GICv4.0 bits [7:6]. | ||
124 | + */ | ||
125 | + if (vte.vptsize > FIELD_EX64(s->typer, GITS_TYPER, IDBITS)) { | ||
126 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
127 | + "%s: invalid VPT_size 0x%x\n", __func__, vte.vptsize); | ||
128 | + return CMD_CONTINUE; | ||
129 | + } | ||
130 | + | ||
131 | + if (vte.valid && vte.rdbase >= s->gicv3->num_cpu) { | ||
132 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
133 | + "%s: invalid rdbase 0x%x\n", __func__, vte.rdbase); | ||
134 | + return CMD_CONTINUE; | ||
135 | + } | ||
136 | + | ||
137 | + if (vpeid >= s->vpet.num_entries) { | ||
138 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
139 | + "%s: VPEID 0x%x out of range (must be less than 0x%x)\n", | ||
140 | + __func__, vpeid, s->vpet.num_entries); | ||
141 | + return CMD_CONTINUE; | ||
142 | + } | ||
143 | + | ||
144 | + return update_vte(s, vpeid, &vte) ? CMD_CONTINUE : CMD_STALL; | ||
145 | +} | ||
146 | + | ||
147 | /* | ||
148 | * Current implementation blocks until all | ||
149 | * commands are processed | ||
150 | @@ -XXX,XX +XXX,XX @@ static void process_cmdq(GICv3ITSState *s) | ||
151 | case GITS_CMD_VMAPI: | ||
152 | result = process_vmapti(s, cmdpkt, true); | ||
153 | break; | ||
154 | + case GITS_CMD_VMAPP: | ||
155 | + result = process_vmapp(s, cmdpkt); | ||
156 | + break; | ||
157 | default: | ||
158 | trace_gicv3_its_cmd_unknown(cmd); | ||
159 | break; | ||
160 | diff --git a/hw/intc/trace-events b/hw/intc/trace-events | ||
161 | index XXXXXXX..XXXXXXX 100644 | ||
162 | --- a/hw/intc/trace-events | ||
163 | +++ b/hw/intc/trace-events | ||
164 | @@ -XXX,XX +XXX,XX @@ gicv3_its_cmd_movall(uint64_t rd1, uint64_t rd2) "GICv3 ITS: command MOVALL RDba | ||
165 | gicv3_its_cmd_movi(uint32_t devid, uint32_t eventid, uint32_t icid) "GICv3 ITS: command MOVI DeviceID 0x%x EventID 0x%x ICID 0x%x" | ||
166 | gicv3_its_cmd_vmapi(uint32_t devid, uint32_t eventid, uint32_t vpeid, uint32_t doorbell) "GICv3 ITS: command VMAPI DeviceID 0x%x EventID 0x%x vPEID 0x%x Dbell_pINTID 0x%x" | ||
167 | gicv3_its_cmd_vmapti(uint32_t devid, uint32_t eventid, uint32_t vpeid, uint32_t vintid, uint32_t doorbell) "GICv3 ITS: command VMAPI DeviceID 0x%x EventID 0x%x vPEID 0x%x vINTID 0x%x Dbell_pINTID 0x%x" | ||
168 | +gicv3_its_cmd_vmapp(uint32_t vpeid, uint64_t rdbase, int valid, uint64_t vptaddr, uint32_t vptsize) "GICv3 ITS: command VMAPP vPEID 0x%x RDbase 0x%" PRIx64 " V %d VPT_addr 0x%" PRIx64 " VPT_size 0x%x" | ||
169 | gicv3_its_cmd_unknown(unsigned cmd) "GICv3 ITS: unknown command 0x%x" | ||
170 | gicv3_its_cte_read(uint32_t icid, int valid, uint32_t rdbase) "GICv3 ITS: Collection Table read for ICID 0x%x: valid %d RDBase 0x%x" | ||
171 | gicv3_its_cte_write(uint32_t icid, int valid, uint32_t rdbase) "GICv3 ITS: Collection Table write for ICID 0x%x: valid %d RDBase 0x%x" | ||
172 | @@ -XXX,XX +XXX,XX @@ gicv3_its_ite_write(uint64_t ittaddr, uint32_t eventid, int valid, int inttype, | ||
173 | gicv3_its_dte_read(uint32_t devid, int valid, uint32_t size, uint64_t ittaddr) "GICv3 ITS: Device Table read for DeviceID 0x%x: valid %d size 0x%x ITTaddr 0x%" PRIx64 | ||
174 | gicv3_its_dte_write(uint32_t devid, int valid, uint32_t size, uint64_t ittaddr) "GICv3 ITS: Device Table write for DeviceID 0x%x: valid %d size 0x%x ITTaddr 0x%" PRIx64 | ||
175 | gicv3_its_dte_read_fault(uint32_t devid) "GICv3 ITS: Device Table read for DeviceID 0x%x: faulted" | ||
176 | +gicv3_its_vte_write(uint32_t vpeid, int valid, uint32_t vptsize, uint64_t vptaddr, uint32_t rdbase) "GICv3 ITS: vPE Table write for vPEID 0x%x: valid %d VPTsize 0x%x VPTaddr 0x%" PRIx64 " RDbase 0x%x" | ||
177 | |||
178 | # armv7m_nvic.c | ||
179 | nvic_recompute_state(int vectpending, int vectpending_prio, int exception_prio) "NVIC state recomputed: vectpending %d vectpending_prio %d exception_prio %d" | ||
180 | -- | ||
181 | 2.25.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | In the ItsCmdResult enum, we currently distinguish only CMD_STALL | ||
2 | (failure, stall processing of the command queue) and CMD_CONTINUE | ||
3 | (keep processing the queue), and we use the latter both for "there | ||
4 | was a parameter error, go on to the next command" and "the command | ||
5 | succeeded, go on to the next command". Sometimes we would like to | ||
6 | distinguish those two cases, so add CMD_CONTINUE_OK to the enum to | ||
7 | represent the success situation, and use it in the relevant places. | ||
1 | 8 | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
11 | Message-id: 20220408141550.1271295-11-peter.maydell@linaro.org | ||
12 | --- | ||
13 | hw/intc/arm_gicv3_its.c | 29 ++++++++++++++++------------- | ||
14 | 1 file changed, 16 insertions(+), 13 deletions(-) | ||
15 | |||
16 | diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/hw/intc/arm_gicv3_its.c | ||
19 | +++ b/hw/intc/arm_gicv3_its.c | ||
20 | @@ -XXX,XX +XXX,XX @@ typedef struct VTEntry { | ||
21 | * and continue processing. | ||
22 | * The process_* functions which handle individual ITS commands all | ||
23 | * return an ItsCmdResult which tells process_cmdq() whether it should | ||
24 | - * stall or keep going. | ||
25 | + * stall, keep going because of an error, or keep going because the | ||
26 | + * command was a success. | ||
27 | */ | ||
28 | typedef enum ItsCmdResult { | ||
29 | CMD_STALL = 0, | ||
30 | CMD_CONTINUE = 1, | ||
31 | + CMD_CONTINUE_OK = 2, | ||
32 | } ItsCmdResult; | ||
33 | |||
34 | /* True if the ITS supports the GICv4 virtual LPI feature */ | ||
35 | @@ -XXX,XX +XXX,XX @@ static ItsCmdResult do_process_its_cmd(GICv3ITSState *s, uint32_t devid, | ||
36 | ITEntry ite = {}; | ||
37 | /* remove mapping from interrupt translation table */ | ||
38 | ite.valid = false; | ||
39 | - return update_ite(s, eventid, &dte, &ite) ? CMD_CONTINUE : CMD_STALL; | ||
40 | + return update_ite(s, eventid, &dte, &ite) ? CMD_CONTINUE_OK : CMD_STALL; | ||
41 | } | ||
42 | - return CMD_CONTINUE; | ||
43 | + return CMD_CONTINUE_OK; | ||
44 | } | ||
45 | |||
46 | static ItsCmdResult process_its_cmd(GICv3ITSState *s, const uint64_t *cmdpkt, | ||
47 | @@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_mapti(GICv3ITSState *s, const uint64_t *cmdpkt, | ||
48 | ite.icid = icid; | ||
49 | ite.doorbell = INTID_SPURIOUS; | ||
50 | ite.vpeid = 0; | ||
51 | - return update_ite(s, eventid, &dte, &ite) ? CMD_CONTINUE : CMD_STALL; | ||
52 | + return update_ite(s, eventid, &dte, &ite) ? CMD_CONTINUE_OK : CMD_STALL; | ||
53 | } | ||
54 | |||
55 | static ItsCmdResult process_vmapti(GICv3ITSState *s, const uint64_t *cmdpkt, | ||
56 | @@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_vmapti(GICv3ITSState *s, const uint64_t *cmdpkt, | ||
57 | ite.icid = 0; | ||
58 | ite.doorbell = doorbell; | ||
59 | ite.vpeid = vpeid; | ||
60 | - return update_ite(s, eventid, &dte, &ite) ? CMD_CONTINUE : CMD_STALL; | ||
61 | + return update_ite(s, eventid, &dte, &ite) ? CMD_CONTINUE_OK : CMD_STALL; | ||
62 | } | ||
63 | |||
64 | /* | ||
65 | @@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_mapc(GICv3ITSState *s, const uint64_t *cmdpkt) | ||
66 | return CMD_CONTINUE; | ||
67 | } | ||
68 | |||
69 | - return update_cte(s, icid, &cte) ? CMD_CONTINUE : CMD_STALL; | ||
70 | + return update_cte(s, icid, &cte) ? CMD_CONTINUE_OK : CMD_STALL; | ||
71 | } | ||
72 | |||
73 | /* | ||
74 | @@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_mapd(GICv3ITSState *s, const uint64_t *cmdpkt) | ||
75 | return CMD_CONTINUE; | ||
76 | } | ||
77 | |||
78 | - return update_dte(s, devid, &dte) ? CMD_CONTINUE : CMD_STALL; | ||
79 | + return update_dte(s, devid, &dte) ? CMD_CONTINUE_OK : CMD_STALL; | ||
80 | } | ||
81 | |||
82 | static ItsCmdResult process_movall(GICv3ITSState *s, const uint64_t *cmdpkt) | ||
83 | @@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_movall(GICv3ITSState *s, const uint64_t *cmdpkt) | ||
84 | |||
85 | if (rd1 == rd2) { | ||
86 | /* Move to same target must succeed as a no-op */ | ||
87 | - return CMD_CONTINUE; | ||
88 | + return CMD_CONTINUE_OK; | ||
89 | } | ||
90 | |||
91 | /* Move all pending LPIs from redistributor 1 to redistributor 2 */ | ||
92 | gicv3_redist_movall_lpis(&s->gicv3->cpu[rd1], &s->gicv3->cpu[rd2]); | ||
93 | |||
94 | - return CMD_CONTINUE; | ||
95 | + return CMD_CONTINUE_OK; | ||
96 | } | ||
97 | |||
98 | static ItsCmdResult process_movi(GICv3ITSState *s, const uint64_t *cmdpkt) | ||
99 | @@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_movi(GICv3ITSState *s, const uint64_t *cmdpkt) | ||
100 | |||
101 | /* Update the ICID field in the interrupt translation table entry */ | ||
102 | old_ite.icid = new_icid; | ||
103 | - return update_ite(s, eventid, &dte, &old_ite) ? CMD_CONTINUE : CMD_STALL; | ||
104 | + return update_ite(s, eventid, &dte, &old_ite) ? CMD_CONTINUE_OK : CMD_STALL; | ||
105 | } | ||
106 | |||
107 | /* | ||
108 | @@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_vmapp(GICv3ITSState *s, const uint64_t *cmdpkt) | ||
109 | return CMD_CONTINUE; | ||
110 | } | ||
111 | |||
112 | - return update_vte(s, vpeid, &vte) ? CMD_CONTINUE : CMD_STALL; | ||
113 | + return update_vte(s, vpeid, &vte) ? CMD_CONTINUE_OK : CMD_STALL; | ||
114 | } | ||
115 | |||
116 | /* | ||
117 | @@ -XXX,XX +XXX,XX @@ static void process_cmdq(GICv3ITSState *s) | ||
118 | } | ||
119 | |||
120 | while (wr_offset != rd_offset) { | ||
121 | - ItsCmdResult result = CMD_CONTINUE; | ||
122 | + ItsCmdResult result = CMD_CONTINUE_OK; | ||
123 | void *hostmem; | ||
124 | hwaddr buflen; | ||
125 | uint64_t cmdpkt[GITS_CMDQ_ENTRY_WORDS]; | ||
126 | @@ -XXX,XX +XXX,XX @@ static void process_cmdq(GICv3ITSState *s) | ||
127 | trace_gicv3_its_cmd_unknown(cmd); | ||
128 | break; | ||
129 | } | ||
130 | - if (result == CMD_CONTINUE) { | ||
131 | + if (result != CMD_STALL) { | ||
132 | + /* CMD_CONTINUE or CMD_CONTINUE_OK */ | ||
133 | rd_offset++; | ||
134 | rd_offset %= s->cq.num_entries; | ||
135 | s->creadr = FIELD_DP64(s->creadr, GITS_CREADR, OFFSET, rd_offset); | ||
136 | -- | ||
137 | 2.25.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | The operation of finding an interrupt table entry given a (DeviceID, | ||
2 | EventID) pair is necessary in multiple different ITS commands. The | ||
3 | process requires first using the DeviceID as an index into the device | ||
4 | table to find the DTE, and then useng the EventID as an index into | ||
5 | the interrupt table specified by that DTE to find the ITE. We also | ||
6 | need to handle all the possible error cases: indexes out of range, | ||
7 | table memory not readable, table entries not valid. | ||
1 | 8 | ||
9 | Factor this out into a separate lookup_ite() function which we | ||
10 | can then call from the places where we were previously open-coding | ||
11 | this sequence. We'll also need this for some of the new GICv4.0 | ||
12 | commands. | ||
13 | |||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
15 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
16 | Message-id: 20220408141550.1271295-12-peter.maydell@linaro.org | ||
17 | --- | ||
18 | hw/intc/arm_gicv3_its.c | 124 +++++++++++++++++++++------------------- | ||
19 | 1 file changed, 64 insertions(+), 60 deletions(-) | ||
20 | |||
21 | diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c | ||
22 | index XXXXXXX..XXXXXXX 100644 | ||
23 | --- a/hw/intc/arm_gicv3_its.c | ||
24 | +++ b/hw/intc/arm_gicv3_its.c | ||
25 | @@ -XXX,XX +XXX,XX @@ out: | ||
26 | return res; | ||
27 | } | ||
28 | |||
29 | +/* | ||
30 | + * Given a (DeviceID, EventID), look up the corresponding ITE, including | ||
31 | + * checking for the various invalid-value cases. If we find a valid ITE, | ||
32 | + * fill in @ite and @dte and return CMD_CONTINUE_OK. Otherwise return | ||
33 | + * CMD_STALL or CMD_CONTINUE as appropriate (and the contents of @ite | ||
34 | + * should not be relied on). | ||
35 | + * | ||
36 | + * The string @who is purely for the LOG_GUEST_ERROR messages, | ||
37 | + * and should indicate the name of the calling function or similar. | ||
38 | + */ | ||
39 | +static ItsCmdResult lookup_ite(GICv3ITSState *s, const char *who, | ||
40 | + uint32_t devid, uint32_t eventid, ITEntry *ite, | ||
41 | + DTEntry *dte) | ||
42 | +{ | ||
43 | + uint64_t num_eventids; | ||
44 | + | ||
45 | + if (devid >= s->dt.num_entries) { | ||
46 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
47 | + "%s: invalid command attributes: devid %d>=%d", | ||
48 | + who, devid, s->dt.num_entries); | ||
49 | + return CMD_CONTINUE; | ||
50 | + } | ||
51 | + | ||
52 | + if (get_dte(s, devid, dte) != MEMTX_OK) { | ||
53 | + return CMD_STALL; | ||
54 | + } | ||
55 | + if (!dte->valid) { | ||
56 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
57 | + "%s: invalid command attributes: " | ||
58 | + "invalid dte for %d\n", who, devid); | ||
59 | + return CMD_CONTINUE; | ||
60 | + } | ||
61 | + | ||
62 | + num_eventids = 1ULL << (dte->size + 1); | ||
63 | + if (eventid >= num_eventids) { | ||
64 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
65 | + "%s: invalid command attributes: eventid %d >= %" | ||
66 | + PRId64 "\n", who, eventid, num_eventids); | ||
67 | + return CMD_CONTINUE; | ||
68 | + } | ||
69 | + | ||
70 | + if (get_ite(s, eventid, dte, ite) != MEMTX_OK) { | ||
71 | + return CMD_STALL; | ||
72 | + } | ||
73 | + | ||
74 | + if (!ite->valid) { | ||
75 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
76 | + "%s: invalid command attributes: invalid ITE\n", who); | ||
77 | + return CMD_CONTINUE; | ||
78 | + } | ||
79 | + | ||
80 | + return CMD_CONTINUE_OK; | ||
81 | +} | ||
82 | + | ||
83 | /* | ||
84 | * This function handles the processing of following commands based on | ||
85 | * the ItsCmdType parameter passed:- | ||
86 | @@ -XXX,XX +XXX,XX @@ out: | ||
87 | static ItsCmdResult do_process_its_cmd(GICv3ITSState *s, uint32_t devid, | ||
88 | uint32_t eventid, ItsCmdType cmd) | ||
89 | { | ||
90 | - uint64_t num_eventids; | ||
91 | DTEntry dte; | ||
92 | CTEntry cte; | ||
93 | ITEntry ite; | ||
94 | + ItsCmdResult cmdres; | ||
95 | |||
96 | - if (devid >= s->dt.num_entries) { | ||
97 | - qemu_log_mask(LOG_GUEST_ERROR, | ||
98 | - "%s: invalid command attributes: devid %d>=%d", | ||
99 | - __func__, devid, s->dt.num_entries); | ||
100 | - return CMD_CONTINUE; | ||
101 | + cmdres = lookup_ite(s, __func__, devid, eventid, &ite, &dte); | ||
102 | + if (cmdres != CMD_CONTINUE_OK) { | ||
103 | + return cmdres; | ||
104 | } | ||
105 | |||
106 | - if (get_dte(s, devid, &dte) != MEMTX_OK) { | ||
107 | - return CMD_STALL; | ||
108 | - } | ||
109 | - if (!dte.valid) { | ||
110 | - qemu_log_mask(LOG_GUEST_ERROR, | ||
111 | - "%s: invalid command attributes: " | ||
112 | - "invalid dte for %d\n", __func__, devid); | ||
113 | - return CMD_CONTINUE; | ||
114 | - } | ||
115 | - | ||
116 | - num_eventids = 1ULL << (dte.size + 1); | ||
117 | - if (eventid >= num_eventids) { | ||
118 | - qemu_log_mask(LOG_GUEST_ERROR, | ||
119 | - "%s: invalid command attributes: eventid %d >= %" | ||
120 | - PRId64 "\n", | ||
121 | - __func__, eventid, num_eventids); | ||
122 | - return CMD_CONTINUE; | ||
123 | - } | ||
124 | - | ||
125 | - if (get_ite(s, eventid, &dte, &ite) != MEMTX_OK) { | ||
126 | - return CMD_STALL; | ||
127 | - } | ||
128 | - | ||
129 | - if (!ite.valid || ite.inttype != ITE_INTTYPE_PHYSICAL) { | ||
130 | + if (ite.inttype != ITE_INTTYPE_PHYSICAL) { | ||
131 | qemu_log_mask(LOG_GUEST_ERROR, | ||
132 | "%s: invalid command attributes: invalid ITE\n", | ||
133 | __func__); | ||
134 | @@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_movi(GICv3ITSState *s, const uint64_t *cmdpkt) | ||
135 | { | ||
136 | uint32_t devid, eventid; | ||
137 | uint16_t new_icid; | ||
138 | - uint64_t num_eventids; | ||
139 | DTEntry dte; | ||
140 | CTEntry old_cte, new_cte; | ||
141 | ITEntry old_ite; | ||
142 | + ItsCmdResult cmdres; | ||
143 | |||
144 | devid = FIELD_EX64(cmdpkt[0], MOVI_0, DEVICEID); | ||
145 | eventid = FIELD_EX64(cmdpkt[1], MOVI_1, EVENTID); | ||
146 | @@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_movi(GICv3ITSState *s, const uint64_t *cmdpkt) | ||
147 | |||
148 | trace_gicv3_its_cmd_movi(devid, eventid, new_icid); | ||
149 | |||
150 | - if (devid >= s->dt.num_entries) { | ||
151 | - qemu_log_mask(LOG_GUEST_ERROR, | ||
152 | - "%s: invalid command attributes: devid %d>=%d", | ||
153 | - __func__, devid, s->dt.num_entries); | ||
154 | - return CMD_CONTINUE; | ||
155 | - } | ||
156 | - if (get_dte(s, devid, &dte) != MEMTX_OK) { | ||
157 | - return CMD_STALL; | ||
158 | + cmdres = lookup_ite(s, __func__, devid, eventid, &old_ite, &dte); | ||
159 | + if (cmdres != CMD_CONTINUE_OK) { | ||
160 | + return cmdres; | ||
161 | } | ||
162 | |||
163 | - if (!dte.valid) { | ||
164 | - qemu_log_mask(LOG_GUEST_ERROR, | ||
165 | - "%s: invalid command attributes: " | ||
166 | - "invalid dte for %d\n", __func__, devid); | ||
167 | - return CMD_CONTINUE; | ||
168 | - } | ||
169 | - | ||
170 | - num_eventids = 1ULL << (dte.size + 1); | ||
171 | - if (eventid >= num_eventids) { | ||
172 | - qemu_log_mask(LOG_GUEST_ERROR, | ||
173 | - "%s: invalid command attributes: eventid %d >= %" | ||
174 | - PRId64 "\n", | ||
175 | - __func__, eventid, num_eventids); | ||
176 | - return CMD_CONTINUE; | ||
177 | - } | ||
178 | - | ||
179 | - if (get_ite(s, eventid, &dte, &old_ite) != MEMTX_OK) { | ||
180 | - return CMD_STALL; | ||
181 | - } | ||
182 | - | ||
183 | - if (!old_ite.valid || old_ite.inttype != ITE_INTTYPE_PHYSICAL) { | ||
184 | + if (old_ite.inttype != ITE_INTTYPE_PHYSICAL) { | ||
185 | qemu_log_mask(LOG_GUEST_ERROR, | ||
186 | "%s: invalid command attributes: invalid ITE\n", | ||
187 | __func__); | ||
188 | -- | ||
189 | 2.25.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Factor out the sequence of looking up a CTE from an ICID including | ||
2 | the validity and error checks. | ||
1 | 3 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20220408141550.1271295-13-peter.maydell@linaro.org | ||
7 | --- | ||
8 | hw/intc/arm_gicv3_its.c | 109 ++++++++++++++-------------------------- | ||
9 | 1 file changed, 39 insertions(+), 70 deletions(-) | ||
10 | |||
11 | diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c | ||
12 | index XXXXXXX..XXXXXXX 100644 | ||
13 | --- a/hw/intc/arm_gicv3_its.c | ||
14 | +++ b/hw/intc/arm_gicv3_its.c | ||
15 | @@ -XXX,XX +XXX,XX @@ static ItsCmdResult lookup_ite(GICv3ITSState *s, const char *who, | ||
16 | return CMD_CONTINUE_OK; | ||
17 | } | ||
18 | |||
19 | +/* | ||
20 | + * Given an ICID, look up the corresponding CTE, including checking for various | ||
21 | + * invalid-value cases. If we find a valid CTE, fill in @cte and return | ||
22 | + * CMD_CONTINUE_OK; otherwise return CMD_STALL or CMD_CONTINUE (and the | ||
23 | + * contents of @cte should not be relied on). | ||
24 | + * | ||
25 | + * The string @who is purely for the LOG_GUEST_ERROR messages, | ||
26 | + * and should indicate the name of the calling function or similar. | ||
27 | + */ | ||
28 | +static ItsCmdResult lookup_cte(GICv3ITSState *s, const char *who, | ||
29 | + uint32_t icid, CTEntry *cte) | ||
30 | +{ | ||
31 | + if (icid >= s->ct.num_entries) { | ||
32 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: invalid ICID 0x%x\n", who, icid); | ||
33 | + return CMD_CONTINUE; | ||
34 | + } | ||
35 | + if (get_cte(s, icid, cte) != MEMTX_OK) { | ||
36 | + return CMD_STALL; | ||
37 | + } | ||
38 | + if (!cte->valid) { | ||
39 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: invalid CTE\n", who); | ||
40 | + return CMD_CONTINUE; | ||
41 | + } | ||
42 | + if (cte->rdbase >= s->gicv3->num_cpu) { | ||
43 | + return CMD_CONTINUE; | ||
44 | + } | ||
45 | + return CMD_CONTINUE_OK; | ||
46 | +} | ||
47 | + | ||
48 | + | ||
49 | /* | ||
50 | * This function handles the processing of following commands based on | ||
51 | * the ItsCmdType parameter passed:- | ||
52 | @@ -XXX,XX +XXX,XX @@ static ItsCmdResult do_process_its_cmd(GICv3ITSState *s, uint32_t devid, | ||
53 | return CMD_CONTINUE; | ||
54 | } | ||
55 | |||
56 | - if (ite.icid >= s->ct.num_entries) { | ||
57 | - qemu_log_mask(LOG_GUEST_ERROR, | ||
58 | - "%s: invalid ICID 0x%x in ITE (table corrupted?)\n", | ||
59 | - __func__, ite.icid); | ||
60 | - return CMD_CONTINUE; | ||
61 | - } | ||
62 | - | ||
63 | - if (get_cte(s, ite.icid, &cte) != MEMTX_OK) { | ||
64 | - return CMD_STALL; | ||
65 | - } | ||
66 | - if (!cte.valid) { | ||
67 | - qemu_log_mask(LOG_GUEST_ERROR, | ||
68 | - "%s: invalid command attributes: invalid CTE\n", | ||
69 | - __func__); | ||
70 | - return CMD_CONTINUE; | ||
71 | - } | ||
72 | - | ||
73 | - /* | ||
74 | - * Current implementation only supports rdbase == procnum | ||
75 | - * Hence rdbase physical address is ignored | ||
76 | - */ | ||
77 | - if (cte.rdbase >= s->gicv3->num_cpu) { | ||
78 | - return CMD_CONTINUE; | ||
79 | + cmdres = lookup_cte(s, __func__, ite.icid, &cte); | ||
80 | + if (cmdres != CMD_CONTINUE_OK) { | ||
81 | + return cmdres; | ||
82 | } | ||
83 | |||
84 | if ((cmd == CLEAR) || (cmd == DISCARD)) { | ||
85 | @@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_movi(GICv3ITSState *s, const uint64_t *cmdpkt) | ||
86 | return CMD_CONTINUE; | ||
87 | } | ||
88 | |||
89 | - if (old_ite.icid >= s->ct.num_entries) { | ||
90 | - qemu_log_mask(LOG_GUEST_ERROR, | ||
91 | - "%s: invalid ICID 0x%x in ITE (table corrupted?)\n", | ||
92 | - __func__, old_ite.icid); | ||
93 | - return CMD_CONTINUE; | ||
94 | + cmdres = lookup_cte(s, __func__, old_ite.icid, &old_cte); | ||
95 | + if (cmdres != CMD_CONTINUE_OK) { | ||
96 | + return cmdres; | ||
97 | } | ||
98 | - | ||
99 | - if (new_icid >= s->ct.num_entries) { | ||
100 | - qemu_log_mask(LOG_GUEST_ERROR, | ||
101 | - "%s: invalid command attributes: ICID 0x%x\n", | ||
102 | - __func__, new_icid); | ||
103 | - return CMD_CONTINUE; | ||
104 | - } | ||
105 | - | ||
106 | - if (get_cte(s, old_ite.icid, &old_cte) != MEMTX_OK) { | ||
107 | - return CMD_STALL; | ||
108 | - } | ||
109 | - if (!old_cte.valid) { | ||
110 | - qemu_log_mask(LOG_GUEST_ERROR, | ||
111 | - "%s: invalid command attributes: " | ||
112 | - "invalid CTE for old ICID 0x%x\n", | ||
113 | - __func__, old_ite.icid); | ||
114 | - return CMD_CONTINUE; | ||
115 | - } | ||
116 | - | ||
117 | - if (get_cte(s, new_icid, &new_cte) != MEMTX_OK) { | ||
118 | - return CMD_STALL; | ||
119 | - } | ||
120 | - if (!new_cte.valid) { | ||
121 | - qemu_log_mask(LOG_GUEST_ERROR, | ||
122 | - "%s: invalid command attributes: " | ||
123 | - "invalid CTE for new ICID 0x%x\n", | ||
124 | - __func__, new_icid); | ||
125 | - return CMD_CONTINUE; | ||
126 | - } | ||
127 | - | ||
128 | - if (old_cte.rdbase >= s->gicv3->num_cpu) { | ||
129 | - qemu_log_mask(LOG_GUEST_ERROR, | ||
130 | - "%s: CTE has invalid rdbase 0x%x\n", | ||
131 | - __func__, old_cte.rdbase); | ||
132 | - return CMD_CONTINUE; | ||
133 | - } | ||
134 | - | ||
135 | - if (new_cte.rdbase >= s->gicv3->num_cpu) { | ||
136 | - qemu_log_mask(LOG_GUEST_ERROR, | ||
137 | - "%s: CTE has invalid rdbase 0x%x\n", | ||
138 | - __func__, new_cte.rdbase); | ||
139 | - return CMD_CONTINUE; | ||
140 | + cmdres = lookup_cte(s, __func__, new_icid, &new_cte); | ||
141 | + if (cmdres != CMD_CONTINUE_OK) { | ||
142 | + return cmdres; | ||
143 | } | ||
144 | |||
145 | if (old_cte.rdbase != new_cte.rdbase) { | ||
146 | -- | ||
147 | 2.25.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Split the part of process_its_cmd() which is specific to physical | ||
2 | interrupts into its own function. This is the part which starts by | ||
3 | taking the ICID and looking it up in the collection table. The | ||
4 | handling of virtual interrupts is significantly different (involving | ||
5 | a lookup in the vPE table) so structuring the code with one | ||
6 | sub-function for the physical interrupt case and one for the virtual | ||
7 | interrupt case will be clearer than putting both cases in one large | ||
8 | function. | ||
1 | 9 | ||
10 | The code for handling the "remove mapping from ITE" for the DISCARD | ||
11 | command remains in process_its_cmd() because it is common to both | ||
12 | virtual and physical interrupts. | ||
13 | |||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
15 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
16 | Message-id: 20220408141550.1271295-14-peter.maydell@linaro.org | ||
17 | --- | ||
18 | hw/intc/arm_gicv3_its.c | 51 ++++++++++++++++++++++++++--------------- | ||
19 | 1 file changed, 33 insertions(+), 18 deletions(-) | ||
20 | |||
21 | diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c | ||
22 | index XXXXXXX..XXXXXXX 100644 | ||
23 | --- a/hw/intc/arm_gicv3_its.c | ||
24 | +++ b/hw/intc/arm_gicv3_its.c | ||
25 | @@ -XXX,XX +XXX,XX @@ static ItsCmdResult lookup_cte(GICv3ITSState *s, const char *who, | ||
26 | return CMD_CONTINUE_OK; | ||
27 | } | ||
28 | |||
29 | +static ItsCmdResult process_its_cmd_phys(GICv3ITSState *s, const ITEntry *ite, | ||
30 | + int irqlevel) | ||
31 | +{ | ||
32 | + CTEntry cte; | ||
33 | + ItsCmdResult cmdres; | ||
34 | + | ||
35 | + cmdres = lookup_cte(s, __func__, ite->icid, &cte); | ||
36 | + if (cmdres != CMD_CONTINUE_OK) { | ||
37 | + return cmdres; | ||
38 | + } | ||
39 | + gicv3_redist_process_lpi(&s->gicv3->cpu[cte.rdbase], ite->intid, irqlevel); | ||
40 | + return CMD_CONTINUE_OK; | ||
41 | +} | ||
42 | |||
43 | /* | ||
44 | * This function handles the processing of following commands based on | ||
45 | @@ -XXX,XX +XXX,XX @@ static ItsCmdResult do_process_its_cmd(GICv3ITSState *s, uint32_t devid, | ||
46 | uint32_t eventid, ItsCmdType cmd) | ||
47 | { | ||
48 | DTEntry dte; | ||
49 | - CTEntry cte; | ||
50 | ITEntry ite; | ||
51 | ItsCmdResult cmdres; | ||
52 | + int irqlevel; | ||
53 | |||
54 | cmdres = lookup_ite(s, __func__, devid, eventid, &ite, &dte); | ||
55 | if (cmdres != CMD_CONTINUE_OK) { | ||
56 | return cmdres; | ||
57 | } | ||
58 | |||
59 | - if (ite.inttype != ITE_INTTYPE_PHYSICAL) { | ||
60 | - qemu_log_mask(LOG_GUEST_ERROR, | ||
61 | - "%s: invalid command attributes: invalid ITE\n", | ||
62 | - __func__); | ||
63 | - return CMD_CONTINUE; | ||
64 | + irqlevel = (cmd == CLEAR || cmd == DISCARD) ? 0 : 1; | ||
65 | + | ||
66 | + switch (ite.inttype) { | ||
67 | + case ITE_INTTYPE_PHYSICAL: | ||
68 | + cmdres = process_its_cmd_phys(s, &ite, irqlevel); | ||
69 | + break; | ||
70 | + case ITE_INTTYPE_VIRTUAL: | ||
71 | + if (!its_feature_virtual(s)) { | ||
72 | + /* Can't happen unless guest is illegally writing to table memory */ | ||
73 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
74 | + "%s: invalid type %d in ITE (table corrupted?)\n", | ||
75 | + __func__, ite.inttype); | ||
76 | + return CMD_CONTINUE; | ||
77 | + } | ||
78 | + /* The GICv4 virtual interrupt handling will go here */ | ||
79 | + g_assert_not_reached(); | ||
80 | + default: | ||
81 | + g_assert_not_reached(); | ||
82 | } | ||
83 | |||
84 | - cmdres = lookup_cte(s, __func__, ite.icid, &cte); | ||
85 | - if (cmdres != CMD_CONTINUE_OK) { | ||
86 | - return cmdres; | ||
87 | - } | ||
88 | - | ||
89 | - if ((cmd == CLEAR) || (cmd == DISCARD)) { | ||
90 | - gicv3_redist_process_lpi(&s->gicv3->cpu[cte.rdbase], ite.intid, 0); | ||
91 | - } else { | ||
92 | - gicv3_redist_process_lpi(&s->gicv3->cpu[cte.rdbase], ite.intid, 1); | ||
93 | - } | ||
94 | - | ||
95 | - if (cmd == DISCARD) { | ||
96 | + if (cmdres == CMD_CONTINUE_OK && cmd == DISCARD) { | ||
97 | ITEntry ite = {}; | ||
98 | /* remove mapping from interrupt translation table */ | ||
99 | ite.valid = false; | ||
100 | -- | ||
101 | 2.25.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | For GICv4, interrupt table entries read by process_its_cmd() may | ||
2 | indicate virtual LPIs which are to be directly injected into a VM. | ||
3 | Implement the ITS side of the code for handling this. This is | ||
4 | similar to the existing handling of physical LPIs, but instead of | ||
5 | looking up a collection ID in a collection table, we look up a vPEID | ||
6 | in a vPE table. As with the physical LPIs, we leave the rest of the | ||
7 | work to code in the redistributor device. | ||
1 | 8 | ||
9 | The redistributor half will be implemented in a later commit; | ||
10 | for now we just provide a stub function which does nothing. | ||
11 | |||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
14 | Message-id: 20220408141550.1271295-15-peter.maydell@linaro.org | ||
15 | --- | ||
16 | hw/intc/gicv3_internal.h | 17 +++++++ | ||
17 | hw/intc/arm_gicv3_its.c | 99 +++++++++++++++++++++++++++++++++++++- | ||
18 | hw/intc/arm_gicv3_redist.c | 9 ++++ | ||
19 | hw/intc/trace-events | 2 + | ||
20 | 4 files changed, 125 insertions(+), 2 deletions(-) | ||
21 | |||
22 | diff --git a/hw/intc/gicv3_internal.h b/hw/intc/gicv3_internal.h | ||
23 | index XXXXXXX..XXXXXXX 100644 | ||
24 | --- a/hw/intc/gicv3_internal.h | ||
25 | +++ b/hw/intc/gicv3_internal.h | ||
26 | @@ -XXX,XX +XXX,XX @@ MemTxResult gicv3_redist_write(void *opaque, hwaddr offset, uint64_t data, | ||
27 | void gicv3_dist_set_irq(GICv3State *s, int irq, int level); | ||
28 | void gicv3_redist_set_irq(GICv3CPUState *cs, int irq, int level); | ||
29 | void gicv3_redist_process_lpi(GICv3CPUState *cs, int irq, int level); | ||
30 | +/** | ||
31 | + * gicv3_redist_process_vlpi: | ||
32 | + * @cs: GICv3CPUState | ||
33 | + * @irq: (virtual) interrupt number | ||
34 | + * @vptaddr: (guest) address of VLPI table | ||
35 | + * @doorbell: doorbell (physical) interrupt number (1023 for "no doorbell") | ||
36 | + * @level: level to set @irq to | ||
37 | + * | ||
38 | + * Process a virtual LPI being directly injected by the ITS. This function | ||
39 | + * will update the VLPI table specified by @vptaddr and @vptsize. If the | ||
40 | + * vCPU corresponding to that VLPI table is currently running on | ||
41 | + * the CPU associated with this redistributor, directly inject the VLPI | ||
42 | + * @irq. If the vCPU is not running on this CPU, raise the doorbell | ||
43 | + * interrupt instead. | ||
44 | + */ | ||
45 | +void gicv3_redist_process_vlpi(GICv3CPUState *cs, int irq, uint64_t vptaddr, | ||
46 | + int doorbell, int level); | ||
47 | void gicv3_redist_lpi_pending(GICv3CPUState *cs, int irq, int level); | ||
48 | /** | ||
49 | * gicv3_redist_update_lpi: | ||
50 | diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c | ||
51 | index XXXXXXX..XXXXXXX 100644 | ||
52 | --- a/hw/intc/arm_gicv3_its.c | ||
53 | +++ b/hw/intc/arm_gicv3_its.c | ||
54 | @@ -XXX,XX +XXX,XX @@ out: | ||
55 | return res; | ||
56 | } | ||
57 | |||
58 | +/* | ||
59 | + * Read the vPE Table entry at index @vpeid. On success (including | ||
60 | + * successfully determining that there is no valid entry for this index), | ||
61 | + * we return MEMTX_OK and populate the VTEntry struct accordingly. | ||
62 | + * If there is an error reading memory then we return the error code. | ||
63 | + */ | ||
64 | +static MemTxResult get_vte(GICv3ITSState *s, uint32_t vpeid, VTEntry *vte) | ||
65 | +{ | ||
66 | + MemTxResult res = MEMTX_OK; | ||
67 | + AddressSpace *as = &s->gicv3->dma_as; | ||
68 | + uint64_t entry_addr = table_entry_addr(s, &s->vpet, vpeid, &res); | ||
69 | + uint64_t vteval; | ||
70 | + | ||
71 | + if (entry_addr == -1) { | ||
72 | + /* No L2 table entry, i.e. no valid VTE, or a memory error */ | ||
73 | + vte->valid = false; | ||
74 | + goto out; | ||
75 | + } | ||
76 | + vteval = address_space_ldq_le(as, entry_addr, MEMTXATTRS_UNSPECIFIED, &res); | ||
77 | + if (res != MEMTX_OK) { | ||
78 | + goto out; | ||
79 | + } | ||
80 | + vte->valid = FIELD_EX64(vteval, VTE, VALID); | ||
81 | + vte->vptsize = FIELD_EX64(vteval, VTE, VPTSIZE); | ||
82 | + vte->vptaddr = FIELD_EX64(vteval, VTE, VPTADDR); | ||
83 | + vte->rdbase = FIELD_EX64(vteval, VTE, RDBASE); | ||
84 | +out: | ||
85 | + if (res != MEMTX_OK) { | ||
86 | + trace_gicv3_its_vte_read_fault(vpeid); | ||
87 | + } else { | ||
88 | + trace_gicv3_its_vte_read(vpeid, vte->valid, vte->vptsize, | ||
89 | + vte->vptaddr, vte->rdbase); | ||
90 | + } | ||
91 | + return res; | ||
92 | +} | ||
93 | + | ||
94 | /* | ||
95 | * Given a (DeviceID, EventID), look up the corresponding ITE, including | ||
96 | * checking for the various invalid-value cases. If we find a valid ITE, | ||
97 | @@ -XXX,XX +XXX,XX @@ static ItsCmdResult lookup_cte(GICv3ITSState *s, const char *who, | ||
98 | return CMD_CONTINUE_OK; | ||
99 | } | ||
100 | |||
101 | +/* | ||
102 | + * Given a VPEID, look up the corresponding VTE, including checking | ||
103 | + * for various invalid-value cases. if we find a valid VTE, fill in @vte | ||
104 | + * and return CMD_CONTINUE_OK; otherwise return CMD_STALL or CMD_CONTINUE | ||
105 | + * (and the contents of @vte should not be relied on). | ||
106 | + * | ||
107 | + * The string @who is purely for the LOG_GUEST_ERROR messages, | ||
108 | + * and should indicate the name of the calling function or similar. | ||
109 | + */ | ||
110 | +static ItsCmdResult lookup_vte(GICv3ITSState *s, const char *who, | ||
111 | + uint32_t vpeid, VTEntry *vte) | ||
112 | +{ | ||
113 | + if (vpeid >= s->vpet.num_entries) { | ||
114 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: invalid VPEID 0x%x\n", who, vpeid); | ||
115 | + return CMD_CONTINUE; | ||
116 | + } | ||
117 | + | ||
118 | + if (get_vte(s, vpeid, vte) != MEMTX_OK) { | ||
119 | + return CMD_STALL; | ||
120 | + } | ||
121 | + if (!vte->valid) { | ||
122 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
123 | + "%s: invalid VTE for VPEID 0x%x\n", who, vpeid); | ||
124 | + return CMD_CONTINUE; | ||
125 | + } | ||
126 | + | ||
127 | + if (vte->rdbase >= s->gicv3->num_cpu) { | ||
128 | + return CMD_CONTINUE; | ||
129 | + } | ||
130 | + return CMD_CONTINUE_OK; | ||
131 | +} | ||
132 | + | ||
133 | static ItsCmdResult process_its_cmd_phys(GICv3ITSState *s, const ITEntry *ite, | ||
134 | int irqlevel) | ||
135 | { | ||
136 | @@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_its_cmd_phys(GICv3ITSState *s, const ITEntry *ite, | ||
137 | return CMD_CONTINUE_OK; | ||
138 | } | ||
139 | |||
140 | +static ItsCmdResult process_its_cmd_virt(GICv3ITSState *s, const ITEntry *ite, | ||
141 | + int irqlevel) | ||
142 | +{ | ||
143 | + VTEntry vte; | ||
144 | + ItsCmdResult cmdres; | ||
145 | + | ||
146 | + cmdres = lookup_vte(s, __func__, ite->vpeid, &vte); | ||
147 | + if (cmdres != CMD_CONTINUE_OK) { | ||
148 | + return cmdres; | ||
149 | + } | ||
150 | + | ||
151 | + if (!intid_in_lpi_range(ite->intid) || | ||
152 | + ite->intid >= (1ULL << (vte.vptsize + 1))) { | ||
153 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: intid 0x%x out of range\n", | ||
154 | + __func__, ite->intid); | ||
155 | + return CMD_CONTINUE; | ||
156 | + } | ||
157 | + | ||
158 | + /* | ||
159 | + * For QEMU the actual pending of the vLPI is handled in the | ||
160 | + * redistributor code | ||
161 | + */ | ||
162 | + gicv3_redist_process_vlpi(&s->gicv3->cpu[vte.rdbase], ite->intid, | ||
163 | + vte.vptaddr << 16, ite->doorbell, irqlevel); | ||
164 | + return CMD_CONTINUE_OK; | ||
165 | +} | ||
166 | + | ||
167 | /* | ||
168 | * This function handles the processing of following commands based on | ||
169 | * the ItsCmdType parameter passed:- | ||
170 | @@ -XXX,XX +XXX,XX @@ static ItsCmdResult do_process_its_cmd(GICv3ITSState *s, uint32_t devid, | ||
171 | __func__, ite.inttype); | ||
172 | return CMD_CONTINUE; | ||
173 | } | ||
174 | - /* The GICv4 virtual interrupt handling will go here */ | ||
175 | - g_assert_not_reached(); | ||
176 | + cmdres = process_its_cmd_virt(s, &ite, irqlevel); | ||
177 | + break; | ||
178 | default: | ||
179 | g_assert_not_reached(); | ||
180 | } | ||
181 | diff --git a/hw/intc/arm_gicv3_redist.c b/hw/intc/arm_gicv3_redist.c | ||
182 | index XXXXXXX..XXXXXXX 100644 | ||
183 | --- a/hw/intc/arm_gicv3_redist.c | ||
184 | +++ b/hw/intc/arm_gicv3_redist.c | ||
185 | @@ -XXX,XX +XXX,XX @@ void gicv3_redist_movall_lpis(GICv3CPUState *src, GICv3CPUState *dest) | ||
186 | gicv3_redist_update_lpi(dest); | ||
187 | } | ||
188 | |||
189 | +void gicv3_redist_process_vlpi(GICv3CPUState *cs, int irq, uint64_t vptaddr, | ||
190 | + int doorbell, int level) | ||
191 | +{ | ||
192 | + /* | ||
193 | + * The redistributor handling for being handed a VLPI by the ITS | ||
194 | + * will be added in a subsequent commit. | ||
195 | + */ | ||
196 | +} | ||
197 | + | ||
198 | void gicv3_redist_set_irq(GICv3CPUState *cs, int irq, int level) | ||
199 | { | ||
200 | /* Update redistributor state for a change in an external PPI input line */ | ||
201 | diff --git a/hw/intc/trace-events b/hw/intc/trace-events | ||
202 | index XXXXXXX..XXXXXXX 100644 | ||
203 | --- a/hw/intc/trace-events | ||
204 | +++ b/hw/intc/trace-events | ||
205 | @@ -XXX,XX +XXX,XX @@ gicv3_its_ite_write(uint64_t ittaddr, uint32_t eventid, int valid, int inttype, | ||
206 | gicv3_its_dte_read(uint32_t devid, int valid, uint32_t size, uint64_t ittaddr) "GICv3 ITS: Device Table read for DeviceID 0x%x: valid %d size 0x%x ITTaddr 0x%" PRIx64 | ||
207 | gicv3_its_dte_write(uint32_t devid, int valid, uint32_t size, uint64_t ittaddr) "GICv3 ITS: Device Table write for DeviceID 0x%x: valid %d size 0x%x ITTaddr 0x%" PRIx64 | ||
208 | gicv3_its_dte_read_fault(uint32_t devid) "GICv3 ITS: Device Table read for DeviceID 0x%x: faulted" | ||
209 | +gicv3_its_vte_read(uint32_t vpeid, int valid, uint32_t vptsize, uint64_t vptaddr, uint32_t rdbase) "GICv3 ITS: vPE Table read for vPEID 0x%x: valid %d VPTsize 0x%x VPTaddr 0x%" PRIx64 " RDbase 0x%x" | ||
210 | +gicv3_its_vte_read_fault(uint32_t vpeid) "GICv3 ITS: vPE Table read for vPEID 0x%x: faulted" | ||
211 | gicv3_its_vte_write(uint32_t vpeid, int valid, uint32_t vptsize, uint64_t vptaddr, uint32_t rdbase) "GICv3 ITS: vPE Table write for vPEID 0x%x: valid %d VPTsize 0x%x VPTaddr 0x%" PRIx64 " RDbase 0x%x" | ||
212 | |||
213 | # armv7m_nvic.c | ||
214 | -- | ||
215 | 2.25.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | The GICv4 ITS VMOVP command's semantics require it to perform the | ||
2 | operation on every ITS connected to the same GIC that the ITS that | ||
3 | received the command is attached to. This means that the GIC object | ||
4 | needs to keep a pointer to every ITS that is connected to it | ||
5 | (previously it was sufficient for the ITS to have a pointer to its | ||
6 | GIC). | ||
1 | 7 | ||
8 | Add a glib ptrarray to the GICv3 object which holds pointers to every | ||
9 | connected ITS, and make the ITS add itself to the array for the GIC | ||
10 | it is connected to when it is realized. | ||
11 | |||
12 | Note that currently all QEMU machine types with an ITS have exactly | ||
13 | one ITS in the system, so typically the length of this ptrarray will | ||
14 | be 1. Multiple ITSes are typically used to improve performance on | ||
15 | real hardware, so we wouldn't need to have more than one unless we | ||
16 | were modelling a real machine type that had multile ITSes. | ||
17 | |||
18 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
19 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
20 | Message-id: 20220408141550.1271295-16-peter.maydell@linaro.org | ||
21 | --- | ||
22 | hw/intc/gicv3_internal.h | 9 +++++++++ | ||
23 | include/hw/intc/arm_gicv3_common.h | 2 ++ | ||
24 | hw/intc/arm_gicv3_common.c | 2 ++ | ||
25 | hw/intc/arm_gicv3_its.c | 2 ++ | ||
26 | hw/intc/arm_gicv3_its_kvm.c | 2 ++ | ||
27 | 5 files changed, 17 insertions(+) | ||
28 | |||
29 | diff --git a/hw/intc/gicv3_internal.h b/hw/intc/gicv3_internal.h | ||
30 | index XXXXXXX..XXXXXXX 100644 | ||
31 | --- a/hw/intc/gicv3_internal.h | ||
32 | +++ b/hw/intc/gicv3_internal.h | ||
33 | @@ -XXX,XX +XXX,XX @@ static inline void gicv3_cache_all_target_cpustates(GICv3State *s) | ||
34 | |||
35 | void gicv3_set_gicv3state(CPUState *cpu, GICv3CPUState *s); | ||
36 | |||
37 | +/* | ||
38 | + * The ITS should call this when it is realized to add itself | ||
39 | + * to its GIC's list of connected ITSes. | ||
40 | + */ | ||
41 | +static inline void gicv3_add_its(GICv3State *s, DeviceState *its) | ||
42 | +{ | ||
43 | + g_ptr_array_add(s->itslist, its); | ||
44 | +} | ||
45 | + | ||
46 | #endif /* QEMU_ARM_GICV3_INTERNAL_H */ | ||
47 | diff --git a/include/hw/intc/arm_gicv3_common.h b/include/hw/intc/arm_gicv3_common.h | ||
48 | index XXXXXXX..XXXXXXX 100644 | ||
49 | --- a/include/hw/intc/arm_gicv3_common.h | ||
50 | +++ b/include/hw/intc/arm_gicv3_common.h | ||
51 | @@ -XXX,XX +XXX,XX @@ struct GICv3State { | ||
52 | uint32_t gicd_nsacr[DIV_ROUND_UP(GICV3_MAXIRQ, 16)]; | ||
53 | |||
54 | GICv3CPUState *cpu; | ||
55 | + /* List of all ITSes connected to this GIC */ | ||
56 | + GPtrArray *itslist; | ||
57 | }; | ||
58 | |||
59 | #define GICV3_BITMAP_ACCESSORS(BMP) \ | ||
60 | diff --git a/hw/intc/arm_gicv3_common.c b/hw/intc/arm_gicv3_common.c | ||
61 | index XXXXXXX..XXXXXXX 100644 | ||
62 | --- a/hw/intc/arm_gicv3_common.c | ||
63 | +++ b/hw/intc/arm_gicv3_common.c | ||
64 | @@ -XXX,XX +XXX,XX @@ static void arm_gicv3_common_realize(DeviceState *dev, Error **errp) | ||
65 | cpuidx += s->redist_region_count[i]; | ||
66 | s->cpu[cpuidx - 1].gicr_typer |= GICR_TYPER_LAST; | ||
67 | } | ||
68 | + | ||
69 | + s->itslist = g_ptr_array_new(); | ||
70 | } | ||
71 | |||
72 | static void arm_gicv3_finalize(Object *obj) | ||
73 | diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c | ||
74 | index XXXXXXX..XXXXXXX 100644 | ||
75 | --- a/hw/intc/arm_gicv3_its.c | ||
76 | +++ b/hw/intc/arm_gicv3_its.c | ||
77 | @@ -XXX,XX +XXX,XX @@ static void gicv3_arm_its_realize(DeviceState *dev, Error **errp) | ||
78 | } | ||
79 | } | ||
80 | |||
81 | + gicv3_add_its(s->gicv3, dev); | ||
82 | + | ||
83 | gicv3_its_init_mmio(s, &gicv3_its_control_ops, &gicv3_its_translation_ops); | ||
84 | |||
85 | /* set the ITS default features supported */ | ||
86 | diff --git a/hw/intc/arm_gicv3_its_kvm.c b/hw/intc/arm_gicv3_its_kvm.c | ||
87 | index XXXXXXX..XXXXXXX 100644 | ||
88 | --- a/hw/intc/arm_gicv3_its_kvm.c | ||
89 | +++ b/hw/intc/arm_gicv3_its_kvm.c | ||
90 | @@ -XXX,XX +XXX,XX @@ static void kvm_arm_its_realize(DeviceState *dev, Error **errp) | ||
91 | kvm_arm_register_device(&s->iomem_its_cntrl, -1, KVM_DEV_ARM_VGIC_GRP_ADDR, | ||
92 | KVM_VGIC_ITS_ADDR_TYPE, s->dev_fd, 0); | ||
93 | |||
94 | + gicv3_add_its(s->gicv3, dev); | ||
95 | + | ||
96 | gicv3_its_init_mmio(s, NULL, NULL); | ||
97 | |||
98 | if (!kvm_device_check_attr(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_ITS_REGS, | ||
99 | -- | ||
100 | 2.25.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Implement the GICv4 VMOVP command, which updates an entry in the vPE | ||
2 | table to change its rdbase field. This command is unique in the ITS | ||
3 | command set because its effects must be propagated to all the other | ||
4 | ITSes connected to the same GIC as the ITS which executes the VMOVP | ||
5 | command. | ||
1 | 6 | ||
7 | The GICv4 spec allows two implementation choices for handling the | ||
8 | propagation to other ITSes: | ||
9 | * If GITS_TYPER.VMOVP is 1, the guest only needs to issue the command | ||
10 | on one ITS, and the implementation handles the propagation to | ||
11 | all ITSes | ||
12 | * If GITS_TYPER.VMOVP is 0, the guest must issue the command on | ||
13 | every ITS, and arrange for the ITSes to synchronize the updates | ||
14 | with each other by setting ITSList and Sequence Number fields | ||
15 | in the command packets | ||
16 | |||
17 | We choose the GITS_TYPER.VMOVP = 1 approach, and synchronously | ||
18 | execute the update on every ITS. | ||
19 | |||
20 | For GICv4.1 this command has extra fields in the command packet and | ||
21 | additional behaviour. We define the 4.1-only fields with the FIELD | ||
22 | macro, but only implement the GICv4.0 version of the command. | ||
23 | |||
24 | Note that we don't update the reported GITS_TYPER value here; | ||
25 | we'll do that later in a commit which updates all the reported | ||
26 | feature bit and ID register values for GICv4. | ||
27 | |||
28 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
29 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
30 | Message-id: 20220408141550.1271295-17-peter.maydell@linaro.org | ||
31 | --- | ||
32 | hw/intc/gicv3_internal.h | 18 ++++++++++ | ||
33 | hw/intc/arm_gicv3_its.c | 75 ++++++++++++++++++++++++++++++++++++++++ | ||
34 | hw/intc/trace-events | 1 + | ||
35 | 3 files changed, 94 insertions(+) | ||
36 | |||
37 | diff --git a/hw/intc/gicv3_internal.h b/hw/intc/gicv3_internal.h | ||
38 | index XXXXXXX..XXXXXXX 100644 | ||
39 | --- a/hw/intc/gicv3_internal.h | ||
40 | +++ b/hw/intc/gicv3_internal.h | ||
41 | @@ -XXX,XX +XXX,XX @@ FIELD(GITS_TYPER, CIL, 36, 1) | ||
42 | #define GITS_CMD_INVALL 0x0D | ||
43 | #define GITS_CMD_MOVALL 0x0E | ||
44 | #define GITS_CMD_DISCARD 0x0F | ||
45 | +#define GITS_CMD_VMOVP 0x22 | ||
46 | #define GITS_CMD_VMAPP 0x29 | ||
47 | #define GITS_CMD_VMAPTI 0x2A | ||
48 | #define GITS_CMD_VMAPI 0x2B | ||
49 | @@ -XXX,XX +XXX,XX @@ FIELD(VMAPP_2, V, 63, 1) | ||
50 | FIELD(VMAPP_3, VPTSIZE, 0, 8) /* For GICv4.0, bits [7:6] are RES0 */ | ||
51 | FIELD(VMAPP_3, VPTADDR, 16, 36) | ||
52 | |||
53 | +/* VMOVP command fields */ | ||
54 | +FIELD(VMOVP_0, SEQNUM, 32, 16) /* not used for GITS_TYPER.VMOVP == 1 */ | ||
55 | +FIELD(VMOVP_1, ITSLIST, 0, 16) /* not used for GITS_TYPER.VMOVP == 1 */ | ||
56 | +FIELD(VMOVP_1, VPEID, 32, 16) | ||
57 | +FIELD(VMOVP_2, RDBASE, 16, 36) | ||
58 | +FIELD(VMOVP_2, DB, 63, 1) /* GICv4.1 only */ | ||
59 | +FIELD(VMOVP_3, DEFAULT_DOORBELL, 0, 32) /* GICv4.1 only */ | ||
60 | + | ||
61 | /* | ||
62 | * 12 bytes Interrupt translation Table Entry size | ||
63 | * as per Table 5.3 in GICv3 spec | ||
64 | @@ -XXX,XX +XXX,XX @@ static inline void gicv3_add_its(GICv3State *s, DeviceState *its) | ||
65 | g_ptr_array_add(s->itslist, its); | ||
66 | } | ||
67 | |||
68 | +/* | ||
69 | + * The ITS can use this for operations that must be performed on | ||
70 | + * every ITS connected to the same GIC that it is | ||
71 | + */ | ||
72 | +static inline void gicv3_foreach_its(GICv3State *s, GFunc func, void *opaque) | ||
73 | +{ | ||
74 | + g_ptr_array_foreach(s->itslist, func, opaque); | ||
75 | +} | ||
76 | + | ||
77 | #endif /* QEMU_ARM_GICV3_INTERNAL_H */ | ||
78 | diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c | ||
79 | index XXXXXXX..XXXXXXX 100644 | ||
80 | --- a/hw/intc/arm_gicv3_its.c | ||
81 | +++ b/hw/intc/arm_gicv3_its.c | ||
82 | @@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_vmapp(GICv3ITSState *s, const uint64_t *cmdpkt) | ||
83 | return update_vte(s, vpeid, &vte) ? CMD_CONTINUE_OK : CMD_STALL; | ||
84 | } | ||
85 | |||
86 | +typedef struct VmovpCallbackData { | ||
87 | + uint64_t rdbase; | ||
88 | + uint32_t vpeid; | ||
89 | + /* | ||
90 | + * Overall command result. If more than one callback finds an | ||
91 | + * error, STALL beats CONTINUE. | ||
92 | + */ | ||
93 | + ItsCmdResult result; | ||
94 | +} VmovpCallbackData; | ||
95 | + | ||
96 | +static void vmovp_callback(gpointer data, gpointer opaque) | ||
97 | +{ | ||
98 | + /* | ||
99 | + * This function is called to update the VPEID field in a VPE | ||
100 | + * table entry for this ITS. This might be because of a VMOVP | ||
101 | + * command executed on any ITS that is connected to the same GIC | ||
102 | + * as this ITS. We need to read the VPE table entry for the VPEID | ||
103 | + * and update its RDBASE field. | ||
104 | + */ | ||
105 | + GICv3ITSState *s = data; | ||
106 | + VmovpCallbackData *cbdata = opaque; | ||
107 | + VTEntry vte; | ||
108 | + ItsCmdResult cmdres; | ||
109 | + | ||
110 | + cmdres = lookup_vte(s, __func__, cbdata->vpeid, &vte); | ||
111 | + switch (cmdres) { | ||
112 | + case CMD_STALL: | ||
113 | + cbdata->result = CMD_STALL; | ||
114 | + return; | ||
115 | + case CMD_CONTINUE: | ||
116 | + if (cbdata->result != CMD_STALL) { | ||
117 | + cbdata->result = CMD_CONTINUE; | ||
118 | + } | ||
119 | + return; | ||
120 | + case CMD_CONTINUE_OK: | ||
121 | + break; | ||
122 | + } | ||
123 | + | ||
124 | + vte.rdbase = cbdata->rdbase; | ||
125 | + if (!update_vte(s, cbdata->vpeid, &vte)) { | ||
126 | + cbdata->result = CMD_STALL; | ||
127 | + } | ||
128 | +} | ||
129 | + | ||
130 | +static ItsCmdResult process_vmovp(GICv3ITSState *s, const uint64_t *cmdpkt) | ||
131 | +{ | ||
132 | + VmovpCallbackData cbdata; | ||
133 | + | ||
134 | + if (!its_feature_virtual(s)) { | ||
135 | + return CMD_CONTINUE; | ||
136 | + } | ||
137 | + | ||
138 | + cbdata.vpeid = FIELD_EX64(cmdpkt[1], VMOVP_1, VPEID); | ||
139 | + cbdata.rdbase = FIELD_EX64(cmdpkt[2], VMOVP_2, RDBASE); | ||
140 | + | ||
141 | + trace_gicv3_its_cmd_vmovp(cbdata.vpeid, cbdata.rdbase); | ||
142 | + | ||
143 | + if (cbdata.rdbase >= s->gicv3->num_cpu) { | ||
144 | + return CMD_CONTINUE; | ||
145 | + } | ||
146 | + | ||
147 | + /* | ||
148 | + * Our ITS implementation reports GITS_TYPER.VMOVP == 1, which means | ||
149 | + * that when the VMOVP command is executed on an ITS to change the | ||
150 | + * VPEID field in a VPE table entry the change must be propagated | ||
151 | + * to all the ITSes connected to the same GIC. | ||
152 | + */ | ||
153 | + cbdata.result = CMD_CONTINUE_OK; | ||
154 | + gicv3_foreach_its(s->gicv3, vmovp_callback, &cbdata); | ||
155 | + return cbdata.result; | ||
156 | +} | ||
157 | + | ||
158 | /* | ||
159 | * Current implementation blocks until all | ||
160 | * commands are processed | ||
161 | @@ -XXX,XX +XXX,XX @@ static void process_cmdq(GICv3ITSState *s) | ||
162 | case GITS_CMD_VMAPP: | ||
163 | result = process_vmapp(s, cmdpkt); | ||
164 | break; | ||
165 | + case GITS_CMD_VMOVP: | ||
166 | + result = process_vmovp(s, cmdpkt); | ||
167 | + break; | ||
168 | default: | ||
169 | trace_gicv3_its_cmd_unknown(cmd); | ||
170 | break; | ||
171 | diff --git a/hw/intc/trace-events b/hw/intc/trace-events | ||
172 | index XXXXXXX..XXXXXXX 100644 | ||
173 | --- a/hw/intc/trace-events | ||
174 | +++ b/hw/intc/trace-events | ||
175 | @@ -XXX,XX +XXX,XX @@ gicv3_its_cmd_movi(uint32_t devid, uint32_t eventid, uint32_t icid) "GICv3 ITS: | ||
176 | gicv3_its_cmd_vmapi(uint32_t devid, uint32_t eventid, uint32_t vpeid, uint32_t doorbell) "GICv3 ITS: command VMAPI DeviceID 0x%x EventID 0x%x vPEID 0x%x Dbell_pINTID 0x%x" | ||
177 | gicv3_its_cmd_vmapti(uint32_t devid, uint32_t eventid, uint32_t vpeid, uint32_t vintid, uint32_t doorbell) "GICv3 ITS: command VMAPI DeviceID 0x%x EventID 0x%x vPEID 0x%x vINTID 0x%x Dbell_pINTID 0x%x" | ||
178 | gicv3_its_cmd_vmapp(uint32_t vpeid, uint64_t rdbase, int valid, uint64_t vptaddr, uint32_t vptsize) "GICv3 ITS: command VMAPP vPEID 0x%x RDbase 0x%" PRIx64 " V %d VPT_addr 0x%" PRIx64 " VPT_size 0x%x" | ||
179 | +gicv3_its_cmd_vmovp(uint32_t vpeid, uint64_t rdbase) "GICv3 ITS: command VMOVP vPEID 0x%x RDbase 0x%" PRIx64 | ||
180 | gicv3_its_cmd_unknown(unsigned cmd) "GICv3 ITS: unknown command 0x%x" | ||
181 | gicv3_its_cte_read(uint32_t icid, int valid, uint32_t rdbase) "GICv3 ITS: Collection Table read for ICID 0x%x: valid %d RDBase 0x%x" | ||
182 | gicv3_its_cte_write(uint32_t icid, int valid, uint32_t rdbase) "GICv3 ITS: Collection Table write for ICID 0x%x: valid %d RDBase 0x%x" | ||
183 | -- | ||
184 | 2.25.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | The VSYNC command forces the ITS to synchronize all outstanding ITS | ||
2 | operations for the specified vPEID, so that subsequent writes to | ||
3 | GITS_TRANSLATER honour them. The QEMU implementation is always in | ||
4 | sync, so for us this is a nop, like the existing SYNC command. | ||
1 | 5 | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20220408141550.1271295-18-peter.maydell@linaro.org | ||
9 | --- | ||
10 | hw/intc/gicv3_internal.h | 1 + | ||
11 | hw/intc/arm_gicv3_its.c | 11 +++++++++++ | ||
12 | hw/intc/trace-events | 1 + | ||
13 | 3 files changed, 13 insertions(+) | ||
14 | |||
15 | diff --git a/hw/intc/gicv3_internal.h b/hw/intc/gicv3_internal.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/hw/intc/gicv3_internal.h | ||
18 | +++ b/hw/intc/gicv3_internal.h | ||
19 | @@ -XXX,XX +XXX,XX @@ FIELD(GITS_TYPER, CIL, 36, 1) | ||
20 | #define GITS_CMD_MOVALL 0x0E | ||
21 | #define GITS_CMD_DISCARD 0x0F | ||
22 | #define GITS_CMD_VMOVP 0x22 | ||
23 | +#define GITS_CMD_VSYNC 0x25 | ||
24 | #define GITS_CMD_VMAPP 0x29 | ||
25 | #define GITS_CMD_VMAPTI 0x2A | ||
26 | #define GITS_CMD_VMAPI 0x2B | ||
27 | diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c | ||
28 | index XXXXXXX..XXXXXXX 100644 | ||
29 | --- a/hw/intc/arm_gicv3_its.c | ||
30 | +++ b/hw/intc/arm_gicv3_its.c | ||
31 | @@ -XXX,XX +XXX,XX @@ static void process_cmdq(GICv3ITSState *s) | ||
32 | */ | ||
33 | trace_gicv3_its_cmd_sync(); | ||
34 | break; | ||
35 | + case GITS_CMD_VSYNC: | ||
36 | + /* | ||
37 | + * VSYNC also is a nop, because our implementation is always | ||
38 | + * in sync. | ||
39 | + */ | ||
40 | + if (!its_feature_virtual(s)) { | ||
41 | + result = CMD_CONTINUE; | ||
42 | + break; | ||
43 | + } | ||
44 | + trace_gicv3_its_cmd_vsync(); | ||
45 | + break; | ||
46 | case GITS_CMD_MAPD: | ||
47 | result = process_mapd(s, cmdpkt); | ||
48 | break; | ||
49 | diff --git a/hw/intc/trace-events b/hw/intc/trace-events | ||
50 | index XXXXXXX..XXXXXXX 100644 | ||
51 | --- a/hw/intc/trace-events | ||
52 | +++ b/hw/intc/trace-events | ||
53 | @@ -XXX,XX +XXX,XX @@ gicv3_its_cmd_vmapi(uint32_t devid, uint32_t eventid, uint32_t vpeid, uint32_t d | ||
54 | gicv3_its_cmd_vmapti(uint32_t devid, uint32_t eventid, uint32_t vpeid, uint32_t vintid, uint32_t doorbell) "GICv3 ITS: command VMAPI DeviceID 0x%x EventID 0x%x vPEID 0x%x vINTID 0x%x Dbell_pINTID 0x%x" | ||
55 | gicv3_its_cmd_vmapp(uint32_t vpeid, uint64_t rdbase, int valid, uint64_t vptaddr, uint32_t vptsize) "GICv3 ITS: command VMAPP vPEID 0x%x RDbase 0x%" PRIx64 " V %d VPT_addr 0x%" PRIx64 " VPT_size 0x%x" | ||
56 | gicv3_its_cmd_vmovp(uint32_t vpeid, uint64_t rdbase) "GICv3 ITS: command VMOVP vPEID 0x%x RDbase 0x%" PRIx64 | ||
57 | +gicv3_its_cmd_vsync(void) "GICv3 ITS: command VSYNC" | ||
58 | gicv3_its_cmd_unknown(unsigned cmd) "GICv3 ITS: unknown command 0x%x" | ||
59 | gicv3_its_cte_read(uint32_t icid, int valid, uint32_t rdbase) "GICv3 ITS: Collection Table read for ICID 0x%x: valid %d RDBase 0x%x" | ||
60 | gicv3_its_cte_write(uint32_t icid, int valid, uint32_t rdbase) "GICv3 ITS: Collection Table write for ICID 0x%x: valid %d RDBase 0x%x" | ||
61 | -- | ||
62 | 2.25.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | We were previously implementing INV (like INVALL) to just blow away | ||
2 | cached highest-priority-pending-LPI information on all connected | ||
3 | redistributors. For GICv4.0, this isn't going to be sufficient, | ||
4 | because the LPI we are invalidating cached information for might be | ||
5 | either physical or virtual, and the required action is different for | ||
6 | those two cases. So we need to do the full process of looking up the | ||
7 | ITE from the devid and eventid. This also means we can do the error | ||
8 | checks that the spec lists for this command. | ||
1 | 9 | ||
10 | Split out INV handling into a process_inv() function like our other | ||
11 | command-processing functions. For the moment, stick to handling only | ||
12 | physical LPIs; we will add the vLPI parts later. | ||
13 | |||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
15 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
16 | Message-id: 20220408141550.1271295-19-peter.maydell@linaro.org | ||
17 | --- | ||
18 | hw/intc/gicv3_internal.h | 12 +++++++++ | ||
19 | hw/intc/arm_gicv3_its.c | 50 +++++++++++++++++++++++++++++++++++++- | ||
20 | hw/intc/arm_gicv3_redist.c | 11 +++++++++ | ||
21 | hw/intc/trace-events | 3 ++- | ||
22 | 4 files changed, 74 insertions(+), 2 deletions(-) | ||
23 | |||
24 | diff --git a/hw/intc/gicv3_internal.h b/hw/intc/gicv3_internal.h | ||
25 | index XXXXXXX..XXXXXXX 100644 | ||
26 | --- a/hw/intc/gicv3_internal.h | ||
27 | +++ b/hw/intc/gicv3_internal.h | ||
28 | @@ -XXX,XX +XXX,XX @@ FIELD(MOVI_0, DEVICEID, 32, 32) | ||
29 | FIELD(MOVI_1, EVENTID, 0, 32) | ||
30 | FIELD(MOVI_2, ICID, 0, 16) | ||
31 | |||
32 | +/* INV command fields */ | ||
33 | +FIELD(INV_0, DEVICEID, 32, 32) | ||
34 | +FIELD(INV_1, EVENTID, 0, 32) | ||
35 | + | ||
36 | /* VMAPI, VMAPTI command fields */ | ||
37 | FIELD(VMAPTI_0, DEVICEID, 32, 32) | ||
38 | FIELD(VMAPTI_1, EVENTID, 0, 32) | ||
39 | @@ -XXX,XX +XXX,XX @@ void gicv3_redist_update_lpi(GICv3CPUState *cs); | ||
40 | * an incoming migration has loaded new state. | ||
41 | */ | ||
42 | void gicv3_redist_update_lpi_only(GICv3CPUState *cs); | ||
43 | +/** | ||
44 | + * gicv3_redist_inv_lpi: | ||
45 | + * @cs: GICv3CPUState | ||
46 | + * @irq: LPI to invalidate cached information for | ||
47 | + * | ||
48 | + * Forget or update any cached information associated with this LPI. | ||
49 | + */ | ||
50 | +void gicv3_redist_inv_lpi(GICv3CPUState *cs, int irq); | ||
51 | /** | ||
52 | * gicv3_redist_mov_lpi: | ||
53 | * @src: source redistributor | ||
54 | diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c | ||
55 | index XXXXXXX..XXXXXXX 100644 | ||
56 | --- a/hw/intc/arm_gicv3_its.c | ||
57 | +++ b/hw/intc/arm_gicv3_its.c | ||
58 | @@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_vmovp(GICv3ITSState *s, const uint64_t *cmdpkt) | ||
59 | return cbdata.result; | ||
60 | } | ||
61 | |||
62 | +static ItsCmdResult process_inv(GICv3ITSState *s, const uint64_t *cmdpkt) | ||
63 | +{ | ||
64 | + uint32_t devid, eventid; | ||
65 | + ITEntry ite; | ||
66 | + DTEntry dte; | ||
67 | + CTEntry cte; | ||
68 | + ItsCmdResult cmdres; | ||
69 | + | ||
70 | + devid = FIELD_EX64(cmdpkt[0], INV_0, DEVICEID); | ||
71 | + eventid = FIELD_EX64(cmdpkt[1], INV_1, EVENTID); | ||
72 | + | ||
73 | + trace_gicv3_its_cmd_inv(devid, eventid); | ||
74 | + | ||
75 | + cmdres = lookup_ite(s, __func__, devid, eventid, &ite, &dte); | ||
76 | + if (cmdres != CMD_CONTINUE_OK) { | ||
77 | + return cmdres; | ||
78 | + } | ||
79 | + | ||
80 | + switch (ite.inttype) { | ||
81 | + case ITE_INTTYPE_PHYSICAL: | ||
82 | + cmdres = lookup_cte(s, __func__, ite.icid, &cte); | ||
83 | + if (cmdres != CMD_CONTINUE_OK) { | ||
84 | + return cmdres; | ||
85 | + } | ||
86 | + gicv3_redist_inv_lpi(&s->gicv3->cpu[cte.rdbase], ite.intid); | ||
87 | + break; | ||
88 | + case ITE_INTTYPE_VIRTUAL: | ||
89 | + if (!its_feature_virtual(s)) { | ||
90 | + /* Can't happen unless guest is illegally writing to table memory */ | ||
91 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
92 | + "%s: invalid type %d in ITE (table corrupted?)\n", | ||
93 | + __func__, ite.inttype); | ||
94 | + return CMD_CONTINUE; | ||
95 | + } | ||
96 | + /* We will implement the vLPI invalidation in a later commit */ | ||
97 | + g_assert_not_reached(); | ||
98 | + break; | ||
99 | + default: | ||
100 | + g_assert_not_reached(); | ||
101 | + } | ||
102 | + | ||
103 | + return CMD_CONTINUE_OK; | ||
104 | +} | ||
105 | + | ||
106 | /* | ||
107 | * Current implementation blocks until all | ||
108 | * commands are processed | ||
109 | @@ -XXX,XX +XXX,XX @@ static void process_cmdq(GICv3ITSState *s) | ||
110 | result = process_its_cmd(s, cmdpkt, DISCARD); | ||
111 | break; | ||
112 | case GITS_CMD_INV: | ||
113 | + result = process_inv(s, cmdpkt); | ||
114 | + break; | ||
115 | case GITS_CMD_INVALL: | ||
116 | /* | ||
117 | * Current implementation doesn't cache any ITS tables, | ||
118 | * but the calculated lpi priority information. We only | ||
119 | * need to trigger lpi priority re-calculation to be in | ||
120 | * sync with LPI config table or pending table changes. | ||
121 | + * INVALL operates on a collection specified by ICID so | ||
122 | + * it only affects physical LPIs. | ||
123 | */ | ||
124 | - trace_gicv3_its_cmd_inv(); | ||
125 | + trace_gicv3_its_cmd_invall(); | ||
126 | for (i = 0; i < s->gicv3->num_cpu; i++) { | ||
127 | gicv3_redist_update_lpi(&s->gicv3->cpu[i]); | ||
128 | } | ||
129 | diff --git a/hw/intc/arm_gicv3_redist.c b/hw/intc/arm_gicv3_redist.c | ||
130 | index XXXXXXX..XXXXXXX 100644 | ||
131 | --- a/hw/intc/arm_gicv3_redist.c | ||
132 | +++ b/hw/intc/arm_gicv3_redist.c | ||
133 | @@ -XXX,XX +XXX,XX @@ void gicv3_redist_process_lpi(GICv3CPUState *cs, int irq, int level) | ||
134 | gicv3_redist_lpi_pending(cs, irq, level); | ||
135 | } | ||
136 | |||
137 | +void gicv3_redist_inv_lpi(GICv3CPUState *cs, int irq) | ||
138 | +{ | ||
139 | + /* | ||
140 | + * The only cached information for LPIs we have is the HPPLPI. | ||
141 | + * We could be cleverer about identifying when we don't need | ||
142 | + * to do a full rescan of the pending table, but until we find | ||
143 | + * this is a performance issue, just always recalculate. | ||
144 | + */ | ||
145 | + gicv3_redist_update_lpi(cs); | ||
146 | +} | ||
147 | + | ||
148 | void gicv3_redist_mov_lpi(GICv3CPUState *src, GICv3CPUState *dest, int irq) | ||
149 | { | ||
150 | /* | ||
151 | diff --git a/hw/intc/trace-events b/hw/intc/trace-events | ||
152 | index XXXXXXX..XXXXXXX 100644 | ||
153 | --- a/hw/intc/trace-events | ||
154 | +++ b/hw/intc/trace-events | ||
155 | @@ -XXX,XX +XXX,XX @@ gicv3_its_cmd_mapd(uint32_t devid, uint32_t size, uint64_t ittaddr, int valid) " | ||
156 | gicv3_its_cmd_mapc(uint32_t icid, uint64_t rdbase, int valid) "GICv3 ITS: command MAPC ICID 0x%x RDbase 0x%" PRIx64 " V %d" | ||
157 | gicv3_its_cmd_mapi(uint32_t devid, uint32_t eventid, uint32_t icid) "GICv3 ITS: command MAPI DeviceID 0x%x EventID 0x%x ICID 0x%x" | ||
158 | gicv3_its_cmd_mapti(uint32_t devid, uint32_t eventid, uint32_t icid, uint32_t intid) "GICv3 ITS: command MAPTI DeviceID 0x%x EventID 0x%x ICID 0x%x pINTID 0x%x" | ||
159 | -gicv3_its_cmd_inv(void) "GICv3 ITS: command INV or INVALL" | ||
160 | +gicv3_its_cmd_inv(uint32_t devid, uint32_t eventid) "GICv3 ITS: command INV DeviceID 0x%x EventID 0x%x" | ||
161 | +gicv3_its_cmd_invall(void) "GICv3 ITS: command INVALL" | ||
162 | gicv3_its_cmd_movall(uint64_t rd1, uint64_t rd2) "GICv3 ITS: command MOVALL RDbase1 0x%" PRIx64 " RDbase2 0x%" PRIx64 | ||
163 | gicv3_its_cmd_movi(uint32_t devid, uint32_t eventid, uint32_t icid) "GICv3 ITS: command MOVI DeviceID 0x%x EventID 0x%x ICID 0x%x" | ||
164 | gicv3_its_cmd_vmapi(uint32_t devid, uint32_t eventid, uint32_t vpeid, uint32_t doorbell) "GICv3 ITS: command VMAPI DeviceID 0x%x EventID 0x%x vPEID 0x%x Dbell_pINTID 0x%x" | ||
165 | -- | ||
166 | 2.25.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Implement the ITS side of the handling of the INV command for | ||
2 | virtual interrupts; as usual this calls into a redistributor | ||
3 | function which we leave as a stub to fill in later. | ||
1 | 4 | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20220408141550.1271295-20-peter.maydell@linaro.org | ||
8 | --- | ||
9 | hw/intc/gicv3_internal.h | 9 +++++++++ | ||
10 | hw/intc/arm_gicv3_its.c | 16 ++++++++++++++-- | ||
11 | hw/intc/arm_gicv3_redist.c | 8 ++++++++ | ||
12 | 3 files changed, 31 insertions(+), 2 deletions(-) | ||
13 | |||
14 | diff --git a/hw/intc/gicv3_internal.h b/hw/intc/gicv3_internal.h | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/hw/intc/gicv3_internal.h | ||
17 | +++ b/hw/intc/gicv3_internal.h | ||
18 | @@ -XXX,XX +XXX,XX @@ void gicv3_redist_update_lpi_only(GICv3CPUState *cs); | ||
19 | * Forget or update any cached information associated with this LPI. | ||
20 | */ | ||
21 | void gicv3_redist_inv_lpi(GICv3CPUState *cs, int irq); | ||
22 | +/** | ||
23 | + * gicv3_redist_inv_vlpi: | ||
24 | + * @cs: GICv3CPUState | ||
25 | + * @irq: vLPI to invalidate cached information for | ||
26 | + * @vptaddr: (guest) address of vLPI table | ||
27 | + * | ||
28 | + * Forget or update any cached information associated with this vLPI. | ||
29 | + */ | ||
30 | +void gicv3_redist_inv_vlpi(GICv3CPUState *cs, int irq, uint64_t vptaddr); | ||
31 | /** | ||
32 | * gicv3_redist_mov_lpi: | ||
33 | * @src: source redistributor | ||
34 | diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c | ||
35 | index XXXXXXX..XXXXXXX 100644 | ||
36 | --- a/hw/intc/arm_gicv3_its.c | ||
37 | +++ b/hw/intc/arm_gicv3_its.c | ||
38 | @@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_inv(GICv3ITSState *s, const uint64_t *cmdpkt) | ||
39 | ITEntry ite; | ||
40 | DTEntry dte; | ||
41 | CTEntry cte; | ||
42 | + VTEntry vte; | ||
43 | ItsCmdResult cmdres; | ||
44 | |||
45 | devid = FIELD_EX64(cmdpkt[0], INV_0, DEVICEID); | ||
46 | @@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_inv(GICv3ITSState *s, const uint64_t *cmdpkt) | ||
47 | __func__, ite.inttype); | ||
48 | return CMD_CONTINUE; | ||
49 | } | ||
50 | - /* We will implement the vLPI invalidation in a later commit */ | ||
51 | - g_assert_not_reached(); | ||
52 | + | ||
53 | + cmdres = lookup_vte(s, __func__, ite.vpeid, &vte); | ||
54 | + if (cmdres != CMD_CONTINUE_OK) { | ||
55 | + return cmdres; | ||
56 | + } | ||
57 | + if (!intid_in_lpi_range(ite.intid) || | ||
58 | + ite.intid >= (1ULL << (vte.vptsize + 1))) { | ||
59 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: intid 0x%x out of range\n", | ||
60 | + __func__, ite.intid); | ||
61 | + return CMD_CONTINUE; | ||
62 | + } | ||
63 | + gicv3_redist_inv_vlpi(&s->gicv3->cpu[vte.rdbase], ite.intid, | ||
64 | + vte.vptaddr << 16); | ||
65 | break; | ||
66 | default: | ||
67 | g_assert_not_reached(); | ||
68 | diff --git a/hw/intc/arm_gicv3_redist.c b/hw/intc/arm_gicv3_redist.c | ||
69 | index XXXXXXX..XXXXXXX 100644 | ||
70 | --- a/hw/intc/arm_gicv3_redist.c | ||
71 | +++ b/hw/intc/arm_gicv3_redist.c | ||
72 | @@ -XXX,XX +XXX,XX @@ void gicv3_redist_process_vlpi(GICv3CPUState *cs, int irq, uint64_t vptaddr, | ||
73 | */ | ||
74 | } | ||
75 | |||
76 | +void gicv3_redist_inv_vlpi(GICv3CPUState *cs, int irq, uint64_t vptaddr) | ||
77 | +{ | ||
78 | + /* | ||
79 | + * The redistributor handling for invalidating cached information | ||
80 | + * about a VLPI will be added in a subsequent commit. | ||
81 | + */ | ||
82 | +} | ||
83 | + | ||
84 | void gicv3_redist_set_irq(GICv3CPUState *cs, int irq, int level) | ||
85 | { | ||
86 | /* Update redistributor state for a change in an external PPI input line */ | ||
87 | -- | ||
88 | 2.25.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Implement the GICv4 VMOVI command, which moves the pending state | ||
2 | of a virtual interrupt from one redistributor to another. As with | ||
3 | MOVI, we handle the "parse and validate command arguments and | ||
4 | table lookups" part in the ITS source file, and pass the final | ||
5 | results to a function in the redistributor which will do the | ||
6 | actual operation. As with the "make a VLPI pending" change, | ||
7 | for the moment we leave that redistributor function as a stub, | ||
8 | to be implemented in a later commit. | ||
1 | 9 | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
12 | Message-id: 20220408141550.1271295-21-peter.maydell@linaro.org | ||
13 | --- | ||
14 | hw/intc/gicv3_internal.h | 23 +++++++++++ | ||
15 | hw/intc/arm_gicv3_its.c | 82 ++++++++++++++++++++++++++++++++++++++ | ||
16 | hw/intc/arm_gicv3_redist.c | 10 +++++ | ||
17 | hw/intc/trace-events | 1 + | ||
18 | 4 files changed, 116 insertions(+) | ||
19 | |||
20 | diff --git a/hw/intc/gicv3_internal.h b/hw/intc/gicv3_internal.h | ||
21 | index XXXXXXX..XXXXXXX 100644 | ||
22 | --- a/hw/intc/gicv3_internal.h | ||
23 | +++ b/hw/intc/gicv3_internal.h | ||
24 | @@ -XXX,XX +XXX,XX @@ FIELD(GITS_TYPER, CIL, 36, 1) | ||
25 | #define GITS_CMD_INVALL 0x0D | ||
26 | #define GITS_CMD_MOVALL 0x0E | ||
27 | #define GITS_CMD_DISCARD 0x0F | ||
28 | +#define GITS_CMD_VMOVI 0x21 | ||
29 | #define GITS_CMD_VMOVP 0x22 | ||
30 | #define GITS_CMD_VSYNC 0x25 | ||
31 | #define GITS_CMD_VMAPP 0x29 | ||
32 | @@ -XXX,XX +XXX,XX @@ FIELD(VMOVP_2, RDBASE, 16, 36) | ||
33 | FIELD(VMOVP_2, DB, 63, 1) /* GICv4.1 only */ | ||
34 | FIELD(VMOVP_3, DEFAULT_DOORBELL, 0, 32) /* GICv4.1 only */ | ||
35 | |||
36 | +/* VMOVI command fields */ | ||
37 | +FIELD(VMOVI_0, DEVICEID, 32, 32) | ||
38 | +FIELD(VMOVI_1, EVENTID, 0, 32) | ||
39 | +FIELD(VMOVI_1, VPEID, 32, 16) | ||
40 | +FIELD(VMOVI_2, D, 0, 1) | ||
41 | +FIELD(VMOVI_2, DOORBELL, 32, 32) | ||
42 | + | ||
43 | /* | ||
44 | * 12 bytes Interrupt translation Table Entry size | ||
45 | * as per Table 5.3 in GICv3 spec | ||
46 | @@ -XXX,XX +XXX,XX @@ void gicv3_redist_mov_lpi(GICv3CPUState *src, GICv3CPUState *dest, int irq); | ||
47 | * by the ITS MOVALL command. | ||
48 | */ | ||
49 | void gicv3_redist_movall_lpis(GICv3CPUState *src, GICv3CPUState *dest); | ||
50 | +/** | ||
51 | + * gicv3_redist_mov_vlpi: | ||
52 | + * @src: source redistributor | ||
53 | + * @src_vptaddr: (guest) address of source VLPI table | ||
54 | + * @dest: destination redistributor | ||
55 | + * @dest_vptaddr: (guest) address of destination VLPI table | ||
56 | + * @irq: VLPI to update | ||
57 | + * @doorbell: doorbell for destination (1023 for "no doorbell") | ||
58 | + * | ||
59 | + * Move the pending state of the specified VLPI from @src to @dest, | ||
60 | + * as required by the ITS VMOVI command. | ||
61 | + */ | ||
62 | +void gicv3_redist_mov_vlpi(GICv3CPUState *src, uint64_t src_vptaddr, | ||
63 | + GICv3CPUState *dest, uint64_t dest_vptaddr, | ||
64 | + int irq, int doorbell); | ||
65 | |||
66 | void gicv3_redist_send_sgi(GICv3CPUState *cs, int grp, int irq, bool ns); | ||
67 | void gicv3_init_cpuif(GICv3State *s); | ||
68 | diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c | ||
69 | index XXXXXXX..XXXXXXX 100644 | ||
70 | --- a/hw/intc/arm_gicv3_its.c | ||
71 | +++ b/hw/intc/arm_gicv3_its.c | ||
72 | @@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_vmovp(GICv3ITSState *s, const uint64_t *cmdpkt) | ||
73 | return cbdata.result; | ||
74 | } | ||
75 | |||
76 | +static ItsCmdResult process_vmovi(GICv3ITSState *s, const uint64_t *cmdpkt) | ||
77 | +{ | ||
78 | + uint32_t devid, eventid, vpeid, doorbell; | ||
79 | + bool doorbell_valid; | ||
80 | + DTEntry dte; | ||
81 | + ITEntry ite; | ||
82 | + VTEntry old_vte, new_vte; | ||
83 | + ItsCmdResult cmdres; | ||
84 | + | ||
85 | + if (!its_feature_virtual(s)) { | ||
86 | + return CMD_CONTINUE; | ||
87 | + } | ||
88 | + | ||
89 | + devid = FIELD_EX64(cmdpkt[0], VMOVI_0, DEVICEID); | ||
90 | + eventid = FIELD_EX64(cmdpkt[1], VMOVI_1, EVENTID); | ||
91 | + vpeid = FIELD_EX64(cmdpkt[1], VMOVI_1, VPEID); | ||
92 | + doorbell_valid = FIELD_EX64(cmdpkt[2], VMOVI_2, D); | ||
93 | + doorbell = FIELD_EX64(cmdpkt[2], VMOVI_2, DOORBELL); | ||
94 | + | ||
95 | + trace_gicv3_its_cmd_vmovi(devid, eventid, vpeid, doorbell_valid, doorbell); | ||
96 | + | ||
97 | + if (doorbell_valid && !valid_doorbell(doorbell)) { | ||
98 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
99 | + "%s: invalid doorbell 0x%x\n", __func__, doorbell); | ||
100 | + return CMD_CONTINUE; | ||
101 | + } | ||
102 | + | ||
103 | + cmdres = lookup_ite(s, __func__, devid, eventid, &ite, &dte); | ||
104 | + if (cmdres != CMD_CONTINUE_OK) { | ||
105 | + return cmdres; | ||
106 | + } | ||
107 | + | ||
108 | + if (ite.inttype != ITE_INTTYPE_VIRTUAL) { | ||
109 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: ITE is not for virtual interrupt\n", | ||
110 | + __func__); | ||
111 | + return CMD_CONTINUE; | ||
112 | + } | ||
113 | + | ||
114 | + cmdres = lookup_vte(s, __func__, ite.vpeid, &old_vte); | ||
115 | + if (cmdres != CMD_CONTINUE_OK) { | ||
116 | + return cmdres; | ||
117 | + } | ||
118 | + cmdres = lookup_vte(s, __func__, vpeid, &new_vte); | ||
119 | + if (cmdres != CMD_CONTINUE_OK) { | ||
120 | + return cmdres; | ||
121 | + } | ||
122 | + | ||
123 | + if (!intid_in_lpi_range(ite.intid) || | ||
124 | + ite.intid >= (1ULL << (old_vte.vptsize + 1)) || | ||
125 | + ite.intid >= (1ULL << (new_vte.vptsize + 1))) { | ||
126 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
127 | + "%s: ITE intid 0x%x out of range\n", | ||
128 | + __func__, ite.intid); | ||
129 | + return CMD_CONTINUE; | ||
130 | + } | ||
131 | + | ||
132 | + ite.vpeid = vpeid; | ||
133 | + if (doorbell_valid) { | ||
134 | + ite.doorbell = doorbell; | ||
135 | + } | ||
136 | + | ||
137 | + /* | ||
138 | + * Move the LPI from the old redistributor to the new one. We don't | ||
139 | + * need to do anything if the guest somehow specified the | ||
140 | + * same pending table for source and destination. | ||
141 | + */ | ||
142 | + if (old_vte.vptaddr != new_vte.vptaddr) { | ||
143 | + gicv3_redist_mov_vlpi(&s->gicv3->cpu[old_vte.rdbase], | ||
144 | + old_vte.vptaddr << 16, | ||
145 | + &s->gicv3->cpu[new_vte.rdbase], | ||
146 | + new_vte.vptaddr << 16, | ||
147 | + ite.intid, | ||
148 | + ite.doorbell); | ||
149 | + } | ||
150 | + | ||
151 | + /* Update the ITE to the new VPEID and possibly doorbell values */ | ||
152 | + return update_ite(s, eventid, &dte, &ite) ? CMD_CONTINUE_OK : CMD_STALL; | ||
153 | +} | ||
154 | + | ||
155 | static ItsCmdResult process_inv(GICv3ITSState *s, const uint64_t *cmdpkt) | ||
156 | { | ||
157 | uint32_t devid, eventid; | ||
158 | @@ -XXX,XX +XXX,XX @@ static void process_cmdq(GICv3ITSState *s) | ||
159 | case GITS_CMD_VMOVP: | ||
160 | result = process_vmovp(s, cmdpkt); | ||
161 | break; | ||
162 | + case GITS_CMD_VMOVI: | ||
163 | + result = process_vmovi(s, cmdpkt); | ||
164 | + break; | ||
165 | default: | ||
166 | trace_gicv3_its_cmd_unknown(cmd); | ||
167 | break; | ||
168 | diff --git a/hw/intc/arm_gicv3_redist.c b/hw/intc/arm_gicv3_redist.c | ||
169 | index XXXXXXX..XXXXXXX 100644 | ||
170 | --- a/hw/intc/arm_gicv3_redist.c | ||
171 | +++ b/hw/intc/arm_gicv3_redist.c | ||
172 | @@ -XXX,XX +XXX,XX @@ void gicv3_redist_process_vlpi(GICv3CPUState *cs, int irq, uint64_t vptaddr, | ||
173 | */ | ||
174 | } | ||
175 | |||
176 | +void gicv3_redist_mov_vlpi(GICv3CPUState *src, uint64_t src_vptaddr, | ||
177 | + GICv3CPUState *dest, uint64_t dest_vptaddr, | ||
178 | + int irq, int doorbell) | ||
179 | +{ | ||
180 | + /* | ||
181 | + * The redistributor handling for moving a VLPI will be added | ||
182 | + * in a subsequent commit. | ||
183 | + */ | ||
184 | +} | ||
185 | + | ||
186 | void gicv3_redist_inv_vlpi(GICv3CPUState *cs, int irq, uint64_t vptaddr) | ||
187 | { | ||
188 | /* | ||
189 | diff --git a/hw/intc/trace-events b/hw/intc/trace-events | ||
190 | index XXXXXXX..XXXXXXX 100644 | ||
191 | --- a/hw/intc/trace-events | ||
192 | +++ b/hw/intc/trace-events | ||
193 | @@ -XXX,XX +XXX,XX @@ gicv3_its_cmd_vmapti(uint32_t devid, uint32_t eventid, uint32_t vpeid, uint32_t | ||
194 | gicv3_its_cmd_vmapp(uint32_t vpeid, uint64_t rdbase, int valid, uint64_t vptaddr, uint32_t vptsize) "GICv3 ITS: command VMAPP vPEID 0x%x RDbase 0x%" PRIx64 " V %d VPT_addr 0x%" PRIx64 " VPT_size 0x%x" | ||
195 | gicv3_its_cmd_vmovp(uint32_t vpeid, uint64_t rdbase) "GICv3 ITS: command VMOVP vPEID 0x%x RDbase 0x%" PRIx64 | ||
196 | gicv3_its_cmd_vsync(void) "GICv3 ITS: command VSYNC" | ||
197 | +gicv3_its_cmd_vmovi(uint32_t devid, uint32_t eventid, uint32_t vpeid, int dbvalid, uint32_t doorbell) "GICv3 ITS: command VMOVI DeviceID 0x%x EventID 0x%x vPEID 0x%x D %d Dbell_pINTID 0x%x" | ||
198 | gicv3_its_cmd_unknown(unsigned cmd) "GICv3 ITS: unknown command 0x%x" | ||
199 | gicv3_its_cte_read(uint32_t icid, int valid, uint32_t rdbase) "GICv3 ITS: Collection Table read for ICID 0x%x: valid %d RDBase 0x%x" | ||
200 | gicv3_its_cte_write(uint32_t icid, int valid, uint32_t rdbase) "GICv3 ITS: Collection Table write for ICID 0x%x: valid %d RDBase 0x%x" | ||
201 | -- | ||
202 | 2.25.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | The VINVALL command should cause any cached information in the | ||
2 | ITS or redistributor for the specified vCPU to be dropped or | ||
3 | otherwise made consistent with the in-memory LPI configuration | ||
4 | tables. | ||
1 | 5 | ||
6 | Here we implement the command and table parsing, leaving the | ||
7 | redistributor part as a stub for the moment, as usual. | ||
8 | |||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
11 | Message-id: 20220408141550.1271295-22-peter.maydell@linaro.org | ||
12 | --- | ||
13 | hw/intc/gicv3_internal.h | 13 +++++++++++++ | ||
14 | hw/intc/arm_gicv3_its.c | 26 ++++++++++++++++++++++++++ | ||
15 | hw/intc/arm_gicv3_redist.c | 5 +++++ | ||
16 | hw/intc/trace-events | 1 + | ||
17 | 4 files changed, 45 insertions(+) | ||
18 | |||
19 | diff --git a/hw/intc/gicv3_internal.h b/hw/intc/gicv3_internal.h | ||
20 | index XXXXXXX..XXXXXXX 100644 | ||
21 | --- a/hw/intc/gicv3_internal.h | ||
22 | +++ b/hw/intc/gicv3_internal.h | ||
23 | @@ -XXX,XX +XXX,XX @@ FIELD(GITS_TYPER, CIL, 36, 1) | ||
24 | #define GITS_CMD_VMAPP 0x29 | ||
25 | #define GITS_CMD_VMAPTI 0x2A | ||
26 | #define GITS_CMD_VMAPI 0x2B | ||
27 | +#define GITS_CMD_VINVALL 0x2D | ||
28 | |||
29 | /* MAPC command fields */ | ||
30 | #define ICID_LENGTH 16 | ||
31 | @@ -XXX,XX +XXX,XX @@ FIELD(VMOVI_1, VPEID, 32, 16) | ||
32 | FIELD(VMOVI_2, D, 0, 1) | ||
33 | FIELD(VMOVI_2, DOORBELL, 32, 32) | ||
34 | |||
35 | +/* VINVALL command fields */ | ||
36 | +FIELD(VINVALL_1, VPEID, 32, 16) | ||
37 | + | ||
38 | /* | ||
39 | * 12 bytes Interrupt translation Table Entry size | ||
40 | * as per Table 5.3 in GICv3 spec | ||
41 | @@ -XXX,XX +XXX,XX @@ void gicv3_redist_movall_lpis(GICv3CPUState *src, GICv3CPUState *dest); | ||
42 | void gicv3_redist_mov_vlpi(GICv3CPUState *src, uint64_t src_vptaddr, | ||
43 | GICv3CPUState *dest, uint64_t dest_vptaddr, | ||
44 | int irq, int doorbell); | ||
45 | +/** | ||
46 | + * gicv3_redist_vinvall: | ||
47 | + * @cs: GICv3CPUState | ||
48 | + * @vptaddr: address of VLPI pending table | ||
49 | + * | ||
50 | + * On redistributor @cs, invalidate all cached information associated | ||
51 | + * with the vCPU defined by @vptaddr. | ||
52 | + */ | ||
53 | +void gicv3_redist_vinvall(GICv3CPUState *cs, uint64_t vptaddr); | ||
54 | |||
55 | void gicv3_redist_send_sgi(GICv3CPUState *cs, int grp, int irq, bool ns); | ||
56 | void gicv3_init_cpuif(GICv3State *s); | ||
57 | diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c | ||
58 | index XXXXXXX..XXXXXXX 100644 | ||
59 | --- a/hw/intc/arm_gicv3_its.c | ||
60 | +++ b/hw/intc/arm_gicv3_its.c | ||
61 | @@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_vmovi(GICv3ITSState *s, const uint64_t *cmdpkt) | ||
62 | return update_ite(s, eventid, &dte, &ite) ? CMD_CONTINUE_OK : CMD_STALL; | ||
63 | } | ||
64 | |||
65 | +static ItsCmdResult process_vinvall(GICv3ITSState *s, const uint64_t *cmdpkt) | ||
66 | +{ | ||
67 | + VTEntry vte; | ||
68 | + uint32_t vpeid; | ||
69 | + ItsCmdResult cmdres; | ||
70 | + | ||
71 | + if (!its_feature_virtual(s)) { | ||
72 | + return CMD_CONTINUE; | ||
73 | + } | ||
74 | + | ||
75 | + vpeid = FIELD_EX64(cmdpkt[1], VINVALL_1, VPEID); | ||
76 | + | ||
77 | + trace_gicv3_its_cmd_vinvall(vpeid); | ||
78 | + | ||
79 | + cmdres = lookup_vte(s, __func__, vpeid, &vte); | ||
80 | + if (cmdres != CMD_CONTINUE_OK) { | ||
81 | + return cmdres; | ||
82 | + } | ||
83 | + | ||
84 | + gicv3_redist_vinvall(&s->gicv3->cpu[vte.rdbase], vte.vptaddr << 16); | ||
85 | + return CMD_CONTINUE_OK; | ||
86 | +} | ||
87 | + | ||
88 | static ItsCmdResult process_inv(GICv3ITSState *s, const uint64_t *cmdpkt) | ||
89 | { | ||
90 | uint32_t devid, eventid; | ||
91 | @@ -XXX,XX +XXX,XX @@ static void process_cmdq(GICv3ITSState *s) | ||
92 | case GITS_CMD_VMOVI: | ||
93 | result = process_vmovi(s, cmdpkt); | ||
94 | break; | ||
95 | + case GITS_CMD_VINVALL: | ||
96 | + result = process_vinvall(s, cmdpkt); | ||
97 | + break; | ||
98 | default: | ||
99 | trace_gicv3_its_cmd_unknown(cmd); | ||
100 | break; | ||
101 | diff --git a/hw/intc/arm_gicv3_redist.c b/hw/intc/arm_gicv3_redist.c | ||
102 | index XXXXXXX..XXXXXXX 100644 | ||
103 | --- a/hw/intc/arm_gicv3_redist.c | ||
104 | +++ b/hw/intc/arm_gicv3_redist.c | ||
105 | @@ -XXX,XX +XXX,XX @@ void gicv3_redist_mov_vlpi(GICv3CPUState *src, uint64_t src_vptaddr, | ||
106 | */ | ||
107 | } | ||
108 | |||
109 | +void gicv3_redist_vinvall(GICv3CPUState *cs, uint64_t vptaddr) | ||
110 | +{ | ||
111 | + /* The redistributor handling will be added in a subsequent commit */ | ||
112 | +} | ||
113 | + | ||
114 | void gicv3_redist_inv_vlpi(GICv3CPUState *cs, int irq, uint64_t vptaddr) | ||
115 | { | ||
116 | /* | ||
117 | diff --git a/hw/intc/trace-events b/hw/intc/trace-events | ||
118 | index XXXXXXX..XXXXXXX 100644 | ||
119 | --- a/hw/intc/trace-events | ||
120 | +++ b/hw/intc/trace-events | ||
121 | @@ -XXX,XX +XXX,XX @@ gicv3_its_cmd_vmapp(uint32_t vpeid, uint64_t rdbase, int valid, uint64_t vptaddr | ||
122 | gicv3_its_cmd_vmovp(uint32_t vpeid, uint64_t rdbase) "GICv3 ITS: command VMOVP vPEID 0x%x RDbase 0x%" PRIx64 | ||
123 | gicv3_its_cmd_vsync(void) "GICv3 ITS: command VSYNC" | ||
124 | gicv3_its_cmd_vmovi(uint32_t devid, uint32_t eventid, uint32_t vpeid, int dbvalid, uint32_t doorbell) "GICv3 ITS: command VMOVI DeviceID 0x%x EventID 0x%x vPEID 0x%x D %d Dbell_pINTID 0x%x" | ||
125 | +gicv3_its_cmd_vinvall(uint32_t vpeid) "GICv3 ITS: command VINVALL vPEID 0x%x" | ||
126 | gicv3_its_cmd_unknown(unsigned cmd) "GICv3 ITS: unknown command 0x%x" | ||
127 | gicv3_its_cte_read(uint32_t icid, int valid, uint32_t rdbase) "GICv3 ITS: Collection Table read for ICID 0x%x: valid %d RDBase 0x%x" | ||
128 | gicv3_its_cte_write(uint32_t icid, int valid, uint32_t rdbase) "GICv3 ITS: Collection Table write for ICID 0x%x: valid %d RDBase 0x%x" | ||
129 | -- | ||
130 | 2.25.1 | diff view generated by jsdifflib |
1 | Currently timer_free() is a simple wrapper for g_free(). This means | 1 | The GICv4 extends the redistributor register map -- where GICv3 |
---|---|---|---|
2 | that the timer being freed must not be currently active, as otherwise | 2 | had two 64KB frames per CPU, GICv4 has four frames. Add support |
3 | QEMU might crash later when the active list is processed and still | 3 | for the extra frame by using a new gicv3_redist_size() function |
4 | has a pointer to freed memory on it. As a result almost all calls to | 4 | in the places in the GIC implementation which currently use |
5 | timer_free() are preceded by a timer_del() call, as can be seen in | 5 | a fixed constant size for the redistributor register block. |
6 | the output of | 6 | (Until we implement the extra registers they will RAZ/WI.) |
7 | git grep -B1 '\<timer_free\>' | ||
8 | 7 | ||
9 | This is unfortunate API design as it makes it easy to accidentally | 8 | Any board that wants to use a GICv4 will need to also adjust |
10 | misuse (by forgetting the timer_del()), and the correct use is | 9 | to handle the different sized redistributor register block; |
11 | annoyingly verbose. | 10 | that will be done separately. |
12 | |||
13 | Make timer_free() imply a timer_del(). | ||
14 | 11 | ||
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
16 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
17 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 13 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
18 | Message-id: 20201215154107.3255-2-peter.maydell@linaro.org | 14 | Message-id: 20220408141550.1271295-23-peter.maydell@linaro.org |
19 | --- | 15 | --- |
20 | include/qemu/timer.h | 24 +++++++++++++----------- | 16 | hw/intc/gicv3_internal.h | 21 +++++++++++++++++++++ |
21 | 1 file changed, 13 insertions(+), 11 deletions(-) | 17 | include/hw/intc/arm_gicv3_common.h | 5 +++++ |
18 | hw/intc/arm_gicv3_common.c | 2 +- | ||
19 | hw/intc/arm_gicv3_redist.c | 8 ++++---- | ||
20 | 4 files changed, 31 insertions(+), 5 deletions(-) | ||
22 | 21 | ||
23 | diff --git a/include/qemu/timer.h b/include/qemu/timer.h | 22 | diff --git a/hw/intc/gicv3_internal.h b/hw/intc/gicv3_internal.h |
24 | index XXXXXXX..XXXXXXX 100644 | 23 | index XXXXXXX..XXXXXXX 100644 |
25 | --- a/include/qemu/timer.h | 24 | --- a/hw/intc/gicv3_internal.h |
26 | +++ b/include/qemu/timer.h | 25 | +++ b/hw/intc/gicv3_internal.h |
27 | @@ -XXX,XX +XXX,XX @@ static inline QEMUTimer *timer_new_ms(QEMUClockType type, QEMUTimerCB *cb, | 26 | @@ -XXX,XX +XXX,XX @@ FIELD(VTE, RDBASE, 42, RDBASE_PROCNUM_LENGTH) |
28 | */ | 27 | |
29 | void timer_deinit(QEMUTimer *ts); | 28 | /* Functions internal to the emulated GICv3 */ |
30 | |||
31 | -/** | ||
32 | - * timer_free: | ||
33 | - * @ts: the timer | ||
34 | - * | ||
35 | - * Free a timer (it must not be on the active list) | ||
36 | - */ | ||
37 | -static inline void timer_free(QEMUTimer *ts) | ||
38 | -{ | ||
39 | - g_free(ts); | ||
40 | -} | ||
41 | - | ||
42 | /** | ||
43 | * timer_del: | ||
44 | * @ts: the timer | ||
45 | @@ -XXX,XX +XXX,XX @@ static inline void timer_free(QEMUTimer *ts) | ||
46 | */ | ||
47 | void timer_del(QEMUTimer *ts); | ||
48 | 29 | ||
49 | +/** | 30 | +/** |
50 | + * timer_free: | 31 | + * gicv3_redist_size: |
51 | + * @ts: the timer | 32 | + * @s: GICv3State |
52 | + * | 33 | + * |
53 | + * Free a timer. This will call timer_del() for you to remove | 34 | + * Return the size of the redistributor register frame in bytes |
54 | + * the timer from the active list if it was still active. | 35 | + * (which depends on what GIC version this is) |
55 | + */ | 36 | + */ |
56 | +static inline void timer_free(QEMUTimer *ts) | 37 | +static inline int gicv3_redist_size(GICv3State *s) |
57 | +{ | 38 | +{ |
58 | + timer_del(ts); | 39 | + /* |
59 | + g_free(ts); | 40 | + * Redistributor size is controlled by the redistributor GICR_TYPER.VLPIS. |
41 | + * It's the same for every redistributor in the GIC, so arbitrarily | ||
42 | + * use the register field in the first one. | ||
43 | + */ | ||
44 | + if (s->cpu[0].gicr_typer & GICR_TYPER_VLPIS) { | ||
45 | + return GICV4_REDIST_SIZE; | ||
46 | + } else { | ||
47 | + return GICV3_REDIST_SIZE; | ||
48 | + } | ||
60 | +} | 49 | +} |
61 | + | 50 | + |
62 | /** | 51 | /** |
63 | * timer_mod_ns: | 52 | * gicv3_intid_is_special: |
64 | * @ts: the timer | 53 | * @intid: interrupt ID |
54 | diff --git a/include/hw/intc/arm_gicv3_common.h b/include/hw/intc/arm_gicv3_common.h | ||
55 | index XXXXXXX..XXXXXXX 100644 | ||
56 | --- a/include/hw/intc/arm_gicv3_common.h | ||
57 | +++ b/include/hw/intc/arm_gicv3_common.h | ||
58 | @@ -XXX,XX +XXX,XX @@ | ||
59 | |||
60 | #define GICV3_LPI_INTID_START 8192 | ||
61 | |||
62 | +/* | ||
63 | + * The redistributor in GICv3 has two 64KB frames per CPU; in | ||
64 | + * GICv4 it has four 64KB frames per CPU. | ||
65 | + */ | ||
66 | #define GICV3_REDIST_SIZE 0x20000 | ||
67 | +#define GICV4_REDIST_SIZE 0x40000 | ||
68 | |||
69 | /* Number of SGI target-list bits */ | ||
70 | #define GICV3_TARGETLIST_BITS 16 | ||
71 | diff --git a/hw/intc/arm_gicv3_common.c b/hw/intc/arm_gicv3_common.c | ||
72 | index XXXXXXX..XXXXXXX 100644 | ||
73 | --- a/hw/intc/arm_gicv3_common.c | ||
74 | +++ b/hw/intc/arm_gicv3_common.c | ||
75 | @@ -XXX,XX +XXX,XX @@ void gicv3_init_irqs_and_mmio(GICv3State *s, qemu_irq_handler handler, | ||
76 | |||
77 | memory_region_init_io(®ion->iomem, OBJECT(s), | ||
78 | ops ? &ops[1] : NULL, region, name, | ||
79 | - s->redist_region_count[i] * GICV3_REDIST_SIZE); | ||
80 | + s->redist_region_count[i] * gicv3_redist_size(s)); | ||
81 | sysbus_init_mmio(sbd, ®ion->iomem); | ||
82 | g_free(name); | ||
83 | } | ||
84 | diff --git a/hw/intc/arm_gicv3_redist.c b/hw/intc/arm_gicv3_redist.c | ||
85 | index XXXXXXX..XXXXXXX 100644 | ||
86 | --- a/hw/intc/arm_gicv3_redist.c | ||
87 | +++ b/hw/intc/arm_gicv3_redist.c | ||
88 | @@ -XXX,XX +XXX,XX @@ MemTxResult gicv3_redist_read(void *opaque, hwaddr offset, uint64_t *data, | ||
89 | * in the memory map); if so then the GIC has multiple MemoryRegions | ||
90 | * for the redistributors. | ||
91 | */ | ||
92 | - cpuidx = region->cpuidx + offset / GICV3_REDIST_SIZE; | ||
93 | - offset %= GICV3_REDIST_SIZE; | ||
94 | + cpuidx = region->cpuidx + offset / gicv3_redist_size(s); | ||
95 | + offset %= gicv3_redist_size(s); | ||
96 | |||
97 | cs = &s->cpu[cpuidx]; | ||
98 | |||
99 | @@ -XXX,XX +XXX,XX @@ MemTxResult gicv3_redist_write(void *opaque, hwaddr offset, uint64_t data, | ||
100 | * in the memory map); if so then the GIC has multiple MemoryRegions | ||
101 | * for the redistributors. | ||
102 | */ | ||
103 | - cpuidx = region->cpuidx + offset / GICV3_REDIST_SIZE; | ||
104 | - offset %= GICV3_REDIST_SIZE; | ||
105 | + cpuidx = region->cpuidx + offset / gicv3_redist_size(s); | ||
106 | + offset %= gicv3_redist_size(s); | ||
107 | |||
108 | cs = &s->cpu[cpuidx]; | ||
109 | |||
65 | -- | 110 | -- |
66 | 2.20.1 | 111 | 2.25.1 |
67 | |||
68 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Implement the new GICv4 redistributor registers: GICR_VPROPBASER | ||
2 | and GICR_VPENDBASER; for the moment we implement these as simple | ||
3 | reads-as-written stubs, together with the necessary migration | ||
4 | and reset handling. | ||
1 | 5 | ||
6 | We don't put ID-register checks on the handling of these registers, | ||
7 | because they are all in the only-in-v4 extra register frames, so | ||
8 | they're not accessible in a GICv3. | ||
9 | |||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
12 | Message-id: 20220408141550.1271295-24-peter.maydell@linaro.org | ||
13 | --- | ||
14 | hw/intc/gicv3_internal.h | 21 +++++++++++ | ||
15 | include/hw/intc/arm_gicv3_common.h | 3 ++ | ||
16 | hw/intc/arm_gicv3_common.c | 22 ++++++++++++ | ||
17 | hw/intc/arm_gicv3_redist.c | 56 ++++++++++++++++++++++++++++++ | ||
18 | 4 files changed, 102 insertions(+) | ||
19 | |||
20 | diff --git a/hw/intc/gicv3_internal.h b/hw/intc/gicv3_internal.h | ||
21 | index XXXXXXX..XXXXXXX 100644 | ||
22 | --- a/hw/intc/gicv3_internal.h | ||
23 | +++ b/hw/intc/gicv3_internal.h | ||
24 | @@ -XXX,XX +XXX,XX @@ | ||
25 | * Redistributor frame offsets from RD_base | ||
26 | */ | ||
27 | #define GICR_SGI_OFFSET 0x10000 | ||
28 | +#define GICR_VLPI_OFFSET 0x20000 | ||
29 | |||
30 | /* | ||
31 | * Redistributor registers, offsets from RD_base | ||
32 | @@ -XXX,XX +XXX,XX @@ | ||
33 | #define GICR_IGRPMODR0 (GICR_SGI_OFFSET + 0x0D00) | ||
34 | #define GICR_NSACR (GICR_SGI_OFFSET + 0x0E00) | ||
35 | |||
36 | +/* VLPI redistributor registers, offsets from VLPI_base */ | ||
37 | +#define GICR_VPROPBASER (GICR_VLPI_OFFSET + 0x70) | ||
38 | +#define GICR_VPENDBASER (GICR_VLPI_OFFSET + 0x78) | ||
39 | + | ||
40 | #define GICR_CTLR_ENABLE_LPIS (1U << 0) | ||
41 | #define GICR_CTLR_CES (1U << 1) | ||
42 | #define GICR_CTLR_RWP (1U << 3) | ||
43 | @@ -XXX,XX +XXX,XX @@ FIELD(GICR_PENDBASER, PTZ, 62, 1) | ||
44 | |||
45 | #define GICR_PROPBASER_IDBITS_THRESHOLD 0xd | ||
46 | |||
47 | +/* These are the GICv4 VPROPBASER and VPENDBASER layouts; v4.1 is different */ | ||
48 | +FIELD(GICR_VPROPBASER, IDBITS, 0, 5) | ||
49 | +FIELD(GICR_VPROPBASER, INNERCACHE, 7, 3) | ||
50 | +FIELD(GICR_VPROPBASER, SHAREABILITY, 10, 2) | ||
51 | +FIELD(GICR_VPROPBASER, PHYADDR, 12, 40) | ||
52 | +FIELD(GICR_VPROPBASER, OUTERCACHE, 56, 3) | ||
53 | + | ||
54 | +FIELD(GICR_VPENDBASER, INNERCACHE, 7, 3) | ||
55 | +FIELD(GICR_VPENDBASER, SHAREABILITY, 10, 2) | ||
56 | +FIELD(GICR_VPENDBASER, PHYADDR, 16, 36) | ||
57 | +FIELD(GICR_VPENDBASER, OUTERCACHE, 56, 3) | ||
58 | +FIELD(GICR_VPENDBASER, DIRTY, 60, 1) | ||
59 | +FIELD(GICR_VPENDBASER, PENDINGLAST, 61, 1) | ||
60 | +FIELD(GICR_VPENDBASER, IDAI, 62, 1) | ||
61 | +FIELD(GICR_VPENDBASER, VALID, 63, 1) | ||
62 | + | ||
63 | #define ICC_CTLR_EL1_CBPR (1U << 0) | ||
64 | #define ICC_CTLR_EL1_EOIMODE (1U << 1) | ||
65 | #define ICC_CTLR_EL1_PMHE (1U << 6) | ||
66 | diff --git a/include/hw/intc/arm_gicv3_common.h b/include/hw/intc/arm_gicv3_common.h | ||
67 | index XXXXXXX..XXXXXXX 100644 | ||
68 | --- a/include/hw/intc/arm_gicv3_common.h | ||
69 | +++ b/include/hw/intc/arm_gicv3_common.h | ||
70 | @@ -XXX,XX +XXX,XX @@ struct GICv3CPUState { | ||
71 | uint32_t gicr_igrpmodr0; | ||
72 | uint32_t gicr_nsacr; | ||
73 | uint8_t gicr_ipriorityr[GIC_INTERNAL]; | ||
74 | + /* VLPI_base page registers */ | ||
75 | + uint64_t gicr_vpropbaser; | ||
76 | + uint64_t gicr_vpendbaser; | ||
77 | |||
78 | /* CPU interface */ | ||
79 | uint64_t icc_sre_el1; | ||
80 | diff --git a/hw/intc/arm_gicv3_common.c b/hw/intc/arm_gicv3_common.c | ||
81 | index XXXXXXX..XXXXXXX 100644 | ||
82 | --- a/hw/intc/arm_gicv3_common.c | ||
83 | +++ b/hw/intc/arm_gicv3_common.c | ||
84 | @@ -XXX,XX +XXX,XX @@ const VMStateDescription vmstate_gicv3_cpu_sre_el1 = { | ||
85 | } | ||
86 | }; | ||
87 | |||
88 | +static bool gicv4_needed(void *opaque) | ||
89 | +{ | ||
90 | + GICv3CPUState *cs = opaque; | ||
91 | + | ||
92 | + return cs->gic->revision > 3; | ||
93 | +} | ||
94 | + | ||
95 | +const VMStateDescription vmstate_gicv3_gicv4 = { | ||
96 | + .name = "arm_gicv3_cpu/gicv4", | ||
97 | + .version_id = 1, | ||
98 | + .minimum_version_id = 1, | ||
99 | + .needed = gicv4_needed, | ||
100 | + .fields = (VMStateField[]) { | ||
101 | + VMSTATE_UINT64(gicr_vpropbaser, GICv3CPUState), | ||
102 | + VMSTATE_UINT64(gicr_vpendbaser, GICv3CPUState), | ||
103 | + VMSTATE_END_OF_LIST() | ||
104 | + } | ||
105 | +}; | ||
106 | + | ||
107 | static const VMStateDescription vmstate_gicv3_cpu = { | ||
108 | .name = "arm_gicv3_cpu", | ||
109 | .version_id = 1, | ||
110 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_gicv3_cpu = { | ||
111 | .subsections = (const VMStateDescription * []) { | ||
112 | &vmstate_gicv3_cpu_virt, | ||
113 | &vmstate_gicv3_cpu_sre_el1, | ||
114 | + &vmstate_gicv3_gicv4, | ||
115 | NULL | ||
116 | } | ||
117 | }; | ||
118 | @@ -XXX,XX +XXX,XX @@ static void arm_gicv3_common_reset(DeviceState *dev) | ||
119 | cs->gicr_waker = GICR_WAKER_ProcessorSleep | GICR_WAKER_ChildrenAsleep; | ||
120 | cs->gicr_propbaser = 0; | ||
121 | cs->gicr_pendbaser = 0; | ||
122 | + cs->gicr_vpropbaser = 0; | ||
123 | + cs->gicr_vpendbaser = 0; | ||
124 | /* If we're resetting a TZ-aware GIC as if secure firmware | ||
125 | * had set it up ready to start a kernel in non-secure, we | ||
126 | * need to set interrupts to group 1 so the kernel can use them. | ||
127 | diff --git a/hw/intc/arm_gicv3_redist.c b/hw/intc/arm_gicv3_redist.c | ||
128 | index XXXXXXX..XXXXXXX 100644 | ||
129 | --- a/hw/intc/arm_gicv3_redist.c | ||
130 | +++ b/hw/intc/arm_gicv3_redist.c | ||
131 | @@ -XXX,XX +XXX,XX @@ static MemTxResult gicr_readl(GICv3CPUState *cs, hwaddr offset, | ||
132 | case GICR_IDREGS ... GICR_IDREGS + 0x2f: | ||
133 | *data = gicv3_idreg(offset - GICR_IDREGS, GICV3_PIDR0_REDIST); | ||
134 | return MEMTX_OK; | ||
135 | + /* | ||
136 | + * VLPI frame registers. We don't need a version check for | ||
137 | + * VPROPBASER and VPENDBASER because gicv3_redist_size() will | ||
138 | + * prevent pre-v4 GIC from passing us offsets this high. | ||
139 | + */ | ||
140 | + case GICR_VPROPBASER: | ||
141 | + *data = extract64(cs->gicr_vpropbaser, 0, 32); | ||
142 | + return MEMTX_OK; | ||
143 | + case GICR_VPROPBASER + 4: | ||
144 | + *data = extract64(cs->gicr_vpropbaser, 32, 32); | ||
145 | + return MEMTX_OK; | ||
146 | + case GICR_VPENDBASER: | ||
147 | + *data = extract64(cs->gicr_vpendbaser, 0, 32); | ||
148 | + return MEMTX_OK; | ||
149 | + case GICR_VPENDBASER + 4: | ||
150 | + *data = extract64(cs->gicr_vpendbaser, 32, 32); | ||
151 | + return MEMTX_OK; | ||
152 | default: | ||
153 | return MEMTX_ERROR; | ||
154 | } | ||
155 | @@ -XXX,XX +XXX,XX @@ static MemTxResult gicr_writel(GICv3CPUState *cs, hwaddr offset, | ||
156 | "%s: invalid guest write to RO register at offset " | ||
157 | TARGET_FMT_plx "\n", __func__, offset); | ||
158 | return MEMTX_OK; | ||
159 | + /* | ||
160 | + * VLPI frame registers. We don't need a version check for | ||
161 | + * VPROPBASER and VPENDBASER because gicv3_redist_size() will | ||
162 | + * prevent pre-v4 GIC from passing us offsets this high. | ||
163 | + */ | ||
164 | + case GICR_VPROPBASER: | ||
165 | + cs->gicr_vpropbaser = deposit64(cs->gicr_vpropbaser, 0, 32, value); | ||
166 | + return MEMTX_OK; | ||
167 | + case GICR_VPROPBASER + 4: | ||
168 | + cs->gicr_vpropbaser = deposit64(cs->gicr_vpropbaser, 32, 32, value); | ||
169 | + return MEMTX_OK; | ||
170 | + case GICR_VPENDBASER: | ||
171 | + cs->gicr_vpendbaser = deposit64(cs->gicr_vpendbaser, 0, 32, value); | ||
172 | + return MEMTX_OK; | ||
173 | + case GICR_VPENDBASER + 4: | ||
174 | + cs->gicr_vpendbaser = deposit64(cs->gicr_vpendbaser, 32, 32, value); | ||
175 | + return MEMTX_OK; | ||
176 | default: | ||
177 | return MEMTX_ERROR; | ||
178 | } | ||
179 | @@ -XXX,XX +XXX,XX @@ static MemTxResult gicr_readll(GICv3CPUState *cs, hwaddr offset, | ||
180 | case GICR_PENDBASER: | ||
181 | *data = cs->gicr_pendbaser; | ||
182 | return MEMTX_OK; | ||
183 | + /* | ||
184 | + * VLPI frame registers. We don't need a version check for | ||
185 | + * VPROPBASER and VPENDBASER because gicv3_redist_size() will | ||
186 | + * prevent pre-v4 GIC from passing us offsets this high. | ||
187 | + */ | ||
188 | + case GICR_VPROPBASER: | ||
189 | + *data = cs->gicr_vpropbaser; | ||
190 | + return MEMTX_OK; | ||
191 | + case GICR_VPENDBASER: | ||
192 | + *data = cs->gicr_vpendbaser; | ||
193 | + return MEMTX_OK; | ||
194 | default: | ||
195 | return MEMTX_ERROR; | ||
196 | } | ||
197 | @@ -XXX,XX +XXX,XX @@ static MemTxResult gicr_writell(GICv3CPUState *cs, hwaddr offset, | ||
198 | "%s: invalid guest write to RO register at offset " | ||
199 | TARGET_FMT_plx "\n", __func__, offset); | ||
200 | return MEMTX_OK; | ||
201 | + /* | ||
202 | + * VLPI frame registers. We don't need a version check for | ||
203 | + * VPROPBASER and VPENDBASER because gicv3_redist_size() will | ||
204 | + * prevent pre-v4 GIC from passing us offsets this high. | ||
205 | + */ | ||
206 | + case GICR_VPROPBASER: | ||
207 | + cs->gicr_vpropbaser = value; | ||
208 | + return MEMTX_OK; | ||
209 | + case GICR_VPENDBASER: | ||
210 | + cs->gicr_vpendbaser = value; | ||
211 | + return MEMTX_OK; | ||
212 | default: | ||
213 | return MEMTX_ERROR; | ||
214 | } | ||
215 | -- | ||
216 | 2.25.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | The function gicv3_cpuif_virt_update() currently sets all of vIRQ, | ||
2 | vFIQ and the maintenance interrupt. This implies that it has to be | ||
3 | used quite carefully -- as the comment notes, setting the maintenance | ||
4 | interrupt will typically cause the GIC code to be re-entered | ||
5 | recursively. For handling vLPIs, we need the redistributor to be | ||
6 | able to tell the cpuif to update the vIRQ and vFIQ lines when the | ||
7 | highest priority pending vLPI changes. Since that change can't cause | ||
8 | the maintenance interrupt state to change, we can pull the "update | ||
9 | vIRQ/vFIQ" parts of gicv3_cpuif_virt_update() out into a separate | ||
10 | function, which the redistributor can then call without having to | ||
11 | worry about the reentrancy issue. | ||
1 | 12 | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
14 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
15 | Message-id: 20220408141550.1271295-25-peter.maydell@linaro.org | ||
16 | --- | ||
17 | hw/intc/gicv3_internal.h | 11 +++++++ | ||
18 | hw/intc/arm_gicv3_cpuif.c | 64 ++++++++++++++++++++++++--------------- | ||
19 | hw/intc/trace-events | 3 +- | ||
20 | 3 files changed, 53 insertions(+), 25 deletions(-) | ||
21 | |||
22 | diff --git a/hw/intc/gicv3_internal.h b/hw/intc/gicv3_internal.h | ||
23 | index XXXXXXX..XXXXXXX 100644 | ||
24 | --- a/hw/intc/gicv3_internal.h | ||
25 | +++ b/hw/intc/gicv3_internal.h | ||
26 | @@ -XXX,XX +XXX,XX @@ void gicv3_init_cpuif(GICv3State *s); | ||
27 | */ | ||
28 | void gicv3_cpuif_update(GICv3CPUState *cs); | ||
29 | |||
30 | +/* | ||
31 | + * gicv3_cpuif_virt_irq_fiq_update: | ||
32 | + * @cs: GICv3CPUState for the CPU to update | ||
33 | + * | ||
34 | + * Recalculate whether to assert the virtual IRQ or FIQ lines after | ||
35 | + * a change to the current highest priority pending virtual interrupt. | ||
36 | + * Note that this does not recalculate and change the maintenance | ||
37 | + * interrupt status (for that, see gicv3_cpuif_virt_update()). | ||
38 | + */ | ||
39 | +void gicv3_cpuif_virt_irq_fiq_update(GICv3CPUState *cs); | ||
40 | + | ||
41 | static inline uint32_t gicv3_iidr(void) | ||
42 | { | ||
43 | /* Return the Implementer Identification Register value | ||
44 | diff --git a/hw/intc/arm_gicv3_cpuif.c b/hw/intc/arm_gicv3_cpuif.c | ||
45 | index XXXXXXX..XXXXXXX 100644 | ||
46 | --- a/hw/intc/arm_gicv3_cpuif.c | ||
47 | +++ b/hw/intc/arm_gicv3_cpuif.c | ||
48 | @@ -XXX,XX +XXX,XX @@ static uint32_t maintenance_interrupt_state(GICv3CPUState *cs) | ||
49 | return value; | ||
50 | } | ||
51 | |||
52 | -static void gicv3_cpuif_virt_update(GICv3CPUState *cs) | ||
53 | +void gicv3_cpuif_virt_irq_fiq_update(GICv3CPUState *cs) | ||
54 | { | ||
55 | - /* Tell the CPU about any pending virtual interrupts or | ||
56 | - * maintenance interrupts, following a change to the state | ||
57 | - * of the CPU interface relevant to virtual interrupts. | ||
58 | - * | ||
59 | - * CAUTION: this function will call qemu_set_irq() on the | ||
60 | - * CPU maintenance IRQ line, which is typically wired up | ||
61 | - * to the GIC as a per-CPU interrupt. This means that it | ||
62 | - * will recursively call back into the GIC code via | ||
63 | - * gicv3_redist_set_irq() and thus into the CPU interface code's | ||
64 | - * gicv3_cpuif_update(). It is therefore important that this | ||
65 | - * function is only called as the final action of a CPU interface | ||
66 | - * register write implementation, after all the GIC state | ||
67 | - * fields have been updated. gicv3_cpuif_update() also must | ||
68 | - * not cause this function to be called, but that happens | ||
69 | - * naturally as a result of there being no architectural | ||
70 | - * linkage between the physical and virtual GIC logic. | ||
71 | + /* | ||
72 | + * Tell the CPU about any pending virtual interrupts. | ||
73 | + * This should only be called for changes that affect the | ||
74 | + * vIRQ and vFIQ status and do not change the maintenance | ||
75 | + * interrupt status. This means that unlike gicv3_cpuif_virt_update() | ||
76 | + * this function won't recursively call back into the GIC code. | ||
77 | + * The main use of this is when the redistributor has changed the | ||
78 | + * highest priority pending virtual LPI. | ||
79 | */ | ||
80 | int idx; | ||
81 | int irqlevel = 0; | ||
82 | int fiqlevel = 0; | ||
83 | - int maintlevel = 0; | ||
84 | - ARMCPU *cpu = ARM_CPU(cs->cpu); | ||
85 | |||
86 | idx = hppvi_index(cs); | ||
87 | trace_gicv3_cpuif_virt_update(gicv3_redist_affid(cs), idx); | ||
88 | @@ -XXX,XX +XXX,XX @@ static void gicv3_cpuif_virt_update(GICv3CPUState *cs) | ||
89 | } | ||
90 | } | ||
91 | |||
92 | + trace_gicv3_cpuif_virt_set_irqs(gicv3_redist_affid(cs), fiqlevel, irqlevel); | ||
93 | + qemu_set_irq(cs->parent_vfiq, fiqlevel); | ||
94 | + qemu_set_irq(cs->parent_virq, irqlevel); | ||
95 | +} | ||
96 | + | ||
97 | +static void gicv3_cpuif_virt_update(GICv3CPUState *cs) | ||
98 | +{ | ||
99 | + /* | ||
100 | + * Tell the CPU about any pending virtual interrupts or | ||
101 | + * maintenance interrupts, following a change to the state | ||
102 | + * of the CPU interface relevant to virtual interrupts. | ||
103 | + * | ||
104 | + * CAUTION: this function will call qemu_set_irq() on the | ||
105 | + * CPU maintenance IRQ line, which is typically wired up | ||
106 | + * to the GIC as a per-CPU interrupt. This means that it | ||
107 | + * will recursively call back into the GIC code via | ||
108 | + * gicv3_redist_set_irq() and thus into the CPU interface code's | ||
109 | + * gicv3_cpuif_update(). It is therefore important that this | ||
110 | + * function is only called as the final action of a CPU interface | ||
111 | + * register write implementation, after all the GIC state | ||
112 | + * fields have been updated. gicv3_cpuif_update() also must | ||
113 | + * not cause this function to be called, but that happens | ||
114 | + * naturally as a result of there being no architectural | ||
115 | + * linkage between the physical and virtual GIC logic. | ||
116 | + */ | ||
117 | + ARMCPU *cpu = ARM_CPU(cs->cpu); | ||
118 | + int maintlevel = 0; | ||
119 | + | ||
120 | + gicv3_cpuif_virt_irq_fiq_update(cs); | ||
121 | + | ||
122 | if ((cs->ich_hcr_el2 & ICH_HCR_EL2_EN) && | ||
123 | maintenance_interrupt_state(cs) != 0) { | ||
124 | maintlevel = 1; | ||
125 | } | ||
126 | |||
127 | - trace_gicv3_cpuif_virt_set_irqs(gicv3_redist_affid(cs), fiqlevel, | ||
128 | - irqlevel, maintlevel); | ||
129 | - | ||
130 | - qemu_set_irq(cs->parent_vfiq, fiqlevel); | ||
131 | - qemu_set_irq(cs->parent_virq, irqlevel); | ||
132 | + trace_gicv3_cpuif_virt_set_maint_irq(gicv3_redist_affid(cs), maintlevel); | ||
133 | qemu_set_irq(cpu->gicv3_maintenance_interrupt, maintlevel); | ||
134 | } | ||
135 | |||
136 | diff --git a/hw/intc/trace-events b/hw/intc/trace-events | ||
137 | index XXXXXXX..XXXXXXX 100644 | ||
138 | --- a/hw/intc/trace-events | ||
139 | +++ b/hw/intc/trace-events | ||
140 | @@ -XXX,XX +XXX,XX @@ gicv3_icv_dir_write(uint32_t cpu, uint64_t val) "GICv3 ICV_DIR write cpu 0x%x va | ||
141 | gicv3_icv_iar_read(int grp, uint32_t cpu, uint64_t val) "GICv3 ICV_IAR%d read cpu 0x%x value 0x%" PRIx64 | ||
142 | gicv3_icv_eoir_write(int grp, uint32_t cpu, uint64_t val) "GICv3 ICV_EOIR%d write cpu 0x%x value 0x%" PRIx64 | ||
143 | gicv3_cpuif_virt_update(uint32_t cpuid, int idx) "GICv3 CPU i/f 0x%x virt HPPI update LR index %d" | ||
144 | -gicv3_cpuif_virt_set_irqs(uint32_t cpuid, int fiqlevel, int irqlevel, int maintlevel) "GICv3 CPU i/f 0x%x virt HPPI update: setting FIQ %d IRQ %d maintenance-irq %d" | ||
145 | +gicv3_cpuif_virt_set_irqs(uint32_t cpuid, int fiqlevel, int irqlevel) "GICv3 CPU i/f 0x%x virt HPPI update: setting FIQ %d IRQ %d" | ||
146 | +gicv3_cpuif_virt_set_maint_irq(uint32_t cpuid, int maintlevel) "GICv3 CPU i/f 0x%x virt HPPI update: setting maintenance-irq %d" | ||
147 | |||
148 | # arm_gicv3_dist.c | ||
149 | gicv3_dist_read(uint64_t offset, uint64_t data, unsigned size, bool secure) "GICv3 distributor read: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u secure %d" | ||
150 | -- | ||
151 | 2.25.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | The CPU interface changes to support vLPIs are fairly minor: | ||
2 | in the parts of the code that currently look at the list registers | ||
3 | to determine the highest priority pending virtual interrupt, we | ||
4 | must also look at the highest priority pending vLPI. To do this | ||
5 | we change hppvi_index() to check the vLPI and return a special-case | ||
6 | value if that is the right virtual interrupt to take. The callsites | ||
7 | (which handle HPPIR and IAR registers and the "raise vIRQ and vFIQ | ||
8 | lines" code) then have to handle this special-case value. | ||
1 | 9 | ||
10 | This commit includes two interfaces with the as-yet-unwritten | ||
11 | redistributor code: | ||
12 | * the new GICv3CPUState::hppvlpi will be set by the redistributor | ||
13 | (in the same way as the existing hpplpi does for physical LPIs) | ||
14 | * when the CPU interface acknowledges a vLPI it needs to set it | ||
15 | to non-pending; the new gicv3_redist_vlpi_pending() function | ||
16 | (which matches the existing gicv3_redist_lpi_pending() used | ||
17 | for physical LPIs) is a stub that will be filled in later | ||
18 | |||
19 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
20 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
21 | Message-id: 20220408141550.1271295-26-peter.maydell@linaro.org | ||
22 | --- | ||
23 | hw/intc/gicv3_internal.h | 13 ++++ | ||
24 | include/hw/intc/arm_gicv3_common.h | 3 + | ||
25 | hw/intc/arm_gicv3_common.c | 1 + | ||
26 | hw/intc/arm_gicv3_cpuif.c | 119 +++++++++++++++++++++++++++-- | ||
27 | hw/intc/arm_gicv3_redist.c | 8 ++ | ||
28 | hw/intc/trace-events | 2 +- | ||
29 | 6 files changed, 140 insertions(+), 6 deletions(-) | ||
30 | |||
31 | diff --git a/hw/intc/gicv3_internal.h b/hw/intc/gicv3_internal.h | ||
32 | index XXXXXXX..XXXXXXX 100644 | ||
33 | --- a/hw/intc/gicv3_internal.h | ||
34 | +++ b/hw/intc/gicv3_internal.h | ||
35 | @@ -XXX,XX +XXX,XX @@ void gicv3_redist_process_lpi(GICv3CPUState *cs, int irq, int level); | ||
36 | */ | ||
37 | void gicv3_redist_process_vlpi(GICv3CPUState *cs, int irq, uint64_t vptaddr, | ||
38 | int doorbell, int level); | ||
39 | +/** | ||
40 | + * gicv3_redist_vlpi_pending: | ||
41 | + * @cs: GICv3CPUState | ||
42 | + * @irq: (virtual) interrupt number | ||
43 | + * @level: level to set @irq to | ||
44 | + * | ||
45 | + * Set/clear the pending status of a virtual LPI in the vLPI table | ||
46 | + * that this redistributor is currently using. (The difference between | ||
47 | + * this and gicv3_redist_process_vlpi() is that this is called from | ||
48 | + * the cpuif and does not need to do the not-running-on-this-vcpu checks.) | ||
49 | + */ | ||
50 | +void gicv3_redist_vlpi_pending(GICv3CPUState *cs, int irq, int level); | ||
51 | + | ||
52 | void gicv3_redist_lpi_pending(GICv3CPUState *cs, int irq, int level); | ||
53 | /** | ||
54 | * gicv3_redist_update_lpi: | ||
55 | diff --git a/include/hw/intc/arm_gicv3_common.h b/include/hw/intc/arm_gicv3_common.h | ||
56 | index XXXXXXX..XXXXXXX 100644 | ||
57 | --- a/include/hw/intc/arm_gicv3_common.h | ||
58 | +++ b/include/hw/intc/arm_gicv3_common.h | ||
59 | @@ -XXX,XX +XXX,XX @@ struct GICv3CPUState { | ||
60 | */ | ||
61 | PendingIrq hpplpi; | ||
62 | |||
63 | + /* Cached information recalculated from vLPI tables in guest memory */ | ||
64 | + PendingIrq hppvlpi; | ||
65 | + | ||
66 | /* This is temporary working state, to avoid a malloc in gicv3_update() */ | ||
67 | bool seenbetter; | ||
68 | }; | ||
69 | diff --git a/hw/intc/arm_gicv3_common.c b/hw/intc/arm_gicv3_common.c | ||
70 | index XXXXXXX..XXXXXXX 100644 | ||
71 | --- a/hw/intc/arm_gicv3_common.c | ||
72 | +++ b/hw/intc/arm_gicv3_common.c | ||
73 | @@ -XXX,XX +XXX,XX @@ static void arm_gicv3_common_reset(DeviceState *dev) | ||
74 | |||
75 | cs->hppi.prio = 0xff; | ||
76 | cs->hpplpi.prio = 0xff; | ||
77 | + cs->hppvlpi.prio = 0xff; | ||
78 | |||
79 | /* State in the CPU interface must *not* be reset here, because it | ||
80 | * is part of the CPU's reset domain, not the GIC device's. | ||
81 | diff --git a/hw/intc/arm_gicv3_cpuif.c b/hw/intc/arm_gicv3_cpuif.c | ||
82 | index XXXXXXX..XXXXXXX 100644 | ||
83 | --- a/hw/intc/arm_gicv3_cpuif.c | ||
84 | +++ b/hw/intc/arm_gicv3_cpuif.c | ||
85 | @@ -XXX,XX +XXX,XX @@ | ||
86 | #include "hw/irq.h" | ||
87 | #include "cpu.h" | ||
88 | |||
89 | +/* | ||
90 | + * Special case return value from hppvi_index(); must be larger than | ||
91 | + * the architecturally maximum possible list register index (which is 15) | ||
92 | + */ | ||
93 | +#define HPPVI_INDEX_VLPI 16 | ||
94 | + | ||
95 | static GICv3CPUState *icc_cs_from_env(CPUARMState *env) | ||
96 | { | ||
97 | return env->gicv3state; | ||
98 | @@ -XXX,XX +XXX,XX @@ static int ich_highest_active_virt_prio(GICv3CPUState *cs) | ||
99 | |||
100 | static int hppvi_index(GICv3CPUState *cs) | ||
101 | { | ||
102 | - /* Return the list register index of the highest priority pending | ||
103 | + /* | ||
104 | + * Return the list register index of the highest priority pending | ||
105 | * virtual interrupt, as per the HighestPriorityVirtualInterrupt | ||
106 | * pseudocode. If no pending virtual interrupts, return -1. | ||
107 | + * If the highest priority pending virtual interrupt is a vLPI, | ||
108 | + * return HPPVI_INDEX_VLPI. | ||
109 | + * (The pseudocode handles checking whether the vLPI is higher | ||
110 | + * priority than the highest priority list register at every | ||
111 | + * callsite of HighestPriorityVirtualInterrupt; we check it here.) | ||
112 | */ | ||
113 | + ARMCPU *cpu = ARM_CPU(cs->cpu); | ||
114 | + CPUARMState *env = &cpu->env; | ||
115 | int idx = -1; | ||
116 | int i; | ||
117 | /* Note that a list register entry with a priority of 0xff will | ||
118 | @@ -XXX,XX +XXX,XX @@ static int hppvi_index(GICv3CPUState *cs) | ||
119 | } | ||
120 | } | ||
121 | |||
122 | + /* | ||
123 | + * "no pending vLPI" is indicated with prio = 0xff, which always | ||
124 | + * fails the priority check here. vLPIs are only considered | ||
125 | + * when we are in Non-Secure state. | ||
126 | + */ | ||
127 | + if (cs->hppvlpi.prio < prio && !arm_is_secure(env)) { | ||
128 | + if (cs->hppvlpi.grp == GICV3_G0) { | ||
129 | + if (cs->ich_vmcr_el2 & ICH_VMCR_EL2_VENG0) { | ||
130 | + return HPPVI_INDEX_VLPI; | ||
131 | + } | ||
132 | + } else { | ||
133 | + if (cs->ich_vmcr_el2 & ICH_VMCR_EL2_VENG1) { | ||
134 | + return HPPVI_INDEX_VLPI; | ||
135 | + } | ||
136 | + } | ||
137 | + } | ||
138 | + | ||
139 | return idx; | ||
140 | } | ||
141 | |||
142 | @@ -XXX,XX +XXX,XX @@ static bool icv_hppi_can_preempt(GICv3CPUState *cs, uint64_t lr) | ||
143 | return false; | ||
144 | } | ||
145 | |||
146 | +static bool icv_hppvlpi_can_preempt(GICv3CPUState *cs) | ||
147 | +{ | ||
148 | + /* | ||
149 | + * Return true if we can signal the highest priority pending vLPI. | ||
150 | + * We can assume we're Non-secure because hppvi_index() already | ||
151 | + * tested for that. | ||
152 | + */ | ||
153 | + uint32_t mask, rprio, vpmr; | ||
154 | + | ||
155 | + if (!(cs->ich_hcr_el2 & ICH_HCR_EL2_EN)) { | ||
156 | + /* Virtual interface disabled */ | ||
157 | + return false; | ||
158 | + } | ||
159 | + | ||
160 | + vpmr = extract64(cs->ich_vmcr_el2, ICH_VMCR_EL2_VPMR_SHIFT, | ||
161 | + ICH_VMCR_EL2_VPMR_LENGTH); | ||
162 | + | ||
163 | + if (cs->hppvlpi.prio >= vpmr) { | ||
164 | + /* Priority mask masks this interrupt */ | ||
165 | + return false; | ||
166 | + } | ||
167 | + | ||
168 | + rprio = ich_highest_active_virt_prio(cs); | ||
169 | + if (rprio == 0xff) { | ||
170 | + /* No running interrupt so we can preempt */ | ||
171 | + return true; | ||
172 | + } | ||
173 | + | ||
174 | + mask = icv_gprio_mask(cs, cs->hppvlpi.grp); | ||
175 | + | ||
176 | + /* | ||
177 | + * We only preempt a running interrupt if the pending interrupt's | ||
178 | + * group priority is sufficient (the subpriorities are not considered). | ||
179 | + */ | ||
180 | + if ((cs->hppvlpi.prio & mask) < (rprio & mask)) { | ||
181 | + return true; | ||
182 | + } | ||
183 | + | ||
184 | + return false; | ||
185 | +} | ||
186 | + | ||
187 | static uint32_t eoi_maintenance_interrupt_state(GICv3CPUState *cs, | ||
188 | uint32_t *misr) | ||
189 | { | ||
190 | @@ -XXX,XX +XXX,XX @@ void gicv3_cpuif_virt_irq_fiq_update(GICv3CPUState *cs) | ||
191 | int fiqlevel = 0; | ||
192 | |||
193 | idx = hppvi_index(cs); | ||
194 | - trace_gicv3_cpuif_virt_update(gicv3_redist_affid(cs), idx); | ||
195 | - if (idx >= 0) { | ||
196 | + trace_gicv3_cpuif_virt_update(gicv3_redist_affid(cs), idx, | ||
197 | + cs->hppvlpi.irq, cs->hppvlpi.grp, | ||
198 | + cs->hppvlpi.prio); | ||
199 | + if (idx == HPPVI_INDEX_VLPI) { | ||
200 | + if (icv_hppvlpi_can_preempt(cs)) { | ||
201 | + if (cs->hppvlpi.grp == GICV3_G0) { | ||
202 | + fiqlevel = 1; | ||
203 | + } else { | ||
204 | + irqlevel = 1; | ||
205 | + } | ||
206 | + } | ||
207 | + } else if (idx >= 0) { | ||
208 | uint64_t lr = cs->ich_lr_el2[idx]; | ||
209 | |||
210 | if (icv_hppi_can_preempt(cs, lr)) { | ||
211 | @@ -XXX,XX +XXX,XX @@ static uint64_t icv_hppir_read(CPUARMState *env, const ARMCPRegInfo *ri) | ||
212 | int idx = hppvi_index(cs); | ||
213 | uint64_t value = INTID_SPURIOUS; | ||
214 | |||
215 | - if (idx >= 0) { | ||
216 | + if (idx == HPPVI_INDEX_VLPI) { | ||
217 | + if (cs->hppvlpi.grp == grp) { | ||
218 | + value = cs->hppvlpi.irq; | ||
219 | + } | ||
220 | + } else if (idx >= 0) { | ||
221 | uint64_t lr = cs->ich_lr_el2[idx]; | ||
222 | int thisgrp = (lr & ICH_LR_EL2_GROUP) ? GICV3_G1NS : GICV3_G0; | ||
223 | |||
224 | @@ -XXX,XX +XXX,XX @@ static void icv_activate_irq(GICv3CPUState *cs, int idx, int grp) | ||
225 | cs->ich_apr[grp][regno] |= (1 << regbit); | ||
226 | } | ||
227 | |||
228 | +static void icv_activate_vlpi(GICv3CPUState *cs) | ||
229 | +{ | ||
230 | + uint32_t mask = icv_gprio_mask(cs, cs->hppvlpi.grp); | ||
231 | + int prio = cs->hppvlpi.prio & mask; | ||
232 | + int aprbit = prio >> (8 - cs->vprebits); | ||
233 | + int regno = aprbit / 32; | ||
234 | + int regbit = aprbit % 32; | ||
235 | + | ||
236 | + cs->ich_apr[cs->hppvlpi.grp][regno] |= (1 << regbit); | ||
237 | + gicv3_redist_vlpi_pending(cs, cs->hppvlpi.irq, 0); | ||
238 | +} | ||
239 | + | ||
240 | static uint64_t icv_iar_read(CPUARMState *env, const ARMCPRegInfo *ri) | ||
241 | { | ||
242 | GICv3CPUState *cs = icc_cs_from_env(env); | ||
243 | @@ -XXX,XX +XXX,XX @@ static uint64_t icv_iar_read(CPUARMState *env, const ARMCPRegInfo *ri) | ||
244 | int idx = hppvi_index(cs); | ||
245 | uint64_t intid = INTID_SPURIOUS; | ||
246 | |||
247 | - if (idx >= 0) { | ||
248 | + if (idx == HPPVI_INDEX_VLPI) { | ||
249 | + if (cs->hppvlpi.grp == grp && icv_hppvlpi_can_preempt(cs)) { | ||
250 | + intid = cs->hppvlpi.irq; | ||
251 | + icv_activate_vlpi(cs); | ||
252 | + } | ||
253 | + } else if (idx >= 0) { | ||
254 | uint64_t lr = cs->ich_lr_el2[idx]; | ||
255 | int thisgrp = (lr & ICH_LR_EL2_GROUP) ? GICV3_G1NS : GICV3_G0; | ||
256 | |||
257 | @@ -XXX,XX +XXX,XX @@ static void gicv3_cpuif_el_change_hook(ARMCPU *cpu, void *opaque) | ||
258 | GICv3CPUState *cs = opaque; | ||
259 | |||
260 | gicv3_cpuif_update(cs); | ||
261 | + /* | ||
262 | + * Because vLPIs are only pending in NonSecure state, | ||
263 | + * an EL change can change the VIRQ/VFIQ status (but | ||
264 | + * cannot affect the maintenance interrupt state) | ||
265 | + */ | ||
266 | + gicv3_cpuif_virt_irq_fiq_update(cs); | ||
267 | } | ||
268 | |||
269 | void gicv3_init_cpuif(GICv3State *s) | ||
270 | diff --git a/hw/intc/arm_gicv3_redist.c b/hw/intc/arm_gicv3_redist.c | ||
271 | index XXXXXXX..XXXXXXX 100644 | ||
272 | --- a/hw/intc/arm_gicv3_redist.c | ||
273 | +++ b/hw/intc/arm_gicv3_redist.c | ||
274 | @@ -XXX,XX +XXX,XX @@ void gicv3_redist_movall_lpis(GICv3CPUState *src, GICv3CPUState *dest) | ||
275 | gicv3_redist_update_lpi(dest); | ||
276 | } | ||
277 | |||
278 | +void gicv3_redist_vlpi_pending(GICv3CPUState *cs, int irq, int level) | ||
279 | +{ | ||
280 | + /* | ||
281 | + * The redistributor handling for changing the pending state | ||
282 | + * of a vLPI will be added in a subsequent commit. | ||
283 | + */ | ||
284 | +} | ||
285 | + | ||
286 | void gicv3_redist_process_vlpi(GICv3CPUState *cs, int irq, uint64_t vptaddr, | ||
287 | int doorbell, int level) | ||
288 | { | ||
289 | diff --git a/hw/intc/trace-events b/hw/intc/trace-events | ||
290 | index XXXXXXX..XXXXXXX 100644 | ||
291 | --- a/hw/intc/trace-events | ||
292 | +++ b/hw/intc/trace-events | ||
293 | @@ -XXX,XX +XXX,XX @@ gicv3_icv_hppir_read(int grp, uint32_t cpu, uint64_t val) "GICv3 ICV_HPPIR%d rea | ||
294 | gicv3_icv_dir_write(uint32_t cpu, uint64_t val) "GICv3 ICV_DIR write cpu 0x%x value 0x%" PRIx64 | ||
295 | gicv3_icv_iar_read(int grp, uint32_t cpu, uint64_t val) "GICv3 ICV_IAR%d read cpu 0x%x value 0x%" PRIx64 | ||
296 | gicv3_icv_eoir_write(int grp, uint32_t cpu, uint64_t val) "GICv3 ICV_EOIR%d write cpu 0x%x value 0x%" PRIx64 | ||
297 | -gicv3_cpuif_virt_update(uint32_t cpuid, int idx) "GICv3 CPU i/f 0x%x virt HPPI update LR index %d" | ||
298 | +gicv3_cpuif_virt_update(uint32_t cpuid, int idx, int hppvlpi, int grp, int prio) "GICv3 CPU i/f 0x%x virt HPPI update LR index %d HPPVLPI %d grp %d prio %d" | ||
299 | gicv3_cpuif_virt_set_irqs(uint32_t cpuid, int fiqlevel, int irqlevel) "GICv3 CPU i/f 0x%x virt HPPI update: setting FIQ %d IRQ %d" | ||
300 | gicv3_cpuif_virt_set_maint_irq(uint32_t cpuid, int maintlevel) "GICv3 CPU i/f 0x%x virt HPPI update: setting maintenance-irq %d" | ||
301 | |||
302 | -- | ||
303 | 2.25.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | The maintenance interrupt state depends only on: | ||
2 | * ICH_HCR_EL2 | ||
3 | * ICH_LR<n>_EL2 | ||
4 | * ICH_VMCR_EL2 fields VENG0 and VENG1 | ||
1 | 5 | ||
6 | Now we have a separate function that updates only the vIRQ and vFIQ | ||
7 | lines, use that in places that only change state that affects vIRQ | ||
8 | and vFIQ but not the maintenance interrupt. | ||
9 | |||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
12 | Message-id: 20220408141550.1271295-27-peter.maydell@linaro.org | ||
13 | --- | ||
14 | hw/intc/arm_gicv3_cpuif.c | 10 +++++----- | ||
15 | 1 file changed, 5 insertions(+), 5 deletions(-) | ||
16 | |||
17 | diff --git a/hw/intc/arm_gicv3_cpuif.c b/hw/intc/arm_gicv3_cpuif.c | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/hw/intc/arm_gicv3_cpuif.c | ||
20 | +++ b/hw/intc/arm_gicv3_cpuif.c | ||
21 | @@ -XXX,XX +XXX,XX @@ static void icv_ap_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
22 | |||
23 | cs->ich_apr[grp][regno] = value & 0xFFFFFFFFU; | ||
24 | |||
25 | - gicv3_cpuif_virt_update(cs); | ||
26 | + gicv3_cpuif_virt_irq_fiq_update(cs); | ||
27 | return; | ||
28 | } | ||
29 | |||
30 | @@ -XXX,XX +XXX,XX @@ static void icv_bpr_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
31 | |||
32 | write_vbpr(cs, grp, value); | ||
33 | |||
34 | - gicv3_cpuif_virt_update(cs); | ||
35 | + gicv3_cpuif_virt_irq_fiq_update(cs); | ||
36 | } | ||
37 | |||
38 | static uint64_t icv_pmr_read(CPUARMState *env, const ARMCPRegInfo *ri) | ||
39 | @@ -XXX,XX +XXX,XX @@ static void icv_pmr_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
40 | cs->ich_vmcr_el2 = deposit64(cs->ich_vmcr_el2, ICH_VMCR_EL2_VPMR_SHIFT, | ||
41 | ICH_VMCR_EL2_VPMR_LENGTH, value); | ||
42 | |||
43 | - gicv3_cpuif_virt_update(cs); | ||
44 | + gicv3_cpuif_virt_irq_fiq_update(cs); | ||
45 | } | ||
46 | |||
47 | static uint64_t icv_igrpen_read(CPUARMState *env, const ARMCPRegInfo *ri) | ||
48 | @@ -XXX,XX +XXX,XX @@ static void icv_ctlr_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
49 | cs->ich_vmcr_el2 = deposit64(cs->ich_vmcr_el2, ICH_VMCR_EL2_VEOIM_SHIFT, | ||
50 | 1, value & ICC_CTLR_EL1_EOIMODE ? 1 : 0); | ||
51 | |||
52 | - gicv3_cpuif_virt_update(cs); | ||
53 | + gicv3_cpuif_virt_irq_fiq_update(cs); | ||
54 | } | ||
55 | |||
56 | static uint64_t icv_rpr_read(CPUARMState *env, const ARMCPRegInfo *ri) | ||
57 | @@ -XXX,XX +XXX,XX @@ static void ich_ap_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
58 | trace_gicv3_ich_ap_write(ri->crm & 1, regno, gicv3_redist_affid(cs), value); | ||
59 | |||
60 | cs->ich_apr[grp][regno] = value & 0xFFFFFFFFU; | ||
61 | - gicv3_cpuif_virt_update(cs); | ||
62 | + gicv3_cpuif_virt_irq_fiq_update(cs); | ||
63 | } | ||
64 | |||
65 | static uint64_t ich_hcr_read(CPUARMState *env, const ARMCPRegInfo *ri) | ||
66 | -- | ||
67 | 2.25.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Currently the functions which update the highest priority pending LPI | ||
2 | information by looking at the LPI Pending and Configuration tables | ||
3 | are hard-coded to use the physical LPI tables addressed by | ||
4 | GICR_PENDBASER and GICR_PROPBASER. To support virtual LPIs we will | ||
5 | need to do essentially the same job, but looking at the current | ||
6 | virtual LPI Pending and Configuration tables and updating cs->hppvlpi | ||
7 | instead of cs->hpplpi. | ||
1 | 8 | ||
9 | Factor out the common part of the gicv3_redist_check_lpi_priority() | ||
10 | function into a new update_for_one_lpi() function, which updates | ||
11 | a PendingIrq struct if the specified LPI is higher priority than | ||
12 | what is currently recorded there. | ||
13 | |||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
15 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
16 | Message-id: 20220408141550.1271295-28-peter.maydell@linaro.org | ||
17 | --- | ||
18 | hw/intc/arm_gicv3_redist.c | 74 ++++++++++++++++++++++++-------------- | ||
19 | 1 file changed, 47 insertions(+), 27 deletions(-) | ||
20 | |||
21 | diff --git a/hw/intc/arm_gicv3_redist.c b/hw/intc/arm_gicv3_redist.c | ||
22 | index XXXXXXX..XXXXXXX 100644 | ||
23 | --- a/hw/intc/arm_gicv3_redist.c | ||
24 | +++ b/hw/intc/arm_gicv3_redist.c | ||
25 | @@ -XXX,XX +XXX,XX @@ static uint32_t gicr_read_bitmap_reg(GICv3CPUState *cs, MemTxAttrs attrs, | ||
26 | return reg; | ||
27 | } | ||
28 | |||
29 | +/** | ||
30 | + * update_for_one_lpi: Update pending information if this LPI is better | ||
31 | + * | ||
32 | + * @cs: GICv3CPUState | ||
33 | + * @irq: interrupt to look up in the LPI Configuration table | ||
34 | + * @ctbase: physical address of the LPI Configuration table to use | ||
35 | + * @ds: true if priority value should not be shifted | ||
36 | + * @hpp: points to pending information to update | ||
37 | + * | ||
38 | + * Look up @irq in the Configuration table specified by @ctbase | ||
39 | + * to see if it is enabled and what its priority is. If it is an | ||
40 | + * enabled interrupt with a higher priority than that currently | ||
41 | + * recorded in @hpp, update @hpp. | ||
42 | + */ | ||
43 | +static void update_for_one_lpi(GICv3CPUState *cs, int irq, | ||
44 | + uint64_t ctbase, bool ds, PendingIrq *hpp) | ||
45 | +{ | ||
46 | + uint8_t lpite; | ||
47 | + uint8_t prio; | ||
48 | + | ||
49 | + address_space_read(&cs->gic->dma_as, | ||
50 | + ctbase + ((irq - GICV3_LPI_INTID_START) * sizeof(lpite)), | ||
51 | + MEMTXATTRS_UNSPECIFIED, &lpite, sizeof(lpite)); | ||
52 | + | ||
53 | + if (!(lpite & LPI_CTE_ENABLED)) { | ||
54 | + return; | ||
55 | + } | ||
56 | + | ||
57 | + if (ds) { | ||
58 | + prio = lpite & LPI_PRIORITY_MASK; | ||
59 | + } else { | ||
60 | + prio = ((lpite & LPI_PRIORITY_MASK) >> 1) | 0x80; | ||
61 | + } | ||
62 | + | ||
63 | + if ((prio < hpp->prio) || | ||
64 | + ((prio == hpp->prio) && (irq <= hpp->irq))) { | ||
65 | + hpp->irq = irq; | ||
66 | + hpp->prio = prio; | ||
67 | + /* LPIs and vLPIs are always non-secure Grp1 interrupts */ | ||
68 | + hpp->grp = GICV3_G1NS; | ||
69 | + } | ||
70 | +} | ||
71 | + | ||
72 | static uint8_t gicr_read_ipriorityr(GICv3CPUState *cs, MemTxAttrs attrs, | ||
73 | int irq) | ||
74 | { | ||
75 | @@ -XXX,XX +XXX,XX @@ MemTxResult gicv3_redist_write(void *opaque, hwaddr offset, uint64_t data, | ||
76 | |||
77 | static void gicv3_redist_check_lpi_priority(GICv3CPUState *cs, int irq) | ||
78 | { | ||
79 | - AddressSpace *as = &cs->gic->dma_as; | ||
80 | - uint64_t lpict_baddr; | ||
81 | - uint8_t lpite; | ||
82 | - uint8_t prio; | ||
83 | + uint64_t lpict_baddr = cs->gicr_propbaser & R_GICR_PROPBASER_PHYADDR_MASK; | ||
84 | |||
85 | - lpict_baddr = cs->gicr_propbaser & R_GICR_PROPBASER_PHYADDR_MASK; | ||
86 | - | ||
87 | - address_space_read(as, lpict_baddr + ((irq - GICV3_LPI_INTID_START) * | ||
88 | - sizeof(lpite)), MEMTXATTRS_UNSPECIFIED, &lpite, | ||
89 | - sizeof(lpite)); | ||
90 | - | ||
91 | - if (!(lpite & LPI_CTE_ENABLED)) { | ||
92 | - return; | ||
93 | - } | ||
94 | - | ||
95 | - if (cs->gic->gicd_ctlr & GICD_CTLR_DS) { | ||
96 | - prio = lpite & LPI_PRIORITY_MASK; | ||
97 | - } else { | ||
98 | - prio = ((lpite & LPI_PRIORITY_MASK) >> 1) | 0x80; | ||
99 | - } | ||
100 | - | ||
101 | - if ((prio < cs->hpplpi.prio) || | ||
102 | - ((prio == cs->hpplpi.prio) && (irq <= cs->hpplpi.irq))) { | ||
103 | - cs->hpplpi.irq = irq; | ||
104 | - cs->hpplpi.prio = prio; | ||
105 | - /* LPIs are always non-secure Grp1 interrupts */ | ||
106 | - cs->hpplpi.grp = GICV3_G1NS; | ||
107 | - } | ||
108 | + update_for_one_lpi(cs, irq, lpict_baddr, | ||
109 | + cs->gic->gicd_ctlr & GICD_CTLR_DS, | ||
110 | + &cs->hpplpi); | ||
111 | } | ||
112 | |||
113 | void gicv3_redist_update_lpi_only(GICv3CPUState *cs) | ||
114 | -- | ||
115 | 2.25.1 | diff view generated by jsdifflib |
1 | This commit is the result of running the timer-del-timer-free.cocci | 1 | Factor out the common part of gicv3_redist_update_lpi_only() into |
---|---|---|---|
2 | script on the whole source tree. | 2 | a new function update_for_all_lpis(), which does a full rescan |
3 | of an LPI Pending table and sets the specified PendingIrq struct | ||
4 | with the highest priority pending enabled LPI it finds. | ||
3 | 5 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Acked-by: Corey Minyard <cminyard@mvista.com> | ||
6 | Acked-by: Paolo Bonzini <pbonzini@redhat.com> | ||
7 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
9 | Message-id: 20201215154107.3255-4-peter.maydell@linaro.org | 8 | Message-id: 20220408141550.1271295-29-peter.maydell@linaro.org |
10 | --- | 9 | --- |
11 | block/iscsi.c | 2 -- | 10 | hw/intc/arm_gicv3_redist.c | 66 ++++++++++++++++++++++++++------------ |
12 | block/nbd.c | 1 - | 11 | 1 file changed, 46 insertions(+), 20 deletions(-) |
13 | block/qcow2.c | 1 - | ||
14 | hw/block/nvme.c | 2 -- | ||
15 | hw/char/serial.c | 2 -- | ||
16 | hw/char/virtio-serial-bus.c | 2 -- | ||
17 | hw/ide/core.c | 1 - | ||
18 | hw/input/hid.c | 1 - | ||
19 | hw/intc/apic.c | 1 - | ||
20 | hw/intc/ioapic.c | 1 - | ||
21 | hw/ipmi/ipmi_bmc_extern.c | 1 - | ||
22 | hw/net/e1000.c | 3 --- | ||
23 | hw/net/e1000e_core.c | 8 -------- | ||
24 | hw/net/pcnet-pci.c | 1 - | ||
25 | hw/net/rtl8139.c | 1 - | ||
26 | hw/net/spapr_llan.c | 1 - | ||
27 | hw/net/virtio-net.c | 2 -- | ||
28 | hw/s390x/s390-pci-inst.c | 1 - | ||
29 | hw/sd/sd.c | 1 - | ||
30 | hw/sd/sdhci.c | 2 -- | ||
31 | hw/usb/dev-hub.c | 1 - | ||
32 | hw/usb/hcd-ehci.c | 1 - | ||
33 | hw/usb/hcd-ohci-pci.c | 1 - | ||
34 | hw/usb/hcd-uhci.c | 1 - | ||
35 | hw/usb/hcd-xhci.c | 1 - | ||
36 | hw/usb/redirect.c | 1 - | ||
37 | hw/vfio/display.c | 1 - | ||
38 | hw/virtio/vhost-vsock-common.c | 1 - | ||
39 | hw/virtio/virtio-balloon.c | 1 - | ||
40 | hw/virtio/virtio-rng.c | 1 - | ||
41 | hw/watchdog/wdt_diag288.c | 1 - | ||
42 | hw/watchdog/wdt_i6300esb.c | 1 - | ||
43 | migration/colo.c | 1 - | ||
44 | monitor/hmp-cmds.c | 1 - | ||
45 | net/announce.c | 1 - | ||
46 | net/colo-compare.c | 1 - | ||
47 | net/slirp.c | 1 - | ||
48 | replay/replay-debugging.c | 1 - | ||
49 | target/s390x/cpu.c | 2 -- | ||
50 | ui/console.c | 1 - | ||
51 | ui/spice-core.c | 1 - | ||
52 | util/throttle.c | 1 - | ||
53 | 42 files changed, 58 deletions(-) | ||
54 | 12 | ||
55 | diff --git a/block/iscsi.c b/block/iscsi.c | 13 | diff --git a/hw/intc/arm_gicv3_redist.c b/hw/intc/arm_gicv3_redist.c |
56 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
57 | --- a/block/iscsi.c | 15 | --- a/hw/intc/arm_gicv3_redist.c |
58 | +++ b/block/iscsi.c | 16 | +++ b/hw/intc/arm_gicv3_redist.c |
59 | @@ -XXX,XX +XXX,XX @@ static void iscsi_detach_aio_context(BlockDriverState *bs) | 17 | @@ -XXX,XX +XXX,XX @@ static void update_for_one_lpi(GICv3CPUState *cs, int irq, |
60 | iscsilun->events = 0; | ||
61 | |||
62 | if (iscsilun->nop_timer) { | ||
63 | - timer_del(iscsilun->nop_timer); | ||
64 | timer_free(iscsilun->nop_timer); | ||
65 | iscsilun->nop_timer = NULL; | ||
66 | } | ||
67 | if (iscsilun->event_timer) { | ||
68 | - timer_del(iscsilun->event_timer); | ||
69 | timer_free(iscsilun->event_timer); | ||
70 | iscsilun->event_timer = NULL; | ||
71 | } | ||
72 | diff --git a/block/nbd.c b/block/nbd.c | ||
73 | index XXXXXXX..XXXXXXX 100644 | ||
74 | --- a/block/nbd.c | ||
75 | +++ b/block/nbd.c | ||
76 | @@ -XXX,XX +XXX,XX @@ static void nbd_recv_coroutines_wake_all(BDRVNBDState *s) | ||
77 | static void reconnect_delay_timer_del(BDRVNBDState *s) | ||
78 | { | ||
79 | if (s->reconnect_delay_timer) { | ||
80 | - timer_del(s->reconnect_delay_timer); | ||
81 | timer_free(s->reconnect_delay_timer); | ||
82 | s->reconnect_delay_timer = NULL; | ||
83 | } | ||
84 | diff --git a/block/qcow2.c b/block/qcow2.c | ||
85 | index XXXXXXX..XXXXXXX 100644 | ||
86 | --- a/block/qcow2.c | ||
87 | +++ b/block/qcow2.c | ||
88 | @@ -XXX,XX +XXX,XX @@ static void cache_clean_timer_del(BlockDriverState *bs) | ||
89 | { | ||
90 | BDRVQcow2State *s = bs->opaque; | ||
91 | if (s->cache_clean_timer) { | ||
92 | - timer_del(s->cache_clean_timer); | ||
93 | timer_free(s->cache_clean_timer); | ||
94 | s->cache_clean_timer = NULL; | ||
95 | } | ||
96 | diff --git a/hw/block/nvme.c b/hw/block/nvme.c | ||
97 | index XXXXXXX..XXXXXXX 100644 | ||
98 | --- a/hw/block/nvme.c | ||
99 | +++ b/hw/block/nvme.c | ||
100 | @@ -XXX,XX +XXX,XX @@ static uint16_t nvme_io_cmd(NvmeCtrl *n, NvmeRequest *req) | ||
101 | static void nvme_free_sq(NvmeSQueue *sq, NvmeCtrl *n) | ||
102 | { | ||
103 | n->sq[sq->sqid] = NULL; | ||
104 | - timer_del(sq->timer); | ||
105 | timer_free(sq->timer); | ||
106 | g_free(sq->io_req); | ||
107 | if (sq->sqid) { | ||
108 | @@ -XXX,XX +XXX,XX @@ static uint16_t nvme_get_log(NvmeCtrl *n, NvmeRequest *req) | ||
109 | static void nvme_free_cq(NvmeCQueue *cq, NvmeCtrl *n) | ||
110 | { | ||
111 | n->cq[cq->cqid] = NULL; | ||
112 | - timer_del(cq->timer); | ||
113 | timer_free(cq->timer); | ||
114 | msix_vector_unuse(&n->parent_obj, cq->vector); | ||
115 | if (cq->cqid) { | ||
116 | diff --git a/hw/char/serial.c b/hw/char/serial.c | ||
117 | index XXXXXXX..XXXXXXX 100644 | ||
118 | --- a/hw/char/serial.c | ||
119 | +++ b/hw/char/serial.c | ||
120 | @@ -XXX,XX +XXX,XX @@ static void serial_unrealize(DeviceState *dev) | ||
121 | |||
122 | qemu_chr_fe_deinit(&s->chr, false); | ||
123 | |||
124 | - timer_del(s->modem_status_poll); | ||
125 | timer_free(s->modem_status_poll); | ||
126 | |||
127 | - timer_del(s->fifo_timeout_timer); | ||
128 | timer_free(s->fifo_timeout_timer); | ||
129 | |||
130 | fifo8_destroy(&s->recv_fifo); | ||
131 | diff --git a/hw/char/virtio-serial-bus.c b/hw/char/virtio-serial-bus.c | ||
132 | index XXXXXXX..XXXXXXX 100644 | ||
133 | --- a/hw/char/virtio-serial-bus.c | ||
134 | +++ b/hw/char/virtio-serial-bus.c | ||
135 | @@ -XXX,XX +XXX,XX @@ static void virtio_serial_post_load_timer_cb(void *opaque) | ||
136 | } | ||
137 | } | ||
138 | g_free(s->post_load->connected); | ||
139 | - timer_del(s->post_load->timer); | ||
140 | timer_free(s->post_load->timer); | ||
141 | g_free(s->post_load); | ||
142 | s->post_load = NULL; | ||
143 | @@ -XXX,XX +XXX,XX @@ static void virtio_serial_device_unrealize(DeviceState *dev) | ||
144 | g_free(vser->ports_map); | ||
145 | if (vser->post_load) { | ||
146 | g_free(vser->post_load->connected); | ||
147 | - timer_del(vser->post_load->timer); | ||
148 | timer_free(vser->post_load->timer); | ||
149 | g_free(vser->post_load); | ||
150 | } | ||
151 | diff --git a/hw/ide/core.c b/hw/ide/core.c | ||
152 | index XXXXXXX..XXXXXXX 100644 | ||
153 | --- a/hw/ide/core.c | ||
154 | +++ b/hw/ide/core.c | ||
155 | @@ -XXX,XX +XXX,XX @@ void ide_init2(IDEBus *bus, qemu_irq irq) | ||
156 | |||
157 | void ide_exit(IDEState *s) | ||
158 | { | ||
159 | - timer_del(s->sector_write_timer); | ||
160 | timer_free(s->sector_write_timer); | ||
161 | qemu_vfree(s->smart_selftest_data); | ||
162 | qemu_vfree(s->io_buffer); | ||
163 | diff --git a/hw/input/hid.c b/hw/input/hid.c | ||
164 | index XXXXXXX..XXXXXXX 100644 | ||
165 | --- a/hw/input/hid.c | ||
166 | +++ b/hw/input/hid.c | ||
167 | @@ -XXX,XX +XXX,XX @@ static void hid_idle_timer(void *opaque) | ||
168 | static void hid_del_idle_timer(HIDState *hs) | ||
169 | { | ||
170 | if (hs->idle_timer) { | ||
171 | - timer_del(hs->idle_timer); | ||
172 | timer_free(hs->idle_timer); | ||
173 | hs->idle_timer = NULL; | ||
174 | } | ||
175 | diff --git a/hw/intc/apic.c b/hw/intc/apic.c | ||
176 | index XXXXXXX..XXXXXXX 100644 | ||
177 | --- a/hw/intc/apic.c | ||
178 | +++ b/hw/intc/apic.c | ||
179 | @@ -XXX,XX +XXX,XX @@ static void apic_unrealize(DeviceState *dev) | ||
180 | { | ||
181 | APICCommonState *s = APIC(dev); | ||
182 | |||
183 | - timer_del(s->timer); | ||
184 | timer_free(s->timer); | ||
185 | local_apics[s->id] = NULL; | ||
186 | } | ||
187 | diff --git a/hw/intc/ioapic.c b/hw/intc/ioapic.c | ||
188 | index XXXXXXX..XXXXXXX 100644 | ||
189 | --- a/hw/intc/ioapic.c | ||
190 | +++ b/hw/intc/ioapic.c | ||
191 | @@ -XXX,XX +XXX,XX @@ static void ioapic_unrealize(DeviceState *dev) | ||
192 | { | ||
193 | IOAPICCommonState *s = IOAPIC_COMMON(dev); | ||
194 | |||
195 | - timer_del(s->delayed_ioapic_service_timer); | ||
196 | timer_free(s->delayed_ioapic_service_timer); | ||
197 | } | ||
198 | |||
199 | diff --git a/hw/ipmi/ipmi_bmc_extern.c b/hw/ipmi/ipmi_bmc_extern.c | ||
200 | index XXXXXXX..XXXXXXX 100644 | ||
201 | --- a/hw/ipmi/ipmi_bmc_extern.c | ||
202 | +++ b/hw/ipmi/ipmi_bmc_extern.c | ||
203 | @@ -XXX,XX +XXX,XX @@ static void ipmi_bmc_extern_finalize(Object *obj) | ||
204 | { | ||
205 | IPMIBmcExtern *ibe = IPMI_BMC_EXTERN(obj); | ||
206 | |||
207 | - timer_del(ibe->extern_timer); | ||
208 | timer_free(ibe->extern_timer); | ||
209 | } | ||
210 | |||
211 | diff --git a/hw/net/e1000.c b/hw/net/e1000.c | ||
212 | index XXXXXXX..XXXXXXX 100644 | ||
213 | --- a/hw/net/e1000.c | ||
214 | +++ b/hw/net/e1000.c | ||
215 | @@ -XXX,XX +XXX,XX @@ pci_e1000_uninit(PCIDevice *dev) | ||
216 | { | ||
217 | E1000State *d = E1000(dev); | ||
218 | |||
219 | - timer_del(d->autoneg_timer); | ||
220 | timer_free(d->autoneg_timer); | ||
221 | - timer_del(d->mit_timer); | ||
222 | timer_free(d->mit_timer); | ||
223 | - timer_del(d->flush_queue_timer); | ||
224 | timer_free(d->flush_queue_timer); | ||
225 | qemu_del_nic(d->nic); | ||
226 | } | ||
227 | diff --git a/hw/net/e1000e_core.c b/hw/net/e1000e_core.c | ||
228 | index XXXXXXX..XXXXXXX 100644 | ||
229 | --- a/hw/net/e1000e_core.c | ||
230 | +++ b/hw/net/e1000e_core.c | ||
231 | @@ -XXX,XX +XXX,XX @@ e1000e_intrmgr_pci_unint(E1000ECore *core) | ||
232 | { | ||
233 | int i; | ||
234 | |||
235 | - timer_del(core->radv.timer); | ||
236 | timer_free(core->radv.timer); | ||
237 | - timer_del(core->rdtr.timer); | ||
238 | timer_free(core->rdtr.timer); | ||
239 | - timer_del(core->raid.timer); | ||
240 | timer_free(core->raid.timer); | ||
241 | |||
242 | - timer_del(core->tadv.timer); | ||
243 | timer_free(core->tadv.timer); | ||
244 | - timer_del(core->tidv.timer); | ||
245 | timer_free(core->tidv.timer); | ||
246 | |||
247 | - timer_del(core->itr.timer); | ||
248 | timer_free(core->itr.timer); | ||
249 | |||
250 | for (i = 0; i < E1000E_MSIX_VEC_NUM; i++) { | ||
251 | - timer_del(core->eitr[i].timer); | ||
252 | timer_free(core->eitr[i].timer); | ||
253 | } | 18 | } |
254 | } | 19 | } |
255 | @@ -XXX,XX +XXX,XX @@ e1000e_core_pci_uninit(E1000ECore *core) | 20 | |
21 | +/** | ||
22 | + * update_for_all_lpis: Fully scan LPI tables and find best pending LPI | ||
23 | + * | ||
24 | + * @cs: GICv3CPUState | ||
25 | + * @ptbase: physical address of LPI Pending table | ||
26 | + * @ctbase: physical address of LPI Configuration table | ||
27 | + * @ptsizebits: size of tables, specified as number of interrupt ID bits minus 1 | ||
28 | + * @ds: true if priority value should not be shifted | ||
29 | + * @hpp: points to pending information to set | ||
30 | + * | ||
31 | + * Recalculate the highest priority pending enabled LPI from scratch, | ||
32 | + * and set @hpp accordingly. | ||
33 | + * | ||
34 | + * We scan the LPI pending table @ptbase; for each pending LPI, we read the | ||
35 | + * corresponding entry in the LPI configuration table @ctbase to extract | ||
36 | + * the priority and enabled information. | ||
37 | + * | ||
38 | + * We take @ptsizebits in the form idbits-1 because this is the way that | ||
39 | + * LPI table sizes are architecturally specified in GICR_PROPBASER.IDBits | ||
40 | + * and in the VMAPP command's VPT_size field. | ||
41 | + */ | ||
42 | +static void update_for_all_lpis(GICv3CPUState *cs, uint64_t ptbase, | ||
43 | + uint64_t ctbase, unsigned ptsizebits, | ||
44 | + bool ds, PendingIrq *hpp) | ||
45 | +{ | ||
46 | + AddressSpace *as = &cs->gic->dma_as; | ||
47 | + uint8_t pend; | ||
48 | + uint32_t pendt_size = (1ULL << (ptsizebits + 1)); | ||
49 | + int i, bit; | ||
50 | + | ||
51 | + hpp->prio = 0xff; | ||
52 | + | ||
53 | + for (i = GICV3_LPI_INTID_START / 8; i < pendt_size / 8; i++) { | ||
54 | + address_space_read(as, ptbase + i, MEMTXATTRS_UNSPECIFIED, &pend, 1); | ||
55 | + while (pend) { | ||
56 | + bit = ctz32(pend); | ||
57 | + update_for_one_lpi(cs, i * 8 + bit, ctbase, ds, hpp); | ||
58 | + pend &= ~(1 << bit); | ||
59 | + } | ||
60 | + } | ||
61 | +} | ||
62 | + | ||
63 | static uint8_t gicr_read_ipriorityr(GICv3CPUState *cs, MemTxAttrs attrs, | ||
64 | int irq) | ||
256 | { | 65 | { |
257 | int i; | 66 | @@ -XXX,XX +XXX,XX @@ void gicv3_redist_update_lpi_only(GICv3CPUState *cs) |
258 | 67 | * priority is lower than the last computed high priority lpi interrupt. | |
259 | - timer_del(core->autoneg_timer); | 68 | * If yes, replace current LPI as the new high priority lpi interrupt. |
260 | timer_free(core->autoneg_timer); | 69 | */ |
261 | 70 | - AddressSpace *as = &cs->gic->dma_as; | |
262 | e1000e_intrmgr_pci_unint(core); | 71 | - uint64_t lpipt_baddr; |
263 | diff --git a/hw/net/pcnet-pci.c b/hw/net/pcnet-pci.c | 72 | - uint32_t pendt_size = 0; |
264 | index XXXXXXX..XXXXXXX 100644 | 73 | - uint8_t pend; |
265 | --- a/hw/net/pcnet-pci.c | 74 | - int i, bit; |
266 | +++ b/hw/net/pcnet-pci.c | 75 | + uint64_t lpipt_baddr, lpict_baddr; |
267 | @@ -XXX,XX +XXX,XX @@ static void pci_pcnet_uninit(PCIDevice *dev) | 76 | uint64_t idbits; |
268 | PCIPCNetState *d = PCI_PCNET(dev); | 77 | |
269 | 78 | idbits = MIN(FIELD_EX64(cs->gicr_propbaser, GICR_PROPBASER, IDBITS), | |
270 | qemu_free_irq(d->state.irq); | 79 | @@ -XXX,XX +XXX,XX @@ void gicv3_redist_update_lpi_only(GICv3CPUState *cs) |
271 | - timer_del(d->state.poll_timer); | ||
272 | timer_free(d->state.poll_timer); | ||
273 | qemu_del_nic(d->state.nic); | ||
274 | } | ||
275 | diff --git a/hw/net/rtl8139.c b/hw/net/rtl8139.c | ||
276 | index XXXXXXX..XXXXXXX 100644 | ||
277 | --- a/hw/net/rtl8139.c | ||
278 | +++ b/hw/net/rtl8139.c | ||
279 | @@ -XXX,XX +XXX,XX @@ static void pci_rtl8139_uninit(PCIDevice *dev) | ||
280 | |||
281 | g_free(s->cplus_txbuffer); | ||
282 | s->cplus_txbuffer = NULL; | ||
283 | - timer_del(s->timer); | ||
284 | timer_free(s->timer); | ||
285 | qemu_del_nic(s->nic); | ||
286 | } | ||
287 | diff --git a/hw/net/spapr_llan.c b/hw/net/spapr_llan.c | ||
288 | index XXXXXXX..XXXXXXX 100644 | ||
289 | --- a/hw/net/spapr_llan.c | ||
290 | +++ b/hw/net/spapr_llan.c | ||
291 | @@ -XXX,XX +XXX,XX @@ static void spapr_vlan_instance_finalize(Object *obj) | ||
292 | } | ||
293 | |||
294 | if (dev->rxp_timer) { | ||
295 | - timer_del(dev->rxp_timer); | ||
296 | timer_free(dev->rxp_timer); | ||
297 | } | ||
298 | } | ||
299 | diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c | ||
300 | index XXXXXXX..XXXXXXX 100644 | ||
301 | --- a/hw/net/virtio-net.c | ||
302 | +++ b/hw/net/virtio-net.c | ||
303 | @@ -XXX,XX +XXX,XX @@ static void virtio_net_rsc_cleanup(VirtIONet *n) | ||
304 | g_free(seg); | ||
305 | } | ||
306 | |||
307 | - timer_del(chain->drain_timer); | ||
308 | timer_free(chain->drain_timer); | ||
309 | QTAILQ_REMOVE(&n->rsc_chains, chain, next); | ||
310 | g_free(chain); | ||
311 | @@ -XXX,XX +XXX,XX @@ static void virtio_net_del_queue(VirtIONet *n, int index) | ||
312 | |||
313 | virtio_del_queue(vdev, index * 2); | ||
314 | if (q->tx_timer) { | ||
315 | - timer_del(q->tx_timer); | ||
316 | timer_free(q->tx_timer); | ||
317 | q->tx_timer = NULL; | ||
318 | } else { | ||
319 | diff --git a/hw/s390x/s390-pci-inst.c b/hw/s390x/s390-pci-inst.c | ||
320 | index XXXXXXX..XXXXXXX 100644 | ||
321 | --- a/hw/s390x/s390-pci-inst.c | ||
322 | +++ b/hw/s390x/s390-pci-inst.c | ||
323 | @@ -XXX,XX +XXX,XX @@ void pci_dereg_ioat(S390PCIIOMMU *iommu) | ||
324 | void fmb_timer_free(S390PCIBusDevice *pbdev) | ||
325 | { | ||
326 | if (pbdev->fmb_timer) { | ||
327 | - timer_del(pbdev->fmb_timer); | ||
328 | timer_free(pbdev->fmb_timer); | ||
329 | pbdev->fmb_timer = NULL; | ||
330 | } | ||
331 | diff --git a/hw/sd/sd.c b/hw/sd/sd.c | ||
332 | index XXXXXXX..XXXXXXX 100644 | ||
333 | --- a/hw/sd/sd.c | ||
334 | +++ b/hw/sd/sd.c | ||
335 | @@ -XXX,XX +XXX,XX @@ static void sd_instance_finalize(Object *obj) | ||
336 | { | ||
337 | SDState *sd = SD_CARD(obj); | ||
338 | |||
339 | - timer_del(sd->ocr_power_timer); | ||
340 | timer_free(sd->ocr_power_timer); | ||
341 | } | ||
342 | |||
343 | diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c | ||
344 | index XXXXXXX..XXXXXXX 100644 | ||
345 | --- a/hw/sd/sdhci.c | ||
346 | +++ b/hw/sd/sdhci.c | ||
347 | @@ -XXX,XX +XXX,XX @@ void sdhci_initfn(SDHCIState *s) | ||
348 | |||
349 | void sdhci_uninitfn(SDHCIState *s) | ||
350 | { | ||
351 | - timer_del(s->insert_timer); | ||
352 | timer_free(s->insert_timer); | ||
353 | - timer_del(s->transfer_timer); | ||
354 | timer_free(s->transfer_timer); | ||
355 | |||
356 | g_free(s->fifo_buffer); | ||
357 | diff --git a/hw/usb/dev-hub.c b/hw/usb/dev-hub.c | ||
358 | index XXXXXXX..XXXXXXX 100644 | ||
359 | --- a/hw/usb/dev-hub.c | ||
360 | +++ b/hw/usb/dev-hub.c | ||
361 | @@ -XXX,XX +XXX,XX @@ static void usb_hub_unrealize(USBDevice *dev) | ||
362 | &s->ports[i].port); | ||
363 | } | ||
364 | |||
365 | - timer_del(s->port_timer); | ||
366 | timer_free(s->port_timer); | ||
367 | } | ||
368 | |||
369 | diff --git a/hw/usb/hcd-ehci.c b/hw/usb/hcd-ehci.c | ||
370 | index XXXXXXX..XXXXXXX 100644 | ||
371 | --- a/hw/usb/hcd-ehci.c | ||
372 | +++ b/hw/usb/hcd-ehci.c | ||
373 | @@ -XXX,XX +XXX,XX @@ void usb_ehci_unrealize(EHCIState *s, DeviceState *dev) | ||
374 | trace_usb_ehci_unrealize(); | ||
375 | |||
376 | if (s->frame_timer) { | ||
377 | - timer_del(s->frame_timer); | ||
378 | timer_free(s->frame_timer); | ||
379 | s->frame_timer = NULL; | ||
380 | } | ||
381 | diff --git a/hw/usb/hcd-ohci-pci.c b/hw/usb/hcd-ohci-pci.c | ||
382 | index XXXXXXX..XXXXXXX 100644 | ||
383 | --- a/hw/usb/hcd-ohci-pci.c | ||
384 | +++ b/hw/usb/hcd-ohci-pci.c | ||
385 | @@ -XXX,XX +XXX,XX @@ static void usb_ohci_exit(PCIDevice *dev) | ||
386 | usb_bus_release(&s->bus); | ||
387 | } | ||
388 | |||
389 | - timer_del(s->eof_timer); | ||
390 | timer_free(s->eof_timer); | ||
391 | } | ||
392 | |||
393 | diff --git a/hw/usb/hcd-uhci.c b/hw/usb/hcd-uhci.c | ||
394 | index XXXXXXX..XXXXXXX 100644 | ||
395 | --- a/hw/usb/hcd-uhci.c | ||
396 | +++ b/hw/usb/hcd-uhci.c | ||
397 | @@ -XXX,XX +XXX,XX @@ static void usb_uhci_exit(PCIDevice *dev) | ||
398 | trace_usb_uhci_exit(); | ||
399 | |||
400 | if (s->frame_timer) { | ||
401 | - timer_del(s->frame_timer); | ||
402 | timer_free(s->frame_timer); | ||
403 | s->frame_timer = NULL; | ||
404 | } | ||
405 | diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c | ||
406 | index XXXXXXX..XXXXXXX 100644 | ||
407 | --- a/hw/usb/hcd-xhci.c | ||
408 | +++ b/hw/usb/hcd-xhci.c | ||
409 | @@ -XXX,XX +XXX,XX @@ static void usb_xhci_unrealize(DeviceState *dev) | ||
410 | } | ||
411 | |||
412 | if (xhci->mfwrap_timer) { | ||
413 | - timer_del(xhci->mfwrap_timer); | ||
414 | timer_free(xhci->mfwrap_timer); | ||
415 | xhci->mfwrap_timer = NULL; | ||
416 | } | ||
417 | diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c | ||
418 | index XXXXXXX..XXXXXXX 100644 | ||
419 | --- a/hw/usb/redirect.c | ||
420 | +++ b/hw/usb/redirect.c | ||
421 | @@ -XXX,XX +XXX,XX @@ static void usbredir_unrealize(USBDevice *udev) | ||
422 | qemu_bh_delete(dev->chardev_close_bh); | ||
423 | qemu_bh_delete(dev->device_reject_bh); | ||
424 | |||
425 | - timer_del(dev->attach_timer); | ||
426 | timer_free(dev->attach_timer); | ||
427 | |||
428 | usbredir_cleanup_device_queues(dev); | ||
429 | diff --git a/hw/vfio/display.c b/hw/vfio/display.c | ||
430 | index XXXXXXX..XXXXXXX 100644 | ||
431 | --- a/hw/vfio/display.c | ||
432 | +++ b/hw/vfio/display.c | ||
433 | @@ -XXX,XX +XXX,XX @@ static void vfio_display_edid_exit(VFIODisplay *dpy) | ||
434 | |||
435 | g_free(dpy->edid_regs); | ||
436 | g_free(dpy->edid_blob); | ||
437 | - timer_del(dpy->edid_link_timer); | ||
438 | timer_free(dpy->edid_link_timer); | ||
439 | } | ||
440 | |||
441 | diff --git a/hw/virtio/vhost-vsock-common.c b/hw/virtio/vhost-vsock-common.c | ||
442 | index XXXXXXX..XXXXXXX 100644 | ||
443 | --- a/hw/virtio/vhost-vsock-common.c | ||
444 | +++ b/hw/virtio/vhost-vsock-common.c | ||
445 | @@ -XXX,XX +XXX,XX @@ static void vhost_vsock_common_post_load_timer_cleanup(VHostVSockCommon *vvc) | ||
446 | return; | 80 | return; |
447 | } | 81 | } |
448 | 82 | ||
449 | - timer_del(vvc->post_load_timer); | 83 | - cs->hpplpi.prio = 0xff; |
450 | timer_free(vvc->post_load_timer); | 84 | - |
451 | vvc->post_load_timer = NULL; | 85 | lpipt_baddr = cs->gicr_pendbaser & R_GICR_PENDBASER_PHYADDR_MASK; |
86 | + lpict_baddr = cs->gicr_propbaser & R_GICR_PROPBASER_PHYADDR_MASK; | ||
87 | |||
88 | - /* Determine the highest priority pending interrupt among LPIs */ | ||
89 | - pendt_size = (1ULL << (idbits + 1)); | ||
90 | - | ||
91 | - for (i = GICV3_LPI_INTID_START / 8; i < pendt_size / 8; i++) { | ||
92 | - address_space_read(as, lpipt_baddr + i, MEMTXATTRS_UNSPECIFIED, &pend, | ||
93 | - sizeof(pend)); | ||
94 | - | ||
95 | - while (pend) { | ||
96 | - bit = ctz32(pend); | ||
97 | - gicv3_redist_check_lpi_priority(cs, i * 8 + bit); | ||
98 | - pend &= ~(1 << bit); | ||
99 | - } | ||
100 | - } | ||
101 | + update_for_all_lpis(cs, lpipt_baddr, lpict_baddr, idbits, | ||
102 | + cs->gic->gicd_ctlr & GICD_CTLR_DS, &cs->hpplpi); | ||
452 | } | 103 | } |
453 | diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c | 104 | |
454 | index XXXXXXX..XXXXXXX 100644 | 105 | void gicv3_redist_update_lpi(GICv3CPUState *cs) |
455 | --- a/hw/virtio/virtio-balloon.c | ||
456 | +++ b/hw/virtio/virtio-balloon.c | ||
457 | @@ -XXX,XX +XXX,XX @@ static bool balloon_stats_enabled(const VirtIOBalloon *s) | ||
458 | static void balloon_stats_destroy_timer(VirtIOBalloon *s) | ||
459 | { | ||
460 | if (balloon_stats_enabled(s)) { | ||
461 | - timer_del(s->stats_timer); | ||
462 | timer_free(s->stats_timer); | ||
463 | s->stats_timer = NULL; | ||
464 | s->stats_poll_interval = 0; | ||
465 | diff --git a/hw/virtio/virtio-rng.c b/hw/virtio/virtio-rng.c | ||
466 | index XXXXXXX..XXXXXXX 100644 | ||
467 | --- a/hw/virtio/virtio-rng.c | ||
468 | +++ b/hw/virtio/virtio-rng.c | ||
469 | @@ -XXX,XX +XXX,XX @@ static void virtio_rng_device_unrealize(DeviceState *dev) | ||
470 | VirtIORNG *vrng = VIRTIO_RNG(dev); | ||
471 | |||
472 | qemu_del_vm_change_state_handler(vrng->vmstate); | ||
473 | - timer_del(vrng->rate_limit_timer); | ||
474 | timer_free(vrng->rate_limit_timer); | ||
475 | virtio_del_queue(vdev, 0); | ||
476 | virtio_cleanup(vdev); | ||
477 | diff --git a/hw/watchdog/wdt_diag288.c b/hw/watchdog/wdt_diag288.c | ||
478 | index XXXXXXX..XXXXXXX 100644 | ||
479 | --- a/hw/watchdog/wdt_diag288.c | ||
480 | +++ b/hw/watchdog/wdt_diag288.c | ||
481 | @@ -XXX,XX +XXX,XX @@ static void wdt_diag288_unrealize(DeviceState *dev) | ||
482 | { | ||
483 | DIAG288State *diag288 = DIAG288(dev); | ||
484 | |||
485 | - timer_del(diag288->timer); | ||
486 | timer_free(diag288->timer); | ||
487 | } | ||
488 | |||
489 | diff --git a/hw/watchdog/wdt_i6300esb.c b/hw/watchdog/wdt_i6300esb.c | ||
490 | index XXXXXXX..XXXXXXX 100644 | ||
491 | --- a/hw/watchdog/wdt_i6300esb.c | ||
492 | +++ b/hw/watchdog/wdt_i6300esb.c | ||
493 | @@ -XXX,XX +XXX,XX @@ static void i6300esb_exit(PCIDevice *dev) | ||
494 | { | ||
495 | I6300State *d = WATCHDOG_I6300ESB_DEVICE(dev); | ||
496 | |||
497 | - timer_del(d->timer); | ||
498 | timer_free(d->timer); | ||
499 | } | ||
500 | |||
501 | diff --git a/migration/colo.c b/migration/colo.c | ||
502 | index XXXXXXX..XXXXXXX 100644 | ||
503 | --- a/migration/colo.c | ||
504 | +++ b/migration/colo.c | ||
505 | @@ -XXX,XX +XXX,XX @@ out: | ||
506 | * error. | ||
507 | */ | ||
508 | colo_compare_unregister_notifier(&packets_compare_notifier); | ||
509 | - timer_del(s->colo_delay_timer); | ||
510 | timer_free(s->colo_delay_timer); | ||
511 | qemu_event_destroy(&s->colo_checkpoint_event); | ||
512 | |||
513 | diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c | ||
514 | index XXXXXXX..XXXXXXX 100644 | ||
515 | --- a/monitor/hmp-cmds.c | ||
516 | +++ b/monitor/hmp-cmds.c | ||
517 | @@ -XXX,XX +XXX,XX @@ static void hmp_migrate_status_cb(void *opaque) | ||
518 | error_report("%s", info->error_desc); | ||
519 | } | ||
520 | monitor_resume(status->mon); | ||
521 | - timer_del(status->timer); | ||
522 | timer_free(status->timer); | ||
523 | g_free(status); | ||
524 | } | ||
525 | diff --git a/net/announce.c b/net/announce.c | ||
526 | index XXXXXXX..XXXXXXX 100644 | ||
527 | --- a/net/announce.c | ||
528 | +++ b/net/announce.c | ||
529 | @@ -XXX,XX +XXX,XX @@ void qemu_announce_timer_del(AnnounceTimer *timer, bool free_named) | ||
530 | { | ||
531 | bool free_timer = false; | ||
532 | if (timer->tm) { | ||
533 | - timer_del(timer->tm); | ||
534 | timer_free(timer->tm); | ||
535 | timer->tm = NULL; | ||
536 | } | ||
537 | diff --git a/net/colo-compare.c b/net/colo-compare.c | ||
538 | index XXXXXXX..XXXXXXX 100644 | ||
539 | --- a/net/colo-compare.c | ||
540 | +++ b/net/colo-compare.c | ||
541 | @@ -XXX,XX +XXX,XX @@ static void colo_compare_timer_init(CompareState *s) | ||
542 | static void colo_compare_timer_del(CompareState *s) | ||
543 | { | ||
544 | if (s->packet_check_timer) { | ||
545 | - timer_del(s->packet_check_timer); | ||
546 | timer_free(s->packet_check_timer); | ||
547 | s->packet_check_timer = NULL; | ||
548 | } | ||
549 | diff --git a/net/slirp.c b/net/slirp.c | ||
550 | index XXXXXXX..XXXXXXX 100644 | ||
551 | --- a/net/slirp.c | ||
552 | +++ b/net/slirp.c | ||
553 | @@ -XXX,XX +XXX,XX @@ static void *net_slirp_timer_new(SlirpTimerCb cb, | ||
554 | |||
555 | static void net_slirp_timer_free(void *timer, void *opaque) | ||
556 | { | ||
557 | - timer_del(timer); | ||
558 | timer_free(timer); | ||
559 | } | ||
560 | |||
561 | diff --git a/replay/replay-debugging.c b/replay/replay-debugging.c | ||
562 | index XXXXXXX..XXXXXXX 100644 | ||
563 | --- a/replay/replay-debugging.c | ||
564 | +++ b/replay/replay-debugging.c | ||
565 | @@ -XXX,XX +XXX,XX @@ static void replay_delete_break(void) | ||
566 | assert(replay_mutex_locked()); | ||
567 | |||
568 | if (replay_break_timer) { | ||
569 | - timer_del(replay_break_timer); | ||
570 | timer_free(replay_break_timer); | ||
571 | replay_break_timer = NULL; | ||
572 | } | ||
573 | diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c | ||
574 | index XXXXXXX..XXXXXXX 100644 | ||
575 | --- a/target/s390x/cpu.c | ||
576 | +++ b/target/s390x/cpu.c | ||
577 | @@ -XXX,XX +XXX,XX @@ static void s390_cpu_finalize(Object *obj) | ||
578 | #if !defined(CONFIG_USER_ONLY) | ||
579 | S390CPU *cpu = S390_CPU(obj); | ||
580 | |||
581 | - timer_del(cpu->env.tod_timer); | ||
582 | timer_free(cpu->env.tod_timer); | ||
583 | - timer_del(cpu->env.cpu_timer); | ||
584 | timer_free(cpu->env.cpu_timer); | ||
585 | |||
586 | qemu_unregister_reset(s390_cpu_machine_reset_cb, cpu); | ||
587 | diff --git a/ui/console.c b/ui/console.c | ||
588 | index XXXXXXX..XXXXXXX 100644 | ||
589 | --- a/ui/console.c | ||
590 | +++ b/ui/console.c | ||
591 | @@ -XXX,XX +XXX,XX @@ static void gui_setup_refresh(DisplayState *ds) | ||
592 | timer_mod(ds->gui_timer, qemu_clock_get_ms(QEMU_CLOCK_REALTIME)); | ||
593 | } | ||
594 | if (!need_timer && ds->gui_timer != NULL) { | ||
595 | - timer_del(ds->gui_timer); | ||
596 | timer_free(ds->gui_timer); | ||
597 | ds->gui_timer = NULL; | ||
598 | } | ||
599 | diff --git a/ui/spice-core.c b/ui/spice-core.c | ||
600 | index XXXXXXX..XXXXXXX 100644 | ||
601 | --- a/ui/spice-core.c | ||
602 | +++ b/ui/spice-core.c | ||
603 | @@ -XXX,XX +XXX,XX @@ static void timer_cancel(SpiceTimer *timer) | ||
604 | |||
605 | static void timer_remove(SpiceTimer *timer) | ||
606 | { | ||
607 | - timer_del(timer->timer); | ||
608 | timer_free(timer->timer); | ||
609 | g_free(timer); | ||
610 | } | ||
611 | diff --git a/util/throttle.c b/util/throttle.c | ||
612 | index XXXXXXX..XXXXXXX 100644 | ||
613 | --- a/util/throttle.c | ||
614 | +++ b/util/throttle.c | ||
615 | @@ -XXX,XX +XXX,XX @@ static void throttle_timer_destroy(QEMUTimer **timer) | ||
616 | { | ||
617 | assert(*timer != NULL); | ||
618 | |||
619 | - timer_del(*timer); | ||
620 | timer_free(*timer); | ||
621 | *timer = NULL; | ||
622 | } | ||
623 | -- | 106 | -- |
624 | 2.20.1 | 107 | 2.25.1 |
625 | |||
626 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | The guest uses GICR_VPENDBASER to tell the redistributor when it is | ||
2 | scheduling or descheduling a vCPU. When it writes and changes the | ||
3 | VALID bit from 0 to 1, it is scheduling a vCPU, and we must update | ||
4 | our view of the current highest priority pending vLPI from the new | ||
5 | Pending and Configuration tables. When it writes and changes the | ||
6 | VALID bit from 1 to 0, it is descheduling, which means that there is | ||
7 | no longer a highest priority pending vLPI. | ||
1 | 8 | ||
9 | The specification allows the implementation to use part of the vLPI | ||
10 | Pending table as an IMPDEF area where it can cache information when a | ||
11 | vCPU is descheduled, so that it can avoid having to do a full rescan | ||
12 | of the tables when the vCPU is scheduled again. For now, we don't | ||
13 | take advantage of this, and simply do a complete rescan. | ||
14 | |||
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
16 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
17 | Message-id: 20220408141550.1271295-30-peter.maydell@linaro.org | ||
18 | --- | ||
19 | hw/intc/arm_gicv3_redist.c | 87 ++++++++++++++++++++++++++++++++++++-- | ||
20 | 1 file changed, 84 insertions(+), 3 deletions(-) | ||
21 | |||
22 | diff --git a/hw/intc/arm_gicv3_redist.c b/hw/intc/arm_gicv3_redist.c | ||
23 | index XXXXXXX..XXXXXXX 100644 | ||
24 | --- a/hw/intc/arm_gicv3_redist.c | ||
25 | +++ b/hw/intc/arm_gicv3_redist.c | ||
26 | @@ -XXX,XX +XXX,XX @@ static void gicr_write_ipriorityr(GICv3CPUState *cs, MemTxAttrs attrs, int irq, | ||
27 | cs->gicr_ipriorityr[irq] = value; | ||
28 | } | ||
29 | |||
30 | +static void gicv3_redist_update_vlpi_only(GICv3CPUState *cs) | ||
31 | +{ | ||
32 | + uint64_t ptbase, ctbase, idbits; | ||
33 | + | ||
34 | + if (!FIELD_EX64(cs->gicr_vpendbaser, GICR_VPENDBASER, VALID)) { | ||
35 | + cs->hppvlpi.prio = 0xff; | ||
36 | + return; | ||
37 | + } | ||
38 | + | ||
39 | + ptbase = cs->gicr_vpendbaser & R_GICR_VPENDBASER_PHYADDR_MASK; | ||
40 | + ctbase = cs->gicr_vpropbaser & R_GICR_VPROPBASER_PHYADDR_MASK; | ||
41 | + idbits = FIELD_EX64(cs->gicr_vpropbaser, GICR_VPROPBASER, IDBITS); | ||
42 | + | ||
43 | + update_for_all_lpis(cs, ptbase, ctbase, idbits, true, &cs->hppvlpi); | ||
44 | +} | ||
45 | + | ||
46 | +static void gicv3_redist_update_vlpi(GICv3CPUState *cs) | ||
47 | +{ | ||
48 | + gicv3_redist_update_vlpi_only(cs); | ||
49 | + gicv3_cpuif_virt_irq_fiq_update(cs); | ||
50 | +} | ||
51 | + | ||
52 | +static void gicr_write_vpendbaser(GICv3CPUState *cs, uint64_t newval) | ||
53 | +{ | ||
54 | + /* Write @newval to GICR_VPENDBASER, handling its effects */ | ||
55 | + bool oldvalid = FIELD_EX64(cs->gicr_vpendbaser, GICR_VPENDBASER, VALID); | ||
56 | + bool newvalid = FIELD_EX64(newval, GICR_VPENDBASER, VALID); | ||
57 | + bool pendinglast; | ||
58 | + | ||
59 | + /* | ||
60 | + * The DIRTY bit is read-only and for us is always zero; | ||
61 | + * other fields are writeable. | ||
62 | + */ | ||
63 | + newval &= R_GICR_VPENDBASER_INNERCACHE_MASK | | ||
64 | + R_GICR_VPENDBASER_SHAREABILITY_MASK | | ||
65 | + R_GICR_VPENDBASER_PHYADDR_MASK | | ||
66 | + R_GICR_VPENDBASER_OUTERCACHE_MASK | | ||
67 | + R_GICR_VPENDBASER_PENDINGLAST_MASK | | ||
68 | + R_GICR_VPENDBASER_IDAI_MASK | | ||
69 | + R_GICR_VPENDBASER_VALID_MASK; | ||
70 | + | ||
71 | + if (oldvalid && newvalid) { | ||
72 | + /* | ||
73 | + * Changing other fields while VALID is 1 is UNPREDICTABLE; | ||
74 | + * we choose to log and ignore the write. | ||
75 | + */ | ||
76 | + if (cs->gicr_vpendbaser ^ newval) { | ||
77 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
78 | + "%s: Changing GICR_VPENDBASER when VALID=1 " | ||
79 | + "is UNPREDICTABLE\n", __func__); | ||
80 | + } | ||
81 | + return; | ||
82 | + } | ||
83 | + if (!oldvalid && !newvalid) { | ||
84 | + cs->gicr_vpendbaser = newval; | ||
85 | + return; | ||
86 | + } | ||
87 | + | ||
88 | + if (newvalid) { | ||
89 | + /* | ||
90 | + * Valid going from 0 to 1: update hppvlpi from tables. | ||
91 | + * If IDAI is 0 we are allowed to use the info we cached in | ||
92 | + * the IMPDEF area of the table. | ||
93 | + * PendingLast is RES1 when we make this transition. | ||
94 | + */ | ||
95 | + pendinglast = true; | ||
96 | + } else { | ||
97 | + /* | ||
98 | + * Valid going from 1 to 0: | ||
99 | + * Set PendingLast if there was a pending enabled interrupt | ||
100 | + * for the vPE that was just descheduled. | ||
101 | + * If we cache info in the IMPDEF area, write it out here. | ||
102 | + */ | ||
103 | + pendinglast = cs->hppvlpi.prio != 0xff; | ||
104 | + } | ||
105 | + | ||
106 | + newval = FIELD_DP64(newval, GICR_VPENDBASER, PENDINGLAST, pendinglast); | ||
107 | + cs->gicr_vpendbaser = newval; | ||
108 | + gicv3_redist_update_vlpi(cs); | ||
109 | +} | ||
110 | + | ||
111 | static MemTxResult gicr_readb(GICv3CPUState *cs, hwaddr offset, | ||
112 | uint64_t *data, MemTxAttrs attrs) | ||
113 | { | ||
114 | @@ -XXX,XX +XXX,XX @@ static MemTxResult gicr_writel(GICv3CPUState *cs, hwaddr offset, | ||
115 | cs->gicr_vpropbaser = deposit64(cs->gicr_vpropbaser, 32, 32, value); | ||
116 | return MEMTX_OK; | ||
117 | case GICR_VPENDBASER: | ||
118 | - cs->gicr_vpendbaser = deposit64(cs->gicr_vpendbaser, 0, 32, value); | ||
119 | + gicr_write_vpendbaser(cs, deposit64(cs->gicr_vpendbaser, 0, 32, value)); | ||
120 | return MEMTX_OK; | ||
121 | case GICR_VPENDBASER + 4: | ||
122 | - cs->gicr_vpendbaser = deposit64(cs->gicr_vpendbaser, 32, 32, value); | ||
123 | + gicr_write_vpendbaser(cs, deposit64(cs->gicr_vpendbaser, 32, 32, value)); | ||
124 | return MEMTX_OK; | ||
125 | default: | ||
126 | return MEMTX_ERROR; | ||
127 | @@ -XXX,XX +XXX,XX @@ static MemTxResult gicr_writell(GICv3CPUState *cs, hwaddr offset, | ||
128 | cs->gicr_vpropbaser = value; | ||
129 | return MEMTX_OK; | ||
130 | case GICR_VPENDBASER: | ||
131 | - cs->gicr_vpendbaser = value; | ||
132 | + gicr_write_vpendbaser(cs, value); | ||
133 | return MEMTX_OK; | ||
134 | default: | ||
135 | return MEMTX_ERROR; | ||
136 | -- | ||
137 | 2.25.1 | diff view generated by jsdifflib |
1 | Now that we have implemented all the features needed by the v8.1M | 1 | Factor out the code which sets a single bit in an LPI pending table. |
---|---|---|---|
2 | architecture, we can add the model of the Cortex-M55. This is the | 2 | We're going to need this for handling vLPI tables, not just the |
3 | configuration without MVE support; we'll add MVE later. | 3 | physical LPI table. |
4 | 4 | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
7 | Message-id: 20201210201433.26262-5-peter.maydell@linaro.org | 7 | Message-id: 20220408141550.1271295-31-peter.maydell@linaro.org |
8 | --- | 8 | --- |
9 | target/arm/cpu_tcg.c | 42 ++++++++++++++++++++++++++++++++++++++++++ | 9 | hw/intc/arm_gicv3_redist.c | 49 +++++++++++++++++++++++--------------- |
10 | 1 file changed, 42 insertions(+) | 10 | 1 file changed, 30 insertions(+), 19 deletions(-) |
11 | 11 | ||
12 | diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c | 12 | diff --git a/hw/intc/arm_gicv3_redist.c b/hw/intc/arm_gicv3_redist.c |
13 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
14 | --- a/target/arm/cpu_tcg.c | 14 | --- a/hw/intc/arm_gicv3_redist.c |
15 | +++ b/target/arm/cpu_tcg.c | 15 | +++ b/hw/intc/arm_gicv3_redist.c |
16 | @@ -XXX,XX +XXX,XX @@ static void cortex_m33_initfn(Object *obj) | 16 | @@ -XXX,XX +XXX,XX @@ static void update_for_all_lpis(GICv3CPUState *cs, uint64_t ptbase, |
17 | cpu->ctr = 0x8000c000; | 17 | } |
18 | } | 18 | } |
19 | 19 | ||
20 | +static void cortex_m55_initfn(Object *obj) | 20 | +/** |
21 | + * set_lpi_pending_bit: Set or clear pending bit for an LPI | ||
22 | + * | ||
23 | + * @cs: GICv3CPUState | ||
24 | + * @ptbase: physical address of LPI Pending table | ||
25 | + * @irq: LPI to change pending state for | ||
26 | + * @level: false to clear pending state, true to set | ||
27 | + * | ||
28 | + * Returns true if we needed to do something, false if the pending bit | ||
29 | + * was already at @level. | ||
30 | + */ | ||
31 | +static bool set_pending_table_bit(GICv3CPUState *cs, uint64_t ptbase, | ||
32 | + int irq, bool level) | ||
21 | +{ | 33 | +{ |
22 | + ARMCPU *cpu = ARM_CPU(obj); | 34 | + AddressSpace *as = &cs->gic->dma_as; |
35 | + uint64_t addr = ptbase + irq / 8; | ||
36 | + uint8_t pend; | ||
23 | + | 37 | + |
24 | + set_feature(&cpu->env, ARM_FEATURE_V8); | 38 | + address_space_read(as, addr, MEMTXATTRS_UNSPECIFIED, &pend, 1); |
25 | + set_feature(&cpu->env, ARM_FEATURE_V8_1M); | 39 | + if (extract32(pend, irq % 8, 1) == level) { |
26 | + set_feature(&cpu->env, ARM_FEATURE_M); | 40 | + /* Bit already at requested state, no action required */ |
27 | + set_feature(&cpu->env, ARM_FEATURE_M_MAIN); | 41 | + return false; |
28 | + set_feature(&cpu->env, ARM_FEATURE_M_SECURITY); | 42 | + } |
29 | + set_feature(&cpu->env, ARM_FEATURE_THUMB_DSP); | 43 | + pend = deposit32(pend, irq % 8, 1, level ? 1 : 0); |
30 | + cpu->midr = 0x410fd221; /* r0p1 */ | 44 | + address_space_write(as, addr, MEMTXATTRS_UNSPECIFIED, &pend, 1); |
31 | + cpu->revidr = 0; | 45 | + return true; |
32 | + cpu->pmsav7_dregion = 16; | ||
33 | + cpu->sau_sregion = 8; | ||
34 | + /* | ||
35 | + * These are the MVFR* values for the FPU, no MVE configuration; | ||
36 | + * we will update them later when we implement MVE | ||
37 | + */ | ||
38 | + cpu->isar.mvfr0 = 0x10110221; | ||
39 | + cpu->isar.mvfr1 = 0x12100011; | ||
40 | + cpu->isar.mvfr2 = 0x00000040; | ||
41 | + cpu->isar.id_pfr0 = 0x20000030; | ||
42 | + cpu->isar.id_pfr1 = 0x00000230; | ||
43 | + cpu->isar.id_dfr0 = 0x10200000; | ||
44 | + cpu->id_afr0 = 0x00000000; | ||
45 | + cpu->isar.id_mmfr0 = 0x00111040; | ||
46 | + cpu->isar.id_mmfr1 = 0x00000000; | ||
47 | + cpu->isar.id_mmfr2 = 0x01000000; | ||
48 | + cpu->isar.id_mmfr3 = 0x00000011; | ||
49 | + cpu->isar.id_isar0 = 0x01103110; | ||
50 | + cpu->isar.id_isar1 = 0x02212000; | ||
51 | + cpu->isar.id_isar2 = 0x20232232; | ||
52 | + cpu->isar.id_isar3 = 0x01111131; | ||
53 | + cpu->isar.id_isar4 = 0x01310132; | ||
54 | + cpu->isar.id_isar5 = 0x00000000; | ||
55 | + cpu->isar.id_isar6 = 0x00000000; | ||
56 | + cpu->clidr = 0x00000000; /* caches not implemented */ | ||
57 | + cpu->ctr = 0x8303c003; | ||
58 | +} | 46 | +} |
59 | + | 47 | + |
60 | static const ARMCPRegInfo cortexr5_cp_reginfo[] = { | 48 | static uint8_t gicr_read_ipriorityr(GICv3CPUState *cs, MemTxAttrs attrs, |
61 | /* Dummy the TCM region regs for the moment */ | 49 | int irq) |
62 | { .name = "ATCM", .cp = 15, .opc1 = 0, .crn = 9, .crm = 1, .opc2 = 0, | 50 | { |
63 | @@ -XXX,XX +XXX,XX @@ static const ARMCPUInfo arm_tcg_cpus[] = { | 51 | @@ -XXX,XX +XXX,XX @@ void gicv3_redist_lpi_pending(GICv3CPUState *cs, int irq, int level) |
64 | .class_init = arm_v7m_class_init }, | 52 | * This function updates the pending bit in lpi pending table for |
65 | { .name = "cortex-m33", .initfn = cortex_m33_initfn, | 53 | * the irq being activated or deactivated. |
66 | .class_init = arm_v7m_class_init }, | 54 | */ |
67 | + { .name = "cortex-m55", .initfn = cortex_m55_initfn, | 55 | - AddressSpace *as = &cs->gic->dma_as; |
68 | + .class_init = arm_v7m_class_init }, | 56 | uint64_t lpipt_baddr; |
69 | { .name = "cortex-r5", .initfn = cortex_r5_initfn }, | 57 | - bool ispend = false; |
70 | { .name = "cortex-r5f", .initfn = cortex_r5f_initfn }, | 58 | - uint8_t pend; |
71 | { .name = "ti925t", .initfn = ti925t_initfn }, | 59 | |
60 | - /* | ||
61 | - * get the bit value corresponding to this irq in the | ||
62 | - * lpi pending table | ||
63 | - */ | ||
64 | lpipt_baddr = cs->gicr_pendbaser & R_GICR_PENDBASER_PHYADDR_MASK; | ||
65 | - | ||
66 | - address_space_read(as, lpipt_baddr + ((irq / 8) * sizeof(pend)), | ||
67 | - MEMTXATTRS_UNSPECIFIED, &pend, sizeof(pend)); | ||
68 | - | ||
69 | - ispend = extract32(pend, irq % 8, 1); | ||
70 | - | ||
71 | - /* no change in the value of pending bit, return */ | ||
72 | - if (ispend == level) { | ||
73 | + if (!set_pending_table_bit(cs, lpipt_baddr, irq, level)) { | ||
74 | + /* no change in the value of pending bit, return */ | ||
75 | return; | ||
76 | } | ||
77 | - pend = deposit32(pend, irq % 8, 1, level ? 1 : 0); | ||
78 | - | ||
79 | - address_space_write(as, lpipt_baddr + ((irq / 8) * sizeof(pend)), | ||
80 | - MEMTXATTRS_UNSPECIFIED, &pend, sizeof(pend)); | ||
81 | |||
82 | /* | ||
83 | * check if this LPI is better than the current hpplpi, if yes | ||
72 | -- | 84 | -- |
73 | 2.20.1 | 85 | 2.25.1 |
74 | |||
75 | diff view generated by jsdifflib |
1 | Implement the v8.1M FPCXT_NS floating-point system register. This is | 1 | Implement the function gicv3_redist_process_vlpi(), which was left as |
---|---|---|---|
2 | a little more complicated than FPCXT_S, because it has specific | 2 | just a stub earlier. This function deals with being handed a VLPI by |
3 | handling for "current FP state is inactive", and it only wants to do | 3 | the ITS. It must set the bit in the pending table. If the vCPU is |
4 | PreserveFPState(), not the full set of actions done by | 4 | currently resident we must recalculate the highest priority pending |
5 | ExecuteFPCheck() which vfp_access_check() implements. | 5 | vLPI; otherwise we may need to ring a "doorbell" interrupt to let the |
6 | hypervisor know it might want to reschedule the vCPU. | ||
6 | 7 | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
9 | Message-id: 20201210201433.26262-4-peter.maydell@linaro.org | 10 | Message-id: 20220408141550.1271295-32-peter.maydell@linaro.org |
10 | --- | 11 | --- |
11 | target/arm/translate-vfp.c.inc | 102 ++++++++++++++++++++++++++++++++- | 12 | hw/intc/arm_gicv3_redist.c | 48 ++++++++++++++++++++++++++++++++++---- |
12 | 1 file changed, 99 insertions(+), 3 deletions(-) | 13 | 1 file changed, 44 insertions(+), 4 deletions(-) |
13 | 14 | ||
14 | diff --git a/target/arm/translate-vfp.c.inc b/target/arm/translate-vfp.c.inc | 15 | diff --git a/hw/intc/arm_gicv3_redist.c b/hw/intc/arm_gicv3_redist.c |
15 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/translate-vfp.c.inc | 17 | --- a/hw/intc/arm_gicv3_redist.c |
17 | +++ b/target/arm/translate-vfp.c.inc | 18 | +++ b/hw/intc/arm_gicv3_redist.c |
18 | @@ -XXX,XX +XXX,XX @@ static FPSysRegCheckResult fp_sysreg_checks(DisasContext *s, int regno) | 19 | @@ -XXX,XX +XXX,XX @@ static uint32_t gicr_read_bitmap_reg(GICv3CPUState *cs, MemTxAttrs attrs, |
19 | } | 20 | return reg; |
20 | break; | ||
21 | case ARM_VFP_FPCXT_S: | ||
22 | + case ARM_VFP_FPCXT_NS: | ||
23 | if (!arm_dc_feature(s, ARM_FEATURE_V8_1M)) { | ||
24 | return false; | ||
25 | } | ||
26 | @@ -XXX,XX +XXX,XX @@ static FPSysRegCheckResult fp_sysreg_checks(DisasContext *s, int regno) | ||
27 | return FPSysRegCheckFailed; | ||
28 | } | ||
29 | |||
30 | - if (!vfp_access_check(s)) { | ||
31 | + /* | ||
32 | + * FPCXT_NS is a special case: it has specific handling for | ||
33 | + * "current FP state is inactive", and must do the PreserveFPState() | ||
34 | + * but not the usual full set of actions done by ExecuteFPCheck(). | ||
35 | + * So we don't call vfp_access_check() and the callers must handle this. | ||
36 | + */ | ||
37 | + if (regno != ARM_VFP_FPCXT_NS && !vfp_access_check(s)) { | ||
38 | return FPSysRegCheckDone; | ||
39 | } | ||
40 | - | ||
41 | return FPSysRegCheckContinue; | ||
42 | } | 21 | } |
43 | 22 | ||
44 | +static void gen_branch_fpInactive(DisasContext *s, TCGCond cond, | 23 | +static bool vcpu_resident(GICv3CPUState *cs, uint64_t vptaddr) |
45 | + TCGLabel *label) | ||
46 | +{ | 24 | +{ |
47 | + /* | 25 | + /* |
48 | + * FPCXT_NS is a special case: it has specific handling for | 26 | + * Return true if a vCPU is resident, which is defined by |
49 | + * "current FP state is inactive", and must do the PreserveFPState() | 27 | + * whether the GICR_VPENDBASER register is marked VALID and |
50 | + * but not the usual full set of actions done by ExecuteFPCheck(). | 28 | + * has the right virtual pending table address. |
51 | + * We don't have a TB flag that matches the fpInactive check, so we | ||
52 | + * do it at runtime as we don't expect FPCXT_NS accesses to be frequent. | ||
53 | + * | ||
54 | + * Emit code that checks fpInactive and does a conditional | ||
55 | + * branch to label based on it: | ||
56 | + * if cond is TCG_COND_NE then branch if fpInactive != 0 (ie if inactive) | ||
57 | + * if cond is TCG_COND_EQ then branch if fpInactive == 0 (ie if active) | ||
58 | + */ | 29 | + */ |
59 | + assert(cond == TCG_COND_EQ || cond == TCG_COND_NE); | 30 | + if (!FIELD_EX64(cs->gicr_vpendbaser, GICR_VPENDBASER, VALID)) { |
60 | + | 31 | + return false; |
61 | + /* fpInactive = FPCCR_NS.ASPEN == 1 && CONTROL.FPCA == 0 */ | 32 | + } |
62 | + TCGv_i32 aspen, fpca; | 33 | + return vptaddr == (cs->gicr_vpendbaser & R_GICR_VPENDBASER_PHYADDR_MASK); |
63 | + aspen = load_cpu_field(v7m.fpccr[M_REG_NS]); | ||
64 | + fpca = load_cpu_field(v7m.control[M_REG_S]); | ||
65 | + tcg_gen_andi_i32(aspen, aspen, R_V7M_FPCCR_ASPEN_MASK); | ||
66 | + tcg_gen_xori_i32(aspen, aspen, R_V7M_FPCCR_ASPEN_MASK); | ||
67 | + tcg_gen_andi_i32(fpca, fpca, R_V7M_CONTROL_FPCA_MASK); | ||
68 | + tcg_gen_or_i32(fpca, fpca, aspen); | ||
69 | + tcg_gen_brcondi_i32(tcg_invert_cond(cond), fpca, 0, label); | ||
70 | + tcg_temp_free_i32(aspen); | ||
71 | + tcg_temp_free_i32(fpca); | ||
72 | +} | 34 | +} |
73 | + | 35 | + |
74 | static bool gen_M_fp_sysreg_write(DisasContext *s, int regno, | 36 | /** |
75 | 37 | * update_for_one_lpi: Update pending information if this LPI is better | |
76 | fp_sysreg_loadfn *loadfn, | 38 | * |
77 | @@ -XXX,XX +XXX,XX @@ static bool gen_M_fp_sysreg_write(DisasContext *s, int regno, | 39 | @@ -XXX,XX +XXX,XX @@ void gicv3_redist_vlpi_pending(GICv3CPUState *cs, int irq, int level) |
40 | void gicv3_redist_process_vlpi(GICv3CPUState *cs, int irq, uint64_t vptaddr, | ||
41 | int doorbell, int level) | ||
78 | { | 42 | { |
79 | /* Do a write to an M-profile floating point system register */ | 43 | - /* |
80 | TCGv_i32 tmp; | 44 | - * The redistributor handling for being handed a VLPI by the ITS |
81 | + TCGLabel *lab_end = NULL; | 45 | - * will be added in a subsequent commit. |
82 | 46 | - */ | |
83 | switch (fp_sysreg_checks(s, regno)) { | 47 | + bool bit_changed; |
84 | case FPSysRegCheckFailed: | 48 | + bool resident = vcpu_resident(cs, vptaddr); |
85 | @@ -XXX,XX +XXX,XX @@ static bool gen_M_fp_sysreg_write(DisasContext *s, int regno, | 49 | + uint64_t ctbase; |
86 | tcg_temp_free_i32(tmp); | 50 | + |
87 | break; | 51 | + if (resident) { |
88 | } | 52 | + uint32_t idbits = FIELD_EX64(cs->gicr_vpropbaser, GICR_VPROPBASER, IDBITS); |
89 | + case ARM_VFP_FPCXT_NS: | 53 | + if (irq >= (1ULL << (idbits + 1))) { |
90 | + lab_end = gen_new_label(); | 54 | + return; |
91 | + /* fpInactive case: write is a NOP, so branch to end */ | 55 | + } |
92 | + gen_branch_fpInactive(s, TCG_COND_NE, lab_end); | ||
93 | + /* !fpInactive: PreserveFPState(), and reads same as FPCXT_S */ | ||
94 | + gen_preserve_fp_state(s); | ||
95 | + /* fall through */ | ||
96 | case ARM_VFP_FPCXT_S: | ||
97 | { | ||
98 | TCGv_i32 sfpa, control; | ||
99 | @@ -XXX,XX +XXX,XX @@ static bool gen_M_fp_sysreg_write(DisasContext *s, int regno, | ||
100 | default: | ||
101 | g_assert_not_reached(); | ||
102 | } | ||
103 | + if (lab_end) { | ||
104 | + gen_set_label(lab_end); | ||
105 | + } | 56 | + } |
106 | return true; | 57 | + |
58 | + bit_changed = set_pending_table_bit(cs, vptaddr, irq, level); | ||
59 | + if (resident && bit_changed) { | ||
60 | + if (level) { | ||
61 | + /* Check whether this vLPI is now the best */ | ||
62 | + ctbase = cs->gicr_vpropbaser & R_GICR_VPROPBASER_PHYADDR_MASK; | ||
63 | + update_for_one_lpi(cs, irq, ctbase, true, &cs->hppvlpi); | ||
64 | + gicv3_cpuif_virt_irq_fiq_update(cs); | ||
65 | + } else { | ||
66 | + /* Only need to recalculate if this was previously the best vLPI */ | ||
67 | + if (irq == cs->hppvlpi.irq) { | ||
68 | + gicv3_redist_update_vlpi(cs); | ||
69 | + } | ||
70 | + } | ||
71 | + } | ||
72 | + | ||
73 | + if (!resident && level && doorbell != INTID_SPURIOUS && | ||
74 | + (cs->gicr_ctlr & GICR_CTLR_ENABLE_LPIS)) { | ||
75 | + /* vCPU is not currently resident: ring the doorbell */ | ||
76 | + gicv3_redist_process_lpi(cs, doorbell, 1); | ||
77 | + } | ||
107 | } | 78 | } |
108 | 79 | ||
109 | @@ -XXX,XX +XXX,XX @@ static bool gen_M_fp_sysreg_read(DisasContext *s, int regno, | 80 | void gicv3_redist_mov_vlpi(GICv3CPUState *src, uint64_t src_vptaddr, |
110 | { | ||
111 | /* Do a read from an M-profile floating point system register */ | ||
112 | TCGv_i32 tmp; | ||
113 | + TCGLabel *lab_end = NULL; | ||
114 | + bool lookup_tb = false; | ||
115 | |||
116 | switch (fp_sysreg_checks(s, regno)) { | ||
117 | case FPSysRegCheckFailed: | ||
118 | @@ -XXX,XX +XXX,XX @@ static bool gen_M_fp_sysreg_read(DisasContext *s, int regno, | ||
119 | fpscr = load_cpu_field(v7m.fpdscr[M_REG_NS]); | ||
120 | gen_helper_vfp_set_fpscr(cpu_env, fpscr); | ||
121 | tcg_temp_free_i32(fpscr); | ||
122 | - gen_lookup_tb(s); | ||
123 | + lookup_tb = true; | ||
124 | + break; | ||
125 | + } | ||
126 | + case ARM_VFP_FPCXT_NS: | ||
127 | + { | ||
128 | + TCGv_i32 control, sfpa, fpscr, fpdscr, zero; | ||
129 | + TCGLabel *lab_active = gen_new_label(); | ||
130 | + | ||
131 | + lookup_tb = true; | ||
132 | + | ||
133 | + gen_branch_fpInactive(s, TCG_COND_EQ, lab_active); | ||
134 | + /* fpInactive case: reads as FPDSCR_NS */ | ||
135 | + TCGv_i32 tmp = load_cpu_field(v7m.fpdscr[M_REG_NS]); | ||
136 | + storefn(s, opaque, tmp); | ||
137 | + lab_end = gen_new_label(); | ||
138 | + tcg_gen_br(lab_end); | ||
139 | + | ||
140 | + gen_set_label(lab_active); | ||
141 | + /* !fpInactive: Reads the same as FPCXT_S, but side effects differ */ | ||
142 | + gen_preserve_fp_state(s); | ||
143 | + tmp = tcg_temp_new_i32(); | ||
144 | + sfpa = tcg_temp_new_i32(); | ||
145 | + fpscr = tcg_temp_new_i32(); | ||
146 | + gen_helper_vfp_get_fpscr(fpscr, cpu_env); | ||
147 | + tcg_gen_andi_i32(tmp, fpscr, ~FPCR_NZCV_MASK); | ||
148 | + control = load_cpu_field(v7m.control[M_REG_S]); | ||
149 | + tcg_gen_andi_i32(sfpa, control, R_V7M_CONTROL_SFPA_MASK); | ||
150 | + tcg_gen_shli_i32(sfpa, sfpa, 31 - R_V7M_CONTROL_SFPA_SHIFT); | ||
151 | + tcg_gen_or_i32(tmp, tmp, sfpa); | ||
152 | + tcg_temp_free_i32(control); | ||
153 | + /* Store result before updating FPSCR, in case it faults */ | ||
154 | + storefn(s, opaque, tmp); | ||
155 | + /* If SFPA is zero then set FPSCR from FPDSCR_NS */ | ||
156 | + fpdscr = load_cpu_field(v7m.fpdscr[M_REG_NS]); | ||
157 | + zero = tcg_const_i32(0); | ||
158 | + tcg_gen_movcond_i32(TCG_COND_EQ, fpscr, sfpa, zero, fpdscr, fpscr); | ||
159 | + gen_helper_vfp_set_fpscr(cpu_env, fpscr); | ||
160 | + tcg_temp_free_i32(zero); | ||
161 | + tcg_temp_free_i32(sfpa); | ||
162 | + tcg_temp_free_i32(fpdscr); | ||
163 | + tcg_temp_free_i32(fpscr); | ||
164 | break; | ||
165 | } | ||
166 | default: | ||
167 | g_assert_not_reached(); | ||
168 | } | ||
169 | + | ||
170 | + if (lab_end) { | ||
171 | + gen_set_label(lab_end); | ||
172 | + } | ||
173 | + if (lookup_tb) { | ||
174 | + gen_lookup_tb(s); | ||
175 | + } | ||
176 | return true; | ||
177 | } | ||
178 | |||
179 | -- | 81 | -- |
180 | 2.20.1 | 82 | 2.25.1 |
181 | |||
182 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Implement the function gicv3_redist_vlpi_pending(), which was | ||
2 | previously left as a stub. This is the function that is called by | ||
3 | the CPU interface when it changes the state of a vLPI. It's similar | ||
4 | to gicv3_redist_process_vlpi(), but we know that the vCPU is | ||
5 | definitely resident on the redistributor and the irq is in range, so | ||
6 | it is a bit simpler. | ||
1 | 7 | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
10 | Message-id: 20220408141550.1271295-33-peter.maydell@linaro.org | ||
11 | --- | ||
12 | hw/intc/arm_gicv3_redist.c | 23 +++++++++++++++++++++-- | ||
13 | 1 file changed, 21 insertions(+), 2 deletions(-) | ||
14 | |||
15 | diff --git a/hw/intc/arm_gicv3_redist.c b/hw/intc/arm_gicv3_redist.c | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/hw/intc/arm_gicv3_redist.c | ||
18 | +++ b/hw/intc/arm_gicv3_redist.c | ||
19 | @@ -XXX,XX +XXX,XX @@ void gicv3_redist_movall_lpis(GICv3CPUState *src, GICv3CPUState *dest) | ||
20 | void gicv3_redist_vlpi_pending(GICv3CPUState *cs, int irq, int level) | ||
21 | { | ||
22 | /* | ||
23 | - * The redistributor handling for changing the pending state | ||
24 | - * of a vLPI will be added in a subsequent commit. | ||
25 | + * Change the pending state of the specified vLPI. | ||
26 | + * Unlike gicv3_redist_process_vlpi(), we know here that the | ||
27 | + * vCPU is definitely resident on this redistributor, and that | ||
28 | + * the irq is in range. | ||
29 | */ | ||
30 | + uint64_t vptbase, ctbase; | ||
31 | + | ||
32 | + vptbase = FIELD_EX64(cs->gicr_vpendbaser, GICR_VPENDBASER, PHYADDR) << 16; | ||
33 | + | ||
34 | + if (set_pending_table_bit(cs, vptbase, irq, level)) { | ||
35 | + if (level) { | ||
36 | + /* Check whether this vLPI is now the best */ | ||
37 | + ctbase = cs->gicr_vpropbaser & R_GICR_VPROPBASER_PHYADDR_MASK; | ||
38 | + update_for_one_lpi(cs, irq, ctbase, true, &cs->hppvlpi); | ||
39 | + gicv3_cpuif_virt_irq_fiq_update(cs); | ||
40 | + } else { | ||
41 | + /* Only need to recalculate if this was previously the best vLPI */ | ||
42 | + if (irq == cs->hppvlpi.irq) { | ||
43 | + gicv3_redist_update_vlpi(cs); | ||
44 | + } | ||
45 | + } | ||
46 | + } | ||
47 | } | ||
48 | |||
49 | void gicv3_redist_process_vlpi(GICv3CPUState *cs, int irq, uint64_t vptaddr, | ||
50 | -- | ||
51 | 2.25.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | We can use our new set_pending_table_bit() utility function | ||
2 | in gicv3_redist_mov_lpi() to clear the bit in the source | ||
3 | pending table, rather than doing the "load, clear bit, store" | ||
4 | ourselves. | ||
1 | 5 | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20220408141550.1271295-34-peter.maydell@linaro.org | ||
9 | --- | ||
10 | hw/intc/arm_gicv3_redist.c | 9 +-------- | ||
11 | 1 file changed, 1 insertion(+), 8 deletions(-) | ||
12 | |||
13 | diff --git a/hw/intc/arm_gicv3_redist.c b/hw/intc/arm_gicv3_redist.c | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/hw/intc/arm_gicv3_redist.c | ||
16 | +++ b/hw/intc/arm_gicv3_redist.c | ||
17 | @@ -XXX,XX +XXX,XX @@ void gicv3_redist_mov_lpi(GICv3CPUState *src, GICv3CPUState *dest, int irq) | ||
18 | * we choose to NOP. If LPIs are disabled on source there's nothing | ||
19 | * to be transferred anyway. | ||
20 | */ | ||
21 | - AddressSpace *as = &src->gic->dma_as; | ||
22 | uint64_t idbits; | ||
23 | uint32_t pendt_size; | ||
24 | uint64_t src_baddr; | ||
25 | - uint8_t src_pend; | ||
26 | |||
27 | if (!(src->gicr_ctlr & GICR_CTLR_ENABLE_LPIS) || | ||
28 | !(dest->gicr_ctlr & GICR_CTLR_ENABLE_LPIS)) { | ||
29 | @@ -XXX,XX +XXX,XX @@ void gicv3_redist_mov_lpi(GICv3CPUState *src, GICv3CPUState *dest, int irq) | ||
30 | |||
31 | src_baddr = src->gicr_pendbaser & R_GICR_PENDBASER_PHYADDR_MASK; | ||
32 | |||
33 | - address_space_read(as, src_baddr + (irq / 8), | ||
34 | - MEMTXATTRS_UNSPECIFIED, &src_pend, sizeof(src_pend)); | ||
35 | - if (!extract32(src_pend, irq % 8, 1)) { | ||
36 | + if (!set_pending_table_bit(src, src_baddr, irq, 0)) { | ||
37 | /* Not pending on source, nothing to do */ | ||
38 | return; | ||
39 | } | ||
40 | - src_pend &= ~(1 << (irq % 8)); | ||
41 | - address_space_write(as, src_baddr + (irq / 8), | ||
42 | - MEMTXATTRS_UNSPECIFIED, &src_pend, sizeof(src_pend)); | ||
43 | if (irq == src->hpplpi.irq) { | ||
44 | /* | ||
45 | * We just made this LPI not-pending so only need to update | ||
46 | -- | ||
47 | 2.25.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Implement the gicv3_redist_mov_vlpi() function (previously left as a | ||
2 | stub). This function handles the work of a VMOVI command: it marks | ||
3 | the vLPI not-pending on the source and pending on the destination. | ||
1 | 4 | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20220408141550.1271295-35-peter.maydell@linaro.org | ||
8 | --- | ||
9 | hw/intc/arm_gicv3_redist.c | 20 ++++++++++++++++++-- | ||
10 | 1 file changed, 18 insertions(+), 2 deletions(-) | ||
11 | |||
12 | diff --git a/hw/intc/arm_gicv3_redist.c b/hw/intc/arm_gicv3_redist.c | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/hw/intc/arm_gicv3_redist.c | ||
15 | +++ b/hw/intc/arm_gicv3_redist.c | ||
16 | @@ -XXX,XX +XXX,XX @@ void gicv3_redist_mov_vlpi(GICv3CPUState *src, uint64_t src_vptaddr, | ||
17 | int irq, int doorbell) | ||
18 | { | ||
19 | /* | ||
20 | - * The redistributor handling for moving a VLPI will be added | ||
21 | - * in a subsequent commit. | ||
22 | + * Move the specified vLPI's pending state from the source redistributor | ||
23 | + * to the destination. | ||
24 | */ | ||
25 | + if (!set_pending_table_bit(src, src_vptaddr, irq, 0)) { | ||
26 | + /* Not pending on source, nothing to do */ | ||
27 | + return; | ||
28 | + } | ||
29 | + if (vcpu_resident(src, src_vptaddr) && irq == src->hppvlpi.irq) { | ||
30 | + /* | ||
31 | + * Update src's cached highest-priority pending vLPI if we just made | ||
32 | + * it not-pending | ||
33 | + */ | ||
34 | + gicv3_redist_update_vlpi(src); | ||
35 | + } | ||
36 | + /* | ||
37 | + * Mark the vLPI pending on the destination (ringing the doorbell | ||
38 | + * if the vCPU isn't resident) | ||
39 | + */ | ||
40 | + gicv3_redist_process_vlpi(dest, irq, dest_vptaddr, doorbell, irq); | ||
41 | } | ||
42 | |||
43 | void gicv3_redist_vinvall(GICv3CPUState *cs, uint64_t vptaddr) | ||
44 | -- | ||
45 | 2.25.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Implement the gicv3_redist_vinvall() function (previously left as a | ||
2 | stub). This function handles the work of a VINVALL command: it must | ||
3 | invalidate any cached information associated with a specific vCPU. | ||
1 | 4 | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20220408141550.1271295-36-peter.maydell@linaro.org | ||
8 | --- | ||
9 | hw/intc/arm_gicv3_redist.c | 8 +++++++- | ||
10 | 1 file changed, 7 insertions(+), 1 deletion(-) | ||
11 | |||
12 | diff --git a/hw/intc/arm_gicv3_redist.c b/hw/intc/arm_gicv3_redist.c | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/hw/intc/arm_gicv3_redist.c | ||
15 | +++ b/hw/intc/arm_gicv3_redist.c | ||
16 | @@ -XXX,XX +XXX,XX @@ void gicv3_redist_mov_vlpi(GICv3CPUState *src, uint64_t src_vptaddr, | ||
17 | |||
18 | void gicv3_redist_vinvall(GICv3CPUState *cs, uint64_t vptaddr) | ||
19 | { | ||
20 | - /* The redistributor handling will be added in a subsequent commit */ | ||
21 | + if (!vcpu_resident(cs, vptaddr)) { | ||
22 | + /* We don't have anything cached if the vCPU isn't resident */ | ||
23 | + return; | ||
24 | + } | ||
25 | + | ||
26 | + /* Otherwise, our only cached information is the HPPVLPI info */ | ||
27 | + gicv3_redist_update_vlpi(cs); | ||
28 | } | ||
29 | |||
30 | void gicv3_redist_inv_vlpi(GICv3CPUState *cs, int irq, uint64_t vptaddr) | ||
31 | -- | ||
32 | 2.25.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Implement the function gicv3_redist_inv_vlpi(), which was previously | ||
2 | left as a stub. This is the function that does the work of the INV | ||
3 | command for a virtual interrupt. | ||
1 | 4 | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20220408141550.1271295-37-peter.maydell@linaro.org | ||
8 | --- | ||
9 | hw/intc/arm_gicv3_redist.c | 7 +++++-- | ||
10 | 1 file changed, 5 insertions(+), 2 deletions(-) | ||
11 | |||
12 | diff --git a/hw/intc/arm_gicv3_redist.c b/hw/intc/arm_gicv3_redist.c | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/hw/intc/arm_gicv3_redist.c | ||
15 | +++ b/hw/intc/arm_gicv3_redist.c | ||
16 | @@ -XXX,XX +XXX,XX @@ void gicv3_redist_vinvall(GICv3CPUState *cs, uint64_t vptaddr) | ||
17 | void gicv3_redist_inv_vlpi(GICv3CPUState *cs, int irq, uint64_t vptaddr) | ||
18 | { | ||
19 | /* | ||
20 | - * The redistributor handling for invalidating cached information | ||
21 | - * about a VLPI will be added in a subsequent commit. | ||
22 | + * The only cached information for LPIs we have is the HPPLPI. | ||
23 | + * We could be cleverer about identifying when we don't need | ||
24 | + * to do a full rescan of the pending table, but until we find | ||
25 | + * this is a performance issue, just always recalculate. | ||
26 | */ | ||
27 | + gicv3_redist_vinvall(cs, vptaddr); | ||
28 | } | ||
29 | |||
30 | void gicv3_redist_set_irq(GICv3CPUState *cs, int irq, int level) | ||
31 | -- | ||
32 | 2.25.1 | diff view generated by jsdifflib |
1 | The CCR is a register most of whose bits are banked between security | 1 | Update the various GIC ID and feature registers for GICv4: |
---|---|---|---|
2 | states but where BFHFNMIGN is not, and we keep it in the non-secure | 2 | * PIDR2 [7:4] is the GIC architecture revision |
3 | entry of the v7m.ccr[] array. The logic which tries to handle this | 3 | * GICD_TYPER.DVIS is 1 to indicate direct vLPI injection support |
4 | bit fails to implement the "RAZ/WI from Nonsecure if AIRCR.BFHFNMINS | 4 | * GICR_TYPER.VLPIS is 1 to indicate redistributor support for vLPIs |
5 | is zero" requirement; correct the omission. | 5 | * GITS_TYPER.VIRTUAL is 1 to indicate vLPI support |
6 | * GITS_TYPER.VMOVP is 1 to indicate that our VMOVP implementation | ||
7 | handles cross-ITS synchronization for the guest | ||
8 | * ICH_VTR_EL2.nV4 is 0 to indicate direct vLPI injection support | ||
6 | 9 | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 11 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
9 | Message-id: 20201210201433.26262-2-peter.maydell@linaro.org | 12 | Message-id: 20220408141550.1271295-38-peter.maydell@linaro.org |
10 | --- | 13 | --- |
11 | hw/intc/armv7m_nvic.c | 15 +++++++++++++++ | 14 | hw/intc/gicv3_internal.h | 15 +++++++++++---- |
12 | 1 file changed, 15 insertions(+) | 15 | hw/intc/arm_gicv3_common.c | 7 +++++-- |
16 | hw/intc/arm_gicv3_cpuif.c | 6 +++++- | ||
17 | hw/intc/arm_gicv3_dist.c | 7 ++++--- | ||
18 | hw/intc/arm_gicv3_its.c | 7 ++++++- | ||
19 | hw/intc/arm_gicv3_redist.c | 2 +- | ||
20 | 6 files changed, 32 insertions(+), 12 deletions(-) | ||
13 | 21 | ||
14 | diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c | 22 | diff --git a/hw/intc/gicv3_internal.h b/hw/intc/gicv3_internal.h |
15 | index XXXXXXX..XXXXXXX 100644 | 23 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/hw/intc/armv7m_nvic.c | 24 | --- a/hw/intc/gicv3_internal.h |
17 | +++ b/hw/intc/armv7m_nvic.c | 25 | +++ b/hw/intc/gicv3_internal.h |
18 | @@ -XXX,XX +XXX,XX @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs) | 26 | @@ -XXX,XX +XXX,XX @@ FIELD(GITS_TYPER, SEIS, 18, 1) |
27 | FIELD(GITS_TYPER, PTA, 19, 1) | ||
28 | FIELD(GITS_TYPER, CIDBITS, 32, 4) | ||
29 | FIELD(GITS_TYPER, CIL, 36, 1) | ||
30 | +FIELD(GITS_TYPER, VMOVP, 37, 1) | ||
31 | |||
32 | #define GITS_IDREGS 0xFFD0 | ||
33 | |||
34 | @@ -XXX,XX +XXX,XX @@ static inline uint32_t gicv3_iidr(void) | ||
35 | #define GICV3_PIDR0_REDIST 0x93 | ||
36 | #define GICV3_PIDR0_ITS 0x94 | ||
37 | |||
38 | -static inline uint32_t gicv3_idreg(int regoffset, uint8_t pidr0) | ||
39 | +static inline uint32_t gicv3_idreg(GICv3State *s, int regoffset, uint8_t pidr0) | ||
40 | { | ||
41 | /* Return the value of the CoreSight ID register at the specified | ||
42 | * offset from the first ID register (as found in the distributor | ||
43 | * and redistributor register banks). | ||
44 | - * These values indicate an ARM implementation of a GICv3. | ||
45 | + * These values indicate an ARM implementation of a GICv3 or v4. | ||
46 | */ | ||
47 | static const uint8_t gicd_ids[] = { | ||
48 | - 0x44, 0x00, 0x00, 0x00, 0x92, 0xB4, 0x3B, 0x00, 0x0D, 0xF0, 0x05, 0xB1 | ||
49 | + 0x44, 0x00, 0x00, 0x00, 0x92, 0xB4, 0x0B, 0x00, 0x0D, 0xF0, 0x05, 0xB1 | ||
50 | }; | ||
51 | + uint32_t id; | ||
52 | |||
53 | regoffset /= 4; | ||
54 | |||
55 | if (regoffset == 4) { | ||
56 | return pidr0; | ||
57 | } | ||
58 | - return gicd_ids[regoffset]; | ||
59 | + id = gicd_ids[regoffset]; | ||
60 | + if (regoffset == 6) { | ||
61 | + /* PIDR2 bits [7:4] are the GIC architecture revision */ | ||
62 | + id |= s->revision << 4; | ||
63 | + } | ||
64 | + return id; | ||
65 | } | ||
66 | |||
67 | /** | ||
68 | diff --git a/hw/intc/arm_gicv3_common.c b/hw/intc/arm_gicv3_common.c | ||
69 | index XXXXXXX..XXXXXXX 100644 | ||
70 | --- a/hw/intc/arm_gicv3_common.c | ||
71 | +++ b/hw/intc/arm_gicv3_common.c | ||
72 | @@ -XXX,XX +XXX,XX @@ static void arm_gicv3_common_realize(DeviceState *dev, Error **errp) | ||
73 | * Last == 1 if this is the last redistributor in a series of | ||
74 | * contiguous redistributor pages | ||
75 | * DirectLPI == 0 (direct injection of LPIs not supported) | ||
76 | - * VLPIS == 0 (virtual LPIs not supported) | ||
77 | - * PLPIS == 0 (physical LPIs not supported) | ||
78 | + * VLPIS == 1 if vLPIs supported (GICv4 and up) | ||
79 | + * PLPIS == 1 if LPIs supported | ||
19 | */ | 80 | */ |
20 | val = cpu->env.v7m.ccr[attrs.secure]; | 81 | cpu_affid = object_property_get_uint(OBJECT(cpu), "mp-affinity", NULL); |
21 | val |= cpu->env.v7m.ccr[M_REG_NS] & R_V7M_CCR_BFHFNMIGN_MASK; | 82 | |
22 | + /* BFHFNMIGN is RAZ/WI from NS if AIRCR.BFHFNMINS is 0 */ | 83 | @@ -XXX,XX +XXX,XX @@ static void arm_gicv3_common_realize(DeviceState *dev, Error **errp) |
23 | + if (!attrs.secure) { | 84 | |
24 | + if (!(cpu->env.v7m.aircr & R_V7M_AIRCR_BFHFNMINS_MASK)) { | 85 | if (s->lpi_enable) { |
25 | + val &= ~R_V7M_CCR_BFHFNMIGN_MASK; | 86 | s->cpu[i].gicr_typer |= GICR_TYPER_PLPIS; |
26 | + } | 87 | + if (s->revision > 3) { |
27 | + } | 88 | + s->cpu[i].gicr_typer |= GICR_TYPER_VLPIS; |
28 | return val; | ||
29 | case 0xd24: /* System Handler Control and State (SHCSR) */ | ||
30 | if (!arm_feature(&cpu->env, ARM_FEATURE_V7)) { | ||
31 | @@ -XXX,XX +XXX,XX @@ static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value, | ||
32 | (cpu->env.v7m.ccr[M_REG_NS] & ~R_V7M_CCR_BFHFNMIGN_MASK) | ||
33 | | (value & R_V7M_CCR_BFHFNMIGN_MASK); | ||
34 | value &= ~R_V7M_CCR_BFHFNMIGN_MASK; | ||
35 | + } else { | ||
36 | + /* | ||
37 | + * BFHFNMIGN is RAZ/WI from NS if AIRCR.BFHFNMINS is 0, so | ||
38 | + * preserve the state currently in the NS element of the array | ||
39 | + */ | ||
40 | + if (!(cpu->env.v7m.aircr & R_V7M_AIRCR_BFHFNMINS_MASK)) { | ||
41 | + value &= ~R_V7M_CCR_BFHFNMIGN_MASK; | ||
42 | + value |= cpu->env.v7m.ccr[M_REG_NS] & R_V7M_CCR_BFHFNMIGN_MASK; | ||
43 | + } | 89 | + } |
44 | } | 90 | } |
45 | 91 | } | |
46 | cpu->env.v7m.ccr[attrs.secure] = value; | 92 | |
93 | diff --git a/hw/intc/arm_gicv3_cpuif.c b/hw/intc/arm_gicv3_cpuif.c | ||
94 | index XXXXXXX..XXXXXXX 100644 | ||
95 | --- a/hw/intc/arm_gicv3_cpuif.c | ||
96 | +++ b/hw/intc/arm_gicv3_cpuif.c | ||
97 | @@ -XXX,XX +XXX,XX @@ static uint64_t ich_vtr_read(CPUARMState *env, const ARMCPRegInfo *ri) | ||
98 | uint64_t value; | ||
99 | |||
100 | value = ((cs->num_list_regs - 1) << ICH_VTR_EL2_LISTREGS_SHIFT) | ||
101 | - | ICH_VTR_EL2_TDS | ICH_VTR_EL2_NV4 | ICH_VTR_EL2_A3V | ||
102 | + | ICH_VTR_EL2_TDS | ICH_VTR_EL2_A3V | ||
103 | | (1 << ICH_VTR_EL2_IDBITS_SHIFT) | ||
104 | | ((cs->vprebits - 1) << ICH_VTR_EL2_PREBITS_SHIFT) | ||
105 | | ((cs->vpribits - 1) << ICH_VTR_EL2_PRIBITS_SHIFT); | ||
106 | |||
107 | + if (cs->gic->revision < 4) { | ||
108 | + value |= ICH_VTR_EL2_NV4; | ||
109 | + } | ||
110 | + | ||
111 | trace_gicv3_ich_vtr_read(gicv3_redist_affid(cs), value); | ||
112 | return value; | ||
113 | } | ||
114 | diff --git a/hw/intc/arm_gicv3_dist.c b/hw/intc/arm_gicv3_dist.c | ||
115 | index XXXXXXX..XXXXXXX 100644 | ||
116 | --- a/hw/intc/arm_gicv3_dist.c | ||
117 | +++ b/hw/intc/arm_gicv3_dist.c | ||
118 | @@ -XXX,XX +XXX,XX @@ static bool gicd_readl(GICv3State *s, hwaddr offset, | ||
119 | * No1N == 1 (1-of-N SPI interrupts not supported) | ||
120 | * A3V == 1 (non-zero values of Affinity level 3 supported) | ||
121 | * IDbits == 0xf (we support 16-bit interrupt identifiers) | ||
122 | - * DVIS == 0 (Direct virtual LPI injection not supported) | ||
123 | + * DVIS == 1 (Direct virtual LPI injection supported) if GICv4 | ||
124 | * LPIS == 1 (LPIs are supported if affinity routing is enabled) | ||
125 | * num_LPIs == 0b00000 (bits [15:11],Number of LPIs as indicated | ||
126 | * by GICD_TYPER.IDbits) | ||
127 | @@ -XXX,XX +XXX,XX @@ static bool gicd_readl(GICv3State *s, hwaddr offset, | ||
128 | * so we only need to check the DS bit. | ||
129 | */ | ||
130 | bool sec_extn = !(s->gicd_ctlr & GICD_CTLR_DS); | ||
131 | + bool dvis = s->revision >= 4; | ||
132 | |||
133 | - *data = (1 << 25) | (1 << 24) | (sec_extn << 10) | | ||
134 | + *data = (1 << 25) | (1 << 24) | (dvis << 18) | (sec_extn << 10) | | ||
135 | (s->lpi_enable << GICD_TYPER_LPIS_SHIFT) | | ||
136 | (0xf << 19) | itlinesnumber; | ||
137 | return true; | ||
138 | @@ -XXX,XX +XXX,XX @@ static bool gicd_readl(GICv3State *s, hwaddr offset, | ||
139 | } | ||
140 | case GICD_IDREGS ... GICD_IDREGS + 0x2f: | ||
141 | /* ID registers */ | ||
142 | - *data = gicv3_idreg(offset - GICD_IDREGS, GICV3_PIDR0_DIST); | ||
143 | + *data = gicv3_idreg(s, offset - GICD_IDREGS, GICV3_PIDR0_DIST); | ||
144 | return true; | ||
145 | case GICD_SGIR: | ||
146 | /* WO registers, return unknown value */ | ||
147 | diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c | ||
148 | index XXXXXXX..XXXXXXX 100644 | ||
149 | --- a/hw/intc/arm_gicv3_its.c | ||
150 | +++ b/hw/intc/arm_gicv3_its.c | ||
151 | @@ -XXX,XX +XXX,XX @@ static bool its_readl(GICv3ITSState *s, hwaddr offset, | ||
152 | break; | ||
153 | case GITS_IDREGS ... GITS_IDREGS + 0x2f: | ||
154 | /* ID registers */ | ||
155 | - *data = gicv3_idreg(offset - GITS_IDREGS, GICV3_PIDR0_ITS); | ||
156 | + *data = gicv3_idreg(s->gicv3, offset - GITS_IDREGS, GICV3_PIDR0_ITS); | ||
157 | break; | ||
158 | case GITS_TYPER: | ||
159 | *data = extract64(s->typer, 0, 32); | ||
160 | @@ -XXX,XX +XXX,XX @@ static void gicv3_arm_its_realize(DeviceState *dev, Error **errp) | ||
161 | s->typer = FIELD_DP64(s->typer, GITS_TYPER, DEVBITS, ITS_DEVBITS); | ||
162 | s->typer = FIELD_DP64(s->typer, GITS_TYPER, CIL, 1); | ||
163 | s->typer = FIELD_DP64(s->typer, GITS_TYPER, CIDBITS, ITS_CIDBITS); | ||
164 | + if (s->gicv3->revision >= 4) { | ||
165 | + /* Our VMOVP handles cross-ITS synchronization itself */ | ||
166 | + s->typer = FIELD_DP64(s->typer, GITS_TYPER, VMOVP, 1); | ||
167 | + s->typer = FIELD_DP64(s->typer, GITS_TYPER, VIRTUAL, 1); | ||
168 | + } | ||
169 | } | ||
170 | |||
171 | static void gicv3_its_reset(DeviceState *dev) | ||
172 | diff --git a/hw/intc/arm_gicv3_redist.c b/hw/intc/arm_gicv3_redist.c | ||
173 | index XXXXXXX..XXXXXXX 100644 | ||
174 | --- a/hw/intc/arm_gicv3_redist.c | ||
175 | +++ b/hw/intc/arm_gicv3_redist.c | ||
176 | @@ -XXX,XX +XXX,XX @@ static MemTxResult gicr_readl(GICv3CPUState *cs, hwaddr offset, | ||
177 | *data = cs->gicr_nsacr; | ||
178 | return MEMTX_OK; | ||
179 | case GICR_IDREGS ... GICR_IDREGS + 0x2f: | ||
180 | - *data = gicv3_idreg(offset - GICR_IDREGS, GICV3_PIDR0_REDIST); | ||
181 | + *data = gicv3_idreg(cs->gic, offset - GICR_IDREGS, GICV3_PIDR0_REDIST); | ||
182 | return MEMTX_OK; | ||
183 | /* | ||
184 | * VLPI frame registers. We don't need a version check for | ||
47 | -- | 185 | -- |
48 | 2.20.1 | 186 | 2.25.1 |
49 | |||
50 | diff view generated by jsdifflib |
1 | Now that timer_free() implicitly calls timer_del(), sequences | 1 | Now that we have implemented all the GICv4 requirements, relax the |
---|---|---|---|
2 | timer_del(mytimer); | 2 | error-checking on the GIC object's 'revision' property to allow a TCG |
3 | timer_free(mytimer); | 3 | GIC to be a GICv4, whilst still constraining the KVM GIC to GICv3. |
4 | 4 | ||
5 | can be simplified to just | 5 | Our 'revision' property doesn't consider the possibility of wanting |
6 | timer_free(mytimer); | 6 | to specify the minor version of the GIC -- for instance there is a |
7 | 7 | GICv3.1 which adds support for extended SPI and PPI ranges, among | |
8 | Add a Coccinelle script to do this transformation. | 8 | other things, and also GICv4.1. But since the QOM property is |
9 | internal to QEMU, not user-facing, we can cross that bridge when we | ||
10 | come to it. Within the GIC implementation itself code generally | ||
11 | checks against the appropriate ID register feature bits, and the | ||
12 | only use of s->revision is for setting those ID register bits. | ||
9 | 13 | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | Acked-by: Paolo Bonzini <pbonzini@redhat.com> | ||
12 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
13 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 15 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
14 | Message-id: 20201215154107.3255-3-peter.maydell@linaro.org | 16 | Message-id: 20220408141550.1271295-39-peter.maydell@linaro.org |
15 | --- | 17 | --- |
16 | scripts/coccinelle/timer-del-timer-free.cocci | 18 ++++++++++++++++++ | 18 | hw/intc/arm_gicv3_common.c | 12 +++++++----- |
17 | 1 file changed, 18 insertions(+) | 19 | hw/intc/arm_gicv3_kvm.c | 5 +++++ |
18 | create mode 100644 scripts/coccinelle/timer-del-timer-free.cocci | 20 | 2 files changed, 12 insertions(+), 5 deletions(-) |
19 | 21 | ||
20 | diff --git a/scripts/coccinelle/timer-del-timer-free.cocci b/scripts/coccinelle/timer-del-timer-free.cocci | 22 | diff --git a/hw/intc/arm_gicv3_common.c b/hw/intc/arm_gicv3_common.c |
21 | new file mode 100644 | 23 | index XXXXXXX..XXXXXXX 100644 |
22 | index XXXXXXX..XXXXXXX | 24 | --- a/hw/intc/arm_gicv3_common.c |
23 | --- /dev/null | 25 | +++ b/hw/intc/arm_gicv3_common.c |
24 | +++ b/scripts/coccinelle/timer-del-timer-free.cocci | 26 | @@ -XXX,XX +XXX,XX @@ static void arm_gicv3_common_realize(DeviceState *dev, Error **errp) |
25 | @@ -XXX,XX +XXX,XX @@ | 27 | GICv3State *s = ARM_GICV3_COMMON(dev); |
26 | +// Remove superfluous timer_del() calls | 28 | int i, rdist_capacity, cpuidx; |
27 | +// | 29 | |
28 | +// Copyright Linaro Limited 2020 | 30 | - /* revision property is actually reserved and currently used only in order |
29 | +// This work is licensed under the terms of the GNU GPLv2 or later. | 31 | - * to keep the interface compatible with GICv2 code, avoiding extra |
30 | +// | 32 | - * conditions. However, in future it could be used, for example, if we |
31 | +// spatch --macro-file scripts/cocci-macro-file.h \ | 33 | - * implement GICv4. |
32 | +// --sp-file scripts/coccinelle/timer-del-timer-free.cocci \ | 34 | + /* |
33 | +// --in-place --dir . | 35 | + * This GIC device supports only revisions 3 and 4. The GICv1/v2 |
34 | +// | 36 | + * is a separate device. |
35 | +// The timer_free() function now implicitly calls timer_del() | 37 | + * Note that subclasses of this device may impose further restrictions |
36 | +// for you, so calls to timer_del() immediately before the | 38 | + * on the GIC revision: notably, the in-kernel KVM GIC doesn't |
37 | +// timer_free() of the same timer can be deleted. | 39 | + * support GICv4. |
40 | */ | ||
41 | - if (s->revision != 3) { | ||
42 | + if (s->revision != 3 && s->revision != 4) { | ||
43 | error_setg(errp, "unsupported GIC revision %d", s->revision); | ||
44 | return; | ||
45 | } | ||
46 | diff --git a/hw/intc/arm_gicv3_kvm.c b/hw/intc/arm_gicv3_kvm.c | ||
47 | index XXXXXXX..XXXXXXX 100644 | ||
48 | --- a/hw/intc/arm_gicv3_kvm.c | ||
49 | +++ b/hw/intc/arm_gicv3_kvm.c | ||
50 | @@ -XXX,XX +XXX,XX @@ static void kvm_arm_gicv3_realize(DeviceState *dev, Error **errp) | ||
51 | return; | ||
52 | } | ||
53 | |||
54 | + if (s->revision != 3) { | ||
55 | + error_setg(errp, "unsupported GIC revision %d for in-kernel GIC", | ||
56 | + s->revision); | ||
57 | + } | ||
38 | + | 58 | + |
39 | +@@ | 59 | if (s->security_extn) { |
40 | +expression T; | 60 | error_setg(errp, "the in-kernel VGICv3 does not implement the " |
41 | +@@ | 61 | "security extensions"); |
42 | +-timer_del(T); | ||
43 | + timer_free(T); | ||
44 | -- | 62 | -- |
45 | 2.20.1 | 63 | 2.25.1 |
46 | |||
47 | diff view generated by jsdifflib |
1 | Support for running KVM on 32-bit Arm hosts was removed in commit | 1 | Everywhere we need to check which GIC version we're using, we look at |
---|---|---|---|
2 | 82bf7ae84ce739e. You can still run a 32-bit guest on a 64-bit Arm | 2 | vms->gic_version and use the VIRT_GIC_VERSION_* enum values, except |
3 | host CPU, but because Arm KVM requires the host and guest CPU types | 3 | in create_gic(), which copies vms->gic_version into a local 'int' |
4 | to match, it is not possible to run a guest that requires a Cortex-A9 | 4 | variable and makes direct comparisons against values 2 and 3. |
5 | or Cortex-A15 CPU there. That means that the code in the | 5 | |
6 | highbank/midway board models to support KVM is no longer used, and we | 6 | For consistency, change this function to check the GIC version |
7 | can delete it. | 7 | the same way we do elsewhere. This includes not implicitly relying |
8 | on the enumeration type values happening to match the integer | ||
9 | 'revision' values the GIC device object wants. | ||
8 | 10 | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 12 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
11 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 13 | Message-id: 20220408141550.1271295-40-peter.maydell@linaro.org |
12 | Message-id: 20201215144215.28482-1-peter.maydell@linaro.org | ||
13 | --- | 14 | --- |
14 | hw/arm/highbank.c | 14 ++++---------- | 15 | hw/arm/virt.c | 31 +++++++++++++++++++++++-------- |
15 | 1 file changed, 4 insertions(+), 10 deletions(-) | 16 | 1 file changed, 23 insertions(+), 8 deletions(-) |
16 | 17 | ||
17 | diff --git a/hw/arm/highbank.c b/hw/arm/highbank.c | 18 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c |
18 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/hw/arm/highbank.c | 20 | --- a/hw/arm/virt.c |
20 | +++ b/hw/arm/highbank.c | 21 | +++ b/hw/arm/virt.c |
21 | @@ -XXX,XX +XXX,XX @@ | 22 | @@ -XXX,XX +XXX,XX @@ static void create_gic(VirtMachineState *vms, MemoryRegion *mem) |
22 | #include "hw/arm/boot.h" | 23 | /* We create a standalone GIC */ |
23 | #include "hw/loader.h" | 24 | SysBusDevice *gicbusdev; |
24 | #include "net/net.h" | 25 | const char *gictype; |
25 | -#include "sysemu/kvm.h" | 26 | - int type = vms->gic_version, i; |
26 | #include "sysemu/runstate.h" | 27 | + int i; |
27 | #include "sysemu/sysemu.h" | 28 | unsigned int smp_cpus = ms->smp.cpus; |
28 | #include "hw/boards.h" | 29 | uint32_t nb_redist_regions = 0; |
29 | @@ -XXX,XX +XXX,XX @@ | 30 | + int revision; |
30 | #include "hw/cpu/a15mpcore.h" | 31 | |
31 | #include "qemu/log.h" | 32 | - gictype = (type == 3) ? gicv3_class_name() : gic_class_name(); |
32 | #include "qom/object.h" | 33 | + if (vms->gic_version == VIRT_GIC_VERSION_2) { |
33 | +#include "cpu.h" | 34 | + gictype = gic_class_name(); |
34 | 35 | + } else { | |
35 | #define SMP_BOOT_ADDR 0x100 | 36 | + gictype = gicv3_class_name(); |
36 | #define SMP_BOOT_REG 0x40 | 37 | + } |
37 | @@ -XXX,XX +XXX,XX @@ static void calxeda_init(MachineState *machine, enum cxmachines machine_id) | 38 | |
38 | highbank_binfo.loader_start = 0; | 39 | + switch (vms->gic_version) { |
39 | highbank_binfo.write_secondary_boot = hb_write_secondary; | 40 | + case VIRT_GIC_VERSION_2: |
40 | highbank_binfo.secondary_cpu_reset_hook = hb_reset_secondary; | 41 | + revision = 2; |
41 | - if (!kvm_enabled()) { | 42 | + break; |
42 | - highbank_binfo.board_setup_addr = BOARD_SETUP_ADDR; | 43 | + case VIRT_GIC_VERSION_3: |
43 | - highbank_binfo.write_board_setup = hb_write_board_setup; | 44 | + revision = 3; |
44 | - highbank_binfo.secure_board_setup = true; | 45 | + break; |
45 | - } else { | 46 | + default: |
46 | - warn_report("cannot load built-in Monitor support " | 47 | + g_assert_not_reached(); |
47 | - "if KVM is enabled. Some guests (such as Linux) " | 48 | + } |
48 | - "may not boot."); | 49 | vms->gic = qdev_new(gictype); |
49 | - } | 50 | - qdev_prop_set_uint32(vms->gic, "revision", type); |
50 | + highbank_binfo.board_setup_addr = BOARD_SETUP_ADDR; | 51 | + qdev_prop_set_uint32(vms->gic, "revision", revision); |
51 | + highbank_binfo.write_board_setup = hb_write_board_setup; | 52 | qdev_prop_set_uint32(vms->gic, "num-cpu", smp_cpus); |
52 | + highbank_binfo.secure_board_setup = true; | 53 | /* Note that the num-irq property counts both internal and external |
53 | 54 | * interrupts; there are always 32 of the former (mandated by GIC spec). | |
54 | arm_load_kernel(ARM_CPU(first_cpu), machine, &highbank_binfo); | 55 | @@ -XXX,XX +XXX,XX @@ static void create_gic(VirtMachineState *vms, MemoryRegion *mem) |
56 | qdev_prop_set_bit(vms->gic, "has-security-extensions", vms->secure); | ||
57 | } | ||
58 | |||
59 | - if (type == 3) { | ||
60 | + if (vms->gic_version == VIRT_GIC_VERSION_3) { | ||
61 | uint32_t redist0_capacity = | ||
62 | vms->memmap[VIRT_GIC_REDIST].size / GICV3_REDIST_SIZE; | ||
63 | uint32_t redist0_count = MIN(smp_cpus, redist0_capacity); | ||
64 | @@ -XXX,XX +XXX,XX @@ static void create_gic(VirtMachineState *vms, MemoryRegion *mem) | ||
65 | gicbusdev = SYS_BUS_DEVICE(vms->gic); | ||
66 | sysbus_realize_and_unref(gicbusdev, &error_fatal); | ||
67 | sysbus_mmio_map(gicbusdev, 0, vms->memmap[VIRT_GIC_DIST].base); | ||
68 | - if (type == 3) { | ||
69 | + if (vms->gic_version == VIRT_GIC_VERSION_3) { | ||
70 | sysbus_mmio_map(gicbusdev, 1, vms->memmap[VIRT_GIC_REDIST].base); | ||
71 | if (nb_redist_regions == 2) { | ||
72 | sysbus_mmio_map(gicbusdev, 2, | ||
73 | @@ -XXX,XX +XXX,XX @@ static void create_gic(VirtMachineState *vms, MemoryRegion *mem) | ||
74 | ppibase + timer_irq[irq])); | ||
75 | } | ||
76 | |||
77 | - if (type == 3) { | ||
78 | + if (vms->gic_version == VIRT_GIC_VERSION_3) { | ||
79 | qemu_irq irq = qdev_get_gpio_in(vms->gic, | ||
80 | ppibase + ARCH_GIC_MAINT_IRQ); | ||
81 | qdev_connect_gpio_out_named(cpudev, "gicv3-maintenance-interrupt", | ||
82 | @@ -XXX,XX +XXX,XX @@ static void create_gic(VirtMachineState *vms, MemoryRegion *mem) | ||
83 | |||
84 | fdt_add_gic_node(vms); | ||
85 | |||
86 | - if (type == 3 && vms->its) { | ||
87 | + if (vms->gic_version == VIRT_GIC_VERSION_3 && vms->its) { | ||
88 | create_its(vms); | ||
89 | - } else if (type == 2) { | ||
90 | + } else if (vms->gic_version == VIRT_GIC_VERSION_2) { | ||
91 | create_v2m(vms); | ||
92 | } | ||
55 | } | 93 | } |
56 | -- | 94 | -- |
57 | 2.20.1 | 95 | 2.25.1 |
58 | |||
59 | diff view generated by jsdifflib |
1 | From: Andrew Jones <drjones@redhat.com> | 1 | In several places in virt.c we calculate the number of redistributors that |
---|---|---|---|
2 | fit in a region of our memory map, which is the size of the region | ||
3 | divided by the size of a single redistributor frame. For GICv4, the | ||
4 | redistributor frame is a different size from that for GICv3. Abstract | ||
5 | out the calculation of redistributor region capacity so that we have | ||
6 | one place we need to change to handle GICv4 rather than several. | ||
2 | 7 | ||
3 | virt machine's 'smp_cpus' and machine->smp.cpus must always have the | ||
4 | same value. And, anywhere we have virt machine state we have machine | ||
5 | state. So let's remove the redundancy. Also, to make it easier to see | ||
6 | that machine->smp is the true source for "smp_cpus" and "max_cpus", | ||
7 | avoid passing them in function parameters, preferring instead to get | ||
8 | them from the state. | ||
9 | |||
10 | No functional change intended. | ||
11 | |||
12 | Signed-off-by: Andrew Jones <drjones@redhat.com> | ||
13 | Reviewed-by: David Edmondson <david.edmondson@oracle.com> | ||
14 | Reviewed-by: Ying Fang <fangying1@huawei.com> | ||
15 | Message-id: 20201215174815.51520-1-drjones@redhat.com | ||
16 | [PMM: minor formatting tweak to smp_cpus variable declaration] | ||
17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
10 | Message-id: 20220408141550.1271295-41-peter.maydell@linaro.org | ||
18 | --- | 11 | --- |
19 | include/hw/arm/virt.h | 3 +-- | 12 | include/hw/arm/virt.h | 9 +++++++-- |
20 | hw/arm/virt-acpi-build.c | 9 +++++---- | 13 | hw/arm/virt.c | 11 ++++------- |
21 | hw/arm/virt.c | 21 ++++++++++----------- | 14 | 2 files changed, 11 insertions(+), 9 deletions(-) |
22 | 3 files changed, 16 insertions(+), 17 deletions(-) | ||
23 | 15 | ||
24 | diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h | 16 | diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h |
25 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
26 | --- a/include/hw/arm/virt.h | 18 | --- a/include/hw/arm/virt.h |
27 | +++ b/include/hw/arm/virt.h | 19 | +++ b/include/hw/arm/virt.h |
28 | @@ -XXX,XX +XXX,XX @@ struct VirtMachineState { | 20 | @@ -XXX,XX +XXX,XX @@ OBJECT_DECLARE_TYPE(VirtMachineState, VirtMachineClass, VIRT_MACHINE) |
29 | MemMapEntry *memmap; | 21 | void virt_acpi_setup(VirtMachineState *vms); |
30 | char *pciehb_nodename; | 22 | bool virt_is_acpi_enabled(VirtMachineState *vms); |
31 | const int *irqmap; | 23 | |
32 | - int smp_cpus; | 24 | +/* Return number of redistributors that fit in the specified region */ |
33 | void *fdt; | 25 | +static uint32_t virt_redist_capacity(VirtMachineState *vms, int region) |
34 | int fdt_size; | 26 | +{ |
35 | uint32_t clock_phandle; | 27 | + return vms->memmap[region].size / GICV3_REDIST_SIZE; |
36 | @@ -XXX,XX +XXX,XX @@ static inline int virt_gicv3_redist_region_count(VirtMachineState *vms) | 28 | +} |
29 | + | ||
30 | /* Return the number of used redistributor regions */ | ||
31 | static inline int virt_gicv3_redist_region_count(VirtMachineState *vms) | ||
32 | { | ||
33 | - uint32_t redist0_capacity = | ||
34 | - vms->memmap[VIRT_GIC_REDIST].size / GICV3_REDIST_SIZE; | ||
35 | + uint32_t redist0_capacity = virt_redist_capacity(vms, VIRT_GIC_REDIST); | ||
37 | 36 | ||
38 | assert(vms->gic_version == VIRT_GIC_VERSION_3); | 37 | assert(vms->gic_version == VIRT_GIC_VERSION_3); |
39 | 38 | ||
40 | - return vms->smp_cpus > redist0_capacity ? 2 : 1; | ||
41 | + return MACHINE(vms)->smp.cpus > redist0_capacity ? 2 : 1; | ||
42 | } | ||
43 | |||
44 | #endif /* QEMU_ARM_VIRT_H */ | ||
45 | diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c | ||
46 | index XXXXXXX..XXXXXXX 100644 | ||
47 | --- a/hw/arm/virt-acpi-build.c | ||
48 | +++ b/hw/arm/virt-acpi-build.c | ||
49 | @@ -XXX,XX +XXX,XX @@ | ||
50 | |||
51 | #define ACPI_BUILD_TABLE_SIZE 0x20000 | ||
52 | |||
53 | -static void acpi_dsdt_add_cpus(Aml *scope, int smp_cpus) | ||
54 | +static void acpi_dsdt_add_cpus(Aml *scope, VirtMachineState *vms) | ||
55 | { | ||
56 | + MachineState *ms = MACHINE(vms); | ||
57 | uint16_t i; | ||
58 | |||
59 | - for (i = 0; i < smp_cpus; i++) { | ||
60 | + for (i = 0; i < ms->smp.cpus; i++) { | ||
61 | Aml *dev = aml_device("C%.03X", i); | ||
62 | aml_append(dev, aml_name_decl("_HID", aml_string("ACPI0007"))); | ||
63 | aml_append(dev, aml_name_decl("_UID", aml_int(i))); | ||
64 | @@ -XXX,XX +XXX,XX @@ build_madt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) | ||
65 | gicd->base_address = cpu_to_le64(memmap[VIRT_GIC_DIST].base); | ||
66 | gicd->version = vms->gic_version; | ||
67 | |||
68 | - for (i = 0; i < vms->smp_cpus; i++) { | ||
69 | + for (i = 0; i < MACHINE(vms)->smp.cpus; i++) { | ||
70 | AcpiMadtGenericCpuInterface *gicc = acpi_data_push(table_data, | ||
71 | sizeof(*gicc)); | ||
72 | ARMCPU *armcpu = ARM_CPU(qemu_get_cpu(i)); | ||
73 | @@ -XXX,XX +XXX,XX @@ build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) | ||
74 | * the RTC ACPI device at all when using UEFI. | ||
75 | */ | ||
76 | scope = aml_scope("\\_SB"); | ||
77 | - acpi_dsdt_add_cpus(scope, vms->smp_cpus); | ||
78 | + acpi_dsdt_add_cpus(scope, vms); | ||
79 | acpi_dsdt_add_uart(scope, &memmap[VIRT_UART], | ||
80 | (irqmap[VIRT_UART] + ARM_SPI_BASE)); | ||
81 | if (vmc->acpi_expose_flash) { | ||
82 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c | 39 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c |
83 | index XXXXXXX..XXXXXXX 100644 | 40 | index XXXXXXX..XXXXXXX 100644 |
84 | --- a/hw/arm/virt.c | 41 | --- a/hw/arm/virt.c |
85 | +++ b/hw/arm/virt.c | 42 | +++ b/hw/arm/virt.c |
86 | @@ -XXX,XX +XXX,XX @@ static void fdt_add_timer_nodes(const VirtMachineState *vms) | 43 | @@ -XXX,XX +XXX,XX @@ static void create_gic(VirtMachineState *vms, MemoryRegion *mem) |
87 | if (vms->gic_version == VIRT_GIC_VERSION_2) { | ||
88 | irqflags = deposit32(irqflags, GIC_FDT_IRQ_PPI_CPU_START, | ||
89 | GIC_FDT_IRQ_PPI_CPU_WIDTH, | ||
90 | - (1 << vms->smp_cpus) - 1); | ||
91 | + (1 << MACHINE(vms)->smp.cpus) - 1); | ||
92 | } | 44 | } |
93 | 45 | ||
94 | qemu_fdt_add_subnode(vms->fdt, "/timer"); | 46 | if (vms->gic_version == VIRT_GIC_VERSION_3) { |
95 | @@ -XXX,XX +XXX,XX @@ static void fdt_add_cpu_nodes(const VirtMachineState *vms) | 47 | - uint32_t redist0_capacity = |
96 | int cpu; | 48 | - vms->memmap[VIRT_GIC_REDIST].size / GICV3_REDIST_SIZE; |
97 | int addr_cells = 1; | 49 | + uint32_t redist0_capacity = virt_redist_capacity(vms, VIRT_GIC_REDIST); |
98 | const MachineState *ms = MACHINE(vms); | 50 | uint32_t redist0_count = MIN(smp_cpus, redist0_capacity); |
99 | + int smp_cpus = ms->smp.cpus; | 51 | |
100 | 52 | nb_redist_regions = virt_gicv3_redist_region_count(vms); | |
101 | /* | 53 | @@ -XXX,XX +XXX,XX @@ static void create_gic(VirtMachineState *vms, MemoryRegion *mem) |
102 | * From Documentation/devicetree/bindings/arm/cpus.txt | 54 | |
103 | @@ -XXX,XX +XXX,XX @@ static void fdt_add_cpu_nodes(const VirtMachineState *vms) | 55 | if (nb_redist_regions == 2) { |
104 | * The simplest way to go is to examine affinity IDs of all our CPUs. If | 56 | uint32_t redist1_capacity = |
105 | * at least one of them has Aff3 populated, we set #address-cells to 2. | 57 | - vms->memmap[VIRT_HIGH_GIC_REDIST2].size / GICV3_REDIST_SIZE; |
58 | + virt_redist_capacity(vms, VIRT_HIGH_GIC_REDIST2); | ||
59 | |||
60 | qdev_prop_set_uint32(vms->gic, "redist-region-count[1]", | ||
61 | MIN(smp_cpus - redist0_count, redist1_capacity)); | ||
62 | @@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine) | ||
63 | * many redistributors we can fit into the memory map. | ||
106 | */ | 64 | */ |
107 | - for (cpu = 0; cpu < vms->smp_cpus; cpu++) { | 65 | if (vms->gic_version == VIRT_GIC_VERSION_3) { |
108 | + for (cpu = 0; cpu < smp_cpus; cpu++) { | 66 | - virt_max_cpus = |
109 | ARMCPU *armcpu = ARM_CPU(qemu_get_cpu(cpu)); | 67 | - vms->memmap[VIRT_GIC_REDIST].size / GICV3_REDIST_SIZE; |
110 | 68 | - virt_max_cpus += | |
111 | if (armcpu->mp_affinity & ARM_AFF3_MASK) { | 69 | - vms->memmap[VIRT_HIGH_GIC_REDIST2].size / GICV3_REDIST_SIZE; |
112 | @@ -XXX,XX +XXX,XX @@ static void fdt_add_cpu_nodes(const VirtMachineState *vms) | 70 | + virt_max_cpus = virt_redist_capacity(vms, VIRT_GIC_REDIST) + |
113 | qemu_fdt_setprop_cell(vms->fdt, "/cpus", "#address-cells", addr_cells); | 71 | + virt_redist_capacity(vms, VIRT_HIGH_GIC_REDIST2); |
114 | qemu_fdt_setprop_cell(vms->fdt, "/cpus", "#size-cells", 0x0); | 72 | } else { |
115 | 73 | virt_max_cpus = GIC_NCPU; | |
116 | - for (cpu = vms->smp_cpus - 1; cpu >= 0; cpu--) { | ||
117 | + for (cpu = smp_cpus - 1; cpu >= 0; cpu--) { | ||
118 | char *nodename = g_strdup_printf("/cpus/cpu@%d", cpu); | ||
119 | ARMCPU *armcpu = ARM_CPU(qemu_get_cpu(cpu)); | ||
120 | CPUState *cs = CPU(armcpu); | ||
121 | @@ -XXX,XX +XXX,XX @@ static void fdt_add_cpu_nodes(const VirtMachineState *vms) | ||
122 | qemu_fdt_setprop_string(vms->fdt, nodename, "compatible", | ||
123 | armcpu->dtb_compatible); | ||
124 | |||
125 | - if (vms->psci_conduit != QEMU_PSCI_CONDUIT_DISABLED | ||
126 | - && vms->smp_cpus > 1) { | ||
127 | + if (vms->psci_conduit != QEMU_PSCI_CONDUIT_DISABLED && smp_cpus > 1) { | ||
128 | qemu_fdt_setprop_string(vms->fdt, nodename, | ||
129 | "enable-method", "psci"); | ||
130 | } | ||
131 | @@ -XXX,XX +XXX,XX @@ static void fdt_add_pmu_nodes(const VirtMachineState *vms) | ||
132 | if (vms->gic_version == VIRT_GIC_VERSION_2) { | ||
133 | irqflags = deposit32(irqflags, GIC_FDT_IRQ_PPI_CPU_START, | ||
134 | GIC_FDT_IRQ_PPI_CPU_WIDTH, | ||
135 | - (1 << vms->smp_cpus) - 1); | ||
136 | + (1 << MACHINE(vms)->smp.cpus) - 1); | ||
137 | } | 74 | } |
138 | |||
139 | qemu_fdt_add_subnode(vms->fdt, "/pmu"); | ||
140 | @@ -XXX,XX +XXX,XX @@ static void finalize_gic_version(VirtMachineState *vms) | ||
141 | * virt_cpu_post_init() must be called after the CPUs have | ||
142 | * been realized and the GIC has been created. | ||
143 | */ | ||
144 | -static void virt_cpu_post_init(VirtMachineState *vms, int max_cpus, | ||
145 | - MemoryRegion *sysmem) | ||
146 | +static void virt_cpu_post_init(VirtMachineState *vms, MemoryRegion *sysmem) | ||
147 | { | ||
148 | + int max_cpus = MACHINE(vms)->smp.max_cpus; | ||
149 | bool aarch64, pmu, steal_time; | ||
150 | CPUState *cpu; | ||
151 | |||
152 | @@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine) | ||
153 | exit(1); | ||
154 | } | ||
155 | |||
156 | - vms->smp_cpus = smp_cpus; | ||
157 | - | ||
158 | if (vms->virt && kvm_enabled()) { | ||
159 | error_report("mach-virt: KVM does not support providing " | ||
160 | "Virtualization extensions to the guest CPU"); | ||
161 | @@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine) | ||
162 | create_fdt(vms); | ||
163 | |||
164 | possible_cpus = mc->possible_cpu_arch_ids(machine); | ||
165 | + assert(possible_cpus->len == max_cpus); | ||
166 | for (n = 0; n < possible_cpus->len; n++) { | ||
167 | Object *cpuobj; | ||
168 | CPUState *cs; | ||
169 | @@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine) | ||
170 | |||
171 | create_gic(vms); | ||
172 | |||
173 | - virt_cpu_post_init(vms, possible_cpus->len, sysmem); | ||
174 | + virt_cpu_post_init(vms, sysmem); | ||
175 | |||
176 | fdt_add_pmu_nodes(vms); | ||
177 | |||
178 | -- | 75 | -- |
179 | 2.20.1 | 76 | 2.25.1 |
180 | |||
181 | diff view generated by jsdifflib |
1 | In commit 64f863baeedc8659 we implemented the v8.1M FPCXT_S register, | 1 | Add support for the TCG GICv4 to the virt board. For the board, |
---|---|---|---|
2 | but we got the write behaviour wrong. On read, this register reads | 2 | the GICv4 is very similar to the GICv3, with the only difference |
3 | bits [27:0] of FPSCR plus the CONTROL.SFPA bit. On write, it doesn't | 3 | being the size of the redistributor frame. The changes here are thus: |
4 | just write back those bits -- it writes a value to the whole FPSCR, | 4 | * calculating virt_redist_capacity correctly for GICv4 |
5 | whose upper 4 bits are zeroes. | 5 | * changing various places which were "if GICv3" to be "if not GICv2" |
6 | * the commandline option handling | ||
6 | 7 | ||
7 | We also incorrectly implemented the write-to-FPSCR as a simple store | 8 | Note that using GICv4 reduces the maximum possible number of CPUs on |
8 | to vfp.xregs; this skips the "update the softfloat flags" part of | 9 | the virt board from 512 to 317, because we can now only fit half as |
9 | the vfp_set_fpscr helper so the value would read back correctly but | 10 | many redistributors into the redistributor regions we have defined. |
10 | not actually take effect. | ||
11 | |||
12 | Fix both of these things by doing a complete write to the FPSCR | ||
13 | using the helper function. | ||
14 | 11 | ||
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
16 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 13 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
17 | Message-id: 20201210201433.26262-3-peter.maydell@linaro.org | 14 | Message-id: 20220408141550.1271295-42-peter.maydell@linaro.org |
18 | --- | 15 | --- |
19 | target/arm/translate-vfp.c.inc | 12 ++++++------ | 16 | docs/system/arm/virt.rst | 5 ++- |
20 | 1 file changed, 6 insertions(+), 6 deletions(-) | 17 | include/hw/arm/virt.h | 12 +++++-- |
18 | hw/arm/virt.c | 70 ++++++++++++++++++++++++++++++---------- | ||
19 | 3 files changed, 67 insertions(+), 20 deletions(-) | ||
21 | 20 | ||
22 | diff --git a/target/arm/translate-vfp.c.inc b/target/arm/translate-vfp.c.inc | 21 | diff --git a/docs/system/arm/virt.rst b/docs/system/arm/virt.rst |
23 | index XXXXXXX..XXXXXXX 100644 | 22 | index XXXXXXX..XXXXXXX 100644 |
24 | --- a/target/arm/translate-vfp.c.inc | 23 | --- a/docs/system/arm/virt.rst |
25 | +++ b/target/arm/translate-vfp.c.inc | 24 | +++ b/docs/system/arm/virt.rst |
26 | @@ -XXX,XX +XXX,XX @@ static bool gen_M_fp_sysreg_write(DisasContext *s, int regno, | 25 | @@ -XXX,XX +XXX,XX @@ gic-version |
27 | } | 26 | GICv2. Note that this limits the number of CPUs to 8. |
28 | case ARM_VFP_FPCXT_S: | 27 | ``3`` |
29 | { | 28 | GICv3. This allows up to 512 CPUs. |
30 | - TCGv_i32 sfpa, control, fpscr; | 29 | + ``4`` |
31 | - /* Set FPSCR[27:0] and CONTROL.SFPA from value */ | 30 | + GICv4. Requires ``virtualization`` to be ``on``; allows up to 317 CPUs. |
32 | + TCGv_i32 sfpa, control; | 31 | ``host`` |
33 | + /* | 32 | Use the same GIC version the host provides, when using KVM |
34 | + * Set FPSCR and CONTROL.SFPA from value; the new FPSCR takes | 33 | ``max`` |
35 | + * bits [27:0] from value and zeroes bits [31:28]. | 34 | Use the best GIC version possible (same as host when using KVM; |
36 | + */ | 35 | - currently same as ``3``` for TCG, but this may change in future) |
37 | tmp = loadfn(s, opaque); | 36 | + with TCG this is currently ``3`` if ``virtualization`` is ``off`` and |
38 | sfpa = tcg_temp_new_i32(); | 37 | + ``4`` if ``virtualization`` is ``on``, but this may change in future) |
39 | tcg_gen_shri_i32(sfpa, tmp, 31); | 38 | |
40 | @@ -XXX,XX +XXX,XX @@ static bool gen_M_fp_sysreg_write(DisasContext *s, int regno, | 39 | its |
41 | tcg_gen_deposit_i32(control, control, sfpa, | 40 | Set ``on``/``off`` to enable/disable ITS instantiation. The default is ``on`` |
42 | R_V7M_CONTROL_SFPA_SHIFT, 1); | 41 | diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h |
43 | store_cpu_field(control, v7m.control[M_REG_S]); | 42 | index XXXXXXX..XXXXXXX 100644 |
44 | - fpscr = load_cpu_field(vfp.xregs[ARM_VFP_FPSCR]); | 43 | --- a/include/hw/arm/virt.h |
45 | - tcg_gen_andi_i32(fpscr, fpscr, FPCR_NZCV_MASK); | 44 | +++ b/include/hw/arm/virt.h |
46 | tcg_gen_andi_i32(tmp, tmp, ~FPCR_NZCV_MASK); | 45 | @@ -XXX,XX +XXX,XX @@ typedef enum VirtGICType { |
47 | - tcg_gen_or_i32(fpscr, fpscr, tmp); | 46 | VIRT_GIC_VERSION_HOST, |
48 | - store_cpu_field(fpscr, vfp.xregs[ARM_VFP_FPSCR]); | 47 | VIRT_GIC_VERSION_2, |
49 | + gen_helper_vfp_set_fpscr(cpu_env, tmp); | 48 | VIRT_GIC_VERSION_3, |
50 | tcg_temp_free_i32(tmp); | 49 | + VIRT_GIC_VERSION_4, |
51 | tcg_temp_free_i32(sfpa); | 50 | VIRT_GIC_VERSION_NOSEL, |
51 | } VirtGICType; | ||
52 | |||
53 | @@ -XXX,XX +XXX,XX @@ bool virt_is_acpi_enabled(VirtMachineState *vms); | ||
54 | /* Return number of redistributors that fit in the specified region */ | ||
55 | static uint32_t virt_redist_capacity(VirtMachineState *vms, int region) | ||
56 | { | ||
57 | - return vms->memmap[region].size / GICV3_REDIST_SIZE; | ||
58 | + uint32_t redist_size; | ||
59 | + | ||
60 | + if (vms->gic_version == VIRT_GIC_VERSION_3) { | ||
61 | + redist_size = GICV3_REDIST_SIZE; | ||
62 | + } else { | ||
63 | + redist_size = GICV4_REDIST_SIZE; | ||
64 | + } | ||
65 | + return vms->memmap[region].size / redist_size; | ||
66 | } | ||
67 | |||
68 | /* Return the number of used redistributor regions */ | ||
69 | @@ -XXX,XX +XXX,XX @@ static inline int virt_gicv3_redist_region_count(VirtMachineState *vms) | ||
70 | { | ||
71 | uint32_t redist0_capacity = virt_redist_capacity(vms, VIRT_GIC_REDIST); | ||
72 | |||
73 | - assert(vms->gic_version == VIRT_GIC_VERSION_3); | ||
74 | + assert(vms->gic_version != VIRT_GIC_VERSION_2); | ||
75 | |||
76 | return (MACHINE(vms)->smp.cpus > redist0_capacity && | ||
77 | vms->highmem_redists) ? 2 : 1; | ||
78 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c | ||
79 | index XXXXXXX..XXXXXXX 100644 | ||
80 | --- a/hw/arm/virt.c | ||
81 | +++ b/hw/arm/virt.c | ||
82 | @@ -XXX,XX +XXX,XX @@ static void fdt_add_gic_node(VirtMachineState *vms) | ||
83 | qemu_fdt_setprop_cell(ms->fdt, nodename, "#address-cells", 0x2); | ||
84 | qemu_fdt_setprop_cell(ms->fdt, nodename, "#size-cells", 0x2); | ||
85 | qemu_fdt_setprop(ms->fdt, nodename, "ranges", NULL, 0); | ||
86 | - if (vms->gic_version == VIRT_GIC_VERSION_3) { | ||
87 | + if (vms->gic_version != VIRT_GIC_VERSION_2) { | ||
88 | int nb_redist_regions = virt_gicv3_redist_region_count(vms); | ||
89 | |||
90 | qemu_fdt_setprop_string(ms->fdt, nodename, "compatible", | ||
91 | @@ -XXX,XX +XXX,XX @@ static void create_gic(VirtMachineState *vms, MemoryRegion *mem) | ||
92 | case VIRT_GIC_VERSION_3: | ||
93 | revision = 3; | ||
52 | break; | 94 | break; |
95 | + case VIRT_GIC_VERSION_4: | ||
96 | + revision = 4; | ||
97 | + break; | ||
98 | default: | ||
99 | g_assert_not_reached(); | ||
100 | } | ||
101 | @@ -XXX,XX +XXX,XX @@ static void create_gic(VirtMachineState *vms, MemoryRegion *mem) | ||
102 | qdev_prop_set_bit(vms->gic, "has-security-extensions", vms->secure); | ||
103 | } | ||
104 | |||
105 | - if (vms->gic_version == VIRT_GIC_VERSION_3) { | ||
106 | + if (vms->gic_version != VIRT_GIC_VERSION_2) { | ||
107 | uint32_t redist0_capacity = virt_redist_capacity(vms, VIRT_GIC_REDIST); | ||
108 | uint32_t redist0_count = MIN(smp_cpus, redist0_capacity); | ||
109 | |||
110 | @@ -XXX,XX +XXX,XX @@ static void create_gic(VirtMachineState *vms, MemoryRegion *mem) | ||
111 | gicbusdev = SYS_BUS_DEVICE(vms->gic); | ||
112 | sysbus_realize_and_unref(gicbusdev, &error_fatal); | ||
113 | sysbus_mmio_map(gicbusdev, 0, vms->memmap[VIRT_GIC_DIST].base); | ||
114 | - if (vms->gic_version == VIRT_GIC_VERSION_3) { | ||
115 | + if (vms->gic_version != VIRT_GIC_VERSION_2) { | ||
116 | sysbus_mmio_map(gicbusdev, 1, vms->memmap[VIRT_GIC_REDIST].base); | ||
117 | if (nb_redist_regions == 2) { | ||
118 | sysbus_mmio_map(gicbusdev, 2, | ||
119 | @@ -XXX,XX +XXX,XX @@ static void create_gic(VirtMachineState *vms, MemoryRegion *mem) | ||
120 | ppibase + timer_irq[irq])); | ||
121 | } | ||
122 | |||
123 | - if (vms->gic_version == VIRT_GIC_VERSION_3) { | ||
124 | + if (vms->gic_version != VIRT_GIC_VERSION_2) { | ||
125 | qemu_irq irq = qdev_get_gpio_in(vms->gic, | ||
126 | ppibase + ARCH_GIC_MAINT_IRQ); | ||
127 | qdev_connect_gpio_out_named(cpudev, "gicv3-maintenance-interrupt", | ||
128 | @@ -XXX,XX +XXX,XX @@ static void create_gic(VirtMachineState *vms, MemoryRegion *mem) | ||
129 | |||
130 | fdt_add_gic_node(vms); | ||
131 | |||
132 | - if (vms->gic_version == VIRT_GIC_VERSION_3 && vms->its) { | ||
133 | + if (vms->gic_version != VIRT_GIC_VERSION_2 && vms->its) { | ||
134 | create_its(vms); | ||
135 | } else if (vms->gic_version == VIRT_GIC_VERSION_2) { | ||
136 | create_v2m(vms); | ||
137 | @@ -XXX,XX +XXX,XX @@ static uint64_t virt_cpu_mp_affinity(VirtMachineState *vms, int idx) | ||
138 | * purposes are to make TCG consistent (with 64-bit KVM hosts) | ||
139 | * and to improve SGI efficiency. | ||
140 | */ | ||
141 | - if (vms->gic_version == VIRT_GIC_VERSION_3) { | ||
142 | - clustersz = GICV3_TARGETLIST_BITS; | ||
143 | - } else { | ||
144 | + if (vms->gic_version == VIRT_GIC_VERSION_2) { | ||
145 | clustersz = GIC_TARGETLIST_BITS; | ||
146 | + } else { | ||
147 | + clustersz = GICV3_TARGETLIST_BITS; | ||
148 | } | ||
149 | } | ||
150 | return arm_cpu_mp_affinity(idx, clustersz); | ||
151 | @@ -XXX,XX +XXX,XX @@ static void finalize_gic_version(VirtMachineState *vms) | ||
152 | error_report( | ||
153 | "gic-version=3 is not supported with kernel-irqchip=off"); | ||
154 | exit(1); | ||
155 | + case VIRT_GIC_VERSION_4: | ||
156 | + error_report( | ||
157 | + "gic-version=4 is not supported with kernel-irqchip=off"); | ||
158 | + exit(1); | ||
159 | } | ||
160 | } | ||
161 | |||
162 | @@ -XXX,XX +XXX,XX @@ static void finalize_gic_version(VirtMachineState *vms) | ||
163 | case VIRT_GIC_VERSION_2: | ||
164 | case VIRT_GIC_VERSION_3: | ||
165 | break; | ||
166 | + case VIRT_GIC_VERSION_4: | ||
167 | + error_report("gic-version=4 is not supported with KVM"); | ||
168 | + exit(1); | ||
169 | } | ||
170 | |||
171 | /* Check chosen version is effectively supported by the host */ | ||
172 | @@ -XXX,XX +XXX,XX @@ static void finalize_gic_version(VirtMachineState *vms) | ||
173 | case VIRT_GIC_VERSION_MAX: | ||
174 | if (module_object_class_by_name("arm-gicv3")) { | ||
175 | /* CONFIG_ARM_GICV3_TCG was set */ | ||
176 | - vms->gic_version = VIRT_GIC_VERSION_3; | ||
177 | + if (vms->virt) { | ||
178 | + /* GICv4 only makes sense if CPU has EL2 */ | ||
179 | + vms->gic_version = VIRT_GIC_VERSION_4; | ||
180 | + } else { | ||
181 | + vms->gic_version = VIRT_GIC_VERSION_3; | ||
182 | + } | ||
183 | } else { | ||
184 | vms->gic_version = VIRT_GIC_VERSION_2; | ||
185 | } | ||
186 | @@ -XXX,XX +XXX,XX @@ static void finalize_gic_version(VirtMachineState *vms) | ||
187 | case VIRT_GIC_VERSION_HOST: | ||
188 | error_report("gic-version=host requires KVM"); | ||
189 | exit(1); | ||
190 | + case VIRT_GIC_VERSION_4: | ||
191 | + if (!vms->virt) { | ||
192 | + error_report("gic-version=4 requires virtualization enabled"); | ||
193 | + exit(1); | ||
194 | + } | ||
195 | + break; | ||
196 | case VIRT_GIC_VERSION_2: | ||
197 | case VIRT_GIC_VERSION_3: | ||
198 | break; | ||
199 | @@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine) | ||
200 | vms->psci_conduit = QEMU_PSCI_CONDUIT_HVC; | ||
201 | } | ||
202 | |||
203 | - /* The maximum number of CPUs depends on the GIC version, or on how | ||
204 | - * many redistributors we can fit into the memory map. | ||
205 | + /* | ||
206 | + * The maximum number of CPUs depends on the GIC version, or on how | ||
207 | + * many redistributors we can fit into the memory map (which in turn | ||
208 | + * depends on whether this is a GICv3 or v4). | ||
209 | */ | ||
210 | - if (vms->gic_version == VIRT_GIC_VERSION_3) { | ||
211 | + if (vms->gic_version == VIRT_GIC_VERSION_2) { | ||
212 | + virt_max_cpus = GIC_NCPU; | ||
213 | + } else { | ||
214 | virt_max_cpus = virt_redist_capacity(vms, VIRT_GIC_REDIST) + | ||
215 | virt_redist_capacity(vms, VIRT_HIGH_GIC_REDIST2); | ||
216 | - } else { | ||
217 | - virt_max_cpus = GIC_NCPU; | ||
218 | } | ||
219 | |||
220 | if (max_cpus > virt_max_cpus) { | ||
221 | @@ -XXX,XX +XXX,XX @@ static void virt_set_mte(Object *obj, bool value, Error **errp) | ||
222 | static char *virt_get_gic_version(Object *obj, Error **errp) | ||
223 | { | ||
224 | VirtMachineState *vms = VIRT_MACHINE(obj); | ||
225 | - const char *val = vms->gic_version == VIRT_GIC_VERSION_3 ? "3" : "2"; | ||
226 | + const char *val; | ||
227 | |||
228 | + switch (vms->gic_version) { | ||
229 | + case VIRT_GIC_VERSION_4: | ||
230 | + val = "4"; | ||
231 | + break; | ||
232 | + case VIRT_GIC_VERSION_3: | ||
233 | + val = "3"; | ||
234 | + break; | ||
235 | + default: | ||
236 | + val = "2"; | ||
237 | + break; | ||
238 | + } | ||
239 | return g_strdup(val); | ||
240 | } | ||
241 | |||
242 | @@ -XXX,XX +XXX,XX @@ static void virt_set_gic_version(Object *obj, const char *value, Error **errp) | ||
243 | { | ||
244 | VirtMachineState *vms = VIRT_MACHINE(obj); | ||
245 | |||
246 | - if (!strcmp(value, "3")) { | ||
247 | + if (!strcmp(value, "4")) { | ||
248 | + vms->gic_version = VIRT_GIC_VERSION_4; | ||
249 | + } else if (!strcmp(value, "3")) { | ||
250 | vms->gic_version = VIRT_GIC_VERSION_3; | ||
251 | } else if (!strcmp(value, "2")) { | ||
252 | vms->gic_version = VIRT_GIC_VERSION_2; | ||
253 | @@ -XXX,XX +XXX,XX @@ static void virt_machine_class_init(ObjectClass *oc, void *data) | ||
254 | virt_set_gic_version); | ||
255 | object_class_property_set_description(oc, "gic-version", | ||
256 | "Set GIC version. " | ||
257 | - "Valid values are 2, 3, host and max"); | ||
258 | + "Valid values are 2, 3, 4, host and max"); | ||
259 | |||
260 | object_class_property_add_str(oc, "iommu", virt_get_iommu, virt_set_iommu); | ||
261 | object_class_property_set_description(oc, "iommu", | ||
53 | -- | 262 | -- |
54 | 2.20.1 | 263 | 2.25.1 |
55 | |||
56 | diff view generated by jsdifflib |
1 | From: Bin Meng <bin.meng@windriver.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | At present, when booting U-Boot on QEMU sabrelite, we see: | 3 | Update isar fields per ARM DDI0487 H.a. |
4 | 4 | ||
5 | Net: Board Net Initialization Failed | 5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
6 | No ethernet found. | 6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
7 | |||
8 | U-Boot scans PHY at address 4/5/6/7 (see board_eth_init() in the | ||
9 | U-Boot source: board/boundary/nitrogen6x/nitrogen6x.c). On the real | ||
10 | board, the Ethernet PHY is at address 6. Adjust this by updating the | ||
11 | "fec-phy-num" property of the fsl_imx6 SoC object. | ||
12 | |||
13 | With this change, U-Boot sees the PHY but complains MAC address: | ||
14 | |||
15 | Net: using phy at 6 | ||
16 | FEC [PRIME] | ||
17 | Error: FEC address not set. | ||
18 | |||
19 | This is due to U-Boot tries to read the MAC address from the fuse, | ||
20 | which QEMU does not have any valid content filled in. However this | ||
21 | does not prevent the Ethernet from working in QEMU. We just need to | ||
22 | set up the MAC address later in the U-Boot command shell, by: | ||
23 | |||
24 | => setenv ethaddr 00:11:22:33:44:55 | ||
25 | |||
26 | Signed-off-by: Bin Meng <bin.meng@windriver.com> | ||
27 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | 7 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> |
28 | Message-id: 20210106063504.10841-4-bmeng.cn@gmail.com | ||
29 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
30 | --- | 9 | --- |
31 | hw/arm/sabrelite.c | 4 ++++ | 10 | target/arm/cpu.h | 24 ++++++++++++++++++++++++ |
32 | 1 file changed, 4 insertions(+) | 11 | 1 file changed, 24 insertions(+) |
33 | 12 | ||
34 | diff --git a/hw/arm/sabrelite.c b/hw/arm/sabrelite.c | 13 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
35 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
36 | --- a/hw/arm/sabrelite.c | 15 | --- a/target/arm/cpu.h |
37 | +++ b/hw/arm/sabrelite.c | 16 | +++ b/target/arm/cpu.h |
38 | @@ -XXX,XX +XXX,XX @@ static void sabrelite_init(MachineState *machine) | 17 | @@ -XXX,XX +XXX,XX @@ FIELD(ID_MMFR4, CCIDX, 24, 4) |
39 | 18 | FIELD(ID_MMFR4, EVT, 28, 4) | |
40 | s = FSL_IMX6(object_new(TYPE_FSL_IMX6)); | 19 | |
41 | object_property_add_child(OBJECT(machine), "soc", OBJECT(s)); | 20 | FIELD(ID_MMFR5, ETS, 0, 4) |
21 | +FIELD(ID_MMFR5, NTLBPA, 4, 4) | ||
22 | |||
23 | FIELD(ID_PFR0, STATE0, 0, 4) | ||
24 | FIELD(ID_PFR0, STATE1, 4, 4) | ||
25 | @@ -XXX,XX +XXX,XX @@ FIELD(ID_AA64ISAR1, SPECRES, 40, 4) | ||
26 | FIELD(ID_AA64ISAR1, BF16, 44, 4) | ||
27 | FIELD(ID_AA64ISAR1, DGH, 48, 4) | ||
28 | FIELD(ID_AA64ISAR1, I8MM, 52, 4) | ||
29 | +FIELD(ID_AA64ISAR1, XS, 56, 4) | ||
30 | +FIELD(ID_AA64ISAR1, LS64, 60, 4) | ||
42 | + | 31 | + |
43 | + /* Ethernet PHY address is 6 */ | 32 | +FIELD(ID_AA64ISAR2, WFXT, 0, 4) |
44 | + object_property_set_int(OBJECT(s), "fec-phy-num", 6, &error_fatal); | 33 | +FIELD(ID_AA64ISAR2, RPRES, 4, 4) |
45 | + | 34 | +FIELD(ID_AA64ISAR2, GPA3, 8, 4) |
46 | qdev_realize(DEVICE(s), NULL, &error_fatal); | 35 | +FIELD(ID_AA64ISAR2, APA3, 12, 4) |
47 | 36 | +FIELD(ID_AA64ISAR2, MOPS, 16, 4) | |
48 | memory_region_add_subregion(get_system_memory(), FSL_IMX6_MMDC_ADDR, | 37 | +FIELD(ID_AA64ISAR2, BC, 20, 4) |
38 | +FIELD(ID_AA64ISAR2, PAC_FRAC, 24, 4) | ||
39 | |||
40 | FIELD(ID_AA64PFR0, EL0, 0, 4) | ||
41 | FIELD(ID_AA64PFR0, EL1, 4, 4) | ||
42 | @@ -XXX,XX +XXX,XX @@ FIELD(ID_AA64PFR1, SSBS, 4, 4) | ||
43 | FIELD(ID_AA64PFR1, MTE, 8, 4) | ||
44 | FIELD(ID_AA64PFR1, RAS_FRAC, 12, 4) | ||
45 | FIELD(ID_AA64PFR1, MPAM_FRAC, 16, 4) | ||
46 | +FIELD(ID_AA64PFR1, SME, 24, 4) | ||
47 | +FIELD(ID_AA64PFR1, RNDR_TRAP, 28, 4) | ||
48 | +FIELD(ID_AA64PFR1, CSV2_FRAC, 32, 4) | ||
49 | +FIELD(ID_AA64PFR1, NMI, 36, 4) | ||
50 | |||
51 | FIELD(ID_AA64MMFR0, PARANGE, 0, 4) | ||
52 | FIELD(ID_AA64MMFR0, ASIDBITS, 4, 4) | ||
53 | @@ -XXX,XX +XXX,XX @@ FIELD(ID_AA64MMFR1, SPECSEI, 24, 4) | ||
54 | FIELD(ID_AA64MMFR1, XNX, 28, 4) | ||
55 | FIELD(ID_AA64MMFR1, TWED, 32, 4) | ||
56 | FIELD(ID_AA64MMFR1, ETS, 36, 4) | ||
57 | +FIELD(ID_AA64MMFR1, HCX, 40, 4) | ||
58 | +FIELD(ID_AA64MMFR1, AFP, 44, 4) | ||
59 | +FIELD(ID_AA64MMFR1, NTLBPA, 48, 4) | ||
60 | +FIELD(ID_AA64MMFR1, TIDCP1, 52, 4) | ||
61 | +FIELD(ID_AA64MMFR1, CMOW, 56, 4) | ||
62 | |||
63 | FIELD(ID_AA64MMFR2, CNP, 0, 4) | ||
64 | FIELD(ID_AA64MMFR2, UAO, 4, 4) | ||
65 | @@ -XXX,XX +XXX,XX @@ FIELD(ID_AA64DFR0, CTX_CMPS, 28, 4) | ||
66 | FIELD(ID_AA64DFR0, PMSVER, 32, 4) | ||
67 | FIELD(ID_AA64DFR0, DOUBLELOCK, 36, 4) | ||
68 | FIELD(ID_AA64DFR0, TRACEFILT, 40, 4) | ||
69 | +FIELD(ID_AA64DFR0, TRACEBUFFER, 44, 4) | ||
70 | FIELD(ID_AA64DFR0, MTPMU, 48, 4) | ||
71 | +FIELD(ID_AA64DFR0, BRBE, 52, 4) | ||
72 | +FIELD(ID_AA64DFR0, HPMN0, 60, 4) | ||
73 | |||
74 | FIELD(ID_AA64ZFR0, SVEVER, 0, 4) | ||
75 | FIELD(ID_AA64ZFR0, AES, 4, 4) | ||
76 | @@ -XXX,XX +XXX,XX @@ FIELD(ID_DFR0, PERFMON, 24, 4) | ||
77 | FIELD(ID_DFR0, TRACEFILT, 28, 4) | ||
78 | |||
79 | FIELD(ID_DFR1, MTPMU, 0, 4) | ||
80 | +FIELD(ID_DFR1, HPMN0, 4, 4) | ||
81 | |||
82 | FIELD(DBGDIDR, SE_IMP, 12, 1) | ||
83 | FIELD(DBGDIDR, NSUHD_IMP, 14, 1) | ||
49 | -- | 84 | -- |
50 | 2.20.1 | 85 | 2.25.1 |
51 | 86 | ||
52 | 87 | diff view generated by jsdifflib |
1 | From: Bin Meng <bin.meng@windriver.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | This adds the target guide for SABRE Lite board, and documents how | 3 | Update SCR_EL3 fields per ARM DDI0487 H.a. |
4 | to boot a Linux kernel and U-Boot bootloader. | ||
5 | 4 | ||
6 | Signed-off-by: Bin Meng <bin.meng@windriver.com> | 5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
7 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | 6 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> |
8 | Message-id: 20210106063504.10841-5-bmeng.cn@gmail.com | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 8 | --- |
11 | docs/system/arm/sabrelite.rst | 119 ++++++++++++++++++++++++++++++++++ | 9 | target/arm/cpu.h | 12 ++++++++++++ |
12 | docs/system/target-arm.rst | 1 + | 10 | 1 file changed, 12 insertions(+) |
13 | 2 files changed, 120 insertions(+) | ||
14 | create mode 100644 docs/system/arm/sabrelite.rst | ||
15 | 11 | ||
16 | diff --git a/docs/system/arm/sabrelite.rst b/docs/system/arm/sabrelite.rst | 12 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
17 | new file mode 100644 | ||
18 | index XXXXXXX..XXXXXXX | ||
19 | --- /dev/null | ||
20 | +++ b/docs/system/arm/sabrelite.rst | ||
21 | @@ -XXX,XX +XXX,XX @@ | ||
22 | +Boundary Devices SABRE Lite (``sabrelite``) | ||
23 | +=========================================== | ||
24 | + | ||
25 | +Boundary Devices SABRE Lite i.MX6 Development Board is a low-cost development | ||
26 | +platform featuring the powerful Freescale / NXP Semiconductor's i.MX 6 Quad | ||
27 | +Applications Processor. | ||
28 | + | ||
29 | +Supported devices | ||
30 | +----------------- | ||
31 | + | ||
32 | +The SABRE Lite machine supports the following devices: | ||
33 | + | ||
34 | + * Up to 4 Cortex A9 cores | ||
35 | + * Generic Interrupt Controller | ||
36 | + * 1 Clock Controller Module | ||
37 | + * 1 System Reset Controller | ||
38 | + * 5 UARTs | ||
39 | + * 2 EPIC timers | ||
40 | + * 1 GPT timer | ||
41 | + * 2 Watchdog timers | ||
42 | + * 1 FEC Ethernet controller | ||
43 | + * 3 I2C controllers | ||
44 | + * 7 GPIO controllers | ||
45 | + * 4 SDHC storage controllers | ||
46 | + * 4 USB 2.0 host controllers | ||
47 | + * 5 ECSPI controllers | ||
48 | + * 1 SST 25VF016B flash | ||
49 | + | ||
50 | +Please note above list is a complete superset the QEMU SABRE Lite machine can | ||
51 | +support. For a normal use case, a device tree blob that represents a real world | ||
52 | +SABRE Lite board, only exposes a subset of devices to the guest software. | ||
53 | + | ||
54 | +Boot options | ||
55 | +------------ | ||
56 | + | ||
57 | +The SABRE Lite machine can start using the standard -kernel functionality | ||
58 | +for loading a Linux kernel, U-Boot bootloader or ELF executable. | ||
59 | + | ||
60 | +Running Linux kernel | ||
61 | +-------------------- | ||
62 | + | ||
63 | +Linux mainline v5.10 release is tested at the time of writing. To build a Linux | ||
64 | +mainline kernel that can be booted by the SABRE Lite machine, simply configure | ||
65 | +the kernel using the imx_v6_v7_defconfig configuration: | ||
66 | + | ||
67 | +.. code-block:: bash | ||
68 | + | ||
69 | + $ export ARCH=arm | ||
70 | + $ export CROSS_COMPILE=arm-linux-gnueabihf- | ||
71 | + $ make imx_v6_v7_defconfig | ||
72 | + $ make | ||
73 | + | ||
74 | +To boot the newly built Linux kernel in QEMU with the SABRE Lite machine, use: | ||
75 | + | ||
76 | +.. code-block:: bash | ||
77 | + | ||
78 | + $ qemu-system-arm -M sabrelite -smp 4 -m 1G \ | ||
79 | + -display none -serial null -serial stdio \ | ||
80 | + -kernel arch/arm/boot/zImage \ | ||
81 | + -dtb arch/arm/boot/dts/imx6q-sabrelite.dtb \ | ||
82 | + -initrd /path/to/rootfs.ext4 \ | ||
83 | + -append "root=/dev/ram" | ||
84 | + | ||
85 | +Running U-Boot | ||
86 | +-------------- | ||
87 | + | ||
88 | +U-Boot mainline v2020.10 release is tested at the time of writing. To build a | ||
89 | +U-Boot mainline bootloader that can be booted by the SABRE Lite machine, use | ||
90 | +the mx6qsabrelite_defconfig with similar commands as described above for Linux: | ||
91 | + | ||
92 | +.. code-block:: bash | ||
93 | + | ||
94 | + $ export CROSS_COMPILE=arm-linux-gnueabihf- | ||
95 | + $ make mx6qsabrelite_defconfig | ||
96 | + | ||
97 | +Note we need to adjust settings by: | ||
98 | + | ||
99 | +.. code-block:: bash | ||
100 | + | ||
101 | + $ make menuconfig | ||
102 | + | ||
103 | +then manually select the following configuration in U-Boot: | ||
104 | + | ||
105 | + Device Tree Control > Provider of DTB for DT Control > Embedded DTB | ||
106 | + | ||
107 | +To start U-Boot using the SABRE Lite machine, provide the u-boot binary to | ||
108 | +the -kernel argument, along with an SD card image with rootfs: | ||
109 | + | ||
110 | +.. code-block:: bash | ||
111 | + | ||
112 | + $ qemu-system-arm -M sabrelite -smp 4 -m 1G \ | ||
113 | + -display none -serial null -serial stdio \ | ||
114 | + -kernel u-boot | ||
115 | + | ||
116 | +The following example shows booting Linux kernel from dhcp, and uses the | ||
117 | +rootfs on an SD card. This requires some additional command line parameters | ||
118 | +for QEMU: | ||
119 | + | ||
120 | +.. code-block:: none | ||
121 | + | ||
122 | + -nic user,tftp=/path/to/kernel/zImage \ | ||
123 | + -drive file=sdcard.img,id=rootfs -device sd-card,drive=rootfs | ||
124 | + | ||
125 | +The directory for the built-in TFTP server should also contain the device tree | ||
126 | +blob of the SABRE Lite board. The sample SD card image was populated with the | ||
127 | +root file system with one single partition. You may adjust the kernel "root=" | ||
128 | +boot parameter accordingly. | ||
129 | + | ||
130 | +After U-Boot boots, type the following commands in the U-Boot command shell to | ||
131 | +boot the Linux kernel: | ||
132 | + | ||
133 | +.. code-block:: none | ||
134 | + | ||
135 | + => setenv ethaddr 00:11:22:33:44:55 | ||
136 | + => setenv bootfile zImage | ||
137 | + => dhcp | ||
138 | + => tftpboot 14000000 imx6q-sabrelite.dtb | ||
139 | + => setenv bootargs root=/dev/mmcblk3p1 | ||
140 | + => bootz 12000000 - 14000000 | ||
141 | diff --git a/docs/system/target-arm.rst b/docs/system/target-arm.rst | ||
142 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
143 | --- a/docs/system/target-arm.rst | 14 | --- a/target/arm/cpu.h |
144 | +++ b/docs/system/target-arm.rst | 15 | +++ b/target/arm/cpu.h |
145 | @@ -XXX,XX +XXX,XX @@ undocumented; you can get a complete list by running | 16 | @@ -XXX,XX +XXX,XX @@ static inline void xpsr_write(CPUARMState *env, uint32_t val, uint32_t mask) |
146 | arm/versatile | 17 | #define SCR_FIEN (1U << 21) |
147 | arm/vexpress | 18 | #define SCR_ENSCXT (1U << 25) |
148 | arm/aspeed | 19 | #define SCR_ATA (1U << 26) |
149 | + arm/sabrelite | 20 | +#define SCR_FGTEN (1U << 27) |
150 | arm/digic | 21 | +#define SCR_ECVEN (1U << 28) |
151 | arm/musicpal | 22 | +#define SCR_TWEDEN (1U << 29) |
152 | arm/gumstix | 23 | +#define SCR_TWEDEL MAKE_64BIT_MASK(30, 4) |
24 | +#define SCR_TME (1ULL << 34) | ||
25 | +#define SCR_AMVOFFEN (1ULL << 35) | ||
26 | +#define SCR_ENAS0 (1ULL << 36) | ||
27 | +#define SCR_ADEN (1ULL << 37) | ||
28 | +#define SCR_HXEN (1ULL << 38) | ||
29 | +#define SCR_TRNDR (1ULL << 40) | ||
30 | +#define SCR_ENTP2 (1ULL << 41) | ||
31 | +#define SCR_GPF (1ULL << 48) | ||
32 | |||
33 | #define HSTR_TTEE (1 << 16) | ||
34 | #define HSTR_TJDBX (1 << 17) | ||
153 | -- | 35 | -- |
154 | 2.20.1 | 36 | 2.25.1 |
155 | 37 | ||
156 | 38 | diff view generated by jsdifflib |
1 | From: Gan Qixin <ganqixin@huawei.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | When running device-introspect-test, a memory leak occurred in the | 3 | Update SCTLR_ELx fields per ARM DDI0487 H.a. |
4 | exynos4210_mct_init function, so use ptimer_free() in the finalize function to | ||
5 | avoid it. | ||
6 | 4 | ||
7 | ASAN shows memory leak stack: | 5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
8 | 6 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | |
9 | Indirect leak of 96 byte(s) in 1 object(s) allocated from: | ||
10 | #0 0xffffab97e1f0 in __interceptor_calloc (/lib64/libasan.so.5+0xee1f0) | ||
11 | #1 0xffffab256800 in g_malloc0 (/lib64/libglib-2.0.so.0+0x56800) | ||
12 | #2 0xaaabf555db78 in ptimer_init /qemu/hw/core/ptimer.c:432 | ||
13 | #3 0xaaabf56b01a0 in exynos4210_mct_init /qemu/hw/timer/exynos4210_mct.c:1505 | ||
14 | #4 0xaaabf6339f6c in object_initialize_with_type /qemu/qom/object.c:515 | ||
15 | #5 0xaaabf633a1e0 in object_new_with_type /qemu/qom/object.c:729 | ||
16 | #6 0xaaabf6375e40 in qmp_device_list_properties /qemu/qom/qom-qmp-cmds.c:153 | ||
17 | #7 0xaaabf653d8ec in qmp_marshal_device_list_properties /qemu/qapi/qapi-commands-qdev.c:59 | ||
18 | #8 0xaaabf6587d08 in do_qmp_dispatch_bh /qemu/qapi/qmp-dispatch.c:110 | ||
19 | #9 0xaaabf6552708 in aio_bh_call /qemu/util/async.c:136 | ||
20 | #10 0xaaabf6552708 in aio_bh_poll /qemu/util/async.c:164 | ||
21 | #11 0xaaabf655f19c in aio_dispatch /qemu/util/aio-posix.c:381 | ||
22 | #12 0xaaabf65523f4 in aio_ctx_dispatch /qemu/util/async.c:306 | ||
23 | |||
24 | Reported-by: Euler Robot <euler.robot@huawei.com> | ||
25 | Signed-off-by: Gan Qixin <ganqixin@huawei.com> | ||
26 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
27 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
28 | --- | 8 | --- |
29 | hw/timer/exynos4210_mct.c | 14 ++++++++++++++ | 9 | target/arm/cpu.h | 14 ++++++++++++++ |
30 | 1 file changed, 14 insertions(+) | 10 | 1 file changed, 14 insertions(+) |
31 | 11 | ||
32 | diff --git a/hw/timer/exynos4210_mct.c b/hw/timer/exynos4210_mct.c | 12 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
33 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
34 | --- a/hw/timer/exynos4210_mct.c | 14 | --- a/target/arm/cpu.h |
35 | +++ b/hw/timer/exynos4210_mct.c | 15 | +++ b/target/arm/cpu.h |
36 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_mct_init(Object *obj) | 16 | @@ -XXX,XX +XXX,XX @@ void pmu_init(ARMCPU *cpu); |
37 | sysbus_init_mmio(dev, &s->iomem); | 17 | #define SCTLR_ATA0 (1ULL << 42) /* v8.5-MemTag */ |
38 | } | 18 | #define SCTLR_ATA (1ULL << 43) /* v8.5-MemTag */ |
39 | 19 | #define SCTLR_DSSBS_64 (1ULL << 44) /* v8.5, AArch64 only */ | |
40 | +static void exynos4210_mct_finalize(Object *obj) | 20 | +#define SCTLR_TWEDEn (1ULL << 45) /* FEAT_TWED */ |
41 | +{ | 21 | +#define SCTLR_TWEDEL MAKE_64_MASK(46, 4) /* FEAT_TWED */ |
42 | + int i; | 22 | +#define SCTLR_TMT0 (1ULL << 50) /* FEAT_TME */ |
43 | + Exynos4210MCTState *s = EXYNOS4210_MCT(obj); | 23 | +#define SCTLR_TMT (1ULL << 51) /* FEAT_TME */ |
44 | + | 24 | +#define SCTLR_TME0 (1ULL << 52) /* FEAT_TME */ |
45 | + ptimer_free(s->g_timer.ptimer_frc); | 25 | +#define SCTLR_TME (1ULL << 53) /* FEAT_TME */ |
46 | + | 26 | +#define SCTLR_EnASR (1ULL << 54) /* FEAT_LS64_V */ |
47 | + for (i = 0; i < 2; i++) { | 27 | +#define SCTLR_EnAS0 (1ULL << 55) /* FEAT_LS64_ACCDATA */ |
48 | + ptimer_free(s->l_timer[i].tick_timer.ptimer_tick); | 28 | +#define SCTLR_EnALS (1ULL << 56) /* FEAT_LS64 */ |
49 | + ptimer_free(s->l_timer[i].ptimer_frc); | 29 | +#define SCTLR_EPAN (1ULL << 57) /* FEAT_PAN3 */ |
50 | + } | 30 | +#define SCTLR_EnTP2 (1ULL << 60) /* FEAT_SME */ |
51 | +} | 31 | +#define SCTLR_NMI (1ULL << 61) /* FEAT_NMI */ |
52 | + | 32 | +#define SCTLR_SPINTMASK (1ULL << 62) /* FEAT_NMI */ |
53 | static void exynos4210_mct_class_init(ObjectClass *klass, void *data) | 33 | +#define SCTLR_TIDCP (1ULL << 63) /* FEAT_TIDCP1 */ |
54 | { | 34 | |
55 | DeviceClass *dc = DEVICE_CLASS(klass); | 35 | #define CPTR_TCPAC (1U << 31) |
56 | @@ -XXX,XX +XXX,XX @@ static const TypeInfo exynos4210_mct_info = { | 36 | #define CPTR_TTA (1U << 20) |
57 | .parent = TYPE_SYS_BUS_DEVICE, | ||
58 | .instance_size = sizeof(Exynos4210MCTState), | ||
59 | .instance_init = exynos4210_mct_init, | ||
60 | + .instance_finalize = exynos4210_mct_finalize, | ||
61 | .class_init = exynos4210_mct_class_init, | ||
62 | }; | ||
63 | |||
64 | -- | 37 | -- |
65 | 2.20.1 | 38 | 2.25.1 |
66 | 39 | ||
67 | 40 | diff view generated by jsdifflib |
1 | From: Bin Meng <bin.meng@windriver.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Currently when U-Boot boots, it prints "??" for i.MX processor: | 3 | Bool is a more appropriate type for this value. |
4 | Move the member down in the struct to keep the | ||
5 | bool type members together and remove a hole. | ||
4 | 6 | ||
5 | CPU: Freescale i.MX?? rev1.0 at 792 MHz | 7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
6 | |||
7 | The register that was used to determine the silicon type is | ||
8 | undocumented in the latest IMX6DQRM (Rev. 6, 05/2020), but we | ||
9 | can refer to get_cpu_rev() in arch/arm/mach-imx/mx6/soc.c in | ||
10 | the U-Boot source codes that USB_ANALOG_DIGPROG is used. | ||
11 | |||
12 | Update its reset value to indicate i.MX6Q. | ||
13 | |||
14 | Signed-off-by: Bin Meng <bin.meng@windriver.com> | ||
15 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | 8 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> |
16 | Message-id: 20210106063504.10841-3-bmeng.cn@gmail.com | ||
17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
18 | --- | 10 | --- |
19 | hw/misc/imx6_ccm.c | 2 +- | 11 | target/arm/translate.h | 2 +- |
20 | 1 file changed, 1 insertion(+), 1 deletion(-) | 12 | target/arm/translate-a64.c | 2 +- |
13 | target/arm/translate.c | 2 +- | ||
14 | 3 files changed, 3 insertions(+), 3 deletions(-) | ||
21 | 15 | ||
22 | diff --git a/hw/misc/imx6_ccm.c b/hw/misc/imx6_ccm.c | 16 | diff --git a/target/arm/translate.h b/target/arm/translate.h |
23 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
24 | --- a/hw/misc/imx6_ccm.c | 18 | --- a/target/arm/translate.h |
25 | +++ b/hw/misc/imx6_ccm.c | 19 | +++ b/target/arm/translate.h |
26 | @@ -XXX,XX +XXX,XX @@ static void imx6_ccm_reset(DeviceState *dev) | 20 | @@ -XXX,XX +XXX,XX @@ typedef struct DisasContext { |
27 | s->analog[USB_ANALOG_USB2_VBUS_DETECT] = 0x00000004; | 21 | * so that top level loop can generate correct syndrome information. |
28 | s->analog[USB_ANALOG_USB2_CHRG_DETECT] = 0x00000000; | 22 | */ |
29 | s->analog[USB_ANALOG_USB2_MISC] = 0x00000002; | 23 | uint32_t svc_imm; |
30 | - s->analog[USB_ANALOG_DIGPROG] = 0x00000000; | 24 | - int aarch64; |
31 | + s->analog[USB_ANALOG_DIGPROG] = 0x00630000; | 25 | int current_el; |
32 | 26 | /* Debug target exception level for single-step exceptions */ | |
33 | /* all PLLs need to be locked */ | 27 | int debug_target_el; |
34 | s->analog[CCM_ANALOG_PLL_ARM] |= CCM_ANALOG_PLL_LOCK; | 28 | GHashTable *cp_regs; |
29 | uint64_t features; /* CPU features bits */ | ||
30 | + bool aarch64; | ||
31 | /* Because unallocated encodings generate different exception syndrome | ||
32 | * information from traps due to FP being disabled, we can't do a single | ||
33 | * "is fp access disabled" check at a high level in the decode tree. | ||
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 aarch64_tr_init_disas_context(DisasContextBase *dcbase, | ||
39 | dc->isar = &arm_cpu->isar; | ||
40 | dc->condjmp = 0; | ||
41 | |||
42 | - dc->aarch64 = 1; | ||
43 | + dc->aarch64 = true; | ||
44 | /* If we are coming from secure EL0 in a system with a 32-bit EL3, then | ||
45 | * there is no secure EL1, so we route exceptions to EL3. | ||
46 | */ | ||
47 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
48 | index XXXXXXX..XXXXXXX 100644 | ||
49 | --- a/target/arm/translate.c | ||
50 | +++ b/target/arm/translate.c | ||
51 | @@ -XXX,XX +XXX,XX @@ static void arm_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) | ||
52 | dc->isar = &cpu->isar; | ||
53 | dc->condjmp = 0; | ||
54 | |||
55 | - dc->aarch64 = 0; | ||
56 | + dc->aarch64 = false; | ||
57 | /* If we are coming from secure EL0 in a system with a 32-bit EL3, then | ||
58 | * there is no secure EL1, so we route exceptions to EL3. | ||
59 | */ | ||
35 | -- | 60 | -- |
36 | 2.20.1 | 61 | 2.25.1 |
37 | 62 | ||
38 | 63 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | In 50244cc76abc we updated mte_check_fail to match the ARM | 3 | Bool is a more appropriate type for this value. |
4 | pseudocode, using the correct EL to select the TCF field. | 4 | Adjust the assignments to use true/false. |
5 | But we failed to update MTE0_ACTIVE the same way, which led | ||
6 | to g_assert_not_reached(). | ||
7 | 5 | ||
8 | Cc: qemu-stable@nongnu.org | ||
9 | Buglink: https://bugs.launchpad.net/bugs/1907137 | ||
10 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
11 | Message-id: 20201221204426.88514-1-richard.henderson@linaro.org | 7 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> |
12 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | --- | 9 | --- |
15 | target/arm/helper.c | 2 +- | 10 | target/arm/cpu.h | 2 +- |
16 | 1 file changed, 1 insertion(+), 1 deletion(-) | 11 | target/arm/cpu.c | 2 +- |
12 | target/arm/helper-a64.c | 4 ++-- | ||
13 | target/arm/helper.c | 2 +- | ||
14 | target/arm/hvf/hvf.c | 2 +- | ||
15 | 5 files changed, 6 insertions(+), 6 deletions(-) | ||
17 | 16 | ||
17 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/target/arm/cpu.h | ||
20 | +++ b/target/arm/cpu.h | ||
21 | @@ -XXX,XX +XXX,XX @@ typedef struct CPUArchState { | ||
22 | * all other bits are stored in their correct places in env->pstate | ||
23 | */ | ||
24 | uint32_t pstate; | ||
25 | - uint32_t aarch64; /* 1 if CPU is in aarch64 state; inverse of PSTATE.nRW */ | ||
26 | + bool aarch64; /* True if CPU is in aarch64 state; inverse of PSTATE.nRW */ | ||
27 | |||
28 | /* Cached TBFLAGS state. See below for which bits are included. */ | ||
29 | CPUARMTBFlags hflags; | ||
30 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | ||
31 | index XXXXXXX..XXXXXXX 100644 | ||
32 | --- a/target/arm/cpu.c | ||
33 | +++ b/target/arm/cpu.c | ||
34 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_reset(DeviceState *dev) | ||
35 | |||
36 | if (arm_feature(env, ARM_FEATURE_AARCH64)) { | ||
37 | /* 64 bit CPUs always start in 64 bit mode */ | ||
38 | - env->aarch64 = 1; | ||
39 | + env->aarch64 = true; | ||
40 | #if defined(CONFIG_USER_ONLY) | ||
41 | env->pstate = PSTATE_MODE_EL0t; | ||
42 | /* Userspace expects access to DC ZVA, CTL_EL0 and the cache ops */ | ||
43 | diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c | ||
44 | index XXXXXXX..XXXXXXX 100644 | ||
45 | --- a/target/arm/helper-a64.c | ||
46 | +++ b/target/arm/helper-a64.c | ||
47 | @@ -XXX,XX +XXX,XX @@ void HELPER(exception_return)(CPUARMState *env, uint64_t new_pc) | ||
48 | qemu_mutex_unlock_iothread(); | ||
49 | |||
50 | if (!return_to_aa64) { | ||
51 | - env->aarch64 = 0; | ||
52 | + env->aarch64 = false; | ||
53 | /* We do a raw CPSR write because aarch64_sync_64_to_32() | ||
54 | * will sort the register banks out for us, and we've already | ||
55 | * caught all the bad-mode cases in el_from_spsr(). | ||
56 | @@ -XXX,XX +XXX,XX @@ void HELPER(exception_return)(CPUARMState *env, uint64_t new_pc) | ||
57 | } else { | ||
58 | int tbii; | ||
59 | |||
60 | - env->aarch64 = 1; | ||
61 | + env->aarch64 = true; | ||
62 | spsr &= aarch64_pstate_valid_mask(&env_archcpu(env)->isar); | ||
63 | pstate_write(env, spsr); | ||
64 | if (!arm_singlestep_active(env)) { | ||
18 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 65 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
19 | index XXXXXXX..XXXXXXX 100644 | 66 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/target/arm/helper.c | 67 | --- a/target/arm/helper.c |
21 | +++ b/target/arm/helper.c | 68 | +++ b/target/arm/helper.c |
22 | @@ -XXX,XX +XXX,XX @@ static uint32_t rebuild_hflags_a64(CPUARMState *env, int el, int fp_el, | 69 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_do_interrupt_aarch64(CPUState *cs) |
23 | if (FIELD_EX32(flags, TBFLAG_A64, UNPRIV) | 70 | } |
24 | && tbid | 71 | |
25 | && !(env->pstate & PSTATE_TCO) | 72 | pstate_write(env, PSTATE_DAIF | new_mode); |
26 | - && (sctlr & SCTLR_TCF0) | 73 | - env->aarch64 = 1; |
27 | + && (sctlr & SCTLR_TCF) | 74 | + env->aarch64 = true; |
28 | && allocation_tag_access_enabled(env, 0, sctlr)) { | 75 | aarch64_restore_sp(env, new_el); |
29 | flags = FIELD_DP32(flags, TBFLAG_A64, MTE0_ACTIVE, 1); | 76 | helper_rebuild_hflags_a64(env, new_el); |
30 | } | 77 | |
78 | diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c | ||
79 | index XXXXXXX..XXXXXXX 100644 | ||
80 | --- a/target/arm/hvf/hvf.c | ||
81 | +++ b/target/arm/hvf/hvf.c | ||
82 | @@ -XXX,XX +XXX,XX @@ int hvf_arch_init_vcpu(CPUState *cpu) | ||
83 | hv_return_t ret; | ||
84 | int i; | ||
85 | |||
86 | - env->aarch64 = 1; | ||
87 | + env->aarch64 = true; | ||
88 | asm volatile("mrs %0, cntfrq_el0" : "=r"(arm_cpu->gt_cntfrq_hz)); | ||
89 | |||
90 | /* Allocate enough space for our sysreg sync */ | ||
31 | -- | 91 | -- |
32 | 2.20.1 | 92 | 2.25.1 |
33 | 93 | ||
34 | 94 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
1 | 2 | ||
3 | Currently we assume all fields are 32-bit. | ||
4 | Prepare for fields of a single byte, using sizeof_field(). | ||
5 | |||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | [PMM: use sizeof_field() instead of raw sizeof()] | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | target/arm/translate-a32.h | 13 +++++-------- | ||
12 | target/arm/translate.c | 21 ++++++++++++++++++++- | ||
13 | 2 files changed, 25 insertions(+), 9 deletions(-) | ||
14 | |||
15 | diff --git a/target/arm/translate-a32.h b/target/arm/translate-a32.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/target/arm/translate-a32.h | ||
18 | +++ b/target/arm/translate-a32.h | ||
19 | @@ -XXX,XX +XXX,XX @@ static inline TCGv_i32 load_cpu_offset(int offset) | ||
20 | |||
21 | #define load_cpu_field(name) load_cpu_offset(offsetof(CPUARMState, name)) | ||
22 | |||
23 | -static inline void store_cpu_offset(TCGv_i32 var, int offset) | ||
24 | -{ | ||
25 | - tcg_gen_st_i32(var, cpu_env, offset); | ||
26 | - tcg_temp_free_i32(var); | ||
27 | -} | ||
28 | +void store_cpu_offset(TCGv_i32 var, int offset, int size); | ||
29 | |||
30 | -#define store_cpu_field(var, name) \ | ||
31 | - store_cpu_offset(var, offsetof(CPUARMState, name)) | ||
32 | +#define store_cpu_field(var, name) \ | ||
33 | + store_cpu_offset(var, offsetof(CPUARMState, name), \ | ||
34 | + sizeof_field(CPUARMState, name)) | ||
35 | |||
36 | #define store_cpu_field_constant(val, name) \ | ||
37 | - tcg_gen_st_i32(tcg_constant_i32(val), cpu_env, offsetof(CPUARMState, name)) | ||
38 | + store_cpu_field(tcg_constant_i32(val), name) | ||
39 | |||
40 | /* Create a new temporary and set it to the value of a CPU register. */ | ||
41 | static inline TCGv_i32 load_reg(DisasContext *s, int reg) | ||
42 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
43 | index XXXXXXX..XXXXXXX 100644 | ||
44 | --- a/target/arm/translate.c | ||
45 | +++ b/target/arm/translate.c | ||
46 | @@ -XXX,XX +XXX,XX @@ typedef enum ISSInfo { | ||
47 | ISSIs16Bit = (1 << 8), | ||
48 | } ISSInfo; | ||
49 | |||
50 | +/* | ||
51 | + * Store var into env + offset to a member with size bytes. | ||
52 | + * Free var after use. | ||
53 | + */ | ||
54 | +void store_cpu_offset(TCGv_i32 var, int offset, int size) | ||
55 | +{ | ||
56 | + switch (size) { | ||
57 | + case 1: | ||
58 | + tcg_gen_st8_i32(var, cpu_env, offset); | ||
59 | + break; | ||
60 | + case 4: | ||
61 | + tcg_gen_st_i32(var, cpu_env, offset); | ||
62 | + break; | ||
63 | + default: | ||
64 | + g_assert_not_reached(); | ||
65 | + } | ||
66 | + tcg_temp_free_i32(var); | ||
67 | +} | ||
68 | + | ||
69 | /* Save the syndrome information for a Data Abort */ | ||
70 | static void disas_set_da_iss(DisasContext *s, MemOp memop, ISSInfo issinfo) | ||
71 | { | ||
72 | @@ -XXX,XX +XXX,XX @@ static void do_coproc_insn(DisasContext *s, int cpnum, int is64, | ||
73 | tcg_temp_free_i32(tmp); | ||
74 | } else { | ||
75 | TCGv_i32 tmp = load_reg(s, rt); | ||
76 | - store_cpu_offset(tmp, ri->fieldoffset); | ||
77 | + store_cpu_offset(tmp, ri->fieldoffset, 4); | ||
78 | } | ||
79 | } | ||
80 | } | ||
81 | -- | ||
82 | 2.25.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
1 | 2 | ||
3 | Bool is a more appropriate type for this value. | ||
4 | Move the member down in the struct to keep the | ||
5 | bool type members together and remove a hole. | ||
6 | |||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | target/arm/translate.h | 2 +- | ||
12 | target/arm/translate-a64.c | 2 +- | ||
13 | 2 files changed, 2 insertions(+), 2 deletions(-) | ||
14 | |||
15 | diff --git a/target/arm/translate.h b/target/arm/translate.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/target/arm/translate.h | ||
18 | +++ b/target/arm/translate.h | ||
19 | @@ -XXX,XX +XXX,XX @@ typedef struct DisasContext { | ||
20 | bool eci_handled; | ||
21 | /* TCG op to rewind to if this turns out to be an invalid ECI state */ | ||
22 | TCGOp *insn_eci_rewind; | ||
23 | - int thumb; | ||
24 | int sctlr_b; | ||
25 | MemOp be_data; | ||
26 | #if !defined(CONFIG_USER_ONLY) | ||
27 | @@ -XXX,XX +XXX,XX @@ typedef struct DisasContext { | ||
28 | GHashTable *cp_regs; | ||
29 | uint64_t features; /* CPU features bits */ | ||
30 | bool aarch64; | ||
31 | + bool thumb; | ||
32 | /* Because unallocated encodings generate different exception syndrome | ||
33 | * information from traps due to FP being disabled, we can't do a single | ||
34 | * "is fp access disabled" check at a high level in the decode tree. | ||
35 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
36 | index XXXXXXX..XXXXXXX 100644 | ||
37 | --- a/target/arm/translate-a64.c | ||
38 | +++ b/target/arm/translate-a64.c | ||
39 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_init_disas_context(DisasContextBase *dcbase, | ||
40 | */ | ||
41 | dc->secure_routed_to_el3 = arm_feature(env, ARM_FEATURE_EL3) && | ||
42 | !arm_el_is_aa64(env, 3); | ||
43 | - dc->thumb = 0; | ||
44 | + dc->thumb = false; | ||
45 | dc->sctlr_b = 0; | ||
46 | dc->be_data = EX_TBFLAG_ANY(tb_flags, BE_DATA) ? MO_BE : MO_LE; | ||
47 | dc->condexec_mask = 0; | ||
48 | -- | ||
49 | 2.25.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
1 | 2 | ||
3 | Bool is a more appropriate type for this value. | ||
4 | Adjust the assignments to use true/false. | ||
5 | |||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | --- | ||
10 | target/arm/cpu.h | 2 +- | ||
11 | linux-user/arm/cpu_loop.c | 2 +- | ||
12 | target/arm/cpu.c | 2 +- | ||
13 | target/arm/m_helper.c | 6 +++--- | ||
14 | 4 files changed, 6 insertions(+), 6 deletions(-) | ||
15 | |||
16 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/target/arm/cpu.h | ||
19 | +++ b/target/arm/cpu.h | ||
20 | @@ -XXX,XX +XXX,XX @@ typedef struct CPUArchState { | ||
21 | */ | ||
22 | uint32_t pstate; | ||
23 | bool aarch64; /* True if CPU is in aarch64 state; inverse of PSTATE.nRW */ | ||
24 | + bool thumb; /* True if CPU is in thumb mode; cpsr[5] */ | ||
25 | |||
26 | /* Cached TBFLAGS state. See below for which bits are included. */ | ||
27 | CPUARMTBFlags hflags; | ||
28 | @@ -XXX,XX +XXX,XX @@ typedef struct CPUArchState { | ||
29 | uint32_t ZF; /* Z set if zero. */ | ||
30 | uint32_t QF; /* 0 or 1 */ | ||
31 | uint32_t GE; /* cpsr[19:16] */ | ||
32 | - uint32_t thumb; /* cpsr[5]. 0 = arm mode, 1 = thumb mode. */ | ||
33 | uint32_t condexec_bits; /* IT bits. cpsr[15:10,26:25]. */ | ||
34 | uint32_t btype; /* BTI branch type. spsr[11:10]. */ | ||
35 | uint64_t daif; /* exception masks, in the bits they are in PSTATE */ | ||
36 | diff --git a/linux-user/arm/cpu_loop.c b/linux-user/arm/cpu_loop.c | ||
37 | index XXXXXXX..XXXXXXX 100644 | ||
38 | --- a/linux-user/arm/cpu_loop.c | ||
39 | +++ b/linux-user/arm/cpu_loop.c | ||
40 | @@ -XXX,XX +XXX,XX @@ do_kernel_trap(CPUARMState *env) | ||
41 | /* Jump back to the caller. */ | ||
42 | addr = env->regs[14]; | ||
43 | if (addr & 1) { | ||
44 | - env->thumb = 1; | ||
45 | + env->thumb = true; | ||
46 | addr &= ~1; | ||
47 | } | ||
48 | env->regs[15] = addr; | ||
49 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | ||
50 | index XXXXXXX..XXXXXXX 100644 | ||
51 | --- a/target/arm/cpu.c | ||
52 | +++ b/target/arm/cpu.c | ||
53 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_set_pc(CPUState *cs, vaddr value) | ||
54 | |||
55 | if (is_a64(env)) { | ||
56 | env->pc = value; | ||
57 | - env->thumb = 0; | ||
58 | + env->thumb = false; | ||
59 | } else { | ||
60 | env->regs[15] = value & ~1; | ||
61 | env->thumb = value & 1; | ||
62 | diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c | ||
63 | index XXXXXXX..XXXXXXX 100644 | ||
64 | --- a/target/arm/m_helper.c | ||
65 | +++ b/target/arm/m_helper.c | ||
66 | @@ -XXX,XX +XXX,XX @@ void HELPER(v7m_bxns)(CPUARMState *env, uint32_t dest) | ||
67 | env->v7m.control[M_REG_S] &= ~R_V7M_CONTROL_SFPA_MASK; | ||
68 | } | ||
69 | switch_v7m_security_state(env, dest & 1); | ||
70 | - env->thumb = 1; | ||
71 | + env->thumb = true; | ||
72 | env->regs[15] = dest & ~1; | ||
73 | arm_rebuild_hflags(env); | ||
74 | } | ||
75 | @@ -XXX,XX +XXX,XX @@ void HELPER(v7m_blxns)(CPUARMState *env, uint32_t dest) | ||
76 | * except that the low bit doesn't indicate Thumb/not. | ||
77 | */ | ||
78 | env->regs[14] = nextinst; | ||
79 | - env->thumb = 1; | ||
80 | + env->thumb = true; | ||
81 | env->regs[15] = dest & ~1; | ||
82 | return; | ||
83 | } | ||
84 | @@ -XXX,XX +XXX,XX @@ void HELPER(v7m_blxns)(CPUARMState *env, uint32_t dest) | ||
85 | } | ||
86 | env->v7m.control[M_REG_S] &= ~R_V7M_CONTROL_SFPA_MASK; | ||
87 | switch_v7m_security_state(env, 0); | ||
88 | - env->thumb = 1; | ||
89 | + env->thumb = true; | ||
90 | env->regs[15] = dest; | ||
91 | arm_rebuild_hflags(env); | ||
92 | } | ||
93 | -- | ||
94 | 2.25.1 | diff view generated by jsdifflib |
1 | From: Gan Qixin <ganqixin@huawei.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | When running device-introspect-test, a memory leak occurred in the a10_pit_init | 3 | This function is incorrect in that it does not properly consider |
4 | function, so use ptimer_free() in the finalize function to avoid it. | 4 | CPTR_EL2.FPEN. We've already got another mechanism for raising |
5 | an FPU access trap: ARM_CP_FPU, so use that instead. | ||
5 | 6 | ||
6 | ASAN shows memory leak stack: | 7 | Remove CP_ACCESS_TRAP_FP_EL{2,3}, which becomes unused. |
7 | 8 | ||
8 | Indirect leak of 288 byte(s) in 6 object(s) allocated from: | 9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
9 | #0 0xffffab97e1f0 in __interceptor_calloc (/lib64/libasan.so.5+0xee1f0) | ||
10 | #1 0xffffab256800 in g_malloc0 (/lib64/libglib-2.0.so.0+0x56800) | ||
11 | #2 0xaaabf555db84 in timer_new_full /qemu/include/qemu/timer.h:523 | ||
12 | #3 0xaaabf555db84 in timer_new /qemu/include/qemu/timer.h:544 | ||
13 | #4 0xaaabf555db84 in timer_new_ns /qemu/include/qemu/timer.h:562 | ||
14 | #5 0xaaabf555db84 in ptimer_init /qemu/hw/core/ptimer.c:433 | ||
15 | #6 0xaaabf57415e8 in a10_pit_init /qemu/hw/timer/allwinner-a10-pit.c:278 | ||
16 | #7 0xaaabf6339f6c in object_initialize_with_type /qemu/qom/object.c:515 | ||
17 | #8 0xaaabf633ca04 in object_initialize_child_with_propsv /qemu/qom/object.c:564 | ||
18 | #9 0xaaabf633cc08 in object_initialize_child_with_props /qemu/qom/object.c:547 | ||
19 | #10 0xaaabf5b94680 in aw_a10_init /qemu/hw/arm/allwinner-a10.c:49 | ||
20 | #11 0xaaabf6339f6c in object_initialize_with_type /qemu/qom/object.c:515 | ||
21 | #12 0xaaabf633a1e0 in object_new_with_type /qemu/qom/object.c:729 | ||
22 | |||
23 | Reported-by: Euler Robot <euler.robot@huawei.com> | ||
24 | Signed-off-by: Gan Qixin <ganqixin@huawei.com> | ||
25 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
26 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
27 | --- | 12 | --- |
28 | hw/timer/allwinner-a10-pit.c | 11 +++++++++++ | 13 | target/arm/cpu.h | 5 ----- |
29 | 1 file changed, 11 insertions(+) | 14 | target/arm/helper.c | 17 ++--------------- |
15 | target/arm/op_helper.c | 13 ------------- | ||
16 | 3 files changed, 2 insertions(+), 33 deletions(-) | ||
30 | 17 | ||
31 | diff --git a/hw/timer/allwinner-a10-pit.c b/hw/timer/allwinner-a10-pit.c | 18 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
32 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
33 | --- a/hw/timer/allwinner-a10-pit.c | 20 | --- a/target/arm/cpu.h |
34 | +++ b/hw/timer/allwinner-a10-pit.c | 21 | +++ b/target/arm/cpu.h |
35 | @@ -XXX,XX +XXX,XX @@ static void a10_pit_init(Object *obj) | 22 | @@ -XXX,XX +XXX,XX @@ typedef enum CPAccessResult { |
23 | /* As CP_ACCESS_UNCATEGORIZED, but for traps directly to EL2 or EL3 */ | ||
24 | CP_ACCESS_TRAP_UNCATEGORIZED_EL2 = 5, | ||
25 | CP_ACCESS_TRAP_UNCATEGORIZED_EL3 = 6, | ||
26 | - /* Access fails and results in an exception syndrome for an FP access, | ||
27 | - * trapped directly to EL2 or EL3 | ||
28 | - */ | ||
29 | - CP_ACCESS_TRAP_FP_EL2 = 7, | ||
30 | - CP_ACCESS_TRAP_FP_EL3 = 8, | ||
31 | } CPAccessResult; | ||
32 | |||
33 | /* Access functions for coprocessor registers. These cannot fail and | ||
34 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
35 | index XXXXXXX..XXXXXXX 100644 | ||
36 | --- a/target/arm/helper.c | ||
37 | +++ b/target/arm/helper.c | ||
38 | @@ -XXX,XX +XXX,XX @@ static void sctlr_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
36 | } | 39 | } |
37 | } | 40 | } |
38 | 41 | ||
39 | +static void a10_pit_finalize(Object *obj) | 42 | -static CPAccessResult fpexc32_access(CPUARMState *env, const ARMCPRegInfo *ri, |
40 | +{ | 43 | - bool isread) |
41 | + AwA10PITState *s = AW_A10_PIT(obj); | 44 | -{ |
42 | + int i; | 45 | - if ((env->cp15.cptr_el[2] & CPTR_TFP) && arm_current_el(env) == 2) { |
43 | + | 46 | - return CP_ACCESS_TRAP_FP_EL2; |
44 | + for (i = 0; i < AW_A10_PIT_TIMER_NR; i++) { | 47 | - } |
45 | + ptimer_free(s->timer[i]); | 48 | - if (env->cp15.cptr_el[3] & CPTR_TFP) { |
46 | + } | 49 | - return CP_ACCESS_TRAP_FP_EL3; |
47 | +} | 50 | - } |
48 | + | 51 | - return CP_ACCESS_OK; |
49 | static void a10_pit_class_init(ObjectClass *klass, void *data) | 52 | -} |
53 | - | ||
54 | static void sdcr_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
55 | uint64_t value) | ||
50 | { | 56 | { |
51 | DeviceClass *dc = DEVICE_CLASS(klass); | 57 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v8_cp_reginfo[] = { |
52 | @@ -XXX,XX +XXX,XX @@ static const TypeInfo a10_pit_info = { | 58 | .access = PL1_RW, .readfn = spsel_read, .writefn = spsel_write }, |
53 | .parent = TYPE_SYS_BUS_DEVICE, | 59 | { .name = "FPEXC32_EL2", .state = ARM_CP_STATE_AA64, |
54 | .instance_size = sizeof(AwA10PITState), | 60 | .opc0 = 3, .opc1 = 4, .crn = 5, .crm = 3, .opc2 = 0, |
55 | .instance_init = a10_pit_init, | 61 | - .type = ARM_CP_ALIAS, |
56 | + .instance_finalize = a10_pit_finalize, | 62 | - .fieldoffset = offsetof(CPUARMState, vfp.xregs[ARM_VFP_FPEXC]), |
57 | .class_init = a10_pit_class_init, | 63 | - .access = PL2_RW, .accessfn = fpexc32_access }, |
58 | }; | 64 | + .access = PL2_RW, .type = ARM_CP_ALIAS | ARM_CP_FPU, |
59 | 65 | + .fieldoffset = offsetof(CPUARMState, vfp.xregs[ARM_VFP_FPEXC]) }, | |
66 | { .name = "DACR32_EL2", .state = ARM_CP_STATE_AA64, | ||
67 | .opc0 = 3, .opc1 = 4, .crn = 3, .crm = 0, .opc2 = 0, | ||
68 | .access = PL2_RW, .resetvalue = 0, | ||
69 | diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c | ||
70 | index XXXXXXX..XXXXXXX 100644 | ||
71 | --- a/target/arm/op_helper.c | ||
72 | +++ b/target/arm/op_helper.c | ||
73 | @@ -XXX,XX +XXX,XX @@ void HELPER(access_check_cp_reg)(CPUARMState *env, void *rip, uint32_t syndrome, | ||
74 | target_el = 3; | ||
75 | syndrome = syn_uncategorized(); | ||
76 | break; | ||
77 | - case CP_ACCESS_TRAP_FP_EL2: | ||
78 | - target_el = 2; | ||
79 | - /* Since we are an implementation that takes exceptions on a trapped | ||
80 | - * conditional insn only if the insn has passed its condition code | ||
81 | - * check, we take the IMPDEF choice to always report CV=1 COND=0xe | ||
82 | - * (which is also the required value for AArch64 traps). | ||
83 | - */ | ||
84 | - syndrome = syn_fp_access_trap(1, 0xe, false); | ||
85 | - break; | ||
86 | - case CP_ACCESS_TRAP_FP_EL3: | ||
87 | - target_el = 3; | ||
88 | - syndrome = syn_fp_access_trap(1, 0xe, false); | ||
89 | - break; | ||
90 | default: | ||
91 | g_assert_not_reached(); | ||
92 | } | ||
60 | -- | 93 | -- |
61 | 2.20.1 | 94 | 2.25.1 |
62 | |||
63 | diff view generated by jsdifflib |
1 | From: Gan Qixin <ganqixin@huawei.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | When running device-introspect-test, a memory leak occurred in the | 3 | Common code for reset_btype and set_btype. |
4 | mv88w8618_pit_init function, so use ptimer_free() in the finalize function to | 4 | Use tcg_constant_i32. |
5 | avoid it. | ||
6 | 5 | ||
7 | ASAN shows memory leak stack: | 6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
8 | |||
9 | Indirect leak of 192 byte(s) in 4 object(s) allocated from: | ||
10 | #0 0xffffab97e1f0 in __interceptor_calloc (/lib64/libasan.so.5+0xee1f0) | ||
11 | #1 0xffffab256800 in g_malloc0 (/lib64/libglib-2.0.so.0+0x56800) | ||
12 | #2 0xaaabf555db84 in timer_new_full /qemu/include/qemu/timer.h:523 | ||
13 | #3 0xaaabf555db84 in timer_new /qemu/include/qemu/timer.h:544 | ||
14 | #4 0xaaabf555db84 in timer_new_ns /qemu/include/qemu/timer.h:562 | ||
15 | #5 0xaaabf555db84 in ptimer_init /qemu/hw/core/ptimer.c:433 | ||
16 | #6 0xaaabf5bb2290 in mv88w8618_timer_init /qemu/hw/arm/musicpal.c:862 | ||
17 | #7 0xaaabf5bb2290 in mv88w8618_pit_init /qemu/hw/arm/musicpal.c:954 | ||
18 | #8 0xaaabf6339f6c in object_initialize_with_type /qemu/qom/object.c:515 | ||
19 | #9 0xaaabf633a1e0 in object_new_with_type /qemu/qom/object.c:729 | ||
20 | #10 0xaaabf6375e40 in qmp_device_list_properties /qemu/qom/qom-qmp-cmds.c:153 | ||
21 | #11 0xaaabf5a95540 in qdev_device_help /qemu/softmmu/qdev-monitor.c:283 | ||
22 | #12 0xaaabf5a96940 in qmp_device_add /qemu/softmmu/qdev-monitor.c:801 | ||
23 | |||
24 | Reported-by: Euler Robot <euler.robot@huawei.com> | ||
25 | Signed-off-by: Gan Qixin <ganqixin@huawei.com> | ||
26 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
27 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
28 | --- | 9 | --- |
29 | hw/arm/musicpal.c | 12 ++++++++++++ | 10 | target/arm/translate-a64.c | 25 ++++++++++++------------- |
30 | 1 file changed, 12 insertions(+) | 11 | 1 file changed, 12 insertions(+), 13 deletions(-) |
31 | 12 | ||
32 | diff --git a/hw/arm/musicpal.c b/hw/arm/musicpal.c | 13 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c |
33 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
34 | --- a/hw/arm/musicpal.c | 15 | --- a/target/arm/translate-a64.c |
35 | +++ b/hw/arm/musicpal.c | 16 | +++ b/target/arm/translate-a64.c |
36 | @@ -XXX,XX +XXX,XX @@ static void mv88w8618_pit_init(Object *obj) | 17 | @@ -XXX,XX +XXX,XX @@ static int get_a64_user_mem_index(DisasContext *s) |
37 | sysbus_init_mmio(dev, &s->iomem); | 18 | return arm_to_core_mmu_idx(useridx); |
38 | } | 19 | } |
39 | 20 | ||
40 | +static void mv88w8618_pit_finalize(Object *obj) | 21 | -static void reset_btype(DisasContext *s) |
22 | +static void set_btype_raw(int val) | ||
23 | { | ||
24 | - if (s->btype != 0) { | ||
25 | - TCGv_i32 zero = tcg_const_i32(0); | ||
26 | - tcg_gen_st_i32(zero, cpu_env, offsetof(CPUARMState, btype)); | ||
27 | - tcg_temp_free_i32(zero); | ||
28 | - s->btype = 0; | ||
29 | - } | ||
30 | + tcg_gen_st_i32(tcg_constant_i32(val), cpu_env, | ||
31 | + offsetof(CPUARMState, btype)); | ||
32 | } | ||
33 | |||
34 | static void set_btype(DisasContext *s, int val) | ||
35 | { | ||
36 | - TCGv_i32 tcg_val; | ||
37 | - | ||
38 | /* BTYPE is a 2-bit field, and 0 should be done with reset_btype. */ | ||
39 | tcg_debug_assert(val >= 1 && val <= 3); | ||
40 | - | ||
41 | - tcg_val = tcg_const_i32(val); | ||
42 | - tcg_gen_st_i32(tcg_val, cpu_env, offsetof(CPUARMState, btype)); | ||
43 | - tcg_temp_free_i32(tcg_val); | ||
44 | + set_btype_raw(val); | ||
45 | s->btype = -1; | ||
46 | } | ||
47 | |||
48 | +static void reset_btype(DisasContext *s) | ||
41 | +{ | 49 | +{ |
42 | + SysBusDevice *dev = SYS_BUS_DEVICE(obj); | 50 | + if (s->btype != 0) { |
43 | + mv88w8618_pit_state *s = MV88W8618_PIT(dev); | 51 | + set_btype_raw(0); |
44 | + int i; | 52 | + s->btype = 0; |
45 | + | ||
46 | + for (i = 0; i < 4; i++) { | ||
47 | + ptimer_free(s->timer[i].ptimer); | ||
48 | + } | 53 | + } |
49 | +} | 54 | +} |
50 | + | 55 | + |
51 | static const VMStateDescription mv88w8618_timer_vmsd = { | 56 | void gen_a64_set_pc_im(uint64_t val) |
52 | .name = "timer", | 57 | { |
53 | .version_id = 1, | 58 | tcg_gen_movi_i64(cpu_pc, val); |
54 | @@ -XXX,XX +XXX,XX @@ static const TypeInfo mv88w8618_pit_info = { | ||
55 | .parent = TYPE_SYS_BUS_DEVICE, | ||
56 | .instance_size = sizeof(mv88w8618_pit_state), | ||
57 | .instance_init = mv88w8618_pit_init, | ||
58 | + .instance_finalize = mv88w8618_pit_finalize, | ||
59 | .class_init = mv88w8618_pit_class_init, | ||
60 | }; | ||
61 | |||
62 | -- | 59 | -- |
63 | 2.20.1 | 60 | 2.25.1 |
64 | |||
65 | diff view generated by jsdifflib |
1 | From: Gan Qixin <ganqixin@huawei.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | When running device-introspect-test, a memory leak occurred in the | 3 | For aa32, the function has a parameter to use the new el. |
4 | mss_timer_init function, so use ptimer_free() in the finalize function to avoid | 4 | For aa64, that never happens. |
5 | it. | 5 | Use tcg_constant_i32 while we're at it. |
6 | 6 | ||
7 | ASAN shows memory leak stack: | 7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
8 | |||
9 | Indirect leak of 192 byte(s) in 2 object(s) allocated from: | ||
10 | #0 0xffffab97e1f0 in __interceptor_calloc (/lib64/libasan.so.5+0xee1f0) | ||
11 | #1 0xffffab256800 in g_malloc0 (/lib64/libglib-2.0.so.0+0x56800) | ||
12 | #2 0xaaabf555db78 in ptimer_init /qemu/hw/core/ptimer.c:432 | ||
13 | #3 0xaaabf58a0010 in mss_timer_init /qemu/hw/timer/mss-timer.c:235 | ||
14 | #4 0xaaabf6339f6c in object_initialize_with_type /qemu/qom/object.c:515 | ||
15 | #5 0xaaabf633ca04 in object_initialize_child_with_propsv /qemu/qom/object.c:564 | ||
16 | #6 0xaaabf633cc08 in object_initialize_child_with_props /qemu/qom/object.c:547 | ||
17 | #7 0xaaabf5b8316c in m2sxxx_soc_initfn /qemu/hw/arm/msf2-soc.c:70 | ||
18 | #8 0xaaabf6339f6c in object_initialize_with_type /qemu/qom/object.c:515 | ||
19 | #9 0xaaabf633a1e0 in object_new_with_type /qemu/qom/object.c:729 | ||
20 | #10 0xaaabf6375e40 in qmp_device_list_properties /qemu/qom/qom-qmp-cmds.c:153 | ||
21 | #11 0xaaabf653d8ec in qmp_marshal_device_list_properties /qemu/qapi/qapi-commands-qdev.c:59 | ||
22 | #12 0xaaabf6587d08 in do_qmp_dispatch_bh /qemu/qapi/qmp-dispatch.c:110 | ||
23 | |||
24 | Reported-by: Euler Robot <euler.robot@huawei.com> | ||
25 | Signed-off-by: Gan Qixin <ganqixin@huawei.com> | ||
26 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
27 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
28 | --- | 10 | --- |
29 | hw/timer/mss-timer.c | 13 +++++++++++++ | 11 | target/arm/translate-a64.c | 21 +++++++++----------- |
30 | 1 file changed, 13 insertions(+) | 12 | target/arm/translate.c | 40 +++++++++++++++++++++++--------------- |
13 | 2 files changed, 33 insertions(+), 28 deletions(-) | ||
31 | 14 | ||
32 | diff --git a/hw/timer/mss-timer.c b/hw/timer/mss-timer.c | 15 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c |
33 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
34 | --- a/hw/timer/mss-timer.c | 17 | --- a/target/arm/translate-a64.c |
35 | +++ b/hw/timer/mss-timer.c | 18 | +++ b/target/arm/translate-a64.c |
36 | @@ -XXX,XX +XXX,XX @@ static void mss_timer_init(Object *obj) | 19 | @@ -XXX,XX +XXX,XX @@ static void a64_free_cc(DisasCompare64 *c64) |
37 | sysbus_init_mmio(SYS_BUS_DEVICE(obj), &t->mmio); | 20 | tcg_temp_free_i64(c64->value); |
38 | } | 21 | } |
39 | 22 | ||
40 | +static void mss_timer_finalize(Object *obj) | 23 | +static void gen_rebuild_hflags(DisasContext *s) |
41 | +{ | 24 | +{ |
42 | + MSSTimerState *t = MSS_TIMER(obj); | 25 | + gen_helper_rebuild_hflags_a64(cpu_env, tcg_constant_i32(s->current_el)); |
43 | + int i; | 26 | +} |
44 | + | 27 | + |
45 | + for (i = 0; i < NUM_TIMERS; i++) { | 28 | static void gen_exception_internal(int excp) |
46 | + struct Msf2Timer *st = &t->timers[i]; | 29 | { |
30 | TCGv_i32 tcg_excp = tcg_const_i32(excp); | ||
31 | @@ -XXX,XX +XXX,XX @@ static void handle_msr_i(DisasContext *s, uint32_t insn, | ||
32 | } else { | ||
33 | clear_pstate_bits(PSTATE_UAO); | ||
34 | } | ||
35 | - t1 = tcg_const_i32(s->current_el); | ||
36 | - gen_helper_rebuild_hflags_a64(cpu_env, t1); | ||
37 | - tcg_temp_free_i32(t1); | ||
38 | + gen_rebuild_hflags(s); | ||
39 | break; | ||
40 | |||
41 | case 0x04: /* PAN */ | ||
42 | @@ -XXX,XX +XXX,XX @@ static void handle_msr_i(DisasContext *s, uint32_t insn, | ||
43 | } else { | ||
44 | clear_pstate_bits(PSTATE_PAN); | ||
45 | } | ||
46 | - t1 = tcg_const_i32(s->current_el); | ||
47 | - gen_helper_rebuild_hflags_a64(cpu_env, t1); | ||
48 | - tcg_temp_free_i32(t1); | ||
49 | + gen_rebuild_hflags(s); | ||
50 | break; | ||
51 | |||
52 | case 0x05: /* SPSel */ | ||
53 | @@ -XXX,XX +XXX,XX @@ static void handle_msr_i(DisasContext *s, uint32_t insn, | ||
54 | } else { | ||
55 | clear_pstate_bits(PSTATE_TCO); | ||
56 | } | ||
57 | - t1 = tcg_const_i32(s->current_el); | ||
58 | - gen_helper_rebuild_hflags_a64(cpu_env, t1); | ||
59 | - tcg_temp_free_i32(t1); | ||
60 | + gen_rebuild_hflags(s); | ||
61 | /* Many factors, including TCO, go into MTE_ACTIVE. */ | ||
62 | s->base.is_jmp = DISAS_UPDATE_NOCHAIN; | ||
63 | } else if (dc_isar_feature(aa64_mte_insn_reg, s)) { | ||
64 | @@ -XXX,XX +XXX,XX @@ static void handle_sys(DisasContext *s, uint32_t insn, bool isread, | ||
65 | * A write to any coprocessor regiser that ends a TB | ||
66 | * must rebuild the hflags for the next TB. | ||
67 | */ | ||
68 | - TCGv_i32 tcg_el = tcg_const_i32(s->current_el); | ||
69 | - gen_helper_rebuild_hflags_a64(cpu_env, tcg_el); | ||
70 | - tcg_temp_free_i32(tcg_el); | ||
71 | + gen_rebuild_hflags(s); | ||
72 | /* | ||
73 | * We default to ending the TB on a coprocessor register write, | ||
74 | * but allow this to be suppressed by the register definition | ||
75 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
76 | index XXXXXXX..XXXXXXX 100644 | ||
77 | --- a/target/arm/translate.c | ||
78 | +++ b/target/arm/translate.c | ||
79 | @@ -XXX,XX +XXX,XX @@ void gen_set_cpsr(TCGv_i32 var, uint32_t mask) | ||
80 | tcg_temp_free_i32(tmp_mask); | ||
81 | } | ||
82 | |||
83 | +static void gen_rebuild_hflags(DisasContext *s, bool new_el) | ||
84 | +{ | ||
85 | + bool m_profile = arm_dc_feature(s, ARM_FEATURE_M); | ||
47 | + | 86 | + |
48 | + ptimer_free(st->ptimer); | 87 | + if (new_el) { |
88 | + if (m_profile) { | ||
89 | + gen_helper_rebuild_hflags_m32_newel(cpu_env); | ||
90 | + } else { | ||
91 | + gen_helper_rebuild_hflags_a32_newel(cpu_env); | ||
92 | + } | ||
93 | + } else { | ||
94 | + TCGv_i32 tcg_el = tcg_constant_i32(s->current_el); | ||
95 | + if (m_profile) { | ||
96 | + gen_helper_rebuild_hflags_m32(cpu_env, tcg_el); | ||
97 | + } else { | ||
98 | + gen_helper_rebuild_hflags_a32(cpu_env, tcg_el); | ||
99 | + } | ||
49 | + } | 100 | + } |
50 | +} | 101 | +} |
51 | + | 102 | + |
52 | static const VMStateDescription vmstate_timers = { | 103 | static void gen_exception_internal(int excp) |
53 | .name = "mss-timer-block", | 104 | { |
54 | .version_id = 1, | 105 | TCGv_i32 tcg_excp = tcg_const_i32(excp); |
55 | @@ -XXX,XX +XXX,XX @@ static const TypeInfo mss_timer_info = { | 106 | @@ -XXX,XX +XXX,XX @@ static void do_coproc_insn(DisasContext *s, int cpnum, int is64, |
56 | .parent = TYPE_SYS_BUS_DEVICE, | 107 | * A write to any coprocessor register that ends a TB |
57 | .instance_size = sizeof(MSSTimerState), | 108 | * must rebuild the hflags for the next TB. |
58 | .instance_init = mss_timer_init, | 109 | */ |
59 | + .instance_finalize = mss_timer_finalize, | 110 | - TCGv_i32 tcg_el = tcg_const_i32(s->current_el); |
60 | .class_init = mss_timer_class_init, | 111 | - if (arm_dc_feature(s, ARM_FEATURE_M)) { |
61 | }; | 112 | - gen_helper_rebuild_hflags_m32(cpu_env, tcg_el); |
62 | 113 | - } else { | |
114 | - if (ri->type & ARM_CP_NEWEL) { | ||
115 | - gen_helper_rebuild_hflags_a32_newel(cpu_env); | ||
116 | - } else { | ||
117 | - gen_helper_rebuild_hflags_a32(cpu_env, tcg_el); | ||
118 | - } | ||
119 | - } | ||
120 | - tcg_temp_free_i32(tcg_el); | ||
121 | + gen_rebuild_hflags(s, ri->type & ARM_CP_NEWEL); | ||
122 | /* | ||
123 | * We default to ending the TB on a coprocessor register write, | ||
124 | * but allow this to be suppressed by the register definition | ||
125 | @@ -XXX,XX +XXX,XX @@ static bool trans_MSR_v7m(DisasContext *s, arg_MSR_v7m *a) | ||
126 | tcg_temp_free_i32(addr); | ||
127 | tcg_temp_free_i32(reg); | ||
128 | /* If we wrote to CONTROL, the EL might have changed */ | ||
129 | - gen_helper_rebuild_hflags_m32_newel(cpu_env); | ||
130 | + gen_rebuild_hflags(s, true); | ||
131 | gen_lookup_tb(s); | ||
132 | return true; | ||
133 | } | ||
134 | @@ -XXX,XX +XXX,XX @@ static bool trans_CPS(DisasContext *s, arg_CPS *a) | ||
135 | |||
136 | static bool trans_CPS_v7m(DisasContext *s, arg_CPS_v7m *a) | ||
137 | { | ||
138 | - TCGv_i32 tmp, addr, el; | ||
139 | + TCGv_i32 tmp, addr; | ||
140 | |||
141 | if (!arm_dc_feature(s, ARM_FEATURE_M)) { | ||
142 | return false; | ||
143 | @@ -XXX,XX +XXX,XX @@ static bool trans_CPS_v7m(DisasContext *s, arg_CPS_v7m *a) | ||
144 | gen_helper_v7m_msr(cpu_env, addr, tmp); | ||
145 | tcg_temp_free_i32(addr); | ||
146 | } | ||
147 | - el = tcg_const_i32(s->current_el); | ||
148 | - gen_helper_rebuild_hflags_m32(cpu_env, el); | ||
149 | - tcg_temp_free_i32(el); | ||
150 | + gen_rebuild_hflags(s, false); | ||
151 | tcg_temp_free_i32(tmp); | ||
152 | gen_lookup_tb(s); | ||
153 | return true; | ||
63 | -- | 154 | -- |
64 | 2.20.1 | 155 | 2.25.1 |
65 | |||
66 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
1 | 2 | ||
3 | Instead of computing | ||
4 | |||
5 | tmp1 = shift & 0xff; | ||
6 | dest = (tmp1 > 0x1f ? 0 : value) << (tmp1 & 0x1f) | ||
7 | |||
8 | use | ||
9 | |||
10 | tmpd = value << (shift & 0x1f); | ||
11 | dest = shift & 0xe0 ? 0 : tmpd; | ||
12 | |||
13 | which has a flatter dependency tree. | ||
14 | Use tcg_constant_i32 while we're at it. | ||
15 | |||
16 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
17 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
18 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
19 | --- | ||
20 | target/arm/translate.c | 18 ++++++++---------- | ||
21 | 1 file changed, 8 insertions(+), 10 deletions(-) | ||
22 | |||
23 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
24 | index XXXXXXX..XXXXXXX 100644 | ||
25 | --- a/target/arm/translate.c | ||
26 | +++ b/target/arm/translate.c | ||
27 | @@ -XXX,XX +XXX,XX @@ static void gen_sbc_CC(TCGv_i32 dest, TCGv_i32 t0, TCGv_i32 t1) | ||
28 | #define GEN_SHIFT(name) \ | ||
29 | static void gen_##name(TCGv_i32 dest, TCGv_i32 t0, TCGv_i32 t1) \ | ||
30 | { \ | ||
31 | - TCGv_i32 tmp1, tmp2, tmp3; \ | ||
32 | - tmp1 = tcg_temp_new_i32(); \ | ||
33 | - tcg_gen_andi_i32(tmp1, t1, 0xff); \ | ||
34 | - tmp2 = tcg_const_i32(0); \ | ||
35 | - tmp3 = tcg_const_i32(0x1f); \ | ||
36 | - tcg_gen_movcond_i32(TCG_COND_GTU, tmp2, tmp1, tmp3, tmp2, t0); \ | ||
37 | - tcg_temp_free_i32(tmp3); \ | ||
38 | - tcg_gen_andi_i32(tmp1, tmp1, 0x1f); \ | ||
39 | - tcg_gen_##name##_i32(dest, tmp2, tmp1); \ | ||
40 | - tcg_temp_free_i32(tmp2); \ | ||
41 | + TCGv_i32 tmpd = tcg_temp_new_i32(); \ | ||
42 | + TCGv_i32 tmp1 = tcg_temp_new_i32(); \ | ||
43 | + TCGv_i32 zero = tcg_constant_i32(0); \ | ||
44 | + tcg_gen_andi_i32(tmp1, t1, 0x1f); \ | ||
45 | + tcg_gen_##name##_i32(tmpd, t0, tmp1); \ | ||
46 | + tcg_gen_andi_i32(tmp1, t1, 0xe0); \ | ||
47 | + tcg_gen_movcond_i32(TCG_COND_NE, dest, tmp1, zero, zero, tmpd); \ | ||
48 | + tcg_temp_free_i32(tmpd); \ | ||
49 | tcg_temp_free_i32(tmp1); \ | ||
50 | } | ||
51 | GEN_SHIFT(shl) | ||
52 | -- | ||
53 | 2.25.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
1 | 2 | ||
3 | Use tcg_gen_umin_i32 instead of tcg_gen_movcond_i32. | ||
4 | Use tcg_constant_i32 while we're at it. | ||
5 | |||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | --- | ||
10 | target/arm/translate.c | 8 +++----- | ||
11 | 1 file changed, 3 insertions(+), 5 deletions(-) | ||
12 | |||
13 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/target/arm/translate.c | ||
16 | +++ b/target/arm/translate.c | ||
17 | @@ -XXX,XX +XXX,XX @@ GEN_SHIFT(shr) | ||
18 | |||
19 | static void gen_sar(TCGv_i32 dest, TCGv_i32 t0, TCGv_i32 t1) | ||
20 | { | ||
21 | - TCGv_i32 tmp1, tmp2; | ||
22 | - tmp1 = tcg_temp_new_i32(); | ||
23 | + TCGv_i32 tmp1 = tcg_temp_new_i32(); | ||
24 | + | ||
25 | tcg_gen_andi_i32(tmp1, t1, 0xff); | ||
26 | - tmp2 = tcg_const_i32(0x1f); | ||
27 | - tcg_gen_movcond_i32(TCG_COND_GTU, tmp1, tmp1, tmp2, tmp2, tmp1); | ||
28 | - tcg_temp_free_i32(tmp2); | ||
29 | + tcg_gen_umin_i32(tmp1, tmp1, tcg_constant_i32(31)); | ||
30 | tcg_gen_sar_i32(dest, t0, tmp1); | ||
31 | tcg_temp_free_i32(tmp1); | ||
32 | } | ||
33 | -- | ||
34 | 2.25.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
1 | 2 | ||
3 | The length of the previous insn may be computed from | ||
4 | the difference of start and end addresses. | ||
5 | Use tcg_constant_i32 while we're at it. | ||
6 | |||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | target/arm/translate.c | 12 ++++-------- | ||
12 | 1 file changed, 4 insertions(+), 8 deletions(-) | ||
13 | |||
14 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/target/arm/translate.c | ||
17 | +++ b/target/arm/translate.c | ||
18 | @@ -XXX,XX +XXX,XX @@ static void arm_tr_tb_stop(DisasContextBase *dcbase, CPUState *cpu) | ||
19 | /* nothing more to generate */ | ||
20 | break; | ||
21 | case DISAS_WFI: | ||
22 | - { | ||
23 | - TCGv_i32 tmp = tcg_const_i32((dc->thumb && | ||
24 | - !(dc->insn & (1U << 31))) ? 2 : 4); | ||
25 | - | ||
26 | - gen_helper_wfi(cpu_env, tmp); | ||
27 | - tcg_temp_free_i32(tmp); | ||
28 | - /* The helper doesn't necessarily throw an exception, but we | ||
29 | + gen_helper_wfi(cpu_env, | ||
30 | + tcg_constant_i32(dc->base.pc_next - dc->pc_curr)); | ||
31 | + /* | ||
32 | + * The helper doesn't necessarily throw an exception, but we | ||
33 | * must go back to the main loop to check for interrupts anyway. | ||
34 | */ | ||
35 | tcg_gen_exit_tb(NULL, 0); | ||
36 | break; | ||
37 | - } | ||
38 | case DISAS_WFE: | ||
39 | gen_helper_wfe(cpu_env); | ||
40 | break; | ||
41 | -- | ||
42 | 2.25.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
1 | 2 | ||
3 | Use tcg_constant_{i32,i64} as appropriate throughout. | ||
4 | This fixes a bug in trans_VSCCLRM() where we were leaking a TCGv. | ||
5 | |||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | --- | ||
10 | target/arm/translate-m-nocp.c | 12 +++++------- | ||
11 | 1 file changed, 5 insertions(+), 7 deletions(-) | ||
12 | |||
13 | diff --git a/target/arm/translate-m-nocp.c b/target/arm/translate-m-nocp.c | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/target/arm/translate-m-nocp.c | ||
16 | +++ b/target/arm/translate-m-nocp.c | ||
17 | @@ -XXX,XX +XXX,XX @@ static bool trans_VSCCLRM(DisasContext *s, arg_VSCCLRM *a) | ||
18 | } | ||
19 | |||
20 | /* Zero the Sregs from btmreg to topreg inclusive. */ | ||
21 | - zero = tcg_const_i64(0); | ||
22 | + zero = tcg_constant_i64(0); | ||
23 | if (btmreg & 1) { | ||
24 | write_neon_element64(zero, btmreg >> 1, 1, MO_32); | ||
25 | btmreg++; | ||
26 | @@ -XXX,XX +XXX,XX @@ static bool trans_VSCCLRM(DisasContext *s, arg_VSCCLRM *a) | ||
27 | } | ||
28 | assert(btmreg == topreg + 1); | ||
29 | if (dc_isar_feature(aa32_mve, s)) { | ||
30 | - TCGv_i32 z32 = tcg_const_i32(0); | ||
31 | - store_cpu_field(z32, v7m.vpr); | ||
32 | + store_cpu_field(tcg_constant_i32(0), v7m.vpr); | ||
33 | } | ||
34 | |||
35 | clear_eci_state(s); | ||
36 | @@ -XXX,XX +XXX,XX @@ static bool gen_M_fp_sysreg_read(DisasContext *s, int regno, | ||
37 | } | ||
38 | case ARM_VFP_FPCXT_NS: | ||
39 | { | ||
40 | - TCGv_i32 control, sfpa, fpscr, fpdscr, zero; | ||
41 | + TCGv_i32 control, sfpa, fpscr, fpdscr; | ||
42 | TCGLabel *lab_active = gen_new_label(); | ||
43 | |||
44 | lookup_tb = true; | ||
45 | @@ -XXX,XX +XXX,XX @@ static bool gen_M_fp_sysreg_read(DisasContext *s, int regno, | ||
46 | storefn(s, opaque, tmp, true); | ||
47 | /* If SFPA is zero then set FPSCR from FPDSCR_NS */ | ||
48 | fpdscr = load_cpu_field(v7m.fpdscr[M_REG_NS]); | ||
49 | - zero = tcg_const_i32(0); | ||
50 | - tcg_gen_movcond_i32(TCG_COND_EQ, fpscr, sfpa, zero, fpdscr, fpscr); | ||
51 | + tcg_gen_movcond_i32(TCG_COND_EQ, fpscr, sfpa, tcg_constant_i32(0), | ||
52 | + fpdscr, fpscr); | ||
53 | gen_helper_vfp_set_fpscr(cpu_env, fpscr); | ||
54 | - tcg_temp_free_i32(zero); | ||
55 | tcg_temp_free_i32(sfpa); | ||
56 | tcg_temp_free_i32(fpdscr); | ||
57 | tcg_temp_free_i32(fpscr); | ||
58 | -- | ||
59 | 2.25.1 | diff view generated by jsdifflib |
1 | From: Gan Qixin <ganqixin@huawei.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | When running device-introspect-test, a memory leak occurred in the | 3 | Use tcg_constant_{i32,i64} as appropriate throughout. |
4 | exynos4210_pwm_init function, so use ptimer_free() in the finalize function to | ||
5 | avoid it. | ||
6 | 4 | ||
7 | ASAN shows memory leak stack: | 5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
8 | |||
9 | Indirect leak of 240 byte(s) in 5 object(s) allocated from: | ||
10 | #0 0xffffab97e1f0 in __interceptor_calloc (/lib64/libasan.so.5+0xee1f0) | ||
11 | #1 0xffffab256800 in g_malloc0 (/lib64/libglib-2.0.so.0+0x56800) | ||
12 | #2 0xaaabf555db84 in timer_new_full /qemu/include/qemu/timer.h:523 | ||
13 | #3 0xaaabf555db84 in timer_new /qemu/include/qemu/timer.h:544 | ||
14 | #4 0xaaabf555db84 in timer_new_ns /qemu/include/qemu/timer.h:562 | ||
15 | #5 0xaaabf555db84 in ptimer_init /qemu/hw/core/ptimer.c:433 | ||
16 | #6 0xaaabf56a36cc in exynos4210_pwm_init /qemu/hw/timer/exynos4210_pwm.c:401 | ||
17 | #7 0xaaabf6339f6c in object_initialize_with_type /qemu/qom/object.c:515 | ||
18 | #8 0xaaabf633a1e0 in object_new_with_type /qemu/qom/object.c:729 | ||
19 | #9 0xaaabf6375e40 in qmp_device_list_properties /qemu/qom/qom-qmp-cmds.c:153 | ||
20 | #10 0xaaabf653d8ec in qmp_marshal_device_list_properties /qemu/qapi/qapi-commands-qdev.c:59 | ||
21 | #11 0xaaabf6587d08 in do_qmp_dispatch_bh /qemu/qapi/qmp-dispatch.c:110 | ||
22 | #12 0xaaabf6552708 in aio_bh_call /qemu/util/async.c:136 | ||
23 | |||
24 | Reported-by: Euler Robot <euler.robot@huawei.com> | ||
25 | Signed-off-by: Gan Qixin <ganqixin@huawei.com> | ||
26 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
27 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
28 | --- | 8 | --- |
29 | hw/timer/exynos4210_pwm.c | 11 +++++++++++ | 9 | target/arm/translate-neon.c | 21 +++++++-------------- |
30 | 1 file changed, 11 insertions(+) | 10 | 1 file changed, 7 insertions(+), 14 deletions(-) |
31 | 11 | ||
32 | diff --git a/hw/timer/exynos4210_pwm.c b/hw/timer/exynos4210_pwm.c | 12 | diff --git a/target/arm/translate-neon.c b/target/arm/translate-neon.c |
33 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
34 | --- a/hw/timer/exynos4210_pwm.c | 14 | --- a/target/arm/translate-neon.c |
35 | +++ b/hw/timer/exynos4210_pwm.c | 15 | +++ b/target/arm/translate-neon.c |
36 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_pwm_init(Object *obj) | 16 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLDST_multiple(DisasContext *s, arg_VLDST_multiple *a) |
37 | sysbus_init_mmio(dev, &s->iomem); | 17 | int mmu_idx = get_mem_index(s); |
18 | int size = a->size; | ||
19 | TCGv_i64 tmp64; | ||
20 | - TCGv_i32 addr, tmp; | ||
21 | + TCGv_i32 addr; | ||
22 | |||
23 | if (!arm_dc_feature(s, ARM_FEATURE_NEON)) { | ||
24 | return false; | ||
25 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLDST_multiple(DisasContext *s, arg_VLDST_multiple *a) | ||
26 | |||
27 | tmp64 = tcg_temp_new_i64(); | ||
28 | addr = tcg_temp_new_i32(); | ||
29 | - tmp = tcg_const_i32(1 << size); | ||
30 | load_reg_var(s, addr, a->rn); | ||
31 | |||
32 | mop = endian | size | align; | ||
33 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLDST_multiple(DisasContext *s, arg_VLDST_multiple *a) | ||
34 | neon_load_element64(tmp64, tt, n, size); | ||
35 | gen_aa32_st_internal_i64(s, tmp64, addr, mmu_idx, mop); | ||
36 | } | ||
37 | - tcg_gen_add_i32(addr, addr, tmp); | ||
38 | + tcg_gen_addi_i32(addr, addr, 1 << size); | ||
39 | |||
40 | /* Subsequent memory operations inherit alignment */ | ||
41 | mop &= ~MO_AMASK; | ||
42 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLDST_multiple(DisasContext *s, arg_VLDST_multiple *a) | ||
43 | } | ||
44 | } | ||
45 | tcg_temp_free_i32(addr); | ||
46 | - tcg_temp_free_i32(tmp); | ||
47 | tcg_temp_free_i64(tmp64); | ||
48 | |||
49 | gen_neon_ldst_base_update(s, a->rm, a->rn, nregs * interleave * 8); | ||
50 | @@ -XXX,XX +XXX,XX @@ static bool do_2shift_env_64(DisasContext *s, arg_2reg_shift *a, | ||
51 | * To avoid excessive duplication of ops we implement shift | ||
52 | * by immediate using the variable shift operations. | ||
53 | */ | ||
54 | - constimm = tcg_const_i64(dup_const(a->size, a->shift)); | ||
55 | + constimm = tcg_constant_i64(dup_const(a->size, a->shift)); | ||
56 | |||
57 | for (pass = 0; pass < a->q + 1; pass++) { | ||
58 | TCGv_i64 tmp = tcg_temp_new_i64(); | ||
59 | @@ -XXX,XX +XXX,XX @@ static bool do_2shift_env_64(DisasContext *s, arg_2reg_shift *a, | ||
60 | write_neon_element64(tmp, a->vd, pass, MO_64); | ||
61 | tcg_temp_free_i64(tmp); | ||
62 | } | ||
63 | - tcg_temp_free_i64(constimm); | ||
64 | return true; | ||
38 | } | 65 | } |
39 | 66 | ||
40 | +static void exynos4210_pwm_finalize(Object *obj) | 67 | @@ -XXX,XX +XXX,XX @@ static bool do_2shift_env_32(DisasContext *s, arg_2reg_shift *a, |
41 | +{ | 68 | * To avoid excessive duplication of ops we implement shift |
42 | + Exynos4210PWMState *s = EXYNOS4210_PWM(obj); | 69 | * by immediate using the variable shift operations. |
43 | + int i; | 70 | */ |
44 | + | 71 | - constimm = tcg_const_i32(dup_const(a->size, a->shift)); |
45 | + for (i = 0; i < EXYNOS4210_PWM_TIMERS_NUM; i++) { | 72 | + constimm = tcg_constant_i32(dup_const(a->size, a->shift)); |
46 | + ptimer_free(s->timer[i].ptimer); | 73 | tmp = tcg_temp_new_i32(); |
47 | + } | 74 | |
48 | +} | 75 | for (pass = 0; pass < (a->q ? 4 : 2); pass++) { |
49 | + | 76 | @@ -XXX,XX +XXX,XX @@ static bool do_2shift_env_32(DisasContext *s, arg_2reg_shift *a, |
50 | static void exynos4210_pwm_class_init(ObjectClass *klass, void *data) | 77 | write_neon_element32(tmp, a->vd, pass, MO_32); |
51 | { | 78 | } |
52 | DeviceClass *dc = DEVICE_CLASS(klass); | 79 | tcg_temp_free_i32(tmp); |
53 | @@ -XXX,XX +XXX,XX @@ static const TypeInfo exynos4210_pwm_info = { | 80 | - tcg_temp_free_i32(constimm); |
54 | .parent = TYPE_SYS_BUS_DEVICE, | 81 | return true; |
55 | .instance_size = sizeof(Exynos4210PWMState), | 82 | } |
56 | .instance_init = exynos4210_pwm_init, | 83 | |
57 | + .instance_finalize = exynos4210_pwm_finalize, | 84 | @@ -XXX,XX +XXX,XX @@ static bool do_2shift_narrow_64(DisasContext *s, arg_2reg_shift *a, |
58 | .class_init = exynos4210_pwm_class_init, | 85 | * This is always a right shift, and the shiftfn is always a |
59 | }; | 86 | * left-shift helper, which thus needs the negated shift count. |
87 | */ | ||
88 | - constimm = tcg_const_i64(-a->shift); | ||
89 | + constimm = tcg_constant_i64(-a->shift); | ||
90 | rm1 = tcg_temp_new_i64(); | ||
91 | rm2 = tcg_temp_new_i64(); | ||
92 | rd = tcg_temp_new_i32(); | ||
93 | @@ -XXX,XX +XXX,XX @@ static bool do_2shift_narrow_64(DisasContext *s, arg_2reg_shift *a, | ||
94 | tcg_temp_free_i32(rd); | ||
95 | tcg_temp_free_i64(rm1); | ||
96 | tcg_temp_free_i64(rm2); | ||
97 | - tcg_temp_free_i64(constimm); | ||
98 | |||
99 | return true; | ||
100 | } | ||
101 | @@ -XXX,XX +XXX,XX @@ static bool do_2shift_narrow_32(DisasContext *s, arg_2reg_shift *a, | ||
102 | /* size == 2 */ | ||
103 | imm = -a->shift; | ||
104 | } | ||
105 | - constimm = tcg_const_i32(imm); | ||
106 | + constimm = tcg_constant_i32(imm); | ||
107 | |||
108 | /* Load all inputs first to avoid potential overwrite */ | ||
109 | rm1 = tcg_temp_new_i32(); | ||
110 | @@ -XXX,XX +XXX,XX @@ static bool do_2shift_narrow_32(DisasContext *s, arg_2reg_shift *a, | ||
111 | |||
112 | shiftfn(rm3, rm3, constimm); | ||
113 | shiftfn(rm4, rm4, constimm); | ||
114 | - tcg_temp_free_i32(constimm); | ||
115 | |||
116 | tcg_gen_concat_i32_i64(rtmp, rm3, rm4); | ||
117 | tcg_temp_free_i32(rm4); | ||
118 | @@ -XXX,XX +XXX,XX @@ static bool trans_VTBL(DisasContext *s, arg_VTBL *a) | ||
119 | return true; | ||
120 | } | ||
121 | |||
122 | - desc = tcg_const_i32((a->vn << 2) | a->len); | ||
123 | + desc = tcg_constant_i32((a->vn << 2) | a->len); | ||
124 | def = tcg_temp_new_i64(); | ||
125 | if (a->op) { | ||
126 | read_neon_element64(def, a->vd, 0, MO_64); | ||
127 | @@ -XXX,XX +XXX,XX @@ static bool trans_VTBL(DisasContext *s, arg_VTBL *a) | ||
128 | |||
129 | tcg_temp_free_i64(def); | ||
130 | tcg_temp_free_i64(val); | ||
131 | - tcg_temp_free_i32(desc); | ||
132 | return true; | ||
133 | } | ||
60 | 134 | ||
61 | -- | 135 | -- |
62 | 2.20.1 | 136 | 2.25.1 |
63 | |||
64 | diff view generated by jsdifflib |
1 | From: Gan Qixin <ganqixin@huawei.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | When running device-introspect-test, a memory leak occurred in the | 3 | The operation we're performing with the movcond |
4 | exynos4210_rtc_init function, so use ptimer_free() in the finalize function to | 4 | is either min/max depending on cond -- simplify. |
5 | avoid it. | 5 | Use tcg_constant_i64 while we're at it. |
6 | 6 | ||
7 | ASAN shows memory leak stack: | 7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
8 | |||
9 | Indirect leak of 96 byte(s) in 1 object(s) allocated from: | ||
10 | #0 0xffffab97e1f0 in __interceptor_calloc (/lib64/libasan.so.5+0xee1f0) | ||
11 | #1 0xffffab256800 in g_malloc0 (/lib64/libglib-2.0.so.0+0x56800) | ||
12 | #2 0xaaabf555db78 in ptimer_init /qemu/hw/core/ptimer.c:432 | ||
13 | #3 0xaaabf57b3934 in exynos4210_rtc_init /qemu/hw/rtc/exynos4210_rtc.c:567 | ||
14 | #4 0xaaabf6339f6c in object_initialize_with_type /qemu/qom/object.c:515 | ||
15 | #5 0xaaabf633a1e0 in object_new_with_type /qemu/qom/object.c:729 | ||
16 | #6 0xaaabf6375e40 in qmp_device_list_properties /qemu/qom/qom-qmp-cmds.c:153 | ||
17 | #7 0xaaabf653d8ec in qmp_marshal_device_list_properties /qemu/qapi/qapi-commands-qdev.c:59 | ||
18 | #8 0xaaabf6587d08 in do_qmp_dispatch_bh /qemu/qapi/qmp-dispatch.c:110 | ||
19 | #9 0xaaabf6552708 in aio_bh_call /qemu/util/async.c:136 | ||
20 | #10 0xaaabf6552708 in aio_bh_poll /qemu/util/async.c:164 | ||
21 | #11 0xaaabf655f19c in aio_dispatch /qemu/util/aio-posix.c:381 | ||
22 | #12 0xaaabf65523f4 in aio_ctx_dispatch /qemu/util/async.c:306 | ||
23 | |||
24 | Reported-by: Euler Robot <euler.robot@huawei.com> | ||
25 | Signed-off-by: Gan Qixin <ganqixin@huawei.com> | ||
26 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
27 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
28 | --- | 10 | --- |
29 | hw/rtc/exynos4210_rtc.c | 9 +++++++++ | 11 | target/arm/translate-sve.c | 9 ++------- |
30 | 1 file changed, 9 insertions(+) | 12 | 1 file changed, 2 insertions(+), 7 deletions(-) |
31 | 13 | ||
32 | diff --git a/hw/rtc/exynos4210_rtc.c b/hw/rtc/exynos4210_rtc.c | 14 | diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c |
33 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
34 | --- a/hw/rtc/exynos4210_rtc.c | 16 | --- a/target/arm/translate-sve.c |
35 | +++ b/hw/rtc/exynos4210_rtc.c | 17 | +++ b/target/arm/translate-sve.c |
36 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_rtc_init(Object *obj) | 18 | @@ -XXX,XX +XXX,XX @@ static bool trans_PNEXT(DisasContext *s, arg_rr_esz *a) |
37 | sysbus_init_mmio(dev, &s->iomem); | 19 | static void do_sat_addsub_32(TCGv_i64 reg, TCGv_i64 val, bool u, bool d) |
20 | { | ||
21 | int64_t ibound; | ||
22 | - TCGv_i64 bound; | ||
23 | - TCGCond cond; | ||
24 | |||
25 | /* Use normal 64-bit arithmetic to detect 32-bit overflow. */ | ||
26 | if (u) { | ||
27 | @@ -XXX,XX +XXX,XX @@ static void do_sat_addsub_32(TCGv_i64 reg, TCGv_i64 val, bool u, bool d) | ||
28 | if (d) { | ||
29 | tcg_gen_sub_i64(reg, reg, val); | ||
30 | ibound = (u ? 0 : INT32_MIN); | ||
31 | - cond = TCG_COND_LT; | ||
32 | + tcg_gen_smax_i64(reg, reg, tcg_constant_i64(ibound)); | ||
33 | } else { | ||
34 | tcg_gen_add_i64(reg, reg, val); | ||
35 | ibound = (u ? UINT32_MAX : INT32_MAX); | ||
36 | - cond = TCG_COND_GT; | ||
37 | + tcg_gen_smin_i64(reg, reg, tcg_constant_i64(ibound)); | ||
38 | } | ||
39 | - bound = tcg_const_i64(ibound); | ||
40 | - tcg_gen_movcond_i64(cond, reg, reg, bound, bound, reg); | ||
41 | - tcg_temp_free_i64(bound); | ||
38 | } | 42 | } |
39 | 43 | ||
40 | +static void exynos4210_rtc_finalize(Object *obj) | 44 | /* Similarly with 64-bit values. */ |
41 | +{ | ||
42 | + Exynos4210RTCState *s = EXYNOS4210_RTC(obj); | ||
43 | + | ||
44 | + ptimer_free(s->ptimer); | ||
45 | + ptimer_free(s->ptimer_1Hz); | ||
46 | +} | ||
47 | + | ||
48 | static void exynos4210_rtc_class_init(ObjectClass *klass, void *data) | ||
49 | { | ||
50 | DeviceClass *dc = DEVICE_CLASS(klass); | ||
51 | @@ -XXX,XX +XXX,XX @@ static const TypeInfo exynos4210_rtc_info = { | ||
52 | .parent = TYPE_SYS_BUS_DEVICE, | ||
53 | .instance_size = sizeof(Exynos4210RTCState), | ||
54 | .instance_init = exynos4210_rtc_init, | ||
55 | + .instance_finalize = exynos4210_rtc_finalize, | ||
56 | .class_init = exynos4210_rtc_class_init, | ||
57 | }; | ||
58 | |||
59 | -- | 45 | -- |
60 | 2.20.1 | 46 | 2.25.1 |
61 | |||
62 | diff view generated by jsdifflib |
1 | From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Correct the indexing into s->cpu_ctlr for vCPUs. | 3 | Use tcg_constant_{i32,i64} as appropriate throughout. |
4 | 4 | ||
5 | Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> | 5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
6 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Luc Michel <luc.michel@greensocs.com> | ||
8 | Message-id: 20201214222154.3480243-2-edgar.iglesias@gmail.com | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 8 | --- |
11 | hw/intc/arm_gic.c | 4 +++- | 9 | target/arm/translate-vfp.c | 76 ++++++++++++-------------------------- |
12 | 1 file changed, 3 insertions(+), 1 deletion(-) | 10 | 1 file changed, 23 insertions(+), 53 deletions(-) |
13 | 11 | ||
14 | diff --git a/hw/intc/arm_gic.c b/hw/intc/arm_gic.c | 12 | diff --git a/target/arm/translate-vfp.c b/target/arm/translate-vfp.c |
15 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/hw/intc/arm_gic.c | 14 | --- a/target/arm/translate-vfp.c |
17 | +++ b/hw/intc/arm_gic.c | 15 | +++ b/target/arm/translate-vfp.c |
18 | @@ -XXX,XX +XXX,XX @@ static inline void gic_get_best_virq(GICState *s, int cpu, | 16 | @@ -XXX,XX +XXX,XX @@ static void gen_update_fp_context(DisasContext *s) |
19 | static inline bool gic_irq_signaling_enabled(GICState *s, int cpu, bool virt, | 17 | gen_helper_vfp_set_fpscr(cpu_env, fpscr); |
20 | int group_mask) | 18 | tcg_temp_free_i32(fpscr); |
19 | if (dc_isar_feature(aa32_mve, s)) { | ||
20 | - TCGv_i32 z32 = tcg_const_i32(0); | ||
21 | - store_cpu_field(z32, v7m.vpr); | ||
22 | + store_cpu_field(tcg_constant_i32(0), v7m.vpr); | ||
23 | } | ||
24 | /* | ||
25 | * We just updated the FPSCR and VPR. Some of this state is cached | ||
26 | @@ -XXX,XX +XXX,XX @@ static bool trans_VSEL(DisasContext *s, arg_VSEL *a) | ||
27 | TCGv_i64 frn, frm, dest; | ||
28 | TCGv_i64 tmp, zero, zf, nf, vf; | ||
29 | |||
30 | - zero = tcg_const_i64(0); | ||
31 | + zero = tcg_constant_i64(0); | ||
32 | |||
33 | frn = tcg_temp_new_i64(); | ||
34 | frm = tcg_temp_new_i64(); | ||
35 | @@ -XXX,XX +XXX,XX @@ static bool trans_VSEL(DisasContext *s, arg_VSEL *a) | ||
36 | vfp_load_reg64(frm, rm); | ||
37 | switch (a->cc) { | ||
38 | case 0: /* eq: Z */ | ||
39 | - tcg_gen_movcond_i64(TCG_COND_EQ, dest, zf, zero, | ||
40 | - frn, frm); | ||
41 | + tcg_gen_movcond_i64(TCG_COND_EQ, dest, zf, zero, frn, frm); | ||
42 | break; | ||
43 | case 1: /* vs: V */ | ||
44 | - tcg_gen_movcond_i64(TCG_COND_LT, dest, vf, zero, | ||
45 | - frn, frm); | ||
46 | + tcg_gen_movcond_i64(TCG_COND_LT, dest, vf, zero, frn, frm); | ||
47 | break; | ||
48 | case 2: /* ge: N == V -> N ^ V == 0 */ | ||
49 | tmp = tcg_temp_new_i64(); | ||
50 | tcg_gen_xor_i64(tmp, vf, nf); | ||
51 | - tcg_gen_movcond_i64(TCG_COND_GE, dest, tmp, zero, | ||
52 | - frn, frm); | ||
53 | + tcg_gen_movcond_i64(TCG_COND_GE, dest, tmp, zero, frn, frm); | ||
54 | tcg_temp_free_i64(tmp); | ||
55 | break; | ||
56 | case 3: /* gt: !Z && N == V */ | ||
57 | - tcg_gen_movcond_i64(TCG_COND_NE, dest, zf, zero, | ||
58 | - frn, frm); | ||
59 | + tcg_gen_movcond_i64(TCG_COND_NE, dest, zf, zero, frn, frm); | ||
60 | tmp = tcg_temp_new_i64(); | ||
61 | tcg_gen_xor_i64(tmp, vf, nf); | ||
62 | - tcg_gen_movcond_i64(TCG_COND_GE, dest, tmp, zero, | ||
63 | - dest, frm); | ||
64 | + tcg_gen_movcond_i64(TCG_COND_GE, dest, tmp, zero, dest, frm); | ||
65 | tcg_temp_free_i64(tmp); | ||
66 | break; | ||
67 | } | ||
68 | @@ -XXX,XX +XXX,XX @@ static bool trans_VSEL(DisasContext *s, arg_VSEL *a) | ||
69 | tcg_temp_free_i64(zf); | ||
70 | tcg_temp_free_i64(nf); | ||
71 | tcg_temp_free_i64(vf); | ||
72 | - | ||
73 | - tcg_temp_free_i64(zero); | ||
74 | } else { | ||
75 | TCGv_i32 frn, frm, dest; | ||
76 | TCGv_i32 tmp, zero; | ||
77 | |||
78 | - zero = tcg_const_i32(0); | ||
79 | + zero = tcg_constant_i32(0); | ||
80 | |||
81 | frn = tcg_temp_new_i32(); | ||
82 | frm = tcg_temp_new_i32(); | ||
83 | @@ -XXX,XX +XXX,XX @@ static bool trans_VSEL(DisasContext *s, arg_VSEL *a) | ||
84 | vfp_load_reg32(frm, rm); | ||
85 | switch (a->cc) { | ||
86 | case 0: /* eq: Z */ | ||
87 | - tcg_gen_movcond_i32(TCG_COND_EQ, dest, cpu_ZF, zero, | ||
88 | - frn, frm); | ||
89 | + tcg_gen_movcond_i32(TCG_COND_EQ, dest, cpu_ZF, zero, frn, frm); | ||
90 | break; | ||
91 | case 1: /* vs: V */ | ||
92 | - tcg_gen_movcond_i32(TCG_COND_LT, dest, cpu_VF, zero, | ||
93 | - frn, frm); | ||
94 | + tcg_gen_movcond_i32(TCG_COND_LT, dest, cpu_VF, zero, frn, frm); | ||
95 | break; | ||
96 | case 2: /* ge: N == V -> N ^ V == 0 */ | ||
97 | tmp = tcg_temp_new_i32(); | ||
98 | tcg_gen_xor_i32(tmp, cpu_VF, cpu_NF); | ||
99 | - tcg_gen_movcond_i32(TCG_COND_GE, dest, tmp, zero, | ||
100 | - frn, frm); | ||
101 | + tcg_gen_movcond_i32(TCG_COND_GE, dest, tmp, zero, frn, frm); | ||
102 | tcg_temp_free_i32(tmp); | ||
103 | break; | ||
104 | case 3: /* gt: !Z && N == V */ | ||
105 | - tcg_gen_movcond_i32(TCG_COND_NE, dest, cpu_ZF, zero, | ||
106 | - frn, frm); | ||
107 | + tcg_gen_movcond_i32(TCG_COND_NE, dest, cpu_ZF, zero, frn, frm); | ||
108 | tmp = tcg_temp_new_i32(); | ||
109 | tcg_gen_xor_i32(tmp, cpu_VF, cpu_NF); | ||
110 | - tcg_gen_movcond_i32(TCG_COND_GE, dest, tmp, zero, | ||
111 | - dest, frm); | ||
112 | + tcg_gen_movcond_i32(TCG_COND_GE, dest, tmp, zero, dest, frm); | ||
113 | tcg_temp_free_i32(tmp); | ||
114 | break; | ||
115 | } | ||
116 | @@ -XXX,XX +XXX,XX @@ static bool trans_VSEL(DisasContext *s, arg_VSEL *a) | ||
117 | tcg_temp_free_i32(frn); | ||
118 | tcg_temp_free_i32(frm); | ||
119 | tcg_temp_free_i32(dest); | ||
120 | - | ||
121 | - tcg_temp_free_i32(zero); | ||
122 | } | ||
123 | |||
124 | return true; | ||
125 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT(DisasContext *s, arg_VCVT *a) | ||
126 | fpst = fpstatus_ptr(FPST_FPCR); | ||
127 | } | ||
128 | |||
129 | - tcg_shift = tcg_const_i32(0); | ||
130 | + tcg_shift = tcg_constant_i32(0); | ||
131 | |||
132 | tcg_rmode = tcg_const_i32(arm_rmode_to_sf(rounding)); | ||
133 | gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst); | ||
134 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT(DisasContext *s, arg_VCVT *a) | ||
135 | gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst); | ||
136 | tcg_temp_free_i32(tcg_rmode); | ||
137 | |||
138 | - tcg_temp_free_i32(tcg_shift); | ||
139 | - | ||
140 | tcg_temp_free_ptr(fpst); | ||
141 | |||
142 | return true; | ||
143 | @@ -XXX,XX +XXX,XX @@ static bool trans_VMSR_VMRS(DisasContext *s, arg_VMSR_VMRS *a) | ||
144 | case ARM_VFP_MVFR2: | ||
145 | case ARM_VFP_FPSID: | ||
146 | if (s->current_el == 1) { | ||
147 | - TCGv_i32 tcg_reg, tcg_rt; | ||
148 | - | ||
149 | gen_set_condexec(s); | ||
150 | gen_set_pc_im(s, s->pc_curr); | ||
151 | - tcg_reg = tcg_const_i32(a->reg); | ||
152 | - tcg_rt = tcg_const_i32(a->rt); | ||
153 | - gen_helper_check_hcr_el2_trap(cpu_env, tcg_rt, tcg_reg); | ||
154 | - tcg_temp_free_i32(tcg_reg); | ||
155 | - tcg_temp_free_i32(tcg_rt); | ||
156 | + gen_helper_check_hcr_el2_trap(cpu_env, | ||
157 | + tcg_constant_i32(a->rt), | ||
158 | + tcg_constant_i32(a->reg)); | ||
159 | } | ||
160 | /* fall through */ | ||
161 | case ARM_VFP_FPEXC: | ||
162 | @@ -XXX,XX +XXX,XX @@ MAKE_VFM_TRANS_FNS(dp) | ||
163 | |||
164 | static bool trans_VMOV_imm_hp(DisasContext *s, arg_VMOV_imm_sp *a) | ||
21 | { | 165 | { |
22 | + int cpu_iface = virt ? (cpu + GIC_NCPU) : cpu; | 166 | - TCGv_i32 fd; |
23 | + | 167 | - |
24 | if (!virt && !(s->ctlr & group_mask)) { | 168 | if (!dc_isar_feature(aa32_fp16_arith, s)) { |
25 | return false; | 169 | return false; |
26 | } | 170 | } |
27 | @@ -XXX,XX +XXX,XX @@ static inline bool gic_irq_signaling_enabled(GICState *s, int cpu, bool virt, | 171 | @@ -XXX,XX +XXX,XX @@ static bool trans_VMOV_imm_hp(DisasContext *s, arg_VMOV_imm_sp *a) |
28 | return false; | 172 | return true; |
29 | } | 173 | } |
30 | 174 | ||
31 | - if (!(s->cpu_ctlr[cpu] & group_mask)) { | 175 | - fd = tcg_const_i32(vfp_expand_imm(MO_16, a->imm)); |
32 | + if (!(s->cpu_ctlr[cpu_iface] & group_mask)) { | 176 | - vfp_store_reg32(fd, a->vd); |
33 | return false; | 177 | - tcg_temp_free_i32(fd); |
34 | } | 178 | + vfp_store_reg32(tcg_constant_i32(vfp_expand_imm(MO_16, a->imm)), a->vd); |
35 | 179 | return true; | |
180 | } | ||
181 | |||
182 | @@ -XXX,XX +XXX,XX @@ static bool trans_VMOV_imm_sp(DisasContext *s, arg_VMOV_imm_sp *a) | ||
183 | } | ||
184 | } | ||
185 | |||
186 | - fd = tcg_const_i32(vfp_expand_imm(MO_32, a->imm)); | ||
187 | + fd = tcg_constant_i32(vfp_expand_imm(MO_32, a->imm)); | ||
188 | |||
189 | for (;;) { | ||
190 | vfp_store_reg32(fd, vd); | ||
191 | @@ -XXX,XX +XXX,XX @@ static bool trans_VMOV_imm_sp(DisasContext *s, arg_VMOV_imm_sp *a) | ||
192 | vd = vfp_advance_sreg(vd, delta_d); | ||
193 | } | ||
194 | |||
195 | - tcg_temp_free_i32(fd); | ||
196 | return true; | ||
197 | } | ||
198 | |||
199 | @@ -XXX,XX +XXX,XX @@ static bool trans_VMOV_imm_dp(DisasContext *s, arg_VMOV_imm_dp *a) | ||
200 | } | ||
201 | } | ||
202 | |||
203 | - fd = tcg_const_i64(vfp_expand_imm(MO_64, a->imm)); | ||
204 | + fd = tcg_constant_i64(vfp_expand_imm(MO_64, a->imm)); | ||
205 | |||
206 | for (;;) { | ||
207 | vfp_store_reg64(fd, vd); | ||
208 | @@ -XXX,XX +XXX,XX @@ static bool trans_VMOV_imm_dp(DisasContext *s, arg_VMOV_imm_dp *a) | ||
209 | vd = vfp_advance_dreg(vd, delta_d); | ||
210 | } | ||
211 | |||
212 | - tcg_temp_free_i64(fd); | ||
213 | return true; | ||
214 | } | ||
215 | |||
216 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_fix_hp(DisasContext *s, arg_VCVT_fix_sp *a) | ||
217 | vfp_load_reg32(vd, a->vd); | ||
218 | |||
219 | fpst = fpstatus_ptr(FPST_FPCR_F16); | ||
220 | - shift = tcg_const_i32(frac_bits); | ||
221 | + shift = tcg_constant_i32(frac_bits); | ||
222 | |||
223 | /* Switch on op:U:sx bits */ | ||
224 | switch (a->opc) { | ||
225 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_fix_hp(DisasContext *s, arg_VCVT_fix_sp *a) | ||
226 | |||
227 | vfp_store_reg32(vd, a->vd); | ||
228 | tcg_temp_free_i32(vd); | ||
229 | - tcg_temp_free_i32(shift); | ||
230 | tcg_temp_free_ptr(fpst); | ||
231 | return true; | ||
232 | } | ||
233 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_fix_sp(DisasContext *s, arg_VCVT_fix_sp *a) | ||
234 | vfp_load_reg32(vd, a->vd); | ||
235 | |||
236 | fpst = fpstatus_ptr(FPST_FPCR); | ||
237 | - shift = tcg_const_i32(frac_bits); | ||
238 | + shift = tcg_constant_i32(frac_bits); | ||
239 | |||
240 | /* Switch on op:U:sx bits */ | ||
241 | switch (a->opc) { | ||
242 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_fix_sp(DisasContext *s, arg_VCVT_fix_sp *a) | ||
243 | |||
244 | vfp_store_reg32(vd, a->vd); | ||
245 | tcg_temp_free_i32(vd); | ||
246 | - tcg_temp_free_i32(shift); | ||
247 | tcg_temp_free_ptr(fpst); | ||
248 | return true; | ||
249 | } | ||
250 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_fix_dp(DisasContext *s, arg_VCVT_fix_dp *a) | ||
251 | vfp_load_reg64(vd, a->vd); | ||
252 | |||
253 | fpst = fpstatus_ptr(FPST_FPCR); | ||
254 | - shift = tcg_const_i32(frac_bits); | ||
255 | + shift = tcg_constant_i32(frac_bits); | ||
256 | |||
257 | /* Switch on op:U:sx bits */ | ||
258 | switch (a->opc) { | ||
259 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_fix_dp(DisasContext *s, arg_VCVT_fix_dp *a) | ||
260 | |||
261 | vfp_store_reg64(vd, a->vd); | ||
262 | tcg_temp_free_i64(vd); | ||
263 | - tcg_temp_free_i32(shift); | ||
264 | tcg_temp_free_ptr(fpst); | ||
265 | return true; | ||
266 | } | ||
36 | -- | 267 | -- |
37 | 2.20.1 | 268 | 2.25.1 |
38 | |||
39 | diff view generated by jsdifflib |
1 | From: Gan Qixin <ganqixin@huawei.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | When running device-introspect-test, a memory leak occurred in the | 3 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
4 | digic_timer_init function, so use ptimer_free() in the finalize function to | ||
5 | avoid it. | ||
6 | |||
7 | ASAN shows memory leak stack: | ||
8 | |||
9 | Indirect leak of 288 byte(s) in 3 object(s) allocated from: | ||
10 | #0 0xffffab97e1f0 in __interceptor_calloc (/lib64/libasan.so.5+0xee1f0) | ||
11 | #1 0xffffab256800 in g_malloc0 (/lib64/libglib-2.0.so.0+0x56800) | ||
12 | #2 0xaaabf555db78 in ptimer_init /qemu/hw/core/ptimer.c:432 | ||
13 | #3 0xaaabf5b04084 in digic_timer_init /qemu/hw/timer/digic-timer.c:142 | ||
14 | #4 0xaaabf6339f6c in object_initialize_with_type /qemu/qom/object.c:515 | ||
15 | #5 0xaaabf633ca04 in object_initialize_child_with_propsv /qemu/qom/object.c:564 | ||
16 | #6 0xaaabf633cc08 in object_initialize_child_with_props /qemu/qom/object.c:547 | ||
17 | #7 0xaaabf5b40e84 in digic_init /qemu/hw/arm/digic.c:46 | ||
18 | #8 0xaaabf6339f6c in object_initialize_with_type /qemu/qom/object.c:515 | ||
19 | #9 0xaaabf633a1e0 in object_new_with_type /qemu/qom/object.c:729 | ||
20 | #10 0xaaabf6375e40 in qmp_device_list_properties /qemu/qom/qom-qmp-cmds.c:153 | ||
21 | #11 0xaaabf653d8ec in qmp_marshal_device_list_properties /qemu/qapi/qapi-commands-qdev.c:59 | ||
22 | #12 0xaaabf6587d08 in do_qmp_dispatch_bh /qemu/qapi/qmp-dispatch.c:110 | ||
23 | |||
24 | Reported-by: Euler Robot <euler.robot@huawei.com> | ||
25 | Signed-off-by: Gan Qixin <ganqixin@huawei.com> | ||
26 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 4 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
27 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
28 | --- | 6 | --- |
29 | hw/timer/digic-timer.c | 8 ++++++++ | 7 | target/arm/translate.h | 13 +++---------- |
30 | 1 file changed, 8 insertions(+) | 8 | 1 file changed, 3 insertions(+), 10 deletions(-) |
31 | 9 | ||
32 | diff --git a/hw/timer/digic-timer.c b/hw/timer/digic-timer.c | 10 | diff --git a/target/arm/translate.h b/target/arm/translate.h |
33 | index XXXXXXX..XXXXXXX 100644 | 11 | index XXXXXXX..XXXXXXX 100644 |
34 | --- a/hw/timer/digic-timer.c | 12 | --- a/target/arm/translate.h |
35 | +++ b/hw/timer/digic-timer.c | 13 | +++ b/target/arm/translate.h |
36 | @@ -XXX,XX +XXX,XX @@ static void digic_timer_init(Object *obj) | 14 | @@ -XXX,XX +XXX,XX @@ static inline void gen_ss_advance(DisasContext *s) |
37 | sysbus_init_mmio(SYS_BUS_DEVICE(obj), &s->iomem); | 15 | static inline void gen_exception(int excp, uint32_t syndrome, |
16 | uint32_t target_el) | ||
17 | { | ||
18 | - TCGv_i32 tcg_excp = tcg_const_i32(excp); | ||
19 | - TCGv_i32 tcg_syn = tcg_const_i32(syndrome); | ||
20 | - TCGv_i32 tcg_el = tcg_const_i32(target_el); | ||
21 | - | ||
22 | - gen_helper_exception_with_syndrome(cpu_env, tcg_excp, | ||
23 | - tcg_syn, tcg_el); | ||
24 | - | ||
25 | - tcg_temp_free_i32(tcg_el); | ||
26 | - tcg_temp_free_i32(tcg_syn); | ||
27 | - tcg_temp_free_i32(tcg_excp); | ||
28 | + gen_helper_exception_with_syndrome(cpu_env, tcg_constant_i32(excp), | ||
29 | + tcg_constant_i32(syndrome), | ||
30 | + tcg_constant_i32(target_el)); | ||
38 | } | 31 | } |
39 | 32 | ||
40 | +static void digic_timer_finalize(Object *obj) | 33 | /* Generate an architectural singlestep exception */ |
41 | +{ | ||
42 | + DigicTimerState *s = DIGIC_TIMER(obj); | ||
43 | + | ||
44 | + ptimer_free(s->ptimer); | ||
45 | +} | ||
46 | + | ||
47 | static void digic_timer_class_init(ObjectClass *klass, void *class_data) | ||
48 | { | ||
49 | DeviceClass *dc = DEVICE_CLASS(klass); | ||
50 | @@ -XXX,XX +XXX,XX @@ static const TypeInfo digic_timer_info = { | ||
51 | .parent = TYPE_SYS_BUS_DEVICE, | ||
52 | .instance_size = sizeof(DigicTimerState), | ||
53 | .instance_init = digic_timer_init, | ||
54 | + .instance_finalize = digic_timer_finalize, | ||
55 | .class_init = digic_timer_class_init, | ||
56 | }; | ||
57 | |||
58 | -- | 34 | -- |
59 | 2.20.1 | 35 | 2.25.1 |
60 | |||
61 | diff view generated by jsdifflib |
1 | From: Bin Meng <bin.meng@windriver.com> | 1 | From: Xiang Chen <chenxiang66@hisilicon.com> |
---|---|---|---|
2 | 2 | ||
3 | U-Boot expects PMU_MISC0 register bit 7 is set (see init_bandgap() | 3 | It always calls the IOMMU MR translate() callback with flag=IOMMU_NONE in |
4 | in arch/arm/mach-imx/mx6/soc.c) during boot. This bit indicates the | 4 | memory_region_iommu_replay(). Currently, smmuv3_translate() return an |
5 | bandgap has stabilized. | 5 | IOMMUTLBEntry with perm set to IOMMU_NONE even if the translation success, |
6 | whereas it is expected to return the actual permission set in the table | ||
7 | entry. | ||
8 | So pass the actual perm to returned IOMMUTLBEntry in the table entry. | ||
6 | 9 | ||
7 | With this change, the latest upstream U-Boot (v2021.01-rc3) for imx6 | 10 | Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com> |
8 | sabrelite board (mx6qsabrelite_defconfig), with a slight change made | 11 | Reviewed-by: Eric Auger <eric.auger@redhat.com> |
9 | by switching CONFIG_OF_SEPARATE to CONFIG_OF_EMBED, boots to U-Boot | 12 | Message-id: 1650094695-121918-1-git-send-email-chenxiang66@hisilicon.com |
10 | shell on QEMU with the following command: | ||
11 | |||
12 | $ qemu-system-arm -M sabrelite -smp 4 -m 1G -kernel u-boot \ | ||
13 | -display none -serial null -serial stdio | ||
14 | |||
15 | Boot log below: | ||
16 | |||
17 | U-Boot 2021.01-rc3 (Dec 12 2020 - 17:40:02 +0800) | ||
18 | |||
19 | CPU: Freescale i.MX?? rev1.0 at 792 MHz | ||
20 | Reset cause: POR | ||
21 | Model: Freescale i.MX6 Quad SABRE Lite Board | ||
22 | Board: SABRE Lite | ||
23 | I2C: ready | ||
24 | DRAM: 1 GiB | ||
25 | force_idle_bus: sda=0 scl=0 sda.gp=0x5c scl.gp=0x55 | ||
26 | force_idle_bus: failed to clear bus, sda=0 scl=0 | ||
27 | force_idle_bus: sda=0 scl=0 sda.gp=0x6d scl.gp=0x6c | ||
28 | force_idle_bus: failed to clear bus, sda=0 scl=0 | ||
29 | force_idle_bus: sda=0 scl=0 sda.gp=0xcb scl.gp=0x5 | ||
30 | force_idle_bus: failed to clear bus, sda=0 scl=0 | ||
31 | MMC: FSL_SDHC: 0, FSL_SDHC: 1 | ||
32 | Loading Environment from MMC... *** Warning - No block device, using default environment | ||
33 | |||
34 | In: serial | ||
35 | Out: serial | ||
36 | Err: serial | ||
37 | Net: Board Net Initialization Failed | ||
38 | No ethernet found. | ||
39 | starting USB... | ||
40 | Bus usb@2184000: usb dr_mode not found | ||
41 | USB EHCI 1.00 | ||
42 | Bus usb@2184200: USB EHCI 1.00 | ||
43 | scanning bus usb@2184000 for devices... 1 USB Device(s) found | ||
44 | scanning bus usb@2184200 for devices... 1 USB Device(s) found | ||
45 | scanning usb for storage devices... 0 Storage Device(s) found | ||
46 | scanning usb for ethernet devices... 0 Ethernet Device(s) found | ||
47 | Hit any key to stop autoboot: 0 | ||
48 | => | ||
49 | |||
50 | Signed-off-by: Bin Meng <bin.meng@windriver.com> | ||
51 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
52 | Message-id: 20210106063504.10841-2-bmeng.cn@gmail.com | ||
53 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
54 | --- | 14 | --- |
55 | hw/misc/imx6_ccm.c | 2 +- | 15 | hw/arm/smmuv3.c | 2 +- |
56 | 1 file changed, 1 insertion(+), 1 deletion(-) | 16 | 1 file changed, 1 insertion(+), 1 deletion(-) |
57 | 17 | ||
58 | diff --git a/hw/misc/imx6_ccm.c b/hw/misc/imx6_ccm.c | 18 | diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c |
59 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
60 | --- a/hw/misc/imx6_ccm.c | 20 | --- a/hw/arm/smmuv3.c |
61 | +++ b/hw/misc/imx6_ccm.c | 21 | +++ b/hw/arm/smmuv3.c |
62 | @@ -XXX,XX +XXX,XX @@ static void imx6_ccm_reset(DeviceState *dev) | 22 | @@ -XXX,XX +XXX,XX @@ epilogue: |
63 | s->analog[PMU_REG_3P0] = 0x00000F74; | 23 | qemu_mutex_unlock(&s->mutex); |
64 | s->analog[PMU_REG_2P5] = 0x00005071; | 24 | switch (status) { |
65 | s->analog[PMU_REG_CORE] = 0x00402010; | 25 | case SMMU_TRANS_SUCCESS: |
66 | - s->analog[PMU_MISC0] = 0x04000000; | 26 | - entry.perm = flag; |
67 | + s->analog[PMU_MISC0] = 0x04000080; | 27 | + entry.perm = cached_entry->entry.perm; |
68 | s->analog[PMU_MISC1] = 0x00000000; | 28 | entry.translated_addr = cached_entry->entry.translated_addr + |
69 | s->analog[PMU_MISC2] = 0x00272727; | 29 | (addr & cached_entry->entry.addr_mask); |
70 | 30 | entry.addr_mask = cached_entry->entry.addr_mask; | |
71 | -- | 31 | -- |
72 | 2.20.1 | 32 | 2.25.1 |
73 | |||
74 | diff view generated by jsdifflib |