1
ARM queue, various patches accumulated over the Christmas break.
1
Nothing too exciting, but does include the last bits of v8.1M support work.
2
2
3
-- PMM
3
-- PMM
4
4
5
The following changes since commit 612061b277915fadd80631eb7a6926f48a110c44:
5
The following changes since commit e79de63ab1bd1f6550e7b915e433bec1ad1a870a:
6
6
7
Merge remote-tracking branch 'remotes/ericb/tags/pull-nbd-2018-01-10' into staging (2018-01-11 11:52:40 +0000)
7
Merge remote-tracking branch 'remotes/rth-gitlab/tags/pull-tcg-20210107' into staging (2021-01-07 20:34:05 +0000)
8
8
9
are available in the git repository at:
9
are available in the Git repository at:
10
10
11
git://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20180111
11
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20210108
12
12
13
for you to fetch changes up to 0cf09852015e47a5fbb974ff7ac320366afd21ee:
13
for you to fetch changes up to c9f8511ea8d2b80723af0fea1f716d752c1b5208:
14
14
15
hw/intc/arm_gic: reserved register addresses are RAZ/WI (2018-01-11 13:25:40 +0000)
15
docs/system: arm: Add sabrelite board description (2021-01-08 15:13:39 +0000)
16
16
17
----------------------------------------------------------------
17
----------------------------------------------------------------
18
target-arm queue:
18
target-arm queue:
19
* add aarch64_be linux-user target
19
* intc/arm_gic: Fix gic_irq_signaling_enabled() for vCPUs
20
* Virt: ACPI: fix qemu assert due to re-assigned table data address
20
* target/arm: Fix MTE0_ACTIVE
21
* imx_fec: various bug fixes and cleanups
21
* target/arm: Implement v8.1M and Cortex-M55 model
22
* hw/timer/pxa2xx_timer: replace hw_error() -> qemu_log_mask()
22
* hw/arm/highbank: Drop dead KVM support code
23
* hw/sd/pxa2xx_mmci: add read/write() trace events
23
* util/qemu-timer: Make timer_free() imply timer_del()
24
* linux-user/arm/nwfpe: Check coprocessor number for FPA emulation
24
* various devices: Use ptimer_free() in finalize function
25
* target/arm: Make disas_thumb2_insn() generate its own UNDEF exceptions
25
* docs/system: arm: Add sabrelite board description
26
* hw/intc/arm_gicv3: Make reserved register addresses RAZ/WI
26
* sabrelite: Minor fixes to allow booting U-Boot
27
* hw/intc/arm_gic: reserved register addresses are RAZ/WI
28
27
29
----------------------------------------------------------------
28
----------------------------------------------------------------
30
Andrey Smirnov (11):
29
Andrew Jones (1):
31
imx_fec: Do not link to netdev
30
hw/arm/virt: Remove virt machine state 'smp_cpus'
32
imx_fec: Refactor imx_eth_enable_rx()
33
imx_fec: Change queue flushing heuristics
34
imx_fec: Move Tx frame buffer away from the stack
35
imx_fec: Use ENET_FTRL to determine truncation length
36
imx_fec: Use MIN instead of explicit ternary operator
37
imx_fec: Emulate SHIFT16 in ENETx_RACC
38
imx_fec: Add support for multiple Tx DMA rings
39
imx_fec: Use correct length for packet size
40
imx_fec: Fix a typo in imx_enet_receive()
41
imx_fec: Reserve full FSL_IMX25_FEC_SIZE page for the register file
42
31
43
Michael Weiser (8):
32
Bin Meng (4):
44
linux-user: Add support for big-endian aarch64
33
hw/misc: imx6_ccm: Update PMU_MISC0 reset value
45
linux-user: Add separate aarch64_be uname
34
hw/msic: imx6_ccm: Correct register value for silicon type
46
linux-user: Fix endianess of aarch64 signal trampoline
35
hw/arm: sabrelite: Connect the Ethernet PHY at address 6
47
configure: Add aarch64_be-linux-user target
36
docs/system: arm: Add sabrelite board description
48
linux-user: Add aarch64_be magic numbers to qemu-binfmt-conf.sh
49
linux-user: Separate binfmt arm CPU families
50
linux-user: Activate armeb handler registration
51
target/arm: Fix stlxp for aarch64_be
52
37
53
Peter Maydell (4):
38
Edgar E. Iglesias (1):
54
linux-user/arm/nwfpe: Check coprocessor number for FPA emulation
39
intc/arm_gic: Fix gic_irq_signaling_enabled() for vCPUs
55
target/arm: Make disas_thumb2_insn() generate its own UNDEF exceptions
56
hw/intc/arm_gicv3: Make reserved register addresses RAZ/WI
57
hw/intc/arm_gic: reserved register addresses are RAZ/WI
58
40
59
Philippe Mathieu-Daudé (2):
41
Gan Qixin (7):
60
hw/timer/pxa2xx_timer: replace hw_error() -> qemu_log_mask()
42
digic-timer: Use ptimer_free() in the finalize function to avoid memleaks
61
hw/sd/pxa2xx_mmci: add read/write() trace events
43
allwinner-a10-pit: Use ptimer_free() in the finalize function to avoid memleaks
44
exynos4210_rtc: Use ptimer_free() in the finalize function to avoid memleaks
45
exynos4210_pwm: Use ptimer_free() in the finalize function to avoid memleaks
46
mss-timer: Use ptimer_free() in the finalize function to avoid memleaks
47
musicpal: Use ptimer_free() in the finalize function to avoid memleaks
48
exynos4210_mct: Use ptimer_free() in the finalize function to avoid memleaks
62
49
63
Zhaoshenglong (1):
50
Peter Maydell (9):
64
Virt: ACPI: fix qemu assert due to re-assigned table data address
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()
65
60
66
configure | 5 +-
61
Richard Henderson (1):
67
include/hw/arm/fsl-imx25.h | 1 -
62
target/arm: Fix MTE0_ACTIVE
68
include/hw/net/imx_fec.h | 27 +++-
69
linux-user/aarch64/target_syscall.h | 4 +
70
hw/arm/fsl-imx6.c | 1 +
71
hw/arm/virt-acpi-build.c | 18 ++-
72
hw/intc/arm_gic.c | 5 +-
73
hw/intc/arm_gicv3_dist.c | 13 ++
74
hw/intc/arm_gicv3_its_common.c | 8 +-
75
hw/intc/arm_gicv3_redist.c | 13 ++
76
hw/net/imx_fec.c | 210 +++++++++++++++++++++++-------
77
hw/sd/pxa2xx_mmci.c | 78 +++++++----
78
hw/timer/pxa2xx_timer.c | 17 ++-
79
linux-user/arm/nwfpe/fpa11.c | 9 ++
80
linux-user/main.c | 6 +
81
linux-user/signal.c | 10 +-
82
target/arm/helper-a64.c | 7 +-
83
target/arm/translate.c | 23 ++--
84
default-configs/aarch64_be-linux-user.mak | 1 +
85
hw/sd/trace-events | 4 +
86
scripts/qemu-binfmt-conf.sh | 15 ++-
87
21 files changed, 356 insertions(+), 119 deletions(-)
88
create mode 100644 default-configs/aarch64_be-linux-user.mak
89
63
64
docs/system/arm/sabrelite.rst | 119 ++++++++++++++++++++++++++
65
docs/system/target-arm.rst | 1 +
66
scripts/coccinelle/timer-del-timer-free.cocci | 18 ++++
67
include/hw/arm/virt.h | 3 +-
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
132
diff view generated by jsdifflib
Deleted patch
1
From: Michael Weiser <michael.weiser@gmx.de>
2
1
3
Enable big-endian mode for data accesses on aarch64 for big-endian linux
4
user mode. Activate it for all exception levels as documented by ARM:
5
Set the SCTLR EE bit for ELs 1 through 3. Additionally set bit E0E in
6
EL1 to enable it in EL0 as well.
7
8
Signed-off-by: Michael Weiser <michael.weiser@gmx.de>
9
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
10
Message-id: 20171220212308.12614-2-michael.weiser@gmx.de
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
---
13
linux-user/main.c | 6 ++++++
14
1 file changed, 6 insertions(+)
15
16
diff --git a/linux-user/main.c b/linux-user/main.c
17
index XXXXXXX..XXXXXXX 100644
18
--- a/linux-user/main.c
19
+++ b/linux-user/main.c
20
@@ -XXX,XX +XXX,XX @@ int main(int argc, char **argv, char **envp)
21
}
22
env->pc = regs->pc;
23
env->xregs[31] = regs->sp;
24
+#ifdef TARGET_WORDS_BIGENDIAN
25
+ env->cp15.sctlr_el[1] |= SCTLR_E0E;
26
+ for (i = 1; i < 4; ++i) {
27
+ env->cp15.sctlr_el[i] |= SCTLR_EE;
28
+ }
29
+#endif
30
}
31
#elif defined(TARGET_ARM)
32
{
33
--
34
2.7.4
35
36
diff view generated by jsdifflib
1
The GICv2 specification says that reserved register addresses
1
From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com>
2
must RAZ/WI; now that we implement external abort handling
3
for Arm CPUs this means we must return MEMTX_OK rather than
4
MEMTX_ERROR, to avoid generating a spurious guest data abort.
5
2
6
Cc: qemu-stable@nongnu.org
3
Correct the indexing into s->cpu_ctlr for vCPUs.
4
5
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
6
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
7
Reviewed-by: Luc Michel <luc.michel@greensocs.com>
8
Message-id: 20201214222154.3480243-2-edgar.iglesias@gmail.com
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Message-id: 1513183941-24300-3-git-send-email-peter.maydell@linaro.org
9
Reviewed-by: Alistair Francis <alistair.francis@xilinx.com>
10
---
10
---
11
hw/intc/arm_gic.c | 5 +++--
11
hw/intc/arm_gic.c | 4 +++-
12
1 file changed, 3 insertions(+), 2 deletions(-)
12
1 file changed, 3 insertions(+), 1 deletion(-)
13
13
14
diff --git a/hw/intc/arm_gic.c b/hw/intc/arm_gic.c
14
diff --git a/hw/intc/arm_gic.c b/hw/intc/arm_gic.c
15
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
16
--- a/hw/intc/arm_gic.c
16
--- a/hw/intc/arm_gic.c
17
+++ b/hw/intc/arm_gic.c
17
+++ b/hw/intc/arm_gic.c
18
@@ -XXX,XX +XXX,XX @@ static MemTxResult gic_cpu_read(GICState *s, int cpu, int offset,
18
@@ -XXX,XX +XXX,XX @@ static inline void gic_get_best_virq(GICState *s, int cpu,
19
default:
19
static inline bool gic_irq_signaling_enabled(GICState *s, int cpu, bool virt,
20
qemu_log_mask(LOG_GUEST_ERROR,
20
int group_mask)
21
"gic_cpu_read: Bad offset %x\n", (int)offset);
21
{
22
- return MEMTX_ERROR;
22
+ int cpu_iface = virt ? (cpu + GIC_NCPU) : cpu;
23
+ *data = 0;
23
+
24
+ break;
24
if (!virt && !(s->ctlr & group_mask)) {
25
return false;
25
}
26
}
26
return MEMTX_OK;
27
@@ -XXX,XX +XXX,XX @@ static inline bool gic_irq_signaling_enabled(GICState *s, int cpu, bool virt,
27
}
28
return false;
28
@@ -XXX,XX +XXX,XX @@ static MemTxResult gic_cpu_write(GICState *s, int cpu, int offset,
29
default:
30
qemu_log_mask(LOG_GUEST_ERROR,
31
"gic_cpu_write: Bad offset %x\n", (int)offset);
32
- return MEMTX_ERROR;
33
+ return MEMTX_OK;
34
}
29
}
35
gic_update(s);
30
36
return MEMTX_OK;
31
- if (!(s->cpu_ctlr[cpu] & group_mask)) {
32
+ if (!(s->cpu_ctlr[cpu_iface] & group_mask)) {
33
return false;
34
}
35
37
--
36
--
38
2.7.4
37
2.20.1
39
38
40
39
diff view generated by jsdifflib
1
From: Zhaoshenglong <zhaoshenglong@huawei.com>
1
From: Andrew Jones <drjones@redhat.com>
2
2
3
acpi_data_push uses g_array_set_size to resize the memory size. If there
3
virt machine's 'smp_cpus' and machine->smp.cpus must always have the
4
is no enough contiguous memory, the address will be changed. If we use
4
same value. And, anywhere we have virt machine state we have machine
5
the old value, it will assert.
5
state. So let's remove the redundancy. Also, to make it easier to see
6
qemu-kvm: hw/acpi/bios-linker-loader.c:214: bios_linker_loader_add_checksum:
6
that machine->smp is the true source for "smp_cpus" and "max_cpus",
7
Assertion `start_offset < file->blob->len' failed.`
7
avoid passing them in function parameters, preferring instead to get
8
them from the state.
8
9
9
This issue only happens in building SRAT table now but here we unify the
10
No functional change intended.
10
pattern for other tables as well to avoid possible issues in the future.
11
11
12
Signed-off-by: Zhaoshenglong <zhaoshenglong@huawei.com>
12
Signed-off-by: Andrew Jones <drjones@redhat.com>
13
Reviewed-by: Andrew Jones <drjones@redhat.com>
13
Reviewed-by: David Edmondson <david.edmondson@oracle.com>
14
Reviewed-by: Ying Fang <fangying1@huawei.com>
15
Message-id: 20201215174815.51520-1-drjones@redhat.com
16
[PMM: minor formatting tweak to smp_cpus variable declaration]
14
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
17
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
15
---
18
---
16
hw/arm/virt-acpi-build.c | 18 +++++++++++-------
19
include/hw/arm/virt.h | 3 +--
17
1 file changed, 11 insertions(+), 7 deletions(-)
20
hw/arm/virt-acpi-build.c | 9 +++++----
21
hw/arm/virt.c | 21 ++++++++++-----------
22
3 files changed, 16 insertions(+), 17 deletions(-)
18
23
24
diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h
25
index XXXXXXX..XXXXXXX 100644
26
--- a/include/hw/arm/virt.h
27
+++ b/include/hw/arm/virt.h
28
@@ -XXX,XX +XXX,XX @@ struct VirtMachineState {
29
MemMapEntry *memmap;
30
char *pciehb_nodename;
31
const int *irqmap;
32
- int smp_cpus;
33
void *fdt;
34
int fdt_size;
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 */
19
diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
45
diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
20
index XXXXXXX..XXXXXXX 100644
46
index XXXXXXX..XXXXXXX 100644
21
--- a/hw/arm/virt-acpi-build.c
47
--- a/hw/arm/virt-acpi-build.c
22
+++ b/hw/arm/virt-acpi-build.c
48
+++ b/hw/arm/virt-acpi-build.c
23
@@ -XXX,XX +XXX,XX @@ build_spcr(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
49
@@ -XXX,XX +XXX,XX @@
24
AcpiSerialPortConsoleRedirection *spcr;
50
25
const MemMapEntry *uart_memmap = &vms->memmap[VIRT_UART];
51
#define ACPI_BUILD_TABLE_SIZE 0x20000
26
int irq = vms->irqmap[VIRT_UART] + ARM_SPI_BASE;
52
27
+ int spcr_start = table_data->len;
53
-static void acpi_dsdt_add_cpus(Aml *scope, int smp_cpus)
28
54
+static void acpi_dsdt_add_cpus(Aml *scope, VirtMachineState *vms)
29
spcr = acpi_data_push(table_data, sizeof(*spcr));
55
{
30
56
+ MachineState *ms = MACHINE(vms);
31
@@ -XXX,XX +XXX,XX @@ build_spcr(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
57
uint16_t i;
32
spcr->pci_device_id = 0xffff; /* PCI Device ID: not a PCI device */
58
33
spcr->pci_vendor_id = 0xffff; /* PCI Vendor ID: not a PCI device */
59
- for (i = 0; i < smp_cpus; i++) {
34
60
+ for (i = 0; i < ms->smp.cpus; i++) {
35
- build_header(linker, table_data, (void *)spcr, "SPCR", sizeof(*spcr), 2,
61
Aml *dev = aml_device("C%.03X", i);
36
- NULL, NULL);
62
aml_append(dev, aml_name_decl("_HID", aml_string("ACPI0007")));
37
+ build_header(linker, table_data, (void *)(table_data->data + spcr_start),
63
aml_append(dev, aml_name_decl("_UID", aml_int(i)));
38
+ "SPCR", table_data->len - spcr_start, 2, NULL, NULL);
64
@@ -XXX,XX +XXX,XX @@ build_madt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
39
}
65
gicd->base_address = cpu_to_le64(memmap[VIRT_GIC_DIST].base);
40
66
gicd->version = vms->gic_version;
41
static void
67
42
@@ -XXX,XX +XXX,XX @@ build_srat(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
68
- for (i = 0; i < vms->smp_cpus; i++) {
43
mem_base += numa_info[i].node_mem;
69
+ for (i = 0; i < MACHINE(vms)->smp.cpus; i++) {
70
AcpiMadtGenericCpuInterface *gicc = acpi_data_push(table_data,
71
sizeof(*gicc));
72
ARMCPU *armcpu = ARM_CPU(qemu_get_cpu(i));
73
@@ -XXX,XX +XXX,XX @@ build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
74
* the RTC ACPI device at all when using UEFI.
75
*/
76
scope = aml_scope("\\_SB");
77
- acpi_dsdt_add_cpus(scope, vms->smp_cpus);
78
+ acpi_dsdt_add_cpus(scope, vms);
79
acpi_dsdt_add_uart(scope, &memmap[VIRT_UART],
80
(irqmap[VIRT_UART] + ARM_SPI_BASE));
81
if (vmc->acpi_expose_flash) {
82
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
83
index XXXXXXX..XXXXXXX 100644
84
--- a/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);
44
}
92
}
45
93
46
- build_header(linker, table_data, (void *)srat, "SRAT",
94
qemu_fdt_add_subnode(vms->fdt, "/timer");
47
- table_data->len - srat_start, 3, NULL, NULL);
95
@@ -XXX,XX +XXX,XX @@ static void fdt_add_cpu_nodes(const VirtMachineState *vms)
48
+ build_header(linker, table_data, (void *)(table_data->data + srat_start),
96
int cpu;
49
+ "SRAT", table_data->len - srat_start, 3, NULL, NULL);
97
int addr_cells = 1;
50
}
98
const MachineState *ms = MACHINE(vms);
51
99
+ int smp_cpus = ms->smp.cpus;
52
static void
100
53
@@ -XXX,XX +XXX,XX @@ build_mcfg(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
101
/*
54
AcpiTableMcfg *mcfg;
102
* From Documentation/devicetree/bindings/arm/cpus.txt
55
const MemMapEntry *memmap = vms->memmap;
103
@@ -XXX,XX +XXX,XX @@ static void fdt_add_cpu_nodes(const VirtMachineState *vms)
56
int len = sizeof(*mcfg) + sizeof(mcfg->allocation[0]);
104
* The simplest way to go is to examine affinity IDs of all our CPUs. If
57
+ int mcfg_start = table_data->len;
105
* at least one of them has Aff3 populated, we set #address-cells to 2.
58
106
*/
59
mcfg = acpi_data_push(table_data, len);
107
- for (cpu = 0; cpu < vms->smp_cpus; cpu++) {
60
mcfg->allocation[0].address = cpu_to_le64(memmap[VIRT_PCIE_ECAM].base);
108
+ for (cpu = 0; cpu < smp_cpus; cpu++) {
61
@@ -XXX,XX +XXX,XX @@ build_mcfg(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
109
ARMCPU *armcpu = ARM_CPU(qemu_get_cpu(cpu));
62
mcfg->allocation[0].end_bus_number = (memmap[VIRT_PCIE_ECAM].size
110
63
/ PCIE_MMCFG_SIZE_MIN) - 1;
111
if (armcpu->mp_affinity & ARM_AFF3_MASK) {
64
112
@@ -XXX,XX +XXX,XX @@ static void fdt_add_cpu_nodes(const VirtMachineState *vms)
65
- build_header(linker, table_data, (void *)mcfg, "MCFG", len, 1, NULL, NULL);
113
qemu_fdt_setprop_cell(vms->fdt, "/cpus", "#address-cells", addr_cells);
66
+ build_header(linker, table_data, (void *)(table_data->data + mcfg_start),
114
qemu_fdt_setprop_cell(vms->fdt, "/cpus", "#size-cells", 0x0);
67
+ "MCFG", table_data->len - mcfg_start, 1, NULL, NULL);
115
68
}
116
- for (cpu = vms->smp_cpus - 1; cpu >= 0; cpu--) {
69
117
+ for (cpu = smp_cpus - 1; cpu >= 0; cpu--) {
70
/* GTDT */
118
char *nodename = g_strdup_printf("/cpus/cpu@%d", cpu);
71
@@ -XXX,XX +XXX,XX @@ build_madt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
119
ARMCPU *armcpu = ARM_CPU(qemu_get_cpu(cpu));
72
static void build_fadt(GArray *table_data, BIOSLinker *linker,
120
CPUState *cs = CPU(armcpu);
73
VirtMachineState *vms, unsigned dsdt_tbl_offset)
121
@@ -XXX,XX +XXX,XX @@ static void fdt_add_cpu_nodes(const VirtMachineState *vms)
122
qemu_fdt_setprop_string(vms->fdt, nodename, "compatible",
123
armcpu->dtb_compatible);
124
125
- if (vms->psci_conduit != QEMU_PSCI_CONDUIT_DISABLED
126
- && vms->smp_cpus > 1) {
127
+ if (vms->psci_conduit != QEMU_PSCI_CONDUIT_DISABLED && smp_cpus > 1) {
128
qemu_fdt_setprop_string(vms->fdt, nodename,
129
"enable-method", "psci");
130
}
131
@@ -XXX,XX +XXX,XX @@ static void fdt_add_pmu_nodes(const VirtMachineState *vms)
132
if (vms->gic_version == VIRT_GIC_VERSION_2) {
133
irqflags = deposit32(irqflags, GIC_FDT_IRQ_PPI_CPU_START,
134
GIC_FDT_IRQ_PPI_CPU_WIDTH,
135
- (1 << vms->smp_cpus) - 1);
136
+ (1 << MACHINE(vms)->smp.cpus) - 1);
137
}
138
139
qemu_fdt_add_subnode(vms->fdt, "/pmu");
140
@@ -XXX,XX +XXX,XX @@ static void finalize_gic_version(VirtMachineState *vms)
141
* virt_cpu_post_init() must be called after the CPUs have
142
* been realized and the GIC has been created.
143
*/
144
-static void virt_cpu_post_init(VirtMachineState *vms, int max_cpus,
145
- MemoryRegion *sysmem)
146
+static void virt_cpu_post_init(VirtMachineState *vms, MemoryRegion *sysmem)
74
{
147
{
75
+ int fadt_start = table_data->len;
148
+ int max_cpus = MACHINE(vms)->smp.max_cpus;
76
AcpiFadtDescriptorRev5_1 *fadt = acpi_data_push(table_data, sizeof(*fadt));
149
bool aarch64, pmu, steal_time;
77
unsigned xdsdt_entry_offset = (char *)&fadt->x_dsdt - table_data->data;
150
CPUState *cpu;
78
uint16_t bootflags;
151
79
@@ -XXX,XX +XXX,XX @@ static void build_fadt(GArray *table_data, BIOSLinker *linker,
152
@@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine)
80
ACPI_BUILD_TABLE_FILE, xdsdt_entry_offset, sizeof(fadt->x_dsdt),
153
exit(1);
81
ACPI_BUILD_TABLE_FILE, dsdt_tbl_offset);
154
}
82
155
83
- build_header(linker, table_data,
156
- vms->smp_cpus = smp_cpus;
84
- (void *)fadt, "FACP", sizeof(*fadt), 5, NULL, NULL);
157
-
85
+ build_header(linker, table_data, (void *)(table_data->data + fadt_start),
158
if (vms->virt && kvm_enabled()) {
86
+ "FACP", table_data->len - fadt_start, 5, NULL, NULL);
159
error_report("mach-virt: KVM does not support providing "
87
}
160
"Virtualization extensions to the guest CPU");
88
161
@@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine)
89
/* DSDT */
162
create_fdt(vms);
163
164
possible_cpus = mc->possible_cpu_arch_ids(machine);
165
+ assert(possible_cpus->len == max_cpus);
166
for (n = 0; n < possible_cpus->len; n++) {
167
Object *cpuobj;
168
CPUState *cs;
169
@@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine)
170
171
create_gic(vms);
172
173
- virt_cpu_post_init(vms, possible_cpus->len, sysmem);
174
+ virt_cpu_post_init(vms, sysmem);
175
176
fdt_add_pmu_nodes(vms);
177
90
--
178
--
91
2.7.4
179
2.20.1
92
180
93
181
diff view generated by jsdifflib
1
From: Andrey Smirnov <andrew.smirnov@gmail.com>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
Cc: Peter Maydell <peter.maydell@linaro.org>
3
In 50244cc76abc we updated mte_check_fail to match the ARM
4
Cc: Jason Wang <jasowang@redhat.com>
4
pseudocode, using the correct EL to select the TCF field.
5
Cc: Philippe Mathieu-Daudé <f4bug@amsat.org>
5
But we failed to update MTE0_ACTIVE the same way, which led
6
Cc: qemu-devel@nongnu.org
6
to g_assert_not_reached().
7
Cc: qemu-arm@nongnu.org
7
8
Cc: yurovsky@gmail.com
8
Cc: qemu-stable@nongnu.org
9
Buglink: https://bugs.launchpad.net/bugs/1907137
10
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11
Message-id: 20201221204426.88514-1-richard.henderson@linaro.org
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
12
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
---
14
---
13
hw/net/imx_fec.c | 2 +-
15
target/arm/helper.c | 2 +-
14
1 file changed, 1 insertion(+), 1 deletion(-)
16
1 file changed, 1 insertion(+), 1 deletion(-)
15
17
16
diff --git a/hw/net/imx_fec.c b/hw/net/imx_fec.c
18
diff --git a/target/arm/helper.c b/target/arm/helper.c
17
index XXXXXXX..XXXXXXX 100644
19
index XXXXXXX..XXXXXXX 100644
18
--- a/hw/net/imx_fec.c
20
--- a/target/arm/helper.c
19
+++ b/hw/net/imx_fec.c
21
+++ b/target/arm/helper.c
20
@@ -XXX,XX +XXX,XX @@ static ssize_t imx_enet_receive(NetClientState *nc, const uint8_t *buf,
22
@@ -XXX,XX +XXX,XX @@ static uint32_t rebuild_hflags_a64(CPUARMState *env, int el, int fp_el,
21
size += 2;
23
if (FIELD_EX32(flags, TBFLAG_A64, UNPRIV)
22
}
24
&& tbid
23
25
&& !(env->pstate & PSTATE_TCO)
24
- /* Huge frames are truncted. */
26
- && (sctlr & SCTLR_TCF0)
25
+ /* Huge frames are truncated. */
27
+ && (sctlr & SCTLR_TCF)
26
if (size > s->regs[ENET_FTRL]) {
28
&& allocation_tag_access_enabled(env, 0, sctlr)) {
27
size = s->regs[ENET_FTRL];
29
flags = FIELD_DP32(flags, TBFLAG_A64, MTE0_ACTIVE, 1);
28
flags |= ENET_BD_TR | ENET_BD_LG;
30
}
29
--
31
--
30
2.7.4
32
2.20.1
31
33
32
34
diff view generated by jsdifflib
1
The GICv3 specification says that reserved register addresses
1
The CCR is a register most of whose bits are banked between security
2
should RAZ/WI. This means we need to return MEMTX_OK, not MEMTX_ERROR,
2
states but where BFHFNMIGN is not, and we keep it in the non-secure
3
because now that we support generating external aborts the
3
entry of the v7m.ccr[] array. The logic which tries to handle this
4
latter will cause an abort on new board models.
4
bit fails to implement the "RAZ/WI from Nonsecure if AIRCR.BFHFNMINS
5
is zero" requirement; correct the omission.
5
6
6
Cc: qemu-stable@nongnu.org
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Message-id: 1513183941-24300-2-git-send-email-peter.maydell@linaro.org
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Reviewed-by: Alistair Francis <alistair.francis@xilinx.com>
9
Message-id: 20201210201433.26262-2-peter.maydell@linaro.org
10
---
10
---
11
hw/intc/arm_gicv3_dist.c | 13 +++++++++++++
11
hw/intc/armv7m_nvic.c | 15 +++++++++++++++
12
hw/intc/arm_gicv3_its_common.c | 8 +++-----
12
1 file changed, 15 insertions(+)
13
hw/intc/arm_gicv3_redist.c | 13 +++++++++++++
14
3 files changed, 29 insertions(+), 5 deletions(-)
15
13
16
diff --git a/hw/intc/arm_gicv3_dist.c b/hw/intc/arm_gicv3_dist.c
14
diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c
17
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
18
--- a/hw/intc/arm_gicv3_dist.c
16
--- a/hw/intc/armv7m_nvic.c
19
+++ b/hw/intc/arm_gicv3_dist.c
17
+++ b/hw/intc/armv7m_nvic.c
20
@@ -XXX,XX +XXX,XX @@ MemTxResult gicv3_dist_read(void *opaque, hwaddr offset, uint64_t *data,
18
@@ -XXX,XX +XXX,XX @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs)
21
"%s: invalid guest read at offset " TARGET_FMT_plx
19
*/
22
"size %u\n", __func__, offset, size);
20
val = cpu->env.v7m.ccr[attrs.secure];
23
trace_gicv3_dist_badread(offset, size, attrs.secure);
21
val |= cpu->env.v7m.ccr[M_REG_NS] & R_V7M_CCR_BFHFNMIGN_MASK;
24
+ /* The spec requires that reserved registers are RAZ/WI;
22
+ /* BFHFNMIGN is RAZ/WI from NS if AIRCR.BFHFNMINS is 0 */
25
+ * so use MEMTX_ERROR returns from leaf functions as a way to
23
+ if (!attrs.secure) {
26
+ * trigger the guest-error logging but don't return it to
24
+ if (!(cpu->env.v7m.aircr & R_V7M_AIRCR_BFHFNMINS_MASK)) {
27
+ * the caller, or we'll cause a spurious guest data abort.
25
+ val &= ~R_V7M_CCR_BFHFNMIGN_MASK;
28
+ */
26
+ }
29
+ r = MEMTX_OK;
27
+ }
30
+ *data = 0;
28
return val;
31
} else {
29
case 0xd24: /* System Handler Control and State (SHCSR) */
32
trace_gicv3_dist_read(offset, *data, size, attrs.secure);
30
if (!arm_feature(&cpu->env, ARM_FEATURE_V7)) {
33
}
31
@@ -XXX,XX +XXX,XX @@ static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value,
34
@@ -XXX,XX +XXX,XX @@ MemTxResult gicv3_dist_write(void *opaque, hwaddr offset, uint64_t data,
32
(cpu->env.v7m.ccr[M_REG_NS] & ~R_V7M_CCR_BFHFNMIGN_MASK)
35
"%s: invalid guest write at offset " TARGET_FMT_plx
33
| (value & R_V7M_CCR_BFHFNMIGN_MASK);
36
"size %u\n", __func__, offset, size);
34
value &= ~R_V7M_CCR_BFHFNMIGN_MASK;
37
trace_gicv3_dist_badwrite(offset, data, size, attrs.secure);
35
+ } else {
38
+ /* The spec requires that reserved registers are RAZ/WI;
36
+ /*
39
+ * so use MEMTX_ERROR returns from leaf functions as a way to
37
+ * BFHFNMIGN is RAZ/WI from NS if AIRCR.BFHFNMINS is 0, so
40
+ * trigger the guest-error logging but don't return it to
38
+ * preserve the state currently in the NS element of the array
41
+ * the caller, or we'll cause a spurious guest data abort.
39
+ */
42
+ */
40
+ if (!(cpu->env.v7m.aircr & R_V7M_AIRCR_BFHFNMINS_MASK)) {
43
+ r = MEMTX_OK;
41
+ value &= ~R_V7M_CCR_BFHFNMIGN_MASK;
44
} else {
42
+ value |= cpu->env.v7m.ccr[M_REG_NS] & R_V7M_CCR_BFHFNMIGN_MASK;
45
trace_gicv3_dist_write(offset, data, size, attrs.secure);
43
+ }
46
}
47
diff --git a/hw/intc/arm_gicv3_its_common.c b/hw/intc/arm_gicv3_its_common.c
48
index XXXXXXX..XXXXXXX 100644
49
--- a/hw/intc/arm_gicv3_its_common.c
50
+++ b/hw/intc/arm_gicv3_its_common.c
51
@@ -XXX,XX +XXX,XX @@ static MemTxResult gicv3_its_trans_read(void *opaque, hwaddr offset,
52
MemTxAttrs attrs)
53
{
54
qemu_log_mask(LOG_GUEST_ERROR, "ITS read at offset 0x%"PRIx64"\n", offset);
55
- return MEMTX_ERROR;
56
+ *data = 0;
57
+ return MEMTX_OK;
58
}
59
60
static MemTxResult gicv3_its_trans_write(void *opaque, hwaddr offset,
61
@@ -XXX,XX +XXX,XX @@ static MemTxResult gicv3_its_trans_write(void *opaque, hwaddr offset,
62
if (ret <= 0) {
63
qemu_log_mask(LOG_GUEST_ERROR,
64
"ITS: Error sending MSI: %s\n", strerror(-ret));
65
- return MEMTX_DECODE_ERROR;
66
}
44
}
67
-
45
68
- return MEMTX_OK;
46
cpu->env.v7m.ccr[attrs.secure] = value;
69
} else {
70
qemu_log_mask(LOG_GUEST_ERROR,
71
"ITS write at bad offset 0x%"PRIx64"\n", offset);
72
- return MEMTX_DECODE_ERROR;
73
}
74
+ return MEMTX_OK;
75
}
76
77
static const MemoryRegionOps gicv3_its_trans_ops = {
78
diff --git a/hw/intc/arm_gicv3_redist.c b/hw/intc/arm_gicv3_redist.c
79
index XXXXXXX..XXXXXXX 100644
80
--- a/hw/intc/arm_gicv3_redist.c
81
+++ b/hw/intc/arm_gicv3_redist.c
82
@@ -XXX,XX +XXX,XX @@ MemTxResult gicv3_redist_read(void *opaque, hwaddr offset, uint64_t *data,
83
"size %u\n", __func__, offset, size);
84
trace_gicv3_redist_badread(gicv3_redist_affid(cs), offset,
85
size, attrs.secure);
86
+ /* The spec requires that reserved registers are RAZ/WI;
87
+ * so use MEMTX_ERROR returns from leaf functions as a way to
88
+ * trigger the guest-error logging but don't return it to
89
+ * the caller, or we'll cause a spurious guest data abort.
90
+ */
91
+ r = MEMTX_OK;
92
+ *data = 0;
93
} else {
94
trace_gicv3_redist_read(gicv3_redist_affid(cs), offset, *data,
95
size, attrs.secure);
96
@@ -XXX,XX +XXX,XX @@ MemTxResult gicv3_redist_write(void *opaque, hwaddr offset, uint64_t data,
97
"size %u\n", __func__, offset, size);
98
trace_gicv3_redist_badwrite(gicv3_redist_affid(cs), offset, data,
99
size, attrs.secure);
100
+ /* The spec requires that reserved registers are RAZ/WI;
101
+ * so use MEMTX_ERROR returns from leaf functions as a way to
102
+ * trigger the guest-error logging but don't return it to
103
+ * the caller, or we'll cause a spurious guest data abort.
104
+ */
105
+ r = MEMTX_OK;
106
} else {
107
trace_gicv3_redist_write(gicv3_redist_affid(cs), offset, data,
108
size, attrs.secure);
109
--
47
--
110
2.7.4
48
2.20.1
111
49
112
50
diff view generated by jsdifflib
1
From: Andrey Smirnov <andrew.smirnov@gmail.com>
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
Some i.MX SoCs (e.g. i.MX7) have FEC registers going as far as offset
7
We also incorrectly implemented the write-to-FPSCR as a simple store
4
0x614, so to avoid getting aborts when accessing those on QEMU, extend
8
to vfp.xregs; this skips the "update the softfloat flags" part of
5
the register file to cover FSL_IMX25_FEC_SIZE(16K) of address space
9
the vfp_set_fpscr helper so the value would read back correctly but
6
instead of just 1K.
10
not actually take effect.
7
11
8
Cc: Peter Maydell <peter.maydell@linaro.org>
12
Fix both of these things by doing a complete write to the FPSCR
9
Cc: Jason Wang <jasowang@redhat.com>
13
using the helper function.
10
Cc: Philippe Mathieu-Daudé <f4bug@amsat.org>
14
11
Cc: qemu-devel@nongnu.org
12
Cc: qemu-arm@nongnu.org
13
Cc: yurovsky@gmail.com
14
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
15
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
16
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
15
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
16
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
17
Message-id: 20201210201433.26262-3-peter.maydell@linaro.org
17
---
18
---
18
include/hw/arm/fsl-imx25.h | 1 -
19
target/arm/translate-vfp.c.inc | 12 ++++++------
19
include/hw/net/imx_fec.h | 1 +
20
1 file changed, 6 insertions(+), 6 deletions(-)
20
hw/net/imx_fec.c | 2 +-
21
3 files changed, 2 insertions(+), 2 deletions(-)
22
21
23
diff --git a/include/hw/arm/fsl-imx25.h b/include/hw/arm/fsl-imx25.h
22
diff --git a/target/arm/translate-vfp.c.inc b/target/arm/translate-vfp.c.inc
24
index XXXXXXX..XXXXXXX 100644
23
index XXXXXXX..XXXXXXX 100644
25
--- a/include/hw/arm/fsl-imx25.h
24
--- a/target/arm/translate-vfp.c.inc
26
+++ b/include/hw/arm/fsl-imx25.h
25
+++ b/target/arm/translate-vfp.c.inc
27
@@ -XXX,XX +XXX,XX @@ typedef struct FslIMX25State {
26
@@ -XXX,XX +XXX,XX @@ static bool gen_M_fp_sysreg_write(DisasContext *s, int regno,
28
#define FSL_IMX25_UART5_ADDR 0x5002C000
27
}
29
#define FSL_IMX25_UART5_SIZE 0x4000
28
case ARM_VFP_FPCXT_S:
30
#define FSL_IMX25_FEC_ADDR 0x50038000
29
{
31
-#define FSL_IMX25_FEC_SIZE 0x4000
30
- TCGv_i32 sfpa, control, fpscr;
32
#define FSL_IMX25_CCM_ADDR 0x53F80000
31
- /* Set FPSCR[27:0] and CONTROL.SFPA from value */
33
#define FSL_IMX25_CCM_SIZE 0x4000
32
+ TCGv_i32 sfpa, control;
34
#define FSL_IMX25_GPT4_ADDR 0x53F84000
33
+ /*
35
diff --git a/include/hw/net/imx_fec.h b/include/hw/net/imx_fec.h
34
+ * Set FPSCR and CONTROL.SFPA from value; the new FPSCR takes
36
index XXXXXXX..XXXXXXX 100644
35
+ * bits [27:0] from value and zeroes bits [31:28].
37
--- a/include/hw/net/imx_fec.h
36
+ */
38
+++ b/include/hw/net/imx_fec.h
37
tmp = loadfn(s, opaque);
39
@@ -XXX,XX +XXX,XX @@ typedef struct {
38
sfpa = tcg_temp_new_i32();
40
39
tcg_gen_shri_i32(sfpa, tmp, 31);
41
#define ENET_TX_RING_NUM 3
40
@@ -XXX,XX +XXX,XX @@ static bool gen_M_fp_sysreg_write(DisasContext *s, int regno,
42
41
tcg_gen_deposit_i32(control, control, sfpa,
43
+#define FSL_IMX25_FEC_SIZE 0x4000
42
R_V7M_CONTROL_SFPA_SHIFT, 1);
44
43
store_cpu_field(control, v7m.control[M_REG_S]);
45
typedef struct IMXFECState {
44
- fpscr = load_cpu_field(vfp.xregs[ARM_VFP_FPSCR]);
46
/*< private >*/
45
- tcg_gen_andi_i32(fpscr, fpscr, FPCR_NZCV_MASK);
47
diff --git a/hw/net/imx_fec.c b/hw/net/imx_fec.c
46
tcg_gen_andi_i32(tmp, tmp, ~FPCR_NZCV_MASK);
48
index XXXXXXX..XXXXXXX 100644
47
- tcg_gen_or_i32(fpscr, fpscr, tmp);
49
--- a/hw/net/imx_fec.c
48
- store_cpu_field(fpscr, vfp.xregs[ARM_VFP_FPSCR]);
50
+++ b/hw/net/imx_fec.c
49
+ gen_helper_vfp_set_fpscr(cpu_env, tmp);
51
@@ -XXX,XX +XXX,XX @@ static void imx_eth_realize(DeviceState *dev, Error **errp)
50
tcg_temp_free_i32(tmp);
52
SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
51
tcg_temp_free_i32(sfpa);
53
52
break;
54
memory_region_init_io(&s->iomem, OBJECT(dev), &imx_eth_ops, s,
55
- TYPE_IMX_FEC, 0x400);
56
+ TYPE_IMX_FEC, FSL_IMX25_FEC_SIZE);
57
sysbus_init_mmio(sbd, &s->iomem);
58
sysbus_init_irq(sbd, &s->irq[0]);
59
sysbus_init_irq(sbd, &s->irq[1]);
60
--
53
--
61
2.7.4
54
2.20.1
62
55
63
56
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <f4bug@amsat.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
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
4
Reviewed-by: Alistair Francis <alistair.francis@xilinx.com>
5
Message-id: 20180103224208.30291-2-f4bug@amsat.org
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20201210201433.26262-4-peter.maydell@linaro.org
7
---
10
---
8
hw/timer/pxa2xx_timer.c | 17 +++++++++++++++--
11
target/arm/translate-vfp.c.inc | 102 ++++++++++++++++++++++++++++++++-
9
1 file changed, 15 insertions(+), 2 deletions(-)
12
1 file changed, 99 insertions(+), 3 deletions(-)
10
13
11
diff --git a/hw/timer/pxa2xx_timer.c b/hw/timer/pxa2xx_timer.c
14
diff --git a/target/arm/translate-vfp.c.inc b/target/arm/translate-vfp.c.inc
12
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
13
--- a/hw/timer/pxa2xx_timer.c
16
--- a/target/arm/translate-vfp.c.inc
14
+++ b/hw/timer/pxa2xx_timer.c
17
+++ b/target/arm/translate-vfp.c.inc
15
@@ -XXX,XX +XXX,XX @@
18
@@ -XXX,XX +XXX,XX @@ static FPSysRegCheckResult fp_sysreg_checks(DisasContext *s, int regno)
16
#include "sysemu/sysemu.h"
17
#include "hw/arm/pxa.h"
18
#include "hw/sysbus.h"
19
+#include "qemu/log.h"
20
21
#define OSMR0    0x00
22
#define OSMR1    0x04
23
@@ -XXX,XX +XXX,XX @@ static uint64_t pxa2xx_timer_read(void *opaque, hwaddr offset,
24
case OSNR:
25
return s->snapshot;
26
default:
27
+ qemu_log_mask(LOG_UNIMP,
28
+ "%s: unknown register 0x%02" HWADDR_PRIx "\n",
29
+ __func__, offset);
30
+ break;
31
badreg:
32
- hw_error("pxa2xx_timer_read: Bad offset " REG_FMT "\n", offset);
33
+ qemu_log_mask(LOG_GUEST_ERROR,
34
+ "%s: incorrect register 0x%02" HWADDR_PRIx "\n",
35
+ __func__, offset);
36
}
37
38
return 0;
39
@@ -XXX,XX +XXX,XX @@ static void pxa2xx_timer_write(void *opaque, hwaddr offset,
40
}
19
}
41
break;
20
break;
21
case ARM_VFP_FPCXT_S:
22
+ case ARM_VFP_FPCXT_NS:
23
if (!arm_dc_feature(s, ARM_FEATURE_V8_1M)) {
24
return false;
25
}
26
@@ -XXX,XX +XXX,XX @@ static FPSysRegCheckResult fp_sysreg_checks(DisasContext *s, int regno)
27
return FPSysRegCheckFailed;
28
}
29
30
- if (!vfp_access_check(s)) {
31
+ /*
32
+ * FPCXT_NS is a special case: it has specific handling for
33
+ * "current FP state is inactive", and must do the PreserveFPState()
34
+ * but not the usual full set of actions done by ExecuteFPCheck().
35
+ * So we don't call vfp_access_check() and the callers must handle this.
36
+ */
37
+ if (regno != ARM_VFP_FPCXT_NS && !vfp_access_check(s)) {
38
return FPSysRegCheckDone;
39
}
40
-
41
return FPSysRegCheckContinue;
42
}
43
44
+static void gen_branch_fpInactive(DisasContext *s, TCGCond cond,
45
+ TCGLabel *label)
46
+{
47
+ /*
48
+ * FPCXT_NS is a special case: it has specific handling for
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);
60
+
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);
72
+}
73
+
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,
78
{
79
/* Do a write to an M-profile floating point system register */
80
TCGv_i32 tmp;
81
+ TCGLabel *lab_end = NULL;
82
83
switch (fp_sysreg_checks(s, regno)) {
84
case FPSysRegCheckFailed:
85
@@ -XXX,XX +XXX,XX @@ static bool gen_M_fp_sysreg_write(DisasContext *s, int regno,
86
tcg_temp_free_i32(tmp);
87
break;
88
}
89
+ case ARM_VFP_FPCXT_NS:
90
+ lab_end = gen_new_label();
91
+ /* fpInactive case: write is a NOP, so branch to end */
92
+ gen_branch_fpInactive(s, TCG_COND_NE, lab_end);
93
+ /* !fpInactive: PreserveFPState(), and reads same as FPCXT_S */
94
+ gen_preserve_fp_state(s);
95
+ /* fall through */
96
case ARM_VFP_FPCXT_S:
97
{
98
TCGv_i32 sfpa, control;
99
@@ -XXX,XX +XXX,XX @@ static bool gen_M_fp_sysreg_write(DisasContext *s, int regno,
42
default:
100
default:
43
+ qemu_log_mask(LOG_UNIMP,
101
g_assert_not_reached();
44
+ "%s: unknown register 0x%02" HWADDR_PRIx " "
102
}
45
+ "(value 0x%08" PRIx64 ")\n", __func__, offset, value);
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;
46
+ break;
124
+ break;
47
badreg:
125
+ }
48
- hw_error("pxa2xx_timer_write: Bad offset " REG_FMT "\n", offset);
126
+ case ARM_VFP_FPCXT_NS:
49
+ qemu_log_mask(LOG_GUEST_ERROR,
127
+ {
50
+ "%s: incorrect register 0x%02" HWADDR_PRIx " "
128
+ TCGv_i32 control, sfpa, fpscr, fpdscr, zero;
51
+ "(value 0x%08" PRIx64 ")\n", __func__, offset, value);
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;
52
}
165
}
166
default:
167
g_assert_not_reached();
168
}
169
+
170
+ if (lab_end) {
171
+ gen_set_label(lab_end);
172
+ }
173
+ if (lookup_tb) {
174
+ gen_lookup_tb(s);
175
+ }
176
return true;
53
}
177
}
54
178
55
--
179
--
56
2.7.4
180
2.20.1
57
181
58
182
diff view generated by jsdifflib
1
Refactor disas_thumb2_insn() so that it generates the code for raising
1
Now that we have implemented all the features needed by the v8.1M
2
an UNDEF exception for invalid insns, rather than returning a flag
2
architecture, we can add the model of the Cortex-M55. This is the
3
which the caller must check to see if it needs to generate the UNDEF
3
configuration without MVE support; we'll add MVE later.
4
code. This brings the function in to line with the behaviour of
5
disas_thumb_insn() and disas_arm_insn().
6
4
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 1513080506-17703-1-git-send-email-peter.maydell@linaro.org
7
Message-id: 20201210201433.26262-5-peter.maydell@linaro.org
10
---
8
---
11
target/arm/translate.c | 23 ++++++++++-------------
9
target/arm/cpu_tcg.c | 42 ++++++++++++++++++++++++++++++++++++++++++
12
1 file changed, 10 insertions(+), 13 deletions(-)
10
1 file changed, 42 insertions(+)
13
11
14
diff --git a/target/arm/translate.c b/target/arm/translate.c
12
diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c
15
index XXXXXXX..XXXXXXX 100644
13
index XXXXXXX..XXXXXXX 100644
16
--- a/target/arm/translate.c
14
--- a/target/arm/cpu_tcg.c
17
+++ b/target/arm/translate.c
15
+++ b/target/arm/cpu_tcg.c
18
@@ -XXX,XX +XXX,XX @@ gen_thumb2_data_op(DisasContext *s, int op, int conds, uint32_t shifter_out,
16
@@ -XXX,XX +XXX,XX @@ static void cortex_m33_initfn(Object *obj)
19
return 0;
17
cpu->ctr = 0x8000c000;
20
}
18
}
21
19
22
-/* Translate a 32-bit thumb instruction. Returns nonzero if the instruction
20
+static void cortex_m55_initfn(Object *obj)
23
- is not legal. */
21
+{
24
-static int disas_thumb2_insn(DisasContext *s, uint32_t insn)
22
+ ARMCPU *cpu = ARM_CPU(obj);
25
+/* Translate a 32-bit thumb instruction. */
23
+
26
+static void disas_thumb2_insn(DisasContext *s, uint32_t insn)
24
+ set_feature(&cpu->env, ARM_FEATURE_V8);
27
{
25
+ set_feature(&cpu->env, ARM_FEATURE_V8_1M);
28
uint32_t imm, shift, offset;
26
+ set_feature(&cpu->env, ARM_FEATURE_M);
29
uint32_t rd, rn, rm, rs;
27
+ set_feature(&cpu->env, ARM_FEATURE_M_MAIN);
30
@@ -XXX,XX +XXX,XX @@ static int disas_thumb2_insn(DisasContext *s, uint32_t insn)
28
+ set_feature(&cpu->env, ARM_FEATURE_M_SECURITY);
31
/* UNPREDICTABLE, unallocated hint or
29
+ set_feature(&cpu->env, ARM_FEATURE_THUMB_DSP);
32
* PLD/PLDW/PLI (literal)
30
+ cpu->midr = 0x410fd221; /* r0p1 */
33
*/
31
+ cpu->revidr = 0;
34
- return 0;
32
+ cpu->pmsav7_dregion = 16;
35
+ return;
33
+ cpu->sau_sregion = 8;
36
}
34
+ /*
37
if (op1 & 1) {
35
+ * These are the MVFR* values for the FPU, no MVE configuration;
38
- return 0; /* PLD/PLDW/PLI or unallocated hint */
36
+ * we will update them later when we implement MVE
39
+ return; /* PLD/PLDW/PLI or unallocated hint */
37
+ */
40
}
38
+ cpu->isar.mvfr0 = 0x10110221;
41
if ((op2 == 0) || ((op2 & 0x3c) == 0x30)) {
39
+ cpu->isar.mvfr1 = 0x12100011;
42
- return 0; /* PLD/PLDW/PLI or unallocated hint */
40
+ cpu->isar.mvfr2 = 0x00000040;
43
+ return; /* PLD/PLDW/PLI or unallocated hint */
41
+ cpu->isar.id_pfr0 = 0x20000030;
44
}
42
+ cpu->isar.id_pfr1 = 0x00000230;
45
/* UNDEF space, or an UNPREDICTABLE */
43
+ cpu->isar.id_dfr0 = 0x10200000;
46
- return 1;
44
+ cpu->id_afr0 = 0x00000000;
47
+ goto illegal_op;
45
+ cpu->isar.id_mmfr0 = 0x00111040;
48
}
46
+ cpu->isar.id_mmfr1 = 0x00000000;
49
}
47
+ cpu->isar.id_mmfr2 = 0x01000000;
50
memidx = get_mem_index(s);
48
+ cpu->isar.id_mmfr3 = 0x00000011;
51
@@ -XXX,XX +XXX,XX @@ static int disas_thumb2_insn(DisasContext *s, uint32_t insn)
49
+ cpu->isar.id_isar0 = 0x01103110;
52
default:
50
+ cpu->isar.id_isar1 = 0x02212000;
53
goto illegal_op;
51
+ cpu->isar.id_isar2 = 0x20232232;
54
}
52
+ cpu->isar.id_isar3 = 0x01111131;
55
- return 0;
53
+ cpu->isar.id_isar4 = 0x01310132;
56
+ return;
54
+ cpu->isar.id_isar5 = 0x00000000;
57
illegal_op:
55
+ cpu->isar.id_isar6 = 0x00000000;
58
- return 1;
56
+ cpu->clidr = 0x00000000; /* caches not implemented */
59
+ gen_exception_insn(s, 4, EXCP_UDEF, syn_uncategorized(),
57
+ cpu->ctr = 0x8303c003;
60
+ default_exception_el(s));
58
+}
61
}
59
+
62
60
static const ARMCPRegInfo cortexr5_cp_reginfo[] = {
63
static void disas_thumb_insn(DisasContext *s, uint32_t insn)
61
/* Dummy the TCM region regs for the moment */
64
@@ -XXX,XX +XXX,XX @@ static void thumb_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu)
62
{ .name = "ATCM", .cp = 15, .opc1 = 0, .crn = 9, .crm = 1, .opc2 = 0,
65
if (is_16bit) {
63
@@ -XXX,XX +XXX,XX @@ static const ARMCPUInfo arm_tcg_cpus[] = {
66
disas_thumb_insn(dc, insn);
64
.class_init = arm_v7m_class_init },
67
} else {
65
{ .name = "cortex-m33", .initfn = cortex_m33_initfn,
68
- if (disas_thumb2_insn(dc, insn)) {
66
.class_init = arm_v7m_class_init },
69
- gen_exception_insn(dc, 4, EXCP_UDEF, syn_uncategorized(),
67
+ { .name = "cortex-m55", .initfn = cortex_m55_initfn,
70
- default_exception_el(dc));
68
+ .class_init = arm_v7m_class_init },
71
- }
69
{ .name = "cortex-r5", .initfn = cortex_r5_initfn },
72
+ disas_thumb2_insn(dc, insn);
70
{ .name = "cortex-r5f", .initfn = cortex_r5f_initfn },
73
}
71
{ .name = "ti925t", .initfn = ti925t_initfn },
74
75
/* Advance the Thumb condexec condition. */
76
--
72
--
77
2.7.4
73
2.20.1
78
74
79
75
diff view generated by jsdifflib
1
From: Andrey Smirnov <andrew.smirnov@gmail.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
Needed to support latest Linux kernel driver which relies on that
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
functionality.
10
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
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(-)
5
16
6
Cc: Peter Maydell <peter.maydell@linaro.org>
17
diff --git a/hw/arm/highbank.c b/hw/arm/highbank.c
7
Cc: Jason Wang <jasowang@redhat.com>
8
Cc: Philippe Mathieu-Daudé <f4bug@amsat.org>
9
Cc: qemu-devel@nongnu.org
10
Cc: qemu-arm@nongnu.org
11
Cc: yurovsky@gmail.com
12
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
13
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
14
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
15
---
16
include/hw/net/imx_fec.h | 2 ++
17
hw/net/imx_fec.c | 23 +++++++++++++++++++++++
18
2 files changed, 25 insertions(+)
19
20
diff --git a/include/hw/net/imx_fec.h b/include/hw/net/imx_fec.h
21
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
22
--- a/include/hw/net/imx_fec.h
19
--- a/hw/arm/highbank.c
23
+++ b/include/hw/net/imx_fec.h
20
+++ b/hw/arm/highbank.c
24
@@ -XXX,XX +XXX,XX @@
21
@@ -XXX,XX +XXX,XX @@
25
#define ENET_TWFR_TFWR_LENGTH (6)
22
#include "hw/arm/boot.h"
26
#define ENET_TWFR_STRFWD (1 << 8)
23
#include "hw/loader.h"
27
24
#include "net/net.h"
28
+#define ENET_RACC_SHIFT16 BIT(7)
25
-#include "sysemu/kvm.h"
29
+
26
#include "sysemu/runstate.h"
30
/* Buffer Descriptor. */
27
#include "sysemu/sysemu.h"
31
typedef struct {
28
#include "hw/boards.h"
32
uint16_t length;
29
@@ -XXX,XX +XXX,XX @@
33
diff --git a/hw/net/imx_fec.c b/hw/net/imx_fec.c
30
#include "hw/cpu/a15mpcore.h"
34
index XXXXXXX..XXXXXXX 100644
31
#include "qemu/log.h"
35
--- a/hw/net/imx_fec.c
32
#include "qom/object.h"
36
+++ b/hw/net/imx_fec.c
33
+#include "cpu.h"
37
@@ -XXX,XX +XXX,XX @@ static ssize_t imx_enet_receive(NetClientState *nc, const uint8_t *buf,
34
38
uint8_t *crc_ptr;
35
#define SMP_BOOT_ADDR 0x100
39
unsigned int buf_len;
36
#define SMP_BOOT_REG 0x40
40
size_t size = len;
37
@@ -XXX,XX +XXX,XX @@ static void calxeda_init(MachineState *machine, enum cxmachines machine_id)
41
+ bool shift16 = s->regs[ENET_RACC] & ENET_RACC_SHIFT16;
38
highbank_binfo.loader_start = 0;
42
39
highbank_binfo.write_secondary_boot = hb_write_secondary;
43
FEC_PRINTF("len %d\n", (int)size);
40
highbank_binfo.secondary_cpu_reset_hook = hb_reset_secondary;
44
41
- if (!kvm_enabled()) {
45
@@ -XXX,XX +XXX,XX @@ static ssize_t imx_enet_receive(NetClientState *nc, const uint8_t *buf,
42
- highbank_binfo.board_setup_addr = BOARD_SETUP_ADDR;
46
crc = cpu_to_be32(crc32(~0, buf, size));
43
- highbank_binfo.write_board_setup = hb_write_board_setup;
47
crc_ptr = (uint8_t *) &crc;
44
- highbank_binfo.secure_board_setup = true;
48
45
- } else {
49
+ if (shift16) {
46
- warn_report("cannot load built-in Monitor support "
50
+ size += 2;
47
- "if KVM is enabled. Some guests (such as Linux) "
51
+ }
48
- "may not boot.");
52
+
49
- }
53
/* Huge frames are truncted. */
50
+ highbank_binfo.board_setup_addr = BOARD_SETUP_ADDR;
54
if (size > s->regs[ENET_FTRL]) {
51
+ highbank_binfo.write_board_setup = hb_write_board_setup;
55
size = s->regs[ENET_FTRL];
52
+ highbank_binfo.secure_board_setup = true;
56
@@ -XXX,XX +XXX,XX @@ static ssize_t imx_enet_receive(NetClientState *nc, const uint8_t *buf,
53
57
buf_len += size - 4;
54
arm_load_kernel(ARM_CPU(first_cpu), machine, &highbank_binfo);
58
}
55
}
59
buf_addr = bd.data;
60
+
61
+ if (shift16) {
62
+ /*
63
+ * If SHIFT16 bit of ENETx_RACC register is set we need to
64
+ * align the payload to 4-byte boundary.
65
+ */
66
+ const uint8_t zeros[2] = { 0 };
67
+
68
+ dma_memory_write(&address_space_memory, buf_addr,
69
+ zeros, sizeof(zeros));
70
+
71
+ buf_addr += sizeof(zeros);
72
+ buf_len -= sizeof(zeros);
73
+
74
+ /* We only do this once per Ethernet frame */
75
+ shift16 = false;
76
+ }
77
+
78
dma_memory_write(&address_space_memory, buf_addr, buf, buf_len);
79
buf += buf_len;
80
if (size < 4) {
81
--
56
--
82
2.7.4
57
2.20.1
83
58
84
59
diff view generated by jsdifflib
1
From: Andrey Smirnov <andrew.smirnov@gmail.com>
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
Binding to a particular netdev doesn't seem to belong to this layer
9
This is unfortunate API design as it makes it easy to accidentally
4
and should probably be done as a part of board or SoC specific code.
10
misuse (by forgetting the timer_del()), and the correct use is
11
annoyingly verbose.
5
12
6
Convert all of the users of this IP block to use
13
Make timer_free() imply a timer_del().
7
qdev_set_nic_properties() instead.
8
14
9
Cc: Peter Maydell <peter.maydell@linaro.org>
10
Cc: Jason Wang <jasowang@redhat.com>
11
Cc: Philippe Mathieu-Daudé <f4bug@amsat.org>
12
Cc: qemu-devel@nongnu.org
13
Cc: qemu-arm@nongnu.org
14
Cc: yurovsky@gmail.com
15
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
16
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
17
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
15
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
16
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
17
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
18
Message-id: 20201215154107.3255-2-peter.maydell@linaro.org
18
---
19
---
19
hw/arm/fsl-imx6.c | 1 +
20
include/qemu/timer.h | 24 +++++++++++++-----------
20
hw/net/imx_fec.c | 2 --
21
1 file changed, 13 insertions(+), 11 deletions(-)
21
2 files changed, 1 insertion(+), 2 deletions(-)
22
22
23
diff --git a/hw/arm/fsl-imx6.c b/hw/arm/fsl-imx6.c
23
diff --git a/include/qemu/timer.h b/include/qemu/timer.h
24
index XXXXXXX..XXXXXXX 100644
24
index XXXXXXX..XXXXXXX 100644
25
--- a/hw/arm/fsl-imx6.c
25
--- a/include/qemu/timer.h
26
+++ b/hw/arm/fsl-imx6.c
26
+++ b/include/qemu/timer.h
27
@@ -XXX,XX +XXX,XX @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp)
27
@@ -XXX,XX +XXX,XX @@ static inline QEMUTimer *timer_new_ms(QEMUClockType type, QEMUTimerCB *cb,
28
spi_table[i].irq));
28
*/
29
}
29
void timer_deinit(QEMUTimer *ts);
30
30
31
+ qdev_set_nic_properties(DEVICE(&s->eth), &nd_table[0]);
31
-/**
32
object_property_set_bool(OBJECT(&s->eth), true, "realized", &err);
32
- * timer_free:
33
if (err) {
33
- * @ts: the timer
34
error_propagate(errp, err);
34
- *
35
diff --git a/hw/net/imx_fec.c b/hw/net/imx_fec.c
35
- * Free a timer (it must not be on the active list)
36
index XXXXXXX..XXXXXXX 100644
36
- */
37
--- a/hw/net/imx_fec.c
37
-static inline void timer_free(QEMUTimer *ts)
38
+++ b/hw/net/imx_fec.c
38
-{
39
@@ -XXX,XX +XXX,XX @@ static void imx_eth_realize(DeviceState *dev, Error **errp)
39
- g_free(ts);
40
40
-}
41
qemu_macaddr_default_if_unset(&s->conf.macaddr);
42
43
- s->conf.peers.ncs[0] = nd_table[0].netdev;
44
-
41
-
45
s->nic = qemu_new_nic(&imx_eth_net_info, &s->conf,
42
/**
46
object_get_typename(OBJECT(dev)),
43
* timer_del:
47
DEVICE(dev)->id, s);
44
* @ts: the timer
45
@@ -XXX,XX +XXX,XX @@ static inline void timer_free(QEMUTimer *ts)
46
*/
47
void timer_del(QEMUTimer *ts);
48
49
+/**
50
+ * timer_free:
51
+ * @ts: the timer
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.
55
+ */
56
+static inline void timer_free(QEMUTimer *ts)
57
+{
58
+ timer_del(ts);
59
+ g_free(ts);
60
+}
61
+
62
/**
63
* timer_mod_ns:
64
* @ts: the timer
48
--
65
--
49
2.7.4
66
2.20.1
50
67
51
68
diff view generated by jsdifflib
1
From: Michael Weiser <michael.weiser@gmx.de>
1
Now that timer_free() implicitly calls timer_del(), sequences
2
timer_del(mytimer);
3
timer_free(mytimer);
2
4
3
ldxp loads two consecutive doublewords from memory regardless of CPU
5
can be simplified to just
4
endianness. On store, stlxp currently assumes to work with a 128bit
6
timer_free(mytimer);
5
value and consequently switches order in big-endian mode. With this
6
change it packs the doublewords in reverse order in anticipation of the
7
128bit big-endian store operation interposing them so they end up in
8
memory in the right order. This makes it work for both MTTCG and !MTTCG.
9
It effectively implements the ARM ARM STLXP operation pseudo-code:
10
7
11
data = if BigEndian() then el1:el2 else el2:el1;
8
Add a Coccinelle script to do this transformation.
12
9
13
With this change an aarch64_be Linux 4.14.4 kernel succeeds to boot up
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
in system emulation mode.
11
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
12
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
13
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
14
Message-id: 20201215154107.3255-3-peter.maydell@linaro.org
15
---
16
scripts/coccinelle/timer-del-timer-free.cocci | 18 ++++++++++++++++++
17
1 file changed, 18 insertions(+)
18
create mode 100644 scripts/coccinelle/timer-del-timer-free.cocci
15
19
16
Signed-off-by: Michael Weiser <michael.weiser@gmx.de>
20
diff --git a/scripts/coccinelle/timer-del-timer-free.cocci b/scripts/coccinelle/timer-del-timer-free.cocci
17
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
21
new file mode 100644
18
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
22
index XXXXXXX..XXXXXXX
19
---
23
--- /dev/null
20
target/arm/helper-a64.c | 7 +++++--
24
+++ b/scripts/coccinelle/timer-del-timer-free.cocci
21
1 file changed, 5 insertions(+), 2 deletions(-)
25
@@ -XXX,XX +XXX,XX @@
22
26
+// Remove superfluous timer_del() calls
23
diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c
27
+//
24
index XXXXXXX..XXXXXXX 100644
28
+// Copyright Linaro Limited 2020
25
--- a/target/arm/helper-a64.c
29
+// This work is licensed under the terms of the GNU GPLv2 or later.
26
+++ b/target/arm/helper-a64.c
30
+//
27
@@ -XXX,XX +XXX,XX @@ static uint64_t do_paired_cmpxchg64_be(CPUARMState *env, uint64_t addr,
31
+// spatch --macro-file scripts/cocci-macro-file.h \
28
Int128 oldv, cmpv, newv;
32
+// --sp-file scripts/coccinelle/timer-del-timer-free.cocci \
29
bool success;
33
+// --in-place --dir .
30
34
+//
31
- cmpv = int128_make128(env->exclusive_val, env->exclusive_high);
35
+// The timer_free() function now implicitly calls timer_del()
32
- newv = int128_make128(new_lo, new_hi);
36
+// for you, so calls to timer_del() immediately before the
33
+ /* high and low need to be switched here because this is not actually a
37
+// timer_free() of the same timer can be deleted.
34
+ * 128bit store but two doublewords stored consecutively
38
+
35
+ */
39
+@@
36
+ cmpv = int128_make128(env->exclusive_high, env->exclusive_val);
40
+expression T;
37
+ newv = int128_make128(new_hi, new_lo);
41
+@@
38
42
+-timer_del(T);
39
if (parallel) {
43
+ timer_free(T);
40
#ifndef CONFIG_ATOMIC128
41
--
44
--
42
2.7.4
45
2.20.1
43
46
44
47
diff view generated by jsdifflib
1
From: Andrey Smirnov <andrew.smirnov@gmail.com>
1
This commit is the result of running the timer-del-timer-free.cocci
2
script on the whole source tree.
2
3
3
In current implementation, packet queue flushing logic seem to suffer
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
from a deadlock like scenario if a packet is received by the interface
5
Acked-by: Corey Minyard <cminyard@mvista.com>
5
before before Rx ring is initialized by Guest's driver. Consider the
6
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
6
following sequence of events:
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(-)
7
54
8
    1. A QEMU instance is started against a TAP device on Linux
55
diff --git a/block/iscsi.c b/block/iscsi.c
9
     host, running Linux guest, e. g., something to the effect
56
index XXXXXXX..XXXXXXX 100644
10
     of:
57
--- a/block/iscsi.c
11
58
+++ b/block/iscsi.c
12
     qemu-system-arm \
59
@@ -XXX,XX +XXX,XX @@ static void iscsi_detach_aio_context(BlockDriverState *bs)
13
     -net nic,model=imx.fec,netdev=lan0 \
60
iscsilun->events = 0;
14
     netdev tap,id=lan0,ifname=tap0,script=no,downscript=no \
61
15
     ... rest of the arguments ...
62
if (iscsilun->nop_timer) {
16
63
- timer_del(iscsilun->nop_timer);
17
    2. Once QEMU starts, but before guest reaches the point where
64
timer_free(iscsilun->nop_timer);
18
     FEC deriver is done initializing the HW, Guest, via TAP
65
iscsilun->nop_timer = NULL;
19
     interface, receives a number of multicast MDNS packets from
66
}
20
     Host (not necessarily true for every OS, but it happens at
67
if (iscsilun->event_timer) {
21
     least on Fedora 25)
68
- timer_del(iscsilun->event_timer);
22
69
timer_free(iscsilun->event_timer);
23
    3. Recieving a packet in such a state results in
70
iscsilun->event_timer = NULL;
24
     imx_eth_can_receive() returning '0', which in turn causes
71
}
25
     tap_send() to disable corresponding event (tap.c:203)
72
diff --git a/block/nbd.c b/block/nbd.c
26
73
index XXXXXXX..XXXXXXX 100644
27
    4. Once Guest's driver reaches the point where it is ready to
74
--- a/block/nbd.c
28
     recieve packets it prepares Rx ring descriptors and writes
75
+++ b/block/nbd.c
29
     ENET_RDAR_RDAR to ENET_RDAR register to indicate to HW that
76
@@ -XXX,XX +XXX,XX @@ static void nbd_recv_coroutines_wake_all(BDRVNBDState *s)
30
     more descriptors are ready. And at this points emulation
77
static void reconnect_delay_timer_del(BDRVNBDState *s)
31
     layer does this:
78
{
32
79
if (s->reconnect_delay_timer) {
33
          s->regs[index] = ENET_RDAR_RDAR;
80
- timer_del(s->reconnect_delay_timer);
34
imx_eth_enable_rx(s);
81
timer_free(s->reconnect_delay_timer);
35
82
s->reconnect_delay_timer = NULL;
36
     which, combined with:
83
}
37
84
diff --git a/block/qcow2.c b/block/qcow2.c
38
          if (!s->regs[ENET_RDAR]) {
85
index XXXXXXX..XXXXXXX 100644
39
         qemu_flush_queued_packets(qemu_get_queue(s->nic));
86
--- a/block/qcow2.c
40
         }
87
+++ b/block/qcow2.c
41
88
@@ -XXX,XX +XXX,XX @@ static void cache_clean_timer_del(BlockDriverState *bs)
42
     results in Rx queue never being flushed and corresponding
89
{
43
     I/O event beign disabled.
90
BDRVQcow2State *s = bs->opaque;
44
91
if (s->cache_clean_timer) {
45
To prevent the problem, change the code to always flush packet queue
92
- timer_del(s->cache_clean_timer);
46
when ENET_RDAR transitions 0 -> ENET_RDAR_RDAR.
93
timer_free(s->cache_clean_timer);
47
94
s->cache_clean_timer = NULL;
48
Cc: Peter Maydell <peter.maydell@linaro.org>
95
}
49
Cc: Jason Wang <jasowang@redhat.com>
96
diff --git a/hw/block/nvme.c b/hw/block/nvme.c
50
Cc: Philippe Mathieu-Daudé <f4bug@amsat.org>
97
index XXXXXXX..XXXXXXX 100644
51
Cc: qemu-devel@nongnu.org
98
--- a/hw/block/nvme.c
52
Cc: qemu-arm@nongnu.org
99
+++ b/hw/block/nvme.c
53
Cc: yurovsky@gmail.com
100
@@ -XXX,XX +XXX,XX @@ static uint16_t nvme_io_cmd(NvmeCtrl *n, NvmeRequest *req)
54
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
101
static void nvme_free_sq(NvmeSQueue *sq, NvmeCtrl *n)
55
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
102
{
56
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
103
n->sq[sq->sqid] = NULL;
57
---
104
- timer_del(sq->timer);
58
hw/net/imx_fec.c | 12 ++++++------
105
timer_free(sq->timer);
59
1 file changed, 6 insertions(+), 6 deletions(-)
106
g_free(sq->io_req);
60
107
if (sq->sqid) {
61
diff --git a/hw/net/imx_fec.c b/hw/net/imx_fec.c
108
@@ -XXX,XX +XXX,XX @@ static uint16_t nvme_get_log(NvmeCtrl *n, NvmeRequest *req)
62
index XXXXXXX..XXXXXXX 100644
109
static void nvme_free_cq(NvmeCQueue *cq, NvmeCtrl *n)
63
--- a/hw/net/imx_fec.c
110
{
64
+++ b/hw/net/imx_fec.c
111
n->cq[cq->cqid] = NULL;
65
@@ -XXX,XX +XXX,XX @@ static void imx_eth_do_tx(IMXFECState *s)
112
- timer_del(cq->timer);
66
}
113
timer_free(cq->timer);
67
}
114
msix_vector_unuse(&n->parent_obj, cq->vector);
68
115
if (cq->cqid) {
69
-static void imx_eth_enable_rx(IMXFECState *s)
116
diff --git a/hw/char/serial.c b/hw/char/serial.c
70
+static void imx_eth_enable_rx(IMXFECState *s, bool flush)
117
index XXXXXXX..XXXXXXX 100644
71
{
118
--- a/hw/char/serial.c
72
IMXFECBufDesc bd;
119
+++ b/hw/char/serial.c
73
bool rx_ring_full;
120
@@ -XXX,XX +XXX,XX @@ static void serial_unrealize(DeviceState *dev)
74
@@ -XXX,XX +XXX,XX @@ static void imx_eth_enable_rx(IMXFECState *s)
121
75
122
qemu_chr_fe_deinit(&s->chr, false);
76
if (rx_ring_full) {
123
77
FEC_PRINTF("RX buffer full\n");
124
- timer_del(s->modem_status_poll);
78
- } else if (!s->regs[ENET_RDAR]) {
125
timer_free(s->modem_status_poll);
79
+ } else if (flush) {
126
80
qemu_flush_queued_packets(qemu_get_queue(s->nic));
127
- timer_del(s->fifo_timeout_timer);
81
}
128
timer_free(s->fifo_timeout_timer);
82
129
83
@@ -XXX,XX +XXX,XX @@ static void imx_eth_write(void *opaque, hwaddr offset, uint64_t value,
130
fifo8_destroy(&s->recv_fifo);
84
if (s->regs[ENET_ECR] & ENET_ECR_ETHEREN) {
131
diff --git a/hw/char/virtio-serial-bus.c b/hw/char/virtio-serial-bus.c
85
if (!s->regs[index]) {
132
index XXXXXXX..XXXXXXX 100644
86
s->regs[index] = ENET_RDAR_RDAR;
133
--- a/hw/char/virtio-serial-bus.c
87
- imx_eth_enable_rx(s);
134
+++ b/hw/char/virtio-serial-bus.c
88
+ imx_eth_enable_rx(s, true);
135
@@ -XXX,XX +XXX,XX @@ static void virtio_serial_post_load_timer_cb(void *opaque)
89
}
90
} else {
91
s->regs[index] = 0;
92
@@ -XXX,XX +XXX,XX @@ static int imx_eth_can_receive(NetClientState *nc)
93
94
FEC_PRINTF("\n");
95
96
- return s->regs[ENET_RDAR] ? 1 : 0;
97
+ return !!s->regs[ENET_RDAR];
98
}
99
100
static ssize_t imx_fec_receive(NetClientState *nc, const uint8_t *buf,
101
@@ -XXX,XX +XXX,XX @@ static ssize_t imx_fec_receive(NetClientState *nc, const uint8_t *buf,
102
}
136
}
103
}
137
}
104
s->rx_descriptor = addr;
138
g_free(s->post_load->connected);
105
- imx_eth_enable_rx(s);
139
- timer_del(s->post_load->timer);
106
+ imx_eth_enable_rx(s, false);
140
timer_free(s->post_load->timer);
107
imx_eth_update(s);
141
g_free(s->post_load);
108
return len;
142
s->post_load = NULL;
109
}
143
@@ -XXX,XX +XXX,XX @@ static void virtio_serial_device_unrealize(DeviceState *dev)
110
@@ -XXX,XX +XXX,XX @@ static ssize_t imx_enet_receive(NetClientState *nc, const uint8_t *buf,
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);
111
}
305
}
112
}
306
113
s->rx_descriptor = addr;
307
- timer_del(chain->drain_timer);
114
- imx_eth_enable_rx(s);
308
timer_free(chain->drain_timer);
115
+ imx_eth_enable_rx(s, false);
309
QTAILQ_REMOVE(&n->rsc_chains, chain, next);
116
imx_eth_update(s);
310
g_free(chain);
117
return len;
311
@@ -XXX,XX +XXX,XX @@ static void virtio_net_del_queue(VirtIONet *n, int index)
312
313
virtio_del_queue(vdev, index * 2);
314
if (q->tx_timer) {
315
- timer_del(q->tx_timer);
316
timer_free(q->tx_timer);
317
q->tx_timer = NULL;
318
} else {
319
diff --git a/hw/s390x/s390-pci-inst.c b/hw/s390x/s390-pci-inst.c
320
index XXXXXXX..XXXXXXX 100644
321
--- a/hw/s390x/s390-pci-inst.c
322
+++ b/hw/s390x/s390-pci-inst.c
323
@@ -XXX,XX +XXX,XX @@ void pci_dereg_ioat(S390PCIIOMMU *iommu)
324
void fmb_timer_free(S390PCIBusDevice *pbdev)
325
{
326
if (pbdev->fmb_timer) {
327
- timer_del(pbdev->fmb_timer);
328
timer_free(pbdev->fmb_timer);
329
pbdev->fmb_timer = NULL;
330
}
331
diff --git a/hw/sd/sd.c b/hw/sd/sd.c
332
index XXXXXXX..XXXXXXX 100644
333
--- a/hw/sd/sd.c
334
+++ b/hw/sd/sd.c
335
@@ -XXX,XX +XXX,XX @@ static void sd_instance_finalize(Object *obj)
336
{
337
SDState *sd = SD_CARD(obj);
338
339
- timer_del(sd->ocr_power_timer);
340
timer_free(sd->ocr_power_timer);
341
}
342
343
diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c
344
index XXXXXXX..XXXXXXX 100644
345
--- a/hw/sd/sdhci.c
346
+++ b/hw/sd/sdhci.c
347
@@ -XXX,XX +XXX,XX @@ void sdhci_initfn(SDHCIState *s)
348
349
void sdhci_uninitfn(SDHCIState *s)
350
{
351
- timer_del(s->insert_timer);
352
timer_free(s->insert_timer);
353
- timer_del(s->transfer_timer);
354
timer_free(s->transfer_timer);
355
356
g_free(s->fifo_buffer);
357
diff --git a/hw/usb/dev-hub.c b/hw/usb/dev-hub.c
358
index XXXXXXX..XXXXXXX 100644
359
--- a/hw/usb/dev-hub.c
360
+++ b/hw/usb/dev-hub.c
361
@@ -XXX,XX +XXX,XX @@ static void usb_hub_unrealize(USBDevice *dev)
362
&s->ports[i].port);
363
}
364
365
- timer_del(s->port_timer);
366
timer_free(s->port_timer);
367
}
368
369
diff --git a/hw/usb/hcd-ehci.c b/hw/usb/hcd-ehci.c
370
index XXXXXXX..XXXXXXX 100644
371
--- a/hw/usb/hcd-ehci.c
372
+++ b/hw/usb/hcd-ehci.c
373
@@ -XXX,XX +XXX,XX @@ void usb_ehci_unrealize(EHCIState *s, DeviceState *dev)
374
trace_usb_ehci_unrealize();
375
376
if (s->frame_timer) {
377
- timer_del(s->frame_timer);
378
timer_free(s->frame_timer);
379
s->frame_timer = NULL;
380
}
381
diff --git a/hw/usb/hcd-ohci-pci.c b/hw/usb/hcd-ohci-pci.c
382
index XXXXXXX..XXXXXXX 100644
383
--- a/hw/usb/hcd-ohci-pci.c
384
+++ b/hw/usb/hcd-ohci-pci.c
385
@@ -XXX,XX +XXX,XX @@ static void usb_ohci_exit(PCIDevice *dev)
386
usb_bus_release(&s->bus);
387
}
388
389
- timer_del(s->eof_timer);
390
timer_free(s->eof_timer);
391
}
392
393
diff --git a/hw/usb/hcd-uhci.c b/hw/usb/hcd-uhci.c
394
index XXXXXXX..XXXXXXX 100644
395
--- a/hw/usb/hcd-uhci.c
396
+++ b/hw/usb/hcd-uhci.c
397
@@ -XXX,XX +XXX,XX @@ static void usb_uhci_exit(PCIDevice *dev)
398
trace_usb_uhci_exit();
399
400
if (s->frame_timer) {
401
- timer_del(s->frame_timer);
402
timer_free(s->frame_timer);
403
s->frame_timer = NULL;
404
}
405
diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c
406
index XXXXXXX..XXXXXXX 100644
407
--- a/hw/usb/hcd-xhci.c
408
+++ b/hw/usb/hcd-xhci.c
409
@@ -XXX,XX +XXX,XX @@ static void usb_xhci_unrealize(DeviceState *dev)
410
}
411
412
if (xhci->mfwrap_timer) {
413
- timer_del(xhci->mfwrap_timer);
414
timer_free(xhci->mfwrap_timer);
415
xhci->mfwrap_timer = NULL;
416
}
417
diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c
418
index XXXXXXX..XXXXXXX 100644
419
--- a/hw/usb/redirect.c
420
+++ b/hw/usb/redirect.c
421
@@ -XXX,XX +XXX,XX @@ static void usbredir_unrealize(USBDevice *udev)
422
qemu_bh_delete(dev->chardev_close_bh);
423
qemu_bh_delete(dev->device_reject_bh);
424
425
- timer_del(dev->attach_timer);
426
timer_free(dev->attach_timer);
427
428
usbredir_cleanup_device_queues(dev);
429
diff --git a/hw/vfio/display.c b/hw/vfio/display.c
430
index XXXXXXX..XXXXXXX 100644
431
--- a/hw/vfio/display.c
432
+++ b/hw/vfio/display.c
433
@@ -XXX,XX +XXX,XX @@ static void vfio_display_edid_exit(VFIODisplay *dpy)
434
435
g_free(dpy->edid_regs);
436
g_free(dpy->edid_blob);
437
- timer_del(dpy->edid_link_timer);
438
timer_free(dpy->edid_link_timer);
439
}
440
441
diff --git a/hw/virtio/vhost-vsock-common.c b/hw/virtio/vhost-vsock-common.c
442
index XXXXXXX..XXXXXXX 100644
443
--- a/hw/virtio/vhost-vsock-common.c
444
+++ b/hw/virtio/vhost-vsock-common.c
445
@@ -XXX,XX +XXX,XX @@ static void vhost_vsock_common_post_load_timer_cleanup(VHostVSockCommon *vvc)
446
return;
447
}
448
449
- timer_del(vvc->post_load_timer);
450
timer_free(vvc->post_load_timer);
451
vvc->post_load_timer = NULL;
452
}
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;
118
}
622
}
119
--
623
--
120
2.7.4
624
2.20.1
121
625
122
626
diff view generated by jsdifflib
1
From: Michael Weiser <michael.weiser@gmx.de>
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
Give big-endian arm and aarch64 CPUs their own family in
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
qemu-binfmt-conf.sh to make sure we register qemu-user for binaries of
7
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
5
the opposite endianness on arm and aarch64. Apart from the family
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
assignments of the magic values, qemu_get_family() needs to be able to
9
Message-id: 20201215154107.3255-5-peter.maydell@linaro.org
7
distinguish the two and recognise aarch64{,_be} as well.
10
---
11
target/arm/cpu.c | 2 --
12
1 file changed, 2 deletions(-)
8
13
9
Signed-off-by: Michael Weiser <michael.weiser@gmx.de>
14
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
10
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
15
index XXXXXXX..XXXXXXX 100644
11
Message-id: 20171220212308.12614-7-michael.weiser@gmx.de
16
--- a/target/arm/cpu.c
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
17
+++ b/target/arm/cpu.c
13
---
18
@@ -XXX,XX +XXX,XX @@ static void arm_cpu_finalizefn(Object *obj)
14
scripts/qemu-binfmt-conf.sh | 9 ++++++---
19
}
15
1 file changed, 6 insertions(+), 3 deletions(-)
20
#ifndef CONFIG_USER_ONLY
16
21
if (cpu->pmu_timer) {
17
diff --git a/scripts/qemu-binfmt-conf.sh b/scripts/qemu-binfmt-conf.sh
22
- timer_del(cpu->pmu_timer);
18
index XXXXXXX..XXXXXXX 100755
23
- timer_deinit(cpu->pmu_timer);
19
--- a/scripts/qemu-binfmt-conf.sh
24
timer_free(cpu->pmu_timer);
20
+++ b/scripts/qemu-binfmt-conf.sh
25
}
21
@@ -XXX,XX +XXX,XX @@ arm_family=arm
26
#endif
22
23
armeb_magic='\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28'
24
armeb_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
25
-armeb_family=arm
26
+armeb_family=armeb
27
28
sparc_magic='\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x02'
29
sparc_mask='\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
30
@@ -XXX,XX +XXX,XX @@ aarch64_family=arm
31
32
aarch64_be_magic='\x7fELF\x02\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xb7'
33
aarch64_be_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
34
-aarch64_be_family=arm
35
+aarch64_be_family=armeb
36
37
hppa_magic='\x7f\x45\x4c\x46\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x0f'
38
hppa_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
39
@@ -XXX,XX +XXX,XX @@ qemu_get_family() {
40
ppc64el|ppc64le)
41
echo "ppcle"
42
;;
43
- arm|armel|armhf|arm64|armv[4-9]*)
44
+ arm|armel|armhf|arm64|armv[4-9]*l|aarch64)
45
echo "arm"
46
;;
47
+ armeb|armv[4-9]*b|aarch64_be)
48
+ echo "armeb"
49
+ ;;
50
sparc*)
51
echo "sparc"
52
;;
53
--
27
--
54
2.7.4
28
2.20.1
55
29
56
30
diff view generated by jsdifflib
1
From: Andrey Smirnov <andrew.smirnov@gmail.com>
1
From: Gan Qixin <ganqixin@huawei.com>
2
2
3
Frame truncation length, TRUNC_FL, is determined by the contents of
3
When running device-introspect-test, a memory leak occurred in the
4
ENET_FTRL register, so convert the code to use it instead of a
4
digic_timer_init function, so use ptimer_free() in the finalize function to
5
hardcoded constant.
5
avoid it.
6
6
7
To avoid the case where TRUNC_FL is greater that ENET_MAX_FRAME_SIZE,
7
ASAN shows memory leak stack:
8
increase the value of the latter to its theoretical maximum of 16K.
9
8
10
Cc: Peter Maydell <peter.maydell@linaro.org>
9
Indirect leak of 288 byte(s) in 3 object(s) allocated from:
11
Cc: Jason Wang <jasowang@redhat.com>
10
#0 0xffffab97e1f0 in __interceptor_calloc (/lib64/libasan.so.5+0xee1f0)
12
Cc: Philippe Mathieu-Daudé <f4bug@amsat.org>
11
#1 0xffffab256800 in g_malloc0 (/lib64/libglib-2.0.so.0+0x56800)
13
Cc: qemu-devel@nongnu.org
12
#2 0xaaabf555db78 in ptimer_init /qemu/hw/core/ptimer.c:432
14
Cc: qemu-arm@nongnu.org
13
#3 0xaaabf5b04084 in digic_timer_init /qemu/hw/timer/digic-timer.c:142
15
Cc: yurovsky@gmail.com
14
#4 0xaaabf6339f6c in object_initialize_with_type /qemu/qom/object.c:515
16
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
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>
17
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
26
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
18
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
27
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
19
---
28
---
20
include/hw/net/imx_fec.h | 3 ++-
29
hw/timer/digic-timer.c | 8 ++++++++
21
hw/net/imx_fec.c | 4 ++--
30
1 file changed, 8 insertions(+)
22
2 files changed, 4 insertions(+), 3 deletions(-)
23
31
24
diff --git a/include/hw/net/imx_fec.h b/include/hw/net/imx_fec.h
32
diff --git a/hw/timer/digic-timer.c b/hw/timer/digic-timer.c
25
index XXXXXXX..XXXXXXX 100644
33
index XXXXXXX..XXXXXXX 100644
26
--- a/include/hw/net/imx_fec.h
34
--- a/hw/timer/digic-timer.c
27
+++ b/include/hw/net/imx_fec.h
35
+++ b/hw/timer/digic-timer.c
28
@@ -XXX,XX +XXX,XX @@
36
@@ -XXX,XX +XXX,XX @@ static void digic_timer_init(Object *obj)
29
#define ENET_TCCR3 393
37
sysbus_init_mmio(SYS_BUS_DEVICE(obj), &s->iomem);
30
#define ENET_MAX 400
38
}
31
39
32
-#define ENET_MAX_FRAME_SIZE 2032
40
+static void digic_timer_finalize(Object *obj)
33
41
+{
34
/* EIR and EIMR */
42
+ DigicTimerState *s = DIGIC_TIMER(obj);
35
#define ENET_INT_HB (1 << 31)
36
@@ -XXX,XX +XXX,XX @@
37
#define ENET_RCR_NLC (1 << 30)
38
#define ENET_RCR_GRS (1 << 31)
39
40
+#define ENET_MAX_FRAME_SIZE (1 << ENET_RCR_MAX_FL_LENGTH)
41
+
43
+
42
/* TCR */
44
+ ptimer_free(s->ptimer);
43
#define ENET_TCR_GTS (1 << 0)
45
+}
44
#define ENET_TCR_FDEN (1 << 2)
46
+
45
diff --git a/hw/net/imx_fec.c b/hw/net/imx_fec.c
47
static void digic_timer_class_init(ObjectClass *klass, void *class_data)
46
index XXXXXXX..XXXXXXX 100644
48
{
47
--- a/hw/net/imx_fec.c
49
DeviceClass *dc = DEVICE_CLASS(klass);
48
+++ b/hw/net/imx_fec.c
50
@@ -XXX,XX +XXX,XX @@ static const TypeInfo digic_timer_info = {
49
@@ -XXX,XX +XXX,XX @@ static ssize_t imx_enet_receive(NetClientState *nc, const uint8_t *buf,
51
.parent = TYPE_SYS_BUS_DEVICE,
50
crc_ptr = (uint8_t *) &crc;
52
.instance_size = sizeof(DigicTimerState),
51
53
.instance_init = digic_timer_init,
52
/* Huge frames are truncted. */
54
+ .instance_finalize = digic_timer_finalize,
53
- if (size > ENET_MAX_FRAME_SIZE) {
55
.class_init = digic_timer_class_init,
54
- size = ENET_MAX_FRAME_SIZE;
56
};
55
+ if (size > s->regs[ENET_FTRL]) {
56
+ size = s->regs[ENET_FTRL];
57
flags |= ENET_BD_TR | ENET_BD_LG;
58
}
59
57
60
--
58
--
61
2.7.4
59
2.20.1
62
60
63
61
diff view generated by jsdifflib
1
From: Andrey Smirnov <andrew.smirnov@gmail.com>
1
From: Gan Qixin <ganqixin@huawei.com>
2
2
3
More recent version of the IP block support more than one Tx DMA ring,
3
When running device-introspect-test, a memory leak occurred in the a10_pit_init
4
so add the code implementing that feature.
4
function, so use ptimer_free() in the finalize function to avoid it.
5
5
6
Cc: Peter Maydell <peter.maydell@linaro.org>
6
ASAN shows memory leak stack:
7
Cc: Jason Wang <jasowang@redhat.com>
7
8
Cc: Philippe Mathieu-Daudé <f4bug@amsat.org>
8
Indirect leak of 288 byte(s) in 6 object(s) allocated from:
9
Cc: qemu-devel@nongnu.org
9
#0 0xffffab97e1f0 in __interceptor_calloc (/lib64/libasan.so.5+0xee1f0)
10
Cc: qemu-arm@nongnu.org
10
#1 0xffffab256800 in g_malloc0 (/lib64/libglib-2.0.so.0+0x56800)
11
Cc: yurovsky@gmail.com
11
#2 0xaaabf555db84 in timer_new_full /qemu/include/qemu/timer.h:523
12
#3 0xaaabf555db84 in timer_new /qemu/include/qemu/timer.h:544
13
#4 0xaaabf555db84 in timer_new_ns /qemu/include/qemu/timer.h:562
14
#5 0xaaabf555db84 in ptimer_init /qemu/hw/core/ptimer.c:433
15
#6 0xaaabf57415e8 in a10_pit_init /qemu/hw/timer/allwinner-a10-pit.c:278
16
#7 0xaaabf6339f6c in object_initialize_with_type /qemu/qom/object.c:515
17
#8 0xaaabf633ca04 in object_initialize_child_with_propsv /qemu/qom/object.c:564
18
#9 0xaaabf633cc08 in object_initialize_child_with_props /qemu/qom/object.c:547
19
#10 0xaaabf5b94680 in aw_a10_init /qemu/hw/arm/allwinner-a10.c:49
20
#11 0xaaabf6339f6c in object_initialize_with_type /qemu/qom/object.c:515
21
#12 0xaaabf633a1e0 in object_new_with_type /qemu/qom/object.c:729
22
23
Reported-by: Euler Robot <euler.robot@huawei.com>
24
Signed-off-by: Gan Qixin <ganqixin@huawei.com>
12
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
25
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
13
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
14
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
26
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
15
---
27
---
16
include/hw/net/imx_fec.h | 18 ++++++-
28
hw/timer/allwinner-a10-pit.c | 11 +++++++++++
17
hw/net/imx_fec.c | 133 ++++++++++++++++++++++++++++++++++++++++-------
29
1 file changed, 11 insertions(+)
18
2 files changed, 130 insertions(+), 21 deletions(-)
19
30
20
diff --git a/include/hw/net/imx_fec.h b/include/hw/net/imx_fec.h
31
diff --git a/hw/timer/allwinner-a10-pit.c b/hw/timer/allwinner-a10-pit.c
21
index XXXXXXX..XXXXXXX 100644
32
index XXXXXXX..XXXXXXX 100644
22
--- a/include/hw/net/imx_fec.h
33
--- a/hw/timer/allwinner-a10-pit.c
23
+++ b/include/hw/net/imx_fec.h
34
+++ b/hw/timer/allwinner-a10-pit.c
24
@@ -XXX,XX +XXX,XX @@
35
@@ -XXX,XX +XXX,XX @@ static void a10_pit_init(Object *obj)
25
#define ENET_TFWR 81
26
#define ENET_FRBR 83
27
#define ENET_FRSR 84
28
+#define ENET_TDSR1 89
29
+#define ENET_TDSR2 92
30
#define ENET_RDSR 96
31
#define ENET_TDSR 97
32
#define ENET_MRBR 98
33
@@ -XXX,XX +XXX,XX @@
34
#define ENET_FTRL 108
35
#define ENET_TACC 112
36
#define ENET_RACC 113
37
+#define ENET_TDAR1 121
38
+#define ENET_TDAR2 123
39
#define ENET_MIIGSK_CFGR 192
40
#define ENET_MIIGSK_ENR 194
41
#define ENET_ATCR 256
42
@@ -XXX,XX +XXX,XX @@
43
#define ENET_INT_WAKEUP (1 << 17)
44
#define ENET_INT_TS_AVAIL (1 << 16)
45
#define ENET_INT_TS_TIMER (1 << 15)
46
+#define ENET_INT_TXF2 (1 << 7)
47
+#define ENET_INT_TXB2 (1 << 6)
48
+#define ENET_INT_TXF1 (1 << 3)
49
+#define ENET_INT_TXB1 (1 << 2)
50
51
#define ENET_INT_MAC (ENET_INT_HB | ENET_INT_BABR | ENET_INT_BABT | \
52
ENET_INT_GRA | ENET_INT_TXF | ENET_INT_TXB | \
53
ENET_INT_RXF | ENET_INT_RXB | ENET_INT_MII | \
54
ENET_INT_EBERR | ENET_INT_LC | ENET_INT_RL | \
55
ENET_INT_UN | ENET_INT_PLR | ENET_INT_WAKEUP | \
56
- ENET_INT_TS_AVAIL)
57
+ ENET_INT_TS_AVAIL | ENET_INT_TXF1 | \
58
+ ENET_INT_TXB1 | ENET_INT_TXF2 | ENET_INT_TXB2)
59
60
/* RDAR */
61
#define ENET_RDAR_RDAR (1 << 24)
62
@@ -XXX,XX +XXX,XX @@ typedef struct {
63
64
#define ENET_BD_BDU (1 << 31)
65
66
+#define ENET_TX_RING_NUM 3
67
+
68
+
69
typedef struct IMXFECState {
70
/*< private >*/
71
SysBusDevice parent_obj;
72
@@ -XXX,XX +XXX,XX @@ typedef struct IMXFECState {
73
74
uint32_t regs[ENET_MAX];
75
uint32_t rx_descriptor;
76
- uint32_t tx_descriptor;
77
+
78
+ uint32_t tx_descriptor[ENET_TX_RING_NUM];
79
+ uint32_t tx_ring_num;
80
81
uint32_t phy_status;
82
uint32_t phy_control;
83
diff --git a/hw/net/imx_fec.c b/hw/net/imx_fec.c
84
index XXXXXXX..XXXXXXX 100644
85
--- a/hw/net/imx_fec.c
86
+++ b/hw/net/imx_fec.c
87
@@ -XXX,XX +XXX,XX @@ static const char *imx_eth_reg_name(IMXFECState *s, uint32_t index)
88
}
36
}
89
}
37
}
90
38
91
+/*
39
+static void a10_pit_finalize(Object *obj)
92
+ * Versions of this device with more than one TX descriptor save the
93
+ * 2nd and 3rd descriptors in a subsection, to maintain migration
94
+ * compatibility with previous versions of the device that only
95
+ * supported a single descriptor.
96
+ */
97
+static bool imx_eth_is_multi_tx_ring(void *opaque)
98
+{
40
+{
99
+ IMXFECState *s = IMX_FEC(opaque);
41
+ AwA10PITState *s = AW_A10_PIT(obj);
42
+ int i;
100
+
43
+
101
+ return s->tx_ring_num > 1;
44
+ for (i = 0; i < AW_A10_PIT_TIMER_NR; i++) {
45
+ ptimer_free(s->timer[i]);
46
+ }
102
+}
47
+}
103
+
48
+
104
+static const VMStateDescription vmstate_imx_eth_txdescs = {
49
static void a10_pit_class_init(ObjectClass *klass, void *data)
105
+ .name = "imx.fec/txdescs",
50
{
106
+ .version_id = 1,
51
DeviceClass *dc = DEVICE_CLASS(klass);
107
+ .minimum_version_id = 1,
52
@@ -XXX,XX +XXX,XX @@ static const TypeInfo a10_pit_info = {
108
+ .needed = imx_eth_is_multi_tx_ring,
53
.parent = TYPE_SYS_BUS_DEVICE,
109
+ .fields = (VMStateField[]) {
54
.instance_size = sizeof(AwA10PITState),
110
+ VMSTATE_UINT32(tx_descriptor[1], IMXFECState),
55
.instance_init = a10_pit_init,
111
+ VMSTATE_UINT32(tx_descriptor[2], IMXFECState),
56
+ .instance_finalize = a10_pit_finalize,
112
+ VMSTATE_END_OF_LIST()
57
.class_init = a10_pit_class_init,
113
+ }
114
+};
115
+
116
static const VMStateDescription vmstate_imx_eth = {
117
.name = TYPE_IMX_FEC,
118
.version_id = 2,
119
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_imx_eth = {
120
.fields = (VMStateField[]) {
121
VMSTATE_UINT32_ARRAY(regs, IMXFECState, ENET_MAX),
122
VMSTATE_UINT32(rx_descriptor, IMXFECState),
123
- VMSTATE_UINT32(tx_descriptor, IMXFECState),
124
-
125
+ VMSTATE_UINT32(tx_descriptor[0], IMXFECState),
126
VMSTATE_UINT32(phy_status, IMXFECState),
127
VMSTATE_UINT32(phy_control, IMXFECState),
128
VMSTATE_UINT32(phy_advertise, IMXFECState),
129
VMSTATE_UINT32(phy_int, IMXFECState),
130
VMSTATE_UINT32(phy_int_mask, IMXFECState),
131
VMSTATE_END_OF_LIST()
132
- }
133
+ },
134
+ .subsections = (const VMStateDescription * []) {
135
+ &vmstate_imx_eth_txdescs,
136
+ NULL
137
+ },
138
};
58
};
139
59
140
#define PHY_INT_ENERGYON (1 << 7)
141
@@ -XXX,XX +XXX,XX @@ static void imx_fec_do_tx(IMXFECState *s)
142
{
143
int frame_size = 0, descnt = 0;
144
uint8_t *ptr = s->frame;
145
- uint32_t addr = s->tx_descriptor;
146
+ uint32_t addr = s->tx_descriptor[0];
147
148
while (descnt++ < IMX_MAX_DESC) {
149
IMXFECBufDesc bd;
150
@@ -XXX,XX +XXX,XX @@ static void imx_fec_do_tx(IMXFECState *s)
151
}
152
}
153
154
- s->tx_descriptor = addr;
155
+ s->tx_descriptor[0] = addr;
156
157
imx_eth_update(s);
158
}
159
160
-static void imx_enet_do_tx(IMXFECState *s)
161
+static void imx_enet_do_tx(IMXFECState *s, uint32_t index)
162
{
163
int frame_size = 0, descnt = 0;
164
+
165
uint8_t *ptr = s->frame;
166
- uint32_t addr = s->tx_descriptor;
167
+ uint32_t addr, int_txb, int_txf, tdsr;
168
+ size_t ring;
169
+
170
+ switch (index) {
171
+ case ENET_TDAR:
172
+ ring = 0;
173
+ int_txb = ENET_INT_TXB;
174
+ int_txf = ENET_INT_TXF;
175
+ tdsr = ENET_TDSR;
176
+ break;
177
+ case ENET_TDAR1:
178
+ ring = 1;
179
+ int_txb = ENET_INT_TXB1;
180
+ int_txf = ENET_INT_TXF1;
181
+ tdsr = ENET_TDSR1;
182
+ break;
183
+ case ENET_TDAR2:
184
+ ring = 2;
185
+ int_txb = ENET_INT_TXB2;
186
+ int_txf = ENET_INT_TXF2;
187
+ tdsr = ENET_TDSR2;
188
+ break;
189
+ default:
190
+ qemu_log_mask(LOG_GUEST_ERROR,
191
+ "%s: bogus value for index %x\n",
192
+ __func__, index);
193
+ abort();
194
+ break;
195
+ }
196
+
197
+ addr = s->tx_descriptor[ring];
198
199
while (descnt++ < IMX_MAX_DESC) {
200
IMXENETBufDesc bd;
201
@@ -XXX,XX +XXX,XX @@ static void imx_enet_do_tx(IMXFECState *s)
202
203
frame_size = 0;
204
if (bd.option & ENET_BD_TX_INT) {
205
- s->regs[ENET_EIR] |= ENET_INT_TXF;
206
+ s->regs[ENET_EIR] |= int_txf;
207
}
208
}
209
if (bd.option & ENET_BD_TX_INT) {
210
- s->regs[ENET_EIR] |= ENET_INT_TXB;
211
+ s->regs[ENET_EIR] |= int_txb;
212
}
213
bd.flags &= ~ENET_BD_R;
214
/* Write back the modified descriptor. */
215
imx_enet_write_bd(&bd, addr);
216
/* Advance to the next descriptor. */
217
if ((bd.flags & ENET_BD_W) != 0) {
218
- addr = s->regs[ENET_TDSR];
219
+ addr = s->regs[tdsr];
220
} else {
221
addr += sizeof(bd);
222
}
223
}
224
225
- s->tx_descriptor = addr;
226
+ s->tx_descriptor[ring] = addr;
227
228
imx_eth_update(s);
229
}
230
231
-static void imx_eth_do_tx(IMXFECState *s)
232
+static void imx_eth_do_tx(IMXFECState *s, uint32_t index)
233
{
234
if (!s->is_fec && (s->regs[ENET_ECR] & ENET_ECR_EN1588)) {
235
- imx_enet_do_tx(s);
236
+ imx_enet_do_tx(s, index);
237
} else {
238
imx_fec_do_tx(s);
239
}
240
@@ -XXX,XX +XXX,XX @@ static void imx_eth_reset(DeviceState *d)
241
}
242
243
s->rx_descriptor = 0;
244
- s->tx_descriptor = 0;
245
+ memset(s->tx_descriptor, 0, sizeof(s->tx_descriptor));
246
247
/* We also reset the PHY */
248
phy_reset(s);
249
@@ -XXX,XX +XXX,XX @@ static void imx_eth_write(void *opaque, hwaddr offset, uint64_t value,
250
unsigned size)
251
{
252
IMXFECState *s = IMX_FEC(opaque);
253
+ const bool single_tx_ring = !imx_eth_is_multi_tx_ring(s);
254
uint32_t index = offset >> 2;
255
256
FEC_PRINTF("reg[%s] <= 0x%" PRIx32 "\n", imx_eth_reg_name(s, index),
257
@@ -XXX,XX +XXX,XX @@ static void imx_eth_write(void *opaque, hwaddr offset, uint64_t value,
258
s->regs[index] = 0;
259
}
260
break;
261
- case ENET_TDAR:
262
+ case ENET_TDAR1: /* FALLTHROUGH */
263
+ case ENET_TDAR2: /* FALLTHROUGH */
264
+ if (unlikely(single_tx_ring)) {
265
+ qemu_log_mask(LOG_GUEST_ERROR,
266
+ "[%s]%s: trying to access TDAR2 or TDAR1\n",
267
+ TYPE_IMX_FEC, __func__);
268
+ return;
269
+ }
270
+ case ENET_TDAR: /* FALLTHROUGH */
271
if (s->regs[ENET_ECR] & ENET_ECR_ETHEREN) {
272
s->regs[index] = ENET_TDAR_TDAR;
273
- imx_eth_do_tx(s);
274
+ imx_eth_do_tx(s, index);
275
}
276
s->regs[index] = 0;
277
break;
278
@@ -XXX,XX +XXX,XX @@ static void imx_eth_write(void *opaque, hwaddr offset, uint64_t value,
279
if ((s->regs[index] & ENET_ECR_ETHEREN) == 0) {
280
s->regs[ENET_RDAR] = 0;
281
s->rx_descriptor = s->regs[ENET_RDSR];
282
- s->regs[ENET_TDAR] = 0;
283
- s->tx_descriptor = s->regs[ENET_TDSR];
284
+ s->regs[ENET_TDAR] = 0;
285
+ s->regs[ENET_TDAR1] = 0;
286
+ s->regs[ENET_TDAR2] = 0;
287
+ s->tx_descriptor[0] = s->regs[ENET_TDSR];
288
+ s->tx_descriptor[1] = s->regs[ENET_TDSR1];
289
+ s->tx_descriptor[2] = s->regs[ENET_TDSR2];
290
}
291
break;
292
case ENET_MMFR:
293
@@ -XXX,XX +XXX,XX @@ static void imx_eth_write(void *opaque, hwaddr offset, uint64_t value,
294
} else {
295
s->regs[index] = value & ~7;
296
}
297
- s->tx_descriptor = s->regs[index];
298
+ s->tx_descriptor[0] = s->regs[index];
299
+ break;
300
+ case ENET_TDSR1:
301
+ if (unlikely(single_tx_ring)) {
302
+ qemu_log_mask(LOG_GUEST_ERROR,
303
+ "[%s]%s: trying to access TDSR1\n",
304
+ TYPE_IMX_FEC, __func__);
305
+ return;
306
+ }
307
+
308
+ s->regs[index] = value & ~7;
309
+ s->tx_descriptor[1] = s->regs[index];
310
+ break;
311
+ case ENET_TDSR2:
312
+ if (unlikely(single_tx_ring)) {
313
+ qemu_log_mask(LOG_GUEST_ERROR,
314
+ "[%s]%s: trying to access TDSR2\n",
315
+ TYPE_IMX_FEC, __func__);
316
+ return;
317
+ }
318
+
319
+ s->regs[index] = value & ~7;
320
+ s->tx_descriptor[2] = s->regs[index];
321
break;
322
case ENET_MRBR:
323
s->regs[index] = value & 0x00003ff0;
324
@@ -XXX,XX +XXX,XX @@ static void imx_eth_realize(DeviceState *dev, Error **errp)
325
326
static Property imx_eth_properties[] = {
327
DEFINE_NIC_PROPERTIES(IMXFECState, conf),
328
+ DEFINE_PROP_UINT32("tx-ring-num", IMXFECState, tx_ring_num, 1),
329
DEFINE_PROP_END_OF_LIST(),
330
};
331
332
--
60
--
333
2.7.4
61
2.20.1
334
62
335
63
diff view generated by jsdifflib
1
Our copy of the nwfpe code for emulating of the old FPA11 floating
1
From: Gan Qixin <ganqixin@huawei.com>
2
point unit doesn't check the coprocessor number in the instruction
3
when it emulates it. This means that we might treat some
4
instructions which should really UNDEF as being FPA11 instructions by
5
accident.
6
2
7
The kernel's copy of the nwfpe code doesn't make this error; I suspect
3
When running device-introspect-test, a memory leak occurred in the
8
the bug was noticed and fixed as part of the process of mainlining
4
exynos4210_rtc_init function, so use ptimer_free() in the finalize function to
9
the nwfpe code more than a decade ago.
5
avoid it.
10
6
11
Add a check that the coprocessor number (which is always in bits
7
ASAN shows memory leak stack:
12
[11:8] of the instruction) is either 1 or 2, which is where the
13
FPA11 lives.
14
8
15
Reported-by: Richard Henderson <richard.henderson@linaro.org>
9
Indirect leak of 96 byte(s) in 1 object(s) allocated from:
10
#0 0xffffab97e1f0 in __interceptor_calloc (/lib64/libasan.so.5+0xee1f0)
11
#1 0xffffab256800 in g_malloc0 (/lib64/libglib-2.0.so.0+0x56800)
12
#2 0xaaabf555db78 in ptimer_init /qemu/hw/core/ptimer.c:432
13
#3 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>
16
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
27
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
17
---
28
---
18
linux-user/arm/nwfpe/fpa11.c | 9 +++++++++
29
hw/rtc/exynos4210_rtc.c | 9 +++++++++
19
1 file changed, 9 insertions(+)
30
1 file changed, 9 insertions(+)
20
31
21
diff --git a/linux-user/arm/nwfpe/fpa11.c b/linux-user/arm/nwfpe/fpa11.c
32
diff --git a/hw/rtc/exynos4210_rtc.c b/hw/rtc/exynos4210_rtc.c
22
index XXXXXXX..XXXXXXX 100644
33
index XXXXXXX..XXXXXXX 100644
23
--- a/linux-user/arm/nwfpe/fpa11.c
34
--- a/hw/rtc/exynos4210_rtc.c
24
+++ b/linux-user/arm/nwfpe/fpa11.c
35
+++ b/hw/rtc/exynos4210_rtc.c
25
@@ -XXX,XX +XXX,XX @@ unsigned int EmulateAll(unsigned int opcode, FPA11* qfpa, CPUARMState* qregs)
36
@@ -XXX,XX +XXX,XX @@ static void exynos4210_rtc_init(Object *obj)
26
unsigned int nRc = 0;
37
sysbus_init_mmio(dev, &s->iomem);
27
// unsigned long flags;
38
}
28
FPA11 *fpa11;
39
29
+ unsigned int cp;
40
+static void exynos4210_rtc_finalize(Object *obj)
30
// save_flags(flags); sti();
41
+{
31
42
+ Exynos4210RTCState *s = EXYNOS4210_RTC(obj);
32
+ /* Check that this is really an FPA11 instruction: the coprocessor
33
+ * field in bits [11:8] must be 1 or 2.
34
+ */
35
+ cp = (opcode >> 8) & 0xf;
36
+ if (cp != 1 && cp != 2) {
37
+ return 0;
38
+ }
39
+
43
+
40
qemufpa=qfpa;
44
+ ptimer_free(s->ptimer);
41
user_registers=qregs;
45
+ ptimer_free(s->ptimer_1Hz);
46
+}
47
+
48
static void exynos4210_rtc_class_init(ObjectClass *klass, void *data)
49
{
50
DeviceClass *dc = DEVICE_CLASS(klass);
51
@@ -XXX,XX +XXX,XX @@ static const TypeInfo exynos4210_rtc_info = {
52
.parent = TYPE_SYS_BUS_DEVICE,
53
.instance_size = sizeof(Exynos4210RTCState),
54
.instance_init = exynos4210_rtc_init,
55
+ .instance_finalize = exynos4210_rtc_finalize,
56
.class_init = exynos4210_rtc_class_init,
57
};
42
58
43
--
59
--
44
2.7.4
60
2.20.1
45
61
46
62
diff view generated by jsdifflib
1
From: Andrey Smirnov <andrew.smirnov@gmail.com>
1
From: Gan Qixin <ganqixin@huawei.com>
2
2
3
Cc: Peter Maydell <peter.maydell@linaro.org>
3
When running device-introspect-test, a memory leak occurred in the
4
Cc: Jason Wang <jasowang@redhat.com>
4
exynos4210_pwm_init function, so use ptimer_free() in the finalize function to
5
Cc: Philippe Mathieu-Daudé <f4bug@amsat.org>
5
avoid it.
6
Cc: qemu-devel@nongnu.org
6
7
Cc: qemu-arm@nongnu.org
7
ASAN shows memory leak stack:
8
Cc: yurovsky@gmail.com
8
9
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
9
Indirect leak of 240 byte(s) in 5 object(s) allocated from:
10
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
10
#0 0xffffab97e1f0 in __interceptor_calloc (/lib64/libasan.so.5+0xee1f0)
11
#1 0xffffab256800 in g_malloc0 (/lib64/libglib-2.0.so.0+0x56800)
12
#2 0xaaabf555db84 in timer_new_full /qemu/include/qemu/timer.h:523
13
#3 0xaaabf555db84 in timer_new /qemu/include/qemu/timer.h:544
14
#4 0xaaabf555db84 in timer_new_ns /qemu/include/qemu/timer.h:562
15
#5 0xaaabf555db84 in ptimer_init /qemu/hw/core/ptimer.c:433
16
#6 0xaaabf56a36cc in exynos4210_pwm_init /qemu/hw/timer/exynos4210_pwm.c:401
17
#7 0xaaabf6339f6c in object_initialize_with_type /qemu/qom/object.c:515
18
#8 0xaaabf633a1e0 in object_new_with_type /qemu/qom/object.c:729
19
#9 0xaaabf6375e40 in qmp_device_list_properties /qemu/qom/qom-qmp-cmds.c:153
20
#10 0xaaabf653d8ec in qmp_marshal_device_list_properties /qemu/qapi/qapi-commands-qdev.c:59
21
#11 0xaaabf6587d08 in do_qmp_dispatch_bh /qemu/qapi/qmp-dispatch.c:110
22
#12 0xaaabf6552708 in aio_bh_call /qemu/util/async.c:136
23
24
Reported-by: Euler Robot <euler.robot@huawei.com>
25
Signed-off-by: Gan Qixin <ganqixin@huawei.com>
26
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
27
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
---
28
---
13
hw/net/imx_fec.c | 2 +-
29
hw/timer/exynos4210_pwm.c | 11 +++++++++++
14
1 file changed, 1 insertion(+), 1 deletion(-)
30
1 file changed, 11 insertions(+)
15
31
16
diff --git a/hw/net/imx_fec.c b/hw/net/imx_fec.c
32
diff --git a/hw/timer/exynos4210_pwm.c b/hw/timer/exynos4210_pwm.c
17
index XXXXXXX..XXXXXXX 100644
33
index XXXXXXX..XXXXXXX 100644
18
--- a/hw/net/imx_fec.c
34
--- a/hw/timer/exynos4210_pwm.c
19
+++ b/hw/net/imx_fec.c
35
+++ b/hw/timer/exynos4210_pwm.c
20
@@ -XXX,XX +XXX,XX @@ static ssize_t imx_enet_receive(NetClientState *nc, const uint8_t *buf,
36
@@ -XXX,XX +XXX,XX @@ static void exynos4210_pwm_init(Object *obj)
21
TYPE_IMX_FEC, __func__);
37
sysbus_init_mmio(dev, &s->iomem);
22
break;
38
}
23
}
39
24
- buf_len = (size <= s->regs[ENET_MRBR]) ? size : s->regs[ENET_MRBR];
40
+static void exynos4210_pwm_finalize(Object *obj)
25
+ buf_len = MIN(size, s->regs[ENET_MRBR]);
41
+{
26
bd.length = buf_len;
42
+ Exynos4210PWMState *s = EXYNOS4210_PWM(obj);
27
size -= buf_len;
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)
51
{
52
DeviceClass *dc = DEVICE_CLASS(klass);
53
@@ -XXX,XX +XXX,XX @@ static const TypeInfo exynos4210_pwm_info = {
54
.parent = TYPE_SYS_BUS_DEVICE,
55
.instance_size = sizeof(Exynos4210PWMState),
56
.instance_init = exynos4210_pwm_init,
57
+ .instance_finalize = exynos4210_pwm_finalize,
58
.class_init = exynos4210_pwm_class_init,
59
};
28
60
29
--
61
--
30
2.7.4
62
2.20.1
31
63
32
64
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
1
From: Gan Qixin <ganqixin@huawei.com>
2
2
3
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
3
When running device-introspect-test, a memory leak occurred in the
4
Reviewed-by: Alistair Francis <alistair.francis@xilinx.com>
4
mss_timer_init function, so use ptimer_free() in the finalize function to avoid
5
Message-id: 20180104000156.30932-1-f4bug@amsat.org
5
it.
6
[PMM: add missing include]
6
7
ASAN shows memory leak stack:
8
9
Indirect leak of 192 byte(s) in 2 object(s) allocated from:
10
#0 0xffffab97e1f0 in __interceptor_calloc (/lib64/libasan.so.5+0xee1f0)
11
#1 0xffffab256800 in g_malloc0 (/lib64/libglib-2.0.so.0+0x56800)
12
#2 0xaaabf555db78 in ptimer_init /qemu/hw/core/ptimer.c:432
13
#3 0xaaabf58a0010 in mss_timer_init /qemu/hw/timer/mss-timer.c:235
14
#4 0xaaabf6339f6c in object_initialize_with_type /qemu/qom/object.c:515
15
#5 0xaaabf633ca04 in object_initialize_child_with_propsv /qemu/qom/object.c:564
16
#6 0xaaabf633cc08 in object_initialize_child_with_props /qemu/qom/object.c:547
17
#7 0xaaabf5b8316c in m2sxxx_soc_initfn /qemu/hw/arm/msf2-soc.c:70
18
#8 0xaaabf6339f6c in object_initialize_with_type /qemu/qom/object.c:515
19
#9 0xaaabf633a1e0 in object_new_with_type /qemu/qom/object.c:729
20
#10 0xaaabf6375e40 in qmp_device_list_properties /qemu/qom/qom-qmp-cmds.c:153
21
#11 0xaaabf653d8ec in qmp_marshal_device_list_properties /qemu/qapi/qapi-commands-qdev.c:59
22
#12 0xaaabf6587d08 in do_qmp_dispatch_bh /qemu/qapi/qmp-dispatch.c:110
23
24
Reported-by: Euler Robot <euler.robot@huawei.com>
25
Signed-off-by: Gan Qixin <ganqixin@huawei.com>
26
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
27
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
---
28
---
9
hw/sd/pxa2xx_mmci.c | 78 ++++++++++++++++++++++++++++++++++-------------------
29
hw/timer/mss-timer.c | 13 +++++++++++++
10
hw/sd/trace-events | 4 +++
30
1 file changed, 13 insertions(+)
11
2 files changed, 54 insertions(+), 28 deletions(-)
12
31
13
diff --git a/hw/sd/pxa2xx_mmci.c b/hw/sd/pxa2xx_mmci.c
32
diff --git a/hw/timer/mss-timer.c b/hw/timer/mss-timer.c
14
index XXXXXXX..XXXXXXX 100644
33
index XXXXXXX..XXXXXXX 100644
15
--- a/hw/sd/pxa2xx_mmci.c
34
--- a/hw/timer/mss-timer.c
16
+++ b/hw/sd/pxa2xx_mmci.c
35
+++ b/hw/timer/mss-timer.c
17
@@ -XXX,XX +XXX,XX @@
36
@@ -XXX,XX +XXX,XX @@ static void mss_timer_init(Object *obj)
18
#include "hw/qdev.h"
37
sysbus_init_mmio(SYS_BUS_DEVICE(obj), &t->mmio);
19
#include "hw/qdev-properties.h"
20
#include "qemu/error-report.h"
21
+#include "qemu/log.h"
22
+#include "trace.h"
23
24
#define TYPE_PXA2XX_MMCI "pxa2xx-mmci"
25
#define PXA2XX_MMCI(obj) OBJECT_CHECK(PXA2xxMMCIState, (obj), TYPE_PXA2XX_MMCI)
26
@@ -XXX,XX +XXX,XX @@ static void pxa2xx_mmci_wakequeues(PXA2xxMMCIState *s)
27
static uint64_t pxa2xx_mmci_read(void *opaque, hwaddr offset, unsigned size)
28
{
29
PXA2xxMMCIState *s = (PXA2xxMMCIState *) opaque;
30
- uint32_t ret;
31
+ uint32_t ret = 0;
32
33
switch (offset) {
34
case MMC_STRPCL:
35
- return 0;
36
+ break;
37
case MMC_STAT:
38
- return s->status;
39
+ ret = s->status;
40
+ break;
41
case MMC_CLKRT:
42
- return s->clkrt;
43
+ ret = s->clkrt;
44
+ break;
45
case MMC_SPI:
46
- return s->spi;
47
+ ret = s->spi;
48
+ break;
49
case MMC_CMDAT:
50
- return s->cmdat;
51
+ ret = s->cmdat;
52
+ break;
53
case MMC_RESTO:
54
- return s->resp_tout;
55
+ ret = s->resp_tout;
56
+ break;
57
case MMC_RDTO:
58
- return s->read_tout;
59
+ ret = s->read_tout;
60
+ break;
61
case MMC_BLKLEN:
62
- return s->blklen;
63
+ ret = s->blklen;
64
+ break;
65
case MMC_NUMBLK:
66
- return s->numblk;
67
+ ret = s->numblk;
68
+ break;
69
case MMC_PRTBUF:
70
- return 0;
71
+ break;
72
case MMC_I_MASK:
73
- return s->intmask;
74
+ ret = s->intmask;
75
+ break;
76
case MMC_I_REG:
77
- return s->intreq;
78
+ ret = s->intreq;
79
+ break;
80
case MMC_CMD:
81
- return s->cmd | 0x40;
82
+ ret = s->cmd | 0x40;
83
+ break;
84
case MMC_ARGH:
85
- return s->arg >> 16;
86
+ ret = s->arg >> 16;
87
+ break;
88
case MMC_ARGL:
89
- return s->arg & 0xffff;
90
+ ret = s->arg & 0xffff;
91
+ break;
92
case MMC_RES:
93
- if (s->resp_len < 9)
94
- return s->resp_fifo[s->resp_len ++];
95
- return 0;
96
+ ret = (s->resp_len < 9) ? s->resp_fifo[s->resp_len++] : 0;
97
+ break;
98
case MMC_RXFIFO:
99
- ret = 0;
100
while (size-- && s->rx_len) {
101
ret |= s->rx_fifo[s->rx_start++] << (size << 3);
102
s->rx_start &= 0x1f;
103
@@ -XXX,XX +XXX,XX @@ static uint64_t pxa2xx_mmci_read(void *opaque, hwaddr offset, unsigned size)
104
}
105
s->intreq &= ~INT_RXFIFO_REQ;
106
pxa2xx_mmci_fifo_update(s);
107
- return ret;
108
+ break;
109
case MMC_RDWAIT:
110
- return 0;
111
+ break;
112
case MMC_BLKS_REM:
113
- return s->numblk;
114
+ ret = s->numblk;
115
+ break;
116
default:
117
- hw_error("%s: Bad offset " REG_FMT "\n", __FUNCTION__, offset);
118
+ qemu_log_mask(LOG_GUEST_ERROR,
119
+ "%s: incorrect register 0x%02" HWADDR_PRIx "\n",
120
+ __func__, offset);
121
}
122
+ trace_pxa2xx_mmci_read(size, offset, ret);
123
124
- return 0;
125
+ return ret;
126
}
38
}
127
39
128
static void pxa2xx_mmci_write(void *opaque,
40
+static void mss_timer_finalize(Object *obj)
129
@@ -XXX,XX +XXX,XX @@ static void pxa2xx_mmci_write(void *opaque,
41
+{
130
{
42
+ MSSTimerState *t = MSS_TIMER(obj);
131
PXA2xxMMCIState *s = (PXA2xxMMCIState *) opaque;
43
+ int i;
132
133
+ trace_pxa2xx_mmci_write(size, offset, value);
134
switch (offset) {
135
case MMC_STRPCL:
136
if (value & STRPCL_STRT_CLK) {
137
@@ -XXX,XX +XXX,XX @@ static void pxa2xx_mmci_write(void *opaque,
138
139
case MMC_SPI:
140
s->spi = value & 0xf;
141
- if (value & SPI_SPI_MODE)
142
- printf("%s: attempted to use card in SPI mode\n", __FUNCTION__);
143
+ if (value & SPI_SPI_MODE) {
144
+ qemu_log_mask(LOG_GUEST_ERROR,
145
+ "%s: attempted to use card in SPI mode\n", __func__);
146
+ }
147
break;
148
149
case MMC_CMDAT:
150
@@ -XXX,XX +XXX,XX @@ static void pxa2xx_mmci_write(void *opaque,
151
break;
152
153
default:
154
- hw_error("%s: Bad offset " REG_FMT "\n", __FUNCTION__, offset);
155
+ qemu_log_mask(LOG_GUEST_ERROR,
156
+ "%s: incorrect reg 0x%02" HWADDR_PRIx " "
157
+ "(value 0x%08" PRIx64 ")\n", __func__, offset, value);
158
}
159
}
160
161
diff --git a/hw/sd/trace-events b/hw/sd/trace-events
162
index XXXXXXX..XXXXXXX 100644
163
--- a/hw/sd/trace-events
164
+++ b/hw/sd/trace-events
165
@@ -XXX,XX +XXX,XX @@
166
# hw/sd/milkymist-memcard.c
167
milkymist_memcard_memory_read(uint32_t addr, uint32_t value) "addr 0x%08x value 0x%08x"
168
milkymist_memcard_memory_write(uint32_t addr, uint32_t value) "addr 0x%08x value 0x%08x"
169
+
44
+
170
+# hw/sd/pxa2xx_mmci.c
45
+ for (i = 0; i < NUM_TIMERS; i++) {
171
+pxa2xx_mmci_read(uint8_t size, uint32_t addr, uint32_t value) "size %d addr 0x%02x value 0x%08x"
46
+ struct Msf2Timer *st = &t->timers[i];
172
+pxa2xx_mmci_write(uint8_t size, uint32_t addr, uint32_t value) "size %d addr 0x%02x value 0x%08x"
47
+
48
+ ptimer_free(st->ptimer);
49
+ }
50
+}
51
+
52
static const VMStateDescription vmstate_timers = {
53
.name = "mss-timer-block",
54
.version_id = 1,
55
@@ -XXX,XX +XXX,XX @@ static const TypeInfo mss_timer_info = {
56
.parent = TYPE_SYS_BUS_DEVICE,
57
.instance_size = sizeof(MSSTimerState),
58
.instance_init = mss_timer_init,
59
+ .instance_finalize = mss_timer_finalize,
60
.class_init = mss_timer_class_init,
61
};
62
173
--
63
--
174
2.7.4
64
2.20.1
175
65
176
66
diff view generated by jsdifflib
1
From: Andrey Smirnov <andrew.smirnov@gmail.com>
1
From: Gan Qixin <ganqixin@huawei.com>
2
2
3
Refactor imx_eth_enable_rx() to have more meaningfull variable name
3
When running device-introspect-test, a memory leak occurred in the
4
than 'tmp' and to reduce number of logical negations done.
4
mv88w8618_pit_init function, so use ptimer_free() in the finalize function to
5
avoid it.
5
6
6
Cc: Peter Maydell <peter.maydell@linaro.org>
7
ASAN shows memory leak stack:
7
Cc: Jason Wang <jasowang@redhat.com>
8
8
Cc: Philippe Mathieu-Daudé <f4bug@amsat.org>
9
Indirect leak of 192 byte(s) in 4 object(s) allocated from:
9
Cc: qemu-devel@nongnu.org
10
#0 0xffffab97e1f0 in __interceptor_calloc (/lib64/libasan.so.5+0xee1f0)
10
Cc: qemu-arm@nongnu.org
11
#1 0xffffab256800 in g_malloc0 (/lib64/libglib-2.0.so.0+0x56800)
11
Cc: yurovsky@gmail.com
12
#2 0xaaabf555db84 in timer_new_full /qemu/include/qemu/timer.h:523
12
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
13
#3 0xaaabf555db84 in timer_new /qemu/include/qemu/timer.h:544
14
#4 0xaaabf555db84 in timer_new_ns /qemu/include/qemu/timer.h:562
15
#5 0xaaabf555db84 in ptimer_init /qemu/hw/core/ptimer.c:433
16
#6 0xaaabf5bb2290 in mv88w8618_timer_init /qemu/hw/arm/musicpal.c:862
17
#7 0xaaabf5bb2290 in mv88w8618_pit_init /qemu/hw/arm/musicpal.c:954
18
#8 0xaaabf6339f6c in object_initialize_with_type /qemu/qom/object.c:515
19
#9 0xaaabf633a1e0 in object_new_with_type /qemu/qom/object.c:729
20
#10 0xaaabf6375e40 in qmp_device_list_properties /qemu/qom/qom-qmp-cmds.c:153
21
#11 0xaaabf5a95540 in qdev_device_help /qemu/softmmu/qdev-monitor.c:283
22
#12 0xaaabf5a96940 in qmp_device_add /qemu/softmmu/qdev-monitor.c:801
23
24
Reported-by: Euler Robot <euler.robot@huawei.com>
25
Signed-off-by: Gan Qixin <ganqixin@huawei.com>
13
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
26
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
14
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
15
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
27
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
16
---
28
---
17
hw/net/imx_fec.c | 8 ++++----
29
hw/arm/musicpal.c | 12 ++++++++++++
18
1 file changed, 4 insertions(+), 4 deletions(-)
30
1 file changed, 12 insertions(+)
19
31
20
diff --git a/hw/net/imx_fec.c b/hw/net/imx_fec.c
32
diff --git a/hw/arm/musicpal.c b/hw/arm/musicpal.c
21
index XXXXXXX..XXXXXXX 100644
33
index XXXXXXX..XXXXXXX 100644
22
--- a/hw/net/imx_fec.c
34
--- a/hw/arm/musicpal.c
23
+++ b/hw/net/imx_fec.c
35
+++ b/hw/arm/musicpal.c
24
@@ -XXX,XX +XXX,XX @@ static void imx_eth_do_tx(IMXFECState *s)
36
@@ -XXX,XX +XXX,XX @@ static void mv88w8618_pit_init(Object *obj)
25
static void imx_eth_enable_rx(IMXFECState *s)
37
sysbus_init_mmio(dev, &s->iomem);
26
{
27
IMXFECBufDesc bd;
28
- bool tmp;
29
+ bool rx_ring_full;
30
31
imx_fec_read_bd(&bd, s->rx_descriptor);
32
33
- tmp = ((bd.flags & ENET_BD_E) != 0);
34
+ rx_ring_full = !(bd.flags & ENET_BD_E);
35
36
- if (!tmp) {
37
+ if (rx_ring_full) {
38
FEC_PRINTF("RX buffer full\n");
39
} else if (!s->regs[ENET_RDAR]) {
40
qemu_flush_queued_packets(qemu_get_queue(s->nic));
41
}
42
43
- s->regs[ENET_RDAR] = tmp ? ENET_RDAR_RDAR : 0;
44
+ s->regs[ENET_RDAR] = rx_ring_full ? 0 : ENET_RDAR_RDAR;
45
}
38
}
46
39
47
static void imx_eth_reset(DeviceState *d)
40
+static void mv88w8618_pit_finalize(Object *obj)
41
+{
42
+ SysBusDevice *dev = SYS_BUS_DEVICE(obj);
43
+ mv88w8618_pit_state *s = MV88W8618_PIT(dev);
44
+ int i;
45
+
46
+ for (i = 0; i < 4; i++) {
47
+ ptimer_free(s->timer[i].ptimer);
48
+ }
49
+}
50
+
51
static const VMStateDescription mv88w8618_timer_vmsd = {
52
.name = "timer",
53
.version_id = 1,
54
@@ -XXX,XX +XXX,XX @@ static const TypeInfo mv88w8618_pit_info = {
55
.parent = TYPE_SYS_BUS_DEVICE,
56
.instance_size = sizeof(mv88w8618_pit_state),
57
.instance_init = mv88w8618_pit_init,
58
+ .instance_finalize = mv88w8618_pit_finalize,
59
.class_init = mv88w8618_pit_class_init,
60
};
61
48
--
62
--
49
2.7.4
63
2.20.1
50
64
51
65
diff view generated by jsdifflib
1
From: Andrey Smirnov <andrew.smirnov@gmail.com>
1
From: Gan Qixin <ganqixin@huawei.com>
2
2
3
Make Tx frame assembly buffer to be a paort of IMXFECState structure
3
When running device-introspect-test, a memory leak occurred in the
4
to avoid a concern about having large data buffer on the stack.
4
exynos4210_mct_init function, so use ptimer_free() in the finalize function to
5
avoid it.
5
6
6
Cc: Peter Maydell <peter.maydell@linaro.org>
7
ASAN shows memory leak stack:
7
Cc: Jason Wang <jasowang@redhat.com>
8
8
Cc: Philippe Mathieu-Daudé <f4bug@amsat.org>
9
Indirect leak of 96 byte(s) in 1 object(s) allocated from:
9
Cc: qemu-devel@nongnu.org
10
#0 0xffffab97e1f0 in __interceptor_calloc (/lib64/libasan.so.5+0xee1f0)
10
Cc: qemu-arm@nongnu.org
11
#1 0xffffab256800 in g_malloc0 (/lib64/libglib-2.0.so.0+0x56800)
11
Cc: yurovsky@gmail.com
12
#2 0xaaabf555db78 in ptimer_init /qemu/hw/core/ptimer.c:432
12
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
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>
13
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
26
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
14
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
27
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
15
---
28
---
16
include/hw/net/imx_fec.h | 3 +++
29
hw/timer/exynos4210_mct.c | 14 ++++++++++++++
17
hw/net/imx_fec.c | 22 +++++++++++-----------
30
1 file changed, 14 insertions(+)
18
2 files changed, 14 insertions(+), 11 deletions(-)
19
31
20
diff --git a/include/hw/net/imx_fec.h b/include/hw/net/imx_fec.h
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/include/hw/net/imx_fec.h
34
--- a/hw/timer/exynos4210_mct.c
23
+++ b/include/hw/net/imx_fec.h
35
+++ b/hw/timer/exynos4210_mct.c
24
@@ -XXX,XX +XXX,XX @@ typedef struct IMXFECState {
36
@@ -XXX,XX +XXX,XX @@ static void exynos4210_mct_init(Object *obj)
25
uint32_t phy_int_mask;
37
sysbus_init_mmio(dev, &s->iomem);
26
38
}
27
bool is_fec;
39
40
+static void exynos4210_mct_finalize(Object *obj)
41
+{
42
+ int i;
43
+ Exynos4210MCTState *s = EXYNOS4210_MCT(obj);
28
+
44
+
29
+ /* Buffer used to assemble a Tx frame */
45
+ ptimer_free(s->g_timer.ptimer_frc);
30
+ uint8_t frame[ENET_MAX_FRAME_SIZE];
46
+
31
} IMXFECState;
47
+ for (i = 0; i < 2; i++) {
32
48
+ ptimer_free(s->l_timer[i].tick_timer.ptimer_tick);
33
#endif
49
+ ptimer_free(s->l_timer[i].ptimer_frc);
34
diff --git a/hw/net/imx_fec.c b/hw/net/imx_fec.c
50
+ }
35
index XXXXXXX..XXXXXXX 100644
51
+}
36
--- a/hw/net/imx_fec.c
52
+
37
+++ b/hw/net/imx_fec.c
53
static void exynos4210_mct_class_init(ObjectClass *klass, void *data)
38
@@ -XXX,XX +XXX,XX @@ static void imx_eth_update(IMXFECState *s)
39
static void imx_fec_do_tx(IMXFECState *s)
40
{
54
{
41
int frame_size = 0, descnt = 0;
55
DeviceClass *dc = DEVICE_CLASS(klass);
42
- uint8_t frame[ENET_MAX_FRAME_SIZE];
56
@@ -XXX,XX +XXX,XX @@ static const TypeInfo exynos4210_mct_info = {
43
- uint8_t *ptr = frame;
57
.parent = TYPE_SYS_BUS_DEVICE,
44
+ uint8_t *ptr = s->frame;
58
.instance_size = sizeof(Exynos4210MCTState),
45
uint32_t addr = s->tx_descriptor;
59
.instance_init = exynos4210_mct_init,
46
60
+ .instance_finalize = exynos4210_mct_finalize,
47
while (descnt++ < IMX_MAX_DESC) {
61
.class_init = exynos4210_mct_class_init,
48
@@ -XXX,XX +XXX,XX @@ static void imx_fec_do_tx(IMXFECState *s)
62
};
49
frame_size += len;
63
50
if (bd.flags & ENET_BD_L) {
51
/* Last buffer in frame. */
52
- qemu_send_packet(qemu_get_queue(s->nic), frame, frame_size);
53
- ptr = frame;
54
+ qemu_send_packet(qemu_get_queue(s->nic), s->frame, frame_size);
55
+ ptr = s->frame;
56
frame_size = 0;
57
s->regs[ENET_EIR] |= ENET_INT_TXF;
58
}
59
@@ -XXX,XX +XXX,XX @@ static void imx_fec_do_tx(IMXFECState *s)
60
static void imx_enet_do_tx(IMXFECState *s)
61
{
62
int frame_size = 0, descnt = 0;
63
- uint8_t frame[ENET_MAX_FRAME_SIZE];
64
- uint8_t *ptr = frame;
65
+ uint8_t *ptr = s->frame;
66
uint32_t addr = s->tx_descriptor;
67
68
while (descnt++ < IMX_MAX_DESC) {
69
@@ -XXX,XX +XXX,XX @@ static void imx_enet_do_tx(IMXFECState *s)
70
frame_size += len;
71
if (bd.flags & ENET_BD_L) {
72
if (bd.option & ENET_BD_PINS) {
73
- struct ip_header *ip_hd = PKT_GET_IP_HDR(frame);
74
+ struct ip_header *ip_hd = PKT_GET_IP_HDR(s->frame);
75
if (IP_HEADER_VERSION(ip_hd) == 4) {
76
- net_checksum_calculate(frame, frame_size);
77
+ net_checksum_calculate(s->frame, frame_size);
78
}
79
}
80
if (bd.option & ENET_BD_IINS) {
81
- struct ip_header *ip_hd = PKT_GET_IP_HDR(frame);
82
+ struct ip_header *ip_hd = PKT_GET_IP_HDR(s->frame);
83
/* We compute checksum only for IPv4 frames */
84
if (IP_HEADER_VERSION(ip_hd) == 4) {
85
uint16_t csum;
86
@@ -XXX,XX +XXX,XX @@ static void imx_enet_do_tx(IMXFECState *s)
87
}
88
}
89
/* Last buffer in frame. */
90
- qemu_send_packet(qemu_get_queue(s->nic), frame, len);
91
- ptr = frame;
92
+
93
+ qemu_send_packet(qemu_get_queue(s->nic), s->frame, len);
94
+ ptr = s->frame;
95
+
96
frame_size = 0;
97
if (bd.option & ENET_BD_TX_INT) {
98
s->regs[ENET_EIR] |= ENET_INT_TXF;
99
--
64
--
100
2.7.4
65
2.20.1
101
66
102
67
diff view generated by jsdifflib
1
From: Michael Weiser <michael.weiser@gmx.de>
1
From: Bin Meng <bin.meng@windriver.com>
2
2
3
armeb is missing from the target list in qemu-binfmt-conf.sh. Add it so
3
U-Boot expects PMU_MISC0 register bit 7 is set (see init_bandgap()
4
the handler for those binaries gets registered by the script.
4
in arch/arm/mach-imx/mx6/soc.c) during boot. This bit indicates the
5
bandgap has stabilized.
5
6
6
Signed-off-by: Michael Weiser <michael.weiser@gmx.de>
7
With this change, the latest upstream U-Boot (v2021.01-rc3) for imx6
7
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
8
sabrelite board (mx6qsabrelite_defconfig), with a slight change made
8
Message-id: 20171220212308.12614-8-michael.weiser@gmx.de
9
by switching CONFIG_OF_SEPARATE to CONFIG_OF_EMBED, boots to U-Boot
10
shell on QEMU with the following command:
11
12
$ qemu-system-arm -M sabrelite -smp 4 -m 1G -kernel u-boot \
13
-display none -serial null -serial stdio
14
15
Boot log below:
16
17
U-Boot 2021.01-rc3 (Dec 12 2020 - 17:40:02 +0800)
18
19
CPU: Freescale i.MX?? rev1.0 at 792 MHz
20
Reset cause: POR
21
Model: Freescale i.MX6 Quad SABRE Lite Board
22
Board: SABRE Lite
23
I2C: ready
24
DRAM: 1 GiB
25
force_idle_bus: sda=0 scl=0 sda.gp=0x5c scl.gp=0x55
26
force_idle_bus: failed to clear bus, sda=0 scl=0
27
force_idle_bus: sda=0 scl=0 sda.gp=0x6d scl.gp=0x6c
28
force_idle_bus: failed to clear bus, sda=0 scl=0
29
force_idle_bus: sda=0 scl=0 sda.gp=0xcb scl.gp=0x5
30
force_idle_bus: failed to clear bus, sda=0 scl=0
31
MMC: FSL_SDHC: 0, FSL_SDHC: 1
32
Loading Environment from MMC... *** Warning - No block device, using default environment
33
34
In: serial
35
Out: serial
36
Err: serial
37
Net: Board Net Initialization Failed
38
No ethernet found.
39
starting USB...
40
Bus usb@2184000: usb dr_mode not found
41
USB EHCI 1.00
42
Bus usb@2184200: USB EHCI 1.00
43
scanning bus usb@2184000 for devices... 1 USB Device(s) found
44
scanning bus usb@2184200 for devices... 1 USB Device(s) found
45
scanning usb for storage devices... 0 Storage Device(s) found
46
scanning usb for ethernet devices... 0 Ethernet Device(s) found
47
Hit any key to stop autoboot: 0
48
=>
49
50
Signed-off-by: Bin Meng <bin.meng@windriver.com>
51
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
52
Message-id: 20210106063504.10841-2-bmeng.cn@gmail.com
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
53
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
54
---
11
scripts/qemu-binfmt-conf.sh | 2 +-
55
hw/misc/imx6_ccm.c | 2 +-
12
1 file changed, 1 insertion(+), 1 deletion(-)
56
1 file changed, 1 insertion(+), 1 deletion(-)
13
57
14
diff --git a/scripts/qemu-binfmt-conf.sh b/scripts/qemu-binfmt-conf.sh
58
diff --git a/hw/misc/imx6_ccm.c b/hw/misc/imx6_ccm.c
15
index XXXXXXX..XXXXXXX 100755
59
index XXXXXXX..XXXXXXX 100644
16
--- a/scripts/qemu-binfmt-conf.sh
60
--- a/hw/misc/imx6_ccm.c
17
+++ b/scripts/qemu-binfmt-conf.sh
61
+++ b/hw/misc/imx6_ccm.c
18
@@ -XXX,XX +XXX,XX @@
62
@@ -XXX,XX +XXX,XX @@ static void imx6_ccm_reset(DeviceState *dev)
19
# enable automatic i386/ARM/M68K/MIPS/SPARC/PPC/s390/HPPA
63
s->analog[PMU_REG_3P0] = 0x00000F74;
20
# program execution by the kernel
64
s->analog[PMU_REG_2P5] = 0x00005071;
21
65
s->analog[PMU_REG_CORE] = 0x00402010;
22
-qemu_target_list="i386 i486 alpha arm sparc32plus ppc ppc64 ppc64le m68k \
66
- s->analog[PMU_MISC0] = 0x04000000;
23
+qemu_target_list="i386 i486 alpha arm armeb sparc32plus ppc ppc64 ppc64le m68k \
67
+ s->analog[PMU_MISC0] = 0x04000080;
24
mips mipsel mipsn32 mipsn32el mips64 mips64el \
68
s->analog[PMU_MISC1] = 0x00000000;
25
sh4 sh4eb s390x aarch64 aarch64_be hppa"
69
s->analog[PMU_MISC2] = 0x00272727;
26
70
27
--
71
--
28
2.7.4
72
2.20.1
29
73
30
74
diff view generated by jsdifflib
1
From: Andrey Smirnov <andrew.smirnov@gmail.com>
1
From: Bin Meng <bin.meng@windriver.com>
2
2
3
Use 'frame_size' instead of 'len' when calling qemu_send_packet(),
3
Currently when U-Boot boots, it prints "??" for i.MX processor:
4
failing to do so results in malformed packets send in case when that
5
packed is fragmented into multiple DMA transactions.
6
4
7
Cc: Peter Maydell <peter.maydell@linaro.org>
5
CPU: Freescale i.MX?? rev1.0 at 792 MHz
8
Cc: Jason Wang <jasowang@redhat.com>
6
9
Cc: Philippe Mathieu-Daudé <f4bug@amsat.org>
7
The register that was used to determine the silicon type is
10
Cc: qemu-devel@nongnu.org
8
undocumented in the latest IMX6DQRM (Rev. 6, 05/2020), but we
11
Cc: qemu-arm@nongnu.org
9
can refer to get_cpu_rev() in arch/arm/mach-imx/mx6/soc.c in
12
Cc: yurovsky@gmail.com
10
the U-Boot source codes that USB_ANALOG_DIGPROG is used.
13
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
11
14
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
12
Update its reset value to indicate i.MX6Q.
13
14
Signed-off-by: Bin Meng <bin.meng@windriver.com>
15
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
16
Message-id: 20210106063504.10841-3-bmeng.cn@gmail.com
15
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
17
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
16
---
18
---
17
hw/net/imx_fec.c | 2 +-
19
hw/misc/imx6_ccm.c | 2 +-
18
1 file changed, 1 insertion(+), 1 deletion(-)
20
1 file changed, 1 insertion(+), 1 deletion(-)
19
21
20
diff --git a/hw/net/imx_fec.c b/hw/net/imx_fec.c
22
diff --git a/hw/misc/imx6_ccm.c b/hw/misc/imx6_ccm.c
21
index XXXXXXX..XXXXXXX 100644
23
index XXXXXXX..XXXXXXX 100644
22
--- a/hw/net/imx_fec.c
24
--- a/hw/misc/imx6_ccm.c
23
+++ b/hw/net/imx_fec.c
25
+++ b/hw/misc/imx6_ccm.c
24
@@ -XXX,XX +XXX,XX @@ static void imx_enet_do_tx(IMXFECState *s, uint32_t index)
26
@@ -XXX,XX +XXX,XX @@ static void imx6_ccm_reset(DeviceState *dev)
25
}
27
s->analog[USB_ANALOG_USB2_VBUS_DETECT] = 0x00000004;
26
/* Last buffer in frame. */
28
s->analog[USB_ANALOG_USB2_CHRG_DETECT] = 0x00000000;
27
29
s->analog[USB_ANALOG_USB2_MISC] = 0x00000002;
28
- qemu_send_packet(qemu_get_queue(s->nic), s->frame, len);
30
- s->analog[USB_ANALOG_DIGPROG] = 0x00000000;
29
+ qemu_send_packet(qemu_get_queue(s->nic), s->frame, frame_size);
31
+ s->analog[USB_ANALOG_DIGPROG] = 0x00630000;
30
ptr = s->frame;
32
31
33
/* all PLLs need to be locked */
32
frame_size = 0;
34
s->analog[CCM_ANALOG_PLL_ARM] |= CCM_ANALOG_PLL_LOCK;
33
--
35
--
34
2.7.4
36
2.20.1
35
37
36
38
diff view generated by jsdifflib
1
From: Michael Weiser <michael.weiser@gmx.de>
1
From: Bin Meng <bin.meng@windriver.com>
2
2
3
Make big-endian aarch64 systems identify as aarch64_be as expected by
3
At present, when booting U-Boot on QEMU sabrelite, we see:
4
big-endian userland and toolchains.
5
4
6
Signed-off-by: Michael Weiser <michael.weiser@gmx.de>
5
Net: Board Net Initialization Failed
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
No ethernet found.
8
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
7
9
Message-id: 20171220212308.12614-3-michael.weiser@gmx.de
8
U-Boot scans PHY at address 4/5/6/7 (see board_eth_init() in the
9
U-Boot source: board/boundary/nitrogen6x/nitrogen6x.c). On the real
10
board, the Ethernet PHY is at address 6. Adjust this by updating the
11
"fec-phy-num" property of the fsl_imx6 SoC object.
12
13
With this change, U-Boot sees the PHY but complains MAC address:
14
15
Net: using phy at 6
16
FEC [PRIME]
17
Error: FEC address not set.
18
19
This is due to U-Boot tries to read the MAC address from the fuse,
20
which QEMU does not have any valid content filled in. However this
21
does not prevent the Ethernet from working in QEMU. We just need to
22
set up the MAC address later in the U-Boot command shell, by:
23
24
=> setenv ethaddr 00:11:22:33:44:55
25
26
Signed-off-by: Bin Meng <bin.meng@windriver.com>
27
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
28
Message-id: 20210106063504.10841-4-bmeng.cn@gmail.com
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
29
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
30
---
12
linux-user/aarch64/target_syscall.h | 4 ++++
31
hw/arm/sabrelite.c | 4 ++++
13
1 file changed, 4 insertions(+)
32
1 file changed, 4 insertions(+)
14
33
15
diff --git a/linux-user/aarch64/target_syscall.h b/linux-user/aarch64/target_syscall.h
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/linux-user/aarch64/target_syscall.h
36
--- a/hw/arm/sabrelite.c
18
+++ b/linux-user/aarch64/target_syscall.h
37
+++ b/hw/arm/sabrelite.c
19
@@ -XXX,XX +XXX,XX @@ struct target_pt_regs {
38
@@ -XXX,XX +XXX,XX @@ static void sabrelite_init(MachineState *machine)
20
uint64_t pstate;
39
21
};
40
s = FSL_IMX6(object_new(TYPE_FSL_IMX6));
22
41
object_property_add_child(OBJECT(machine), "soc", OBJECT(s));
23
+#if defined(TARGET_WORDS_BIGENDIAN)
42
+
24
+#define UNAME_MACHINE "aarch64_be"
43
+ /* Ethernet PHY address is 6 */
25
+#else
44
+ object_property_set_int(OBJECT(s), "fec-phy-num", 6, &error_fatal);
26
#define UNAME_MACHINE "aarch64"
45
+
27
+#endif
46
qdev_realize(DEVICE(s), NULL, &error_fatal);
28
#define UNAME_MINIMUM_RELEASE "3.8.0"
47
29
#define TARGET_CLONE_BACKWARDS
48
memory_region_add_subregion(get_system_memory(), FSL_IMX6_MMDC_ADDR,
30
#define TARGET_MINSIGSTKSZ 2048
31
--
49
--
32
2.7.4
50
2.20.1
33
51
34
52
diff view generated by jsdifflib
Deleted patch
1
From: Michael Weiser <michael.weiser@gmx.de>
2
1
3
Since for aarch64 the signal trampoline is synthesized directly into the
4
signal frame we need to make sure the instructions end up little-endian.
5
Otherwise the wrong endianness will cause a SIGILL upon return from the
6
signal handler on big-endian targets.
7
8
Signed-off-by: Michael Weiser <michael.weiser@gmx.de>
9
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
10
Message-id: 20171220212308.12614-4-michael.weiser@gmx.de
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
---
13
linux-user/signal.c | 10 +++++++---
14
1 file changed, 7 insertions(+), 3 deletions(-)
15
16
diff --git a/linux-user/signal.c b/linux-user/signal.c
17
index XXXXXXX..XXXXXXX 100644
18
--- a/linux-user/signal.c
19
+++ b/linux-user/signal.c
20
@@ -XXX,XX +XXX,XX @@ static void target_setup_frame(int usig, struct target_sigaction *ka,
21
if (ka->sa_flags & TARGET_SA_RESTORER) {
22
return_addr = ka->sa_restorer;
23
} else {
24
- /* mov x8,#__NR_rt_sigreturn; svc #0 */
25
- __put_user(0xd2801168, &frame->tramp[0]);
26
- __put_user(0xd4000001, &frame->tramp[1]);
27
+ /*
28
+ * mov x8,#__NR_rt_sigreturn; svc #0
29
+ * Since these are instructions they need to be put as little-endian
30
+ * regardless of target default or current CPU endianness.
31
+ */
32
+ __put_user_e(0xd2801168, &frame->tramp[0], le);
33
+ __put_user_e(0xd4000001, &frame->tramp[1], le);
34
return_addr = frame_addr + offsetof(struct target_rt_sigframe, tramp);
35
}
36
env->xregs[0] = usig;
37
--
38
2.7.4
39
40
diff view generated by jsdifflib
1
From: Michael Weiser <michael.weiser@gmx.de>
1
From: Bin Meng <bin.meng@windriver.com>
2
2
3
Add target aarch64_be-linux-user. This allows a qemu-aarch64_be binary
3
This adds the target guide for SABRE Lite board, and documents how
4
to be built that will run big-endian aarch64 binaries.
4
to boot a Linux kernel and U-Boot bootloader.
5
5
6
Signed-off-by: Michael Weiser <michael.weiser@gmx.de>
6
Signed-off-by: Bin Meng <bin.meng@windriver.com>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
8
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
8
Message-id: 20210106063504.10841-5-bmeng.cn@gmail.com
9
Message-id: 20171220212308.12614-5-michael.weiser@gmx.de
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
10
---
12
configure | 5 +++--
11
docs/system/arm/sabrelite.rst | 119 ++++++++++++++++++++++++++++++++++
13
default-configs/aarch64_be-linux-user.mak | 1 +
12
docs/system/target-arm.rst | 1 +
14
2 files changed, 4 insertions(+), 2 deletions(-)
13
2 files changed, 120 insertions(+)
15
create mode 100644 default-configs/aarch64_be-linux-user.mak
14
create mode 100644 docs/system/arm/sabrelite.rst
16
15
17
diff --git a/configure b/configure
16
diff --git a/docs/system/arm/sabrelite.rst b/docs/system/arm/sabrelite.rst
18
index XXXXXXX..XXXXXXX 100755
19
--- a/configure
20
+++ b/configure
21
@@ -XXX,XX +XXX,XX @@ target_name=$(echo $target | cut -d '-' -f 1)
22
target_bigendian="no"
23
24
case "$target_name" in
25
- armeb|hppa|lm32|m68k|microblaze|mips|mipsn32|mips64|moxie|or1k|ppc|ppcemb|ppc64|ppc64abi32|s390x|sh4eb|sparc|sparc64|sparc32plus|xtensaeb)
26
+ armeb|aarch64_be|hppa|lm32|m68k|microblaze|mips|mipsn32|mips64|moxie|or1k|ppc|ppcemb|ppc64|ppc64abi32|s390x|sh4eb|sparc|sparc64|sparc32plus|xtensaeb)
27
target_bigendian=yes
28
;;
29
esac
30
@@ -XXX,XX +XXX,XX @@ case "$target_name" in
31
mttcg="yes"
32
gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
33
;;
34
- aarch64)
35
+ aarch64|aarch64_be)
36
+ TARGET_ARCH=aarch64
37
TARGET_BASE_ARCH=arm
38
bflt="yes"
39
mttcg="yes"
40
diff --git a/default-configs/aarch64_be-linux-user.mak b/default-configs/aarch64_be-linux-user.mak
41
new file mode 100644
17
new file mode 100644
42
index XXXXXXX..XXXXXXX
18
index XXXXXXX..XXXXXXX
43
--- /dev/null
19
--- /dev/null
44
+++ b/default-configs/aarch64_be-linux-user.mak
20
+++ b/docs/system/arm/sabrelite.rst
45
@@ -0,0 +1 @@
21
@@ -XXX,XX +XXX,XX @@
46
+# Default configuration for aarch64_be-linux-user
22
+Boundary Devices SABRE Lite (``sabrelite``)
23
+===========================================
24
+
25
+Boundary Devices SABRE Lite i.MX6 Development Board is a low-cost development
26
+platform featuring the powerful Freescale / NXP Semiconductor's i.MX 6 Quad
27
+Applications Processor.
28
+
29
+Supported devices
30
+-----------------
31
+
32
+The SABRE Lite machine supports the following devices:
33
+
34
+ * Up to 4 Cortex A9 cores
35
+ * Generic Interrupt Controller
36
+ * 1 Clock Controller Module
37
+ * 1 System Reset Controller
38
+ * 5 UARTs
39
+ * 2 EPIC timers
40
+ * 1 GPT timer
41
+ * 2 Watchdog timers
42
+ * 1 FEC Ethernet controller
43
+ * 3 I2C controllers
44
+ * 7 GPIO controllers
45
+ * 4 SDHC storage controllers
46
+ * 4 USB 2.0 host controllers
47
+ * 5 ECSPI controllers
48
+ * 1 SST 25VF016B flash
49
+
50
+Please note above list is a complete superset the QEMU SABRE Lite machine can
51
+support. For a normal use case, a device tree blob that represents a real world
52
+SABRE Lite board, only exposes a subset of devices to the guest software.
53
+
54
+Boot options
55
+------------
56
+
57
+The SABRE Lite machine can start using the standard -kernel functionality
58
+for loading a Linux kernel, U-Boot bootloader or ELF executable.
59
+
60
+Running Linux kernel
61
+--------------------
62
+
63
+Linux mainline v5.10 release is tested at the time of writing. To build a Linux
64
+mainline kernel that can be booted by the SABRE Lite machine, simply configure
65
+the kernel using the imx_v6_v7_defconfig configuration:
66
+
67
+.. code-block:: bash
68
+
69
+ $ export ARCH=arm
70
+ $ export CROSS_COMPILE=arm-linux-gnueabihf-
71
+ $ make imx_v6_v7_defconfig
72
+ $ make
73
+
74
+To boot the newly built Linux kernel in QEMU with the SABRE Lite machine, use:
75
+
76
+.. code-block:: bash
77
+
78
+ $ qemu-system-arm -M sabrelite -smp 4 -m 1G \
79
+ -display none -serial null -serial stdio \
80
+ -kernel arch/arm/boot/zImage \
81
+ -dtb arch/arm/boot/dts/imx6q-sabrelite.dtb \
82
+ -initrd /path/to/rootfs.ext4 \
83
+ -append "root=/dev/ram"
84
+
85
+Running U-Boot
86
+--------------
87
+
88
+U-Boot mainline v2020.10 release is tested at the time of writing. To build a
89
+U-Boot mainline bootloader that can be booted by the SABRE Lite machine, use
90
+the mx6qsabrelite_defconfig with similar commands as described above for Linux:
91
+
92
+.. code-block:: bash
93
+
94
+ $ export CROSS_COMPILE=arm-linux-gnueabihf-
95
+ $ make mx6qsabrelite_defconfig
96
+
97
+Note we need to adjust settings by:
98
+
99
+.. code-block:: bash
100
+
101
+ $ make menuconfig
102
+
103
+then manually select the following configuration in U-Boot:
104
+
105
+ Device Tree Control > Provider of DTB for DT Control > Embedded DTB
106
+
107
+To start U-Boot using the SABRE Lite machine, provide the u-boot binary to
108
+the -kernel argument, along with an SD card image with rootfs:
109
+
110
+.. code-block:: bash
111
+
112
+ $ qemu-system-arm -M sabrelite -smp 4 -m 1G \
113
+ -display none -serial null -serial stdio \
114
+ -kernel u-boot
115
+
116
+The following example shows booting Linux kernel from dhcp, and uses the
117
+rootfs on an SD card. This requires some additional command line parameters
118
+for QEMU:
119
+
120
+.. code-block:: none
121
+
122
+ -nic user,tftp=/path/to/kernel/zImage \
123
+ -drive file=sdcard.img,id=rootfs -device sd-card,drive=rootfs
124
+
125
+The directory for the built-in TFTP server should also contain the device tree
126
+blob of the SABRE Lite board. The sample SD card image was populated with the
127
+root file system with one single partition. You may adjust the kernel "root="
128
+boot parameter accordingly.
129
+
130
+After U-Boot boots, type the following commands in the U-Boot command shell to
131
+boot the Linux kernel:
132
+
133
+.. code-block:: none
134
+
135
+ => setenv ethaddr 00:11:22:33:44:55
136
+ => setenv bootfile zImage
137
+ => dhcp
138
+ => tftpboot 14000000 imx6q-sabrelite.dtb
139
+ => setenv bootargs root=/dev/mmcblk3p1
140
+ => bootz 12000000 - 14000000
141
diff --git a/docs/system/target-arm.rst b/docs/system/target-arm.rst
142
index XXXXXXX..XXXXXXX 100644
143
--- a/docs/system/target-arm.rst
144
+++ b/docs/system/target-arm.rst
145
@@ -XXX,XX +XXX,XX @@ undocumented; you can get a complete list by running
146
arm/versatile
147
arm/vexpress
148
arm/aspeed
149
+ arm/sabrelite
150
arm/digic
151
arm/musicpal
152
arm/gumstix
47
--
153
--
48
2.7.4
154
2.20.1
49
155
50
156
diff view generated by jsdifflib
Deleted patch
1
From: Michael Weiser <michael.weiser@gmx.de>
2
1
3
As we now have a linux-user aarch64_be target, we can add it to the list
4
of supported targets in qemu-binfmt-conf.sh
5
6
Signed-off-by: Michael Weiser <michael.weiser@gmx.de>
7
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
8
Message-id: 20171220212308.12614-6-michael.weiser@gmx.de
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
11
scripts/qemu-binfmt-conf.sh | 6 +++++-
12
1 file changed, 5 insertions(+), 1 deletion(-)
13
14
diff --git a/scripts/qemu-binfmt-conf.sh b/scripts/qemu-binfmt-conf.sh
15
index XXXXXXX..XXXXXXX 100755
16
--- a/scripts/qemu-binfmt-conf.sh
17
+++ b/scripts/qemu-binfmt-conf.sh
18
@@ -XXX,XX +XXX,XX @@
19
20
qemu_target_list="i386 i486 alpha arm sparc32plus ppc ppc64 ppc64le m68k \
21
mips mipsel mipsn32 mipsn32el mips64 mips64el \
22
-sh4 sh4eb s390x aarch64 hppa"
23
+sh4 sh4eb s390x aarch64 aarch64_be hppa"
24
25
i386_magic='\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x03\x00'
26
i386_mask='\xff\xff\xff\xff\xff\xfe\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'
27
@@ -XXX,XX +XXX,XX @@ aarch64_magic='\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x
28
aarch64_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'
29
aarch64_family=arm
30
31
+aarch64_be_magic='\x7fELF\x02\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xb7'
32
+aarch64_be_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
33
+aarch64_be_family=arm
34
+
35
hppa_magic='\x7f\x45\x4c\x46\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x0f'
36
hppa_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
37
hppa_family=hppa
38
--
39
2.7.4
40
41
diff view generated by jsdifflib