1 | First arm pullreq of 5.0! | 1 | Nothing too exciting, but does include the last bits of v8.1M support work. |
---|---|---|---|
2 | 2 | ||
3 | The following changes since commit 084a398bf8aa7634738e6c6c0103236ee1b3b72f: | 3 | -- PMM |
4 | 4 | ||
5 | Merge remote-tracking branch 'remotes/stefanha/tags/block-pull-request' into staging (2019-12-13 18:14:07 +0000) | 5 | The following changes since commit e79de63ab1bd1f6550e7b915e433bec1ad1a870a: |
6 | |||
7 | Merge remote-tracking branch 'remotes/rth-gitlab/tags/pull-tcg-20210107' into staging (2021-01-07 20:34:05 +0000) | ||
6 | 8 | ||
7 | are available in the Git repository at: | 9 | are available in the Git repository at: |
8 | 10 | ||
9 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20191216-1 | 11 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20210108 |
10 | 12 | ||
11 | for you to fetch changes up to f80741d107673f162e3b097fc76a1590036cc9d1: | 13 | for you to fetch changes up to c9f8511ea8d2b80723af0fea1f716d752c1b5208: |
12 | 14 | ||
13 | target/arm: ensure we use current exception state after SCR update (2019-12-16 10:52:58 +0000) | 15 | docs/system: arm: Add sabrelite board description (2021-01-08 15:13:39 +0000) |
14 | 16 | ||
15 | ---------------------------------------------------------------- | 17 | ---------------------------------------------------------------- |
16 | target-arm queue: | 18 | target-arm queue: |
17 | * Add support for Cortex-M7 CPU | 19 | * intc/arm_gic: Fix gic_irq_signaling_enabled() for vCPUs |
18 | * exynos4210_gic: Suppress gcc9 format-truncation warnings | 20 | * target/arm: Fix MTE0_ACTIVE |
19 | * aspeed: Various minor bug fixes and improvements | 21 | * target/arm: Implement v8.1M and Cortex-M55 model |
20 | * aspeed: Add support for the tacoma-bmc board | 22 | * hw/arm/highbank: Drop dead KVM support code |
21 | * Honour HCR_EL32.TID1 and .TID2 trapping requirements | 23 | * util/qemu-timer: Make timer_free() imply timer_del() |
22 | * Handle trapping to EL2 of AArch32 VMRS instructions | 24 | * various devices: Use ptimer_free() in finalize function |
23 | * Handle AArch32 CP15 trapping via HSTR_EL2 | 25 | * docs/system: arm: Add sabrelite board description |
24 | * Add support for missing Jazelle system registers | 26 | * sabrelite: Minor fixes to allow booting U-Boot |
25 | * arm/arm-powerctl: set NSACR.{CP11, CP10} bits in arm_set_cpu_on | ||
26 | * Add support for DC CVAP & DC CVADP instructions | ||
27 | * Fix assertion when SCR.NS is changed in Secure-SVC &c | ||
28 | * enable SHPC native hot plug in arm ACPI | ||
29 | 27 | ||
30 | ---------------------------------------------------------------- | 28 | ---------------------------------------------------------------- |
31 | Alex Bennée (1): | 29 | Andrew Jones (1): |
32 | target/arm: ensure we use current exception state after SCR update | 30 | hw/arm/virt: Remove virt machine state 'smp_cpus' |
33 | 31 | ||
34 | Beata Michalska (4): | 32 | Bin Meng (4): |
35 | tcg: cputlb: Add probe_read | 33 | hw/misc: imx6_ccm: Update PMU_MISC0 reset value |
36 | Memory: Enable writeback for given memory region | 34 | hw/msic: imx6_ccm: Correct register value for silicon type |
37 | migration: ram: Switch to ram block writeback | 35 | hw/arm: sabrelite: Connect the Ethernet PHY at address 6 |
38 | target/arm: Add support for DC CVAP & DC CVADP ins | 36 | docs/system: arm: Add sabrelite board description |
39 | 37 | ||
40 | Christophe Lyon (1): | 38 | Edgar E. Iglesias (1): |
41 | target/arm: Add support for cortex-m7 CPU | 39 | intc/arm_gic: Fix gic_irq_signaling_enabled() for vCPUs |
42 | 40 | ||
43 | Cédric Le Goater (12): | 41 | Gan Qixin (7): |
44 | aspeed/i2c: Add support for pool buffer transfers | 42 | digic-timer: Use ptimer_free() in the finalize function to avoid memleaks |
45 | aspeed/i2c: Check SRAM enablement on AST2500 | 43 | allwinner-a10-pit: Use ptimer_free() in the finalize function to avoid memleaks |
46 | aspeed: Add a DRAM memory region at the SoC level | 44 | exynos4210_rtc: Use ptimer_free() in the finalize function to avoid memleaks |
47 | aspeed/i2c: Add support for DMA transfers | 45 | exynos4210_pwm: Use ptimer_free() in the finalize function to avoid memleaks |
48 | aspeed/i2c: Add trace events | 46 | mss-timer: Use ptimer_free() in the finalize function to avoid memleaks |
49 | aspeed/smc: Restore default AHB window mapping at reset | 47 | musicpal: Use ptimer_free() in the finalize function to avoid memleaks |
50 | aspeed/smc: Do not map disabled segment on the AST2600 | 48 | exynos4210_mct: Use ptimer_free() in the finalize function to avoid memleaks |
51 | aspeed/smc: Add AST2600 timings registers | ||
52 | aspeed: Remove AspeedBoardConfig array and use AspeedMachineClass | ||
53 | aspeed: Add support for the tacoma-bmc board | ||
54 | aspeed: Change the "scu" property definition | ||
55 | aspeed: Change the "nic" property definition | ||
56 | 49 | ||
57 | David Gibson (1): | 50 | Peter Maydell (9): |
58 | exynos4210_gic: Suppress gcc9 format-truncation warnings | 51 | hw/intc/armv7m_nvic: Correct handling of CCR.BFHFNMIGN |
52 | target/arm: Correct store of FPSCR value via FPCXT_S | ||
53 | target/arm: Implement FPCXT_NS fp system register | ||
54 | target/arm: Implement Cortex-M55 model | ||
55 | hw/arm/highbank: Drop dead KVM support code | ||
56 | util/qemu-timer: Make timer_free() imply timer_del() | ||
57 | scripts/coccinelle: New script to remove unnecessary timer_del() calls | ||
58 | Remove superfluous timer_del() calls | ||
59 | target/arm: Remove timer_del()/timer_deinit() before timer_free() | ||
59 | 60 | ||
60 | Heyi Guo (2): | 61 | Richard Henderson (1): |
61 | hw/arm/acpi: simplify AML bit and/or statement | 62 | target/arm: Fix MTE0_ACTIVE |
62 | hw/arm/acpi: enable SHPC native hot plug | ||
63 | 63 | ||
64 | Joel Stanley (4): | 64 | docs/system/arm/sabrelite.rst | 119 ++++++++++++++++++++++++++ |
65 | aspeed/sdmc: Make ast2600 default 1G | 65 | docs/system/target-arm.rst | 1 + |
66 | aspeed/scu: Fix W1C behavior | 66 | scripts/coccinelle/timer-del-timer-free.cocci | 18 ++++ |
67 | watchdog/aspeed: Improve watchdog timeout message | 67 | include/hw/arm/virt.h | 3 +- |
68 | watchdog/aspeed: Fix AST2600 frequency behaviour | 68 | include/qemu/timer.h | 24 +++--- |
69 | block/iscsi.c | 2 - | ||
70 | block/nbd.c | 1 - | ||
71 | block/qcow2.c | 1 - | ||
72 | hw/arm/highbank.c | 14 +-- | ||
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 | ||
69 | 132 | ||
70 | Marc Zyngier (5): | ||
71 | target/arm: Honor HCR_EL2.TID2 trapping requirements | ||
72 | target/arm: Honor HCR_EL2.TID1 trapping requirements | ||
73 | target/arm: Handle trapping to EL2 of AArch32 VMRS instructions | ||
74 | target/arm: Handle AArch32 CP15 trapping via HSTR_EL2 | ||
75 | target/arm: Add support for missing Jazelle system registers | ||
76 | |||
77 | Niek Linnenbank (1): | ||
78 | arm/arm-powerctl: set NSACR.{CP11, CP10} bits in arm_set_cpu_on() | ||
79 | |||
80 | PanNengyuan (1): | ||
81 | gpio: fix memory leak in aspeed_gpio_init() | ||
82 | |||
83 | Philippe Mathieu-Daudé (2): | ||
84 | hw/arm/sbsa-ref: Simplify by moving the gic in the machine state | ||
85 | hw/arm/virt: Simplify by moving the gic in the machine state | ||
86 | |||
87 | include/exec/exec-all.h | 6 + | ||
88 | include/exec/memory.h | 6 + | ||
89 | include/exec/ram_addr.h | 8 + | ||
90 | include/hw/arm/aspeed.h | 24 +-- | ||
91 | include/hw/arm/aspeed_soc.h | 1 + | ||
92 | include/hw/arm/virt.h | 1 + | ||
93 | include/hw/i2c/aspeed_i2c.h | 16 ++ | ||
94 | include/hw/ssi/aspeed_smc.h | 1 + | ||
95 | include/hw/watchdog/wdt_aspeed.h | 1 + | ||
96 | include/qemu/cutils.h | 1 + | ||
97 | target/arm/cpu.h | 20 +- | ||
98 | target/arm/helper.h | 3 + | ||
99 | target/arm/translate.h | 2 + | ||
100 | exec.c | 36 ++++ | ||
101 | hw/arm/aspeed.c | 271 +++++++++++++---------- | ||
102 | hw/arm/aspeed_ast2600.c | 25 ++- | ||
103 | hw/arm/aspeed_soc.c | 22 +- | ||
104 | hw/arm/sbsa-ref.c | 86 ++++---- | ||
105 | hw/arm/virt-acpi-build.c | 21 +- | ||
106 | hw/arm/virt.c | 109 +++++----- | ||
107 | hw/gpio/aspeed_gpio.c | 1 + | ||
108 | hw/i2c/aspeed_i2c.c | 439 +++++++++++++++++++++++++++++++++++--- | ||
109 | hw/intc/exynos4210_gic.c | 9 +- | ||
110 | hw/misc/aspeed_scu.c | 19 +- | ||
111 | hw/misc/aspeed_sdmc.c | 6 +- | ||
112 | hw/net/ftgmac100.c | 19 +- | ||
113 | hw/ssi/aspeed_smc.c | 63 ++++-- | ||
114 | hw/timer/aspeed_timer.c | 17 +- | ||
115 | hw/watchdog/wdt_aspeed.c | 41 ++-- | ||
116 | linux-user/elfload.c | 2 + | ||
117 | memory.c | 12 ++ | ||
118 | migration/ram.c | 5 +- | ||
119 | target/arm/arm-powerctl.c | 3 + | ||
120 | target/arm/cpu.c | 33 +++ | ||
121 | target/arm/cpu64.c | 1 + | ||
122 | target/arm/helper.c | 170 ++++++++++++++- | ||
123 | target/arm/op_helper.c | 22 ++ | ||
124 | target/arm/translate-vfp.inc.c | 20 +- | ||
125 | target/arm/translate.c | 9 +- | ||
126 | target/arm/vfp_helper.c | 29 +++ | ||
127 | util/cutils.c | 38 ++++ | ||
128 | hw/i2c/trace-events | 9 + | ||
129 | tests/data/acpi/virt/DSDT | Bin 18470 -> 18462 bytes | ||
130 | tests/data/acpi/virt/DSDT.memhp | Bin 19807 -> 19799 bytes | ||
131 | tests/data/acpi/virt/DSDT.numamem | Bin 18470 -> 18462 bytes | ||
132 | 45 files changed, 1273 insertions(+), 354 deletions(-) | ||
133 | diff view generated by jsdifflib |
1 | From: Cédric Le Goater <clg@kaod.org> | 1 | From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com> |
---|---|---|---|
2 | 2 | ||
3 | The Aspeed Watchdog and Timer models have a link pointing to the SCU | 3 | Correct the indexing into s->cpu_ctlr for vCPUs. |
4 | controller model of the machine. | ||
5 | 4 | ||
6 | Change the "scu" property definition so that it explicitly sets the | 5 | Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> |
7 | pointer. The property isn't optional : not being able to set the link | 6 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
8 | is a bug and QEMU should rather abort than exit in this case. | 7 | Reviewed-by: Luc Michel <luc.michel@greensocs.com> |
9 | 8 | Message-id: 20201214222154.3480243-2-edgar.iglesias@gmail.com | |
10 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
11 | Reviewed-by: Greg Kurz <groug@kaod.org> | ||
12 | Reviewed-by: Joel Stanley <joel@jms.id.au> | ||
13 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
14 | Message-id: 20191119141211.25716-17-clg@kaod.org | ||
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
16 | --- | 10 | --- |
17 | hw/arm/aspeed_ast2600.c | 8 ++++---- | 11 | hw/intc/arm_gic.c | 4 +++- |
18 | hw/arm/aspeed_soc.c | 8 ++++---- | 12 | 1 file changed, 3 insertions(+), 1 deletion(-) |
19 | hw/timer/aspeed_timer.c | 17 +++++++++-------- | ||
20 | hw/watchdog/wdt_aspeed.c | 17 ++++++++--------- | ||
21 | 4 files changed, 25 insertions(+), 25 deletions(-) | ||
22 | 13 | ||
23 | diff --git a/hw/arm/aspeed_ast2600.c b/hw/arm/aspeed_ast2600.c | 14 | diff --git a/hw/intc/arm_gic.c b/hw/intc/arm_gic.c |
24 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
25 | --- a/hw/arm/aspeed_ast2600.c | 16 | --- a/hw/intc/arm_gic.c |
26 | +++ b/hw/arm/aspeed_ast2600.c | 17 | +++ b/hw/intc/arm_gic.c |
27 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast2600_init(Object *obj) | 18 | @@ -XXX,XX +XXX,XX @@ static inline void gic_get_best_virq(GICState *s, int cpu, |
28 | snprintf(typename, sizeof(typename), "aspeed.timer-%s", socname); | 19 | static inline bool gic_irq_signaling_enabled(GICState *s, int cpu, bool virt, |
29 | sysbus_init_child_obj(obj, "timerctrl", OBJECT(&s->timerctrl), | 20 | int group_mask) |
30 | sizeof(s->timerctrl), typename); | 21 | { |
31 | - object_property_add_const_link(OBJECT(&s->timerctrl), "scu", | 22 | + int cpu_iface = virt ? (cpu + GIC_NCPU) : cpu; |
32 | - OBJECT(&s->scu), &error_abort); | 23 | + |
33 | 24 | if (!virt && !(s->ctlr & group_mask)) { | |
34 | snprintf(typename, sizeof(typename), "aspeed.i2c-%s", socname); | 25 | return false; |
35 | sysbus_init_child_obj(obj, "i2c", OBJECT(&s->i2c), sizeof(s->i2c), | ||
36 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast2600_init(Object *obj) | ||
37 | snprintf(typename, sizeof(typename), "aspeed.wdt-%s", socname); | ||
38 | sysbus_init_child_obj(obj, "wdt[*]", OBJECT(&s->wdt[i]), | ||
39 | sizeof(s->wdt[i]), typename); | ||
40 | - object_property_add_const_link(OBJECT(&s->wdt[i]), "scu", | ||
41 | - OBJECT(&s->scu), &error_abort); | ||
42 | } | 26 | } |
43 | 27 | @@ -XXX,XX +XXX,XX @@ static inline bool gic_irq_signaling_enabled(GICState *s, int cpu, bool virt, | |
44 | for (i = 0; i < sc->macs_num; i++) { | 28 | return false; |
45 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp) | ||
46 | aspeed_soc_get_irq(s, ASPEED_RTC)); | ||
47 | |||
48 | /* Timer */ | ||
49 | + object_property_set_link(OBJECT(&s->timerctrl), | ||
50 | + OBJECT(&s->scu), "scu", &error_abort); | ||
51 | object_property_set_bool(OBJECT(&s->timerctrl), true, "realized", &err); | ||
52 | if (err) { | ||
53 | error_propagate(errp, err); | ||
54 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp) | ||
55 | for (i = 0; i < sc->wdts_num; i++) { | ||
56 | AspeedWDTClass *awc = ASPEED_WDT_GET_CLASS(&s->wdt[i]); | ||
57 | |||
58 | + object_property_set_link(OBJECT(&s->wdt[i]), | ||
59 | + OBJECT(&s->scu), "scu", &error_abort); | ||
60 | object_property_set_bool(OBJECT(&s->wdt[i]), true, "realized", &err); | ||
61 | if (err) { | ||
62 | error_propagate(errp, err); | ||
63 | diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c | ||
64 | index XXXXXXX..XXXXXXX 100644 | ||
65 | --- a/hw/arm/aspeed_soc.c | ||
66 | +++ b/hw/arm/aspeed_soc.c | ||
67 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_init(Object *obj) | ||
68 | snprintf(typename, sizeof(typename), "aspeed.timer-%s", socname); | ||
69 | sysbus_init_child_obj(obj, "timerctrl", OBJECT(&s->timerctrl), | ||
70 | sizeof(s->timerctrl), typename); | ||
71 | - object_property_add_const_link(OBJECT(&s->timerctrl), "scu", | ||
72 | - OBJECT(&s->scu), &error_abort); | ||
73 | |||
74 | snprintf(typename, sizeof(typename), "aspeed.i2c-%s", socname); | ||
75 | sysbus_init_child_obj(obj, "i2c", OBJECT(&s->i2c), sizeof(s->i2c), | ||
76 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_init(Object *obj) | ||
77 | snprintf(typename, sizeof(typename), "aspeed.wdt-%s", socname); | ||
78 | sysbus_init_child_obj(obj, "wdt[*]", OBJECT(&s->wdt[i]), | ||
79 | sizeof(s->wdt[i]), typename); | ||
80 | - object_property_add_const_link(OBJECT(&s->wdt[i]), "scu", | ||
81 | - OBJECT(&s->scu), &error_abort); | ||
82 | } | 29 | } |
83 | 30 | ||
84 | for (i = 0; i < sc->macs_num; i++) { | 31 | - if (!(s->cpu_ctlr[cpu] & group_mask)) { |
85 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) | 32 | + if (!(s->cpu_ctlr[cpu_iface] & group_mask)) { |
86 | aspeed_soc_get_irq(s, ASPEED_RTC)); | 33 | return false; |
87 | |||
88 | /* Timer */ | ||
89 | + object_property_set_link(OBJECT(&s->timerctrl), | ||
90 | + OBJECT(&s->scu), "scu", &error_abort); | ||
91 | object_property_set_bool(OBJECT(&s->timerctrl), true, "realized", &err); | ||
92 | if (err) { | ||
93 | error_propagate(errp, err); | ||
94 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) | ||
95 | for (i = 0; i < sc->wdts_num; i++) { | ||
96 | AspeedWDTClass *awc = ASPEED_WDT_GET_CLASS(&s->wdt[i]); | ||
97 | |||
98 | + object_property_set_link(OBJECT(&s->wdt[i]), | ||
99 | + OBJECT(&s->scu), "scu", &error_abort); | ||
100 | object_property_set_bool(OBJECT(&s->wdt[i]), true, "realized", &err); | ||
101 | if (err) { | ||
102 | error_propagate(errp, err); | ||
103 | diff --git a/hw/timer/aspeed_timer.c b/hw/timer/aspeed_timer.c | ||
104 | index XXXXXXX..XXXXXXX 100644 | ||
105 | --- a/hw/timer/aspeed_timer.c | ||
106 | +++ b/hw/timer/aspeed_timer.c | ||
107 | @@ -XXX,XX +XXX,XX @@ | ||
108 | #include "qemu/timer.h" | ||
109 | #include "qemu/log.h" | ||
110 | #include "qemu/module.h" | ||
111 | +#include "hw/qdev-properties.h" | ||
112 | #include "trace.h" | ||
113 | |||
114 | #define TIMER_NR_REGS 4 | ||
115 | @@ -XXX,XX +XXX,XX @@ static void aspeed_timer_realize(DeviceState *dev, Error **errp) | ||
116 | int i; | ||
117 | SysBusDevice *sbd = SYS_BUS_DEVICE(dev); | ||
118 | AspeedTimerCtrlState *s = ASPEED_TIMER(dev); | ||
119 | - Object *obj; | ||
120 | - Error *err = NULL; | ||
121 | |||
122 | - obj = object_property_get_link(OBJECT(dev), "scu", &err); | ||
123 | - if (!obj) { | ||
124 | - error_propagate_prepend(errp, err, "required link 'scu' not found: "); | ||
125 | - return; | ||
126 | - } | ||
127 | - s->scu = ASPEED_SCU(obj); | ||
128 | + assert(s->scu); | ||
129 | |||
130 | for (i = 0; i < ASPEED_TIMER_NR_TIMERS; i++) { | ||
131 | aspeed_init_one_timer(s, i); | ||
132 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_aspeed_timer_state = { | ||
133 | } | 34 | } |
134 | }; | 35 | |
135 | |||
136 | +static Property aspeed_timer_properties[] = { | ||
137 | + DEFINE_PROP_LINK("scu", AspeedTimerCtrlState, scu, TYPE_ASPEED_SCU, | ||
138 | + AspeedSCUState *), | ||
139 | + DEFINE_PROP_END_OF_LIST(), | ||
140 | +}; | ||
141 | + | ||
142 | static void timer_class_init(ObjectClass *klass, void *data) | ||
143 | { | ||
144 | DeviceClass *dc = DEVICE_CLASS(klass); | ||
145 | @@ -XXX,XX +XXX,XX @@ static void timer_class_init(ObjectClass *klass, void *data) | ||
146 | dc->reset = aspeed_timer_reset; | ||
147 | dc->desc = "ASPEED Timer"; | ||
148 | dc->vmsd = &vmstate_aspeed_timer_state; | ||
149 | + dc->props = aspeed_timer_properties; | ||
150 | } | ||
151 | |||
152 | static const TypeInfo aspeed_timer_info = { | ||
153 | diff --git a/hw/watchdog/wdt_aspeed.c b/hw/watchdog/wdt_aspeed.c | ||
154 | index XXXXXXX..XXXXXXX 100644 | ||
155 | --- a/hw/watchdog/wdt_aspeed.c | ||
156 | +++ b/hw/watchdog/wdt_aspeed.c | ||
157 | @@ -XXX,XX +XXX,XX @@ static void aspeed_wdt_realize(DeviceState *dev, Error **errp) | ||
158 | { | ||
159 | SysBusDevice *sbd = SYS_BUS_DEVICE(dev); | ||
160 | AspeedWDTState *s = ASPEED_WDT(dev); | ||
161 | - Error *err = NULL; | ||
162 | - Object *obj; | ||
163 | |||
164 | - obj = object_property_get_link(OBJECT(dev), "scu", &err); | ||
165 | - if (!obj) { | ||
166 | - error_propagate(errp, err); | ||
167 | - error_prepend(errp, "required link 'scu' not found: "); | ||
168 | - return; | ||
169 | - } | ||
170 | - s->scu = ASPEED_SCU(obj); | ||
171 | + assert(s->scu); | ||
172 | |||
173 | s->timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, aspeed_wdt_timer_expired, dev); | ||
174 | |||
175 | @@ -XXX,XX +XXX,XX @@ static void aspeed_wdt_realize(DeviceState *dev, Error **errp) | ||
176 | sysbus_init_mmio(sbd, &s->iomem); | ||
177 | } | ||
178 | |||
179 | +static Property aspeed_wdt_properties[] = { | ||
180 | + DEFINE_PROP_LINK("scu", AspeedWDTState, scu, TYPE_ASPEED_SCU, | ||
181 | + AspeedSCUState *), | ||
182 | + DEFINE_PROP_END_OF_LIST(), | ||
183 | +}; | ||
184 | + | ||
185 | static void aspeed_wdt_class_init(ObjectClass *klass, void *data) | ||
186 | { | ||
187 | DeviceClass *dc = DEVICE_CLASS(klass); | ||
188 | @@ -XXX,XX +XXX,XX @@ static void aspeed_wdt_class_init(ObjectClass *klass, void *data) | ||
189 | dc->reset = aspeed_wdt_reset; | ||
190 | set_bit(DEVICE_CATEGORY_MISC, dc->categories); | ||
191 | dc->vmsd = &vmstate_aspeed_wdt; | ||
192 | + dc->props = aspeed_wdt_properties; | ||
193 | } | ||
194 | |||
195 | static const TypeInfo aspeed_wdt_info = { | ||
196 | -- | 36 | -- |
197 | 2.20.1 | 37 | 2.20.1 |
198 | 38 | ||
199 | 39 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 1 | From: Andrew Jones <drjones@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | Make the gic a field in the machine state, and instead of filling | 3 | virt machine's 'smp_cpus' and machine->smp.cpus must always have the |
4 | an array of qemu_irq and passing it around, directly call | 4 | same value. And, anywhere we have virt machine state we have machine |
5 | qdev_get_gpio_in() on the gic field. | 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. | ||
6 | 9 | ||
7 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 10 | No functional change intended. |
8 | Reviewed-by: Luc Michel <luc.michel@greensocs.com> | 11 | |
9 | Message-id: 20191209090306.20433-1-philmd@redhat.com | 12 | Signed-off-by: Andrew Jones <drjones@redhat.com> |
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 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] | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | --- | 18 | --- |
13 | include/hw/arm/virt.h | 1 + | 19 | include/hw/arm/virt.h | 3 +-- |
14 | hw/arm/virt.c | 109 +++++++++++++++++++++--------------------- | 20 | hw/arm/virt-acpi-build.c | 9 +++++---- |
15 | 2 files changed, 55 insertions(+), 55 deletions(-) | 21 | hw/arm/virt.c | 21 ++++++++++----------- |
22 | 3 files changed, 16 insertions(+), 17 deletions(-) | ||
16 | 23 | ||
17 | diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h | 24 | diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h |
18 | index XXXXXXX..XXXXXXX 100644 | 25 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/include/hw/arm/virt.h | 26 | --- a/include/hw/arm/virt.h |
20 | +++ b/include/hw/arm/virt.h | 27 | +++ b/include/hw/arm/virt.h |
21 | @@ -XXX,XX +XXX,XX @@ typedef struct { | 28 | @@ -XXX,XX +XXX,XX @@ struct VirtMachineState { |
22 | uint32_t iommu_phandle; | 29 | MemMapEntry *memmap; |
23 | int psci_conduit; | 30 | char *pciehb_nodename; |
24 | hwaddr highest_gpa; | 31 | const int *irqmap; |
25 | + DeviceState *gic; | 32 | - int smp_cpus; |
26 | DeviceState *acpi_dev; | 33 | void *fdt; |
27 | Notifier powerdown_notifier; | 34 | int fdt_size; |
28 | } VirtMachineState; | 35 | uint32_t clock_phandle; |
36 | @@ -XXX,XX +XXX,XX @@ static inline int virt_gicv3_redist_region_count(VirtMachineState *vms) | ||
37 | |||
38 | assert(vms->gic_version == VIRT_GIC_VERSION_3); | ||
39 | |||
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) { | ||
29 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c | 82 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c |
30 | index XXXXXXX..XXXXXXX 100644 | 83 | index XXXXXXX..XXXXXXX 100644 |
31 | --- a/hw/arm/virt.c | 84 | --- a/hw/arm/virt.c |
32 | +++ b/hw/arm/virt.c | 85 | +++ b/hw/arm/virt.c |
86 | @@ -XXX,XX +XXX,XX @@ static void fdt_add_timer_nodes(const VirtMachineState *vms) | ||
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 | } | ||
93 | |||
94 | qemu_fdt_add_subnode(vms->fdt, "/timer"); | ||
95 | @@ -XXX,XX +XXX,XX @@ static void fdt_add_cpu_nodes(const VirtMachineState *vms) | ||
96 | int cpu; | ||
97 | int addr_cells = 1; | ||
98 | const MachineState *ms = MACHINE(vms); | ||
99 | + int smp_cpus = ms->smp.cpus; | ||
100 | |||
101 | /* | ||
102 | * From Documentation/devicetree/bindings/arm/cpus.txt | ||
103 | @@ -XXX,XX +XXX,XX @@ static void fdt_add_cpu_nodes(const VirtMachineState *vms) | ||
104 | * The simplest way to go is to examine affinity IDs of all our CPUs. If | ||
105 | * at least one of them has Aff3 populated, we set #address-cells to 2. | ||
106 | */ | ||
107 | - for (cpu = 0; cpu < vms->smp_cpus; cpu++) { | ||
108 | + for (cpu = 0; cpu < smp_cpus; cpu++) { | ||
109 | ARMCPU *armcpu = ARM_CPU(qemu_get_cpu(cpu)); | ||
110 | |||
111 | if (armcpu->mp_affinity & ARM_AFF3_MASK) { | ||
112 | @@ -XXX,XX +XXX,XX @@ static void fdt_add_cpu_nodes(const VirtMachineState *vms) | ||
113 | qemu_fdt_setprop_cell(vms->fdt, "/cpus", "#address-cells", addr_cells); | ||
114 | qemu_fdt_setprop_cell(vms->fdt, "/cpus", "#size-cells", 0x0); | ||
115 | |||
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 | } | ||
33 | @@ -XXX,XX +XXX,XX @@ static void fdt_add_pmu_nodes(const VirtMachineState *vms) | 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); | ||
34 | } | 137 | } |
35 | } | 138 | |
36 | 139 | qemu_fdt_add_subnode(vms->fdt, "/pmu"); | |
37 | -static inline DeviceState *create_acpi_ged(VirtMachineState *vms, qemu_irq *pic) | 140 | @@ -XXX,XX +XXX,XX @@ static void finalize_gic_version(VirtMachineState *vms) |
38 | +static inline DeviceState *create_acpi_ged(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) | ||
39 | { | 147 | { |
40 | DeviceState *dev; | 148 | + int max_cpus = MACHINE(vms)->smp.max_cpus; |
41 | MachineState *ms = MACHINE(vms); | 149 | bool aarch64, pmu, steal_time; |
42 | @@ -XXX,XX +XXX,XX @@ static inline DeviceState *create_acpi_ged(VirtMachineState *vms, qemu_irq *pic) | 150 | CPUState *cpu; |
43 | 151 | ||
44 | sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, vms->memmap[VIRT_ACPI_GED].base); | 152 | @@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine) |
45 | sysbus_mmio_map(SYS_BUS_DEVICE(dev), 1, vms->memmap[VIRT_PCDIMM_ACPI].base); | 153 | exit(1); |
46 | - sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, pic[irq]); | ||
47 | + sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, qdev_get_gpio_in(vms->gic, irq)); | ||
48 | |||
49 | qdev_init_nofail(dev); | ||
50 | |||
51 | return dev; | ||
52 | } | ||
53 | |||
54 | -static void create_its(VirtMachineState *vms, DeviceState *gicdev) | ||
55 | +static void create_its(VirtMachineState *vms) | ||
56 | { | ||
57 | const char *itsclass = its_class_name(); | ||
58 | DeviceState *dev; | ||
59 | @@ -XXX,XX +XXX,XX @@ static void create_its(VirtMachineState *vms, DeviceState *gicdev) | ||
60 | |||
61 | dev = qdev_create(NULL, itsclass); | ||
62 | |||
63 | - object_property_set_link(OBJECT(dev), OBJECT(gicdev), "parent-gicv3", | ||
64 | + object_property_set_link(OBJECT(dev), OBJECT(vms->gic), "parent-gicv3", | ||
65 | &error_abort); | ||
66 | qdev_init_nofail(dev); | ||
67 | sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, vms->memmap[VIRT_GIC_ITS].base); | ||
68 | @@ -XXX,XX +XXX,XX @@ static void create_its(VirtMachineState *vms, DeviceState *gicdev) | ||
69 | fdt_add_its_gic_node(vms); | ||
70 | } | ||
71 | |||
72 | -static void create_v2m(VirtMachineState *vms, qemu_irq *pic) | ||
73 | +static void create_v2m(VirtMachineState *vms) | ||
74 | { | ||
75 | int i; | ||
76 | int irq = vms->irqmap[VIRT_GIC_V2M]; | ||
77 | @@ -XXX,XX +XXX,XX @@ static void create_v2m(VirtMachineState *vms, qemu_irq *pic) | ||
78 | qdev_init_nofail(dev); | ||
79 | |||
80 | for (i = 0; i < NUM_GICV2M_SPIS; i++) { | ||
81 | - sysbus_connect_irq(SYS_BUS_DEVICE(dev), i, pic[irq + i]); | ||
82 | + sysbus_connect_irq(SYS_BUS_DEVICE(dev), i, | ||
83 | + qdev_get_gpio_in(vms->gic, irq + i)); | ||
84 | } | 154 | } |
85 | 155 | ||
86 | fdt_add_v2m_gic_node(vms); | 156 | - vms->smp_cpus = smp_cpus; |
87 | } | ||
88 | |||
89 | -static void create_gic(VirtMachineState *vms, qemu_irq *pic) | ||
90 | +static void create_gic(VirtMachineState *vms) | ||
91 | { | ||
92 | MachineState *ms = MACHINE(vms); | ||
93 | /* We create a standalone GIC */ | ||
94 | - DeviceState *gicdev; | ||
95 | SysBusDevice *gicbusdev; | ||
96 | const char *gictype; | ||
97 | int type = vms->gic_version, i; | ||
98 | @@ -XXX,XX +XXX,XX @@ static void create_gic(VirtMachineState *vms, qemu_irq *pic) | ||
99 | |||
100 | gictype = (type == 3) ? gicv3_class_name() : gic_class_name(); | ||
101 | |||
102 | - gicdev = qdev_create(NULL, gictype); | ||
103 | - qdev_prop_set_uint32(gicdev, "revision", type); | ||
104 | - qdev_prop_set_uint32(gicdev, "num-cpu", smp_cpus); | ||
105 | + vms->gic = qdev_create(NULL, gictype); | ||
106 | + qdev_prop_set_uint32(vms->gic, "revision", type); | ||
107 | + qdev_prop_set_uint32(vms->gic, "num-cpu", smp_cpus); | ||
108 | /* Note that the num-irq property counts both internal and external | ||
109 | * interrupts; there are always 32 of the former (mandated by GIC spec). | ||
110 | */ | ||
111 | - qdev_prop_set_uint32(gicdev, "num-irq", NUM_IRQS + 32); | ||
112 | + qdev_prop_set_uint32(vms->gic, "num-irq", NUM_IRQS + 32); | ||
113 | if (!kvm_irqchip_in_kernel()) { | ||
114 | - qdev_prop_set_bit(gicdev, "has-security-extensions", vms->secure); | ||
115 | + qdev_prop_set_bit(vms->gic, "has-security-extensions", vms->secure); | ||
116 | } | ||
117 | |||
118 | if (type == 3) { | ||
119 | @@ -XXX,XX +XXX,XX @@ static void create_gic(VirtMachineState *vms, qemu_irq *pic) | ||
120 | |||
121 | nb_redist_regions = virt_gicv3_redist_region_count(vms); | ||
122 | |||
123 | - qdev_prop_set_uint32(gicdev, "len-redist-region-count", | ||
124 | + qdev_prop_set_uint32(vms->gic, "len-redist-region-count", | ||
125 | nb_redist_regions); | ||
126 | - qdev_prop_set_uint32(gicdev, "redist-region-count[0]", redist0_count); | ||
127 | + qdev_prop_set_uint32(vms->gic, "redist-region-count[0]", redist0_count); | ||
128 | |||
129 | if (nb_redist_regions == 2) { | ||
130 | uint32_t redist1_capacity = | ||
131 | vms->memmap[VIRT_HIGH_GIC_REDIST2].size / GICV3_REDIST_SIZE; | ||
132 | |||
133 | - qdev_prop_set_uint32(gicdev, "redist-region-count[1]", | ||
134 | + qdev_prop_set_uint32(vms->gic, "redist-region-count[1]", | ||
135 | MIN(smp_cpus - redist0_count, redist1_capacity)); | ||
136 | } | ||
137 | } else { | ||
138 | if (!kvm_irqchip_in_kernel()) { | ||
139 | - qdev_prop_set_bit(gicdev, "has-virtualization-extensions", | ||
140 | + qdev_prop_set_bit(vms->gic, "has-virtualization-extensions", | ||
141 | vms->virt); | ||
142 | } | ||
143 | } | ||
144 | - qdev_init_nofail(gicdev); | ||
145 | - gicbusdev = SYS_BUS_DEVICE(gicdev); | ||
146 | + qdev_init_nofail(vms->gic); | ||
147 | + gicbusdev = SYS_BUS_DEVICE(vms->gic); | ||
148 | sysbus_mmio_map(gicbusdev, 0, vms->memmap[VIRT_GIC_DIST].base); | ||
149 | if (type == 3) { | ||
150 | sysbus_mmio_map(gicbusdev, 1, vms->memmap[VIRT_GIC_REDIST].base); | ||
151 | @@ -XXX,XX +XXX,XX @@ static void create_gic(VirtMachineState *vms, qemu_irq *pic) | ||
152 | |||
153 | for (irq = 0; irq < ARRAY_SIZE(timer_irq); irq++) { | ||
154 | qdev_connect_gpio_out(cpudev, irq, | ||
155 | - qdev_get_gpio_in(gicdev, | ||
156 | + qdev_get_gpio_in(vms->gic, | ||
157 | ppibase + timer_irq[irq])); | ||
158 | } | ||
159 | |||
160 | if (type == 3) { | ||
161 | - qemu_irq irq = qdev_get_gpio_in(gicdev, | ||
162 | + qemu_irq irq = qdev_get_gpio_in(vms->gic, | ||
163 | ppibase + ARCH_GIC_MAINT_IRQ); | ||
164 | qdev_connect_gpio_out_named(cpudev, "gicv3-maintenance-interrupt", | ||
165 | 0, irq); | ||
166 | } else if (vms->virt) { | ||
167 | - qemu_irq irq = qdev_get_gpio_in(gicdev, | ||
168 | + qemu_irq irq = qdev_get_gpio_in(vms->gic, | ||
169 | ppibase + ARCH_GIC_MAINT_IRQ); | ||
170 | sysbus_connect_irq(gicbusdev, i + 4 * smp_cpus, irq); | ||
171 | } | ||
172 | |||
173 | qdev_connect_gpio_out_named(cpudev, "pmu-interrupt", 0, | ||
174 | - qdev_get_gpio_in(gicdev, ppibase | ||
175 | + qdev_get_gpio_in(vms->gic, ppibase | ||
176 | + VIRTUAL_PMU_IRQ)); | ||
177 | |||
178 | sysbus_connect_irq(gicbusdev, i, qdev_get_gpio_in(cpudev, ARM_CPU_IRQ)); | ||
179 | @@ -XXX,XX +XXX,XX @@ static void create_gic(VirtMachineState *vms, qemu_irq *pic) | ||
180 | qdev_get_gpio_in(cpudev, ARM_CPU_VFIQ)); | ||
181 | } | ||
182 | |||
183 | - for (i = 0; i < NUM_IRQS; i++) { | ||
184 | - pic[i] = qdev_get_gpio_in(gicdev, i); | ||
185 | - } | ||
186 | - | 157 | - |
187 | fdt_add_gic_node(vms); | 158 | if (vms->virt && kvm_enabled()) { |
188 | 159 | error_report("mach-virt: KVM does not support providing " | |
189 | if (type == 3 && vms->its) { | 160 | "Virtualization extensions to the guest CPU"); |
190 | - create_its(vms, gicdev); | ||
191 | + create_its(vms); | ||
192 | } else if (type == 2) { | ||
193 | - create_v2m(vms, pic); | ||
194 | + create_v2m(vms); | ||
195 | } | ||
196 | } | ||
197 | |||
198 | -static void create_uart(const VirtMachineState *vms, qemu_irq *pic, int uart, | ||
199 | +static void create_uart(const VirtMachineState *vms, int uart, | ||
200 | MemoryRegion *mem, Chardev *chr) | ||
201 | { | ||
202 | char *nodename; | ||
203 | @@ -XXX,XX +XXX,XX @@ static void create_uart(const VirtMachineState *vms, qemu_irq *pic, int uart, | ||
204 | qdev_init_nofail(dev); | ||
205 | memory_region_add_subregion(mem, base, | ||
206 | sysbus_mmio_get_region(s, 0)); | ||
207 | - sysbus_connect_irq(s, 0, pic[irq]); | ||
208 | + sysbus_connect_irq(s, 0, qdev_get_gpio_in(vms->gic, irq)); | ||
209 | |||
210 | nodename = g_strdup_printf("/pl011@%" PRIx64, base); | ||
211 | qemu_fdt_add_subnode(vms->fdt, nodename); | ||
212 | @@ -XXX,XX +XXX,XX @@ static void create_uart(const VirtMachineState *vms, qemu_irq *pic, int uart, | ||
213 | g_free(nodename); | ||
214 | } | ||
215 | |||
216 | -static void create_rtc(const VirtMachineState *vms, qemu_irq *pic) | ||
217 | +static void create_rtc(const VirtMachineState *vms) | ||
218 | { | ||
219 | char *nodename; | ||
220 | hwaddr base = vms->memmap[VIRT_RTC].base; | ||
221 | @@ -XXX,XX +XXX,XX @@ static void create_rtc(const VirtMachineState *vms, qemu_irq *pic) | ||
222 | int irq = vms->irqmap[VIRT_RTC]; | ||
223 | const char compat[] = "arm,pl031\0arm,primecell"; | ||
224 | |||
225 | - sysbus_create_simple("pl031", base, pic[irq]); | ||
226 | + sysbus_create_simple("pl031", base, qdev_get_gpio_in(vms->gic, irq)); | ||
227 | |||
228 | nodename = g_strdup_printf("/pl031@%" PRIx64, base); | ||
229 | qemu_fdt_add_subnode(vms->fdt, nodename); | ||
230 | @@ -XXX,XX +XXX,XX @@ static void virt_powerdown_req(Notifier *n, void *opaque) | ||
231 | } | ||
232 | } | ||
233 | |||
234 | -static void create_gpio(const VirtMachineState *vms, qemu_irq *pic) | ||
235 | +static void create_gpio(const VirtMachineState *vms) | ||
236 | { | ||
237 | char *nodename; | ||
238 | DeviceState *pl061_dev; | ||
239 | @@ -XXX,XX +XXX,XX @@ static void create_gpio(const VirtMachineState *vms, qemu_irq *pic) | ||
240 | int irq = vms->irqmap[VIRT_GPIO]; | ||
241 | const char compat[] = "arm,pl061\0arm,primecell"; | ||
242 | |||
243 | - pl061_dev = sysbus_create_simple("pl061", base, pic[irq]); | ||
244 | + pl061_dev = sysbus_create_simple("pl061", base, | ||
245 | + qdev_get_gpio_in(vms->gic, irq)); | ||
246 | |||
247 | uint32_t phandle = qemu_fdt_alloc_phandle(vms->fdt); | ||
248 | nodename = g_strdup_printf("/pl061@%" PRIx64, base); | ||
249 | @@ -XXX,XX +XXX,XX @@ static void create_gpio(const VirtMachineState *vms, qemu_irq *pic) | ||
250 | g_free(nodename); | ||
251 | } | ||
252 | |||
253 | -static void create_virtio_devices(const VirtMachineState *vms, qemu_irq *pic) | ||
254 | +static void create_virtio_devices(const VirtMachineState *vms) | ||
255 | { | ||
256 | int i; | ||
257 | hwaddr size = vms->memmap[VIRT_MMIO].size; | ||
258 | @@ -XXX,XX +XXX,XX @@ static void create_virtio_devices(const VirtMachineState *vms, qemu_irq *pic) | ||
259 | int irq = vms->irqmap[VIRT_MMIO] + i; | ||
260 | hwaddr base = vms->memmap[VIRT_MMIO].base + i * size; | ||
261 | |||
262 | - sysbus_create_simple("virtio-mmio", base, pic[irq]); | ||
263 | + sysbus_create_simple("virtio-mmio", base, | ||
264 | + qdev_get_gpio_in(vms->gic, irq)); | ||
265 | } | ||
266 | |||
267 | /* We add dtb nodes in reverse order so that they appear in the finished | ||
268 | @@ -XXX,XX +XXX,XX @@ static void create_pcie_irq_map(const VirtMachineState *vms, | ||
269 | 0x7 /* PCI irq */); | ||
270 | } | ||
271 | |||
272 | -static void create_smmu(const VirtMachineState *vms, qemu_irq *pic, | ||
273 | +static void create_smmu(const VirtMachineState *vms, | ||
274 | PCIBus *bus) | ||
275 | { | ||
276 | char *node; | ||
277 | @@ -XXX,XX +XXX,XX @@ static void create_smmu(const VirtMachineState *vms, qemu_irq *pic, | ||
278 | qdev_init_nofail(dev); | ||
279 | sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, base); | ||
280 | for (i = 0; i < NUM_SMMU_IRQS; i++) { | ||
281 | - sysbus_connect_irq(SYS_BUS_DEVICE(dev), i, pic[irq + i]); | ||
282 | + sysbus_connect_irq(SYS_BUS_DEVICE(dev), i, | ||
283 | + qdev_get_gpio_in(vms->gic, irq + i)); | ||
284 | } | ||
285 | |||
286 | node = g_strdup_printf("/smmuv3@%" PRIx64, base); | ||
287 | @@ -XXX,XX +XXX,XX @@ static void create_smmu(const VirtMachineState *vms, qemu_irq *pic, | ||
288 | g_free(node); | ||
289 | } | ||
290 | |||
291 | -static void create_pcie(VirtMachineState *vms, qemu_irq *pic) | ||
292 | +static void create_pcie(VirtMachineState *vms) | ||
293 | { | ||
294 | hwaddr base_mmio = vms->memmap[VIRT_PCIE_MMIO].base; | ||
295 | hwaddr size_mmio = vms->memmap[VIRT_PCIE_MMIO].size; | ||
296 | @@ -XXX,XX +XXX,XX @@ static void create_pcie(VirtMachineState *vms, qemu_irq *pic) | ||
297 | sysbus_mmio_map(SYS_BUS_DEVICE(dev), 2, base_pio); | ||
298 | |||
299 | for (i = 0; i < GPEX_NUM_IRQS; i++) { | ||
300 | - sysbus_connect_irq(SYS_BUS_DEVICE(dev), i, pic[irq + i]); | ||
301 | + sysbus_connect_irq(SYS_BUS_DEVICE(dev), i, | ||
302 | + qdev_get_gpio_in(vms->gic, irq + i)); | ||
303 | gpex_set_irq_num(GPEX_HOST(dev), i, irq + i); | ||
304 | } | ||
305 | |||
306 | @@ -XXX,XX +XXX,XX @@ static void create_pcie(VirtMachineState *vms, qemu_irq *pic) | ||
307 | if (vms->iommu) { | ||
308 | vms->iommu_phandle = qemu_fdt_alloc_phandle(vms->fdt); | ||
309 | |||
310 | - create_smmu(vms, pic, pci->bus); | ||
311 | + create_smmu(vms, pci->bus); | ||
312 | |||
313 | qemu_fdt_setprop_cells(vms->fdt, nodename, "iommu-map", | ||
314 | 0x0, vms->iommu_phandle, 0x0, 0x10000); | ||
315 | @@ -XXX,XX +XXX,XX @@ static void create_pcie(VirtMachineState *vms, qemu_irq *pic) | ||
316 | g_free(nodename); | ||
317 | } | ||
318 | |||
319 | -static void create_platform_bus(VirtMachineState *vms, qemu_irq *pic) | ||
320 | +static void create_platform_bus(VirtMachineState *vms) | ||
321 | { | ||
322 | DeviceState *dev; | ||
323 | SysBusDevice *s; | ||
324 | @@ -XXX,XX +XXX,XX @@ static void create_platform_bus(VirtMachineState *vms, qemu_irq *pic) | ||
325 | |||
326 | s = SYS_BUS_DEVICE(dev); | ||
327 | for (i = 0; i < PLATFORM_BUS_NUM_IRQS; i++) { | ||
328 | - int irqn = vms->irqmap[VIRT_PLATFORM_BUS] + i; | ||
329 | - sysbus_connect_irq(s, i, pic[irqn]); | ||
330 | + int irq = vms->irqmap[VIRT_PLATFORM_BUS] + i; | ||
331 | + sysbus_connect_irq(s, i, qdev_get_gpio_in(vms->gic, irq)); | ||
332 | } | ||
333 | |||
334 | memory_region_add_subregion(sysmem, | ||
335 | @@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine) | 161 | @@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine) |
336 | VirtMachineClass *vmc = VIRT_MACHINE_GET_CLASS(machine); | 162 | create_fdt(vms); |
337 | MachineClass *mc = MACHINE_GET_CLASS(machine); | 163 | |
338 | const CPUArchIdList *possible_cpus; | 164 | possible_cpus = mc->possible_cpu_arch_ids(machine); |
339 | - qemu_irq pic[NUM_IRQS]; | 165 | + assert(possible_cpus->len == max_cpus); |
340 | MemoryRegion *sysmem = get_system_memory(); | 166 | for (n = 0; n < possible_cpus->len; n++) { |
341 | MemoryRegion *secure_sysmem = NULL; | 167 | Object *cpuobj; |
342 | int n, virt_max_cpus; | 168 | CPUState *cs; |
343 | @@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine) | 169 | @@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine) |
344 | 170 | ||
345 | virt_flash_fdt(vms, sysmem, secure_sysmem ?: sysmem); | 171 | create_gic(vms); |
346 | 172 | ||
347 | - create_gic(vms, pic); | 173 | - virt_cpu_post_init(vms, possible_cpus->len, sysmem); |
348 | + create_gic(vms); | 174 | + virt_cpu_post_init(vms, sysmem); |
349 | 175 | ||
350 | fdt_add_pmu_nodes(vms); | 176 | fdt_add_pmu_nodes(vms); |
351 | 177 | ||
352 | - create_uart(vms, pic, VIRT_UART, sysmem, serial_hd(0)); | ||
353 | + create_uart(vms, VIRT_UART, sysmem, serial_hd(0)); | ||
354 | |||
355 | if (vms->secure) { | ||
356 | create_secure_ram(vms, secure_sysmem); | ||
357 | - create_uart(vms, pic, VIRT_SECURE_UART, secure_sysmem, serial_hd(1)); | ||
358 | + create_uart(vms, VIRT_SECURE_UART, secure_sysmem, serial_hd(1)); | ||
359 | } | ||
360 | |||
361 | vms->highmem_ecam &= vms->highmem && (!firmware_loaded || aarch64); | ||
362 | |||
363 | - create_rtc(vms, pic); | ||
364 | + create_rtc(vms); | ||
365 | |||
366 | - create_pcie(vms, pic); | ||
367 | + create_pcie(vms); | ||
368 | |||
369 | if (has_ged && aarch64 && firmware_loaded && acpi_enabled) { | ||
370 | - vms->acpi_dev = create_acpi_ged(vms, pic); | ||
371 | + vms->acpi_dev = create_acpi_ged(vms); | ||
372 | } else { | ||
373 | - create_gpio(vms, pic); | ||
374 | + create_gpio(vms); | ||
375 | } | ||
376 | |||
377 | /* connect powerdown request */ | ||
378 | @@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine) | ||
379 | * (which will be automatically plugged in to the transports). If | ||
380 | * no backend is created the transport will just sit harmlessly idle. | ||
381 | */ | ||
382 | - create_virtio_devices(vms, pic); | ||
383 | + create_virtio_devices(vms); | ||
384 | |||
385 | vms->fw_cfg = create_fw_cfg(vms, &address_space_memory); | ||
386 | rom_set_fw(vms->fw_cfg); | ||
387 | |||
388 | - create_platform_bus(vms, pic); | ||
389 | + create_platform_bus(vms); | ||
390 | |||
391 | vms->bootinfo.ram_size = machine->ram_size; | ||
392 | vms->bootinfo.nb_cpus = smp_cpus; | ||
393 | -- | 178 | -- |
394 | 2.20.1 | 179 | 2.20.1 |
395 | 180 | ||
396 | 181 | diff view generated by jsdifflib |
1 | From: Marc Zyngier <maz@kernel.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | QEMU lacks the minimum Jazelle implementation that is required | 3 | In 50244cc76abc we updated mte_check_fail to match the ARM |
4 | by the architecture (everything is RAZ or RAZ/WI). Add it | 4 | pseudocode, using the correct EL to select the TCF field. |
5 | together with the HCR_EL2.TID0 trapping that goes with it. | 5 | But we failed to update MTE0_ACTIVE the same way, which led |
6 | to g_assert_not_reached(). | ||
6 | 7 | ||
7 | Signed-off-by: Marc Zyngier <maz@kernel.org> | 8 | Cc: qemu-stable@nongnu.org |
8 | Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> | 9 | Buglink: https://bugs.launchpad.net/bugs/1907137 |
9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 10 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
10 | Message-id: 20191201122018.25808-6-maz@kernel.org | 11 | Message-id: 20201221204426.88514-1-richard.henderson@linaro.org |
11 | [PMM: moved ARMCPRegInfo array to file scope, marked it | 12 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
12 | 'static global', moved new condition down in | ||
13 | register_cp_regs_for_features() to go with other feature | ||
14 | things rather than up with the v6/v7/v8 stuff] | ||
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
16 | --- | 14 | --- |
17 | target/arm/helper.c | 27 +++++++++++++++++++++++++++ | 15 | target/arm/helper.c | 2 +- |
18 | 1 file changed, 27 insertions(+) | 16 | 1 file changed, 1 insertion(+), 1 deletion(-) |
19 | 17 | ||
20 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 18 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
21 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/target/arm/helper.c | 20 | --- a/target/arm/helper.c |
23 | +++ b/target/arm/helper.c | 21 | +++ b/target/arm/helper.c |
24 | @@ -XXX,XX +XXX,XX @@ static CPAccessResult access_aa32_tid3(CPUARMState *env, const ARMCPRegInfo *ri, | 22 | @@ -XXX,XX +XXX,XX @@ static uint32_t rebuild_hflags_a64(CPUARMState *env, int el, int fp_el, |
25 | return CP_ACCESS_OK; | 23 | if (FIELD_EX32(flags, TBFLAG_A64, UNPRIV) |
26 | } | 24 | && tbid |
27 | 25 | && !(env->pstate & PSTATE_TCO) | |
28 | +static CPAccessResult access_jazelle(CPUARMState *env, const ARMCPRegInfo *ri, | 26 | - && (sctlr & SCTLR_TCF0) |
29 | + bool isread) | 27 | + && (sctlr & SCTLR_TCF) |
30 | +{ | 28 | && allocation_tag_access_enabled(env, 0, sctlr)) { |
31 | + if (arm_current_el(env) == 1 && (arm_hcr_el2_eff(env) & HCR_TID0)) { | 29 | flags = FIELD_DP32(flags, TBFLAG_A64, MTE0_ACTIVE, 1); |
32 | + return CP_ACCESS_TRAP_EL2; | 30 | } |
33 | + } | ||
34 | + | ||
35 | + return CP_ACCESS_OK; | ||
36 | +} | ||
37 | + | ||
38 | +static const ARMCPRegInfo jazelle_regs[] = { | ||
39 | + { .name = "JIDR", | ||
40 | + .cp = 14, .crn = 0, .crm = 0, .opc1 = 7, .opc2 = 0, | ||
41 | + .access = PL1_R, .accessfn = access_jazelle, | ||
42 | + .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
43 | + { .name = "JOSCR", | ||
44 | + .cp = 14, .crn = 1, .crm = 0, .opc1 = 7, .opc2 = 0, | ||
45 | + .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
46 | + { .name = "JMCR", | ||
47 | + .cp = 14, .crn = 2, .crm = 0, .opc1 = 7, .opc2 = 0, | ||
48 | + .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
49 | + REGINFO_SENTINEL | ||
50 | +}; | ||
51 | + | ||
52 | void register_cp_regs_for_features(ARMCPU *cpu) | ||
53 | { | ||
54 | /* Register all the coprocessor registers based on feature bits */ | ||
55 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
56 | if (arm_feature(env, ARM_FEATURE_LPAE)) { | ||
57 | define_arm_cp_regs(cpu, lpae_cp_reginfo); | ||
58 | } | ||
59 | + if (cpu_isar_feature(jazelle, cpu)) { | ||
60 | + define_arm_cp_regs(cpu, jazelle_regs); | ||
61 | + } | ||
62 | /* Slightly awkwardly, the OMAP and StrongARM cores need all of | ||
63 | * cp15 crn=0 to be writes-ignored, whereas for other cores they should | ||
64 | * be read-only (ie write causes UNDEF exception). | ||
65 | -- | 31 | -- |
66 | 2.20.1 | 32 | 2.20.1 |
67 | 33 | ||
68 | 34 | diff view generated by jsdifflib |
1 | From: Marc Zyngier <maz@kernel.org> | 1 | The CCR is a register most of whose bits are banked between security |
---|---|---|---|
2 | states but where BFHFNMIGN is not, and we keep it in the non-secure | ||
3 | entry of the v7m.ccr[] array. The logic which tries to handle this | ||
4 | bit fails to implement the "RAZ/WI from Nonsecure if AIRCR.BFHFNMINS | ||
5 | is zero" requirement; correct the omission. | ||
2 | 6 | ||
3 | HSTR_EL2 offers a way to trap ranges of CP15 system register | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | accesses to EL2, and it looks like this register is completely | 8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
5 | ignored by QEMU. | 9 | Message-id: 20201210201433.26262-2-peter.maydell@linaro.org |
10 | --- | ||
11 | hw/intc/armv7m_nvic.c | 15 +++++++++++++++ | ||
12 | 1 file changed, 15 insertions(+) | ||
6 | 13 | ||
7 | To avoid adding extra .accessfn filters all over the place (which | 14 | diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c |
8 | would have a direct performance impact), let's add a new TB flag | ||
9 | that gets set whenever HSTR_EL2 is non-zero and that QEMU translates | ||
10 | a context where this trap has a chance to apply, and only generate | ||
11 | the extra access check if the hypervisor is actively using this feature. | ||
12 | |||
13 | Tested with a hand-crafted KVM guest accessing CBAR. | ||
14 | |||
15 | Signed-off-by: Marc Zyngier <maz@kernel.org> | ||
16 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
17 | Message-id: 20191201122018.25808-5-maz@kernel.org | ||
18 | [PMM: use is_a64(); fix comment syntax] | ||
19 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
20 | --- | ||
21 | target/arm/cpu.h | 2 ++ | ||
22 | target/arm/translate.h | 2 ++ | ||
23 | target/arm/helper.c | 6 ++++++ | ||
24 | target/arm/op_helper.c | 22 ++++++++++++++++++++++ | ||
25 | target/arm/translate.c | 3 ++- | ||
26 | 5 files changed, 34 insertions(+), 1 deletion(-) | ||
27 | |||
28 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
29 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
30 | --- a/target/arm/cpu.h | 16 | --- a/hw/intc/armv7m_nvic.c |
31 | +++ b/target/arm/cpu.h | 17 | +++ b/hw/intc/armv7m_nvic.c |
32 | @@ -XXX,XX +XXX,XX @@ FIELD(TBFLAG_A32, NS, 6, 1) | 18 | @@ -XXX,XX +XXX,XX @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs) |
33 | FIELD(TBFLAG_A32, VFPEN, 7, 1) /* Partially cached, minus FPEXC. */ | 19 | */ |
34 | FIELD(TBFLAG_A32, CONDEXEC, 8, 8) /* Not cached. */ | 20 | val = cpu->env.v7m.ccr[attrs.secure]; |
35 | FIELD(TBFLAG_A32, SCTLR_B, 16, 1) | 21 | val |= cpu->env.v7m.ccr[M_REG_NS] & R_V7M_CCR_BFHFNMIGN_MASK; |
36 | +FIELD(TBFLAG_A32, HSTR_ACTIVE, 17, 1) | 22 | + /* BFHFNMIGN is RAZ/WI from NS if AIRCR.BFHFNMINS is 0 */ |
37 | + | 23 | + if (!attrs.secure) { |
38 | /* For M profile only, set if FPCCR.LSPACT is set */ | 24 | + if (!(cpu->env.v7m.aircr & R_V7M_AIRCR_BFHFNMINS_MASK)) { |
39 | FIELD(TBFLAG_A32, LSPACT, 18, 1) /* Not cached. */ | 25 | + val &= ~R_V7M_CCR_BFHFNMIGN_MASK; |
40 | /* For M profile only, set if we must create a new FP context */ | 26 | + } |
41 | diff --git a/target/arm/translate.h b/target/arm/translate.h | ||
42 | index XXXXXXX..XXXXXXX 100644 | ||
43 | --- a/target/arm/translate.h | ||
44 | +++ b/target/arm/translate.h | ||
45 | @@ -XXX,XX +XXX,XX @@ typedef struct DisasContext { | ||
46 | bool pauth_active; | ||
47 | /* True with v8.5-BTI and SCTLR_ELx.BT* set. */ | ||
48 | bool bt; | ||
49 | + /* True if any CP15 access is trapped by HSTR_EL2 */ | ||
50 | + bool hstr_active; | ||
51 | /* | ||
52 | * >= 0, a copy of PSTATE.BTYPE, which will be 0 without v8.5-BTI. | ||
53 | * < 0, set by the current instruction. | ||
54 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
55 | index XXXXXXX..XXXXXXX 100644 | ||
56 | --- a/target/arm/helper.c | ||
57 | +++ b/target/arm/helper.c | ||
58 | @@ -XXX,XX +XXX,XX @@ static uint32_t rebuild_hflags_a32(CPUARMState *env, int fp_el, | ||
59 | if (arm_el_is_aa64(env, 1)) { | ||
60 | flags = FIELD_DP32(flags, TBFLAG_A32, VFPEN, 1); | ||
61 | } | ||
62 | + | ||
63 | + if (arm_current_el(env) < 2 && env->cp15.hstr_el2 && | ||
64 | + (arm_hcr_el2_eff(env) & (HCR_E2H | HCR_TGE)) != (HCR_E2H | HCR_TGE)) { | ||
65 | + flags = FIELD_DP32(flags, TBFLAG_A32, HSTR_ACTIVE, 1); | ||
66 | + } | ||
67 | + | ||
68 | return rebuild_hflags_common_32(env, fp_el, mmu_idx, flags); | ||
69 | } | ||
70 | |||
71 | diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c | ||
72 | index XXXXXXX..XXXXXXX 100644 | ||
73 | --- a/target/arm/op_helper.c | ||
74 | +++ b/target/arm/op_helper.c | ||
75 | @@ -XXX,XX +XXX,XX @@ void HELPER(access_check_cp_reg)(CPUARMState *env, void *rip, uint32_t syndrome, | ||
76 | raise_exception(env, EXCP_UDEF, syndrome, exception_target_el(env)); | ||
77 | } | ||
78 | |||
79 | + /* | ||
80 | + * Check for an EL2 trap due to HSTR_EL2. We expect EL0 accesses | ||
81 | + * to sysregs non accessible at EL0 to have UNDEF-ed already. | ||
82 | + */ | ||
83 | + if (!is_a64(env) && arm_current_el(env) < 2 && ri->cp == 15 && | ||
84 | + (arm_hcr_el2_eff(env) & (HCR_E2H | HCR_TGE)) != (HCR_E2H | HCR_TGE)) { | ||
85 | + uint32_t mask = 1 << ri->crn; | ||
86 | + | ||
87 | + if (ri->type & ARM_CP_64BIT) { | ||
88 | + mask = 1 << ri->crm; | ||
89 | + } | 27 | + } |
90 | + | 28 | return val; |
91 | + /* T4 and T14 are RES0 */ | 29 | case 0xd24: /* System Handler Control and State (SHCSR) */ |
92 | + mask &= ~((1 << 4) | (1 << 14)); | 30 | if (!arm_feature(&cpu->env, ARM_FEATURE_V7)) { |
93 | + | 31 | @@ -XXX,XX +XXX,XX @@ static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value, |
94 | + if (env->cp15.hstr_el2 & mask) { | 32 | (cpu->env.v7m.ccr[M_REG_NS] & ~R_V7M_CCR_BFHFNMIGN_MASK) |
95 | + target_el = 2; | 33 | | (value & R_V7M_CCR_BFHFNMIGN_MASK); |
96 | + goto exept; | 34 | value &= ~R_V7M_CCR_BFHFNMIGN_MASK; |
97 | + } | 35 | + } else { |
98 | + } | 36 | + /* |
99 | + | 37 | + * BFHFNMIGN is RAZ/WI from NS if AIRCR.BFHFNMINS is 0, so |
100 | if (!ri->accessfn) { | 38 | + * preserve the state currently in the NS element of the array |
101 | return; | 39 | + */ |
102 | } | 40 | + if (!(cpu->env.v7m.aircr & R_V7M_AIRCR_BFHFNMINS_MASK)) { |
103 | @@ -XXX,XX +XXX,XX @@ void HELPER(access_check_cp_reg)(CPUARMState *env, void *rip, uint32_t syndrome, | 41 | + value &= ~R_V7M_CCR_BFHFNMIGN_MASK; |
104 | g_assert_not_reached(); | 42 | + value |= cpu->env.v7m.ccr[M_REG_NS] & R_V7M_CCR_BFHFNMIGN_MASK; |
105 | } | 43 | + } |
106 | |||
107 | +exept: | ||
108 | raise_exception(env, EXCP_UDEF, syndrome, target_el); | ||
109 | } | ||
110 | |||
111 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
112 | index XXXXXXX..XXXXXXX 100644 | ||
113 | --- a/target/arm/translate.c | ||
114 | +++ b/target/arm/translate.c | ||
115 | @@ -XXX,XX +XXX,XX @@ static int disas_coproc_insn(DisasContext *s, uint32_t insn) | ||
116 | return 1; | ||
117 | } | 44 | } |
118 | 45 | ||
119 | - if (ri->accessfn || | 46 | cpu->env.v7m.ccr[attrs.secure] = value; |
120 | + if (s->hstr_active || ri->accessfn || | ||
121 | (arm_dc_feature(s, ARM_FEATURE_XSCALE) && cpnum < 14)) { | ||
122 | /* Emit code to perform further access permissions checks at | ||
123 | * runtime; this may result in an exception. | ||
124 | @@ -XXX,XX +XXX,XX @@ static void arm_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) | ||
125 | !arm_el_is_aa64(env, 3); | ||
126 | dc->thumb = FIELD_EX32(tb_flags, TBFLAG_A32, THUMB); | ||
127 | dc->sctlr_b = FIELD_EX32(tb_flags, TBFLAG_A32, SCTLR_B); | ||
128 | + dc->hstr_active = FIELD_EX32(tb_flags, TBFLAG_A32, HSTR_ACTIVE); | ||
129 | dc->be_data = FIELD_EX32(tb_flags, TBFLAG_ANY, BE_DATA) ? MO_BE : MO_LE; | ||
130 | condexec = FIELD_EX32(tb_flags, TBFLAG_A32, CONDEXEC); | ||
131 | dc->condexec_mask = (condexec & 0xf) << 1; | ||
132 | -- | 47 | -- |
133 | 2.20.1 | 48 | 2.20.1 |
134 | 49 | ||
135 | 50 | diff view generated by jsdifflib |
1 | From: Alex Bennée <alex.bennee@linaro.org> | 1 | In commit 64f863baeedc8659 we implemented the v8.1M FPCXT_S register, |
---|---|---|---|
2 | but we got the write behaviour wrong. On read, this register reads | ||
3 | bits [27:0] of FPSCR plus the CONTROL.SFPA bit. On write, it doesn't | ||
4 | just write back those bits -- it writes a value to the whole FPSCR, | ||
5 | whose upper 4 bits are zeroes. | ||
2 | 6 | ||
3 | A write to the SCR can change the effective EL by droppping the system | 7 | We also incorrectly implemented the write-to-FPSCR as a simple store |
4 | from secure to non-secure mode. However if we use a cached current_el | 8 | to vfp.xregs; this skips the "update the softfloat flags" part of |
5 | from before the change we'll rebuild the flags incorrectly. To fix | 9 | the vfp_set_fpscr helper so the value would read back correctly but |
6 | this we introduce the ARM_CP_NEWEL CP flag to indicate the new EL | 10 | not actually take effect. |
7 | should be used when recomputing the flags. | ||
8 | 11 | ||
9 | Signed-off-by: Alex Bennée <alex.bennee@linaro.org> | 12 | Fix both of these things by doing a complete write to the FPSCR |
10 | Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 13 | using the helper function. |
14 | |||
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 16 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
12 | Message-id: 20191212114734.6962-1-alex.bennee@linaro.org | 17 | Message-id: 20201210201433.26262-3-peter.maydell@linaro.org |
13 | Cc: Richard Henderson <richard.henderson@linaro.org> | ||
14 | Message-Id: <20191209143723.6368-1-alex.bennee@linaro.org> | ||
15 | Cc: qemu-stable@nongnu.org | ||
16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
17 | --- | 18 | --- |
18 | target/arm/cpu.h | 8 ++++++-- | 19 | target/arm/translate-vfp.c.inc | 12 ++++++------ |
19 | target/arm/helper.h | 1 + | 20 | 1 file changed, 6 insertions(+), 6 deletions(-) |
20 | target/arm/helper.c | 14 +++++++++++++- | ||
21 | target/arm/translate.c | 6 +++++- | ||
22 | 4 files changed, 25 insertions(+), 4 deletions(-) | ||
23 | 21 | ||
24 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 22 | diff --git a/target/arm/translate-vfp.c.inc b/target/arm/translate-vfp.c.inc |
25 | index XXXXXXX..XXXXXXX 100644 | 23 | index XXXXXXX..XXXXXXX 100644 |
26 | --- a/target/arm/cpu.h | 24 | --- a/target/arm/translate-vfp.c.inc |
27 | +++ b/target/arm/cpu.h | 25 | +++ b/target/arm/translate-vfp.c.inc |
28 | @@ -XXX,XX +XXX,XX @@ static inline uint64_t cpreg_to_kvm_id(uint32_t cpregid) | 26 | @@ -XXX,XX +XXX,XX @@ static bool gen_M_fp_sysreg_write(DisasContext *s, int regno, |
29 | * RAISES_EXC is for when the read or write hook might raise an exception; | 27 | } |
30 | * the generated code will synchronize the CPU state before calling the hook | 28 | case ARM_VFP_FPCXT_S: |
31 | * so that it is safe for the hook to call raise_exception(). | 29 | { |
32 | + * NEWEL is for writes to registers that might change the exception | 30 | - TCGv_i32 sfpa, control, fpscr; |
33 | + * level - typically on older ARM chips. For those cases we need to | 31 | - /* Set FPSCR[27:0] and CONTROL.SFPA from value */ |
34 | + * re-read the new el when recomputing the translation flags. | 32 | + TCGv_i32 sfpa, control; |
35 | */ | 33 | + /* |
36 | #define ARM_CP_SPECIAL 0x0001 | 34 | + * Set FPSCR and CONTROL.SFPA from value; the new FPSCR takes |
37 | #define ARM_CP_CONST 0x0002 | 35 | + * bits [27:0] from value and zeroes bits [31:28]. |
38 | @@ -XXX,XX +XXX,XX @@ static inline uint64_t cpreg_to_kvm_id(uint32_t cpregid) | 36 | + */ |
39 | #define ARM_CP_SVE 0x2000 | 37 | tmp = loadfn(s, opaque); |
40 | #define ARM_CP_NO_GDB 0x4000 | 38 | sfpa = tcg_temp_new_i32(); |
41 | #define ARM_CP_RAISES_EXC 0x8000 | 39 | tcg_gen_shri_i32(sfpa, tmp, 31); |
42 | +#define ARM_CP_NEWEL 0x10000 | 40 | @@ -XXX,XX +XXX,XX @@ static bool gen_M_fp_sysreg_write(DisasContext *s, int regno, |
43 | /* Used only as a terminator for ARMCPRegInfo lists */ | 41 | tcg_gen_deposit_i32(control, control, sfpa, |
44 | -#define ARM_CP_SENTINEL 0xffff | 42 | R_V7M_CONTROL_SFPA_SHIFT, 1); |
45 | +#define ARM_CP_SENTINEL 0xfffff | 43 | store_cpu_field(control, v7m.control[M_REG_S]); |
46 | /* Mask of only the flag bits in a type field */ | 44 | - fpscr = load_cpu_field(vfp.xregs[ARM_VFP_FPSCR]); |
47 | -#define ARM_CP_FLAG_MASK 0xf0ff | 45 | - tcg_gen_andi_i32(fpscr, fpscr, FPCR_NZCV_MASK); |
48 | +#define ARM_CP_FLAG_MASK 0x1f0ff | 46 | tcg_gen_andi_i32(tmp, tmp, ~FPCR_NZCV_MASK); |
49 | 47 | - tcg_gen_or_i32(fpscr, fpscr, tmp); | |
50 | /* Valid values for ARMCPRegInfo state field, indicating which of | 48 | - store_cpu_field(fpscr, vfp.xregs[ARM_VFP_FPSCR]); |
51 | * the AArch32 and AArch64 execution states this register is visible in. | 49 | + gen_helper_vfp_set_fpscr(cpu_env, tmp); |
52 | diff --git a/target/arm/helper.h b/target/arm/helper.h | 50 | tcg_temp_free_i32(tmp); |
53 | index XXXXXXX..XXXXXXX 100644 | 51 | tcg_temp_free_i32(sfpa); |
54 | --- a/target/arm/helper.h | 52 | break; |
55 | +++ b/target/arm/helper.h | ||
56 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_2(get_user_reg, i32, env, i32) | ||
57 | DEF_HELPER_3(set_user_reg, void, env, i32, i32) | ||
58 | |||
59 | DEF_HELPER_FLAGS_2(rebuild_hflags_m32, TCG_CALL_NO_RWG, void, env, int) | ||
60 | +DEF_HELPER_FLAGS_1(rebuild_hflags_a32_newel, TCG_CALL_NO_RWG, void, env) | ||
61 | DEF_HELPER_FLAGS_2(rebuild_hflags_a32, TCG_CALL_NO_RWG, void, env, int) | ||
62 | DEF_HELPER_FLAGS_2(rebuild_hflags_a64, TCG_CALL_NO_RWG, void, env, int) | ||
63 | |||
64 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
65 | index XXXXXXX..XXXXXXX 100644 | ||
66 | --- a/target/arm/helper.c | ||
67 | +++ b/target/arm/helper.c | ||
68 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo el3_cp_reginfo[] = { | ||
69 | .opc0 = 3, .opc1 = 6, .crn = 1, .crm = 1, .opc2 = 0, | ||
70 | .access = PL3_RW, .fieldoffset = offsetof(CPUARMState, cp15.scr_el3), | ||
71 | .resetvalue = 0, .writefn = scr_write }, | ||
72 | - { .name = "SCR", .type = ARM_CP_ALIAS, | ||
73 | + { .name = "SCR", .type = ARM_CP_ALIAS | ARM_CP_NEWEL, | ||
74 | .cp = 15, .opc1 = 0, .crn = 1, .crm = 1, .opc2 = 0, | ||
75 | .access = PL1_RW, .accessfn = access_trap_aa32s_el1, | ||
76 | .fieldoffset = offsetoflow32(CPUARMState, cp15.scr_el3), | ||
77 | @@ -XXX,XX +XXX,XX @@ void HELPER(rebuild_hflags_m32)(CPUARMState *env, int el) | ||
78 | env->hflags = rebuild_hflags_m32(env, fp_el, mmu_idx); | ||
79 | } | ||
80 | |||
81 | +/* | ||
82 | + * If we have triggered a EL state change we can't rely on the | ||
83 | + * translator having passed it too us, we need to recompute. | ||
84 | + */ | ||
85 | +void HELPER(rebuild_hflags_a32_newel)(CPUARMState *env) | ||
86 | +{ | ||
87 | + int el = arm_current_el(env); | ||
88 | + int fp_el = fp_exception_el(env, el); | ||
89 | + ARMMMUIdx mmu_idx = arm_mmu_idx_el(env, el); | ||
90 | + env->hflags = rebuild_hflags_a32(env, fp_el, mmu_idx); | ||
91 | +} | ||
92 | + | ||
93 | void HELPER(rebuild_hflags_a32)(CPUARMState *env, int el) | ||
94 | { | ||
95 | int fp_el = fp_exception_el(env, el); | ||
96 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
97 | index XXXXXXX..XXXXXXX 100644 | ||
98 | --- a/target/arm/translate.c | ||
99 | +++ b/target/arm/translate.c | ||
100 | @@ -XXX,XX +XXX,XX @@ static int disas_coproc_insn(DisasContext *s, uint32_t insn) | ||
101 | if (arm_dc_feature(s, ARM_FEATURE_M)) { | ||
102 | gen_helper_rebuild_hflags_m32(cpu_env, tcg_el); | ||
103 | } else { | ||
104 | - gen_helper_rebuild_hflags_a32(cpu_env, tcg_el); | ||
105 | + if (ri->type & ARM_CP_NEWEL) { | ||
106 | + gen_helper_rebuild_hflags_a32_newel(cpu_env); | ||
107 | + } else { | ||
108 | + gen_helper_rebuild_hflags_a32(cpu_env, tcg_el); | ||
109 | + } | ||
110 | } | ||
111 | tcg_temp_free_i32(tcg_el); | ||
112 | /* | ||
113 | -- | 53 | -- |
114 | 2.20.1 | 54 | 2.20.1 |
115 | 55 | ||
116 | 56 | diff view generated by jsdifflib |
1 | From: Marc Zyngier <maz@kernel.org> | 1 | Implement the v8.1M FPCXT_NS floating-point system register. This is |
---|---|---|---|
2 | a little more complicated than FPCXT_S, because it has specific | ||
3 | handling for "current FP state is inactive", and it only wants to do | ||
4 | PreserveFPState(), not the full set of actions done by | ||
5 | ExecuteFPCheck() which vfp_access_check() implements. | ||
2 | 6 | ||
3 | HCR_EL2.TID2 mandates that access from EL1 to CTR_EL0, CCSIDR_EL1, | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | CCSIDR2_EL1, CLIDR_EL1, CSSELR_EL1 are trapped to EL2, and QEMU | 8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
5 | completely ignores it, making it impossible for hypervisors to | 9 | Message-id: 20201210201433.26262-4-peter.maydell@linaro.org |
6 | virtualize the cache hierarchy. | 10 | --- |
11 | target/arm/translate-vfp.c.inc | 102 ++++++++++++++++++++++++++++++++- | ||
12 | 1 file changed, 99 insertions(+), 3 deletions(-) | ||
7 | 13 | ||
8 | Do the right thing by trapping to EL2 if HCR_EL2.TID2 is set. | 14 | diff --git a/target/arm/translate-vfp.c.inc b/target/arm/translate-vfp.c.inc |
9 | |||
10 | Signed-off-by: Marc Zyngier <maz@kernel.org> | ||
11 | Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> | ||
12 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
13 | Message-id: 20191201122018.25808-2-maz@kernel.org | ||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
15 | --- | ||
16 | target/arm/helper.c | 31 +++++++++++++++++++++++++++---- | ||
17 | 1 file changed, 27 insertions(+), 4 deletions(-) | ||
18 | |||
19 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
20 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/target/arm/helper.c | 16 | --- a/target/arm/translate-vfp.c.inc |
22 | +++ b/target/arm/helper.c | 17 | +++ b/target/arm/translate-vfp.c.inc |
23 | @@ -XXX,XX +XXX,XX @@ static void scr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) | 18 | @@ -XXX,XX +XXX,XX @@ static FPSysRegCheckResult fp_sysreg_checks(DisasContext *s, int regno) |
24 | raw_write(env, ri, value); | 19 | } |
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; | ||
25 | } | 42 | } |
26 | 43 | ||
27 | +static CPAccessResult access_aa64_tid2(CPUARMState *env, | 44 | +static void gen_branch_fpInactive(DisasContext *s, TCGCond cond, |
28 | + const ARMCPRegInfo *ri, | 45 | + TCGLabel *label) |
29 | + bool isread) | ||
30 | +{ | 46 | +{ |
31 | + if (arm_current_el(env) == 1 && (arm_hcr_el2_eff(env) & HCR_TID2)) { | 47 | + /* |
32 | + return CP_ACCESS_TRAP_EL2; | 48 | + * FPCXT_NS is a special case: it has specific handling for |
33 | + } | 49 | + * "current FP state is inactive", and must do the PreserveFPState() |
50 | + * but not the usual full set of actions done by ExecuteFPCheck(). | ||
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 | + */ | ||
59 | + assert(cond == TCG_COND_EQ || cond == TCG_COND_NE); | ||
34 | + | 60 | + |
35 | + return CP_ACCESS_OK; | 61 | + /* fpInactive = FPCCR_NS.ASPEN == 1 && CONTROL.FPCA == 0 */ |
62 | + TCGv_i32 aspen, fpca; | ||
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); | ||
36 | +} | 72 | +} |
37 | + | 73 | + |
38 | static uint64_t ccsidr_read(CPUARMState *env, const ARMCPRegInfo *ri) | 74 | static bool gen_M_fp_sysreg_write(DisasContext *s, int regno, |
75 | |||
76 | fp_sysreg_loadfn *loadfn, | ||
77 | @@ -XXX,XX +XXX,XX @@ static bool gen_M_fp_sysreg_write(DisasContext *s, int regno, | ||
39 | { | 78 | { |
40 | ARMCPU *cpu = env_archcpu(env); | 79 | /* Do a write to an M-profile floating point system register */ |
41 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v7_cp_reginfo[] = { | 80 | TCGv_i32 tmp; |
42 | .writefn = pmintenclr_write }, | 81 | + TCGLabel *lab_end = NULL; |
43 | { .name = "CCSIDR", .state = ARM_CP_STATE_BOTH, | 82 | |
44 | .opc0 = 3, .crn = 0, .crm = 0, .opc1 = 1, .opc2 = 0, | 83 | switch (fp_sysreg_checks(s, regno)) { |
45 | - .access = PL1_R, .readfn = ccsidr_read, .type = ARM_CP_NO_RAW }, | 84 | case FPSysRegCheckFailed: |
46 | + .access = PL1_R, | 85 | @@ -XXX,XX +XXX,XX @@ static bool gen_M_fp_sysreg_write(DisasContext *s, int regno, |
47 | + .accessfn = access_aa64_tid2, | 86 | tcg_temp_free_i32(tmp); |
48 | + .readfn = ccsidr_read, .type = ARM_CP_NO_RAW }, | 87 | break; |
49 | { .name = "CSSELR", .state = ARM_CP_STATE_BOTH, | 88 | } |
50 | .opc0 = 3, .crn = 0, .crm = 0, .opc1 = 2, .opc2 = 0, | 89 | + case ARM_VFP_FPCXT_NS: |
51 | - .access = PL1_RW, .writefn = csselr_write, .resetvalue = 0, | 90 | + lab_end = gen_new_label(); |
52 | + .access = PL1_RW, | 91 | + /* fpInactive case: write is a NOP, so branch to end */ |
53 | + .accessfn = access_aa64_tid2, | 92 | + gen_branch_fpInactive(s, TCG_COND_NE, lab_end); |
54 | + .writefn = csselr_write, .resetvalue = 0, | 93 | + /* !fpInactive: PreserveFPState(), and reads same as FPCXT_S */ |
55 | .bank_fieldoffsets = { offsetof(CPUARMState, cp15.csselr_s), | 94 | + gen_preserve_fp_state(s); |
56 | offsetof(CPUARMState, cp15.csselr_ns) } }, | 95 | + /* fall through */ |
57 | /* Auxiliary ID register: this actually has an IMPDEF value but for now | 96 | case ARM_VFP_FPCXT_S: |
58 | @@ -XXX,XX +XXX,XX @@ static CPAccessResult ctr_el0_access(CPUARMState *env, const ARMCPRegInfo *ri, | 97 | { |
59 | if (arm_current_el(env) == 0 && !(env->cp15.sctlr_el[1] & SCTLR_UCT)) { | 98 | TCGv_i32 sfpa, control; |
60 | return CP_ACCESS_TRAP; | 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 | + } | ||
106 | return true; | ||
107 | } | ||
108 | |||
109 | @@ -XXX,XX +XXX,XX @@ static bool gen_M_fp_sysreg_read(DisasContext *s, int regno, | ||
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(); | ||
61 | } | 168 | } |
62 | + | 169 | + |
63 | + if (arm_current_el(env) < 2 && arm_hcr_el2_eff(env) & HCR_TID2) { | 170 | + if (lab_end) { |
64 | + return CP_ACCESS_TRAP_EL2; | 171 | + gen_set_label(lab_end); |
65 | + } | 172 | + } |
66 | + | 173 | + if (lookup_tb) { |
67 | return CP_ACCESS_OK; | 174 | + gen_lookup_tb(s); |
175 | + } | ||
176 | return true; | ||
68 | } | 177 | } |
69 | 178 | ||
70 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
71 | ARMCPRegInfo clidr = { | ||
72 | .name = "CLIDR", .state = ARM_CP_STATE_BOTH, | ||
73 | .opc0 = 3, .crn = 0, .crm = 0, .opc1 = 1, .opc2 = 1, | ||
74 | - .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = cpu->clidr | ||
75 | + .access = PL1_R, .type = ARM_CP_CONST, | ||
76 | + .accessfn = access_aa64_tid2, | ||
77 | + .resetvalue = cpu->clidr | ||
78 | }; | ||
79 | define_one_arm_cp_reg(cpu, &clidr); | ||
80 | define_arm_cp_regs(cpu, v7_cp_reginfo); | ||
81 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
82 | /* These are common to v8 and pre-v8 */ | ||
83 | { .name = "CTR", | ||
84 | .cp = 15, .crn = 0, .crm = 0, .opc1 = 0, .opc2 = 1, | ||
85 | - .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = cpu->ctr }, | ||
86 | + .access = PL1_R, .accessfn = ctr_el0_access, | ||
87 | + .type = ARM_CP_CONST, .resetvalue = cpu->ctr }, | ||
88 | { .name = "CTR_EL0", .state = ARM_CP_STATE_AA64, | ||
89 | .opc0 = 3, .opc1 = 3, .opc2 = 1, .crn = 0, .crm = 0, | ||
90 | .access = PL0_R, .accessfn = ctr_el0_access, | ||
91 | -- | 179 | -- |
92 | 2.20.1 | 180 | 2.20.1 |
93 | 181 | ||
94 | 182 | diff view generated by jsdifflib |
1 | From: Christophe Lyon <christophe.lyon@linaro.org> | 1 | Now that we have implemented all the features needed by the v8.1M |
---|---|---|---|
2 | architecture, we can add the model of the Cortex-M55. This is the | ||
3 | configuration without MVE support; we'll add MVE later. | ||
2 | 4 | ||
3 | This is derived from cortex-m4 description, adding DP support and FPv5 | 5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | instructions with the corresponding flags in isar and mvfr2. | 6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
7 | Message-id: 20201210201433.26262-5-peter.maydell@linaro.org | ||
8 | --- | ||
9 | target/arm/cpu_tcg.c | 42 ++++++++++++++++++++++++++++++++++++++++++ | ||
10 | 1 file changed, 42 insertions(+) | ||
5 | 11 | ||
6 | Checked that it could successfully execute | 12 | diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c |
7 | vrinta.f32 s15, s15 | ||
8 | while cortex-m4 emulation rejects it with "illegal instruction". | ||
9 | |||
10 | Signed-off-by: Christophe Lyon <christophe.lyon@linaro.org> | ||
11 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
12 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | Message-id: 20191025090841.10299-1-christophe.lyon@linaro.org | ||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
15 | --- | ||
16 | target/arm/cpu.c | 33 +++++++++++++++++++++++++++++++++ | ||
17 | 1 file changed, 33 insertions(+) | ||
18 | |||
19 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | ||
20 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/target/arm/cpu.c | 14 | --- a/target/arm/cpu_tcg.c |
22 | +++ b/target/arm/cpu.c | 15 | +++ b/target/arm/cpu_tcg.c |
23 | @@ -XXX,XX +XXX,XX @@ static void cortex_m4_initfn(Object *obj) | 16 | @@ -XXX,XX +XXX,XX @@ static void cortex_m33_initfn(Object *obj) |
24 | cpu->isar.id_isar6 = 0x00000000; | 17 | cpu->ctr = 0x8000c000; |
25 | } | 18 | } |
26 | 19 | ||
27 | +static void cortex_m7_initfn(Object *obj) | 20 | +static void cortex_m55_initfn(Object *obj) |
28 | +{ | 21 | +{ |
29 | + ARMCPU *cpu = ARM_CPU(obj); | 22 | + ARMCPU *cpu = ARM_CPU(obj); |
30 | + | 23 | + |
31 | + set_feature(&cpu->env, ARM_FEATURE_V7); | 24 | + set_feature(&cpu->env, ARM_FEATURE_V8); |
25 | + set_feature(&cpu->env, ARM_FEATURE_V8_1M); | ||
32 | + set_feature(&cpu->env, ARM_FEATURE_M); | 26 | + set_feature(&cpu->env, ARM_FEATURE_M); |
33 | + set_feature(&cpu->env, ARM_FEATURE_M_MAIN); | 27 | + set_feature(&cpu->env, ARM_FEATURE_M_MAIN); |
28 | + set_feature(&cpu->env, ARM_FEATURE_M_SECURITY); | ||
34 | + set_feature(&cpu->env, ARM_FEATURE_THUMB_DSP); | 29 | + set_feature(&cpu->env, ARM_FEATURE_THUMB_DSP); |
35 | + set_feature(&cpu->env, ARM_FEATURE_VFP4); | 30 | + cpu->midr = 0x410fd221; /* r0p1 */ |
36 | + cpu->midr = 0x411fc272; /* r1p2 */ | 31 | + cpu->revidr = 0; |
37 | + cpu->pmsav7_dregion = 8; | 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; | 38 | + cpu->isar.mvfr0 = 0x10110221; |
39 | + cpu->isar.mvfr1 = 0x12000011; | 39 | + cpu->isar.mvfr1 = 0x12100011; |
40 | + cpu->isar.mvfr2 = 0x00000040; | 40 | + cpu->isar.mvfr2 = 0x00000040; |
41 | + cpu->id_pfr0 = 0x00000030; | 41 | + cpu->isar.id_pfr0 = 0x20000030; |
42 | + cpu->id_pfr1 = 0x00000200; | 42 | + cpu->isar.id_pfr1 = 0x00000230; |
43 | + cpu->id_dfr0 = 0x00100000; | 43 | + cpu->isar.id_dfr0 = 0x10200000; |
44 | + cpu->id_afr0 = 0x00000000; | 44 | + cpu->id_afr0 = 0x00000000; |
45 | + cpu->id_mmfr0 = 0x00100030; | 45 | + cpu->isar.id_mmfr0 = 0x00111040; |
46 | + cpu->id_mmfr1 = 0x00000000; | 46 | + cpu->isar.id_mmfr1 = 0x00000000; |
47 | + cpu->id_mmfr2 = 0x01000000; | 47 | + cpu->isar.id_mmfr2 = 0x01000000; |
48 | + cpu->id_mmfr3 = 0x00000000; | 48 | + cpu->isar.id_mmfr3 = 0x00000011; |
49 | + cpu->isar.id_isar0 = 0x01101110; | 49 | + cpu->isar.id_isar0 = 0x01103110; |
50 | + cpu->isar.id_isar1 = 0x02112000; | 50 | + cpu->isar.id_isar1 = 0x02212000; |
51 | + cpu->isar.id_isar2 = 0x20232231; | 51 | + cpu->isar.id_isar2 = 0x20232232; |
52 | + cpu->isar.id_isar3 = 0x01111131; | 52 | + cpu->isar.id_isar3 = 0x01111131; |
53 | + cpu->isar.id_isar4 = 0x01310132; | 53 | + cpu->isar.id_isar4 = 0x01310132; |
54 | + cpu->isar.id_isar5 = 0x00000000; | 54 | + cpu->isar.id_isar5 = 0x00000000; |
55 | + cpu->isar.id_isar6 = 0x00000000; | 55 | + cpu->isar.id_isar6 = 0x00000000; |
56 | + cpu->clidr = 0x00000000; /* caches not implemented */ | ||
57 | + cpu->ctr = 0x8303c003; | ||
56 | +} | 58 | +} |
57 | + | 59 | + |
58 | static void cortex_m33_initfn(Object *obj) | 60 | static const ARMCPRegInfo cortexr5_cp_reginfo[] = { |
59 | { | 61 | /* Dummy the TCM region regs for the moment */ |
60 | ARMCPU *cpu = ARM_CPU(obj); | 62 | { .name = "ATCM", .cp = 15, .opc1 = 0, .crn = 9, .crm = 1, .opc2 = 0, |
61 | @@ -XXX,XX +XXX,XX @@ static const ARMCPUInfo arm_cpus[] = { | 63 | @@ -XXX,XX +XXX,XX @@ static const ARMCPUInfo arm_tcg_cpus[] = { |
62 | .class_init = arm_v7m_class_init }, | 64 | .class_init = arm_v7m_class_init }, |
63 | { .name = "cortex-m4", .initfn = cortex_m4_initfn, | ||
64 | .class_init = arm_v7m_class_init }, | ||
65 | + { .name = "cortex-m7", .initfn = cortex_m7_initfn, | ||
66 | + .class_init = arm_v7m_class_init }, | ||
67 | { .name = "cortex-m33", .initfn = cortex_m33_initfn, | 65 | { .name = "cortex-m33", .initfn = cortex_m33_initfn, |
68 | .class_init = arm_v7m_class_init }, | 66 | .class_init = arm_v7m_class_init }, |
67 | + { .name = "cortex-m55", .initfn = cortex_m55_initfn, | ||
68 | + .class_init = arm_v7m_class_init }, | ||
69 | { .name = "cortex-r5", .initfn = cortex_r5_initfn }, | 69 | { .name = "cortex-r5", .initfn = cortex_r5_initfn }, |
70 | { .name = "cortex-r5f", .initfn = cortex_r5f_initfn }, | ||
71 | { .name = "ti925t", .initfn = ti925t_initfn }, | ||
70 | -- | 72 | -- |
71 | 2.20.1 | 73 | 2.20.1 |
72 | 74 | ||
73 | 75 | diff view generated by jsdifflib |
1 | From: Heyi Guo <guoheyi@huawei.com> | 1 | Support for running KVM on 32-bit Arm hosts was removed in commit |
---|---|---|---|
2 | 82bf7ae84ce739e. You can still run a 32-bit guest on a 64-bit Arm | ||
3 | host CPU, but because Arm KVM requires the host and guest CPU types | ||
4 | to match, it is not possible to run a guest that requires a Cortex-A9 | ||
5 | or Cortex-A15 CPU there. That means that the code in the | ||
6 | highbank/midway board models to support KVM is no longer used, and we | ||
7 | can delete it. | ||
2 | 8 | ||
3 | After the introduction of generic PCIe root port and PCIe-PCI bridge, | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | we will also have SHPC controller on ARM, so just enable SHPC native | 10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
5 | hot plug. | 11 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
12 | Message-id: 20201215144215.28482-1-peter.maydell@linaro.org | ||
13 | --- | ||
14 | hw/arm/highbank.c | 14 ++++---------- | ||
15 | 1 file changed, 4 insertions(+), 10 deletions(-) | ||
6 | 16 | ||
7 | Also update tests/data/acpi/virt/DSDT* to pass "make check". | 17 | diff --git a/hw/arm/highbank.c b/hw/arm/highbank.c |
8 | |||
9 | Cc: Shannon Zhao <shannon.zhaosl@gmail.com> | ||
10 | Cc: Peter Maydell <peter.maydell@linaro.org> | ||
11 | Cc: "Michael S. Tsirkin" <mst@redhat.com> | ||
12 | Cc: Igor Mammedov <imammedo@redhat.com> | ||
13 | Reviewed-by: Michael S. Tsirkin <mst@redhat.com> | ||
14 | Reviewed-by: Igor Mammedov <imammedo@redhat.com> | ||
15 | Signed-off-by: Heyi Guo <guoheyi@huawei.com> | ||
16 | Message-id: 20191209063719.23086-3-guoheyi@huawei.com | ||
17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
18 | --- | ||
19 | hw/arm/virt-acpi-build.c | 7 ++++++- | ||
20 | tests/data/acpi/virt/DSDT | Bin 18462 -> 18462 bytes | ||
21 | tests/data/acpi/virt/DSDT.memhp | Bin 19799 -> 19799 bytes | ||
22 | tests/data/acpi/virt/DSDT.numamem | Bin 18462 -> 18462 bytes | ||
23 | 4 files changed, 6 insertions(+), 1 deletion(-) | ||
24 | |||
25 | diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c | ||
26 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
27 | --- a/hw/arm/virt-acpi-build.c | 19 | --- a/hw/arm/highbank.c |
28 | +++ b/hw/arm/virt-acpi-build.c | 20 | +++ b/hw/arm/highbank.c |
29 | @@ -XXX,XX +XXX,XX @@ static void acpi_dsdt_add_pci(Aml *scope, const MemMapEntry *memmap, | 21 | @@ -XXX,XX +XXX,XX @@ |
30 | aml_create_dword_field(aml_arg(3), aml_int(8), "CDW3")); | 22 | #include "hw/arm/boot.h" |
31 | aml_append(ifctx, aml_store(aml_name("CDW2"), aml_name("SUPP"))); | 23 | #include "hw/loader.h" |
32 | aml_append(ifctx, aml_store(aml_name("CDW3"), aml_name("CTRL"))); | 24 | #include "net/net.h" |
33 | - aml_append(ifctx, aml_and(aml_name("CTRL"), aml_int(0x1D), | 25 | -#include "sysemu/kvm.h" |
34 | + | 26 | #include "sysemu/runstate.h" |
35 | + /* | 27 | #include "sysemu/sysemu.h" |
36 | + * Allow OS control for all 5 features: | 28 | #include "hw/boards.h" |
37 | + * PCIeHotplug SHPCHotplug PME AER PCIeCapability. | 29 | @@ -XXX,XX +XXX,XX @@ |
38 | + */ | 30 | #include "hw/cpu/a15mpcore.h" |
39 | + aml_append(ifctx, aml_and(aml_name("CTRL"), aml_int(0x1F), | 31 | #include "qemu/log.h" |
40 | aml_name("CTRL"))); | 32 | #include "qom/object.h" |
41 | 33 | +#include "cpu.h" | |
42 | ifctx1 = aml_if(aml_lnot(aml_equal(aml_arg(1), aml_int(0x1)))); | 34 | |
43 | diff --git a/tests/data/acpi/virt/DSDT b/tests/data/acpi/virt/DSDT | 35 | #define SMP_BOOT_ADDR 0x100 |
44 | index XXXXXXX..XXXXXXX 100644 | 36 | #define SMP_BOOT_REG 0x40 |
45 | GIT binary patch | 37 | @@ -XXX,XX +XXX,XX @@ static void calxeda_init(MachineState *machine, enum cxmachines machine_id) |
46 | delta 28 | 38 | highbank_binfo.loader_start = 0; |
47 | kcmbO?fpOjhMlP3Nmk>D*1_q{tja=*8809zbbW3Ff0C~9xM*si- | 39 | highbank_binfo.write_secondary_boot = hb_write_secondary; |
48 | 40 | highbank_binfo.secondary_cpu_reset_hook = hb_reset_secondary; | |
49 | delta 28 | 41 | - if (!kvm_enabled()) { |
50 | kcmbO?fpOjhMlP3Nmk>D*1_q|2ja=*87-cu_bW3Ff0C~j-M*si- | 42 | - highbank_binfo.board_setup_addr = BOARD_SETUP_ADDR; |
51 | 43 | - highbank_binfo.write_board_setup = hb_write_board_setup; | |
52 | diff --git a/tests/data/acpi/virt/DSDT.memhp b/tests/data/acpi/virt/DSDT.memhp | 44 | - highbank_binfo.secure_board_setup = true; |
53 | index XXXXXXX..XXXXXXX 100644 | 45 | - } else { |
54 | GIT binary patch | 46 | - warn_report("cannot load built-in Monitor support " |
55 | delta 28 | 47 | - "if KVM is enabled. Some guests (such as Linux) " |
56 | kcmcaUi}Cs_MlP3NmymE@1_mbija=*8809zbbeqQp0Eq|*2mk;8 | 48 | - "may not boot."); |
57 | 49 | - } | |
58 | delta 28 | 50 | + highbank_binfo.board_setup_addr = BOARD_SETUP_ADDR; |
59 | kcmcaUi}Cs_MlP3NmymE@1_ma@ja=*87-cu_beqQp0ErX{2mk;8 | 51 | + highbank_binfo.write_board_setup = hb_write_board_setup; |
60 | 52 | + highbank_binfo.secure_board_setup = true; | |
61 | diff --git a/tests/data/acpi/virt/DSDT.numamem b/tests/data/acpi/virt/DSDT.numamem | 53 | |
62 | index XXXXXXX..XXXXXXX 100644 | 54 | arm_load_kernel(ARM_CPU(first_cpu), machine, &highbank_binfo); |
63 | GIT binary patch | 55 | } |
64 | delta 28 | ||
65 | kcmbO?fpOjhMlP3Nmk>D*1_q{tja=*8809zbbW3Ff0C~9xM*si- | ||
66 | |||
67 | delta 28 | ||
68 | kcmbO?fpOjhMlP3Nmk>D*1_q|2ja=*87-cu_bW3Ff0C~j-M*si- | ||
69 | |||
70 | -- | 56 | -- |
71 | 2.20.1 | 57 | 2.20.1 |
72 | 58 | ||
73 | 59 | diff view generated by jsdifflib |
1 | From: Beata Michalska <beata.michalska@linaro.org> | 1 | Currently timer_free() is a simple wrapper for g_free(). This means |
---|---|---|---|
2 | that the timer being freed must not be currently active, as otherwise | ||
3 | QEMU might crash later when the active list is processed and still | ||
4 | has a pointer to freed memory on it. As a result almost all calls to | ||
5 | timer_free() are preceded by a timer_del() call, as can be seen in | ||
6 | the output of | ||
7 | git grep -B1 '\<timer_free\>' | ||
2 | 8 | ||
3 | Add an option to trigger memory writeback to sync given memory region | 9 | This is unfortunate API design as it makes it easy to accidentally |
4 | with the corresponding backing store, case one is available. | 10 | misuse (by forgetting the timer_del()), and the correct use is |
5 | This extends the support for persistent memory, allowing syncing on-demand. | 11 | annoyingly verbose. |
6 | 12 | ||
7 | Signed-off-by: Beata Michalska <beata.michalska@linaro.org> | 13 | Make timer_free() imply a timer_del(). |
14 | |||
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
16 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 17 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
9 | Message-id: 20191121000843.24844-3-beata.michalska@linaro.org | 18 | Message-id: 20201215154107.3255-2-peter.maydell@linaro.org |
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | 19 | --- |
12 | include/exec/memory.h | 6 ++++++ | 20 | include/qemu/timer.h | 24 +++++++++++++----------- |
13 | include/exec/ram_addr.h | 8 ++++++++ | 21 | 1 file changed, 13 insertions(+), 11 deletions(-) |
14 | include/qemu/cutils.h | 1 + | ||
15 | exec.c | 36 ++++++++++++++++++++++++++++++++++++ | ||
16 | memory.c | 12 ++++++++++++ | ||
17 | util/cutils.c | 38 ++++++++++++++++++++++++++++++++++++++ | ||
18 | 6 files changed, 101 insertions(+) | ||
19 | 22 | ||
20 | diff --git a/include/exec/memory.h b/include/exec/memory.h | 23 | diff --git a/include/qemu/timer.h b/include/qemu/timer.h |
21 | index XXXXXXX..XXXXXXX 100644 | 24 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/include/exec/memory.h | 25 | --- a/include/qemu/timer.h |
23 | +++ b/include/exec/memory.h | 26 | +++ b/include/qemu/timer.h |
24 | @@ -XXX,XX +XXX,XX @@ void *memory_region_get_ram_ptr(MemoryRegion *mr); | 27 | @@ -XXX,XX +XXX,XX @@ static inline QEMUTimer *timer_new_ms(QEMUClockType type, QEMUTimerCB *cb, |
25 | */ | 28 | */ |
26 | void memory_region_ram_resize(MemoryRegion *mr, ram_addr_t newsize, | 29 | void timer_deinit(QEMUTimer *ts); |
27 | Error **errp); | 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 | |||
28 | +/** | 49 | +/** |
29 | + * memory_region_do_writeback: Trigger writeback for selected address range | 50 | + * timer_free: |
30 | + * [addr, addr + size] | 51 | + * @ts: the timer |
31 | + * | 52 | + * |
53 | + * Free a timer. This will call timer_del() for you to remove | ||
54 | + * the timer from the active list if it was still active. | ||
32 | + */ | 55 | + */ |
33 | +void memory_region_do_writeback(MemoryRegion *mr, hwaddr addr, hwaddr size); | 56 | +static inline void timer_free(QEMUTimer *ts) |
34 | |||
35 | /** | ||
36 | * memory_region_set_log: Turn dirty logging on or off for a region. | ||
37 | diff --git a/include/exec/ram_addr.h b/include/exec/ram_addr.h | ||
38 | index XXXXXXX..XXXXXXX 100644 | ||
39 | --- a/include/exec/ram_addr.h | ||
40 | +++ b/include/exec/ram_addr.h | ||
41 | @@ -XXX,XX +XXX,XX @@ void qemu_ram_free(RAMBlock *block); | ||
42 | |||
43 | int qemu_ram_resize(RAMBlock *block, ram_addr_t newsize, Error **errp); | ||
44 | |||
45 | +void qemu_ram_writeback(RAMBlock *block, ram_addr_t start, ram_addr_t length); | ||
46 | + | ||
47 | +/* Clear whole block of mem */ | ||
48 | +static inline void qemu_ram_block_writeback(RAMBlock *block) | ||
49 | +{ | 57 | +{ |
50 | + qemu_ram_writeback(block, 0, block->used_length); | 58 | + timer_del(ts); |
59 | + g_free(ts); | ||
51 | +} | 60 | +} |
52 | + | 61 | + |
53 | #define DIRTY_CLIENTS_ALL ((1 << DIRTY_MEMORY_NUM) - 1) | 62 | /** |
54 | #define DIRTY_CLIENTS_NOCODE (DIRTY_CLIENTS_ALL & ~(1 << DIRTY_MEMORY_CODE)) | 63 | * timer_mod_ns: |
55 | 64 | * @ts: the timer | |
56 | diff --git a/include/qemu/cutils.h b/include/qemu/cutils.h | ||
57 | index XXXXXXX..XXXXXXX 100644 | ||
58 | --- a/include/qemu/cutils.h | ||
59 | +++ b/include/qemu/cutils.h | ||
60 | @@ -XXX,XX +XXX,XX @@ const char *qemu_strchrnul(const char *s, int c); | ||
61 | #endif | ||
62 | time_t mktimegm(struct tm *tm); | ||
63 | int qemu_fdatasync(int fd); | ||
64 | +int qemu_msync(void *addr, size_t length, int fd); | ||
65 | int fcntl_setfl(int fd, int flag); | ||
66 | int qemu_parse_fd(const char *param); | ||
67 | int qemu_strtoi(const char *nptr, const char **endptr, int base, | ||
68 | diff --git a/exec.c b/exec.c | ||
69 | index XXXXXXX..XXXXXXX 100644 | ||
70 | --- a/exec.c | ||
71 | +++ b/exec.c | ||
72 | @@ -XXX,XX +XXX,XX @@ | ||
73 | #include "exec/ram_addr.h" | ||
74 | #include "exec/log.h" | ||
75 | |||
76 | +#include "qemu/pmem.h" | ||
77 | + | ||
78 | #include "migration/vmstate.h" | ||
79 | |||
80 | #include "qemu/range.h" | ||
81 | @@ -XXX,XX +XXX,XX @@ int qemu_ram_resize(RAMBlock *block, ram_addr_t newsize, Error **errp) | ||
82 | return 0; | ||
83 | } | ||
84 | |||
85 | +/* | ||
86 | + * Trigger sync on the given ram block for range [start, start + length] | ||
87 | + * with the backing store if one is available. | ||
88 | + * Otherwise no-op. | ||
89 | + * @Note: this is supposed to be a synchronous op. | ||
90 | + */ | ||
91 | +void qemu_ram_writeback(RAMBlock *block, ram_addr_t start, ram_addr_t length) | ||
92 | +{ | ||
93 | + void *addr = ramblock_ptr(block, start); | ||
94 | + | ||
95 | + /* The requested range should fit in within the block range */ | ||
96 | + g_assert((start + length) <= block->used_length); | ||
97 | + | ||
98 | +#ifdef CONFIG_LIBPMEM | ||
99 | + /* The lack of support for pmem should not block the sync */ | ||
100 | + if (ramblock_is_pmem(block)) { | ||
101 | + pmem_persist(addr, length); | ||
102 | + return; | ||
103 | + } | ||
104 | +#endif | ||
105 | + if (block->fd >= 0) { | ||
106 | + /** | ||
107 | + * Case there is no support for PMEM or the memory has not been | ||
108 | + * specified as persistent (or is not one) - use the msync. | ||
109 | + * Less optimal but still achieves the same goal | ||
110 | + */ | ||
111 | + if (qemu_msync(addr, length, block->fd)) { | ||
112 | + warn_report("%s: failed to sync memory range: start: " | ||
113 | + RAM_ADDR_FMT " length: " RAM_ADDR_FMT, | ||
114 | + __func__, start, length); | ||
115 | + } | ||
116 | + } | ||
117 | +} | ||
118 | + | ||
119 | /* Called with ram_list.mutex held */ | ||
120 | static void dirty_memory_extend(ram_addr_t old_ram_size, | ||
121 | ram_addr_t new_ram_size) | ||
122 | diff --git a/memory.c b/memory.c | ||
123 | index XXXXXXX..XXXXXXX 100644 | ||
124 | --- a/memory.c | ||
125 | +++ b/memory.c | ||
126 | @@ -XXX,XX +XXX,XX @@ void memory_region_ram_resize(MemoryRegion *mr, ram_addr_t newsize, Error **errp | ||
127 | qemu_ram_resize(mr->ram_block, newsize, errp); | ||
128 | } | ||
129 | |||
130 | + | ||
131 | +void memory_region_do_writeback(MemoryRegion *mr, hwaddr addr, hwaddr size) | ||
132 | +{ | ||
133 | + /* | ||
134 | + * Might be extended case needed to cover | ||
135 | + * different types of memory regions | ||
136 | + */ | ||
137 | + if (mr->ram_block && mr->dirty_log_mask) { | ||
138 | + qemu_ram_writeback(mr->ram_block, addr, size); | ||
139 | + } | ||
140 | +} | ||
141 | + | ||
142 | /* | ||
143 | * Call proper memory listeners about the change on the newly | ||
144 | * added/removed CoalescedMemoryRange. | ||
145 | diff --git a/util/cutils.c b/util/cutils.c | ||
146 | index XXXXXXX..XXXXXXX 100644 | ||
147 | --- a/util/cutils.c | ||
148 | +++ b/util/cutils.c | ||
149 | @@ -XXX,XX +XXX,XX @@ int qemu_fdatasync(int fd) | ||
150 | #endif | ||
151 | } | ||
152 | |||
153 | +/** | ||
154 | + * Sync changes made to the memory mapped file back to the backing | ||
155 | + * storage. For POSIX compliant systems this will fallback | ||
156 | + * to regular msync call. Otherwise it will trigger whole file sync | ||
157 | + * (including the metadata case there is no support to skip that otherwise) | ||
158 | + * | ||
159 | + * @addr - start of the memory area to be synced | ||
160 | + * @length - length of the are to be synced | ||
161 | + * @fd - file descriptor for the file to be synced | ||
162 | + * (mandatory only for POSIX non-compliant systems) | ||
163 | + */ | ||
164 | +int qemu_msync(void *addr, size_t length, int fd) | ||
165 | +{ | ||
166 | +#ifdef CONFIG_POSIX | ||
167 | + size_t align_mask = ~(qemu_real_host_page_size - 1); | ||
168 | + | ||
169 | + /** | ||
170 | + * There are no strict reqs as per the length of mapping | ||
171 | + * to be synced. Still the length needs to follow the address | ||
172 | + * alignment changes. Additionally - round the size to the multiple | ||
173 | + * of PAGE_SIZE | ||
174 | + */ | ||
175 | + length += ((uintptr_t)addr & (qemu_real_host_page_size - 1)); | ||
176 | + length = (length + ~align_mask) & align_mask; | ||
177 | + | ||
178 | + addr = (void *)((uintptr_t)addr & align_mask); | ||
179 | + | ||
180 | + return msync(addr, length, MS_SYNC); | ||
181 | +#else /* CONFIG_POSIX */ | ||
182 | + /** | ||
183 | + * Perform the sync based on the file descriptor | ||
184 | + * The sync range will most probably be wider than the one | ||
185 | + * requested - but it will still get the job done | ||
186 | + */ | ||
187 | + return qemu_fdatasync(fd); | ||
188 | +#endif /* CONFIG_POSIX */ | ||
189 | +} | ||
190 | + | ||
191 | #ifndef _WIN32 | ||
192 | /* Sets a specific flag */ | ||
193 | int fcntl_setfl(int fd, int flag) | ||
194 | -- | 65 | -- |
195 | 2.20.1 | 66 | 2.20.1 |
196 | 67 | ||
197 | 68 | diff view generated by jsdifflib |
1 | From: David Gibson <david@gibson.dropbear.id.au> | 1 | Now that timer_free() implicitly calls timer_del(), sequences |
---|---|---|---|
2 | timer_del(mytimer); | ||
3 | timer_free(mytimer); | ||
2 | 4 | ||
3 | exynos4210_gic_realize() prints the number of cpus into some temporary | 5 | can be simplified to just |
4 | buffers, but it only allows 3 bytes space for it. That's plenty: | 6 | timer_free(mytimer); |
5 | existing machines will only ever set this value to EXYNOS4210_NCPUS | ||
6 | (2). But the compiler can't always figure that out, so some[*] gcc9 | ||
7 | versions emit -Wformat-truncation warnings. | ||
8 | 7 | ||
9 | We can fix that by hinting the constraint to the compiler with a | 8 | Add a Coccinelle script to do this transformation. |
10 | suitably placed assert(). | ||
11 | 9 | ||
12 | [*] The bizarre thing here, is that I've long gotten these warnings | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | compiling in a 32-bit x86 container as host - Fedora 30 with | 11 | Acked-by: Paolo Bonzini <pbonzini@redhat.com> |
14 | gcc-9.2.1-1.fc30.i686 - but it compiles just fine on my normal | ||
15 | x86_64 host - Fedora 30 with and gcc-9.2.1-1.fc30.x86_64. | ||
16 | |||
17 | Signed-off-by: David Gibson <david@gibson.dropbear.id.au> | ||
18 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 12 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> |
19 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 13 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
20 | [PMM: deleted stray blank line] | 14 | Message-id: 20201215154107.3255-3-peter.maydell@linaro.org |
21 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
22 | --- | 15 | --- |
23 | hw/intc/exynos4210_gic.c | 9 ++++++++- | 16 | scripts/coccinelle/timer-del-timer-free.cocci | 18 ++++++++++++++++++ |
24 | 1 file changed, 8 insertions(+), 1 deletion(-) | 17 | 1 file changed, 18 insertions(+) |
18 | create mode 100644 scripts/coccinelle/timer-del-timer-free.cocci | ||
25 | 19 | ||
26 | diff --git a/hw/intc/exynos4210_gic.c b/hw/intc/exynos4210_gic.c | 20 | diff --git a/scripts/coccinelle/timer-del-timer-free.cocci b/scripts/coccinelle/timer-del-timer-free.cocci |
27 | index XXXXXXX..XXXXXXX 100644 | 21 | new file mode 100644 |
28 | --- a/hw/intc/exynos4210_gic.c | 22 | index XXXXXXX..XXXXXXX |
29 | +++ b/hw/intc/exynos4210_gic.c | 23 | --- /dev/null |
30 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_gic_realize(DeviceState *dev, Error **errp) | 24 | +++ b/scripts/coccinelle/timer-del-timer-free.cocci |
31 | char cpu_alias_name[sizeof(cpu_prefix) + 3]; | 25 | @@ -XXX,XX +XXX,XX @@ |
32 | char dist_alias_name[sizeof(cpu_prefix) + 3]; | 26 | +// Remove superfluous timer_del() calls |
33 | SysBusDevice *gicbusdev; | 27 | +// |
34 | + uint32_t n = s->num_cpu; | 28 | +// Copyright Linaro Limited 2020 |
35 | uint32_t i; | 29 | +// This work is licensed under the terms of the GNU GPLv2 or later. |
36 | 30 | +// | |
37 | s->gic = qdev_create(NULL, "arm_gic"); | 31 | +// spatch --macro-file scripts/cocci-macro-file.h \ |
38 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_gic_realize(DeviceState *dev, Error **errp) | 32 | +// --sp-file scripts/coccinelle/timer-del-timer-free.cocci \ |
39 | memory_region_init(&s->dist_container, obj, "exynos4210-dist-container", | 33 | +// --in-place --dir . |
40 | EXYNOS4210_EXT_GIC_DIST_REGION_SIZE); | 34 | +// |
41 | 35 | +// The timer_free() function now implicitly calls timer_del() | |
42 | - for (i = 0; i < s->num_cpu; i++) { | 36 | +// for you, so calls to timer_del() immediately before the |
43 | + /* | 37 | +// timer_free() of the same timer can be deleted. |
44 | + * This clues in gcc that our on-stack buffers do, in fact have | 38 | + |
45 | + * enough room for the cpu numbers. gcc 9.2.1 on 32-bit x86 | 39 | +@@ |
46 | + * doesn't figure this out, otherwise and gives spurious warnings. | 40 | +expression T; |
47 | + */ | 41 | +@@ |
48 | + assert(n <= EXYNOS4210_NCPUS); | 42 | +-timer_del(T); |
49 | + for (i = 0; i < n; i++) { | 43 | + timer_free(T); |
50 | /* Map CPU interface per SMP Core */ | ||
51 | sprintf(cpu_alias_name, "%s%x", cpu_prefix, i); | ||
52 | memory_region_init_alias(&s->cpu_alias[i], obj, | ||
53 | -- | 44 | -- |
54 | 2.20.1 | 45 | 2.20.1 |
55 | 46 | ||
56 | 47 | diff view generated by jsdifflib |
1 | From: Joel Stanley <joel@jms.id.au> | 1 | This commit is the result of running the timer-del-timer-free.cocci |
---|---|---|---|
2 | script on the whole source tree. | ||
2 | 3 | ||
3 | Users benefit from knowing which watchdog timer has expired. The address | 4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | of the watchdog's registers unambiguously indicates which has expired, | 5 | Acked-by: Corey Minyard <cminyard@mvista.com> |
5 | so log that. | 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> | ||
9 | Message-id: 20201215154107.3255-4-peter.maydell@linaro.org | ||
10 | --- | ||
11 | block/iscsi.c | 2 -- | ||
12 | block/nbd.c | 1 - | ||
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(-) | ||
6 | 54 | ||
7 | Reviewed-by: Cédric Le Goater <clg@kaod.org> | 55 | diff --git a/block/iscsi.c b/block/iscsi.c |
8 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | 56 | index XXXXXXX..XXXXXXX 100644 |
9 | Signed-off-by: Joel Stanley <joel@jms.id.au> | 57 | --- a/block/iscsi.c |
10 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | 58 | +++ b/block/iscsi.c |
11 | Message-id: 20191119141211.25716-9-clg@kaod.org | 59 | @@ -XXX,XX +XXX,XX @@ static void iscsi_detach_aio_context(BlockDriverState *bs) |
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 60 | iscsilun->events = 0; |
13 | --- | 61 | |
14 | hw/watchdog/wdt_aspeed.c | 3 ++- | 62 | if (iscsilun->nop_timer) { |
15 | 1 file changed, 2 insertions(+), 1 deletion(-) | 63 | - timer_del(iscsilun->nop_timer); |
16 | 64 | timer_free(iscsilun->nop_timer); | |
17 | diff --git a/hw/watchdog/wdt_aspeed.c b/hw/watchdog/wdt_aspeed.c | 65 | iscsilun->nop_timer = NULL; |
18 | index XXXXXXX..XXXXXXX 100644 | 66 | } |
19 | --- a/hw/watchdog/wdt_aspeed.c | 67 | if (iscsilun->event_timer) { |
20 | +++ b/hw/watchdog/wdt_aspeed.c | 68 | - timer_del(iscsilun->event_timer); |
21 | @@ -XXX,XX +XXX,XX @@ static void aspeed_wdt_timer_expired(void *dev) | 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 | } | ||
254 | } | ||
255 | @@ -XXX,XX +XXX,XX @@ e1000e_core_pci_uninit(E1000ECore *core) | ||
256 | { | ||
257 | int i; | ||
258 | |||
259 | - timer_del(core->autoneg_timer); | ||
260 | timer_free(core->autoneg_timer); | ||
261 | |||
262 | e1000e_intrmgr_pci_unint(core); | ||
263 | diff --git a/hw/net/pcnet-pci.c b/hw/net/pcnet-pci.c | ||
264 | index XXXXXXX..XXXXXXX 100644 | ||
265 | --- a/hw/net/pcnet-pci.c | ||
266 | +++ b/hw/net/pcnet-pci.c | ||
267 | @@ -XXX,XX +XXX,XX @@ static void pci_pcnet_uninit(PCIDevice *dev) | ||
268 | PCIPCNetState *d = PCI_PCNET(dev); | ||
269 | |||
270 | qemu_free_irq(d->state.irq); | ||
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) | ||
22 | return; | 446 | return; |
23 | } | 447 | } |
24 | 448 | ||
25 | - qemu_log_mask(CPU_LOG_RESET, "Watchdog timer expired.\n"); | 449 | - timer_del(vvc->post_load_timer); |
26 | + qemu_log_mask(CPU_LOG_RESET, "Watchdog timer %" HWADDR_PRIx " expired.\n", | 450 | timer_free(vvc->post_load_timer); |
27 | + s->iomem.addr); | 451 | vvc->post_load_timer = NULL; |
28 | watchdog_perform_action(); | 452 | } |
29 | timer_del(s->timer); | 453 | diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c |
454 | index XXXXXXX..XXXXXXX 100644 | ||
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; | ||
30 | } | 622 | } |
31 | -- | 623 | -- |
32 | 2.20.1 | 624 | 2.20.1 |
33 | 625 | ||
34 | 626 | diff view generated by jsdifflib |
1 | From: Marc Zyngier <maz@kernel.org> | 1 | The Arm CPU finalize function uses a sequence of timer_del(), timer_deinit(), |
---|---|---|---|
2 | timer_free() to free the timer. The timer_deinit() step in this was always | ||
3 | unnecessary, and now the timer_del() is implied by timer_free(), so we can | ||
4 | collapse this down to simply calling timer_free(). | ||
2 | 5 | ||
3 | HCR_EL2.TID3 requires that AArch32 reads of MVFR[012] are trapped to | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | EL2, and HCR_EL2.TID0 does the same for reads of FPSID. | 7 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> |
5 | In order to handle this, introduce a new TCG helper function that | 8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
6 | checks for these control bits before executing the VMRC instruction. | 9 | Message-id: 20201215154107.3255-5-peter.maydell@linaro.org |
10 | --- | ||
11 | target/arm/cpu.c | 2 -- | ||
12 | 1 file changed, 2 deletions(-) | ||
7 | 13 | ||
8 | Tested with a hacked-up version of KVM/arm64 that sets the control | 14 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c |
9 | bits for 32bit guests. | ||
10 | |||
11 | Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> | ||
12 | Signed-off-by: Marc Zyngier <maz@kernel.org> | ||
13 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
14 | Message-id: 20191201122018.25808-4-maz@kernel.org | ||
15 | [PMM: move helper declaration to helper.h; make it | ||
16 | TCG_CALL_NO_WG] | ||
17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
18 | --- | ||
19 | target/arm/helper.h | 2 ++ | ||
20 | target/arm/translate-vfp.inc.c | 20 ++++++++++++++++---- | ||
21 | target/arm/vfp_helper.c | 29 +++++++++++++++++++++++++++++ | ||
22 | 3 files changed, 47 insertions(+), 4 deletions(-) | ||
23 | |||
24 | diff --git a/target/arm/helper.h b/target/arm/helper.h | ||
25 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
26 | --- a/target/arm/helper.h | 16 | --- a/target/arm/cpu.c |
27 | +++ b/target/arm/helper.h | 17 | +++ b/target/arm/cpu.c |
28 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_2(rintd, TCG_CALL_NO_RWG, f64, f64, ptr) | 18 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_finalizefn(Object *obj) |
29 | DEF_HELPER_FLAGS_2(vjcvt, TCG_CALL_NO_RWG, i32, f64, env) | 19 | } |
30 | DEF_HELPER_FLAGS_2(fjcvtzs, TCG_CALL_NO_RWG, i64, f64, ptr) | 20 | #ifndef CONFIG_USER_ONLY |
31 | 21 | if (cpu->pmu_timer) { | |
32 | +DEF_HELPER_FLAGS_3(check_hcr_el2_trap, TCG_CALL_NO_WG, void, env, i32, i32) | 22 | - timer_del(cpu->pmu_timer); |
33 | + | 23 | - timer_deinit(cpu->pmu_timer); |
34 | /* neon_helper.c */ | 24 | timer_free(cpu->pmu_timer); |
35 | DEF_HELPER_FLAGS_3(neon_qadd_u8, TCG_CALL_NO_RWG, i32, env, i32, i32) | 25 | } |
36 | DEF_HELPER_FLAGS_3(neon_qadd_s8, TCG_CALL_NO_RWG, i32, env, i32, i32) | ||
37 | diff --git a/target/arm/translate-vfp.inc.c b/target/arm/translate-vfp.inc.c | ||
38 | index XXXXXXX..XXXXXXX 100644 | ||
39 | --- a/target/arm/translate-vfp.inc.c | ||
40 | +++ b/target/arm/translate-vfp.inc.c | ||
41 | @@ -XXX,XX +XXX,XX @@ static bool trans_VMSR_VMRS(DisasContext *s, arg_VMSR_VMRS *a) | ||
42 | if (a->l) { | ||
43 | /* VMRS, move VFP special register to gp register */ | ||
44 | switch (a->reg) { | ||
45 | - case ARM_VFP_FPSID: | ||
46 | - case ARM_VFP_FPEXC: | ||
47 | - case ARM_VFP_FPINST: | ||
48 | - case ARM_VFP_FPINST2: | ||
49 | case ARM_VFP_MVFR0: | ||
50 | case ARM_VFP_MVFR1: | ||
51 | case ARM_VFP_MVFR2: | ||
52 | + case ARM_VFP_FPSID: | ||
53 | + if (s->current_el == 1) { | ||
54 | + TCGv_i32 tcg_reg, tcg_rt; | ||
55 | + | ||
56 | + gen_set_condexec(s); | ||
57 | + gen_set_pc_im(s, s->pc_curr); | ||
58 | + tcg_reg = tcg_const_i32(a->reg); | ||
59 | + tcg_rt = tcg_const_i32(a->rt); | ||
60 | + gen_helper_check_hcr_el2_trap(cpu_env, tcg_rt, tcg_reg); | ||
61 | + tcg_temp_free_i32(tcg_reg); | ||
62 | + tcg_temp_free_i32(tcg_rt); | ||
63 | + } | ||
64 | + /* fall through */ | ||
65 | + case ARM_VFP_FPEXC: | ||
66 | + case ARM_VFP_FPINST: | ||
67 | + case ARM_VFP_FPINST2: | ||
68 | tmp = load_cpu_field(vfp.xregs[a->reg]); | ||
69 | break; | ||
70 | case ARM_VFP_FPSCR: | ||
71 | diff --git a/target/arm/vfp_helper.c b/target/arm/vfp_helper.c | ||
72 | index XXXXXXX..XXXXXXX 100644 | ||
73 | --- a/target/arm/vfp_helper.c | ||
74 | +++ b/target/arm/vfp_helper.c | ||
75 | @@ -XXX,XX +XXX,XX @@ float64 HELPER(frint64_d)(float64 f, void *fpst) | ||
76 | return frint_d(f, fpst, 64); | ||
77 | } | ||
78 | |||
79 | +void HELPER(check_hcr_el2_trap)(CPUARMState *env, uint32_t rt, uint32_t reg) | ||
80 | +{ | ||
81 | + uint32_t syndrome; | ||
82 | + | ||
83 | + switch (reg) { | ||
84 | + case ARM_VFP_MVFR0: | ||
85 | + case ARM_VFP_MVFR1: | ||
86 | + case ARM_VFP_MVFR2: | ||
87 | + if (!(arm_hcr_el2_eff(env) & HCR_TID3)) { | ||
88 | + return; | ||
89 | + } | ||
90 | + break; | ||
91 | + case ARM_VFP_FPSID: | ||
92 | + if (!(arm_hcr_el2_eff(env) & HCR_TID0)) { | ||
93 | + return; | ||
94 | + } | ||
95 | + break; | ||
96 | + default: | ||
97 | + g_assert_not_reached(); | ||
98 | + } | ||
99 | + | ||
100 | + syndrome = ((EC_FPIDTRAP << ARM_EL_EC_SHIFT) | ||
101 | + | ARM_EL_IL | ||
102 | + | (1 << 24) | (0xe << 20) | (7 << 14) | ||
103 | + | (reg << 10) | (rt << 5) | 1); | ||
104 | + | ||
105 | + raise_exception(env, EXCP_HYP_TRAP, syndrome, 2); | ||
106 | +} | ||
107 | + | ||
108 | #endif | 26 | #endif |
109 | -- | 27 | -- |
110 | 2.20.1 | 28 | 2.20.1 |
111 | 29 | ||
112 | 30 | diff view generated by jsdifflib |
1 | From: Beata Michalska <beata.michalska@linaro.org> | 1 | From: Gan Qixin <ganqixin@huawei.com> |
---|---|---|---|
2 | 2 | ||
3 | Add probe_read alongside the write probing equivalent. | 3 | When running device-introspect-test, a memory leak occurred in the |
4 | digic_timer_init function, so use ptimer_free() in the finalize function to | ||
5 | avoid it. | ||
4 | 6 | ||
5 | Signed-off-by: Beata Michalska <beata.michalska@linaro.org> | 7 | ASAN shows memory leak stack: |
6 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | 8 | |
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 9 | Indirect leak of 288 byte(s) in 3 object(s) allocated from: |
8 | Message-id: 20191121000843.24844-2-beata.michalska@linaro.org | 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> | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 27 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 28 | --- |
11 | include/exec/exec-all.h | 6 ++++++ | 29 | hw/timer/digic-timer.c | 8 ++++++++ |
12 | 1 file changed, 6 insertions(+) | 30 | 1 file changed, 8 insertions(+) |
13 | 31 | ||
14 | diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h | 32 | diff --git a/hw/timer/digic-timer.c b/hw/timer/digic-timer.c |
15 | index XXXXXXX..XXXXXXX 100644 | 33 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/include/exec/exec-all.h | 34 | --- a/hw/timer/digic-timer.c |
17 | +++ b/include/exec/exec-all.h | 35 | +++ b/hw/timer/digic-timer.c |
18 | @@ -XXX,XX +XXX,XX @@ static inline void *probe_write(CPUArchState *env, target_ulong addr, int size, | 36 | @@ -XXX,XX +XXX,XX @@ static void digic_timer_init(Object *obj) |
19 | return probe_access(env, addr, size, MMU_DATA_STORE, mmu_idx, retaddr); | 37 | sysbus_init_mmio(SYS_BUS_DEVICE(obj), &s->iomem); |
20 | } | 38 | } |
21 | 39 | ||
22 | +static inline void *probe_read(CPUArchState *env, target_ulong addr, int size, | 40 | +static void digic_timer_finalize(Object *obj) |
23 | + int mmu_idx, uintptr_t retaddr) | ||
24 | +{ | 41 | +{ |
25 | + return probe_access(env, addr, size, MMU_DATA_LOAD, mmu_idx, retaddr); | 42 | + DigicTimerState *s = DIGIC_TIMER(obj); |
43 | + | ||
44 | + ptimer_free(s->ptimer); | ||
26 | +} | 45 | +} |
27 | + | 46 | + |
28 | #define CODE_GEN_ALIGN 16 /* must be >= of the size of a icache line */ | 47 | static void digic_timer_class_init(ObjectClass *klass, void *class_data) |
29 | 48 | { | |
30 | /* Estimated block size for TB allocation. */ | 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 | |||
31 | -- | 58 | -- |
32 | 2.20.1 | 59 | 2.20.1 |
33 | 60 | ||
34 | 61 | diff view generated by jsdifflib |
1 | From: Joel Stanley <joel@jms.id.au> | 1 | From: Gan Qixin <ganqixin@huawei.com> |
---|---|---|---|
2 | 2 | ||
3 | The AST2600 control register sneakily changed the meaning of bit 4 | 3 | When running device-introspect-test, a memory leak occurred in the a10_pit_init |
4 | without anyone noticing. It no longer controls the 1MHz vs APB clock | 4 | function, so use ptimer_free() in the finalize function to avoid it. |
5 | select, and instead always runs at 1MHz. | ||
6 | 5 | ||
7 | The AST2500 was always 1MHz too, but it retained bit 4, making it read | 6 | ASAN shows memory leak stack: |
8 | only. We can model both using the same fixed 1MHz calculation. | ||
9 | 7 | ||
10 | Fixes: 6b2b2a703cad ("hw: wdt_aspeed: Add AST2600 support") | 8 | Indirect leak of 288 byte(s) in 6 object(s) allocated from: |
11 | Reviewed-by: Cédric Le Goater <clg@kaod.org> | 9 | #0 0xffffab97e1f0 in __interceptor_calloc (/lib64/libasan.so.5+0xee1f0) |
12 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | 10 | #1 0xffffab256800 in g_malloc0 (/lib64/libglib-2.0.so.0+0x56800) |
13 | Signed-off-by: Joel Stanley <joel@jms.id.au> | 11 | #2 0xaaabf555db84 in timer_new_full /qemu/include/qemu/timer.h:523 |
14 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | 12 | #3 0xaaabf555db84 in timer_new /qemu/include/qemu/timer.h:544 |
15 | Message-id: 20191119141211.25716-10-clg@kaod.org | 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> | ||
16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 26 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
17 | --- | 27 | --- |
18 | include/hw/watchdog/wdt_aspeed.h | 1 + | 28 | hw/timer/allwinner-a10-pit.c | 11 +++++++++++ |
19 | hw/watchdog/wdt_aspeed.c | 21 +++++++++++++++++---- | 29 | 1 file changed, 11 insertions(+) |
20 | 2 files changed, 18 insertions(+), 4 deletions(-) | ||
21 | 30 | ||
22 | diff --git a/include/hw/watchdog/wdt_aspeed.h b/include/hw/watchdog/wdt_aspeed.h | 31 | diff --git a/hw/timer/allwinner-a10-pit.c b/hw/timer/allwinner-a10-pit.c |
23 | index XXXXXXX..XXXXXXX 100644 | 32 | index XXXXXXX..XXXXXXX 100644 |
24 | --- a/include/hw/watchdog/wdt_aspeed.h | 33 | --- a/hw/timer/allwinner-a10-pit.c |
25 | +++ b/include/hw/watchdog/wdt_aspeed.h | 34 | +++ b/hw/timer/allwinner-a10-pit.c |
26 | @@ -XXX,XX +XXX,XX @@ typedef struct AspeedWDTClass { | 35 | @@ -XXX,XX +XXX,XX @@ static void a10_pit_init(Object *obj) |
27 | uint32_t ext_pulse_width_mask; | ||
28 | uint32_t reset_ctrl_reg; | ||
29 | void (*reset_pulse)(AspeedWDTState *s, uint32_t property); | ||
30 | + void (*wdt_reload)(AspeedWDTState *s); | ||
31 | } AspeedWDTClass; | ||
32 | |||
33 | #endif /* WDT_ASPEED_H */ | ||
34 | diff --git a/hw/watchdog/wdt_aspeed.c b/hw/watchdog/wdt_aspeed.c | ||
35 | index XXXXXXX..XXXXXXX 100644 | ||
36 | --- a/hw/watchdog/wdt_aspeed.c | ||
37 | +++ b/hw/watchdog/wdt_aspeed.c | ||
38 | @@ -XXX,XX +XXX,XX @@ static uint64_t aspeed_wdt_read(void *opaque, hwaddr offset, unsigned size) | ||
39 | |||
40 | } | ||
41 | |||
42 | -static void aspeed_wdt_reload(AspeedWDTState *s, bool pclk) | ||
43 | +static void aspeed_wdt_reload(AspeedWDTState *s) | ||
44 | { | ||
45 | uint64_t reload; | ||
46 | |||
47 | - if (pclk) { | ||
48 | + if (!(s->regs[WDT_CTRL] & WDT_CTRL_1MHZ_CLK)) { | ||
49 | reload = muldiv64(s->regs[WDT_RELOAD_VALUE], NANOSECONDS_PER_SECOND, | ||
50 | s->pclk_freq); | ||
51 | } else { | ||
52 | @@ -XXX,XX +XXX,XX @@ static void aspeed_wdt_reload(AspeedWDTState *s, bool pclk) | ||
53 | } | 36 | } |
54 | } | 37 | } |
55 | 38 | ||
56 | +static void aspeed_wdt_reload_1mhz(AspeedWDTState *s) | 39 | +static void a10_pit_finalize(Object *obj) |
57 | +{ | 40 | +{ |
58 | + uint64_t reload = s->regs[WDT_RELOAD_VALUE] * 1000ULL; | 41 | + AwA10PITState *s = AW_A10_PIT(obj); |
42 | + int i; | ||
59 | + | 43 | + |
60 | + if (aspeed_wdt_is_enabled(s)) { | 44 | + for (i = 0; i < AW_A10_PIT_TIMER_NR; i++) { |
61 | + timer_mod(s->timer, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + reload); | 45 | + ptimer_free(s->timer[i]); |
62 | + } | 46 | + } |
63 | +} | 47 | +} |
64 | + | 48 | + |
65 | + | 49 | static void a10_pit_class_init(ObjectClass *klass, void *data) |
66 | static void aspeed_wdt_write(void *opaque, hwaddr offset, uint64_t data, | ||
67 | unsigned size) | ||
68 | { | 50 | { |
69 | @@ -XXX,XX +XXX,XX @@ static void aspeed_wdt_write(void *opaque, hwaddr offset, uint64_t data, | 51 | DeviceClass *dc = DEVICE_CLASS(klass); |
70 | case WDT_RESTART: | 52 | @@ -XXX,XX +XXX,XX @@ static const TypeInfo a10_pit_info = { |
71 | if ((data & 0xFFFF) == WDT_RESTART_MAGIC) { | 53 | .parent = TYPE_SYS_BUS_DEVICE, |
72 | s->regs[WDT_STATUS] = s->regs[WDT_RELOAD_VALUE]; | 54 | .instance_size = sizeof(AwA10PITState), |
73 | - aspeed_wdt_reload(s, !(s->regs[WDT_CTRL] & WDT_CTRL_1MHZ_CLK)); | 55 | .instance_init = a10_pit_init, |
74 | + awc->wdt_reload(s); | 56 | + .instance_finalize = a10_pit_finalize, |
75 | } | 57 | .class_init = a10_pit_class_init, |
76 | break; | 58 | }; |
77 | case WDT_CTRL: | 59 | |
78 | if (enable && !aspeed_wdt_is_enabled(s)) { | ||
79 | s->regs[WDT_CTRL] = data; | ||
80 | - aspeed_wdt_reload(s, !(data & WDT_CTRL_1MHZ_CLK)); | ||
81 | + awc->wdt_reload(s); | ||
82 | } else if (!enable && aspeed_wdt_is_enabled(s)) { | ||
83 | s->regs[WDT_CTRL] = data; | ||
84 | timer_del(s->timer); | ||
85 | @@ -XXX,XX +XXX,XX @@ static void aspeed_2400_wdt_class_init(ObjectClass *klass, void *data) | ||
86 | awc->offset = 0x20; | ||
87 | awc->ext_pulse_width_mask = 0xff; | ||
88 | awc->reset_ctrl_reg = SCU_RESET_CONTROL1; | ||
89 | + awc->wdt_reload = aspeed_wdt_reload; | ||
90 | } | ||
91 | |||
92 | static const TypeInfo aspeed_2400_wdt_info = { | ||
93 | @@ -XXX,XX +XXX,XX @@ static void aspeed_2500_wdt_class_init(ObjectClass *klass, void *data) | ||
94 | awc->ext_pulse_width_mask = 0xfffff; | ||
95 | awc->reset_ctrl_reg = SCU_RESET_CONTROL1; | ||
96 | awc->reset_pulse = aspeed_2500_wdt_reset_pulse; | ||
97 | + awc->wdt_reload = aspeed_wdt_reload_1mhz; | ||
98 | } | ||
99 | |||
100 | static const TypeInfo aspeed_2500_wdt_info = { | ||
101 | @@ -XXX,XX +XXX,XX @@ static void aspeed_2600_wdt_class_init(ObjectClass *klass, void *data) | ||
102 | awc->ext_pulse_width_mask = 0xfffff; /* TODO */ | ||
103 | awc->reset_ctrl_reg = AST2600_SCU_RESET_CONTROL1; | ||
104 | awc->reset_pulse = aspeed_2500_wdt_reset_pulse; | ||
105 | + awc->wdt_reload = aspeed_wdt_reload_1mhz; | ||
106 | } | ||
107 | |||
108 | static const TypeInfo aspeed_2600_wdt_info = { | ||
109 | -- | 60 | -- |
110 | 2.20.1 | 61 | 2.20.1 |
111 | 62 | ||
112 | 63 | diff view generated by jsdifflib |
1 | From: Cédric Le Goater <clg@kaod.org> | 1 | From: Gan Qixin <ganqixin@huawei.com> |
---|---|---|---|
2 | 2 | ||
3 | The I2C controller of the Aspeed AST2500 and AST2600 SoCs supports DMA | 3 | When running device-introspect-test, a memory leak occurred in the |
4 | transfers to and from DRAM. | 4 | exynos4210_rtc_init function, so use ptimer_free() in the finalize function to |
5 | avoid it. | ||
5 | 6 | ||
6 | A pair of registers defines the buffer address and the length of the | 7 | ASAN shows memory leak stack: |
7 | DMA transfer. The address should be aligned on 4 bytes and the maximum | ||
8 | length should not exceed 4K. The receive or transmit DMA transfer can | ||
9 | then be initiated with specific bits in the Command/Status register of | ||
10 | the controller. | ||
11 | 8 | ||
12 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | 9 | Indirect leak of 96 byte(s) in 1 object(s) allocated from: |
13 | Reviewed-by: Joel Stanley <joel@jms.id.au> | 10 | #0 0xffffab97e1f0 in __interceptor_calloc (/lib64/libasan.so.5+0xee1f0) |
14 | Tested-by: Jae Hyun Yoo <jae.hyun.yoo@linux.intel.com> | 11 | #1 0xffffab256800 in g_malloc0 (/lib64/libglib-2.0.so.0+0x56800) |
15 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | 12 | #2 0xaaabf555db78 in ptimer_init /qemu/hw/core/ptimer.c:432 |
16 | Message-id: 20191119141211.25716-5-clg@kaod.org | 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> | ||
17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 27 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
18 | --- | 28 | --- |
19 | include/hw/i2c/aspeed_i2c.h | 5 ++ | 29 | hw/rtc/exynos4210_rtc.c | 9 +++++++++ |
20 | hw/arm/aspeed_ast2600.c | 5 ++ | 30 | 1 file changed, 9 insertions(+) |
21 | hw/arm/aspeed_soc.c | 5 ++ | ||
22 | hw/i2c/aspeed_i2c.c | 126 +++++++++++++++++++++++++++++++++++- | ||
23 | 4 files changed, 138 insertions(+), 3 deletions(-) | ||
24 | 31 | ||
25 | diff --git a/include/hw/i2c/aspeed_i2c.h b/include/hw/i2c/aspeed_i2c.h | 32 | diff --git a/hw/rtc/exynos4210_rtc.c b/hw/rtc/exynos4210_rtc.c |
26 | index XXXXXXX..XXXXXXX 100644 | 33 | index XXXXXXX..XXXXXXX 100644 |
27 | --- a/include/hw/i2c/aspeed_i2c.h | 34 | --- a/hw/rtc/exynos4210_rtc.c |
28 | +++ b/include/hw/i2c/aspeed_i2c.h | 35 | +++ b/hw/rtc/exynos4210_rtc.c |
29 | @@ -XXX,XX +XXX,XX @@ typedef struct AspeedI2CBus { | 36 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_rtc_init(Object *obj) |
30 | uint32_t cmd; | 37 | sysbus_init_mmio(dev, &s->iomem); |
31 | uint32_t buf; | ||
32 | uint32_t pool_ctrl; | ||
33 | + uint32_t dma_addr; | ||
34 | + uint32_t dma_len; | ||
35 | } AspeedI2CBus; | ||
36 | |||
37 | typedef struct AspeedI2CState { | ||
38 | @@ -XXX,XX +XXX,XX @@ typedef struct AspeedI2CState { | ||
39 | uint8_t pool[ASPEED_I2C_MAX_POOL_SIZE]; | ||
40 | |||
41 | AspeedI2CBus busses[ASPEED_I2C_NR_BUSSES]; | ||
42 | + MemoryRegion *dram_mr; | ||
43 | + AddressSpace dram_as; | ||
44 | } AspeedI2CState; | ||
45 | |||
46 | #define ASPEED_I2C_CLASS(klass) \ | ||
47 | @@ -XXX,XX +XXX,XX @@ typedef struct AspeedI2CClass { | ||
48 | hwaddr pool_base; | ||
49 | uint8_t *(*bus_pool_base)(AspeedI2CBus *); | ||
50 | bool check_sram; | ||
51 | + bool has_dma; | ||
52 | |||
53 | } AspeedI2CClass; | ||
54 | |||
55 | diff --git a/hw/arm/aspeed_ast2600.c b/hw/arm/aspeed_ast2600.c | ||
56 | index XXXXXXX..XXXXXXX 100644 | ||
57 | --- a/hw/arm/aspeed_ast2600.c | ||
58 | +++ b/hw/arm/aspeed_ast2600.c | ||
59 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp) | ||
60 | } | ||
61 | |||
62 | /* I2C */ | ||
63 | + object_property_set_link(OBJECT(&s->i2c), OBJECT(s->dram_mr), "dram", &err); | ||
64 | + if (err) { | ||
65 | + error_propagate(errp, err); | ||
66 | + return; | ||
67 | + } | ||
68 | object_property_set_bool(OBJECT(&s->i2c), true, "realized", &err); | ||
69 | if (err) { | ||
70 | error_propagate(errp, err); | ||
71 | diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c | ||
72 | index XXXXXXX..XXXXXXX 100644 | ||
73 | --- a/hw/arm/aspeed_soc.c | ||
74 | +++ b/hw/arm/aspeed_soc.c | ||
75 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) | ||
76 | } | ||
77 | |||
78 | /* I2C */ | ||
79 | + object_property_set_link(OBJECT(&s->i2c), OBJECT(s->dram_mr), "dram", &err); | ||
80 | + if (err) { | ||
81 | + error_propagate(errp, err); | ||
82 | + return; | ||
83 | + } | ||
84 | object_property_set_bool(OBJECT(&s->i2c), true, "realized", &err); | ||
85 | if (err) { | ||
86 | error_propagate(errp, err); | ||
87 | diff --git a/hw/i2c/aspeed_i2c.c b/hw/i2c/aspeed_i2c.c | ||
88 | index XXXXXXX..XXXXXXX 100644 | ||
89 | --- a/hw/i2c/aspeed_i2c.c | ||
90 | +++ b/hw/i2c/aspeed_i2c.c | ||
91 | @@ -XXX,XX +XXX,XX @@ | ||
92 | #include "migration/vmstate.h" | ||
93 | #include "qemu/log.h" | ||
94 | #include "qemu/module.h" | ||
95 | +#include "qemu/error-report.h" | ||
96 | +#include "qapi/error.h" | ||
97 | #include "hw/i2c/aspeed_i2c.h" | ||
98 | #include "hw/irq.h" | ||
99 | +#include "hw/qdev-properties.h" | ||
100 | |||
101 | /* I2C Global Register */ | ||
102 | |||
103 | @@ -XXX,XX +XXX,XX @@ | ||
104 | #define I2CD_BYTE_BUF_TX_MASK 0xff | ||
105 | #define I2CD_BYTE_BUF_RX_SHIFT 8 | ||
106 | #define I2CD_BYTE_BUF_RX_MASK 0xff | ||
107 | - | ||
108 | +#define I2CD_DMA_ADDR 0x24 /* DMA Buffer Address */ | ||
109 | +#define I2CD_DMA_LEN 0x28 /* DMA Transfer Length < 4KB */ | ||
110 | |||
111 | static inline bool aspeed_i2c_bus_is_master(AspeedI2CBus *bus) | ||
112 | { | ||
113 | @@ -XXX,XX +XXX,XX @@ static uint64_t aspeed_i2c_bus_read(void *opaque, hwaddr offset, | ||
114 | unsigned size) | ||
115 | { | ||
116 | AspeedI2CBus *bus = opaque; | ||
117 | + AspeedI2CClass *aic = ASPEED_I2C_GET_CLASS(bus->controller); | ||
118 | |||
119 | switch (offset) { | ||
120 | case I2CD_FUN_CTRL_REG: | ||
121 | @@ -XXX,XX +XXX,XX @@ static uint64_t aspeed_i2c_bus_read(void *opaque, hwaddr offset, | ||
122 | return bus->buf; | ||
123 | case I2CD_CMD_REG: | ||
124 | return bus->cmd | (i2c_bus_busy(bus->bus) << 16); | ||
125 | + case I2CD_DMA_ADDR: | ||
126 | + if (!aic->has_dma) { | ||
127 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: No DMA support\n", __func__); | ||
128 | + return -1; | ||
129 | + } | ||
130 | + return bus->dma_addr; | ||
131 | + case I2CD_DMA_LEN: | ||
132 | + if (!aic->has_dma) { | ||
133 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: No DMA support\n", __func__); | ||
134 | + return -1; | ||
135 | + } | ||
136 | + return bus->dma_len; | ||
137 | default: | ||
138 | qemu_log_mask(LOG_GUEST_ERROR, | ||
139 | "%s: Bad offset 0x%" HWADDR_PRIx "\n", __func__, offset); | ||
140 | @@ -XXX,XX +XXX,XX @@ static uint8_t aspeed_i2c_get_state(AspeedI2CBus *bus) | ||
141 | return (bus->cmd >> I2CD_TX_STATE_SHIFT) & I2CD_TX_STATE_MASK; | ||
142 | } | 38 | } |
143 | 39 | ||
144 | +static int aspeed_i2c_dma_read(AspeedI2CBus *bus, uint8_t *data) | 40 | +static void exynos4210_rtc_finalize(Object *obj) |
145 | +{ | 41 | +{ |
146 | + MemTxResult result; | 42 | + Exynos4210RTCState *s = EXYNOS4210_RTC(obj); |
147 | + AspeedI2CState *s = bus->controller; | ||
148 | + | 43 | + |
149 | + result = address_space_read(&s->dram_as, bus->dma_addr, | 44 | + ptimer_free(s->ptimer); |
150 | + MEMTXATTRS_UNSPECIFIED, data, 1); | 45 | + ptimer_free(s->ptimer_1Hz); |
151 | + if (result != MEMTX_OK) { | ||
152 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: DRAM read failed @%08x\n", | ||
153 | + __func__, bus->dma_addr); | ||
154 | + return -1; | ||
155 | + } | ||
156 | + | ||
157 | + bus->dma_addr++; | ||
158 | + bus->dma_len--; | ||
159 | + return 0; | ||
160 | +} | 46 | +} |
161 | + | 47 | + |
162 | static int aspeed_i2c_bus_send(AspeedI2CBus *bus, uint8_t pool_start) | 48 | static void exynos4210_rtc_class_init(ObjectClass *klass, void *data) |
163 | { | ||
164 | AspeedI2CClass *aic = ASPEED_I2C_GET_CLASS(bus->controller); | ||
165 | @@ -XXX,XX +XXX,XX @@ static int aspeed_i2c_bus_send(AspeedI2CBus *bus, uint8_t pool_start) | ||
166 | } | ||
167 | } | ||
168 | bus->cmd &= ~I2CD_TX_BUFF_ENABLE; | ||
169 | + } else if (bus->cmd & I2CD_TX_DMA_ENABLE) { | ||
170 | + while (bus->dma_len) { | ||
171 | + uint8_t data; | ||
172 | + aspeed_i2c_dma_read(bus, &data); | ||
173 | + ret = i2c_send(bus->bus, data); | ||
174 | + if (ret) { | ||
175 | + break; | ||
176 | + } | ||
177 | + } | ||
178 | + bus->cmd &= ~I2CD_TX_DMA_ENABLE; | ||
179 | } else { | ||
180 | ret = i2c_send(bus->bus, bus->buf); | ||
181 | } | ||
182 | @@ -XXX,XX +XXX,XX @@ static void aspeed_i2c_bus_recv(AspeedI2CBus *bus) | ||
183 | bus->pool_ctrl &= ~(0xff << 24); | ||
184 | bus->pool_ctrl |= (i & 0xff) << 24; | ||
185 | bus->cmd &= ~I2CD_RX_BUFF_ENABLE; | ||
186 | + } else if (bus->cmd & I2CD_RX_DMA_ENABLE) { | ||
187 | + uint8_t data; | ||
188 | + | ||
189 | + while (bus->dma_len) { | ||
190 | + MemTxResult result; | ||
191 | + | ||
192 | + data = i2c_recv(bus->bus); | ||
193 | + result = address_space_write(&s->dram_as, bus->dma_addr, | ||
194 | + MEMTXATTRS_UNSPECIFIED, &data, 1); | ||
195 | + if (result != MEMTX_OK) { | ||
196 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: DRAM write failed @%08x\n", | ||
197 | + __func__, bus->dma_addr); | ||
198 | + return; | ||
199 | + } | ||
200 | + bus->dma_addr++; | ||
201 | + bus->dma_len--; | ||
202 | + } | ||
203 | + bus->cmd &= ~I2CD_RX_DMA_ENABLE; | ||
204 | } else { | ||
205 | data = i2c_recv(bus->bus); | ||
206 | bus->buf = (data & I2CD_BYTE_BUF_RX_MASK) << I2CD_BYTE_BUF_RX_SHIFT; | ||
207 | @@ -XXX,XX +XXX,XX @@ static uint8_t aspeed_i2c_get_addr(AspeedI2CBus *bus) | ||
208 | uint8_t *pool_base = aic->bus_pool_base(bus); | ||
209 | |||
210 | return pool_base[0]; | ||
211 | + } else if (bus->cmd & I2CD_TX_DMA_ENABLE) { | ||
212 | + uint8_t data; | ||
213 | + | ||
214 | + aspeed_i2c_dma_read(bus, &data); | ||
215 | + return data; | ||
216 | } else { | ||
217 | return bus->buf; | ||
218 | } | ||
219 | @@ -XXX,XX +XXX,XX @@ static void aspeed_i2c_bus_handle_cmd(AspeedI2CBus *bus, uint64_t value) | ||
220 | */ | ||
221 | pool_start++; | ||
222 | } | ||
223 | + } else if (bus->cmd & I2CD_TX_DMA_ENABLE) { | ||
224 | + if (bus->dma_len == 0) { | ||
225 | + bus->cmd &= ~I2CD_M_TX_CMD; | ||
226 | + } | ||
227 | } else { | ||
228 | bus->cmd &= ~I2CD_M_TX_CMD; | ||
229 | } | ||
230 | @@ -XXX,XX +XXX,XX @@ static void aspeed_i2c_bus_write(void *opaque, hwaddr offset, | ||
231 | break; | ||
232 | } | ||
233 | |||
234 | + if (!aic->has_dma && | ||
235 | + value & (I2CD_RX_DMA_ENABLE | I2CD_TX_DMA_ENABLE)) { | ||
236 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: No DMA support\n", __func__); | ||
237 | + break; | ||
238 | + } | ||
239 | + | ||
240 | aspeed_i2c_bus_handle_cmd(bus, value); | ||
241 | aspeed_i2c_bus_raise_interrupt(bus); | ||
242 | break; | ||
243 | + case I2CD_DMA_ADDR: | ||
244 | + if (!aic->has_dma) { | ||
245 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: No DMA support\n", __func__); | ||
246 | + break; | ||
247 | + } | ||
248 | + | ||
249 | + bus->dma_addr = value & 0xfffffffc; | ||
250 | + break; | ||
251 | + | ||
252 | + case I2CD_DMA_LEN: | ||
253 | + if (!aic->has_dma) { | ||
254 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: No DMA support\n", __func__); | ||
255 | + break; | ||
256 | + } | ||
257 | + | ||
258 | + bus->dma_len = value & 0xfff; | ||
259 | + if (!bus->dma_len) { | ||
260 | + qemu_log_mask(LOG_UNIMP, "%s: invalid DMA length\n", __func__); | ||
261 | + } | ||
262 | + break; | ||
263 | |||
264 | default: | ||
265 | qemu_log_mask(LOG_GUEST_ERROR, "%s: Bad offset 0x%" HWADDR_PRIx "\n", | ||
266 | @@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps aspeed_i2c_pool_ops = { | ||
267 | |||
268 | static const VMStateDescription aspeed_i2c_bus_vmstate = { | ||
269 | .name = TYPE_ASPEED_I2C, | ||
270 | - .version_id = 2, | ||
271 | - .minimum_version_id = 2, | ||
272 | + .version_id = 3, | ||
273 | + .minimum_version_id = 3, | ||
274 | .fields = (VMStateField[]) { | ||
275 | VMSTATE_UINT8(id, AspeedI2CBus), | ||
276 | VMSTATE_UINT32(ctrl, AspeedI2CBus), | ||
277 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription aspeed_i2c_bus_vmstate = { | ||
278 | VMSTATE_UINT32(cmd, AspeedI2CBus), | ||
279 | VMSTATE_UINT32(buf, AspeedI2CBus), | ||
280 | VMSTATE_UINT32(pool_ctrl, AspeedI2CBus), | ||
281 | + VMSTATE_UINT32(dma_addr, AspeedI2CBus), | ||
282 | + VMSTATE_UINT32(dma_len, AspeedI2CBus), | ||
283 | VMSTATE_END_OF_LIST() | ||
284 | } | ||
285 | }; | ||
286 | @@ -XXX,XX +XXX,XX @@ static void aspeed_i2c_reset(DeviceState *dev) | ||
287 | s->busses[i].intr_status = 0; | ||
288 | s->busses[i].cmd = 0; | ||
289 | s->busses[i].buf = 0; | ||
290 | + s->busses[i].dma_addr = 0; | ||
291 | + s->busses[i].dma_len = 0; | ||
292 | i2c_end_transfer(s->busses[i].bus); | ||
293 | } | ||
294 | } | ||
295 | @@ -XXX,XX +XXX,XX @@ static void aspeed_i2c_realize(DeviceState *dev, Error **errp) | ||
296 | memory_region_init_io(&s->pool_iomem, OBJECT(s), &aspeed_i2c_pool_ops, s, | ||
297 | "aspeed.i2c-pool", aic->pool_size); | ||
298 | memory_region_add_subregion(&s->iomem, aic->pool_base, &s->pool_iomem); | ||
299 | + | ||
300 | + if (aic->has_dma) { | ||
301 | + if (!s->dram_mr) { | ||
302 | + error_setg(errp, TYPE_ASPEED_I2C ": 'dram' link not set"); | ||
303 | + return; | ||
304 | + } | ||
305 | + | ||
306 | + address_space_init(&s->dram_as, s->dram_mr, "dma-dram"); | ||
307 | + } | ||
308 | } | ||
309 | |||
310 | +static Property aspeed_i2c_properties[] = { | ||
311 | + DEFINE_PROP_LINK("dram", AspeedI2CState, dram_mr, | ||
312 | + TYPE_MEMORY_REGION, MemoryRegion *), | ||
313 | + DEFINE_PROP_END_OF_LIST(), | ||
314 | +}; | ||
315 | + | ||
316 | static void aspeed_i2c_class_init(ObjectClass *klass, void *data) | ||
317 | { | 49 | { |
318 | DeviceClass *dc = DEVICE_CLASS(klass); | 50 | DeviceClass *dc = DEVICE_CLASS(klass); |
319 | 51 | @@ -XXX,XX +XXX,XX @@ static const TypeInfo exynos4210_rtc_info = { | |
320 | dc->vmsd = &aspeed_i2c_vmstate; | 52 | .parent = TYPE_SYS_BUS_DEVICE, |
321 | dc->reset = aspeed_i2c_reset; | 53 | .instance_size = sizeof(Exynos4210RTCState), |
322 | + dc->props = aspeed_i2c_properties; | 54 | .instance_init = exynos4210_rtc_init, |
323 | dc->realize = aspeed_i2c_realize; | 55 | + .instance_finalize = exynos4210_rtc_finalize, |
324 | dc->desc = "Aspeed I2C Controller"; | 56 | .class_init = exynos4210_rtc_class_init, |
325 | } | 57 | }; |
326 | @@ -XXX,XX +XXX,XX @@ static void aspeed_2500_i2c_class_init(ObjectClass *klass, void *data) | 58 | |
327 | aic->pool_base = 0x200; | ||
328 | aic->bus_pool_base = aspeed_2500_i2c_bus_pool_base; | ||
329 | aic->check_sram = true; | ||
330 | + aic->has_dma = true; | ||
331 | } | ||
332 | |||
333 | static const TypeInfo aspeed_2500_i2c_info = { | ||
334 | @@ -XXX,XX +XXX,XX @@ static void aspeed_2600_i2c_class_init(ObjectClass *klass, void *data) | ||
335 | aic->pool_size = 0x200; | ||
336 | aic->pool_base = 0xC00; | ||
337 | aic->bus_pool_base = aspeed_2600_i2c_bus_pool_base; | ||
338 | + aic->has_dma = true; | ||
339 | } | ||
340 | |||
341 | static const TypeInfo aspeed_2600_i2c_info = { | ||
342 | -- | 59 | -- |
343 | 2.20.1 | 60 | 2.20.1 |
344 | 61 | ||
345 | 62 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 1 | From: Gan Qixin <ganqixin@huawei.com> |
---|---|---|---|
2 | 2 | ||
3 | Make the gic a field in the machine state, and instead of filling | 3 | When running device-introspect-test, a memory leak occurred in the |
4 | an array of qemu_irq and passing it around, directly call | 4 | exynos4210_pwm_init function, so use ptimer_free() in the finalize function to |
5 | qdev_get_gpio_in() on the gic field. | 5 | avoid it. |
6 | 6 | ||
7 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 7 | ASAN shows memory leak stack: |
8 | Message-id: 20191206162303.30338-1-philmd@redhat.com | 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> | ||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 26 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 27 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 28 | --- |
12 | hw/arm/sbsa-ref.c | 86 +++++++++++++++++++++++------------------------ | 29 | hw/timer/exynos4210_pwm.c | 11 +++++++++++ |
13 | 1 file changed, 42 insertions(+), 44 deletions(-) | 30 | 1 file changed, 11 insertions(+) |
14 | 31 | ||
15 | diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c | 32 | diff --git a/hw/timer/exynos4210_pwm.c b/hw/timer/exynos4210_pwm.c |
16 | index XXXXXXX..XXXXXXX 100644 | 33 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/hw/arm/sbsa-ref.c | 34 | --- a/hw/timer/exynos4210_pwm.c |
18 | +++ b/hw/arm/sbsa-ref.c | 35 | +++ b/hw/timer/exynos4210_pwm.c |
19 | @@ -XXX,XX +XXX,XX @@ typedef struct { | 36 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_pwm_init(Object *obj) |
20 | void *fdt; | 37 | sysbus_init_mmio(dev, &s->iomem); |
21 | int fdt_size; | ||
22 | int psci_conduit; | ||
23 | + DeviceState *gic; | ||
24 | PFlashCFI01 *flash[2]; | ||
25 | } SBSAMachineState; | ||
26 | |||
27 | @@ -XXX,XX +XXX,XX @@ static void create_secure_ram(SBSAMachineState *sms, | ||
28 | memory_region_add_subregion(secure_sysmem, base, secram); | ||
29 | } | 38 | } |
30 | 39 | ||
31 | -static void create_gic(SBSAMachineState *sms, qemu_irq *pic) | 40 | +static void exynos4210_pwm_finalize(Object *obj) |
32 | +static void create_gic(SBSAMachineState *sms) | 41 | +{ |
42 | + Exynos4210PWMState *s = EXYNOS4210_PWM(obj); | ||
43 | + int i; | ||
44 | + | ||
45 | + for (i = 0; i < EXYNOS4210_PWM_TIMERS_NUM; i++) { | ||
46 | + ptimer_free(s->timer[i].ptimer); | ||
47 | + } | ||
48 | +} | ||
49 | + | ||
50 | static void exynos4210_pwm_class_init(ObjectClass *klass, void *data) | ||
33 | { | 51 | { |
34 | unsigned int smp_cpus = MACHINE(sms)->smp.cpus; | 52 | DeviceClass *dc = DEVICE_CLASS(klass); |
35 | - DeviceState *gicdev; | 53 | @@ -XXX,XX +XXX,XX @@ static const TypeInfo exynos4210_pwm_info = { |
36 | SysBusDevice *gicbusdev; | 54 | .parent = TYPE_SYS_BUS_DEVICE, |
37 | const char *gictype; | 55 | .instance_size = sizeof(Exynos4210PWMState), |
38 | uint32_t redist0_capacity, redist0_count; | 56 | .instance_init = exynos4210_pwm_init, |
39 | @@ -XXX,XX +XXX,XX @@ static void create_gic(SBSAMachineState *sms, qemu_irq *pic) | 57 | + .instance_finalize = exynos4210_pwm_finalize, |
40 | 58 | .class_init = exynos4210_pwm_class_init, | |
41 | gictype = gicv3_class_name(); | ||
42 | |||
43 | - gicdev = qdev_create(NULL, gictype); | ||
44 | - qdev_prop_set_uint32(gicdev, "revision", 3); | ||
45 | - qdev_prop_set_uint32(gicdev, "num-cpu", smp_cpus); | ||
46 | + sms->gic = qdev_create(NULL, gictype); | ||
47 | + qdev_prop_set_uint32(sms->gic, "revision", 3); | ||
48 | + qdev_prop_set_uint32(sms->gic, "num-cpu", smp_cpus); | ||
49 | /* | ||
50 | * Note that the num-irq property counts both internal and external | ||
51 | * interrupts; there are always 32 of the former (mandated by GIC spec). | ||
52 | */ | ||
53 | - qdev_prop_set_uint32(gicdev, "num-irq", NUM_IRQS + 32); | ||
54 | - qdev_prop_set_bit(gicdev, "has-security-extensions", true); | ||
55 | + qdev_prop_set_uint32(sms->gic, "num-irq", NUM_IRQS + 32); | ||
56 | + qdev_prop_set_bit(sms->gic, "has-security-extensions", true); | ||
57 | |||
58 | redist0_capacity = | ||
59 | sbsa_ref_memmap[SBSA_GIC_REDIST].size / GICV3_REDIST_SIZE; | ||
60 | redist0_count = MIN(smp_cpus, redist0_capacity); | ||
61 | |||
62 | - qdev_prop_set_uint32(gicdev, "len-redist-region-count", 1); | ||
63 | - qdev_prop_set_uint32(gicdev, "redist-region-count[0]", redist0_count); | ||
64 | + qdev_prop_set_uint32(sms->gic, "len-redist-region-count", 1); | ||
65 | + qdev_prop_set_uint32(sms->gic, "redist-region-count[0]", redist0_count); | ||
66 | |||
67 | - qdev_init_nofail(gicdev); | ||
68 | - gicbusdev = SYS_BUS_DEVICE(gicdev); | ||
69 | + qdev_init_nofail(sms->gic); | ||
70 | + gicbusdev = SYS_BUS_DEVICE(sms->gic); | ||
71 | sysbus_mmio_map(gicbusdev, 0, sbsa_ref_memmap[SBSA_GIC_DIST].base); | ||
72 | sysbus_mmio_map(gicbusdev, 1, sbsa_ref_memmap[SBSA_GIC_REDIST].base); | ||
73 | |||
74 | @@ -XXX,XX +XXX,XX @@ static void create_gic(SBSAMachineState *sms, qemu_irq *pic) | ||
75 | |||
76 | for (irq = 0; irq < ARRAY_SIZE(timer_irq); irq++) { | ||
77 | qdev_connect_gpio_out(cpudev, irq, | ||
78 | - qdev_get_gpio_in(gicdev, | ||
79 | + qdev_get_gpio_in(sms->gic, | ||
80 | ppibase + timer_irq[irq])); | ||
81 | } | ||
82 | |||
83 | qdev_connect_gpio_out_named(cpudev, "gicv3-maintenance-interrupt", 0, | ||
84 | - qdev_get_gpio_in(gicdev, ppibase | ||
85 | + qdev_get_gpio_in(sms->gic, ppibase | ||
86 | + ARCH_GIC_MAINT_IRQ)); | ||
87 | qdev_connect_gpio_out_named(cpudev, "pmu-interrupt", 0, | ||
88 | - qdev_get_gpio_in(gicdev, ppibase | ||
89 | + qdev_get_gpio_in(sms->gic, ppibase | ||
90 | + VIRTUAL_PMU_IRQ)); | ||
91 | |||
92 | sysbus_connect_irq(gicbusdev, i, qdev_get_gpio_in(cpudev, ARM_CPU_IRQ)); | ||
93 | @@ -XXX,XX +XXX,XX @@ static void create_gic(SBSAMachineState *sms, qemu_irq *pic) | ||
94 | sysbus_connect_irq(gicbusdev, i + 3 * smp_cpus, | ||
95 | qdev_get_gpio_in(cpudev, ARM_CPU_VFIQ)); | ||
96 | } | ||
97 | - | ||
98 | - for (i = 0; i < NUM_IRQS; i++) { | ||
99 | - pic[i] = qdev_get_gpio_in(gicdev, i); | ||
100 | - } | ||
101 | } | ||
102 | |||
103 | -static void create_uart(const SBSAMachineState *sms, qemu_irq *pic, int uart, | ||
104 | +static void create_uart(const SBSAMachineState *sms, int uart, | ||
105 | MemoryRegion *mem, Chardev *chr) | ||
106 | { | ||
107 | hwaddr base = sbsa_ref_memmap[uart].base; | ||
108 | @@ -XXX,XX +XXX,XX @@ static void create_uart(const SBSAMachineState *sms, qemu_irq *pic, int uart, | ||
109 | qdev_init_nofail(dev); | ||
110 | memory_region_add_subregion(mem, base, | ||
111 | sysbus_mmio_get_region(s, 0)); | ||
112 | - sysbus_connect_irq(s, 0, pic[irq]); | ||
113 | + sysbus_connect_irq(s, 0, qdev_get_gpio_in(sms->gic, irq)); | ||
114 | } | ||
115 | |||
116 | -static void create_rtc(const SBSAMachineState *sms, qemu_irq *pic) | ||
117 | +static void create_rtc(const SBSAMachineState *sms) | ||
118 | { | ||
119 | hwaddr base = sbsa_ref_memmap[SBSA_RTC].base; | ||
120 | int irq = sbsa_ref_irqmap[SBSA_RTC]; | ||
121 | |||
122 | - sysbus_create_simple("pl031", base, pic[irq]); | ||
123 | + sysbus_create_simple("pl031", base, qdev_get_gpio_in(sms->gic, irq)); | ||
124 | } | ||
125 | |||
126 | static DeviceState *gpio_key_dev; | ||
127 | @@ -XXX,XX +XXX,XX @@ static Notifier sbsa_ref_powerdown_notifier = { | ||
128 | .notify = sbsa_ref_powerdown_req | ||
129 | }; | 59 | }; |
130 | 60 | ||
131 | -static void create_gpio(const SBSAMachineState *sms, qemu_irq *pic) | ||
132 | +static void create_gpio(const SBSAMachineState *sms) | ||
133 | { | ||
134 | DeviceState *pl061_dev; | ||
135 | hwaddr base = sbsa_ref_memmap[SBSA_GPIO].base; | ||
136 | int irq = sbsa_ref_irqmap[SBSA_GPIO]; | ||
137 | |||
138 | - pl061_dev = sysbus_create_simple("pl061", base, pic[irq]); | ||
139 | + pl061_dev = sysbus_create_simple("pl061", base, | ||
140 | + qdev_get_gpio_in(sms->gic, irq)); | ||
141 | |||
142 | gpio_key_dev = sysbus_create_simple("gpio-key", -1, | ||
143 | qdev_get_gpio_in(pl061_dev, 3)); | ||
144 | @@ -XXX,XX +XXX,XX @@ static void create_gpio(const SBSAMachineState *sms, qemu_irq *pic) | ||
145 | qemu_register_powerdown_notifier(&sbsa_ref_powerdown_notifier); | ||
146 | } | ||
147 | |||
148 | -static void create_ahci(const SBSAMachineState *sms, qemu_irq *pic) | ||
149 | +static void create_ahci(const SBSAMachineState *sms) | ||
150 | { | ||
151 | hwaddr base = sbsa_ref_memmap[SBSA_AHCI].base; | ||
152 | int irq = sbsa_ref_irqmap[SBSA_AHCI]; | ||
153 | @@ -XXX,XX +XXX,XX @@ static void create_ahci(const SBSAMachineState *sms, qemu_irq *pic) | ||
154 | qdev_prop_set_uint32(dev, "num-ports", NUM_SATA_PORTS); | ||
155 | qdev_init_nofail(dev); | ||
156 | sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, base); | ||
157 | - sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, pic[irq]); | ||
158 | + sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, qdev_get_gpio_in(sms->gic, irq)); | ||
159 | |||
160 | sysahci = SYSBUS_AHCI(dev); | ||
161 | ahci = &sysahci->ahci; | ||
162 | @@ -XXX,XX +XXX,XX @@ static void create_ahci(const SBSAMachineState *sms, qemu_irq *pic) | ||
163 | } | ||
164 | } | ||
165 | |||
166 | -static void create_ehci(const SBSAMachineState *sms, qemu_irq *pic) | ||
167 | +static void create_ehci(const SBSAMachineState *sms) | ||
168 | { | ||
169 | hwaddr base = sbsa_ref_memmap[SBSA_EHCI].base; | ||
170 | int irq = sbsa_ref_irqmap[SBSA_EHCI]; | ||
171 | |||
172 | - sysbus_create_simple("platform-ehci-usb", base, pic[irq]); | ||
173 | + sysbus_create_simple("platform-ehci-usb", base, | ||
174 | + qdev_get_gpio_in(sms->gic, irq)); | ||
175 | } | ||
176 | |||
177 | -static void create_smmu(const SBSAMachineState *sms, qemu_irq *pic, | ||
178 | - PCIBus *bus) | ||
179 | +static void create_smmu(const SBSAMachineState *sms, PCIBus *bus) | ||
180 | { | ||
181 | hwaddr base = sbsa_ref_memmap[SBSA_SMMU].base; | ||
182 | int irq = sbsa_ref_irqmap[SBSA_SMMU]; | ||
183 | @@ -XXX,XX +XXX,XX @@ static void create_smmu(const SBSAMachineState *sms, qemu_irq *pic, | ||
184 | qdev_init_nofail(dev); | ||
185 | sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, base); | ||
186 | for (i = 0; i < NUM_SMMU_IRQS; i++) { | ||
187 | - sysbus_connect_irq(SYS_BUS_DEVICE(dev), i, pic[irq + i]); | ||
188 | + sysbus_connect_irq(SYS_BUS_DEVICE(dev), i, | ||
189 | + qdev_get_gpio_in(sms->gic, irq + 1)); | ||
190 | } | ||
191 | } | ||
192 | |||
193 | -static void create_pcie(SBSAMachineState *sms, qemu_irq *pic) | ||
194 | +static void create_pcie(SBSAMachineState *sms) | ||
195 | { | ||
196 | hwaddr base_ecam = sbsa_ref_memmap[SBSA_PCIE_ECAM].base; | ||
197 | hwaddr size_ecam = sbsa_ref_memmap[SBSA_PCIE_ECAM].size; | ||
198 | @@ -XXX,XX +XXX,XX @@ static void create_pcie(SBSAMachineState *sms, qemu_irq *pic) | ||
199 | sysbus_mmio_map(SYS_BUS_DEVICE(dev), 2, base_pio); | ||
200 | |||
201 | for (i = 0; i < GPEX_NUM_IRQS; i++) { | ||
202 | - sysbus_connect_irq(SYS_BUS_DEVICE(dev), i, pic[irq + i]); | ||
203 | + sysbus_connect_irq(SYS_BUS_DEVICE(dev), i, | ||
204 | + qdev_get_gpio_in(sms->gic, irq + 1)); | ||
205 | gpex_set_irq_num(GPEX_HOST(dev), i, irq + i); | ||
206 | } | ||
207 | |||
208 | @@ -XXX,XX +XXX,XX @@ static void create_pcie(SBSAMachineState *sms, qemu_irq *pic) | ||
209 | |||
210 | pci_create_simple(pci->bus, -1, "VGA"); | ||
211 | |||
212 | - create_smmu(sms, pic, pci->bus); | ||
213 | + create_smmu(sms, pci->bus); | ||
214 | } | ||
215 | |||
216 | static void *sbsa_ref_dtb(const struct arm_boot_info *binfo, int *fdt_size) | ||
217 | @@ -XXX,XX +XXX,XX @@ static void sbsa_ref_init(MachineState *machine) | ||
218 | bool firmware_loaded; | ||
219 | const CPUArchIdList *possible_cpus; | ||
220 | int n, sbsa_max_cpus; | ||
221 | - qemu_irq pic[NUM_IRQS]; | ||
222 | |||
223 | if (strcmp(machine->cpu_type, ARM_CPU_TYPE_NAME("cortex-a57"))) { | ||
224 | error_report("sbsa-ref: CPU type other than the built-in " | ||
225 | @@ -XXX,XX +XXX,XX @@ static void sbsa_ref_init(MachineState *machine) | ||
226 | |||
227 | create_secure_ram(sms, secure_sysmem); | ||
228 | |||
229 | - create_gic(sms, pic); | ||
230 | + create_gic(sms); | ||
231 | |||
232 | - create_uart(sms, pic, SBSA_UART, sysmem, serial_hd(0)); | ||
233 | - create_uart(sms, pic, SBSA_SECURE_UART, secure_sysmem, serial_hd(1)); | ||
234 | + create_uart(sms, SBSA_UART, sysmem, serial_hd(0)); | ||
235 | + create_uart(sms, SBSA_SECURE_UART, secure_sysmem, serial_hd(1)); | ||
236 | /* Second secure UART for RAS and MM from EL0 */ | ||
237 | - create_uart(sms, pic, SBSA_SECURE_UART_MM, secure_sysmem, serial_hd(2)); | ||
238 | + create_uart(sms, SBSA_SECURE_UART_MM, secure_sysmem, serial_hd(2)); | ||
239 | |||
240 | - create_rtc(sms, pic); | ||
241 | + create_rtc(sms); | ||
242 | |||
243 | - create_gpio(sms, pic); | ||
244 | + create_gpio(sms); | ||
245 | |||
246 | - create_ahci(sms, pic); | ||
247 | + create_ahci(sms); | ||
248 | |||
249 | - create_ehci(sms, pic); | ||
250 | + create_ehci(sms); | ||
251 | |||
252 | - create_pcie(sms, pic); | ||
253 | + create_pcie(sms); | ||
254 | |||
255 | sms->bootinfo.ram_size = machine->ram_size; | ||
256 | sms->bootinfo.nb_cpus = smp_cpus; | ||
257 | -- | 61 | -- |
258 | 2.20.1 | 62 | 2.20.1 |
259 | 63 | ||
260 | 64 | diff view generated by jsdifflib |
1 | From: Beata Michalska <beata.michalska@linaro.org> | 1 | From: Gan Qixin <ganqixin@huawei.com> |
---|---|---|---|
2 | 2 | ||
3 | ARMv8.2 introduced support for Data Cache Clean instructions | 3 | When running device-introspect-test, a memory leak occurred in the |
4 | to PoP (point-of-persistence) - DC CVAP and PoDP (point-of-deep-persistence) | 4 | mss_timer_init function, so use ptimer_free() in the finalize function to avoid |
5 | - DV CVADP. Both specify conceptual points in a memory system where all writes | 5 | it. |
6 | that are to reach them are considered persistent. | ||
7 | The support provided considers both to be actually the same so there is no | ||
8 | distinction between the two. If none is available (there is no backing store | ||
9 | for given memory) both will result in Data Cache Clean up to the point of | ||
10 | coherency. Otherwise sync for the specified range shall be performed. | ||
11 | 6 | ||
12 | Signed-off-by: Beata Michalska <beata.michalska@linaro.org> | 7 | ASAN shows memory leak stack: |
13 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 8 | |
14 | Message-id: 20191121000843.24844-5-beata.michalska@linaro.org | 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> | ||
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 27 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
16 | --- | 28 | --- |
17 | target/arm/cpu.h | 10 ++++++++ | 29 | hw/timer/mss-timer.c | 13 +++++++++++++ |
18 | linux-user/elfload.c | 2 ++ | 30 | 1 file changed, 13 insertions(+) |
19 | target/arm/cpu64.c | 1 + | ||
20 | target/arm/helper.c | 56 ++++++++++++++++++++++++++++++++++++++++++++ | ||
21 | 4 files changed, 69 insertions(+) | ||
22 | 31 | ||
23 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 32 | diff --git a/hw/timer/mss-timer.c b/hw/timer/mss-timer.c |
24 | index XXXXXXX..XXXXXXX 100644 | 33 | index XXXXXXX..XXXXXXX 100644 |
25 | --- a/target/arm/cpu.h | 34 | --- a/hw/timer/mss-timer.c |
26 | +++ b/target/arm/cpu.h | 35 | +++ b/hw/timer/mss-timer.c |
27 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa64_frint(const ARMISARegisters *id) | 36 | @@ -XXX,XX +XXX,XX @@ static void mss_timer_init(Object *obj) |
28 | return FIELD_EX64(id->id_aa64isar1, ID_AA64ISAR1, FRINTTS) != 0; | 37 | sysbus_init_mmio(SYS_BUS_DEVICE(obj), &t->mmio); |
29 | } | 38 | } |
30 | 39 | ||
31 | +static inline bool isar_feature_aa64_dcpop(const ARMISARegisters *id) | 40 | +static void mss_timer_finalize(Object *obj) |
32 | +{ | 41 | +{ |
33 | + return FIELD_EX64(id->id_aa64isar1, ID_AA64ISAR1, DPB) != 0; | 42 | + MSSTimerState *t = MSS_TIMER(obj); |
34 | +} | 43 | + int i; |
35 | + | 44 | + |
36 | +static inline bool isar_feature_aa64_dcpodp(const ARMISARegisters *id) | 45 | + for (i = 0; i < NUM_TIMERS; i++) { |
37 | +{ | 46 | + struct Msf2Timer *st = &t->timers[i]; |
38 | + return FIELD_EX64(id->id_aa64isar1, ID_AA64ISAR1, DPB) >= 2; | ||
39 | +} | ||
40 | + | 47 | + |
41 | static inline bool isar_feature_aa64_fp16(const ARMISARegisters *id) | 48 | + ptimer_free(st->ptimer); |
42 | { | ||
43 | /* We always set the AdvSIMD and FP fields identically wrt FP16. */ | ||
44 | diff --git a/linux-user/elfload.c b/linux-user/elfload.c | ||
45 | index XXXXXXX..XXXXXXX 100644 | ||
46 | --- a/linux-user/elfload.c | ||
47 | +++ b/linux-user/elfload.c | ||
48 | @@ -XXX,XX +XXX,XX @@ static uint32_t get_elf_hwcap(void) | ||
49 | GET_FEATURE_ID(aa64_jscvt, ARM_HWCAP_A64_JSCVT); | ||
50 | GET_FEATURE_ID(aa64_sb, ARM_HWCAP_A64_SB); | ||
51 | GET_FEATURE_ID(aa64_condm_4, ARM_HWCAP_A64_FLAGM); | ||
52 | + GET_FEATURE_ID(aa64_dcpop, ARM_HWCAP_A64_DCPOP); | ||
53 | |||
54 | return hwcaps; | ||
55 | } | ||
56 | @@ -XXX,XX +XXX,XX @@ static uint32_t get_elf_hwcap2(void) | ||
57 | ARMCPU *cpu = ARM_CPU(thread_cpu); | ||
58 | uint32_t hwcaps = 0; | ||
59 | |||
60 | + GET_FEATURE_ID(aa64_dcpodp, ARM_HWCAP2_A64_DCPODP); | ||
61 | GET_FEATURE_ID(aa64_condm_5, ARM_HWCAP2_A64_FLAGM2); | ||
62 | GET_FEATURE_ID(aa64_frint, ARM_HWCAP2_A64_FRINT); | ||
63 | |||
64 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | ||
65 | index XXXXXXX..XXXXXXX 100644 | ||
66 | --- a/target/arm/cpu64.c | ||
67 | +++ b/target/arm/cpu64.c | ||
68 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) | ||
69 | cpu->isar.id_aa64isar0 = t; | ||
70 | |||
71 | t = cpu->isar.id_aa64isar1; | ||
72 | + t = FIELD_DP64(t, ID_AA64ISAR1, DPB, 2); | ||
73 | t = FIELD_DP64(t, ID_AA64ISAR1, JSCVT, 1); | ||
74 | t = FIELD_DP64(t, ID_AA64ISAR1, FCMA, 1); | ||
75 | t = FIELD_DP64(t, ID_AA64ISAR1, APA, 1); /* PAuth, architected only */ | ||
76 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
77 | index XXXXXXX..XXXXXXX 100644 | ||
78 | --- a/target/arm/helper.c | ||
79 | +++ b/target/arm/helper.c | ||
80 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo rndr_reginfo[] = { | ||
81 | .access = PL0_R, .readfn = rndr_readfn }, | ||
82 | REGINFO_SENTINEL | ||
83 | }; | ||
84 | + | ||
85 | +#ifndef CONFIG_USER_ONLY | ||
86 | +static void dccvap_writefn(CPUARMState *env, const ARMCPRegInfo *opaque, | ||
87 | + uint64_t value) | ||
88 | +{ | ||
89 | + ARMCPU *cpu = env_archcpu(env); | ||
90 | + /* CTR_EL0 System register -> DminLine, bits [19:16] */ | ||
91 | + uint64_t dline_size = 4 << ((cpu->ctr >> 16) & 0xF); | ||
92 | + uint64_t vaddr_in = (uint64_t) value; | ||
93 | + uint64_t vaddr = vaddr_in & ~(dline_size - 1); | ||
94 | + void *haddr; | ||
95 | + int mem_idx = cpu_mmu_index(env, false); | ||
96 | + | ||
97 | + /* This won't be crossing page boundaries */ | ||
98 | + haddr = probe_read(env, vaddr, dline_size, mem_idx, GETPC()); | ||
99 | + if (haddr) { | ||
100 | + | ||
101 | + ram_addr_t offset; | ||
102 | + MemoryRegion *mr; | ||
103 | + | ||
104 | + /* RCU lock is already being held */ | ||
105 | + mr = memory_region_from_host(haddr, &offset); | ||
106 | + | ||
107 | + if (mr) { | ||
108 | + memory_region_do_writeback(mr, offset, dline_size); | ||
109 | + } | ||
110 | + } | 49 | + } |
111 | +} | 50 | +} |
112 | + | 51 | + |
113 | +static const ARMCPRegInfo dcpop_reg[] = { | 52 | static const VMStateDescription vmstate_timers = { |
114 | + { .name = "DC_CVAP", .state = ARM_CP_STATE_AA64, | 53 | .name = "mss-timer-block", |
115 | + .opc0 = 1, .opc1 = 3, .crn = 7, .crm = 12, .opc2 = 1, | 54 | .version_id = 1, |
116 | + .access = PL0_W, .type = ARM_CP_NO_RAW | ARM_CP_SUPPRESS_TB_END, | 55 | @@ -XXX,XX +XXX,XX @@ static const TypeInfo mss_timer_info = { |
117 | + .accessfn = aa64_cacheop_access, .writefn = dccvap_writefn }, | 56 | .parent = TYPE_SYS_BUS_DEVICE, |
118 | + REGINFO_SENTINEL | 57 | .instance_size = sizeof(MSSTimerState), |
119 | +}; | 58 | .instance_init = mss_timer_init, |
120 | + | 59 | + .instance_finalize = mss_timer_finalize, |
121 | +static const ARMCPRegInfo dcpodp_reg[] = { | 60 | .class_init = mss_timer_class_init, |
122 | + { .name = "DC_CVADP", .state = ARM_CP_STATE_AA64, | 61 | }; |
123 | + .opc0 = 1, .opc1 = 3, .crn = 7, .crm = 13, .opc2 = 1, | 62 | |
124 | + .access = PL0_W, .type = ARM_CP_NO_RAW | ARM_CP_SUPPRESS_TB_END, | ||
125 | + .accessfn = aa64_cacheop_access, .writefn = dccvap_writefn }, | ||
126 | + REGINFO_SENTINEL | ||
127 | +}; | ||
128 | +#endif /*CONFIG_USER_ONLY*/ | ||
129 | + | ||
130 | #endif | ||
131 | |||
132 | static CPAccessResult access_predinv(CPUARMState *env, const ARMCPRegInfo *ri, | ||
133 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
134 | if (cpu_isar_feature(aa64_rndr, cpu)) { | ||
135 | define_arm_cp_regs(cpu, rndr_reginfo); | ||
136 | } | ||
137 | +#ifndef CONFIG_USER_ONLY | ||
138 | + /* Data Cache clean instructions up to PoP */ | ||
139 | + if (cpu_isar_feature(aa64_dcpop, cpu)) { | ||
140 | + define_one_arm_cp_reg(cpu, dcpop_reg); | ||
141 | + | ||
142 | + if (cpu_isar_feature(aa64_dcpodp, cpu)) { | ||
143 | + define_one_arm_cp_reg(cpu, dcpodp_reg); | ||
144 | + } | ||
145 | + } | ||
146 | +#endif /*CONFIG_USER_ONLY*/ | ||
147 | #endif | ||
148 | |||
149 | /* | ||
150 | -- | 63 | -- |
151 | 2.20.1 | 64 | 2.20.1 |
152 | 65 | ||
153 | 66 | diff view generated by jsdifflib |
1 | From: Cédric Le Goater <clg@kaod.org> | 1 | From: Gan Qixin <ganqixin@huawei.com> |
---|---|---|---|
2 | 2 | ||
3 | The Aspeed I2C controller can operate in different transfer modes : | 3 | When running device-introspect-test, a memory leak occurred in the |
4 | mv88w8618_pit_init function, so use ptimer_free() in the finalize function to | ||
5 | avoid it. | ||
4 | 6 | ||
5 | - Byte Buffer mode, using a dedicated register to transfer a | 7 | ASAN shows memory leak stack: |
6 | byte. This is what the model supports today. | ||
7 | 8 | ||
8 | - Pool Buffer mode, using an internal SRAM to transfer multiple | 9 | Indirect leak of 192 byte(s) in 4 object(s) allocated from: |
9 | bytes in the same command sequence. | 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 | ||
10 | 23 | ||
11 | Each SoC has different SRAM characteristics. On the AST2400, 2048 | 24 | Reported-by: Euler Robot <euler.robot@huawei.com> |
12 | bytes of SRAM are available at offset 0x800 of the controller AHB | 25 | Signed-off-by: Gan Qixin <ganqixin@huawei.com> |
13 | window. The pool buffer can be configured from 1 to 256 bytes per bus. | 26 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
14 | |||
15 | On the AST2500, the SRAM is at offset 0x200 and the pool buffer is of | ||
16 | 16 bytes per bus. | ||
17 | |||
18 | On the AST2600, the SRAM is at offset 0xC00 and the pool buffer is of | ||
19 | 32 bytes per bus. It can be splitted in two for TX and RX but the | ||
20 | current model does not add support for it as it it unused by known | ||
21 | drivers. | ||
22 | |||
23 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
24 | Reviewed-by: Joel Stanley <joel@jms.id.au> | ||
25 | Tested-by: Jae Hyun Yoo <jae.hyun.yoo@linux.intel.com> | ||
26 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
27 | Message-id: 20191119141211.25716-2-clg@kaod.org | ||
28 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 27 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
29 | --- | 28 | --- |
30 | include/hw/i2c/aspeed_i2c.h | 8 ++ | 29 | hw/arm/musicpal.c | 12 ++++++++++++ |
31 | hw/i2c/aspeed_i2c.c | 197 ++++++++++++++++++++++++++++++++---- | 30 | 1 file changed, 12 insertions(+) |
32 | 2 files changed, 186 insertions(+), 19 deletions(-) | ||
33 | 31 | ||
34 | diff --git a/include/hw/i2c/aspeed_i2c.h b/include/hw/i2c/aspeed_i2c.h | 32 | diff --git a/hw/arm/musicpal.c b/hw/arm/musicpal.c |
35 | index XXXXXXX..XXXXXXX 100644 | 33 | index XXXXXXX..XXXXXXX 100644 |
36 | --- a/include/hw/i2c/aspeed_i2c.h | 34 | --- a/hw/arm/musicpal.c |
37 | +++ b/include/hw/i2c/aspeed_i2c.h | 35 | +++ b/hw/arm/musicpal.c |
38 | @@ -XXX,XX +XXX,XX @@ | 36 | @@ -XXX,XX +XXX,XX @@ static void mv88w8618_pit_init(Object *obj) |
39 | OBJECT_CHECK(AspeedI2CState, (obj), TYPE_ASPEED_I2C) | 37 | sysbus_init_mmio(dev, &s->iomem); |
40 | |||
41 | #define ASPEED_I2C_NR_BUSSES 16 | ||
42 | +#define ASPEED_I2C_MAX_POOL_SIZE 0x800 | ||
43 | |||
44 | struct AspeedI2CState; | ||
45 | |||
46 | @@ -XXX,XX +XXX,XX @@ typedef struct AspeedI2CBus { | ||
47 | uint32_t intr_status; | ||
48 | uint32_t cmd; | ||
49 | uint32_t buf; | ||
50 | + uint32_t pool_ctrl; | ||
51 | } AspeedI2CBus; | ||
52 | |||
53 | typedef struct AspeedI2CState { | ||
54 | @@ -XXX,XX +XXX,XX @@ typedef struct AspeedI2CState { | ||
55 | qemu_irq irq; | ||
56 | |||
57 | uint32_t intr_status; | ||
58 | + MemoryRegion pool_iomem; | ||
59 | + uint8_t pool[ASPEED_I2C_MAX_POOL_SIZE]; | ||
60 | |||
61 | AspeedI2CBus busses[ASPEED_I2C_NR_BUSSES]; | ||
62 | } AspeedI2CState; | ||
63 | @@ -XXX,XX +XXX,XX @@ typedef struct AspeedI2CClass { | ||
64 | uint8_t reg_size; | ||
65 | uint8_t gap; | ||
66 | qemu_irq (*bus_get_irq)(AspeedI2CBus *); | ||
67 | + | ||
68 | + uint64_t pool_size; | ||
69 | + hwaddr pool_base; | ||
70 | + uint8_t *(*bus_pool_base)(AspeedI2CBus *); | ||
71 | } AspeedI2CClass; | ||
72 | |||
73 | I2CBus *aspeed_i2c_get_bus(DeviceState *dev, int busnr); | ||
74 | diff --git a/hw/i2c/aspeed_i2c.c b/hw/i2c/aspeed_i2c.c | ||
75 | index XXXXXXX..XXXXXXX 100644 | ||
76 | --- a/hw/i2c/aspeed_i2c.c | ||
77 | +++ b/hw/i2c/aspeed_i2c.c | ||
78 | @@ -XXX,XX +XXX,XX @@ | ||
79 | /* I2C Device (Bus) Register */ | ||
80 | |||
81 | #define I2CD_FUN_CTRL_REG 0x00 /* I2CD Function Control */ | ||
82 | -#define I2CD_BUFF_SEL_MASK (0x7 << 20) | ||
83 | -#define I2CD_BUFF_SEL(x) (x << 20) | ||
84 | +#define I2CD_POOL_PAGE_SEL(x) (((x) >> 20) & 0x7) /* AST2400 */ | ||
85 | #define I2CD_M_SDA_LOCK_EN (0x1 << 16) | ||
86 | #define I2CD_MULTI_MASTER_DIS (0x1 << 15) | ||
87 | #define I2CD_M_SCL_DRIVE_EN (0x1 << 14) | ||
88 | @@ -XXX,XX +XXX,XX @@ | ||
89 | #define I2CD_SCL_O_OUT_DIR (0x1 << 12) | ||
90 | #define I2CD_BUS_RECOVER_CMD_EN (0x1 << 11) | ||
91 | #define I2CD_S_ALT_EN (0x1 << 10) | ||
92 | -#define I2CD_RX_DMA_ENABLE (0x1 << 9) | ||
93 | -#define I2CD_TX_DMA_ENABLE (0x1 << 8) | ||
94 | |||
95 | /* Command Bit */ | ||
96 | +#define I2CD_RX_DMA_ENABLE (0x1 << 9) | ||
97 | +#define I2CD_TX_DMA_ENABLE (0x1 << 8) | ||
98 | +#define I2CD_RX_BUFF_ENABLE (0x1 << 7) | ||
99 | +#define I2CD_TX_BUFF_ENABLE (0x1 << 6) | ||
100 | #define I2CD_M_STOP_CMD (0x1 << 5) | ||
101 | #define I2CD_M_S_RX_CMD_LAST (0x1 << 4) | ||
102 | #define I2CD_M_RX_CMD (0x1 << 3) | ||
103 | @@ -XXX,XX +XXX,XX @@ | ||
104 | #define I2CD_M_START_CMD (0x1) | ||
105 | |||
106 | #define I2CD_DEV_ADDR_REG 0x18 /* Slave Device Address */ | ||
107 | -#define I2CD_BUF_CTRL_REG 0x1c /* Pool Buffer Control */ | ||
108 | +#define I2CD_POOL_CTRL_REG 0x1c /* Pool Buffer Control */ | ||
109 | +#define I2CD_POOL_RX_COUNT(x) (((x) >> 24) & 0xff) | ||
110 | +#define I2CD_POOL_RX_SIZE(x) ((((x) >> 16) & 0xff) + 1) | ||
111 | +#define I2CD_POOL_TX_COUNT(x) ((((x) >> 8) & 0xff) + 1) | ||
112 | +#define I2CD_POOL_OFFSET(x) (((x) & 0x3f) << 2) /* AST2400 */ | ||
113 | #define I2CD_BYTE_BUF_REG 0x20 /* Transmit/Receive Byte Buffer */ | ||
114 | #define I2CD_BYTE_BUF_TX_SHIFT 0 | ||
115 | #define I2CD_BYTE_BUF_TX_MASK 0xff | ||
116 | @@ -XXX,XX +XXX,XX @@ static uint64_t aspeed_i2c_bus_read(void *opaque, hwaddr offset, | ||
117 | return bus->intr_ctrl; | ||
118 | case I2CD_INTR_STS_REG: | ||
119 | return bus->intr_status; | ||
120 | + case I2CD_POOL_CTRL_REG: | ||
121 | + return bus->pool_ctrl; | ||
122 | case I2CD_BYTE_BUF_REG: | ||
123 | return bus->buf; | ||
124 | case I2CD_CMD_REG: | ||
125 | @@ -XXX,XX +XXX,XX @@ static uint8_t aspeed_i2c_get_state(AspeedI2CBus *bus) | ||
126 | return (bus->cmd >> I2CD_TX_STATE_SHIFT) & I2CD_TX_STATE_MASK; | ||
127 | } | 38 | } |
128 | 39 | ||
129 | +static int aspeed_i2c_bus_send(AspeedI2CBus *bus, uint8_t pool_start) | 40 | +static void mv88w8618_pit_finalize(Object *obj) |
130 | +{ | 41 | +{ |
131 | + AspeedI2CClass *aic = ASPEED_I2C_GET_CLASS(bus->controller); | 42 | + SysBusDevice *dev = SYS_BUS_DEVICE(obj); |
132 | + int ret = -1; | 43 | + mv88w8618_pit_state *s = MV88W8618_PIT(dev); |
133 | + int i; | 44 | + int i; |
134 | + | 45 | + |
135 | + if (bus->cmd & I2CD_TX_BUFF_ENABLE) { | 46 | + for (i = 0; i < 4; i++) { |
136 | + for (i = pool_start; i < I2CD_POOL_TX_COUNT(bus->pool_ctrl); i++) { | 47 | + ptimer_free(s->timer[i].ptimer); |
137 | + uint8_t *pool_base = aic->bus_pool_base(bus); | ||
138 | + | ||
139 | + ret = i2c_send(bus->bus, pool_base[i]); | ||
140 | + if (ret) { | ||
141 | + break; | ||
142 | + } | ||
143 | + } | ||
144 | + bus->cmd &= ~I2CD_TX_BUFF_ENABLE; | ||
145 | + } else { | ||
146 | + ret = i2c_send(bus->bus, bus->buf); | ||
147 | + } | ||
148 | + | ||
149 | + return ret; | ||
150 | +} | ||
151 | + | ||
152 | +static void aspeed_i2c_bus_recv(AspeedI2CBus *bus) | ||
153 | +{ | ||
154 | + AspeedI2CState *s = bus->controller; | ||
155 | + AspeedI2CClass *aic = ASPEED_I2C_GET_CLASS(s); | ||
156 | + uint8_t data; | ||
157 | + int i; | ||
158 | + | ||
159 | + if (bus->cmd & I2CD_RX_BUFF_ENABLE) { | ||
160 | + uint8_t *pool_base = aic->bus_pool_base(bus); | ||
161 | + | ||
162 | + for (i = 0; i < I2CD_POOL_RX_SIZE(bus->pool_ctrl); i++) { | ||
163 | + pool_base[i] = i2c_recv(bus->bus); | ||
164 | + } | ||
165 | + | ||
166 | + /* Update RX count */ | ||
167 | + bus->pool_ctrl &= ~(0xff << 24); | ||
168 | + bus->pool_ctrl |= (i & 0xff) << 24; | ||
169 | + bus->cmd &= ~I2CD_RX_BUFF_ENABLE; | ||
170 | + } else { | ||
171 | + data = i2c_recv(bus->bus); | ||
172 | + bus->buf = (data & I2CD_BYTE_BUF_RX_MASK) << I2CD_BYTE_BUF_RX_SHIFT; | ||
173 | + } | 48 | + } |
174 | +} | 49 | +} |
175 | + | 50 | + |
176 | static void aspeed_i2c_handle_rx_cmd(AspeedI2CBus *bus) | 51 | static const VMStateDescription mv88w8618_timer_vmsd = { |
177 | { | 52 | .name = "timer", |
178 | - uint8_t ret; | 53 | .version_id = 1, |
179 | - | 54 | @@ -XXX,XX +XXX,XX @@ static const TypeInfo mv88w8618_pit_info = { |
180 | aspeed_i2c_set_state(bus, I2CD_MRXD); | 55 | .parent = TYPE_SYS_BUS_DEVICE, |
181 | - ret = i2c_recv(bus->bus); | 56 | .instance_size = sizeof(mv88w8618_pit_state), |
182 | + aspeed_i2c_bus_recv(bus); | 57 | .instance_init = mv88w8618_pit_init, |
183 | bus->intr_status |= I2CD_INTR_RX_DONE; | 58 | + .instance_finalize = mv88w8618_pit_finalize, |
184 | - bus->buf = (ret & I2CD_BYTE_BUF_RX_MASK) << I2CD_BYTE_BUF_RX_SHIFT; | 59 | .class_init = mv88w8618_pit_class_init, |
185 | if (bus->cmd & I2CD_M_S_RX_CMD_LAST) { | ||
186 | i2c_nack(bus->bus); | ||
187 | } | ||
188 | @@ -XXX,XX +XXX,XX @@ static void aspeed_i2c_handle_rx_cmd(AspeedI2CBus *bus) | ||
189 | aspeed_i2c_set_state(bus, I2CD_MACTIVE); | ||
190 | } | ||
191 | |||
192 | +static uint8_t aspeed_i2c_get_addr(AspeedI2CBus *bus) | ||
193 | +{ | ||
194 | + AspeedI2CClass *aic = ASPEED_I2C_GET_CLASS(bus->controller); | ||
195 | + | ||
196 | + if (bus->cmd & I2CD_TX_BUFF_ENABLE) { | ||
197 | + uint8_t *pool_base = aic->bus_pool_base(bus); | ||
198 | + | ||
199 | + return pool_base[0]; | ||
200 | + } else { | ||
201 | + return bus->buf; | ||
202 | + } | ||
203 | +} | ||
204 | + | ||
205 | /* | ||
206 | * The state machine needs some refinement. It is only used to track | ||
207 | * invalid STOP commands for the moment. | ||
208 | */ | ||
209 | static void aspeed_i2c_bus_handle_cmd(AspeedI2CBus *bus, uint64_t value) | ||
210 | { | ||
211 | + uint8_t pool_start = 0; | ||
212 | + | ||
213 | bus->cmd &= ~0xFFFF; | ||
214 | bus->cmd |= value & 0xFFFF; | ||
215 | |||
216 | if (bus->cmd & I2CD_M_START_CMD) { | ||
217 | uint8_t state = aspeed_i2c_get_state(bus) & I2CD_MACTIVE ? | ||
218 | I2CD_MSTARTR : I2CD_MSTART; | ||
219 | + uint8_t addr; | ||
220 | |||
221 | aspeed_i2c_set_state(bus, state); | ||
222 | |||
223 | - if (i2c_start_transfer(bus->bus, extract32(bus->buf, 1, 7), | ||
224 | - extract32(bus->buf, 0, 1))) { | ||
225 | + addr = aspeed_i2c_get_addr(bus); | ||
226 | + | ||
227 | + if (i2c_start_transfer(bus->bus, extract32(addr, 1, 7), | ||
228 | + extract32(addr, 0, 1))) { | ||
229 | bus->intr_status |= I2CD_INTR_TX_NAK; | ||
230 | } else { | ||
231 | bus->intr_status |= I2CD_INTR_TX_ACK; | ||
232 | } | ||
233 | |||
234 | - /* START command is also a TX command, as the slave address is | ||
235 | - * sent on the bus */ | ||
236 | - bus->cmd &= ~(I2CD_M_START_CMD | I2CD_M_TX_CMD); | ||
237 | + bus->cmd &= ~I2CD_M_START_CMD; | ||
238 | + | ||
239 | + /* | ||
240 | + * The START command is also a TX command, as the slave | ||
241 | + * address is sent on the bus. Drop the TX flag if nothing | ||
242 | + * else needs to be sent in this sequence. | ||
243 | + */ | ||
244 | + if (bus->cmd & I2CD_TX_BUFF_ENABLE) { | ||
245 | + if (I2CD_POOL_TX_COUNT(bus->pool_ctrl) == 1) { | ||
246 | + bus->cmd &= ~I2CD_M_TX_CMD; | ||
247 | + } else { | ||
248 | + /* | ||
249 | + * Increase the start index in the TX pool buffer to | ||
250 | + * skip the address byte. | ||
251 | + */ | ||
252 | + pool_start++; | ||
253 | + } | ||
254 | + } else { | ||
255 | + bus->cmd &= ~I2CD_M_TX_CMD; | ||
256 | + } | ||
257 | |||
258 | /* No slave found */ | ||
259 | if (!i2c_bus_busy(bus->bus)) { | ||
260 | @@ -XXX,XX +XXX,XX @@ static void aspeed_i2c_bus_handle_cmd(AspeedI2CBus *bus, uint64_t value) | ||
261 | |||
262 | if (bus->cmd & I2CD_M_TX_CMD) { | ||
263 | aspeed_i2c_set_state(bus, I2CD_MTXD); | ||
264 | - if (i2c_send(bus->bus, bus->buf)) { | ||
265 | + if (aspeed_i2c_bus_send(bus, pool_start)) { | ||
266 | bus->intr_status |= (I2CD_INTR_TX_NAK); | ||
267 | i2c_end_transfer(bus->bus); | ||
268 | } else { | ||
269 | @@ -XXX,XX +XXX,XX @@ static void aspeed_i2c_bus_write(void *opaque, hwaddr offset, | ||
270 | qemu_log_mask(LOG_UNIMP, "%s: slave mode not implemented\n", | ||
271 | __func__); | ||
272 | break; | ||
273 | + case I2CD_POOL_CTRL_REG: | ||
274 | + bus->pool_ctrl &= ~0xffffff; | ||
275 | + bus->pool_ctrl |= (value & 0xffffff); | ||
276 | + break; | ||
277 | + | ||
278 | case I2CD_BYTE_BUF_REG: | ||
279 | bus->buf = (value & I2CD_BYTE_BUF_TX_MASK) << I2CD_BYTE_BUF_TX_SHIFT; | ||
280 | break; | ||
281 | @@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps aspeed_i2c_ctrl_ops = { | ||
282 | .endianness = DEVICE_LITTLE_ENDIAN, | ||
283 | }; | 60 | }; |
284 | 61 | ||
285 | +static uint64_t aspeed_i2c_pool_read(void *opaque, hwaddr offset, | ||
286 | + unsigned size) | ||
287 | +{ | ||
288 | + AspeedI2CState *s = opaque; | ||
289 | + uint64_t ret = 0; | ||
290 | + int i; | ||
291 | + | ||
292 | + for (i = 0; i < size; i++) { | ||
293 | + ret |= (uint64_t) s->pool[offset + i] << (8 * i); | ||
294 | + } | ||
295 | + | ||
296 | + return ret; | ||
297 | +} | ||
298 | + | ||
299 | +static void aspeed_i2c_pool_write(void *opaque, hwaddr offset, | ||
300 | + uint64_t value, unsigned size) | ||
301 | +{ | ||
302 | + AspeedI2CState *s = opaque; | ||
303 | + int i; | ||
304 | + | ||
305 | + for (i = 0; i < size; i++) { | ||
306 | + s->pool[offset + i] = (value >> (8 * i)) & 0xFF; | ||
307 | + } | ||
308 | +} | ||
309 | + | ||
310 | +static const MemoryRegionOps aspeed_i2c_pool_ops = { | ||
311 | + .read = aspeed_i2c_pool_read, | ||
312 | + .write = aspeed_i2c_pool_write, | ||
313 | + .endianness = DEVICE_LITTLE_ENDIAN, | ||
314 | + .valid = { | ||
315 | + .min_access_size = 1, | ||
316 | + .max_access_size = 4, | ||
317 | + }, | ||
318 | +}; | ||
319 | + | ||
320 | static const VMStateDescription aspeed_i2c_bus_vmstate = { | ||
321 | .name = TYPE_ASPEED_I2C, | ||
322 | - .version_id = 1, | ||
323 | - .minimum_version_id = 1, | ||
324 | + .version_id = 2, | ||
325 | + .minimum_version_id = 2, | ||
326 | .fields = (VMStateField[]) { | ||
327 | VMSTATE_UINT8(id, AspeedI2CBus), | ||
328 | VMSTATE_UINT32(ctrl, AspeedI2CBus), | ||
329 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription aspeed_i2c_bus_vmstate = { | ||
330 | VMSTATE_UINT32(intr_status, AspeedI2CBus), | ||
331 | VMSTATE_UINT32(cmd, AspeedI2CBus), | ||
332 | VMSTATE_UINT32(buf, AspeedI2CBus), | ||
333 | + VMSTATE_UINT32(pool_ctrl, AspeedI2CBus), | ||
334 | VMSTATE_END_OF_LIST() | ||
335 | } | ||
336 | }; | ||
337 | |||
338 | static const VMStateDescription aspeed_i2c_vmstate = { | ||
339 | .name = TYPE_ASPEED_I2C, | ||
340 | - .version_id = 1, | ||
341 | - .minimum_version_id = 1, | ||
342 | + .version_id = 2, | ||
343 | + .minimum_version_id = 2, | ||
344 | .fields = (VMStateField[]) { | ||
345 | VMSTATE_UINT32(intr_status, AspeedI2CState), | ||
346 | VMSTATE_STRUCT_ARRAY(busses, AspeedI2CState, | ||
347 | ASPEED_I2C_NR_BUSSES, 1, aspeed_i2c_bus_vmstate, | ||
348 | AspeedI2CBus), | ||
349 | + VMSTATE_UINT8_ARRAY(pool, AspeedI2CState, ASPEED_I2C_MAX_POOL_SIZE), | ||
350 | VMSTATE_END_OF_LIST() | ||
351 | } | ||
352 | }; | ||
353 | @@ -XXX,XX +XXX,XX @@ static void aspeed_i2c_realize(DeviceState *dev, Error **errp) | ||
354 | memory_region_add_subregion(&s->iomem, aic->reg_size * (i + offset), | ||
355 | &s->busses[i].mr); | ||
356 | } | ||
357 | + | ||
358 | + memory_region_init_io(&s->pool_iomem, OBJECT(s), &aspeed_i2c_pool_ops, s, | ||
359 | + "aspeed.i2c-pool", aic->pool_size); | ||
360 | + memory_region_add_subregion(&s->iomem, aic->pool_base, &s->pool_iomem); | ||
361 | } | ||
362 | |||
363 | static void aspeed_i2c_class_init(ObjectClass *klass, void *data) | ||
364 | @@ -XXX,XX +XXX,XX @@ static qemu_irq aspeed_2400_i2c_bus_get_irq(AspeedI2CBus *bus) | ||
365 | return bus->controller->irq; | ||
366 | } | ||
367 | |||
368 | +static uint8_t *aspeed_2400_i2c_bus_pool_base(AspeedI2CBus *bus) | ||
369 | +{ | ||
370 | + uint8_t *pool_page = | ||
371 | + &bus->controller->pool[I2CD_POOL_PAGE_SEL(bus->ctrl) * 0x100]; | ||
372 | + | ||
373 | + return &pool_page[I2CD_POOL_OFFSET(bus->pool_ctrl)]; | ||
374 | +} | ||
375 | + | ||
376 | static void aspeed_2400_i2c_class_init(ObjectClass *klass, void *data) | ||
377 | { | ||
378 | DeviceClass *dc = DEVICE_CLASS(klass); | ||
379 | @@ -XXX,XX +XXX,XX @@ static void aspeed_2400_i2c_class_init(ObjectClass *klass, void *data) | ||
380 | aic->reg_size = 0x40; | ||
381 | aic->gap = 7; | ||
382 | aic->bus_get_irq = aspeed_2400_i2c_bus_get_irq; | ||
383 | + aic->pool_size = 0x800; | ||
384 | + aic->pool_base = 0x800; | ||
385 | + aic->bus_pool_base = aspeed_2400_i2c_bus_pool_base; | ||
386 | } | ||
387 | |||
388 | static const TypeInfo aspeed_2400_i2c_info = { | ||
389 | @@ -XXX,XX +XXX,XX @@ static qemu_irq aspeed_2500_i2c_bus_get_irq(AspeedI2CBus *bus) | ||
390 | return bus->controller->irq; | ||
391 | } | ||
392 | |||
393 | +static uint8_t *aspeed_2500_i2c_bus_pool_base(AspeedI2CBus *bus) | ||
394 | +{ | ||
395 | + return &bus->controller->pool[bus->id * 0x10]; | ||
396 | +} | ||
397 | + | ||
398 | static void aspeed_2500_i2c_class_init(ObjectClass *klass, void *data) | ||
399 | { | ||
400 | DeviceClass *dc = DEVICE_CLASS(klass); | ||
401 | @@ -XXX,XX +XXX,XX @@ static void aspeed_2500_i2c_class_init(ObjectClass *klass, void *data) | ||
402 | aic->reg_size = 0x40; | ||
403 | aic->gap = 7; | ||
404 | aic->bus_get_irq = aspeed_2500_i2c_bus_get_irq; | ||
405 | + aic->pool_size = 0x100; | ||
406 | + aic->pool_base = 0x200; | ||
407 | + aic->bus_pool_base = aspeed_2500_i2c_bus_pool_base; | ||
408 | } | ||
409 | |||
410 | static const TypeInfo aspeed_2500_i2c_info = { | ||
411 | @@ -XXX,XX +XXX,XX @@ static qemu_irq aspeed_2600_i2c_bus_get_irq(AspeedI2CBus *bus) | ||
412 | return bus->irq; | ||
413 | } | ||
414 | |||
415 | +static uint8_t *aspeed_2600_i2c_bus_pool_base(AspeedI2CBus *bus) | ||
416 | +{ | ||
417 | + return &bus->controller->pool[bus->id * 0x20]; | ||
418 | +} | ||
419 | + | ||
420 | static void aspeed_2600_i2c_class_init(ObjectClass *klass, void *data) | ||
421 | { | ||
422 | DeviceClass *dc = DEVICE_CLASS(klass); | ||
423 | @@ -XXX,XX +XXX,XX @@ static void aspeed_2600_i2c_class_init(ObjectClass *klass, void *data) | ||
424 | aic->reg_size = 0x80; | ||
425 | aic->gap = -1; /* no gap */ | ||
426 | aic->bus_get_irq = aspeed_2600_i2c_bus_get_irq; | ||
427 | + aic->pool_size = 0x200; | ||
428 | + aic->pool_base = 0xC00; | ||
429 | + aic->bus_pool_base = aspeed_2600_i2c_bus_pool_base; | ||
430 | } | ||
431 | |||
432 | static const TypeInfo aspeed_2600_i2c_info = { | ||
433 | -- | 62 | -- |
434 | 2.20.1 | 63 | 2.20.1 |
435 | 64 | ||
436 | 65 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Cédric Le Goater <clg@kaod.org> | ||
2 | 1 | ||
3 | The SRAM must be enabled before using the Buffer Pool mode or the DMA | ||
4 | mode. This is not required on other SoCs. | ||
5 | |||
6 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
7 | Reviewed-by: Joel Stanley <joel@jms.id.au> | ||
8 | Tested-by: Jae Hyun Yoo <jae.hyun.yoo@linux.intel.com> | ||
9 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
10 | Message-id: 20191119141211.25716-3-clg@kaod.org | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | --- | ||
13 | include/hw/i2c/aspeed_i2c.h | 3 +++ | ||
14 | hw/i2c/aspeed_i2c.c | 37 +++++++++++++++++++++++++++++++++++++ | ||
15 | 2 files changed, 40 insertions(+) | ||
16 | |||
17 | diff --git a/include/hw/i2c/aspeed_i2c.h b/include/hw/i2c/aspeed_i2c.h | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/include/hw/i2c/aspeed_i2c.h | ||
20 | +++ b/include/hw/i2c/aspeed_i2c.h | ||
21 | @@ -XXX,XX +XXX,XX @@ typedef struct AspeedI2CState { | ||
22 | qemu_irq irq; | ||
23 | |||
24 | uint32_t intr_status; | ||
25 | + uint32_t ctrl_global; | ||
26 | MemoryRegion pool_iomem; | ||
27 | uint8_t pool[ASPEED_I2C_MAX_POOL_SIZE]; | ||
28 | |||
29 | @@ -XXX,XX +XXX,XX @@ typedef struct AspeedI2CClass { | ||
30 | uint64_t pool_size; | ||
31 | hwaddr pool_base; | ||
32 | uint8_t *(*bus_pool_base)(AspeedI2CBus *); | ||
33 | + bool check_sram; | ||
34 | + | ||
35 | } AspeedI2CClass; | ||
36 | |||
37 | I2CBus *aspeed_i2c_get_bus(DeviceState *dev, int busnr); | ||
38 | diff --git a/hw/i2c/aspeed_i2c.c b/hw/i2c/aspeed_i2c.c | ||
39 | index XXXXXXX..XXXXXXX 100644 | ||
40 | --- a/hw/i2c/aspeed_i2c.c | ||
41 | +++ b/hw/i2c/aspeed_i2c.c | ||
42 | @@ -XXX,XX +XXX,XX @@ | ||
43 | #define I2C_CTRL_STATUS 0x00 /* Device Interrupt Status */ | ||
44 | #define I2C_CTRL_ASSIGN 0x08 /* Device Interrupt Target | ||
45 | Assignment */ | ||
46 | +#define I2C_CTRL_GLOBAL 0x0C /* Global Control Register */ | ||
47 | +#define I2C_CTRL_SRAM_EN BIT(0) | ||
48 | |||
49 | /* I2C Device (Bus) Register */ | ||
50 | |||
51 | @@ -XXX,XX +XXX,XX @@ static uint8_t aspeed_i2c_get_addr(AspeedI2CBus *bus) | ||
52 | } | ||
53 | } | ||
54 | |||
55 | +static bool aspeed_i2c_check_sram(AspeedI2CBus *bus) | ||
56 | +{ | ||
57 | + AspeedI2CState *s = bus->controller; | ||
58 | + AspeedI2CClass *aic = ASPEED_I2C_GET_CLASS(s); | ||
59 | + | ||
60 | + if (!aic->check_sram) { | ||
61 | + return true; | ||
62 | + } | ||
63 | + | ||
64 | + /* | ||
65 | + * AST2500: SRAM must be enabled before using the Buffer Pool or | ||
66 | + * DMA mode. | ||
67 | + */ | ||
68 | + if (!(s->ctrl_global & I2C_CTRL_SRAM_EN) && | ||
69 | + (bus->cmd & (I2CD_RX_DMA_ENABLE | I2CD_TX_DMA_ENABLE | | ||
70 | + I2CD_RX_BUFF_ENABLE | I2CD_TX_BUFF_ENABLE))) { | ||
71 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: SRAM is not enabled\n", __func__); | ||
72 | + return false; | ||
73 | + } | ||
74 | + | ||
75 | + return true; | ||
76 | +} | ||
77 | + | ||
78 | /* | ||
79 | * The state machine needs some refinement. It is only used to track | ||
80 | * invalid STOP commands for the moment. | ||
81 | @@ -XXX,XX +XXX,XX @@ static void aspeed_i2c_bus_handle_cmd(AspeedI2CBus *bus, uint64_t value) | ||
82 | bus->cmd &= ~0xFFFF; | ||
83 | bus->cmd |= value & 0xFFFF; | ||
84 | |||
85 | + if (!aspeed_i2c_check_sram(bus)) { | ||
86 | + return; | ||
87 | + } | ||
88 | + | ||
89 | if (bus->cmd & I2CD_M_START_CMD) { | ||
90 | uint8_t state = aspeed_i2c_get_state(bus) & I2CD_MACTIVE ? | ||
91 | I2CD_MSTARTR : I2CD_MSTART; | ||
92 | @@ -XXX,XX +XXX,XX @@ static uint64_t aspeed_i2c_ctrl_read(void *opaque, hwaddr offset, | ||
93 | switch (offset) { | ||
94 | case I2C_CTRL_STATUS: | ||
95 | return s->intr_status; | ||
96 | + case I2C_CTRL_GLOBAL: | ||
97 | + return s->ctrl_global; | ||
98 | default: | ||
99 | qemu_log_mask(LOG_GUEST_ERROR, "%s: Bad offset 0x%" HWADDR_PRIx "\n", | ||
100 | __func__, offset); | ||
101 | @@ -XXX,XX +XXX,XX @@ static uint64_t aspeed_i2c_ctrl_read(void *opaque, hwaddr offset, | ||
102 | static void aspeed_i2c_ctrl_write(void *opaque, hwaddr offset, | ||
103 | uint64_t value, unsigned size) | ||
104 | { | ||
105 | + AspeedI2CState *s = opaque; | ||
106 | + | ||
107 | switch (offset) { | ||
108 | + case I2C_CTRL_GLOBAL: | ||
109 | + s->ctrl_global = value; | ||
110 | + break; | ||
111 | case I2C_CTRL_STATUS: | ||
112 | default: | ||
113 | qemu_log_mask(LOG_GUEST_ERROR, "%s: Bad offset 0x%" HWADDR_PRIx "\n", | ||
114 | @@ -XXX,XX +XXX,XX @@ static void aspeed_2500_i2c_class_init(ObjectClass *klass, void *data) | ||
115 | aic->pool_size = 0x100; | ||
116 | aic->pool_base = 0x200; | ||
117 | aic->bus_pool_base = aspeed_2500_i2c_bus_pool_base; | ||
118 | + aic->check_sram = true; | ||
119 | } | ||
120 | |||
121 | static const TypeInfo aspeed_2500_i2c_info = { | ||
122 | -- | ||
123 | 2.20.1 | ||
124 | |||
125 | diff view generated by jsdifflib |
1 | From: Marc Zyngier <maz@kernel.org> | 1 | From: Gan Qixin <ganqixin@huawei.com> |
---|---|---|---|
2 | 2 | ||
3 | HCR_EL2.TID1 mandates that access from EL1 to REVIDR_EL1, AIDR_EL1 | 3 | When running device-introspect-test, a memory leak occurred in the |
4 | (and their 32bit equivalents) as well as TCMTR, TLBTR are trapped | 4 | exynos4210_mct_init function, so use ptimer_free() in the finalize function to |
5 | to EL2. QEMU ignores it, making it harder for a hypervisor to | 5 | avoid it. |
6 | virtualize the HW (though to be fair, no known hypervisor actually | ||
7 | cares). | ||
8 | 6 | ||
9 | Do the right thing by trapping to EL2 if HCR_EL2.TID1 is set. | 7 | ASAN shows memory leak stack: |
10 | 8 | ||
11 | Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> | 9 | Indirect leak of 96 byte(s) in 1 object(s) allocated from: |
12 | Signed-off-by: Marc Zyngier <maz@kernel.org> | 10 | #0 0xffffab97e1f0 in __interceptor_calloc (/lib64/libasan.so.5+0xee1f0) |
13 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 11 | #1 0xffffab256800 in g_malloc0 (/lib64/libglib-2.0.so.0+0x56800) |
14 | Message-id: 20191201122018.25808-3-maz@kernel.org | 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> | ||
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 27 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
16 | --- | 28 | --- |
17 | target/arm/helper.c | 36 ++++++++++++++++++++++++++++++++---- | 29 | hw/timer/exynos4210_mct.c | 14 ++++++++++++++ |
18 | 1 file changed, 32 insertions(+), 4 deletions(-) | 30 | 1 file changed, 14 insertions(+) |
19 | 31 | ||
20 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 32 | diff --git a/hw/timer/exynos4210_mct.c b/hw/timer/exynos4210_mct.c |
21 | index XXXXXXX..XXXXXXX 100644 | 33 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/target/arm/helper.c | 34 | --- a/hw/timer/exynos4210_mct.c |
23 | +++ b/target/arm/helper.c | 35 | +++ b/hw/timer/exynos4210_mct.c |
24 | @@ -XXX,XX +XXX,XX @@ static uint64_t isr_read(CPUARMState *env, const ARMCPRegInfo *ri) | 36 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_mct_init(Object *obj) |
25 | return ret; | 37 | sysbus_init_mmio(dev, &s->iomem); |
26 | } | 38 | } |
27 | 39 | ||
28 | +static CPAccessResult access_aa64_tid1(CPUARMState *env, const ARMCPRegInfo *ri, | 40 | +static void exynos4210_mct_finalize(Object *obj) |
29 | + bool isread) | ||
30 | +{ | 41 | +{ |
31 | + if (arm_current_el(env) == 1 && (arm_hcr_el2_eff(env) & HCR_TID1)) { | 42 | + int i; |
32 | + return CP_ACCESS_TRAP_EL2; | 43 | + Exynos4210MCTState *s = EXYNOS4210_MCT(obj); |
44 | + | ||
45 | + ptimer_free(s->g_timer.ptimer_frc); | ||
46 | + | ||
47 | + for (i = 0; i < 2; i++) { | ||
48 | + ptimer_free(s->l_timer[i].tick_timer.ptimer_tick); | ||
49 | + ptimer_free(s->l_timer[i].ptimer_frc); | ||
33 | + } | 50 | + } |
34 | + | ||
35 | + return CP_ACCESS_OK; | ||
36 | +} | 51 | +} |
37 | + | 52 | + |
38 | +static CPAccessResult access_aa32_tid1(CPUARMState *env, const ARMCPRegInfo *ri, | 53 | static void exynos4210_mct_class_init(ObjectClass *klass, void *data) |
39 | + bool isread) | 54 | { |
40 | +{ | 55 | DeviceClass *dc = DEVICE_CLASS(klass); |
41 | + if (arm_feature(env, ARM_FEATURE_V8)) { | 56 | @@ -XXX,XX +XXX,XX @@ static const TypeInfo exynos4210_mct_info = { |
42 | + return access_aa64_tid1(env, ri, isread); | 57 | .parent = TYPE_SYS_BUS_DEVICE, |
43 | + } | 58 | .instance_size = sizeof(Exynos4210MCTState), |
44 | + | 59 | .instance_init = exynos4210_mct_init, |
45 | + return CP_ACCESS_OK; | 60 | + .instance_finalize = exynos4210_mct_finalize, |
46 | +} | 61 | .class_init = exynos4210_mct_class_init, |
47 | + | 62 | }; |
48 | static const ARMCPRegInfo v7_cp_reginfo[] = { | 63 | |
49 | /* the old v6 WFI, UNPREDICTABLE in v7 but we choose to NOP */ | ||
50 | { .name = "NOP", .cp = 15, .crn = 7, .crm = 0, .opc1 = 0, .opc2 = 4, | ||
51 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v7_cp_reginfo[] = { | ||
52 | */ | ||
53 | { .name = "AIDR", .state = ARM_CP_STATE_BOTH, | ||
54 | .opc0 = 3, .opc1 = 1, .crn = 0, .crm = 0, .opc2 = 7, | ||
55 | - .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
56 | + .access = PL1_R, .type = ARM_CP_CONST, | ||
57 | + .accessfn = access_aa64_tid1, | ||
58 | + .resetvalue = 0 }, | ||
59 | /* Auxiliary fault status registers: these also are IMPDEF, and we | ||
60 | * choose to RAZ/WI for all cores. | ||
61 | */ | ||
62 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
63 | .access = PL1_R, .resetvalue = cpu->midr }, | ||
64 | { .name = "REVIDR_EL1", .state = ARM_CP_STATE_BOTH, | ||
65 | .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 0, .opc2 = 6, | ||
66 | - .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = cpu->revidr }, | ||
67 | + .access = PL1_R, | ||
68 | + .accessfn = access_aa64_tid1, | ||
69 | + .type = ARM_CP_CONST, .resetvalue = cpu->revidr }, | ||
70 | REGINFO_SENTINEL | ||
71 | }; | ||
72 | ARMCPRegInfo id_cp_reginfo[] = { | ||
73 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
74 | /* TCMTR and TLBTR exist in v8 but have no 64-bit versions */ | ||
75 | { .name = "TCMTR", | ||
76 | .cp = 15, .crn = 0, .crm = 0, .opc1 = 0, .opc2 = 2, | ||
77 | - .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
78 | + .access = PL1_R, | ||
79 | + .accessfn = access_aa32_tid1, | ||
80 | + .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
81 | REGINFO_SENTINEL | ||
82 | }; | ||
83 | /* TLBTR is specific to VMSA */ | ||
84 | ARMCPRegInfo id_tlbtr_reginfo = { | ||
85 | .name = "TLBTR", | ||
86 | .cp = 15, .crn = 0, .crm = 0, .opc1 = 0, .opc2 = 3, | ||
87 | - .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = 0, | ||
88 | + .access = PL1_R, | ||
89 | + .accessfn = access_aa32_tid1, | ||
90 | + .type = ARM_CP_CONST, .resetvalue = 0, | ||
91 | }; | ||
92 | /* MPUIR is specific to PMSA V6+ */ | ||
93 | ARMCPRegInfo id_mpuir_reginfo = { | ||
94 | -- | 64 | -- |
95 | 2.20.1 | 65 | 2.20.1 |
96 | 66 | ||
97 | 67 | diff view generated by jsdifflib |
1 | From: Cédric Le Goater <clg@kaod.org> | 1 | From: Bin Meng <bin.meng@windriver.com> |
---|---|---|---|
2 | 2 | ||
3 | Currently, we link the DRAM memory region to the FMC model (for DMAs) | 3 | U-Boot expects PMU_MISC0 register bit 7 is set (see init_bandgap() |
4 | through a property alias at the SoC level. The I2C model will need a | 4 | in arch/arm/mach-imx/mx6/soc.c) during boot. This bit indicates the |
5 | similar region for DMA support, add a DRAM region property at the SoC | 5 | bandgap has stabilized. |
6 | level for both model to use. | ||
7 | 6 | ||
8 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | 7 | With this change, the latest upstream U-Boot (v2021.01-rc3) for imx6 |
9 | Reviewed-by: Joel Stanley <joel@jms.id.au> | 8 | sabrelite board (mx6qsabrelite_defconfig), with a slight change made |
10 | Tested-by: Jae Hyun Yoo <jae.hyun.yoo@linux.intel.com> | 9 | by switching CONFIG_OF_SEPARATE to CONFIG_OF_EMBED, boots to U-Boot |
11 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | 10 | shell on QEMU with the following command: |
12 | Message-id: 20191119141211.25716-4-clg@kaod.org | 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 | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 53 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | --- | 54 | --- |
15 | include/hw/arm/aspeed_soc.h | 1 + | 55 | hw/misc/imx6_ccm.c | 2 +- |
16 | hw/arm/aspeed_ast2600.c | 7 +++++-- | 56 | 1 file changed, 1 insertion(+), 1 deletion(-) |
17 | hw/arm/aspeed_soc.c | 9 +++++++-- | ||
18 | 3 files changed, 13 insertions(+), 4 deletions(-) | ||
19 | 57 | ||
20 | diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h | 58 | diff --git a/hw/misc/imx6_ccm.c b/hw/misc/imx6_ccm.c |
21 | index XXXXXXX..XXXXXXX 100644 | 59 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/include/hw/arm/aspeed_soc.h | 60 | --- a/hw/misc/imx6_ccm.c |
23 | +++ b/include/hw/arm/aspeed_soc.h | 61 | +++ b/hw/misc/imx6_ccm.c |
24 | @@ -XXX,XX +XXX,XX @@ typedef struct AspeedSoCState { | 62 | @@ -XXX,XX +XXX,XX @@ static void imx6_ccm_reset(DeviceState *dev) |
25 | ARMCPU cpu[ASPEED_CPUS_NUM]; | 63 | s->analog[PMU_REG_3P0] = 0x00000F74; |
26 | uint32_t num_cpus; | 64 | s->analog[PMU_REG_2P5] = 0x00005071; |
27 | A15MPPrivState a7mpcore; | 65 | s->analog[PMU_REG_CORE] = 0x00402010; |
28 | + MemoryRegion *dram_mr; | 66 | - s->analog[PMU_MISC0] = 0x04000000; |
29 | MemoryRegion sram; | 67 | + s->analog[PMU_MISC0] = 0x04000080; |
30 | AspeedVICState vic; | 68 | s->analog[PMU_MISC1] = 0x00000000; |
31 | AspeedRtcState rtc; | 69 | s->analog[PMU_MISC2] = 0x00272727; |
32 | diff --git a/hw/arm/aspeed_ast2600.c b/hw/arm/aspeed_ast2600.c | ||
33 | index XXXXXXX..XXXXXXX 100644 | ||
34 | --- a/hw/arm/aspeed_ast2600.c | ||
35 | +++ b/hw/arm/aspeed_ast2600.c | ||
36 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast2600_init(Object *obj) | ||
37 | typename); | ||
38 | object_property_add_alias(obj, "num-cs", OBJECT(&s->fmc), "num-cs", | ||
39 | &error_abort); | ||
40 | - object_property_add_alias(obj, "dram", OBJECT(&s->fmc), "dram", | ||
41 | - &error_abort); | ||
42 | |||
43 | for (i = 0; i < sc->spis_num; i++) { | ||
44 | snprintf(typename, sizeof(typename), "aspeed.spi%d-%s", i + 1, socname); | ||
45 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp) | ||
46 | } | ||
47 | |||
48 | /* FMC, The number of CS is set at the board level */ | ||
49 | + object_property_set_link(OBJECT(&s->fmc), OBJECT(s->dram_mr), "dram", &err); | ||
50 | + if (err) { | ||
51 | + error_propagate(errp, err); | ||
52 | + return; | ||
53 | + } | ||
54 | object_property_set_int(OBJECT(&s->fmc), sc->memmap[ASPEED_SDRAM], | ||
55 | "sdram-base", &err); | ||
56 | if (err) { | ||
57 | diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c | ||
58 | index XXXXXXX..XXXXXXX 100644 | ||
59 | --- a/hw/arm/aspeed_soc.c | ||
60 | +++ b/hw/arm/aspeed_soc.c | ||
61 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_init(Object *obj) | ||
62 | typename); | ||
63 | object_property_add_alias(obj, "num-cs", OBJECT(&s->fmc), "num-cs", | ||
64 | &error_abort); | ||
65 | - object_property_add_alias(obj, "dram", OBJECT(&s->fmc), "dram", | ||
66 | - &error_abort); | ||
67 | |||
68 | for (i = 0; i < sc->spis_num; i++) { | ||
69 | snprintf(typename, sizeof(typename), "aspeed.spi%d-%s", i + 1, socname); | ||
70 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) | ||
71 | aspeed_soc_get_irq(s, ASPEED_I2C)); | ||
72 | |||
73 | /* FMC, The number of CS is set at the board level */ | ||
74 | + object_property_set_link(OBJECT(&s->fmc), OBJECT(s->dram_mr), "dram", &err); | ||
75 | + if (err) { | ||
76 | + error_propagate(errp, err); | ||
77 | + return; | ||
78 | + } | ||
79 | object_property_set_int(OBJECT(&s->fmc), sc->memmap[ASPEED_SDRAM], | ||
80 | "sdram-base", &err); | ||
81 | if (err) { | ||
82 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) | ||
83 | } | ||
84 | static Property aspeed_soc_properties[] = { | ||
85 | DEFINE_PROP_UINT32("num-cpus", AspeedSoCState, num_cpus, 0), | ||
86 | + DEFINE_PROP_LINK("dram", AspeedSoCState, dram_mr, TYPE_MEMORY_REGION, | ||
87 | + MemoryRegion *), | ||
88 | DEFINE_PROP_END_OF_LIST(), | ||
89 | }; | ||
90 | 70 | ||
91 | -- | 71 | -- |
92 | 2.20.1 | 72 | 2.20.1 |
93 | 73 | ||
94 | 74 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Cédric Le Goater <clg@kaod.org> | ||
2 | 1 | ||
3 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
4 | Reviewed-by: Joel Stanley <joel@jms.id.au> | ||
5 | Tested-by: Jae Hyun Yoo <jae.hyun.yoo@linux.intel.com> | ||
6 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
7 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
8 | Message-id: 20191119141211.25716-6-clg@kaod.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | hw/i2c/aspeed_i2c.c | 93 ++++++++++++++++++++++++++++++++++++++------- | ||
12 | hw/i2c/trace-events | 9 +++++ | ||
13 | 2 files changed, 89 insertions(+), 13 deletions(-) | ||
14 | |||
15 | diff --git a/hw/i2c/aspeed_i2c.c b/hw/i2c/aspeed_i2c.c | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/hw/i2c/aspeed_i2c.c | ||
18 | +++ b/hw/i2c/aspeed_i2c.c | ||
19 | @@ -XXX,XX +XXX,XX @@ | ||
20 | #include "hw/i2c/aspeed_i2c.h" | ||
21 | #include "hw/irq.h" | ||
22 | #include "hw/qdev-properties.h" | ||
23 | +#include "trace.h" | ||
24 | |||
25 | /* I2C Global Register */ | ||
26 | |||
27 | @@ -XXX,XX +XXX,XX @@ static inline void aspeed_i2c_bus_raise_interrupt(AspeedI2CBus *bus) | ||
28 | { | ||
29 | AspeedI2CClass *aic = ASPEED_I2C_GET_CLASS(bus->controller); | ||
30 | |||
31 | + trace_aspeed_i2c_bus_raise_interrupt(bus->intr_status, | ||
32 | + bus->intr_status & I2CD_INTR_TX_NAK ? "nak|" : "", | ||
33 | + bus->intr_status & I2CD_INTR_TX_ACK ? "ack|" : "", | ||
34 | + bus->intr_status & I2CD_INTR_RX_DONE ? "done|" : "", | ||
35 | + bus->intr_status & I2CD_INTR_NORMAL_STOP ? "normal|" : "", | ||
36 | + bus->intr_status & I2CD_INTR_ABNORMAL ? "abnormal" : ""); | ||
37 | + | ||
38 | bus->intr_status &= bus->intr_ctrl; | ||
39 | if (bus->intr_status) { | ||
40 | bus->controller->intr_status |= 1 << bus->id; | ||
41 | @@ -XXX,XX +XXX,XX @@ static uint64_t aspeed_i2c_bus_read(void *opaque, hwaddr offset, | ||
42 | { | ||
43 | AspeedI2CBus *bus = opaque; | ||
44 | AspeedI2CClass *aic = ASPEED_I2C_GET_CLASS(bus->controller); | ||
45 | + uint64_t value = -1; | ||
46 | |||
47 | switch (offset) { | ||
48 | case I2CD_FUN_CTRL_REG: | ||
49 | - return bus->ctrl; | ||
50 | + value = bus->ctrl; | ||
51 | + break; | ||
52 | case I2CD_AC_TIMING_REG1: | ||
53 | - return bus->timing[0]; | ||
54 | + value = bus->timing[0]; | ||
55 | + break; | ||
56 | case I2CD_AC_TIMING_REG2: | ||
57 | - return bus->timing[1]; | ||
58 | + value = bus->timing[1]; | ||
59 | + break; | ||
60 | case I2CD_INTR_CTRL_REG: | ||
61 | - return bus->intr_ctrl; | ||
62 | + value = bus->intr_ctrl; | ||
63 | + break; | ||
64 | case I2CD_INTR_STS_REG: | ||
65 | - return bus->intr_status; | ||
66 | + value = bus->intr_status; | ||
67 | + break; | ||
68 | case I2CD_POOL_CTRL_REG: | ||
69 | - return bus->pool_ctrl; | ||
70 | + value = bus->pool_ctrl; | ||
71 | + break; | ||
72 | case I2CD_BYTE_BUF_REG: | ||
73 | - return bus->buf; | ||
74 | + value = bus->buf; | ||
75 | + break; | ||
76 | case I2CD_CMD_REG: | ||
77 | - return bus->cmd | (i2c_bus_busy(bus->bus) << 16); | ||
78 | + value = bus->cmd | (i2c_bus_busy(bus->bus) << 16); | ||
79 | + break; | ||
80 | case I2CD_DMA_ADDR: | ||
81 | if (!aic->has_dma) { | ||
82 | qemu_log_mask(LOG_GUEST_ERROR, "%s: No DMA support\n", __func__); | ||
83 | - return -1; | ||
84 | + break; | ||
85 | } | ||
86 | - return bus->dma_addr; | ||
87 | + value = bus->dma_addr; | ||
88 | + break; | ||
89 | case I2CD_DMA_LEN: | ||
90 | if (!aic->has_dma) { | ||
91 | qemu_log_mask(LOG_GUEST_ERROR, "%s: No DMA support\n", __func__); | ||
92 | - return -1; | ||
93 | + break; | ||
94 | } | ||
95 | - return bus->dma_len; | ||
96 | + value = bus->dma_len; | ||
97 | + break; | ||
98 | + | ||
99 | default: | ||
100 | qemu_log_mask(LOG_GUEST_ERROR, | ||
101 | "%s: Bad offset 0x%" HWADDR_PRIx "\n", __func__, offset); | ||
102 | - return -1; | ||
103 | + value = -1; | ||
104 | + break; | ||
105 | } | ||
106 | + | ||
107 | + trace_aspeed_i2c_bus_read(bus->id, offset, size, value); | ||
108 | + return value; | ||
109 | } | ||
110 | |||
111 | static void aspeed_i2c_set_state(AspeedI2CBus *bus, uint8_t state) | ||
112 | @@ -XXX,XX +XXX,XX @@ static int aspeed_i2c_bus_send(AspeedI2CBus *bus, uint8_t pool_start) | ||
113 | for (i = pool_start; i < I2CD_POOL_TX_COUNT(bus->pool_ctrl); i++) { | ||
114 | uint8_t *pool_base = aic->bus_pool_base(bus); | ||
115 | |||
116 | + trace_aspeed_i2c_bus_send("BUF", i + 1, | ||
117 | + I2CD_POOL_TX_COUNT(bus->pool_ctrl), | ||
118 | + pool_base[i]); | ||
119 | ret = i2c_send(bus->bus, pool_base[i]); | ||
120 | if (ret) { | ||
121 | break; | ||
122 | @@ -XXX,XX +XXX,XX @@ static int aspeed_i2c_bus_send(AspeedI2CBus *bus, uint8_t pool_start) | ||
123 | while (bus->dma_len) { | ||
124 | uint8_t data; | ||
125 | aspeed_i2c_dma_read(bus, &data); | ||
126 | + trace_aspeed_i2c_bus_send("DMA", bus->dma_len, bus->dma_len, data); | ||
127 | ret = i2c_send(bus->bus, data); | ||
128 | if (ret) { | ||
129 | break; | ||
130 | @@ -XXX,XX +XXX,XX @@ static int aspeed_i2c_bus_send(AspeedI2CBus *bus, uint8_t pool_start) | ||
131 | } | ||
132 | bus->cmd &= ~I2CD_TX_DMA_ENABLE; | ||
133 | } else { | ||
134 | + trace_aspeed_i2c_bus_send("BYTE", pool_start, 1, bus->buf); | ||
135 | ret = i2c_send(bus->bus, bus->buf); | ||
136 | } | ||
137 | |||
138 | @@ -XXX,XX +XXX,XX @@ static void aspeed_i2c_bus_recv(AspeedI2CBus *bus) | ||
139 | |||
140 | for (i = 0; i < I2CD_POOL_RX_SIZE(bus->pool_ctrl); i++) { | ||
141 | pool_base[i] = i2c_recv(bus->bus); | ||
142 | + trace_aspeed_i2c_bus_recv("BUF", i + 1, | ||
143 | + I2CD_POOL_RX_SIZE(bus->pool_ctrl), | ||
144 | + pool_base[i]); | ||
145 | } | ||
146 | |||
147 | /* Update RX count */ | ||
148 | @@ -XXX,XX +XXX,XX @@ static void aspeed_i2c_bus_recv(AspeedI2CBus *bus) | ||
149 | MemTxResult result; | ||
150 | |||
151 | data = i2c_recv(bus->bus); | ||
152 | + trace_aspeed_i2c_bus_recv("DMA", bus->dma_len, bus->dma_len, data); | ||
153 | result = address_space_write(&s->dram_as, bus->dma_addr, | ||
154 | MEMTXATTRS_UNSPECIFIED, &data, 1); | ||
155 | if (result != MEMTX_OK) { | ||
156 | @@ -XXX,XX +XXX,XX @@ static void aspeed_i2c_bus_recv(AspeedI2CBus *bus) | ||
157 | bus->cmd &= ~I2CD_RX_DMA_ENABLE; | ||
158 | } else { | ||
159 | data = i2c_recv(bus->bus); | ||
160 | + trace_aspeed_i2c_bus_recv("BYTE", 1, 1, bus->buf); | ||
161 | bus->buf = (data & I2CD_BYTE_BUF_RX_MASK) << I2CD_BYTE_BUF_RX_SHIFT; | ||
162 | } | ||
163 | } | ||
164 | @@ -XXX,XX +XXX,XX @@ static bool aspeed_i2c_check_sram(AspeedI2CBus *bus) | ||
165 | return true; | ||
166 | } | ||
167 | |||
168 | +static void aspeed_i2c_bus_cmd_dump(AspeedI2CBus *bus) | ||
169 | +{ | ||
170 | + g_autofree char *cmd_flags; | ||
171 | + uint32_t count; | ||
172 | + | ||
173 | + if (bus->cmd & (I2CD_RX_BUFF_ENABLE | I2CD_RX_BUFF_ENABLE)) { | ||
174 | + count = I2CD_POOL_TX_COUNT(bus->pool_ctrl); | ||
175 | + } else if (bus->cmd & (I2CD_RX_DMA_ENABLE | I2CD_RX_DMA_ENABLE)) { | ||
176 | + count = bus->dma_len; | ||
177 | + } else { /* BYTE mode */ | ||
178 | + count = 1; | ||
179 | + } | ||
180 | + | ||
181 | + cmd_flags = g_strdup_printf("%s%s%s%s%s%s%s%s%s", | ||
182 | + bus->cmd & I2CD_M_START_CMD ? "start|" : "", | ||
183 | + bus->cmd & I2CD_RX_DMA_ENABLE ? "rxdma|" : "", | ||
184 | + bus->cmd & I2CD_TX_DMA_ENABLE ? "txdma|" : "", | ||
185 | + bus->cmd & I2CD_RX_BUFF_ENABLE ? "rxbuf|" : "", | ||
186 | + bus->cmd & I2CD_TX_BUFF_ENABLE ? "txbuf|" : "", | ||
187 | + bus->cmd & I2CD_M_TX_CMD ? "tx|" : "", | ||
188 | + bus->cmd & I2CD_M_RX_CMD ? "rx|" : "", | ||
189 | + bus->cmd & I2CD_M_S_RX_CMD_LAST ? "last|" : "", | ||
190 | + bus->cmd & I2CD_M_STOP_CMD ? "stop" : ""); | ||
191 | + | ||
192 | + trace_aspeed_i2c_bus_cmd(bus->cmd, cmd_flags, count, bus->intr_status); | ||
193 | +} | ||
194 | + | ||
195 | /* | ||
196 | * The state machine needs some refinement. It is only used to track | ||
197 | * invalid STOP commands for the moment. | ||
198 | @@ -XXX,XX +XXX,XX @@ static void aspeed_i2c_bus_handle_cmd(AspeedI2CBus *bus, uint64_t value) | ||
199 | return; | ||
200 | } | ||
201 | |||
202 | + if (trace_event_get_state_backends(TRACE_ASPEED_I2C_BUS_CMD)) { | ||
203 | + aspeed_i2c_bus_cmd_dump(bus); | ||
204 | + } | ||
205 | + | ||
206 | if (bus->cmd & I2CD_M_START_CMD) { | ||
207 | uint8_t state = aspeed_i2c_get_state(bus) & I2CD_MACTIVE ? | ||
208 | I2CD_MSTARTR : I2CD_MSTART; | ||
209 | @@ -XXX,XX +XXX,XX @@ static void aspeed_i2c_bus_write(void *opaque, hwaddr offset, | ||
210 | AspeedI2CClass *aic = ASPEED_I2C_GET_CLASS(bus->controller); | ||
211 | bool handle_rx; | ||
212 | |||
213 | + trace_aspeed_i2c_bus_write(bus->id, offset, size, value); | ||
214 | + | ||
215 | switch (offset) { | ||
216 | case I2CD_FUN_CTRL_REG: | ||
217 | if (value & I2CD_SLAVE_EN) { | ||
218 | diff --git a/hw/i2c/trace-events b/hw/i2c/trace-events | ||
219 | index XXXXXXX..XXXXXXX 100644 | ||
220 | --- a/hw/i2c/trace-events | ||
221 | +++ b/hw/i2c/trace-events | ||
222 | @@ -XXX,XX +XXX,XX @@ | ||
223 | i2c_event(const char *event, uint8_t address) "%s(addr:0x%02x)" | ||
224 | i2c_send(uint8_t address, uint8_t data) "send(addr:0x%02x) data:0x%02x" | ||
225 | i2c_recv(uint8_t address, uint8_t data) "recv(addr:0x%02x) data:0x%02x" | ||
226 | + | ||
227 | +# aspeed_i2c.c | ||
228 | + | ||
229 | +aspeed_i2c_bus_cmd(uint32_t cmd, const char *cmd_flags, uint32_t count, uint32_t intr_status) "handling cmd=0x%x %s count=%d intr=0x%x" | ||
230 | +aspeed_i2c_bus_raise_interrupt(uint32_t intr_status, const char *str1, const char *str2, const char *str3, const char *str4, const char *str5) "handled intr=0x%x %s%s%s%s%s" | ||
231 | +aspeed_i2c_bus_read(uint32_t busid, uint64_t offset, unsigned size, uint64_t value) "bus[%d]: To 0x%" PRIx64 " of size %u: 0x%" PRIx64 | ||
232 | +aspeed_i2c_bus_write(uint32_t busid, uint64_t offset, unsigned size, uint64_t value) "bus[%d]: To 0x%" PRIx64 " of size %u: 0x%" PRIx64 | ||
233 | +aspeed_i2c_bus_send(const char *mode, int i, int count, uint8_t byte) "%s send %d/%d 0x%02x" | ||
234 | +aspeed_i2c_bus_recv(const char *mode, int i, int count, uint8_t byte) "%s recv %d/%d 0x%02x" | ||
235 | -- | ||
236 | 2.20.1 | ||
237 | |||
238 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Joel Stanley <joel@jms.id.au> | ||
2 | 1 | ||
3 | Most boards have this much. | ||
4 | |||
5 | Reviewed-by: Cédric Le Goater <clg@kaod.org> | ||
6 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
7 | Signed-off-by: Joel Stanley <joel@jms.id.au> | ||
8 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
9 | Message-id: 20191119141211.25716-7-clg@kaod.org | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | hw/misc/aspeed_sdmc.c | 6 +++--- | ||
13 | 1 file changed, 3 insertions(+), 3 deletions(-) | ||
14 | |||
15 | diff --git a/hw/misc/aspeed_sdmc.c b/hw/misc/aspeed_sdmc.c | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/hw/misc/aspeed_sdmc.c | ||
18 | +++ b/hw/misc/aspeed_sdmc.c | ||
19 | @@ -XXX,XX +XXX,XX @@ static int ast2600_rambits(AspeedSDMCState *s) | ||
20 | } | ||
21 | |||
22 | /* use a common default */ | ||
23 | - warn_report("Invalid RAM size 0x%" PRIx64 ". Using default 512M", | ||
24 | + warn_report("Invalid RAM size 0x%" PRIx64 ". Using default 1024M", | ||
25 | s->ram_size); | ||
26 | - s->ram_size = 512 << 20; | ||
27 | - return ASPEED_SDMC_AST2600_512MB; | ||
28 | + s->ram_size = 1024 << 20; | ||
29 | + return ASPEED_SDMC_AST2600_1024MB; | ||
30 | } | ||
31 | |||
32 | static void aspeed_sdmc_reset(DeviceState *dev) | ||
33 | -- | ||
34 | 2.20.1 | ||
35 | |||
36 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Joel Stanley <joel@jms.id.au> | ||
2 | 1 | ||
3 | This models the clock write one to clear registers, and fixes up some | ||
4 | incorrect behavior in all of the write to clear registers. | ||
5 | |||
6 | There was also a typo in one of the register definitions. | ||
7 | |||
8 | Reviewed-by: Cédric Le Goater <clg@kaod.org> | ||
9 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
10 | Signed-off-by: Joel Stanley <joel@jms.id.au> | ||
11 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
12 | Message-id: 20191119141211.25716-8-clg@kaod.org | ||
13 | [clg: checkpatch.pl fixes ] | ||
14 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
16 | --- | ||
17 | hw/misc/aspeed_scu.c | 19 ++++++++++++++----- | ||
18 | 1 file changed, 14 insertions(+), 5 deletions(-) | ||
19 | |||
20 | diff --git a/hw/misc/aspeed_scu.c b/hw/misc/aspeed_scu.c | ||
21 | index XXXXXXX..XXXXXXX 100644 | ||
22 | --- a/hw/misc/aspeed_scu.c | ||
23 | +++ b/hw/misc/aspeed_scu.c | ||
24 | @@ -XXX,XX +XXX,XX @@ | ||
25 | #define AST2600_CLK_STOP_CTRL TO_REG(0x80) | ||
26 | #define AST2600_CLK_STOP_CTRL_CLR TO_REG(0x84) | ||
27 | #define AST2600_CLK_STOP_CTRL2 TO_REG(0x90) | ||
28 | -#define AST2600_CLK_STOP_CTR2L_CLR TO_REG(0x94) | ||
29 | +#define AST2600_CLK_STOP_CTRL2_CLR TO_REG(0x94) | ||
30 | #define AST2600_SDRAM_HANDSHAKE TO_REG(0x100) | ||
31 | #define AST2600_HPLL_PARAM TO_REG(0x200) | ||
32 | #define AST2600_HPLL_EXT TO_REG(0x204) | ||
33 | @@ -XXX,XX +XXX,XX @@ static uint64_t aspeed_ast2600_scu_read(void *opaque, hwaddr offset, | ||
34 | return s->regs[reg]; | ||
35 | } | ||
36 | |||
37 | -static void aspeed_ast2600_scu_write(void *opaque, hwaddr offset, uint64_t data, | ||
38 | - unsigned size) | ||
39 | +static void aspeed_ast2600_scu_write(void *opaque, hwaddr offset, | ||
40 | + uint64_t data64, unsigned size) | ||
41 | { | ||
42 | AspeedSCUState *s = ASPEED_SCU(opaque); | ||
43 | int reg = TO_REG(offset); | ||
44 | + /* Truncate here so bitwise operations below behave as expected */ | ||
45 | + uint32_t data = data64; | ||
46 | |||
47 | if (reg >= ASPEED_AST2600_SCU_NR_REGS) { | ||
48 | qemu_log_mask(LOG_GUEST_ERROR, | ||
49 | @@ -XXX,XX +XXX,XX @@ static void aspeed_ast2600_scu_write(void *opaque, hwaddr offset, uint64_t data, | ||
50 | /* fall through */ | ||
51 | case AST2600_SYS_RST_CTRL: | ||
52 | case AST2600_SYS_RST_CTRL2: | ||
53 | + case AST2600_CLK_STOP_CTRL: | ||
54 | + case AST2600_CLK_STOP_CTRL2: | ||
55 | /* W1S (Write 1 to set) registers */ | ||
56 | s->regs[reg] |= data; | ||
57 | return; | ||
58 | case AST2600_SYS_RST_CTRL_CLR: | ||
59 | case AST2600_SYS_RST_CTRL2_CLR: | ||
60 | + case AST2600_CLK_STOP_CTRL_CLR: | ||
61 | + case AST2600_CLK_STOP_CTRL2_CLR: | ||
62 | case AST2600_HW_STRAP1_CLR: | ||
63 | case AST2600_HW_STRAP2_CLR: | ||
64 | - /* W1C (Write 1 to clear) registers */ | ||
65 | - s->regs[reg] &= ~data; | ||
66 | + /* | ||
67 | + * W1C (Write 1 to clear) registers are offset by one address from | ||
68 | + * the data register | ||
69 | + */ | ||
70 | + s->regs[reg - 1] &= ~data; | ||
71 | return; | ||
72 | |||
73 | case AST2600_RNG_DATA: | ||
74 | -- | ||
75 | 2.20.1 | ||
76 | |||
77 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Cédric Le Goater <clg@kaod.org> | ||
2 | 1 | ||
3 | The current model only restores the Segment Register values but leaves | ||
4 | the previous CS mapping behind. Introduce a helper setting the | ||
5 | register value and mapping the region at the requested address. Use | ||
6 | this helper when a Segment register is set and at reset. | ||
7 | |||
8 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
9 | Reviewed-by: Joel Stanley <joel@jms.id.au> | ||
10 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
11 | Message-id: 20191119141211.25716-11-clg@kaod.org | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | --- | ||
14 | hw/ssi/aspeed_smc.c | 32 +++++++++++++++++++++----------- | ||
15 | 1 file changed, 21 insertions(+), 11 deletions(-) | ||
16 | |||
17 | diff --git a/hw/ssi/aspeed_smc.c b/hw/ssi/aspeed_smc.c | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/hw/ssi/aspeed_smc.c | ||
20 | +++ b/hw/ssi/aspeed_smc.c | ||
21 | @@ -XXX,XX +XXX,XX @@ static bool aspeed_smc_flash_overlap(const AspeedSMCState *s, | ||
22 | return false; | ||
23 | } | ||
24 | |||
25 | +static void aspeed_smc_flash_set_segment_region(AspeedSMCState *s, int cs, | ||
26 | + uint64_t regval) | ||
27 | +{ | ||
28 | + AspeedSMCFlash *fl = &s->flashes[cs]; | ||
29 | + AspeedSegments seg; | ||
30 | + | ||
31 | + s->ctrl->reg_to_segment(s, regval, &seg); | ||
32 | + | ||
33 | + memory_region_transaction_begin(); | ||
34 | + memory_region_set_size(&fl->mmio, seg.size); | ||
35 | + memory_region_set_address(&fl->mmio, seg.addr - s->ctrl->flash_window_base); | ||
36 | + memory_region_set_enabled(&fl->mmio, true); | ||
37 | + memory_region_transaction_commit(); | ||
38 | + | ||
39 | + s->regs[R_SEG_ADDR0 + cs] = regval; | ||
40 | +} | ||
41 | + | ||
42 | static void aspeed_smc_flash_set_segment(AspeedSMCState *s, int cs, | ||
43 | uint64_t new) | ||
44 | { | ||
45 | - AspeedSMCFlash *fl = &s->flashes[cs]; | ||
46 | AspeedSegments seg; | ||
47 | |||
48 | s->ctrl->reg_to_segment(s, new, &seg); | ||
49 | @@ -XXX,XX +XXX,XX @@ static void aspeed_smc_flash_set_segment(AspeedSMCState *s, int cs, | ||
50 | aspeed_smc_flash_overlap(s, &seg, cs); | ||
51 | |||
52 | /* All should be fine now to move the region */ | ||
53 | - memory_region_transaction_begin(); | ||
54 | - memory_region_set_size(&fl->mmio, seg.size); | ||
55 | - memory_region_set_address(&fl->mmio, seg.addr - s->ctrl->flash_window_base); | ||
56 | - memory_region_set_enabled(&fl->mmio, true); | ||
57 | - memory_region_transaction_commit(); | ||
58 | - | ||
59 | - s->regs[R_SEG_ADDR0 + cs] = new; | ||
60 | + aspeed_smc_flash_set_segment_region(s, cs, new); | ||
61 | } | ||
62 | |||
63 | static uint64_t aspeed_smc_flash_default_read(void *opaque, hwaddr addr, | ||
64 | @@ -XXX,XX +XXX,XX @@ static void aspeed_smc_reset(DeviceState *d) | ||
65 | qemu_set_irq(s->cs_lines[i], true); | ||
66 | } | ||
67 | |||
68 | - /* setup default segment register values for all */ | ||
69 | + /* setup the default segment register values and regions for all */ | ||
70 | for (i = 0; i < s->ctrl->max_slaves; ++i) { | ||
71 | - s->regs[R_SEG_ADDR0 + i] = | ||
72 | - s->ctrl->segment_to_reg(s, &s->ctrl->segments[i]); | ||
73 | + aspeed_smc_flash_set_segment_region(s, i, | ||
74 | + s->ctrl->segment_to_reg(s, &s->ctrl->segments[i])); | ||
75 | } | ||
76 | |||
77 | /* HW strapping flash type for the AST2600 controllers */ | ||
78 | -- | ||
79 | 2.20.1 | ||
80 | |||
81 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Cédric Le Goater <clg@kaod.org> | ||
2 | 1 | ||
3 | The segments can be disabled on the AST2600 (zero register value). | ||
4 | CS0 is open by default but not the other CS. This is closing the | ||
5 | access to the flash device in user mode and forbids scanning. | ||
6 | |||
7 | In the model, check the segment size and disable the associated region | ||
8 | when the value is zero. | ||
9 | |||
10 | Fixes: bcaa8ddd081c ("aspeed/smc: Add AST2600 support") | ||
11 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
12 | Reviewed-by: Joel Stanley <joel@jms.id.au> | ||
13 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
14 | Message-id: 20191119141211.25716-12-clg@kaod.org | ||
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
16 | --- | ||
17 | hw/ssi/aspeed_smc.c | 16 +++++++++++----- | ||
18 | 1 file changed, 11 insertions(+), 5 deletions(-) | ||
19 | |||
20 | diff --git a/hw/ssi/aspeed_smc.c b/hw/ssi/aspeed_smc.c | ||
21 | index XXXXXXX..XXXXXXX 100644 | ||
22 | --- a/hw/ssi/aspeed_smc.c | ||
23 | +++ b/hw/ssi/aspeed_smc.c | ||
24 | @@ -XXX,XX +XXX,XX @@ static void aspeed_2600_smc_reg_to_segment(const AspeedSMCState *s, | ||
25 | uint32_t start_offset = (reg << 16) & AST2600_SEG_ADDR_MASK; | ||
26 | uint32_t end_offset = reg & AST2600_SEG_ADDR_MASK; | ||
27 | |||
28 | - seg->addr = s->ctrl->flash_window_base + start_offset; | ||
29 | - seg->size = end_offset + MiB - start_offset; | ||
30 | + if (reg) { | ||
31 | + seg->addr = s->ctrl->flash_window_base + start_offset; | ||
32 | + seg->size = end_offset + MiB - start_offset; | ||
33 | + } else { | ||
34 | + seg->addr = s->ctrl->flash_window_base; | ||
35 | + seg->size = 0; | ||
36 | + } | ||
37 | } | ||
38 | |||
39 | static bool aspeed_smc_flash_overlap(const AspeedSMCState *s, | ||
40 | @@ -XXX,XX +XXX,XX @@ static void aspeed_smc_flash_set_segment_region(AspeedSMCState *s, int cs, | ||
41 | memory_region_transaction_begin(); | ||
42 | memory_region_set_size(&fl->mmio, seg.size); | ||
43 | memory_region_set_address(&fl->mmio, seg.addr - s->ctrl->flash_window_base); | ||
44 | - memory_region_set_enabled(&fl->mmio, true); | ||
45 | + memory_region_set_enabled(&fl->mmio, !!seg.size); | ||
46 | memory_region_transaction_commit(); | ||
47 | |||
48 | s->regs[R_SEG_ADDR0 + cs] = regval; | ||
49 | @@ -XXX,XX +XXX,XX @@ static void aspeed_smc_flash_set_segment(AspeedSMCState *s, int cs, | ||
50 | } | ||
51 | |||
52 | /* Keep the segment in the overall flash window */ | ||
53 | - if (seg.addr + seg.size <= s->ctrl->flash_window_base || | ||
54 | - seg.addr > s->ctrl->flash_window_base + s->ctrl->flash_window_size) { | ||
55 | + if (seg.size && | ||
56 | + (seg.addr + seg.size <= s->ctrl->flash_window_base || | ||
57 | + seg.addr > s->ctrl->flash_window_base + s->ctrl->flash_window_size)) { | ||
58 | qemu_log_mask(LOG_GUEST_ERROR, "%s: new segment for CS%d is invalid : " | ||
59 | "[ 0x%"HWADDR_PRIx" - 0x%"HWADDR_PRIx" ]\n", | ||
60 | s->ctrl->name, cs, seg.addr, seg.addr + seg.size); | ||
61 | -- | ||
62 | 2.20.1 | ||
63 | |||
64 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Cédric Le Goater <clg@kaod.org> | ||
2 | 1 | ||
3 | Each CS has its own Read Timing Compensation Register on newer SoCs. | ||
4 | |||
5 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
6 | Reviewed-by: Joel Stanley <joel@jms.id.au> | ||
7 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
8 | Message-id: 20191119141211.25716-13-clg@kaod.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | include/hw/ssi/aspeed_smc.h | 1 + | ||
12 | hw/ssi/aspeed_smc.c | 17 ++++++++++++++--- | ||
13 | 2 files changed, 15 insertions(+), 3 deletions(-) | ||
14 | |||
15 | diff --git a/include/hw/ssi/aspeed_smc.h b/include/hw/ssi/aspeed_smc.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/include/hw/ssi/aspeed_smc.h | ||
18 | +++ b/include/hw/ssi/aspeed_smc.h | ||
19 | @@ -XXX,XX +XXX,XX @@ typedef struct AspeedSMCController { | ||
20 | uint8_t r_ce_ctrl; | ||
21 | uint8_t r_ctrl0; | ||
22 | uint8_t r_timings; | ||
23 | + uint8_t nregs_timings; | ||
24 | uint8_t conf_enable_w0; | ||
25 | uint8_t max_slaves; | ||
26 | const AspeedSegments *segments; | ||
27 | diff --git a/hw/ssi/aspeed_smc.c b/hw/ssi/aspeed_smc.c | ||
28 | index XXXXXXX..XXXXXXX 100644 | ||
29 | --- a/hw/ssi/aspeed_smc.c | ||
30 | +++ b/hw/ssi/aspeed_smc.c | ||
31 | @@ -XXX,XX +XXX,XX @@ | ||
32 | /* Checksum Calculation Result */ | ||
33 | #define R_DMA_CHECKSUM (0x90 / 4) | ||
34 | |||
35 | -/* Misc Control Register #2 */ | ||
36 | +/* Read Timing Compensation Register */ | ||
37 | #define R_TIMINGS (0x94 / 4) | ||
38 | |||
39 | /* SPI controller registers and bits (AST2400) */ | ||
40 | @@ -XXX,XX +XXX,XX @@ static const AspeedSMCController controllers[] = { | ||
41 | .r_ce_ctrl = R_CE_CTRL, | ||
42 | .r_ctrl0 = R_CTRL0, | ||
43 | .r_timings = R_TIMINGS, | ||
44 | + .nregs_timings = 1, | ||
45 | .conf_enable_w0 = CONF_ENABLE_W0, | ||
46 | .max_slaves = 5, | ||
47 | .segments = aspeed_segments_legacy, | ||
48 | @@ -XXX,XX +XXX,XX @@ static const AspeedSMCController controllers[] = { | ||
49 | .r_ce_ctrl = R_CE_CTRL, | ||
50 | .r_ctrl0 = R_CTRL0, | ||
51 | .r_timings = R_TIMINGS, | ||
52 | + .nregs_timings = 1, | ||
53 | .conf_enable_w0 = CONF_ENABLE_W0, | ||
54 | .max_slaves = 5, | ||
55 | .segments = aspeed_segments_fmc, | ||
56 | @@ -XXX,XX +XXX,XX @@ static const AspeedSMCController controllers[] = { | ||
57 | .r_ce_ctrl = 0xff, | ||
58 | .r_ctrl0 = R_SPI_CTRL0, | ||
59 | .r_timings = R_SPI_TIMINGS, | ||
60 | + .nregs_timings = 1, | ||
61 | .conf_enable_w0 = SPI_CONF_ENABLE_W0, | ||
62 | .max_slaves = 1, | ||
63 | .segments = aspeed_segments_spi, | ||
64 | @@ -XXX,XX +XXX,XX @@ static const AspeedSMCController controllers[] = { | ||
65 | .r_ce_ctrl = R_CE_CTRL, | ||
66 | .r_ctrl0 = R_CTRL0, | ||
67 | .r_timings = R_TIMINGS, | ||
68 | + .nregs_timings = 1, | ||
69 | .conf_enable_w0 = CONF_ENABLE_W0, | ||
70 | .max_slaves = 3, | ||
71 | .segments = aspeed_segments_ast2500_fmc, | ||
72 | @@ -XXX,XX +XXX,XX @@ static const AspeedSMCController controllers[] = { | ||
73 | .r_ce_ctrl = R_CE_CTRL, | ||
74 | .r_ctrl0 = R_CTRL0, | ||
75 | .r_timings = R_TIMINGS, | ||
76 | + .nregs_timings = 1, | ||
77 | .conf_enable_w0 = CONF_ENABLE_W0, | ||
78 | .max_slaves = 2, | ||
79 | .segments = aspeed_segments_ast2500_spi1, | ||
80 | @@ -XXX,XX +XXX,XX @@ static const AspeedSMCController controllers[] = { | ||
81 | .r_ce_ctrl = R_CE_CTRL, | ||
82 | .r_ctrl0 = R_CTRL0, | ||
83 | .r_timings = R_TIMINGS, | ||
84 | + .nregs_timings = 1, | ||
85 | .conf_enable_w0 = CONF_ENABLE_W0, | ||
86 | .max_slaves = 2, | ||
87 | .segments = aspeed_segments_ast2500_spi2, | ||
88 | @@ -XXX,XX +XXX,XX @@ static const AspeedSMCController controllers[] = { | ||
89 | .r_ce_ctrl = R_CE_CTRL, | ||
90 | .r_ctrl0 = R_CTRL0, | ||
91 | .r_timings = R_TIMINGS, | ||
92 | + .nregs_timings = 1, | ||
93 | .conf_enable_w0 = CONF_ENABLE_W0, | ||
94 | .max_slaves = 3, | ||
95 | .segments = aspeed_segments_ast2600_fmc, | ||
96 | @@ -XXX,XX +XXX,XX @@ static const AspeedSMCController controllers[] = { | ||
97 | .r_ce_ctrl = R_CE_CTRL, | ||
98 | .r_ctrl0 = R_CTRL0, | ||
99 | .r_timings = R_TIMINGS, | ||
100 | + .nregs_timings = 2, | ||
101 | .conf_enable_w0 = CONF_ENABLE_W0, | ||
102 | .max_slaves = 2, | ||
103 | .segments = aspeed_segments_ast2600_spi1, | ||
104 | @@ -XXX,XX +XXX,XX @@ static const AspeedSMCController controllers[] = { | ||
105 | .r_ce_ctrl = R_CE_CTRL, | ||
106 | .r_ctrl0 = R_CTRL0, | ||
107 | .r_timings = R_TIMINGS, | ||
108 | + .nregs_timings = 3, | ||
109 | .conf_enable_w0 = CONF_ENABLE_W0, | ||
110 | .max_slaves = 3, | ||
111 | .segments = aspeed_segments_ast2600_spi2, | ||
112 | @@ -XXX,XX +XXX,XX @@ static uint64_t aspeed_smc_read(void *opaque, hwaddr addr, unsigned int size) | ||
113 | addr >>= 2; | ||
114 | |||
115 | if (addr == s->r_conf || | ||
116 | - addr == s->r_timings || | ||
117 | + (addr >= s->r_timings && | ||
118 | + addr < s->r_timings + s->ctrl->nregs_timings) || | ||
119 | addr == s->r_ce_ctrl || | ||
120 | addr == R_INTR_CTRL || | ||
121 | addr == R_DUMMY_DATA || | ||
122 | @@ -XXX,XX +XXX,XX @@ static void aspeed_smc_write(void *opaque, hwaddr addr, uint64_t data, | ||
123 | addr >>= 2; | ||
124 | |||
125 | if (addr == s->r_conf || | ||
126 | - addr == s->r_timings || | ||
127 | + (addr >= s->r_timings && | ||
128 | + addr < s->r_timings + s->ctrl->nregs_timings) || | ||
129 | addr == s->r_ce_ctrl) { | ||
130 | s->regs[addr] = value; | ||
131 | } else if (addr >= s->r_ctrl0 && addr < s->r_ctrl0 + s->num_cs) { | ||
132 | -- | ||
133 | 2.20.1 | ||
134 | |||
135 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Cédric Le Goater <clg@kaod.org> | ||
2 | 1 | ||
3 | AspeedBoardConfig is a redundant way to define class attributes and it | ||
4 | complexifies the machine definition and initialization. | ||
5 | |||
6 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
7 | Reviewed-by: Joel Stanley <joel@jms.id.au> | ||
8 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
9 | Message-id: 20191119141211.25716-14-clg@kaod.org | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | include/hw/arm/aspeed.h | 24 ++-- | ||
13 | hw/arm/aspeed.c | 243 ++++++++++++++++++++++------------------ | ||
14 | 2 files changed, 143 insertions(+), 124 deletions(-) | ||
15 | |||
16 | diff --git a/include/hw/arm/aspeed.h b/include/hw/arm/aspeed.h | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/include/hw/arm/aspeed.h | ||
19 | +++ b/include/hw/arm/aspeed.h | ||
20 | @@ -XXX,XX +XXX,XX @@ | ||
21 | |||
22 | typedef struct AspeedBoardState AspeedBoardState; | ||
23 | |||
24 | -typedef struct AspeedBoardConfig { | ||
25 | - const char *name; | ||
26 | - const char *desc; | ||
27 | - const char *soc_name; | ||
28 | - uint32_t hw_strap1; | ||
29 | - uint32_t hw_strap2; | ||
30 | - const char *fmc_model; | ||
31 | - const char *spi_model; | ||
32 | - uint32_t num_cs; | ||
33 | - void (*i2c_init)(AspeedBoardState *bmc); | ||
34 | - uint32_t ram; | ||
35 | -} AspeedBoardConfig; | ||
36 | - | ||
37 | #define TYPE_ASPEED_MACHINE MACHINE_TYPE_NAME("aspeed") | ||
38 | #define ASPEED_MACHINE(obj) \ | ||
39 | OBJECT_CHECK(AspeedMachine, (obj), TYPE_ASPEED_MACHINE) | ||
40 | @@ -XXX,XX +XXX,XX @@ typedef struct AspeedMachine { | ||
41 | |||
42 | typedef struct AspeedMachineClass { | ||
43 | MachineClass parent_obj; | ||
44 | - const AspeedBoardConfig *board; | ||
45 | + | ||
46 | + const char *name; | ||
47 | + const char *desc; | ||
48 | + const char *soc_name; | ||
49 | + uint32_t hw_strap1; | ||
50 | + uint32_t hw_strap2; | ||
51 | + const char *fmc_model; | ||
52 | + const char *spi_model; | ||
53 | + uint32_t num_cs; | ||
54 | + void (*i2c_init)(AspeedBoardState *bmc); | ||
55 | } AspeedMachineClass; | ||
56 | |||
57 | |||
58 | diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c | ||
59 | index XXXXXXX..XXXXXXX 100644 | ||
60 | --- a/hw/arm/aspeed.c | ||
61 | +++ b/hw/arm/aspeed.c | ||
62 | @@ -XXX,XX +XXX,XX @@ static void aspeed_board_init_flashes(AspeedSMCState *s, const char *flashtype, | ||
63 | } | ||
64 | } | ||
65 | |||
66 | -static void aspeed_board_init(MachineState *machine, | ||
67 | - const AspeedBoardConfig *cfg) | ||
68 | +static void aspeed_machine_init(MachineState *machine) | ||
69 | { | ||
70 | AspeedBoardState *bmc; | ||
71 | + AspeedMachineClass *amc = ASPEED_MACHINE_GET_CLASS(machine); | ||
72 | AspeedSoCClass *sc; | ||
73 | DriveInfo *drive0 = drive_get(IF_MTD, 0, 0); | ||
74 | ram_addr_t max_ram_size; | ||
75 | @@ -XXX,XX +XXX,XX @@ static void aspeed_board_init(MachineState *machine, | ||
76 | UINT32_MAX); | ||
77 | |||
78 | object_initialize_child(OBJECT(machine), "soc", &bmc->soc, | ||
79 | - (sizeof(bmc->soc)), cfg->soc_name, &error_abort, | ||
80 | + (sizeof(bmc->soc)), amc->soc_name, &error_abort, | ||
81 | NULL); | ||
82 | |||
83 | sc = ASPEED_SOC_GET_CLASS(&bmc->soc); | ||
84 | |||
85 | object_property_set_uint(OBJECT(&bmc->soc), ram_size, "ram-size", | ||
86 | &error_abort); | ||
87 | - object_property_set_int(OBJECT(&bmc->soc), cfg->hw_strap1, "hw-strap1", | ||
88 | + object_property_set_int(OBJECT(&bmc->soc), amc->hw_strap1, "hw-strap1", | ||
89 | &error_abort); | ||
90 | - object_property_set_int(OBJECT(&bmc->soc), cfg->hw_strap2, "hw-strap2", | ||
91 | + object_property_set_int(OBJECT(&bmc->soc), amc->hw_strap2, "hw-strap2", | ||
92 | &error_abort); | ||
93 | - object_property_set_int(OBJECT(&bmc->soc), cfg->num_cs, "num-cs", | ||
94 | + object_property_set_int(OBJECT(&bmc->soc), amc->num_cs, "num-cs", | ||
95 | &error_abort); | ||
96 | object_property_set_int(OBJECT(&bmc->soc), machine->smp.cpus, "num-cpus", | ||
97 | &error_abort); | ||
98 | @@ -XXX,XX +XXX,XX @@ static void aspeed_board_init(MachineState *machine, | ||
99 | "max_ram", max_ram_size - ram_size); | ||
100 | memory_region_add_subregion(&bmc->ram_container, ram_size, &bmc->max_ram); | ||
101 | |||
102 | - aspeed_board_init_flashes(&bmc->soc.fmc, cfg->fmc_model, &error_abort); | ||
103 | - aspeed_board_init_flashes(&bmc->soc.spi[0], cfg->spi_model, &error_abort); | ||
104 | + aspeed_board_init_flashes(&bmc->soc.fmc, amc->fmc_model, &error_abort); | ||
105 | + aspeed_board_init_flashes(&bmc->soc.spi[0], amc->spi_model, &error_abort); | ||
106 | |||
107 | /* Install first FMC flash content as a boot rom. */ | ||
108 | if (drive0) { | ||
109 | @@ -XXX,XX +XXX,XX @@ static void aspeed_board_init(MachineState *machine, | ||
110 | aspeed_board_binfo.loader_start = sc->memmap[ASPEED_SDRAM]; | ||
111 | aspeed_board_binfo.nb_cpus = bmc->soc.num_cpus; | ||
112 | |||
113 | - if (cfg->i2c_init) { | ||
114 | - cfg->i2c_init(bmc); | ||
115 | + if (amc->i2c_init) { | ||
116 | + amc->i2c_init(bmc); | ||
117 | } | ||
118 | |||
119 | for (i = 0; i < ARRAY_SIZE(bmc->soc.sdhci.slots); i++) { | ||
120 | @@ -XXX,XX +XXX,XX @@ static void witherspoon_bmc_i2c_init(AspeedBoardState *bmc) | ||
121 | 0x60); | ||
122 | } | ||
123 | |||
124 | -static void aspeed_machine_init(MachineState *machine) | ||
125 | -{ | ||
126 | - AspeedMachineClass *amc = ASPEED_MACHINE_GET_CLASS(machine); | ||
127 | - | ||
128 | - aspeed_board_init(machine, amc->board); | ||
129 | -} | ||
130 | - | ||
131 | static void aspeed_machine_class_init(ObjectClass *oc, void *data) | ||
132 | { | ||
133 | MachineClass *mc = MACHINE_CLASS(oc); | ||
134 | - AspeedMachineClass *amc = ASPEED_MACHINE_CLASS(oc); | ||
135 | - const AspeedBoardConfig *board = data; | ||
136 | |||
137 | - mc->desc = board->desc; | ||
138 | mc->init = aspeed_machine_init; | ||
139 | mc->max_cpus = ASPEED_CPUS_NUM; | ||
140 | mc->no_floppy = 1; | ||
141 | mc->no_cdrom = 1; | ||
142 | mc->no_parallel = 1; | ||
143 | - if (board->ram) { | ||
144 | - mc->default_ram_size = board->ram; | ||
145 | - } | ||
146 | - amc->board = board; | ||
147 | } | ||
148 | |||
149 | -static const TypeInfo aspeed_machine_type = { | ||
150 | - .name = TYPE_ASPEED_MACHINE, | ||
151 | - .parent = TYPE_MACHINE, | ||
152 | - .instance_size = sizeof(AspeedMachine), | ||
153 | - .class_size = sizeof(AspeedMachineClass), | ||
154 | - .abstract = true, | ||
155 | -}; | ||
156 | - | ||
157 | -static const AspeedBoardConfig aspeed_boards[] = { | ||
158 | - { | ||
159 | - .name = MACHINE_TYPE_NAME("palmetto-bmc"), | ||
160 | - .desc = "OpenPOWER Palmetto BMC (ARM926EJ-S)", | ||
161 | - .soc_name = "ast2400-a1", | ||
162 | - .hw_strap1 = PALMETTO_BMC_HW_STRAP1, | ||
163 | - .fmc_model = "n25q256a", | ||
164 | - .spi_model = "mx25l25635e", | ||
165 | - .num_cs = 1, | ||
166 | - .i2c_init = palmetto_bmc_i2c_init, | ||
167 | - .ram = 256 * MiB, | ||
168 | - }, { | ||
169 | - .name = MACHINE_TYPE_NAME("ast2500-evb"), | ||
170 | - .desc = "Aspeed AST2500 EVB (ARM1176)", | ||
171 | - .soc_name = "ast2500-a1", | ||
172 | - .hw_strap1 = AST2500_EVB_HW_STRAP1, | ||
173 | - .fmc_model = "w25q256", | ||
174 | - .spi_model = "mx25l25635e", | ||
175 | - .num_cs = 1, | ||
176 | - .i2c_init = ast2500_evb_i2c_init, | ||
177 | - .ram = 512 * MiB, | ||
178 | - }, { | ||
179 | - .name = MACHINE_TYPE_NAME("romulus-bmc"), | ||
180 | - .desc = "OpenPOWER Romulus BMC (ARM1176)", | ||
181 | - .soc_name = "ast2500-a1", | ||
182 | - .hw_strap1 = ROMULUS_BMC_HW_STRAP1, | ||
183 | - .fmc_model = "n25q256a", | ||
184 | - .spi_model = "mx66l1g45g", | ||
185 | - .num_cs = 2, | ||
186 | - .i2c_init = romulus_bmc_i2c_init, | ||
187 | - .ram = 512 * MiB, | ||
188 | - }, { | ||
189 | - .name = MACHINE_TYPE_NAME("swift-bmc"), | ||
190 | - .desc = "OpenPOWER Swift BMC (ARM1176)", | ||
191 | - .soc_name = "ast2500-a1", | ||
192 | - .hw_strap1 = SWIFT_BMC_HW_STRAP1, | ||
193 | - .fmc_model = "mx66l1g45g", | ||
194 | - .spi_model = "mx66l1g45g", | ||
195 | - .num_cs = 2, | ||
196 | - .i2c_init = swift_bmc_i2c_init, | ||
197 | - .ram = 512 * MiB, | ||
198 | - }, { | ||
199 | - .name = MACHINE_TYPE_NAME("witherspoon-bmc"), | ||
200 | - .desc = "OpenPOWER Witherspoon BMC (ARM1176)", | ||
201 | - .soc_name = "ast2500-a1", | ||
202 | - .hw_strap1 = WITHERSPOON_BMC_HW_STRAP1, | ||
203 | - .fmc_model = "mx25l25635e", | ||
204 | - .spi_model = "mx66l1g45g", | ||
205 | - .num_cs = 2, | ||
206 | - .i2c_init = witherspoon_bmc_i2c_init, | ||
207 | - .ram = 512 * MiB, | ||
208 | - }, { | ||
209 | - .name = MACHINE_TYPE_NAME("ast2600-evb"), | ||
210 | - .desc = "Aspeed AST2600 EVB (Cortex A7)", | ||
211 | - .soc_name = "ast2600-a0", | ||
212 | - .hw_strap1 = AST2600_EVB_HW_STRAP1, | ||
213 | - .hw_strap2 = AST2600_EVB_HW_STRAP2, | ||
214 | - .fmc_model = "w25q512jv", | ||
215 | - .spi_model = "mx66u51235f", | ||
216 | - .num_cs = 1, | ||
217 | - .i2c_init = ast2600_evb_i2c_init, | ||
218 | - .ram = 1 * GiB, | ||
219 | - }, | ||
220 | -}; | ||
221 | - | ||
222 | -static void aspeed_machine_types(void) | ||
223 | +static void aspeed_machine_palmetto_class_init(ObjectClass *oc, void *data) | ||
224 | { | ||
225 | - int i; | ||
226 | + MachineClass *mc = MACHINE_CLASS(oc); | ||
227 | + AspeedMachineClass *amc = ASPEED_MACHINE_CLASS(oc); | ||
228 | |||
229 | - type_register_static(&aspeed_machine_type); | ||
230 | - for (i = 0; i < ARRAY_SIZE(aspeed_boards); ++i) { | ||
231 | - TypeInfo ti = { | ||
232 | - .name = aspeed_boards[i].name, | ||
233 | - .parent = TYPE_ASPEED_MACHINE, | ||
234 | - .class_init = aspeed_machine_class_init, | ||
235 | - .class_data = (void *)&aspeed_boards[i], | ||
236 | - }; | ||
237 | - type_register(&ti); | ||
238 | + mc->desc = "OpenPOWER Palmetto BMC (ARM926EJ-S)"; | ||
239 | + amc->soc_name = "ast2400-a1"; | ||
240 | + amc->hw_strap1 = PALMETTO_BMC_HW_STRAP1; | ||
241 | + amc->fmc_model = "n25q256a"; | ||
242 | + amc->spi_model = "mx25l25635e"; | ||
243 | + amc->num_cs = 1; | ||
244 | + amc->i2c_init = palmetto_bmc_i2c_init; | ||
245 | + mc->default_ram_size = 256 * MiB; | ||
246 | +}; | ||
247 | + | ||
248 | +static void aspeed_machine_ast2500_evb_class_init(ObjectClass *oc, void *data) | ||
249 | +{ | ||
250 | + MachineClass *mc = MACHINE_CLASS(oc); | ||
251 | + AspeedMachineClass *amc = ASPEED_MACHINE_CLASS(oc); | ||
252 | + | ||
253 | + mc->desc = "Aspeed AST2500 EVB (ARM1176)"; | ||
254 | + amc->soc_name = "ast2500-a1"; | ||
255 | + amc->hw_strap1 = AST2500_EVB_HW_STRAP1; | ||
256 | + amc->fmc_model = "w25q256"; | ||
257 | + amc->spi_model = "mx25l25635e"; | ||
258 | + amc->num_cs = 1; | ||
259 | + amc->i2c_init = ast2500_evb_i2c_init; | ||
260 | + mc->default_ram_size = 512 * MiB; | ||
261 | +}; | ||
262 | + | ||
263 | +static void aspeed_machine_romulus_class_init(ObjectClass *oc, void *data) | ||
264 | +{ | ||
265 | + MachineClass *mc = MACHINE_CLASS(oc); | ||
266 | + AspeedMachineClass *amc = ASPEED_MACHINE_CLASS(oc); | ||
267 | + | ||
268 | + mc->desc = "OpenPOWER Romulus BMC (ARM1176)"; | ||
269 | + amc->soc_name = "ast2500-a1"; | ||
270 | + amc->hw_strap1 = ROMULUS_BMC_HW_STRAP1; | ||
271 | + amc->fmc_model = "n25q256a"; | ||
272 | + amc->spi_model = "mx66l1g45g"; | ||
273 | + amc->num_cs = 2; | ||
274 | + amc->i2c_init = romulus_bmc_i2c_init; | ||
275 | + mc->default_ram_size = 512 * MiB; | ||
276 | +}; | ||
277 | + | ||
278 | +static void aspeed_machine_swift_class_init(ObjectClass *oc, void *data) | ||
279 | +{ | ||
280 | + MachineClass *mc = MACHINE_CLASS(oc); | ||
281 | + AspeedMachineClass *amc = ASPEED_MACHINE_CLASS(oc); | ||
282 | + | ||
283 | + mc->desc = "OpenPOWER Swift BMC (ARM1176)"; | ||
284 | + amc->soc_name = "ast2500-a1"; | ||
285 | + amc->hw_strap1 = SWIFT_BMC_HW_STRAP1; | ||
286 | + amc->fmc_model = "mx66l1g45g"; | ||
287 | + amc->spi_model = "mx66l1g45g"; | ||
288 | + amc->num_cs = 2; | ||
289 | + amc->i2c_init = swift_bmc_i2c_init; | ||
290 | + mc->default_ram_size = 512 * MiB; | ||
291 | +}; | ||
292 | + | ||
293 | +static void aspeed_machine_witherspoon_class_init(ObjectClass *oc, void *data) | ||
294 | +{ | ||
295 | + MachineClass *mc = MACHINE_CLASS(oc); | ||
296 | + AspeedMachineClass *amc = ASPEED_MACHINE_CLASS(oc); | ||
297 | + | ||
298 | + mc->desc = "OpenPOWER Witherspoon BMC (ARM1176)"; | ||
299 | + amc->soc_name = "ast2500-a1"; | ||
300 | + amc->hw_strap1 = WITHERSPOON_BMC_HW_STRAP1; | ||
301 | + amc->fmc_model = "mx25l25635e"; | ||
302 | + amc->spi_model = "mx66l1g45g"; | ||
303 | + amc->num_cs = 2; | ||
304 | + amc->i2c_init = witherspoon_bmc_i2c_init; | ||
305 | + mc->default_ram_size = 512 * MiB; | ||
306 | +}; | ||
307 | + | ||
308 | +static void aspeed_machine_ast2600_evb_class_init(ObjectClass *oc, void *data) | ||
309 | +{ | ||
310 | + MachineClass *mc = MACHINE_CLASS(oc); | ||
311 | + AspeedMachineClass *amc = ASPEED_MACHINE_CLASS(oc); | ||
312 | + | ||
313 | + mc->desc = "Aspeed AST2600 EVB (Cortex A7)"; | ||
314 | + amc->soc_name = "ast2600-a0"; | ||
315 | + amc->hw_strap1 = AST2600_EVB_HW_STRAP1; | ||
316 | + amc->hw_strap2 = AST2600_EVB_HW_STRAP2; | ||
317 | + amc->fmc_model = "w25q512jv"; | ||
318 | + amc->spi_model = "mx66u51235f"; | ||
319 | + amc->num_cs = 1; | ||
320 | + amc->i2c_init = ast2600_evb_i2c_init; | ||
321 | + mc->default_ram_size = 1 * GiB; | ||
322 | +}; | ||
323 | + | ||
324 | +static const TypeInfo aspeed_machine_types[] = { | ||
325 | + { | ||
326 | + .name = MACHINE_TYPE_NAME("palmetto-bmc"), | ||
327 | + .parent = TYPE_ASPEED_MACHINE, | ||
328 | + .class_init = aspeed_machine_palmetto_class_init, | ||
329 | + }, { | ||
330 | + .name = MACHINE_TYPE_NAME("ast2500-evb"), | ||
331 | + .parent = TYPE_ASPEED_MACHINE, | ||
332 | + .class_init = aspeed_machine_ast2500_evb_class_init, | ||
333 | + }, { | ||
334 | + .name = MACHINE_TYPE_NAME("romulus-bmc"), | ||
335 | + .parent = TYPE_ASPEED_MACHINE, | ||
336 | + .class_init = aspeed_machine_romulus_class_init, | ||
337 | + }, { | ||
338 | + .name = MACHINE_TYPE_NAME("swift-bmc"), | ||
339 | + .parent = TYPE_ASPEED_MACHINE, | ||
340 | + .class_init = aspeed_machine_swift_class_init, | ||
341 | + }, { | ||
342 | + .name = MACHINE_TYPE_NAME("witherspoon-bmc"), | ||
343 | + .parent = TYPE_ASPEED_MACHINE, | ||
344 | + .class_init = aspeed_machine_witherspoon_class_init, | ||
345 | + }, { | ||
346 | + .name = MACHINE_TYPE_NAME("ast2600-evb"), | ||
347 | + .parent = TYPE_ASPEED_MACHINE, | ||
348 | + .class_init = aspeed_machine_ast2600_evb_class_init, | ||
349 | + }, { | ||
350 | + .name = TYPE_ASPEED_MACHINE, | ||
351 | + .parent = TYPE_MACHINE, | ||
352 | + .instance_size = sizeof(AspeedMachine), | ||
353 | + .class_size = sizeof(AspeedMachineClass), | ||
354 | + .class_init = aspeed_machine_class_init, | ||
355 | + .abstract = true, | ||
356 | } | ||
357 | -} | ||
358 | +}; | ||
359 | |||
360 | -type_init(aspeed_machine_types) | ||
361 | +DEFINE_TYPES(aspeed_machine_types) | ||
362 | -- | ||
363 | 2.20.1 | ||
364 | |||
365 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Cédric Le Goater <clg@kaod.org> | ||
2 | 1 | ||
3 | The Tacoma BMC board is replacement board for the BMC of the OpenPOWER | ||
4 | Witherspoon system. It uses a AST2600 SoC instead of a AST2500 and the | ||
5 | I2C layout is the same as it controls the same main board. Used for HW | ||
6 | bringup. | ||
7 | |||
8 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
9 | Reviewed-by: Joel Stanley <joel@jms.id.au> | ||
10 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
11 | Message-id: 20191119141211.25716-15-clg@kaod.org | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | --- | ||
14 | hw/arm/aspeed.c | 28 ++++++++++++++++++++++++++++ | ||
15 | 1 file changed, 28 insertions(+) | ||
16 | |||
17 | diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/hw/arm/aspeed.c | ||
20 | +++ b/hw/arm/aspeed.c | ||
21 | @@ -XXX,XX +XXX,XX @@ struct AspeedBoardState { | ||
22 | #define AST2600_EVB_HW_STRAP1 0x000000C0 | ||
23 | #define AST2600_EVB_HW_STRAP2 0x00000003 | ||
24 | |||
25 | +/* Tacoma hardware value */ | ||
26 | +#define TACOMA_BMC_HW_STRAP1 0x00000000 | ||
27 | +#define TACOMA_BMC_HW_STRAP2 0x00000000 | ||
28 | + | ||
29 | /* | ||
30 | * The max ram region is for firmwares that scan the address space | ||
31 | * with load/store to guess how much RAM the SoC has. | ||
32 | @@ -XXX,XX +XXX,XX @@ static void witherspoon_bmc_i2c_init(AspeedBoardState *bmc) | ||
33 | AspeedSoCState *soc = &bmc->soc; | ||
34 | uint8_t *eeprom_buf = g_malloc0(8 * 1024); | ||
35 | |||
36 | + /* Bus 3: TODO bmp280@77 */ | ||
37 | + /* Bus 3: TODO max31785@52 */ | ||
38 | + /* Bus 3: TODO dps310@76 */ | ||
39 | i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 3), TYPE_PCA9552, | ||
40 | 0x60); | ||
41 | |||
42 | @@ -XXX,XX +XXX,XX @@ static void witherspoon_bmc_i2c_init(AspeedBoardState *bmc) | ||
43 | eeprom_buf); | ||
44 | i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 11), TYPE_PCA9552, | ||
45 | 0x60); | ||
46 | + /* Bus 11: TODO ucd90160@64 */ | ||
47 | } | ||
48 | |||
49 | static void aspeed_machine_class_init(ObjectClass *oc, void *data) | ||
50 | @@ -XXX,XX +XXX,XX @@ static void aspeed_machine_ast2600_evb_class_init(ObjectClass *oc, void *data) | ||
51 | mc->default_ram_size = 1 * GiB; | ||
52 | }; | ||
53 | |||
54 | +static void aspeed_machine_tacoma_class_init(ObjectClass *oc, void *data) | ||
55 | +{ | ||
56 | + MachineClass *mc = MACHINE_CLASS(oc); | ||
57 | + AspeedMachineClass *amc = ASPEED_MACHINE_CLASS(oc); | ||
58 | + | ||
59 | + mc->desc = "Aspeed AST2600 EVB (Cortex A7)"; | ||
60 | + amc->soc_name = "ast2600-a0"; | ||
61 | + amc->hw_strap1 = TACOMA_BMC_HW_STRAP1; | ||
62 | + amc->hw_strap2 = TACOMA_BMC_HW_STRAP2; | ||
63 | + amc->fmc_model = "mx66l1g45g"; | ||
64 | + amc->spi_model = "mx66l1g45g"; | ||
65 | + amc->num_cs = 2; | ||
66 | + amc->i2c_init = witherspoon_bmc_i2c_init; /* Same board layout */ | ||
67 | + mc->default_ram_size = 1 * GiB; | ||
68 | +}; | ||
69 | + | ||
70 | static const TypeInfo aspeed_machine_types[] = { | ||
71 | { | ||
72 | .name = MACHINE_TYPE_NAME("palmetto-bmc"), | ||
73 | @@ -XXX,XX +XXX,XX @@ static const TypeInfo aspeed_machine_types[] = { | ||
74 | .name = MACHINE_TYPE_NAME("ast2600-evb"), | ||
75 | .parent = TYPE_ASPEED_MACHINE, | ||
76 | .class_init = aspeed_machine_ast2600_evb_class_init, | ||
77 | + }, { | ||
78 | + .name = MACHINE_TYPE_NAME("tacoma-bmc"), | ||
79 | + .parent = TYPE_ASPEED_MACHINE, | ||
80 | + .class_init = aspeed_machine_tacoma_class_init, | ||
81 | }, { | ||
82 | .name = TYPE_ASPEED_MACHINE, | ||
83 | .parent = TYPE_MACHINE, | ||
84 | -- | ||
85 | 2.20.1 | ||
86 | |||
87 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: PanNengyuan <pannengyuan@huawei.com> | ||
2 | 1 | ||
3 | Address Sanitizer shows memory leak in hw/gpio/aspeed_gpio.c:875 | ||
4 | |||
5 | Reported-by: Euler Robot <euler.robot@huawei.com> | ||
6 | Signed-off-by: PanNengyuan <pannengyuan@huawei.com> | ||
7 | Reviewed-by: Cédric Le Goater <clg@kaod.org> | ||
8 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
9 | Message-id: 20191119141211.25716-16-clg@kaod.org | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | hw/gpio/aspeed_gpio.c | 1 + | ||
13 | 1 file changed, 1 insertion(+) | ||
14 | |||
15 | diff --git a/hw/gpio/aspeed_gpio.c b/hw/gpio/aspeed_gpio.c | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/hw/gpio/aspeed_gpio.c | ||
18 | +++ b/hw/gpio/aspeed_gpio.c | ||
19 | @@ -XXX,XX +XXX,XX @@ static void aspeed_gpio_init(Object *obj) | ||
20 | pin_idx % GPIOS_PER_GROUP); | ||
21 | object_property_add(obj, name, "bool", aspeed_gpio_get_pin, | ||
22 | aspeed_gpio_set_pin, NULL, NULL, NULL); | ||
23 | + g_free(name); | ||
24 | } | ||
25 | } | ||
26 | |||
27 | -- | ||
28 | 2.20.1 | ||
29 | |||
30 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Cédric Le Goater <clg@kaod.org> | ||
2 | 1 | ||
3 | The Aspeed MII model has a link pointing to its associated FTGMAC100 | ||
4 | NIC in the machine. | ||
5 | |||
6 | Change the "nic" property definition so that it explicitly sets the | ||
7 | pointer. The property isn't optional : not being able to set the link | ||
8 | is a bug and QEMU should rather abort than exit in this case. | ||
9 | |||
10 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
11 | Reviewed-by: Greg Kurz <groug@kaod.org> | ||
12 | Reviewed-by: Joel Stanley <joel@jms.id.au> | ||
13 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
14 | Message-id: 20191119141211.25716-18-clg@kaod.org | ||
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
16 | --- | ||
17 | hw/arm/aspeed_ast2600.c | 5 ++--- | ||
18 | hw/net/ftgmac100.c | 19 +++++++++---------- | ||
19 | 2 files changed, 11 insertions(+), 13 deletions(-) | ||
20 | |||
21 | diff --git a/hw/arm/aspeed_ast2600.c b/hw/arm/aspeed_ast2600.c | ||
22 | index XXXXXXX..XXXXXXX 100644 | ||
23 | --- a/hw/arm/aspeed_ast2600.c | ||
24 | +++ b/hw/arm/aspeed_ast2600.c | ||
25 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast2600_init(Object *obj) | ||
26 | |||
27 | sysbus_init_child_obj(obj, "mii[*]", &s->mii[i], sizeof(s->mii[i]), | ||
28 | TYPE_ASPEED_MII); | ||
29 | - object_property_add_const_link(OBJECT(&s->mii[i]), "nic", | ||
30 | - OBJECT(&s->ftgmac100[i]), | ||
31 | - &error_abort); | ||
32 | } | ||
33 | |||
34 | sysbus_init_child_obj(obj, "xdma", OBJECT(&s->xdma), sizeof(s->xdma), | ||
35 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp) | ||
36 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->ftgmac100[i]), 0, | ||
37 | aspeed_soc_get_irq(s, ASPEED_ETH1 + i)); | ||
38 | |||
39 | + object_property_set_link(OBJECT(&s->mii[i]), OBJECT(&s->ftgmac100[i]), | ||
40 | + "nic", &error_abort); | ||
41 | object_property_set_bool(OBJECT(&s->mii[i]), true, "realized", | ||
42 | &err); | ||
43 | if (err) { | ||
44 | diff --git a/hw/net/ftgmac100.c b/hw/net/ftgmac100.c | ||
45 | index XXXXXXX..XXXXXXX 100644 | ||
46 | --- a/hw/net/ftgmac100.c | ||
47 | +++ b/hw/net/ftgmac100.c | ||
48 | @@ -XXX,XX +XXX,XX @@ static void aspeed_mii_realize(DeviceState *dev, Error **errp) | ||
49 | { | ||
50 | AspeedMiiState *s = ASPEED_MII(dev); | ||
51 | SysBusDevice *sbd = SYS_BUS_DEVICE(dev); | ||
52 | - Object *obj; | ||
53 | - Error *local_err = NULL; | ||
54 | |||
55 | - obj = object_property_get_link(OBJECT(dev), "nic", &local_err); | ||
56 | - if (!obj) { | ||
57 | - error_propagate(errp, local_err); | ||
58 | - error_prepend(errp, "required link 'nic' not found: "); | ||
59 | - return; | ||
60 | - } | ||
61 | - | ||
62 | - s->nic = FTGMAC100(obj); | ||
63 | + assert(s->nic); | ||
64 | |||
65 | memory_region_init_io(&s->iomem, OBJECT(dev), &aspeed_mii_ops, s, | ||
66 | TYPE_ASPEED_MII, 0x8); | ||
67 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_aspeed_mii = { | ||
68 | VMSTATE_END_OF_LIST() | ||
69 | } | ||
70 | }; | ||
71 | + | ||
72 | +static Property aspeed_mii_properties[] = { | ||
73 | + DEFINE_PROP_LINK("nic", AspeedMiiState, nic, TYPE_FTGMAC100, | ||
74 | + FTGMAC100State *), | ||
75 | + DEFINE_PROP_END_OF_LIST(), | ||
76 | +}; | ||
77 | + | ||
78 | static void aspeed_mii_class_init(ObjectClass *klass, void *data) | ||
79 | { | ||
80 | DeviceClass *dc = DEVICE_CLASS(klass); | ||
81 | @@ -XXX,XX +XXX,XX @@ static void aspeed_mii_class_init(ObjectClass *klass, void *data) | ||
82 | dc->reset = aspeed_mii_reset; | ||
83 | dc->realize = aspeed_mii_realize; | ||
84 | dc->desc = "Aspeed MII controller"; | ||
85 | + dc->props = aspeed_mii_properties; | ||
86 | } | ||
87 | |||
88 | static const TypeInfo aspeed_mii_info = { | ||
89 | -- | ||
90 | 2.20.1 | ||
91 | |||
92 | diff view generated by jsdifflib |
1 | From: Heyi Guo <guoheyi@huawei.com> | 1 | From: Bin Meng <bin.meng@windriver.com> |
---|---|---|---|
2 | 2 | ||
3 | The last argument of AML bit and/or statement is the target variable, | 3 | Currently when U-Boot boots, it prints "??" for i.MX processor: |
4 | so we don't need to use a NULL target and then an additional store | ||
5 | operation; using just aml_and() or aml_or() statement is enough. | ||
6 | 4 | ||
7 | Also update tests/data/acpi/virt/DSDT* to pass "make check". | 5 | CPU: Freescale i.MX?? rev1.0 at 792 MHz |
8 | 6 | ||
9 | Cc: Shannon Zhao <shannon.zhaosl@gmail.com> | 7 | The register that was used to determine the silicon type is |
10 | Cc: Peter Maydell <peter.maydell@linaro.org> | 8 | undocumented in the latest IMX6DQRM (Rev. 6, 05/2020), but we |
11 | Cc: "Michael S. Tsirkin" <mst@redhat.com> | 9 | can refer to get_cpu_rev() in arch/arm/mach-imx/mx6/soc.c in |
12 | Cc: Igor Mammedov <imammedo@redhat.com> | 10 | the U-Boot source codes that USB_ANALOG_DIGPROG is used. |
13 | Suggested-by: Igor Mammedov <imammedo@redhat.com> | 11 | |
14 | Reviewed-by: Igor Mammedov <imammedo@redhat.com> | 12 | Update its reset value to indicate i.MX6Q. |
15 | Signed-off-by: Heyi Guo <guoheyi@huawei.com> | 13 | |
16 | Message-id: 20191209063719.23086-2-guoheyi@huawei.com | 14 | Signed-off-by: Bin Meng <bin.meng@windriver.com> |
15 | 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> | 17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
18 | --- | 18 | --- |
19 | hw/arm/virt-acpi-build.c | 16 ++++++++-------- | 19 | hw/misc/imx6_ccm.c | 2 +- |
20 | tests/data/acpi/virt/DSDT | Bin 18470 -> 18462 bytes | 20 | 1 file changed, 1 insertion(+), 1 deletion(-) |
21 | tests/data/acpi/virt/DSDT.memhp | Bin 19807 -> 19799 bytes | ||
22 | tests/data/acpi/virt/DSDT.numamem | Bin 18470 -> 18462 bytes | ||
23 | 4 files changed, 8 insertions(+), 8 deletions(-) | ||
24 | 21 | ||
25 | diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c | 22 | diff --git a/hw/misc/imx6_ccm.c b/hw/misc/imx6_ccm.c |
26 | index XXXXXXX..XXXXXXX 100644 | 23 | index XXXXXXX..XXXXXXX 100644 |
27 | --- a/hw/arm/virt-acpi-build.c | 24 | --- a/hw/misc/imx6_ccm.c |
28 | +++ b/hw/arm/virt-acpi-build.c | 25 | +++ b/hw/misc/imx6_ccm.c |
29 | @@ -XXX,XX +XXX,XX @@ static void acpi_dsdt_add_pci(Aml *scope, const MemMapEntry *memmap, | 26 | @@ -XXX,XX +XXX,XX @@ static void imx6_ccm_reset(DeviceState *dev) |
30 | aml_create_dword_field(aml_arg(3), aml_int(8), "CDW3")); | 27 | s->analog[USB_ANALOG_USB2_VBUS_DETECT] = 0x00000004; |
31 | aml_append(ifctx, aml_store(aml_name("CDW2"), aml_name("SUPP"))); | 28 | s->analog[USB_ANALOG_USB2_CHRG_DETECT] = 0x00000000; |
32 | aml_append(ifctx, aml_store(aml_name("CDW3"), aml_name("CTRL"))); | 29 | s->analog[USB_ANALOG_USB2_MISC] = 0x00000002; |
33 | - aml_append(ifctx, aml_store(aml_and(aml_name("CTRL"), aml_int(0x1D), NULL), | 30 | - s->analog[USB_ANALOG_DIGPROG] = 0x00000000; |
34 | - aml_name("CTRL"))); | 31 | + s->analog[USB_ANALOG_DIGPROG] = 0x00630000; |
35 | + aml_append(ifctx, aml_and(aml_name("CTRL"), aml_int(0x1D), | 32 | |
36 | + aml_name("CTRL"))); | 33 | /* all PLLs need to be locked */ |
37 | 34 | s->analog[CCM_ANALOG_PLL_ARM] |= CCM_ANALOG_PLL_LOCK; | |
38 | ifctx1 = aml_if(aml_lnot(aml_equal(aml_arg(1), aml_int(0x1)))); | ||
39 | - aml_append(ifctx1, aml_store(aml_or(aml_name("CDW1"), aml_int(0x08), NULL), | ||
40 | - aml_name("CDW1"))); | ||
41 | + aml_append(ifctx1, aml_or(aml_name("CDW1"), aml_int(0x08), | ||
42 | + aml_name("CDW1"))); | ||
43 | aml_append(ifctx, ifctx1); | ||
44 | |||
45 | ifctx1 = aml_if(aml_lnot(aml_equal(aml_name("CDW3"), aml_name("CTRL")))); | ||
46 | - aml_append(ifctx1, aml_store(aml_or(aml_name("CDW1"), aml_int(0x10), NULL), | ||
47 | - aml_name("CDW1"))); | ||
48 | + aml_append(ifctx1, aml_or(aml_name("CDW1"), aml_int(0x10), | ||
49 | + aml_name("CDW1"))); | ||
50 | aml_append(ifctx, ifctx1); | ||
51 | |||
52 | aml_append(ifctx, aml_store(aml_name("CTRL"), aml_name("CDW3"))); | ||
53 | @@ -XXX,XX +XXX,XX @@ static void acpi_dsdt_add_pci(Aml *scope, const MemMapEntry *memmap, | ||
54 | aml_append(method, ifctx); | ||
55 | |||
56 | elsectx = aml_else(); | ||
57 | - aml_append(elsectx, aml_store(aml_or(aml_name("CDW1"), aml_int(4), NULL), | ||
58 | - aml_name("CDW1"))); | ||
59 | + aml_append(elsectx, aml_or(aml_name("CDW1"), aml_int(4), | ||
60 | + aml_name("CDW1"))); | ||
61 | aml_append(elsectx, aml_return(aml_arg(3))); | ||
62 | aml_append(method, elsectx); | ||
63 | aml_append(dev, method); | ||
64 | diff --git a/tests/data/acpi/virt/DSDT b/tests/data/acpi/virt/DSDT | ||
65 | index XXXXXXX..XXXXXXX 100644 | ||
66 | GIT binary patch | ||
67 | delta 133 | ||
68 | zcmZ2BfpOjhMlP3Nmk>D*1_q|2iCof5o%I{lJ2{y;?{412x!p#<jWgaq*qNm(o59&7 | ||
69 | z+;D-%<VrV7_iE>mARjJS5V=5L(&S9WT970c2Uv;Nq{%?q7$gZ1761tsfcPNsCD{x4 | ||
70 | MAmS{W8QoPG0j8@bzW@LL | ||
71 | |||
72 | delta 141 | ||
73 | zcmbO?fpOUcMlP3Nmk>1%1_q`n6S<_B8XGpMcXBc{-rKy1bGwazA7{LOuro_nHiNTE | ||
74 | zxZwi7$(3%F{sq;}AwfP|vJ4<<fzYJMnT!RsAbBnhh%$*ulYv}gkTg_604z}e5&_99 | ||
75 | R$zCV`m0@An{L@X95dZ+BD!u>! | ||
76 | |||
77 | diff --git a/tests/data/acpi/virt/DSDT.memhp b/tests/data/acpi/virt/DSDT.memhp | ||
78 | index XXXXXXX..XXXXXXX 100644 | ||
79 | GIT binary patch | ||
80 | delta 132 | ||
81 | zcmcaVi}Cs_MlP3NmymE@1_ma@iCof*O&is^IGH-{Zr;SX-A2HTGu}VgnWZb6!PzC; | ||
82 | zaDm6<N;gaQYUhw3A1+xCxj<mj<V?m|kR%reSc%xA$w1l|Bnc4~00|d>_#p8m*$ep~ | ||
83 | L;w+mP-Q(B*s{AMU | ||
84 | |||
85 | delta 140 | ||
86 | zcmcaUi}C&}MlP3Nmymd01_maViCof*T^rT9IGGynZQjJW-A2HVGu}VgnWZb6!PzC; | ||
87 | zaDm_CN;gaYf@<fGARjJS1`xGCXwu|N#)4XqJQoK<nZ%^YK&~-J8Y&?GmM8#;fMk|r | ||
88 | QFBE{vurO@?=@!QZ00dYn_y7O^ | ||
89 | |||
90 | diff --git a/tests/data/acpi/virt/DSDT.numamem b/tests/data/acpi/virt/DSDT.numamem | ||
91 | index XXXXXXX..XXXXXXX 100644 | ||
92 | GIT binary patch | ||
93 | delta 133 | ||
94 | zcmZ2BfpOjhMlP3Nmk>D*1_q|2iCof5o%I{lJ2{y;?{412x!p#<jWgaq*qNm(o59&7 | ||
95 | z+;D-%<VrV7_iE>mARjJS5V=5L(&S9WT970c2Uv;Nq{%?q7$gZ1761tsfcPNsCD{x4 | ||
96 | MAmS{W8QoPG0j8@bzW@LL | ||
97 | |||
98 | delta 141 | ||
99 | zcmbO?fpOUcMlP3Nmk>1%1_q`n6S<_B8XGpMcXBc{-rKy1bGwazA7{LOuro_nHiNTE | ||
100 | zxZwi7$(3%F{sq;}AwfP|vJ4<<fzYJMnT!RsAbBnhh%$*ulYv}gkTg_604z}e5&_99 | ||
101 | R$zCV`m0@An{L@X95dZ+BD!u>! | ||
102 | |||
103 | -- | 35 | -- |
104 | 2.20.1 | 36 | 2.20.1 |
105 | 37 | ||
106 | 38 | diff view generated by jsdifflib |
1 | From: Beata Michalska <beata.michalska@linaro.org> | 1 | From: Bin Meng <bin.meng@windriver.com> |
---|---|---|---|
2 | 2 | ||
3 | Switch to ram block writeback for pmem migration. | 3 | At present, when booting U-Boot on QEMU sabrelite, we see: |
4 | 4 | ||
5 | Signed-off-by: Beata Michalska <beata.michalska@linaro.org> | 5 | Net: Board Net Initialization Failed |
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 6 | No ethernet found. |
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> | ||
7 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | 27 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> |
8 | Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com> | 28 | Message-id: 20210106063504.10841-4-bmeng.cn@gmail.com |
9 | Message-id: 20191121000843.24844-4-beata.michalska@linaro.org | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 29 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 30 | --- |
12 | migration/ram.c | 5 +---- | 31 | hw/arm/sabrelite.c | 4 ++++ |
13 | 1 file changed, 1 insertion(+), 4 deletions(-) | 32 | 1 file changed, 4 insertions(+) |
14 | 33 | ||
15 | diff --git a/migration/ram.c b/migration/ram.c | 34 | diff --git a/hw/arm/sabrelite.c b/hw/arm/sabrelite.c |
16 | index XXXXXXX..XXXXXXX 100644 | 35 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/migration/ram.c | 36 | --- a/hw/arm/sabrelite.c |
18 | +++ b/migration/ram.c | 37 | +++ b/hw/arm/sabrelite.c |
19 | @@ -XXX,XX +XXX,XX @@ | 38 | @@ -XXX,XX +XXX,XX @@ static void sabrelite_init(MachineState *machine) |
20 | #include "qemu/bitops.h" | 39 | |
21 | #include "qemu/bitmap.h" | 40 | s = FSL_IMX6(object_new(TYPE_FSL_IMX6)); |
22 | #include "qemu/main-loop.h" | 41 | object_property_add_child(OBJECT(machine), "soc", OBJECT(s)); |
23 | -#include "qemu/pmem.h" | 42 | + |
24 | #include "xbzrle.h" | 43 | + /* Ethernet PHY address is 6 */ |
25 | #include "ram.h" | 44 | + object_property_set_int(OBJECT(s), "fec-phy-num", 6, &error_fatal); |
26 | #include "migration.h" | 45 | + |
27 | @@ -XXX,XX +XXX,XX @@ static int ram_load_cleanup(void *opaque) | 46 | qdev_realize(DEVICE(s), NULL, &error_fatal); |
28 | RAMBlock *rb; | 47 | |
29 | 48 | memory_region_add_subregion(get_system_memory(), FSL_IMX6_MMDC_ADDR, | |
30 | RAMBLOCK_FOREACH_NOT_IGNORED(rb) { | ||
31 | - if (ramblock_is_pmem(rb)) { | ||
32 | - pmem_persist(rb->host, rb->used_length); | ||
33 | - } | ||
34 | + qemu_ram_block_writeback(rb); | ||
35 | } | ||
36 | |||
37 | xbzrle_load_cleanup(); | ||
38 | -- | 49 | -- |
39 | 2.20.1 | 50 | 2.20.1 |
40 | 51 | ||
41 | 52 | diff view generated by jsdifflib |
1 | From: Niek Linnenbank <nieklinnenbank@gmail.com> | 1 | From: Bin Meng <bin.meng@windriver.com> |
---|---|---|---|
2 | 2 | ||
3 | This change ensures that the FPU can be accessed in Non-Secure mode | 3 | This adds the target guide for SABRE Lite board, and documents how |
4 | when the CPU core is reset using the arm_set_cpu_on() function call. | 4 | to boot a Linux kernel and U-Boot bootloader. |
5 | The NSACR.{CP11,CP10} bits define the exception level required to | ||
6 | access the FPU in Non-Secure mode. Without these bits set, the CPU | ||
7 | will give an undefined exception trap on the first FPU access for the | ||
8 | secondary cores under Linux. | ||
9 | 5 | ||
10 | This is necessary because in this power-control codepath QEMU | 6 | Signed-off-by: Bin Meng <bin.meng@windriver.com> |
11 | is effectively emulating a bit of EL3 firmware, and has to set | 7 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> |
12 | the CPU up as the EL3 firmware would. | 8 | Message-id: 20210106063504.10841-5-bmeng.cn@gmail.com |
13 | |||
14 | Fixes: fc1120a7f5 | ||
15 | Cc: qemu-stable@nongnu.org | ||
16 | Signed-off-by: Niek Linnenbank <nieklinnenbank@gmail.com> | ||
17 | [PMM: added clarifying para to commit message] | ||
18 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
19 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
20 | --- | 10 | --- |
21 | target/arm/arm-powerctl.c | 3 +++ | 11 | docs/system/arm/sabrelite.rst | 119 ++++++++++++++++++++++++++++++++++ |
22 | 1 file changed, 3 insertions(+) | 12 | docs/system/target-arm.rst | 1 + |
13 | 2 files changed, 120 insertions(+) | ||
14 | create mode 100644 docs/system/arm/sabrelite.rst | ||
23 | 15 | ||
24 | diff --git a/target/arm/arm-powerctl.c b/target/arm/arm-powerctl.c | 16 | diff --git a/docs/system/arm/sabrelite.rst b/docs/system/arm/sabrelite.rst |
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 | ||
25 | index XXXXXXX..XXXXXXX 100644 | 142 | index XXXXXXX..XXXXXXX 100644 |
26 | --- a/target/arm/arm-powerctl.c | 143 | --- a/docs/system/target-arm.rst |
27 | +++ b/target/arm/arm-powerctl.c | 144 | +++ b/docs/system/target-arm.rst |
28 | @@ -XXX,XX +XXX,XX @@ static void arm_set_cpu_on_async_work(CPUState *target_cpu_state, | 145 | @@ -XXX,XX +XXX,XX @@ undocumented; you can get a complete list by running |
29 | /* Processor is not in secure mode */ | 146 | arm/versatile |
30 | target_cpu->env.cp15.scr_el3 |= SCR_NS; | 147 | arm/vexpress |
31 | 148 | arm/aspeed | |
32 | + /* Set NSACR.{CP11,CP10} so NS can access the FPU */ | 149 | + arm/sabrelite |
33 | + target_cpu->env.cp15.nsacr |= 3 << 10; | 150 | arm/digic |
34 | + | 151 | arm/musicpal |
35 | /* | 152 | arm/gumstix |
36 | * If QEMU is providing the equivalent of EL3 firmware, then we need | ||
37 | * to make sure a CPU targeting EL2 comes out of reset with a | ||
38 | -- | 153 | -- |
39 | 2.20.1 | 154 | 2.20.1 |
40 | 155 | ||
41 | 156 | diff view generated by jsdifflib |