1
Nothing very exciting this time around...
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 37a712a0f969ca2df7f01182409a6c4825cebfb5:
5
The following changes since commit e79de63ab1bd1f6550e7b915e433bec1ad1a870a:
6
6
7
Merge remote-tracking branch 'remotes/bonzini-gitlab/tags/for-upstream' into staging (2020-10-01 12:23:19 +0100)
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
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20201001
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 cdfaa57dcb53ba012439765a1462247dfda8595d:
13
for you to fetch changes up to c9f8511ea8d2b80723af0fea1f716d752c1b5208:
14
14
15
hw/arm/raspi: Remove use of the 'version' value in the board code (2020-10-01 15:31:01 +0100)
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
* Make isar_feature_aa32_fp16_arith() handle M-profile
19
* intc/arm_gic: Fix gic_irq_signaling_enabled() for vCPUs
20
* Fix SVE splice
20
* target/arm: Fix MTE0_ACTIVE
21
* Fix SVE LDR/STR
21
* target/arm: Implement v8.1M and Cortex-M55 model
22
* Remove ignore_memory_transaction_failures on the raspi2
22
* hw/arm/highbank: Drop dead KVM support code
23
* raspi: Various cleanup/refactoring
23
* util/qemu-timer: Make timer_free() imply timer_del()
24
* various devices: Use ptimer_free() in finalize function
25
* docs/system: arm: Add sabrelite board description
26
* sabrelite: Minor fixes to allow booting U-Boot
24
27
25
----------------------------------------------------------------
28
----------------------------------------------------------------
26
Peter Maydell (5):
29
Andrew Jones (1):
27
target/arm: Replace ARM_FEATURE_PXN with ID_MMFR0.VMSA check
30
hw/arm/virt: Remove virt machine state 'smp_cpus'
28
target/arm: Move id_pfr0, id_pfr1 into ARMISARegisters
29
hw/intc/armv7m_nvic: Only show ID register values for Main Extension CPUs
30
target/arm: Add ID register values for Cortex-M0
31
target/arm: Make isar_feature_aa32_fp16_arith() handle M-profile
32
31
33
Philippe Mathieu-Daudé (11):
32
Bin Meng (4):
34
hw/arm/raspi: Define various blocks base addresses
33
hw/misc: imx6_ccm: Update PMU_MISC0 reset value
35
hw/arm/bcm2835: Add more unimplemented peripherals
34
hw/msic: imx6_ccm: Correct register value for silicon type
36
hw/arm/raspi: Remove ignore_memory_transaction_failures on the raspi2
35
hw/arm: sabrelite: Connect the Ethernet PHY at address 6
37
hw/arm/raspi: Display the board revision in the machine description
36
docs/system: arm: Add sabrelite board description
38
hw/arm/raspi: Load the firmware on the first core
39
hw/arm/raspi: Move arm_boot_info structure to RaspiMachineState
40
hw/arm/raspi: Avoid using TypeInfo::class_data pointer
41
hw/arm/raspi: Use more specific machine names
42
hw/arm/raspi: Introduce RaspiProcessorId enum
43
hw/arm/raspi: Use RaspiProcessorId to set the firmware load address
44
hw/arm/raspi: Remove use of the 'version' value in the board code
45
37
46
Richard Henderson (2):
38
Edgar E. Iglesias (1):
47
target/arm: Fix sve ldr/str
39
intc/arm_gic: Fix gic_irq_signaling_enabled() for vCPUs
48
target/arm: Fix SVE splice
49
40
50
include/hw/arm/bcm2835_peripherals.h | 2 +
41
Gan Qixin (7):
51
include/hw/arm/raspi_platform.h | 51 ++++++++++--
42
digic-timer: Use ptimer_free() in the finalize function to avoid memleaks
52
target/arm/cpu.h | 50 +++++++++--
43
allwinner-a10-pit: Use ptimer_free() in the finalize function to avoid memleaks
53
hw/arm/bcm2835_peripherals.c | 2 +
44
exynos4210_rtc: Use ptimer_free() in the finalize function to avoid memleaks
54
hw/arm/raspi.c | 155 +++++++++++++++++++----------------
45
exynos4210_pwm: Use ptimer_free() in the finalize function to avoid memleaks
55
hw/intc/armv7m_nvic.c | 46 ++++++++++-
46
mss-timer: Use ptimer_free() in the finalize function to avoid memleaks
56
target/arm/cpu.c | 21 +++--
47
musicpal: Use ptimer_free() in the finalize function to avoid memleaks
57
target/arm/cpu64.c | 12 +--
48
exynos4210_mct: Use ptimer_free() in the finalize function to avoid memleaks
58
target/arm/cpu_tcg.c | 60 ++++++++++----
59
target/arm/helper.c | 9 +-
60
target/arm/kvm64.c | 4 +
61
target/arm/translate-sve.c | 6 +-
62
12 files changed, 286 insertions(+), 132 deletions(-)
63
49
50
Peter Maydell (9):
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()
60
61
Richard Henderson (1):
62
target/arm: Fix MTE0_ACTIVE
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
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
1
From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com>
2
2
3
Display the board revision in the machine description.
3
Correct the indexing into s->cpu_ctlr for vCPUs.
4
4
5
Before:
5
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
6
6
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
7
$ qemu-system-aarch64 -M help | fgrep raspi
8
raspi2 Raspberry Pi 2B
9
raspi3 Raspberry Pi 3B
10
11
After:
12
13
raspi2 Raspberry Pi 2B (revision 1.1)
14
raspi3 Raspberry Pi 3B (revision 1.2)
15
16
Reviewed-by: Luc Michel <luc.michel@greensocs.com>
7
Reviewed-by: Luc Michel <luc.michel@greensocs.com>
17
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
8
Message-id: 20201214222154.3480243-2-edgar.iglesias@gmail.com
18
Message-id: 20200924111808.77168-2-f4bug@amsat.org
19
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
20
---
10
---
21
hw/arm/raspi.c | 4 +++-
11
hw/intc/arm_gic.c | 4 +++-
22
1 file changed, 3 insertions(+), 1 deletion(-)
12
1 file changed, 3 insertions(+), 1 deletion(-)
23
13
24
diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c
14
diff --git a/hw/intc/arm_gic.c b/hw/intc/arm_gic.c
25
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
26
--- a/hw/arm/raspi.c
16
--- a/hw/intc/arm_gic.c
27
+++ b/hw/arm/raspi.c
17
+++ b/hw/intc/arm_gic.c
28
@@ -XXX,XX +XXX,XX @@ static void raspi_machine_class_init(ObjectClass *oc, void *data)
18
@@ -XXX,XX +XXX,XX @@ static inline void gic_get_best_virq(GICState *s, int cpu,
29
uint32_t board_rev = (uint32_t)(uintptr_t)data;
19
static inline bool gic_irq_signaling_enabled(GICState *s, int cpu, bool virt,
30
20
int group_mask)
31
rmc->board_rev = board_rev;
21
{
32
- mc->desc = g_strdup_printf("Raspberry Pi %s", board_type(board_rev));
22
+ int cpu_iface = virt ? (cpu + GIC_NCPU) : cpu;
33
+ mc->desc = g_strdup_printf("Raspberry Pi %s (revision 1.%u)",
23
+
34
+ board_type(board_rev),
24
if (!virt && !(s->ctlr & group_mask)) {
35
+ FIELD_EX32(board_rev, REV_CODE, REVISION));
25
return false;
36
mc->init = raspi_machine_init;
26
}
37
mc->block_default_type = IF_SD;
27
@@ -XXX,XX +XXX,XX @@ static inline bool gic_irq_signaling_enabled(GICState *s, int cpu, bool virt,
38
mc->no_parallel = 1;
28
return false;
29
}
30
31
- if (!(s->cpu_ctlr[cpu] & group_mask)) {
32
+ if (!(s->cpu_ctlr[cpu_iface] & group_mask)) {
33
return false;
34
}
35
39
--
36
--
40
2.20.1
37
2.20.1
41
38
42
39
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
1
From: Andrew Jones <drjones@redhat.com>
2
2
3
The arm_boot_info structure belong to the machine,
3
virt machine's 'smp_cpus' and machine->smp.cpus must always have the
4
move it to RaspiMachineState.
4
same value. And, anywhere we have virt machine state we have machine
5
state. So let's remove the redundancy. Also, to make it easier to see
6
that machine->smp is the true source for "smp_cpus" and "max_cpus",
7
avoid passing them in function parameters, preferring instead to get
8
them from the state.
5
9
6
Reviewed-by: Luc Michel <luc.michel@greensocs.com>
10
No functional change intended.
7
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
11
8
Message-id: 20200924111808.77168-4-f4bug@amsat.org
12
Signed-off-by: Andrew Jones <drjones@redhat.com>
13
Reviewed-by: David Edmondson <david.edmondson@oracle.com>
14
Reviewed-by: Ying Fang <fangying1@huawei.com>
15
Message-id: 20201215174815.51520-1-drjones@redhat.com
16
[PMM: minor formatting tweak to smp_cpus variable declaration]
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
17
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
18
---
11
hw/arm/raspi.c | 30 +++++++++++++++---------------
19
include/hw/arm/virt.h | 3 +--
12
1 file changed, 15 insertions(+), 15 deletions(-)
20
hw/arm/virt-acpi-build.c | 9 +++++----
21
hw/arm/virt.c | 21 ++++++++++-----------
22
3 files changed, 16 insertions(+), 17 deletions(-)
13
23
14
diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c
24
diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h
15
index XXXXXXX..XXXXXXX 100644
25
index XXXXXXX..XXXXXXX 100644
16
--- a/hw/arm/raspi.c
26
--- a/include/hw/arm/virt.h
17
+++ b/hw/arm/raspi.c
27
+++ b/include/hw/arm/virt.h
18
@@ -XXX,XX +XXX,XX @@ struct RaspiMachineState {
28
@@ -XXX,XX +XXX,XX @@ struct VirtMachineState {
19
MachineState parent_obj;
29
MemMapEntry *memmap;
20
/*< public >*/
30
char *pciehb_nodename;
21
BCM283XState soc;
31
const int *irqmap;
22
+ struct arm_boot_info binfo;
32
- int smp_cpus;
23
};
33
void *fdt;
24
typedef struct RaspiMachineState RaspiMachineState;
34
int fdt_size;
25
35
uint32_t clock_phandle;
26
@@ -XXX,XX +XXX,XX @@ static void reset_secondary(ARMCPU *cpu, const struct arm_boot_info *info)
36
@@ -XXX,XX +XXX,XX @@ static inline int virt_gicv3_redist_region_count(VirtMachineState *vms)
27
static void setup_boot(MachineState *machine, int version, size_t ram_size)
37
38
assert(vms->gic_version == VIRT_GIC_VERSION_3);
39
40
- return vms->smp_cpus > redist0_capacity ? 2 : 1;
41
+ return MACHINE(vms)->smp.cpus > redist0_capacity ? 2 : 1;
42
}
43
44
#endif /* QEMU_ARM_VIRT_H */
45
diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
46
index XXXXXXX..XXXXXXX 100644
47
--- a/hw/arm/virt-acpi-build.c
48
+++ b/hw/arm/virt-acpi-build.c
49
@@ -XXX,XX +XXX,XX @@
50
51
#define ACPI_BUILD_TABLE_SIZE 0x20000
52
53
-static void acpi_dsdt_add_cpus(Aml *scope, int smp_cpus)
54
+static void acpi_dsdt_add_cpus(Aml *scope, VirtMachineState *vms)
28
{
55
{
29
RaspiMachineState *s = RASPI_MACHINE(machine);
56
+ MachineState *ms = MACHINE(vms);
30
- static struct arm_boot_info binfo;
57
uint16_t i;
31
int r;
58
32
59
- for (i = 0; i < smp_cpus; i++) {
33
- binfo.board_id = MACH_TYPE_BCM2708;
60
+ for (i = 0; i < ms->smp.cpus; i++) {
34
- binfo.ram_size = ram_size;
61
Aml *dev = aml_device("C%.03X", i);
35
- binfo.nb_cpus = machine->smp.cpus;
62
aml_append(dev, aml_name_decl("_HID", aml_string("ACPI0007")));
36
+ s->binfo.board_id = MACH_TYPE_BCM2708;
63
aml_append(dev, aml_name_decl("_UID", aml_int(i)));
37
+ s->binfo.ram_size = ram_size;
64
@@ -XXX,XX +XXX,XX @@ build_madt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
38
+ s->binfo.nb_cpus = machine->smp.cpus;
65
gicd->base_address = cpu_to_le64(memmap[VIRT_GIC_DIST].base);
39
66
gicd->version = vms->gic_version;
40
if (version <= 2) {
67
41
/* The rpi1 and 2 require some custom setup code to run in Secure
68
- for (i = 0; i < vms->smp_cpus; i++) {
42
@@ -XXX,XX +XXX,XX @@ static void setup_boot(MachineState *machine, int version, size_t ram_size)
69
+ for (i = 0; i < MACHINE(vms)->smp.cpus; i++) {
43
* firmware for some cache maintenance operations.
70
AcpiMadtGenericCpuInterface *gicc = acpi_data_push(table_data,
44
* The rpi3 doesn't need this.
71
sizeof(*gicc));
45
*/
72
ARMCPU *armcpu = ARM_CPU(qemu_get_cpu(i));
46
- binfo.board_setup_addr = BOARDSETUP_ADDR;
73
@@ -XXX,XX +XXX,XX @@ build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
47
- binfo.write_board_setup = write_board_setup;
74
* the RTC ACPI device at all when using UEFI.
48
- binfo.secure_board_setup = true;
75
*/
49
- binfo.secure_boot = true;
76
scope = aml_scope("\\_SB");
50
+ s->binfo.board_setup_addr = BOARDSETUP_ADDR;
77
- acpi_dsdt_add_cpus(scope, vms->smp_cpus);
51
+ s->binfo.write_board_setup = write_board_setup;
78
+ acpi_dsdt_add_cpus(scope, vms);
52
+ s->binfo.secure_board_setup = true;
79
acpi_dsdt_add_uart(scope, &memmap[VIRT_UART],
53
+ s->binfo.secure_boot = true;
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);
54
}
92
}
55
93
56
/* Pi2 and Pi3 requires SMP setup */
94
qemu_fdt_add_subnode(vms->fdt, "/timer");
57
if (version >= 2) {
95
@@ -XXX,XX +XXX,XX @@ static void fdt_add_cpu_nodes(const VirtMachineState *vms)
58
- binfo.smp_loader_start = SMPBOOT_ADDR;
96
int cpu;
59
+ s->binfo.smp_loader_start = SMPBOOT_ADDR;
97
int addr_cells = 1;
60
if (version == 2) {
98
const MachineState *ms = MACHINE(vms);
61
- binfo.write_secondary_boot = write_smpboot;
99
+ int smp_cpus = ms->smp.cpus;
62
+ s->binfo.write_secondary_boot = write_smpboot;
100
63
} else {
101
/*
64
- binfo.write_secondary_boot = write_smpboot64;
102
* From Documentation/devicetree/bindings/arm/cpus.txt
65
+ s->binfo.write_secondary_boot = write_smpboot64;
103
@@ -XXX,XX +XXX,XX @@ static void fdt_add_cpu_nodes(const VirtMachineState *vms)
104
* The simplest way to go is to examine affinity IDs of all our CPUs. If
105
* at least one of them has Aff3 populated, we set #address-cells to 2.
106
*/
107
- for (cpu = 0; cpu < vms->smp_cpus; cpu++) {
108
+ for (cpu = 0; cpu < smp_cpus; cpu++) {
109
ARMCPU *armcpu = ARM_CPU(qemu_get_cpu(cpu));
110
111
if (armcpu->mp_affinity & ARM_AFF3_MASK) {
112
@@ -XXX,XX +XXX,XX @@ static void fdt_add_cpu_nodes(const VirtMachineState *vms)
113
qemu_fdt_setprop_cell(vms->fdt, "/cpus", "#address-cells", addr_cells);
114
qemu_fdt_setprop_cell(vms->fdt, "/cpus", "#size-cells", 0x0);
115
116
- for (cpu = vms->smp_cpus - 1; cpu >= 0; cpu--) {
117
+ for (cpu = smp_cpus - 1; cpu >= 0; cpu--) {
118
char *nodename = g_strdup_printf("/cpus/cpu@%d", cpu);
119
ARMCPU *armcpu = ARM_CPU(qemu_get_cpu(cpu));
120
CPUState *cs = CPU(armcpu);
121
@@ -XXX,XX +XXX,XX @@ static void fdt_add_cpu_nodes(const VirtMachineState *vms)
122
qemu_fdt_setprop_string(vms->fdt, nodename, "compatible",
123
armcpu->dtb_compatible);
124
125
- if (vms->psci_conduit != QEMU_PSCI_CONDUIT_DISABLED
126
- && vms->smp_cpus > 1) {
127
+ if (vms->psci_conduit != QEMU_PSCI_CONDUIT_DISABLED && smp_cpus > 1) {
128
qemu_fdt_setprop_string(vms->fdt, nodename,
129
"enable-method", "psci");
66
}
130
}
67
- binfo.secondary_cpu_reset_hook = reset_secondary;
131
@@ -XXX,XX +XXX,XX @@ static void fdt_add_pmu_nodes(const VirtMachineState *vms)
68
+ s->binfo.secondary_cpu_reset_hook = reset_secondary;
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);
69
}
137
}
70
138
71
/* If the user specified a "firmware" image (e.g. UEFI), we bypass
139
qemu_fdt_add_subnode(vms->fdt, "/pmu");
72
@@ -XXX,XX +XXX,XX @@ static void setup_boot(MachineState *machine, int version, size_t ram_size)
140
@@ -XXX,XX +XXX,XX @@ static void finalize_gic_version(VirtMachineState *vms)
73
exit(1);
141
* virt_cpu_post_init() must be called after the CPUs have
74
}
142
* been realized and the GIC has been created.
75
143
*/
76
- binfo.entry = firmware_addr;
144
-static void virt_cpu_post_init(VirtMachineState *vms, int max_cpus,
77
- binfo.firmware_loaded = true;
145
- MemoryRegion *sysmem)
78
+ s->binfo.entry = firmware_addr;
146
+static void virt_cpu_post_init(VirtMachineState *vms, MemoryRegion *sysmem)
79
+ s->binfo.firmware_loaded = true;
147
{
148
+ int max_cpus = MACHINE(vms)->smp.max_cpus;
149
bool aarch64, pmu, steal_time;
150
CPUState *cpu;
151
152
@@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine)
153
exit(1);
80
}
154
}
81
155
82
- arm_load_kernel(&s->soc.cpu[0].core, machine, &binfo);
156
- vms->smp_cpus = smp_cpus;
83
+ arm_load_kernel(&s->soc.cpu[0].core, machine, &s->binfo);
157
-
84
}
158
if (vms->virt && kvm_enabled()) {
85
159
error_report("mach-virt: KVM does not support providing "
86
static void raspi_machine_init(MachineState *machine)
160
"Virtualization extensions to the guest CPU");
161
@@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine)
162
create_fdt(vms);
163
164
possible_cpus = mc->possible_cpu_arch_ids(machine);
165
+ assert(possible_cpus->len == max_cpus);
166
for (n = 0; n < possible_cpus->len; n++) {
167
Object *cpuobj;
168
CPUState *cs;
169
@@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine)
170
171
create_gic(vms);
172
173
- virt_cpu_post_init(vms, possible_cpus->len, sysmem);
174
+ virt_cpu_post_init(vms, sysmem);
175
176
fdt_add_pmu_nodes(vms);
177
87
--
178
--
88
2.20.1
179
2.20.1
89
180
90
181
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
While converting to gen_gvec_ool_zzzp, we lost passing
3
In 50244cc76abc we updated mte_check_fail to match the ARM
4
a->esz as the data argument to the function.
4
pseudocode, using the correct EL to select the TCF field.
5
But we failed to update MTE0_ACTIVE the same way, which led
6
to g_assert_not_reached().
5
7
6
Fixes: 36cbb7a8e71
7
Cc: qemu-stable@nongnu.org
8
Cc: qemu-stable@nongnu.org
9
Buglink: https://bugs.launchpad.net/bugs/1907137
8
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
10
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20200918000500.2690937-1-richard.henderson@linaro.org
11
Message-id: 20201221204426.88514-1-richard.henderson@linaro.org
10
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
12
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
---
14
---
13
target/arm/translate-sve.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/target/arm/translate-sve.c b/target/arm/translate-sve.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/target/arm/translate-sve.c
20
--- a/target/arm/helper.c
19
+++ b/target/arm/translate-sve.c
21
+++ b/target/arm/helper.c
20
@@ -XXX,XX +XXX,XX @@ static bool trans_SPLICE(DisasContext *s, arg_rprr_esz *a)
22
@@ -XXX,XX +XXX,XX @@ static uint32_t rebuild_hflags_a64(CPUARMState *env, int el, int fp_el,
21
{
23
if (FIELD_EX32(flags, TBFLAG_A64, UNPRIV)
22
if (sve_access_check(s)) {
24
&& tbid
23
gen_gvec_ool_zzzp(s, gen_helper_sve_splice,
25
&& !(env->pstate & PSTATE_TCO)
24
- a->rd, a->rn, a->rm, a->pg, 0);
26
- && (sctlr & SCTLR_TCF0)
25
+ a->rd, a->rn, a->rm, a->pg, a->esz);
27
+ && (sctlr & SCTLR_TCF)
26
}
28
&& allocation_tag_access_enabled(env, 0, sctlr)) {
27
return true;
29
flags = FIELD_DP32(flags, TBFLAG_A64, MTE0_ACTIVE, 1);
28
}
30
}
29
--
31
--
30
2.20.1
32
2.20.1
31
33
32
34
diff view generated by jsdifflib
1
M-profile CPUs only implement the ID registers as guest-visible if
1
The CCR is a register most of whose bits are banked between security
2
the CPU implements the Main Extension (all our current CPUs except
2
states but where BFHFNMIGN is not, and we keep it in the non-secure
3
the Cortex-M0 do).
3
entry of the v7m.ccr[] array. The logic which tries to handle this
4
4
bit fails to implement the "RAZ/WI from Nonsecure if AIRCR.BFHFNMINS
5
Currently we handle this by having the Cortex-M0 leave the ID
5
is zero" requirement; correct the omission.
6
register values in the ARMCPU struct as zero, but this conflicts with
7
our design decision to make QEMU behaviour be keyed off ID register
8
fields wherever possible.
9
10
Explicitly code the ID registers in the NVIC to return 0 if the Main
11
Extension is not implemented, so we can make the M0 model set the
12
ARMCPU struct fields to obtain the correct behaviour without those
13
values becoming guest-visible.
14
6
15
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
16
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
17
Message-id: 20200910173855.4068-4-peter.maydell@linaro.org
9
Message-id: 20201210201433.26262-2-peter.maydell@linaro.org
18
---
10
---
19
hw/intc/armv7m_nvic.c | 42 ++++++++++++++++++++++++++++++++++++++++++
11
hw/intc/armv7m_nvic.c | 15 +++++++++++++++
20
1 file changed, 42 insertions(+)
12
1 file changed, 15 insertions(+)
21
13
22
diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c
14
diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c
23
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
24
--- a/hw/intc/armv7m_nvic.c
16
--- a/hw/intc/armv7m_nvic.c
25
+++ b/hw/intc/armv7m_nvic.c
17
+++ b/hw/intc/armv7m_nvic.c
26
@@ -XXX,XX +XXX,XX @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs)
18
@@ -XXX,XX +XXX,XX @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs)
27
"Aux Fault status registers unimplemented\n");
19
*/
28
return 0;
20
val = cpu->env.v7m.ccr[attrs.secure];
29
case 0xd40: /* PFR0. */
21
val |= cpu->env.v7m.ccr[M_REG_NS] & R_V7M_CCR_BFHFNMIGN_MASK;
30
+ if (!arm_feature(&cpu->env, ARM_FEATURE_M_MAIN)) {
22
+ /* BFHFNMIGN is RAZ/WI from NS if AIRCR.BFHFNMINS is 0 */
31
+ goto bad_offset;
23
+ if (!attrs.secure) {
24
+ if (!(cpu->env.v7m.aircr & R_V7M_AIRCR_BFHFNMINS_MASK)) {
25
+ val &= ~R_V7M_CCR_BFHFNMIGN_MASK;
26
+ }
32
+ }
27
+ }
33
return cpu->isar.id_pfr0;
28
return val;
34
case 0xd44: /* PFR1. */
29
case 0xd24: /* System Handler Control and State (SHCSR) */
35
+ if (!arm_feature(&cpu->env, ARM_FEATURE_M_MAIN)) {
30
if (!arm_feature(&cpu->env, ARM_FEATURE_V7)) {
36
+ goto bad_offset;
31
@@ -XXX,XX +XXX,XX @@ static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value,
37
+ }
32
(cpu->env.v7m.ccr[M_REG_NS] & ~R_V7M_CCR_BFHFNMIGN_MASK)
38
return cpu->isar.id_pfr1;
33
| (value & R_V7M_CCR_BFHFNMIGN_MASK);
39
case 0xd48: /* DFR0. */
34
value &= ~R_V7M_CCR_BFHFNMIGN_MASK;
40
+ if (!arm_feature(&cpu->env, ARM_FEATURE_M_MAIN)) {
35
+ } else {
41
+ goto bad_offset;
36
+ /*
42
+ }
37
+ * BFHFNMIGN is RAZ/WI from NS if AIRCR.BFHFNMINS is 0, so
43
return cpu->isar.id_dfr0;
38
+ * preserve the state currently in the NS element of the array
44
case 0xd4c: /* AFR0. */
39
+ */
45
+ if (!arm_feature(&cpu->env, ARM_FEATURE_M_MAIN)) {
40
+ if (!(cpu->env.v7m.aircr & R_V7M_AIRCR_BFHFNMINS_MASK)) {
46
+ goto bad_offset;
41
+ value &= ~R_V7M_CCR_BFHFNMIGN_MASK;
47
+ }
42
+ value |= cpu->env.v7m.ccr[M_REG_NS] & R_V7M_CCR_BFHFNMIGN_MASK;
48
return cpu->id_afr0;
43
+ }
49
case 0xd50: /* MMFR0. */
44
}
50
+ if (!arm_feature(&cpu->env, ARM_FEATURE_M_MAIN)) {
45
51
+ goto bad_offset;
46
cpu->env.v7m.ccr[attrs.secure] = value;
52
+ }
53
return cpu->isar.id_mmfr0;
54
case 0xd54: /* MMFR1. */
55
+ if (!arm_feature(&cpu->env, ARM_FEATURE_M_MAIN)) {
56
+ goto bad_offset;
57
+ }
58
return cpu->isar.id_mmfr1;
59
case 0xd58: /* MMFR2. */
60
+ if (!arm_feature(&cpu->env, ARM_FEATURE_M_MAIN)) {
61
+ goto bad_offset;
62
+ }
63
return cpu->isar.id_mmfr2;
64
case 0xd5c: /* MMFR3. */
65
+ if (!arm_feature(&cpu->env, ARM_FEATURE_M_MAIN)) {
66
+ goto bad_offset;
67
+ }
68
return cpu->isar.id_mmfr3;
69
case 0xd60: /* ISAR0. */
70
+ if (!arm_feature(&cpu->env, ARM_FEATURE_M_MAIN)) {
71
+ goto bad_offset;
72
+ }
73
return cpu->isar.id_isar0;
74
case 0xd64: /* ISAR1. */
75
+ if (!arm_feature(&cpu->env, ARM_FEATURE_M_MAIN)) {
76
+ goto bad_offset;
77
+ }
78
return cpu->isar.id_isar1;
79
case 0xd68: /* ISAR2. */
80
+ if (!arm_feature(&cpu->env, ARM_FEATURE_M_MAIN)) {
81
+ goto bad_offset;
82
+ }
83
return cpu->isar.id_isar2;
84
case 0xd6c: /* ISAR3. */
85
+ if (!arm_feature(&cpu->env, ARM_FEATURE_M_MAIN)) {
86
+ goto bad_offset;
87
+ }
88
return cpu->isar.id_isar3;
89
case 0xd70: /* ISAR4. */
90
+ if (!arm_feature(&cpu->env, ARM_FEATURE_M_MAIN)) {
91
+ goto bad_offset;
92
+ }
93
return cpu->isar.id_isar4;
94
case 0xd74: /* ISAR5. */
95
+ if (!arm_feature(&cpu->env, ARM_FEATURE_M_MAIN)) {
96
+ goto bad_offset;
97
+ }
98
return cpu->isar.id_isar5;
99
case 0xd78: /* CLIDR */
100
return cpu->clidr;
101
--
47
--
102
2.20.1
48
2.20.1
103
49
104
50
diff view generated by jsdifflib
1
Move the id_pfr0 and id_pfr1 fields into the ARMISARegisters
1
In commit 64f863baeedc8659 we implemented the v8.1M FPCXT_S register,
2
sub-struct. We're going to want id_pfr1 for an isar_features
2
but we got the write behaviour wrong. On read, this register reads
3
check, and moving both at the same time avoids an odd
3
bits [27:0] of FPSCR plus the CONTROL.SFPA bit. On write, it doesn't
4
inconsistency.
4
just write back those bits -- it writes a value to the whole FPSCR,
5
whose upper 4 bits are zeroes.
5
6
6
Changes other than the ones to cpu.h and kvm64.c made
7
We also incorrectly implemented the write-to-FPSCR as a simple store
7
automatically with:
8
to vfp.xregs; this skips the "update the softfloat flags" part of
8
perl -p -i -e 's/cpu->id_pfr/cpu->isar.id_pfr/' target/arm/*.c hw/intc/armv7m_nvic.c
9
the vfp_set_fpscr helper so the value would read back correctly but
10
not actually take effect.
11
12
Fix both of these things by doing a complete write to the FPSCR
13
using the helper function.
9
14
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
15
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
16
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
12
Message-id: 20200910173855.4068-3-peter.maydell@linaro.org
17
Message-id: 20201210201433.26262-3-peter.maydell@linaro.org
13
---
18
---
14
target/arm/cpu.h | 4 ++--
19
target/arm/translate-vfp.c.inc | 12 ++++++------
15
hw/intc/armv7m_nvic.c | 4 ++--
20
1 file changed, 6 insertions(+), 6 deletions(-)
16
target/arm/cpu.c | 20 ++++++++++----------
17
target/arm/cpu64.c | 12 ++++++------
18
target/arm/cpu_tcg.c | 36 ++++++++++++++++++------------------
19
target/arm/helper.c | 4 ++--
20
target/arm/kvm64.c | 4 ++++
21
7 files changed, 44 insertions(+), 40 deletions(-)
22
21
23
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
22
diff --git a/target/arm/translate-vfp.c.inc b/target/arm/translate-vfp.c.inc
24
index XXXXXXX..XXXXXXX 100644
23
index XXXXXXX..XXXXXXX 100644
25
--- a/target/arm/cpu.h
24
--- a/target/arm/translate-vfp.c.inc
26
+++ b/target/arm/cpu.h
25
+++ b/target/arm/translate-vfp.c.inc
27
@@ -XXX,XX +XXX,XX @@ struct ARMCPU {
26
@@ -XXX,XX +XXX,XX @@ static bool gen_M_fp_sysreg_write(DisasContext *s, int regno,
28
uint32_t id_mmfr2;
29
uint32_t id_mmfr3;
30
uint32_t id_mmfr4;
31
+ uint32_t id_pfr0;
32
+ uint32_t id_pfr1;
33
uint32_t mvfr0;
34
uint32_t mvfr1;
35
uint32_t mvfr2;
36
@@ -XXX,XX +XXX,XX @@ struct ARMCPU {
37
uint32_t reset_fpsid;
38
uint32_t ctr;
39
uint32_t reset_sctlr;
40
- uint32_t id_pfr0;
41
- uint32_t id_pfr1;
42
uint64_t pmceid0;
43
uint64_t pmceid1;
44
uint32_t id_afr0;
45
diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c
46
index XXXXXXX..XXXXXXX 100644
47
--- a/hw/intc/armv7m_nvic.c
48
+++ b/hw/intc/armv7m_nvic.c
49
@@ -XXX,XX +XXX,XX @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs)
50
"Aux Fault status registers unimplemented\n");
51
return 0;
52
case 0xd40: /* PFR0. */
53
- return cpu->id_pfr0;
54
+ return cpu->isar.id_pfr0;
55
case 0xd44: /* PFR1. */
56
- return cpu->id_pfr1;
57
+ return cpu->isar.id_pfr1;
58
case 0xd48: /* DFR0. */
59
return cpu->isar.id_dfr0;
60
case 0xd4c: /* AFR0. */
61
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
62
index XXXXXXX..XXXXXXX 100644
63
--- a/target/arm/cpu.c
64
+++ b/target/arm/cpu.c
65
@@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)
66
/* Disable the security extension feature bits in the processor feature
67
* registers as well. These are id_pfr1[7:4] and id_aa64pfr0[15:12].
68
*/
69
- cpu->id_pfr1 &= ~0xf0;
70
+ cpu->isar.id_pfr1 &= ~0xf0;
71
cpu->isar.id_aa64pfr0 &= ~0xf000;
72
}
27
}
73
28
case ARM_VFP_FPCXT_S:
74
@@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)
29
{
75
* id_aa64pfr0_el1[11:8].
30
- TCGv_i32 sfpa, control, fpscr;
76
*/
31
- /* Set FPSCR[27:0] and CONTROL.SFPA from value */
77
cpu->isar.id_aa64pfr0 &= ~0xf00;
32
+ TCGv_i32 sfpa, control;
78
- cpu->id_pfr1 &= ~0xf000;
33
+ /*
79
+ cpu->isar.id_pfr1 &= ~0xf000;
34
+ * Set FPSCR and CONTROL.SFPA from value; the new FPSCR takes
80
}
35
+ * bits [27:0] from value and zeroes bits [31:28].
81
36
+ */
82
#ifndef CONFIG_USER_ONLY
37
tmp = loadfn(s, opaque);
83
@@ -XXX,XX +XXX,XX @@ static void cortex_a8_initfn(Object *obj)
38
sfpa = tcg_temp_new_i32();
84
cpu->isar.mvfr1 = 0x00011111;
39
tcg_gen_shri_i32(sfpa, tmp, 31);
85
cpu->ctr = 0x82048004;
40
@@ -XXX,XX +XXX,XX @@ static bool gen_M_fp_sysreg_write(DisasContext *s, int regno,
86
cpu->reset_sctlr = 0x00c50078;
41
tcg_gen_deposit_i32(control, control, sfpa,
87
- cpu->id_pfr0 = 0x1031;
42
R_V7M_CONTROL_SFPA_SHIFT, 1);
88
- cpu->id_pfr1 = 0x11;
43
store_cpu_field(control, v7m.control[M_REG_S]);
89
+ cpu->isar.id_pfr0 = 0x1031;
44
- fpscr = load_cpu_field(vfp.xregs[ARM_VFP_FPSCR]);
90
+ cpu->isar.id_pfr1 = 0x11;
45
- tcg_gen_andi_i32(fpscr, fpscr, FPCR_NZCV_MASK);
91
cpu->isar.id_dfr0 = 0x400;
46
tcg_gen_andi_i32(tmp, tmp, ~FPCR_NZCV_MASK);
92
cpu->id_afr0 = 0;
47
- tcg_gen_or_i32(fpscr, fpscr, tmp);
93
cpu->isar.id_mmfr0 = 0x31100003;
48
- store_cpu_field(fpscr, vfp.xregs[ARM_VFP_FPSCR]);
94
@@ -XXX,XX +XXX,XX @@ static void cortex_a9_initfn(Object *obj)
49
+ gen_helper_vfp_set_fpscr(cpu_env, tmp);
95
cpu->isar.mvfr1 = 0x01111111;
50
tcg_temp_free_i32(tmp);
96
cpu->ctr = 0x80038003;
51
tcg_temp_free_i32(sfpa);
97
cpu->reset_sctlr = 0x00c50078;
52
break;
98
- cpu->id_pfr0 = 0x1031;
99
- cpu->id_pfr1 = 0x11;
100
+ cpu->isar.id_pfr0 = 0x1031;
101
+ cpu->isar.id_pfr1 = 0x11;
102
cpu->isar.id_dfr0 = 0x000;
103
cpu->id_afr0 = 0;
104
cpu->isar.id_mmfr0 = 0x00100103;
105
@@ -XXX,XX +XXX,XX @@ static void cortex_a7_initfn(Object *obj)
106
cpu->isar.mvfr1 = 0x11111111;
107
cpu->ctr = 0x84448003;
108
cpu->reset_sctlr = 0x00c50078;
109
- cpu->id_pfr0 = 0x00001131;
110
- cpu->id_pfr1 = 0x00011011;
111
+ cpu->isar.id_pfr0 = 0x00001131;
112
+ cpu->isar.id_pfr1 = 0x00011011;
113
cpu->isar.id_dfr0 = 0x02010555;
114
cpu->id_afr0 = 0x00000000;
115
cpu->isar.id_mmfr0 = 0x10101105;
116
@@ -XXX,XX +XXX,XX @@ static void cortex_a15_initfn(Object *obj)
117
cpu->isar.mvfr1 = 0x11111111;
118
cpu->ctr = 0x8444c004;
119
cpu->reset_sctlr = 0x00c50078;
120
- cpu->id_pfr0 = 0x00001131;
121
- cpu->id_pfr1 = 0x00011011;
122
+ cpu->isar.id_pfr0 = 0x00001131;
123
+ cpu->isar.id_pfr1 = 0x00011011;
124
cpu->isar.id_dfr0 = 0x02010555;
125
cpu->id_afr0 = 0x00000000;
126
cpu->isar.id_mmfr0 = 0x10201105;
127
diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c
128
index XXXXXXX..XXXXXXX 100644
129
--- a/target/arm/cpu64.c
130
+++ b/target/arm/cpu64.c
131
@@ -XXX,XX +XXX,XX @@ static void aarch64_a57_initfn(Object *obj)
132
cpu->isar.mvfr2 = 0x00000043;
133
cpu->ctr = 0x8444c004;
134
cpu->reset_sctlr = 0x00c50838;
135
- cpu->id_pfr0 = 0x00000131;
136
- cpu->id_pfr1 = 0x00011011;
137
+ cpu->isar.id_pfr0 = 0x00000131;
138
+ cpu->isar.id_pfr1 = 0x00011011;
139
cpu->isar.id_dfr0 = 0x03010066;
140
cpu->id_afr0 = 0x00000000;
141
cpu->isar.id_mmfr0 = 0x10101105;
142
@@ -XXX,XX +XXX,XX @@ static void aarch64_a53_initfn(Object *obj)
143
cpu->isar.mvfr2 = 0x00000043;
144
cpu->ctr = 0x84448004; /* L1Ip = VIPT */
145
cpu->reset_sctlr = 0x00c50838;
146
- cpu->id_pfr0 = 0x00000131;
147
- cpu->id_pfr1 = 0x00011011;
148
+ cpu->isar.id_pfr0 = 0x00000131;
149
+ cpu->isar.id_pfr1 = 0x00011011;
150
cpu->isar.id_dfr0 = 0x03010066;
151
cpu->id_afr0 = 0x00000000;
152
cpu->isar.id_mmfr0 = 0x10101105;
153
@@ -XXX,XX +XXX,XX @@ static void aarch64_a72_initfn(Object *obj)
154
cpu->isar.mvfr2 = 0x00000043;
155
cpu->ctr = 0x8444c004;
156
cpu->reset_sctlr = 0x00c50838;
157
- cpu->id_pfr0 = 0x00000131;
158
- cpu->id_pfr1 = 0x00011011;
159
+ cpu->isar.id_pfr0 = 0x00000131;
160
+ cpu->isar.id_pfr1 = 0x00011011;
161
cpu->isar.id_dfr0 = 0x03010066;
162
cpu->id_afr0 = 0x00000000;
163
cpu->isar.id_mmfr0 = 0x10201105;
164
diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c
165
index XXXXXXX..XXXXXXX 100644
166
--- a/target/arm/cpu_tcg.c
167
+++ b/target/arm/cpu_tcg.c
168
@@ -XXX,XX +XXX,XX @@ static void arm1136_r2_initfn(Object *obj)
169
cpu->isar.mvfr1 = 0x00000000;
170
cpu->ctr = 0x1dd20d2;
171
cpu->reset_sctlr = 0x00050078;
172
- cpu->id_pfr0 = 0x111;
173
- cpu->id_pfr1 = 0x1;
174
+ cpu->isar.id_pfr0 = 0x111;
175
+ cpu->isar.id_pfr1 = 0x1;
176
cpu->isar.id_dfr0 = 0x2;
177
cpu->id_afr0 = 0x3;
178
cpu->isar.id_mmfr0 = 0x01130003;
179
@@ -XXX,XX +XXX,XX @@ static void arm1136_initfn(Object *obj)
180
cpu->isar.mvfr1 = 0x00000000;
181
cpu->ctr = 0x1dd20d2;
182
cpu->reset_sctlr = 0x00050078;
183
- cpu->id_pfr0 = 0x111;
184
- cpu->id_pfr1 = 0x1;
185
+ cpu->isar.id_pfr0 = 0x111;
186
+ cpu->isar.id_pfr1 = 0x1;
187
cpu->isar.id_dfr0 = 0x2;
188
cpu->id_afr0 = 0x3;
189
cpu->isar.id_mmfr0 = 0x01130003;
190
@@ -XXX,XX +XXX,XX @@ static void arm1176_initfn(Object *obj)
191
cpu->isar.mvfr1 = 0x00000000;
192
cpu->ctr = 0x1dd20d2;
193
cpu->reset_sctlr = 0x00050078;
194
- cpu->id_pfr0 = 0x111;
195
- cpu->id_pfr1 = 0x11;
196
+ cpu->isar.id_pfr0 = 0x111;
197
+ cpu->isar.id_pfr1 = 0x11;
198
cpu->isar.id_dfr0 = 0x33;
199
cpu->id_afr0 = 0;
200
cpu->isar.id_mmfr0 = 0x01130003;
201
@@ -XXX,XX +XXX,XX @@ static void arm11mpcore_initfn(Object *obj)
202
cpu->isar.mvfr0 = 0x11111111;
203
cpu->isar.mvfr1 = 0x00000000;
204
cpu->ctr = 0x1d192992; /* 32K icache 32K dcache */
205
- cpu->id_pfr0 = 0x111;
206
- cpu->id_pfr1 = 0x1;
207
+ cpu->isar.id_pfr0 = 0x111;
208
+ cpu->isar.id_pfr1 = 0x1;
209
cpu->isar.id_dfr0 = 0;
210
cpu->id_afr0 = 0x2;
211
cpu->isar.id_mmfr0 = 0x01100103;
212
@@ -XXX,XX +XXX,XX @@ static void cortex_m3_initfn(Object *obj)
213
set_feature(&cpu->env, ARM_FEATURE_M_MAIN);
214
cpu->midr = 0x410fc231;
215
cpu->pmsav7_dregion = 8;
216
- cpu->id_pfr0 = 0x00000030;
217
- cpu->id_pfr1 = 0x00000200;
218
+ cpu->isar.id_pfr0 = 0x00000030;
219
+ cpu->isar.id_pfr1 = 0x00000200;
220
cpu->isar.id_dfr0 = 0x00100000;
221
cpu->id_afr0 = 0x00000000;
222
cpu->isar.id_mmfr0 = 0x00000030;
223
@@ -XXX,XX +XXX,XX @@ static void cortex_m4_initfn(Object *obj)
224
cpu->isar.mvfr0 = 0x10110021;
225
cpu->isar.mvfr1 = 0x11000011;
226
cpu->isar.mvfr2 = 0x00000000;
227
- cpu->id_pfr0 = 0x00000030;
228
- cpu->id_pfr1 = 0x00000200;
229
+ cpu->isar.id_pfr0 = 0x00000030;
230
+ cpu->isar.id_pfr1 = 0x00000200;
231
cpu->isar.id_dfr0 = 0x00100000;
232
cpu->id_afr0 = 0x00000000;
233
cpu->isar.id_mmfr0 = 0x00000030;
234
@@ -XXX,XX +XXX,XX @@ static void cortex_m7_initfn(Object *obj)
235
cpu->isar.mvfr0 = 0x10110221;
236
cpu->isar.mvfr1 = 0x12000011;
237
cpu->isar.mvfr2 = 0x00000040;
238
- cpu->id_pfr0 = 0x00000030;
239
- cpu->id_pfr1 = 0x00000200;
240
+ cpu->isar.id_pfr0 = 0x00000030;
241
+ cpu->isar.id_pfr1 = 0x00000200;
242
cpu->isar.id_dfr0 = 0x00100000;
243
cpu->id_afr0 = 0x00000000;
244
cpu->isar.id_mmfr0 = 0x00100030;
245
@@ -XXX,XX +XXX,XX @@ static void cortex_m33_initfn(Object *obj)
246
cpu->isar.mvfr0 = 0x10110021;
247
cpu->isar.mvfr1 = 0x11000011;
248
cpu->isar.mvfr2 = 0x00000040;
249
- cpu->id_pfr0 = 0x00000030;
250
- cpu->id_pfr1 = 0x00000210;
251
+ cpu->isar.id_pfr0 = 0x00000030;
252
+ cpu->isar.id_pfr1 = 0x00000210;
253
cpu->isar.id_dfr0 = 0x00200000;
254
cpu->id_afr0 = 0x00000000;
255
cpu->isar.id_mmfr0 = 0x00101F40;
256
@@ -XXX,XX +XXX,XX @@ static void cortex_r5_initfn(Object *obj)
257
set_feature(&cpu->env, ARM_FEATURE_PMSA);
258
set_feature(&cpu->env, ARM_FEATURE_PMU);
259
cpu->midr = 0x411fc153; /* r1p3 */
260
- cpu->id_pfr0 = 0x0131;
261
- cpu->id_pfr1 = 0x001;
262
+ cpu->isar.id_pfr0 = 0x0131;
263
+ cpu->isar.id_pfr1 = 0x001;
264
cpu->isar.id_dfr0 = 0x010400;
265
cpu->id_afr0 = 0x0;
266
cpu->isar.id_mmfr0 = 0x0210030;
267
diff --git a/target/arm/helper.c b/target/arm/helper.c
268
index XXXXXXX..XXXXXXX 100644
269
--- a/target/arm/helper.c
270
+++ b/target/arm/helper.c
271
@@ -XXX,XX +XXX,XX @@ static void define_pmu_regs(ARMCPU *cpu)
272
static uint64_t id_pfr1_read(CPUARMState *env, const ARMCPRegInfo *ri)
273
{
274
ARMCPU *cpu = env_archcpu(env);
275
- uint64_t pfr1 = cpu->id_pfr1;
276
+ uint64_t pfr1 = cpu->isar.id_pfr1;
277
278
if (env->gicv3state) {
279
pfr1 |= 1 << 28;
280
@@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu)
281
.opc0 = 3, .opc1 = 0, .crn = 0, .crm = 1, .opc2 = 0,
282
.access = PL1_R, .type = ARM_CP_CONST,
283
.accessfn = access_aa32_tid3,
284
- .resetvalue = cpu->id_pfr0 },
285
+ .resetvalue = cpu->isar.id_pfr0 },
286
/* ID_PFR1 is not a plain ARM_CP_CONST because we don't know
287
* the value of the GIC field until after we define these regs.
288
*/
289
diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c
290
index XXXXXXX..XXXXXXX 100644
291
--- a/target/arm/kvm64.c
292
+++ b/target/arm/kvm64.c
293
@@ -XXX,XX +XXX,XX @@ bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf)
294
* than skipping the reads and leaving 0, as we must avoid
295
* considering the values in every case.
296
*/
297
+ err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_pfr0,
298
+ ARM64_SYS_REG(3, 0, 0, 1, 0));
299
+ err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_pfr1,
300
+ ARM64_SYS_REG(3, 0, 0, 1, 1));
301
err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_dfr0,
302
ARM64_SYS_REG(3, 0, 0, 1, 2));
303
err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_mmfr0,
304
--
53
--
305
2.20.1
54
2.20.1
306
55
307
56
diff view generated by jsdifflib
1
The M-profile definition of the MVFR1 ID register differs slightly
1
Implement the v8.1M FPCXT_NS floating-point system register. This is
2
from the A-profile one, and in particular the check for "does the CPU
2
a little more complicated than FPCXT_S, because it has specific
3
support fp16 arithmetic" is not the same.
3
handling for "current FP state is inactive", and it only wants to do
4
4
PreserveFPState(), not the full set of actions done by
5
We don't currently implement any M-profile CPUs with fp16 arithmetic,
5
ExecuteFPCheck() which vfp_access_check() implements.
6
so this is not yet a visible bug, but correcting the logic now
7
disarms this beartrap for when we eventually do.
8
6
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
11
Message-id: 20200910173855.4068-6-peter.maydell@linaro.org
9
Message-id: 20201210201433.26262-4-peter.maydell@linaro.org
12
---
10
---
13
target/arm/cpu.h | 31 ++++++++++++++++++++++++++-----
11
target/arm/translate-vfp.c.inc | 102 ++++++++++++++++++++++++++++++++-
14
1 file changed, 26 insertions(+), 5 deletions(-)
12
1 file changed, 99 insertions(+), 3 deletions(-)
15
13
16
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
14
diff --git a/target/arm/translate-vfp.c.inc b/target/arm/translate-vfp.c.inc
17
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
18
--- a/target/arm/cpu.h
16
--- a/target/arm/translate-vfp.c.inc
19
+++ b/target/arm/cpu.h
17
+++ b/target/arm/translate-vfp.c.inc
20
@@ -XXX,XX +XXX,XX @@ FIELD(ID_MMFR4, LSM, 20, 4)
18
@@ -XXX,XX +XXX,XX @@ static FPSysRegCheckResult fp_sysreg_checks(DisasContext *s, int regno)
21
FIELD(ID_MMFR4, CCIDX, 24, 4)
19
}
22
FIELD(ID_MMFR4, EVT, 28, 4)
20
break;
23
21
case ARM_VFP_FPCXT_S:
24
+FIELD(ID_PFR1, PROGMOD, 0, 4)
22
+ case ARM_VFP_FPCXT_NS:
25
+FIELD(ID_PFR1, SECURITY, 4, 4)
23
if (!arm_dc_feature(s, ARM_FEATURE_V8_1M)) {
26
+FIELD(ID_PFR1, MPROGMOD, 8, 4)
24
return false;
27
+FIELD(ID_PFR1, VIRTUALIZATION, 12, 4)
25
}
28
+FIELD(ID_PFR1, GENTIMER, 16, 4)
26
@@ -XXX,XX +XXX,XX @@ static FPSysRegCheckResult fp_sysreg_checks(DisasContext *s, int regno)
29
+FIELD(ID_PFR1, SEC_FRAC, 20, 4)
27
return FPSysRegCheckFailed;
30
+FIELD(ID_PFR1, VIRT_FRAC, 24, 4)
28
}
31
+FIELD(ID_PFR1, GIC, 28, 4)
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);
32
+
60
+
33
FIELD(ID_AA64ISAR0, AES, 4, 4)
61
+ /* fpInactive = FPCCR_NS.ASPEN == 1 && CONTROL.FPCA == 0 */
34
FIELD(ID_AA64ISAR0, SHA1, 8, 4)
62
+ TCGv_i32 aspen, fpca;
35
FIELD(ID_AA64ISAR0, SHA2, 12, 4)
63
+ aspen = load_cpu_field(v7m.fpccr[M_REG_NS]);
36
@@ -XXX,XX +XXX,XX @@ FIELD(MVFR0, FPROUND, 28, 4)
64
+ fpca = load_cpu_field(v7m.control[M_REG_S]);
37
65
+ tcg_gen_andi_i32(aspen, aspen, R_V7M_FPCCR_ASPEN_MASK);
38
FIELD(MVFR1, FPFTZ, 0, 4)
66
+ tcg_gen_xori_i32(aspen, aspen, R_V7M_FPCCR_ASPEN_MASK);
39
FIELD(MVFR1, FPDNAN, 4, 4)
67
+ tcg_gen_andi_i32(fpca, fpca, R_V7M_CONTROL_FPCA_MASK);
40
-FIELD(MVFR1, SIMDLS, 8, 4)
68
+ tcg_gen_or_i32(fpca, fpca, aspen);
41
-FIELD(MVFR1, SIMDINT, 12, 4)
69
+ tcg_gen_brcondi_i32(tcg_invert_cond(cond), fpca, 0, label);
42
-FIELD(MVFR1, SIMDSP, 16, 4)
70
+ tcg_temp_free_i32(aspen);
43
-FIELD(MVFR1, SIMDHP, 20, 4)
71
+ tcg_temp_free_i32(fpca);
44
+FIELD(MVFR1, SIMDLS, 8, 4) /* A-profile only */
45
+FIELD(MVFR1, SIMDINT, 12, 4) /* A-profile only */
46
+FIELD(MVFR1, SIMDSP, 16, 4) /* A-profile only */
47
+FIELD(MVFR1, SIMDHP, 20, 4) /* A-profile only */
48
+FIELD(MVFR1, MVE, 8, 4) /* M-profile only */
49
+FIELD(MVFR1, FP16, 20, 4) /* M-profile only */
50
FIELD(MVFR1, FPHP, 24, 4)
51
FIELD(MVFR1, SIMDFMAC, 28, 4)
52
53
@@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa32_predinv(const ARMISARegisters *id)
54
return FIELD_EX32(id->id_isar6, ID_ISAR6, SPECRES) != 0;
55
}
56
57
+static inline bool isar_feature_aa32_mprofile(const ARMISARegisters *id)
58
+{
59
+ return FIELD_EX32(id->id_pfr1, ID_PFR1, MPROGMOD) != 0;
60
+}
72
+}
61
+
73
+
62
static inline bool isar_feature_aa32_fp16_arith(const ARMISARegisters *id)
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,
63
{
78
{
64
- return FIELD_EX32(id->mvfr1, MVFR1, FPHP) >= 3;
79
/* Do a write to an M-profile floating point system register */
65
+ /* Sadly this is encoded differently for A-profile and M-profile */
80
TCGv_i32 tmp;
66
+ if (isar_feature_aa32_mprofile(id)) {
81
+ TCGLabel *lab_end = NULL;
67
+ return FIELD_EX32(id->mvfr1, MVFR1, FP16) > 0;
82
68
+ } else {
83
switch (fp_sysreg_checks(s, regno)) {
69
+ return FIELD_EX32(id->mvfr1, MVFR1, FPHP) >= 3;
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,
100
default:
101
g_assert_not_reached();
102
}
103
+ if (lab_end) {
104
+ gen_set_label(lab_end);
70
+ }
105
+ }
106
return true;
71
}
107
}
72
108
73
static inline bool isar_feature_aa32_vfp_simd(const ARMISARegisters *id)
109
@@ -XXX,XX +XXX,XX @@ static bool gen_M_fp_sysreg_read(DisasContext *s, int regno,
110
{
111
/* Do a read from an M-profile floating point system register */
112
TCGv_i32 tmp;
113
+ TCGLabel *lab_end = NULL;
114
+ bool lookup_tb = false;
115
116
switch (fp_sysreg_checks(s, regno)) {
117
case FPSysRegCheckFailed:
118
@@ -XXX,XX +XXX,XX @@ static bool gen_M_fp_sysreg_read(DisasContext *s, int regno,
119
fpscr = load_cpu_field(v7m.fpdscr[M_REG_NS]);
120
gen_helper_vfp_set_fpscr(cpu_env, fpscr);
121
tcg_temp_free_i32(fpscr);
122
- gen_lookup_tb(s);
123
+ lookup_tb = true;
124
+ break;
125
+ }
126
+ case ARM_VFP_FPCXT_NS:
127
+ {
128
+ TCGv_i32 control, sfpa, fpscr, fpdscr, zero;
129
+ TCGLabel *lab_active = gen_new_label();
130
+
131
+ lookup_tb = true;
132
+
133
+ gen_branch_fpInactive(s, TCG_COND_EQ, lab_active);
134
+ /* fpInactive case: reads as FPDSCR_NS */
135
+ TCGv_i32 tmp = load_cpu_field(v7m.fpdscr[M_REG_NS]);
136
+ storefn(s, opaque, tmp);
137
+ lab_end = gen_new_label();
138
+ tcg_gen_br(lab_end);
139
+
140
+ gen_set_label(lab_active);
141
+ /* !fpInactive: Reads the same as FPCXT_S, but side effects differ */
142
+ gen_preserve_fp_state(s);
143
+ tmp = tcg_temp_new_i32();
144
+ sfpa = tcg_temp_new_i32();
145
+ fpscr = tcg_temp_new_i32();
146
+ gen_helper_vfp_get_fpscr(fpscr, cpu_env);
147
+ tcg_gen_andi_i32(tmp, fpscr, ~FPCR_NZCV_MASK);
148
+ control = load_cpu_field(v7m.control[M_REG_S]);
149
+ tcg_gen_andi_i32(sfpa, control, R_V7M_CONTROL_SFPA_MASK);
150
+ tcg_gen_shli_i32(sfpa, sfpa, 31 - R_V7M_CONTROL_SFPA_SHIFT);
151
+ tcg_gen_or_i32(tmp, tmp, sfpa);
152
+ tcg_temp_free_i32(control);
153
+ /* Store result before updating FPSCR, in case it faults */
154
+ storefn(s, opaque, tmp);
155
+ /* If SFPA is zero then set FPSCR from FPDSCR_NS */
156
+ fpdscr = load_cpu_field(v7m.fpdscr[M_REG_NS]);
157
+ zero = tcg_const_i32(0);
158
+ tcg_gen_movcond_i32(TCG_COND_EQ, fpscr, sfpa, zero, fpdscr, fpscr);
159
+ gen_helper_vfp_set_fpscr(cpu_env, fpscr);
160
+ tcg_temp_free_i32(zero);
161
+ tcg_temp_free_i32(sfpa);
162
+ tcg_temp_free_i32(fpdscr);
163
+ tcg_temp_free_i32(fpscr);
164
break;
165
}
166
default:
167
g_assert_not_reached();
168
}
169
+
170
+ if (lab_end) {
171
+ gen_set_label(lab_end);
172
+ }
173
+ if (lookup_tb) {
174
+ gen_lookup_tb(s);
175
+ }
176
return true;
177
}
178
74
--
179
--
75
2.20.1
180
2.20.1
76
181
77
182
diff view generated by jsdifflib
1
Give the Cortex-M0 ID register values corresponding to its
1
Now that we have implemented all the features needed by the v8.1M
2
implemented behaviour. These will not be guest-visible but will be
2
architecture, we can add the model of the Cortex-M55. This is the
3
used to govern the behaviour of QEMU's emulation. We use the same
3
configuration without MVE support; we'll add MVE later.
4
values that the Cortex-M3 does.
5
4
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20200910173855.4068-5-peter.maydell@linaro.org
7
Message-id: 20201210201433.26262-5-peter.maydell@linaro.org
9
---
8
---
10
target/arm/cpu_tcg.c | 24 ++++++++++++++++++++++++
9
target/arm/cpu_tcg.c | 42 ++++++++++++++++++++++++++++++++++++++++++
11
1 file changed, 24 insertions(+)
10
1 file changed, 42 insertions(+)
12
11
13
diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c
12
diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c
14
index XXXXXXX..XXXXXXX 100644
13
index XXXXXXX..XXXXXXX 100644
15
--- a/target/arm/cpu_tcg.c
14
--- a/target/arm/cpu_tcg.c
16
+++ b/target/arm/cpu_tcg.c
15
+++ b/target/arm/cpu_tcg.c
17
@@ -XXX,XX +XXX,XX @@ static void cortex_m0_initfn(Object *obj)
16
@@ -XXX,XX +XXX,XX @@ static void cortex_m33_initfn(Object *obj)
18
set_feature(&cpu->env, ARM_FEATURE_M);
17
cpu->ctr = 0x8000c000;
19
18
}
20
cpu->midr = 0x410cc200;
19
20
+static void cortex_m55_initfn(Object *obj)
21
+{
22
+ ARMCPU *cpu = ARM_CPU(obj);
21
+
23
+
24
+ set_feature(&cpu->env, ARM_FEATURE_V8);
25
+ set_feature(&cpu->env, ARM_FEATURE_V8_1M);
26
+ set_feature(&cpu->env, ARM_FEATURE_M);
27
+ set_feature(&cpu->env, ARM_FEATURE_M_MAIN);
28
+ set_feature(&cpu->env, ARM_FEATURE_M_SECURITY);
29
+ set_feature(&cpu->env, ARM_FEATURE_THUMB_DSP);
30
+ cpu->midr = 0x410fd221; /* r0p1 */
31
+ cpu->revidr = 0;
32
+ cpu->pmsav7_dregion = 16;
33
+ cpu->sau_sregion = 8;
22
+ /*
34
+ /*
23
+ * These ID register values are not guest visible, because
35
+ * These are the MVFR* values for the FPU, no MVE configuration;
24
+ * we do not implement the Main Extension. They must be set
36
+ * we will update them later when we implement MVE
25
+ * to values corresponding to the Cortex-M0's implemented
26
+ * features, because QEMU generally controls its emulation
27
+ * by looking at ID register fields. We use the same values as
28
+ * for the M3.
29
+ */
37
+ */
30
+ cpu->isar.id_pfr0 = 0x00000030;
38
+ cpu->isar.mvfr0 = 0x10110221;
31
+ cpu->isar.id_pfr1 = 0x00000200;
39
+ cpu->isar.mvfr1 = 0x12100011;
32
+ cpu->isar.id_dfr0 = 0x00100000;
40
+ cpu->isar.mvfr2 = 0x00000040;
41
+ cpu->isar.id_pfr0 = 0x20000030;
42
+ cpu->isar.id_pfr1 = 0x00000230;
43
+ cpu->isar.id_dfr0 = 0x10200000;
33
+ cpu->id_afr0 = 0x00000000;
44
+ cpu->id_afr0 = 0x00000000;
34
+ cpu->isar.id_mmfr0 = 0x00000030;
45
+ cpu->isar.id_mmfr0 = 0x00111040;
35
+ cpu->isar.id_mmfr1 = 0x00000000;
46
+ cpu->isar.id_mmfr1 = 0x00000000;
36
+ cpu->isar.id_mmfr2 = 0x00000000;
47
+ cpu->isar.id_mmfr2 = 0x01000000;
37
+ cpu->isar.id_mmfr3 = 0x00000000;
48
+ cpu->isar.id_mmfr3 = 0x00000011;
38
+ cpu->isar.id_isar0 = 0x01141110;
49
+ cpu->isar.id_isar0 = 0x01103110;
39
+ cpu->isar.id_isar1 = 0x02111000;
50
+ cpu->isar.id_isar1 = 0x02212000;
40
+ cpu->isar.id_isar2 = 0x21112231;
51
+ cpu->isar.id_isar2 = 0x20232232;
41
+ cpu->isar.id_isar3 = 0x01111110;
52
+ cpu->isar.id_isar3 = 0x01111131;
42
+ cpu->isar.id_isar4 = 0x01310102;
53
+ cpu->isar.id_isar4 = 0x01310132;
43
+ cpu->isar.id_isar5 = 0x00000000;
54
+ cpu->isar.id_isar5 = 0x00000000;
44
+ cpu->isar.id_isar6 = 0x00000000;
55
+ cpu->isar.id_isar6 = 0x00000000;
45
}
56
+ cpu->clidr = 0x00000000; /* caches not implemented */
46
57
+ cpu->ctr = 0x8303c003;
47
static void cortex_m3_initfn(Object *obj)
58
+}
59
+
60
static const ARMCPRegInfo cortexr5_cp_reginfo[] = {
61
/* Dummy the TCM region regs for the moment */
62
{ .name = "ATCM", .cp = 15, .opc1 = 0, .crn = 9, .crm = 1, .opc2 = 0,
63
@@ -XXX,XX +XXX,XX @@ static const ARMCPUInfo arm_tcg_cpus[] = {
64
.class_init = arm_v7m_class_init },
65
{ .name = "cortex-m33", .initfn = cortex_m33_initfn,
66
.class_init = arm_v7m_class_init },
67
+ { .name = "cortex-m55", .initfn = cortex_m55_initfn,
68
+ .class_init = arm_v7m_class_init },
69
{ .name = "cortex-r5", .initfn = cortex_r5_initfn },
70
{ .name = "cortex-r5f", .initfn = cortex_r5f_initfn },
71
{ .name = "ti925t", .initfn = ti925t_initfn },
48
--
72
--
49
2.20.1
73
2.20.1
50
74
51
75
diff view generated by jsdifflib
New patch
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.
1
8
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
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(-)
16
17
diff --git a/hw/arm/highbank.c b/hw/arm/highbank.c
18
index XXXXXXX..XXXXXXX 100644
19
--- a/hw/arm/highbank.c
20
+++ b/hw/arm/highbank.c
21
@@ -XXX,XX +XXX,XX @@
22
#include "hw/arm/boot.h"
23
#include "hw/loader.h"
24
#include "net/net.h"
25
-#include "sysemu/kvm.h"
26
#include "sysemu/runstate.h"
27
#include "sysemu/sysemu.h"
28
#include "hw/boards.h"
29
@@ -XXX,XX +XXX,XX @@
30
#include "hw/cpu/a15mpcore.h"
31
#include "qemu/log.h"
32
#include "qom/object.h"
33
+#include "cpu.h"
34
35
#define SMP_BOOT_ADDR 0x100
36
#define SMP_BOOT_REG 0x40
37
@@ -XXX,XX +XXX,XX @@ static void calxeda_init(MachineState *machine, enum cxmachines machine_id)
38
highbank_binfo.loader_start = 0;
39
highbank_binfo.write_secondary_boot = hb_write_secondary;
40
highbank_binfo.secondary_cpu_reset_hook = hb_reset_secondary;
41
- if (!kvm_enabled()) {
42
- highbank_binfo.board_setup_addr = BOARD_SETUP_ADDR;
43
- highbank_binfo.write_board_setup = hb_write_board_setup;
44
- highbank_binfo.secure_board_setup = true;
45
- } else {
46
- warn_report("cannot load built-in Monitor support "
47
- "if KVM is enabled. Some guests (such as Linux) "
48
- "may not boot.");
49
- }
50
+ highbank_binfo.board_setup_addr = BOARD_SETUP_ADDR;
51
+ highbank_binfo.write_board_setup = hb_write_board_setup;
52
+ highbank_binfo.secure_board_setup = true;
53
54
arm_load_kernel(ARM_CPU(first_cpu), machine, &highbank_binfo);
55
}
56
--
57
2.20.1
58
59
diff view generated by jsdifflib
New patch
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\>'
1
8
9
This is unfortunate API design as it makes it easy to accidentally
10
misuse (by forgetting the timer_del()), and the correct use is
11
annoyingly verbose.
12
13
Make timer_free() imply a timer_del().
14
15
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
16
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
17
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
18
Message-id: 20201215154107.3255-2-peter.maydell@linaro.org
19
---
20
include/qemu/timer.h | 24 +++++++++++++-----------
21
1 file changed, 13 insertions(+), 11 deletions(-)
22
23
diff --git a/include/qemu/timer.h b/include/qemu/timer.h
24
index XXXXXXX..XXXXXXX 100644
25
--- a/include/qemu/timer.h
26
+++ b/include/qemu/timer.h
27
@@ -XXX,XX +XXX,XX @@ static inline QEMUTimer *timer_new_ms(QEMUClockType type, QEMUTimerCB *cb,
28
*/
29
void timer_deinit(QEMUTimer *ts);
30
31
-/**
32
- * timer_free:
33
- * @ts: the timer
34
- *
35
- * Free a timer (it must not be on the active list)
36
- */
37
-static inline void timer_free(QEMUTimer *ts)
38
-{
39
- g_free(ts);
40
-}
41
-
42
/**
43
* timer_del:
44
* @ts: the timer
45
@@ -XXX,XX +XXX,XX @@ static inline void timer_free(QEMUTimer *ts)
46
*/
47
void timer_del(QEMUTimer *ts);
48
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
65
--
66
2.20.1
67
68
diff view generated by jsdifflib
New patch
1
Now that timer_free() implicitly calls timer_del(), sequences
2
timer_del(mytimer);
3
timer_free(mytimer);
1
4
5
can be simplified to just
6
timer_free(mytimer);
7
8
Add a Coccinelle script to do this transformation.
9
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
12
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
13
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
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
19
20
diff --git a/scripts/coccinelle/timer-del-timer-free.cocci b/scripts/coccinelle/timer-del-timer-free.cocci
21
new file mode 100644
22
index XXXXXXX..XXXXXXX
23
--- /dev/null
24
+++ b/scripts/coccinelle/timer-del-timer-free.cocci
25
@@ -XXX,XX +XXX,XX @@
26
+// Remove superfluous timer_del() calls
27
+//
28
+// Copyright Linaro Limited 2020
29
+// This work is licensed under the terms of the GNU GPLv2 or later.
30
+//
31
+// spatch --macro-file scripts/cocci-macro-file.h \
32
+// --sp-file scripts/coccinelle/timer-del-timer-free.cocci \
33
+// --in-place --dir .
34
+//
35
+// The timer_free() function now implicitly calls timer_del()
36
+// for you, so calls to timer_del() immediately before the
37
+// timer_free() of the same timer can be deleted.
38
+
39
+@@
40
+expression T;
41
+@@
42
+-timer_del(T);
43
+ timer_free(T);
44
--
45
2.20.1
46
47
diff view generated by jsdifflib
New patch
1
This commit is the result of running the timer-del-timer-free.cocci
2
script on the whole source tree.
1
3
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Acked-by: Corey Minyard <cminyard@mvista.com>
6
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
7
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
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(-)
54
55
diff --git a/block/iscsi.c b/block/iscsi.c
56
index XXXXXXX..XXXXXXX 100644
57
--- a/block/iscsi.c
58
+++ b/block/iscsi.c
59
@@ -XXX,XX +XXX,XX @@ static void iscsi_detach_aio_context(BlockDriverState *bs)
60
iscsilun->events = 0;
61
62
if (iscsilun->nop_timer) {
63
- timer_del(iscsilun->nop_timer);
64
timer_free(iscsilun->nop_timer);
65
iscsilun->nop_timer = NULL;
66
}
67
if (iscsilun->event_timer) {
68
- timer_del(iscsilun->event_timer);
69
timer_free(iscsilun->event_timer);
70
iscsilun->event_timer = NULL;
71
}
72
diff --git a/block/nbd.c b/block/nbd.c
73
index XXXXXXX..XXXXXXX 100644
74
--- a/block/nbd.c
75
+++ b/block/nbd.c
76
@@ -XXX,XX +XXX,XX @@ static void nbd_recv_coroutines_wake_all(BDRVNBDState *s)
77
static void reconnect_delay_timer_del(BDRVNBDState *s)
78
{
79
if (s->reconnect_delay_timer) {
80
- timer_del(s->reconnect_delay_timer);
81
timer_free(s->reconnect_delay_timer);
82
s->reconnect_delay_timer = NULL;
83
}
84
diff --git a/block/qcow2.c b/block/qcow2.c
85
index XXXXXXX..XXXXXXX 100644
86
--- a/block/qcow2.c
87
+++ b/block/qcow2.c
88
@@ -XXX,XX +XXX,XX @@ static void cache_clean_timer_del(BlockDriverState *bs)
89
{
90
BDRVQcow2State *s = bs->opaque;
91
if (s->cache_clean_timer) {
92
- timer_del(s->cache_clean_timer);
93
timer_free(s->cache_clean_timer);
94
s->cache_clean_timer = NULL;
95
}
96
diff --git a/hw/block/nvme.c b/hw/block/nvme.c
97
index XXXXXXX..XXXXXXX 100644
98
--- a/hw/block/nvme.c
99
+++ b/hw/block/nvme.c
100
@@ -XXX,XX +XXX,XX @@ static uint16_t nvme_io_cmd(NvmeCtrl *n, NvmeRequest *req)
101
static void nvme_free_sq(NvmeSQueue *sq, NvmeCtrl *n)
102
{
103
n->sq[sq->sqid] = NULL;
104
- timer_del(sq->timer);
105
timer_free(sq->timer);
106
g_free(sq->io_req);
107
if (sq->sqid) {
108
@@ -XXX,XX +XXX,XX @@ static uint16_t nvme_get_log(NvmeCtrl *n, NvmeRequest *req)
109
static void nvme_free_cq(NvmeCQueue *cq, NvmeCtrl *n)
110
{
111
n->cq[cq->cqid] = NULL;
112
- timer_del(cq->timer);
113
timer_free(cq->timer);
114
msix_vector_unuse(&n->parent_obj, cq->vector);
115
if (cq->cqid) {
116
diff --git a/hw/char/serial.c b/hw/char/serial.c
117
index XXXXXXX..XXXXXXX 100644
118
--- a/hw/char/serial.c
119
+++ b/hw/char/serial.c
120
@@ -XXX,XX +XXX,XX @@ static void serial_unrealize(DeviceState *dev)
121
122
qemu_chr_fe_deinit(&s->chr, false);
123
124
- timer_del(s->modem_status_poll);
125
timer_free(s->modem_status_poll);
126
127
- timer_del(s->fifo_timeout_timer);
128
timer_free(s->fifo_timeout_timer);
129
130
fifo8_destroy(&s->recv_fifo);
131
diff --git a/hw/char/virtio-serial-bus.c b/hw/char/virtio-serial-bus.c
132
index XXXXXXX..XXXXXXX 100644
133
--- a/hw/char/virtio-serial-bus.c
134
+++ b/hw/char/virtio-serial-bus.c
135
@@ -XXX,XX +XXX,XX @@ static void virtio_serial_post_load_timer_cb(void *opaque)
136
}
137
}
138
g_free(s->post_load->connected);
139
- timer_del(s->post_load->timer);
140
timer_free(s->post_load->timer);
141
g_free(s->post_load);
142
s->post_load = NULL;
143
@@ -XXX,XX +XXX,XX @@ static void virtio_serial_device_unrealize(DeviceState *dev)
144
g_free(vser->ports_map);
145
if (vser->post_load) {
146
g_free(vser->post_load->connected);
147
- timer_del(vser->post_load->timer);
148
timer_free(vser->post_load->timer);
149
g_free(vser->post_load);
150
}
151
diff --git a/hw/ide/core.c b/hw/ide/core.c
152
index XXXXXXX..XXXXXXX 100644
153
--- a/hw/ide/core.c
154
+++ b/hw/ide/core.c
155
@@ -XXX,XX +XXX,XX @@ void ide_init2(IDEBus *bus, qemu_irq irq)
156
157
void ide_exit(IDEState *s)
158
{
159
- timer_del(s->sector_write_timer);
160
timer_free(s->sector_write_timer);
161
qemu_vfree(s->smart_selftest_data);
162
qemu_vfree(s->io_buffer);
163
diff --git a/hw/input/hid.c b/hw/input/hid.c
164
index XXXXXXX..XXXXXXX 100644
165
--- a/hw/input/hid.c
166
+++ b/hw/input/hid.c
167
@@ -XXX,XX +XXX,XX @@ static void hid_idle_timer(void *opaque)
168
static void hid_del_idle_timer(HIDState *hs)
169
{
170
if (hs->idle_timer) {
171
- timer_del(hs->idle_timer);
172
timer_free(hs->idle_timer);
173
hs->idle_timer = NULL;
174
}
175
diff --git a/hw/intc/apic.c b/hw/intc/apic.c
176
index XXXXXXX..XXXXXXX 100644
177
--- a/hw/intc/apic.c
178
+++ b/hw/intc/apic.c
179
@@ -XXX,XX +XXX,XX @@ static void apic_unrealize(DeviceState *dev)
180
{
181
APICCommonState *s = APIC(dev);
182
183
- timer_del(s->timer);
184
timer_free(s->timer);
185
local_apics[s->id] = NULL;
186
}
187
diff --git a/hw/intc/ioapic.c b/hw/intc/ioapic.c
188
index XXXXXXX..XXXXXXX 100644
189
--- a/hw/intc/ioapic.c
190
+++ b/hw/intc/ioapic.c
191
@@ -XXX,XX +XXX,XX @@ static void ioapic_unrealize(DeviceState *dev)
192
{
193
IOAPICCommonState *s = IOAPIC_COMMON(dev);
194
195
- timer_del(s->delayed_ioapic_service_timer);
196
timer_free(s->delayed_ioapic_service_timer);
197
}
198
199
diff --git a/hw/ipmi/ipmi_bmc_extern.c b/hw/ipmi/ipmi_bmc_extern.c
200
index XXXXXXX..XXXXXXX 100644
201
--- a/hw/ipmi/ipmi_bmc_extern.c
202
+++ b/hw/ipmi/ipmi_bmc_extern.c
203
@@ -XXX,XX +XXX,XX @@ static void ipmi_bmc_extern_finalize(Object *obj)
204
{
205
IPMIBmcExtern *ibe = IPMI_BMC_EXTERN(obj);
206
207
- timer_del(ibe->extern_timer);
208
timer_free(ibe->extern_timer);
209
}
210
211
diff --git a/hw/net/e1000.c b/hw/net/e1000.c
212
index XXXXXXX..XXXXXXX 100644
213
--- a/hw/net/e1000.c
214
+++ b/hw/net/e1000.c
215
@@ -XXX,XX +XXX,XX @@ pci_e1000_uninit(PCIDevice *dev)
216
{
217
E1000State *d = E1000(dev);
218
219
- timer_del(d->autoneg_timer);
220
timer_free(d->autoneg_timer);
221
- timer_del(d->mit_timer);
222
timer_free(d->mit_timer);
223
- timer_del(d->flush_queue_timer);
224
timer_free(d->flush_queue_timer);
225
qemu_del_nic(d->nic);
226
}
227
diff --git a/hw/net/e1000e_core.c b/hw/net/e1000e_core.c
228
index XXXXXXX..XXXXXXX 100644
229
--- a/hw/net/e1000e_core.c
230
+++ b/hw/net/e1000e_core.c
231
@@ -XXX,XX +XXX,XX @@ e1000e_intrmgr_pci_unint(E1000ECore *core)
232
{
233
int i;
234
235
- timer_del(core->radv.timer);
236
timer_free(core->radv.timer);
237
- timer_del(core->rdtr.timer);
238
timer_free(core->rdtr.timer);
239
- timer_del(core->raid.timer);
240
timer_free(core->raid.timer);
241
242
- timer_del(core->tadv.timer);
243
timer_free(core->tadv.timer);
244
- timer_del(core->tidv.timer);
245
timer_free(core->tidv.timer);
246
247
- timer_del(core->itr.timer);
248
timer_free(core->itr.timer);
249
250
for (i = 0; i < E1000E_MSIX_VEC_NUM; i++) {
251
- timer_del(core->eitr[i].timer);
252
timer_free(core->eitr[i].timer);
253
}
254
}
255
@@ -XXX,XX +XXX,XX @@ e1000e_core_pci_uninit(E1000ECore *core)
256
{
257
int i;
258
259
- timer_del(core->autoneg_timer);
260
timer_free(core->autoneg_timer);
261
262
e1000e_intrmgr_pci_unint(core);
263
diff --git a/hw/net/pcnet-pci.c b/hw/net/pcnet-pci.c
264
index XXXXXXX..XXXXXXX 100644
265
--- a/hw/net/pcnet-pci.c
266
+++ b/hw/net/pcnet-pci.c
267
@@ -XXX,XX +XXX,XX @@ static void pci_pcnet_uninit(PCIDevice *dev)
268
PCIPCNetState *d = PCI_PCNET(dev);
269
270
qemu_free_irq(d->state.irq);
271
- timer_del(d->state.poll_timer);
272
timer_free(d->state.poll_timer);
273
qemu_del_nic(d->state.nic);
274
}
275
diff --git a/hw/net/rtl8139.c b/hw/net/rtl8139.c
276
index XXXXXXX..XXXXXXX 100644
277
--- a/hw/net/rtl8139.c
278
+++ b/hw/net/rtl8139.c
279
@@ -XXX,XX +XXX,XX @@ static void pci_rtl8139_uninit(PCIDevice *dev)
280
281
g_free(s->cplus_txbuffer);
282
s->cplus_txbuffer = NULL;
283
- timer_del(s->timer);
284
timer_free(s->timer);
285
qemu_del_nic(s->nic);
286
}
287
diff --git a/hw/net/spapr_llan.c b/hw/net/spapr_llan.c
288
index XXXXXXX..XXXXXXX 100644
289
--- a/hw/net/spapr_llan.c
290
+++ b/hw/net/spapr_llan.c
291
@@ -XXX,XX +XXX,XX @@ static void spapr_vlan_instance_finalize(Object *obj)
292
}
293
294
if (dev->rxp_timer) {
295
- timer_del(dev->rxp_timer);
296
timer_free(dev->rxp_timer);
297
}
298
}
299
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
300
index XXXXXXX..XXXXXXX 100644
301
--- a/hw/net/virtio-net.c
302
+++ b/hw/net/virtio-net.c
303
@@ -XXX,XX +XXX,XX @@ static void virtio_net_rsc_cleanup(VirtIONet *n)
304
g_free(seg);
305
}
306
307
- timer_del(chain->drain_timer);
308
timer_free(chain->drain_timer);
309
QTAILQ_REMOVE(&n->rsc_chains, chain, next);
310
g_free(chain);
311
@@ -XXX,XX +XXX,XX @@ static void virtio_net_del_queue(VirtIONet *n, int index)
312
313
virtio_del_queue(vdev, index * 2);
314
if (q->tx_timer) {
315
- timer_del(q->tx_timer);
316
timer_free(q->tx_timer);
317
q->tx_timer = NULL;
318
} else {
319
diff --git a/hw/s390x/s390-pci-inst.c b/hw/s390x/s390-pci-inst.c
320
index XXXXXXX..XXXXXXX 100644
321
--- a/hw/s390x/s390-pci-inst.c
322
+++ b/hw/s390x/s390-pci-inst.c
323
@@ -XXX,XX +XXX,XX @@ void pci_dereg_ioat(S390PCIIOMMU *iommu)
324
void fmb_timer_free(S390PCIBusDevice *pbdev)
325
{
326
if (pbdev->fmb_timer) {
327
- timer_del(pbdev->fmb_timer);
328
timer_free(pbdev->fmb_timer);
329
pbdev->fmb_timer = NULL;
330
}
331
diff --git a/hw/sd/sd.c b/hw/sd/sd.c
332
index XXXXXXX..XXXXXXX 100644
333
--- a/hw/sd/sd.c
334
+++ b/hw/sd/sd.c
335
@@ -XXX,XX +XXX,XX @@ static void sd_instance_finalize(Object *obj)
336
{
337
SDState *sd = SD_CARD(obj);
338
339
- timer_del(sd->ocr_power_timer);
340
timer_free(sd->ocr_power_timer);
341
}
342
343
diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c
344
index XXXXXXX..XXXXXXX 100644
345
--- a/hw/sd/sdhci.c
346
+++ b/hw/sd/sdhci.c
347
@@ -XXX,XX +XXX,XX @@ void sdhci_initfn(SDHCIState *s)
348
349
void sdhci_uninitfn(SDHCIState *s)
350
{
351
- timer_del(s->insert_timer);
352
timer_free(s->insert_timer);
353
- timer_del(s->transfer_timer);
354
timer_free(s->transfer_timer);
355
356
g_free(s->fifo_buffer);
357
diff --git a/hw/usb/dev-hub.c b/hw/usb/dev-hub.c
358
index XXXXXXX..XXXXXXX 100644
359
--- a/hw/usb/dev-hub.c
360
+++ b/hw/usb/dev-hub.c
361
@@ -XXX,XX +XXX,XX @@ static void usb_hub_unrealize(USBDevice *dev)
362
&s->ports[i].port);
363
}
364
365
- timer_del(s->port_timer);
366
timer_free(s->port_timer);
367
}
368
369
diff --git a/hw/usb/hcd-ehci.c b/hw/usb/hcd-ehci.c
370
index XXXXXXX..XXXXXXX 100644
371
--- a/hw/usb/hcd-ehci.c
372
+++ b/hw/usb/hcd-ehci.c
373
@@ -XXX,XX +XXX,XX @@ void usb_ehci_unrealize(EHCIState *s, DeviceState *dev)
374
trace_usb_ehci_unrealize();
375
376
if (s->frame_timer) {
377
- timer_del(s->frame_timer);
378
timer_free(s->frame_timer);
379
s->frame_timer = NULL;
380
}
381
diff --git a/hw/usb/hcd-ohci-pci.c b/hw/usb/hcd-ohci-pci.c
382
index XXXXXXX..XXXXXXX 100644
383
--- a/hw/usb/hcd-ohci-pci.c
384
+++ b/hw/usb/hcd-ohci-pci.c
385
@@ -XXX,XX +XXX,XX @@ static void usb_ohci_exit(PCIDevice *dev)
386
usb_bus_release(&s->bus);
387
}
388
389
- timer_del(s->eof_timer);
390
timer_free(s->eof_timer);
391
}
392
393
diff --git a/hw/usb/hcd-uhci.c b/hw/usb/hcd-uhci.c
394
index XXXXXXX..XXXXXXX 100644
395
--- a/hw/usb/hcd-uhci.c
396
+++ b/hw/usb/hcd-uhci.c
397
@@ -XXX,XX +XXX,XX @@ static void usb_uhci_exit(PCIDevice *dev)
398
trace_usb_uhci_exit();
399
400
if (s->frame_timer) {
401
- timer_del(s->frame_timer);
402
timer_free(s->frame_timer);
403
s->frame_timer = NULL;
404
}
405
diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c
406
index XXXXXXX..XXXXXXX 100644
407
--- a/hw/usb/hcd-xhci.c
408
+++ b/hw/usb/hcd-xhci.c
409
@@ -XXX,XX +XXX,XX @@ static void usb_xhci_unrealize(DeviceState *dev)
410
}
411
412
if (xhci->mfwrap_timer) {
413
- timer_del(xhci->mfwrap_timer);
414
timer_free(xhci->mfwrap_timer);
415
xhci->mfwrap_timer = NULL;
416
}
417
diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c
418
index XXXXXXX..XXXXXXX 100644
419
--- a/hw/usb/redirect.c
420
+++ b/hw/usb/redirect.c
421
@@ -XXX,XX +XXX,XX @@ static void usbredir_unrealize(USBDevice *udev)
422
qemu_bh_delete(dev->chardev_close_bh);
423
qemu_bh_delete(dev->device_reject_bh);
424
425
- timer_del(dev->attach_timer);
426
timer_free(dev->attach_timer);
427
428
usbredir_cleanup_device_queues(dev);
429
diff --git a/hw/vfio/display.c b/hw/vfio/display.c
430
index XXXXXXX..XXXXXXX 100644
431
--- a/hw/vfio/display.c
432
+++ b/hw/vfio/display.c
433
@@ -XXX,XX +XXX,XX @@ static void vfio_display_edid_exit(VFIODisplay *dpy)
434
435
g_free(dpy->edid_regs);
436
g_free(dpy->edid_blob);
437
- timer_del(dpy->edid_link_timer);
438
timer_free(dpy->edid_link_timer);
439
}
440
441
diff --git a/hw/virtio/vhost-vsock-common.c b/hw/virtio/vhost-vsock-common.c
442
index XXXXXXX..XXXXXXX 100644
443
--- a/hw/virtio/vhost-vsock-common.c
444
+++ b/hw/virtio/vhost-vsock-common.c
445
@@ -XXX,XX +XXX,XX @@ static void vhost_vsock_common_post_load_timer_cleanup(VHostVSockCommon *vvc)
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;
622
}
623
--
624
2.20.1
625
626
diff view generated by jsdifflib
1
The ARM_FEATURE_PXN bit indicates whether the CPU supports the PXN
1
The Arm CPU finalize function uses a sequence of timer_del(), timer_deinit(),
2
bit in short-descriptor translation table format descriptors. This
2
timer_free() to free the timer. The timer_deinit() step in this was always
3
is indicated by ID_MMFR0.VMSA being at least 0b0100. Replace the
3
unnecessary, and now the timer_del() is implied by timer_free(), so we can
4
feature bit with an ID register check, in line with our preference
4
collapse this down to simply calling timer_free().
5
for ID register checks over feature bits.
6
5
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20200910173855.4068-2-peter.maydell@linaro.org
9
Message-id: 20201215154107.3255-5-peter.maydell@linaro.org
10
---
10
---
11
target/arm/cpu.h | 15 ++++++++++++++-
11
target/arm/cpu.c | 2 --
12
target/arm/cpu.c | 1 -
12
1 file changed, 2 deletions(-)
13
target/arm/helper.c | 5 +++--
14
3 files changed, 17 insertions(+), 4 deletions(-)
15
13
16
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
17
index XXXXXXX..XXXXXXX 100644
18
--- a/target/arm/cpu.h
19
+++ b/target/arm/cpu.h
20
@@ -XXX,XX +XXX,XX @@ FIELD(ID_ISAR6, FHM, 8, 4)
21
FIELD(ID_ISAR6, SB, 12, 4)
22
FIELD(ID_ISAR6, SPECRES, 16, 4)
23
24
+FIELD(ID_MMFR0, VMSA, 0, 4)
25
+FIELD(ID_MMFR0, PMSA, 4, 4)
26
+FIELD(ID_MMFR0, OUTERSHR, 8, 4)
27
+FIELD(ID_MMFR0, SHARELVL, 12, 4)
28
+FIELD(ID_MMFR0, TCM, 16, 4)
29
+FIELD(ID_MMFR0, AUXREG, 20, 4)
30
+FIELD(ID_MMFR0, FCSE, 24, 4)
31
+FIELD(ID_MMFR0, INNERSHR, 28, 4)
32
+
33
FIELD(ID_MMFR3, CMAINTVA, 0, 4)
34
FIELD(ID_MMFR3, CMAINTSW, 4, 4)
35
FIELD(ID_MMFR3, BPMAINT, 8, 4)
36
@@ -XXX,XX +XXX,XX @@ enum arm_features {
37
ARM_FEATURE_CACHE_DIRTY_REG, /* 1136/1176 cache dirty status register */
38
ARM_FEATURE_CACHE_BLOCK_OPS, /* v6 optional cache block operations */
39
ARM_FEATURE_MPIDR, /* has cp15 MPIDR */
40
- ARM_FEATURE_PXN, /* has Privileged Execute Never bit */
41
ARM_FEATURE_LPAE, /* has Large Physical Address Extension */
42
ARM_FEATURE_V8,
43
ARM_FEATURE_AARCH64, /* supports 64 bit mode */
44
@@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa32_vminmaxnm(const ARMISARegisters *id)
45
return FIELD_EX32(id->mvfr2, MVFR2, FPMISC) >= 4;
46
}
47
48
+static inline bool isar_feature_aa32_pxn(const ARMISARegisters *id)
49
+{
50
+ return FIELD_EX32(id->id_mmfr0, ID_MMFR0, VMSA) >= 4;
51
+}
52
+
53
static inline bool isar_feature_aa32_pan(const ARMISARegisters *id)
54
{
55
return FIELD_EX32(id->id_mmfr3, ID_MMFR3, PAN) != 0;
56
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
14
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
57
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
58
--- a/target/arm/cpu.c
16
--- a/target/arm/cpu.c
59
+++ b/target/arm/cpu.c
17
+++ b/target/arm/cpu.c
60
@@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)
18
@@ -XXX,XX +XXX,XX @@ static void arm_cpu_finalizefn(Object *obj)
61
}
19
}
62
if (arm_feature(env, ARM_FEATURE_LPAE)) {
20
#ifndef CONFIG_USER_ONLY
63
set_feature(env, ARM_FEATURE_V7MP);
21
if (cpu->pmu_timer) {
64
- set_feature(env, ARM_FEATURE_PXN);
22
- timer_del(cpu->pmu_timer);
23
- timer_deinit(cpu->pmu_timer);
24
timer_free(cpu->pmu_timer);
65
}
25
}
66
if (arm_feature(env, ARM_FEATURE_CBAR_RO)) {
26
#endif
67
set_feature(env, ARM_FEATURE_CBAR);
68
diff --git a/target/arm/helper.c b/target/arm/helper.c
69
index XXXXXXX..XXXXXXX 100644
70
--- a/target/arm/helper.c
71
+++ b/target/arm/helper.c
72
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_v6(CPUARMState *env, uint32_t address,
73
target_ulong *page_size, ARMMMUFaultInfo *fi)
74
{
75
CPUState *cs = env_cpu(env);
76
+ ARMCPU *cpu = env_archcpu(env);
77
int level = 1;
78
uint32_t table;
79
uint32_t desc;
80
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_v6(CPUARMState *env, uint32_t address,
81
goto do_fault;
82
}
83
type = (desc & 3);
84
- if (type == 0 || (type == 3 && !arm_feature(env, ARM_FEATURE_PXN))) {
85
+ if (type == 0 || (type == 3 && !cpu_isar_feature(aa32_pxn, cpu))) {
86
/* Section translation fault, or attempt to use the encoding
87
* which is Reserved on implementations without PXN.
88
*/
89
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_v6(CPUARMState *env, uint32_t address,
90
pxn = desc & 1;
91
ns = extract32(desc, 19, 1);
92
} else {
93
- if (arm_feature(env, ARM_FEATURE_PXN)) {
94
+ if (cpu_isar_feature(aa32_pxn, cpu)) {
95
pxn = (desc >> 2) & 1;
96
}
97
ns = extract32(desc, 3, 1);
98
--
27
--
99
2.20.1
28
2.20.1
100
29
101
30
diff view generated by jsdifflib
New patch
1
From: Gan Qixin <ganqixin@huawei.com>
1
2
3
When running device-introspect-test, a memory leak occurred in the
4
digic_timer_init function, so use ptimer_free() in the finalize function to
5
avoid it.
6
7
ASAN shows memory leak stack:
8
9
Indirect leak of 288 byte(s) in 3 object(s) allocated from:
10
#0 0xffffab97e1f0 in __interceptor_calloc (/lib64/libasan.so.5+0xee1f0)
11
#1 0xffffab256800 in g_malloc0 (/lib64/libglib-2.0.so.0+0x56800)
12
#2 0xaaabf555db78 in ptimer_init /qemu/hw/core/ptimer.c:432
13
#3 0xaaabf5b04084 in digic_timer_init /qemu/hw/timer/digic-timer.c:142
14
#4 0xaaabf6339f6c in object_initialize_with_type /qemu/qom/object.c:515
15
#5 0xaaabf633ca04 in object_initialize_child_with_propsv /qemu/qom/object.c:564
16
#6 0xaaabf633cc08 in object_initialize_child_with_props /qemu/qom/object.c:547
17
#7 0xaaabf5b40e84 in digic_init /qemu/hw/arm/digic.c:46
18
#8 0xaaabf6339f6c in object_initialize_with_type /qemu/qom/object.c:515
19
#9 0xaaabf633a1e0 in object_new_with_type /qemu/qom/object.c:729
20
#10 0xaaabf6375e40 in qmp_device_list_properties /qemu/qom/qom-qmp-cmds.c:153
21
#11 0xaaabf653d8ec in qmp_marshal_device_list_properties /qemu/qapi/qapi-commands-qdev.c:59
22
#12 0xaaabf6587d08 in do_qmp_dispatch_bh /qemu/qapi/qmp-dispatch.c:110
23
24
Reported-by: Euler Robot <euler.robot@huawei.com>
25
Signed-off-by: Gan Qixin <ganqixin@huawei.com>
26
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
27
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
28
---
29
hw/timer/digic-timer.c | 8 ++++++++
30
1 file changed, 8 insertions(+)
31
32
diff --git a/hw/timer/digic-timer.c b/hw/timer/digic-timer.c
33
index XXXXXXX..XXXXXXX 100644
34
--- a/hw/timer/digic-timer.c
35
+++ b/hw/timer/digic-timer.c
36
@@ -XXX,XX +XXX,XX @@ static void digic_timer_init(Object *obj)
37
sysbus_init_mmio(SYS_BUS_DEVICE(obj), &s->iomem);
38
}
39
40
+static void digic_timer_finalize(Object *obj)
41
+{
42
+ DigicTimerState *s = DIGIC_TIMER(obj);
43
+
44
+ ptimer_free(s->ptimer);
45
+}
46
+
47
static void digic_timer_class_init(ObjectClass *klass, void *class_data)
48
{
49
DeviceClass *dc = DEVICE_CLASS(klass);
50
@@ -XXX,XX +XXX,XX @@ static const TypeInfo digic_timer_info = {
51
.parent = TYPE_SYS_BUS_DEVICE,
52
.instance_size = sizeof(DigicTimerState),
53
.instance_init = digic_timer_init,
54
+ .instance_finalize = digic_timer_finalize,
55
.class_init = digic_timer_class_init,
56
};
57
58
--
59
2.20.1
60
61
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
1
From: Gan Qixin <ganqixin@huawei.com>
2
2
3
We expected the 'version' ID to match the board processor ID,
3
When running device-introspect-test, a memory leak occurred in the a10_pit_init
4
but this is not always true (for example boards with revision
4
function, so use ptimer_free() in the finalize function to avoid it.
5
id 0xa02042/0xa22042 are Raspberry Pi 2 with a BCM2837 SoC).
6
This was not important because we were not modelling them, but
7
since the recent refactor now allow to model these boards, it
8
is safer to check the processor id directly. Remove the version
9
check.
10
5
11
Suggested-by: Peter Maydell <peter.maydell@linaro.org>
6
ASAN shows memory leak stack:
12
Reviewed-by: Luc Michel <luc.michel@greensocs.com>
7
13
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
8
Indirect leak of 288 byte(s) in 6 object(s) allocated from:
14
Message-id: 20200924111808.77168-9-f4bug@amsat.org
9
#0 0xffffab97e1f0 in __interceptor_calloc (/lib64/libasan.so.5+0xee1f0)
10
#1 0xffffab256800 in g_malloc0 (/lib64/libglib-2.0.so.0+0x56800)
11
#2 0xaaabf555db84 in timer_new_full /qemu/include/qemu/timer.h:523
12
#3 0xaaabf555db84 in timer_new /qemu/include/qemu/timer.h:544
13
#4 0xaaabf555db84 in timer_new_ns /qemu/include/qemu/timer.h:562
14
#5 0xaaabf555db84 in ptimer_init /qemu/hw/core/ptimer.c:433
15
#6 0xaaabf57415e8 in a10_pit_init /qemu/hw/timer/allwinner-a10-pit.c:278
16
#7 0xaaabf6339f6c in object_initialize_with_type /qemu/qom/object.c:515
17
#8 0xaaabf633ca04 in object_initialize_child_with_propsv /qemu/qom/object.c:564
18
#9 0xaaabf633cc08 in object_initialize_child_with_props /qemu/qom/object.c:547
19
#10 0xaaabf5b94680 in aw_a10_init /qemu/hw/arm/allwinner-a10.c:49
20
#11 0xaaabf6339f6c in object_initialize_with_type /qemu/qom/object.c:515
21
#12 0xaaabf633a1e0 in object_new_with_type /qemu/qom/object.c:729
22
23
Reported-by: Euler Robot <euler.robot@huawei.com>
24
Signed-off-by: Gan Qixin <ganqixin@huawei.com>
25
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
15
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
26
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
16
---
27
---
17
hw/arm/raspi.c | 29 +++++++++++++----------------
28
hw/timer/allwinner-a10-pit.c | 11 +++++++++++
18
1 file changed, 13 insertions(+), 16 deletions(-)
29
1 file changed, 11 insertions(+)
19
30
20
diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c
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/hw/arm/raspi.c
33
--- a/hw/timer/allwinner-a10-pit.c
23
+++ b/hw/arm/raspi.c
34
+++ b/hw/timer/allwinner-a10-pit.c
24
@@ -XXX,XX +XXX,XX @@ static RaspiProcessorId board_processor_id(uint32_t board_rev)
35
@@ -XXX,XX +XXX,XX @@ static void a10_pit_init(Object *obj)
25
return proc_id;
36
}
26
}
37
}
27
38
28
-static int board_version(uint32_t board_rev)
39
+static void a10_pit_finalize(Object *obj)
29
-{
40
+{
30
- return board_processor_id(board_rev) + 1;
41
+ AwA10PITState *s = AW_A10_PIT(obj);
31
-}
42
+ int i;
32
-
43
+
33
static const char *board_soc_type(uint32_t board_rev)
44
+ for (i = 0; i < AW_A10_PIT_TIMER_NR; i++) {
45
+ ptimer_free(s->timer[i]);
46
+ }
47
+}
48
+
49
static void a10_pit_class_init(ObjectClass *klass, void *data)
34
{
50
{
35
return soc_property[board_processor_id(board_rev)].type;
51
DeviceClass *dc = DEVICE_CLASS(klass);
36
@@ -XXX,XX +XXX,XX @@ static void reset_secondary(ARMCPU *cpu, const struct arm_boot_info *info)
52
@@ -XXX,XX +XXX,XX @@ static const TypeInfo a10_pit_info = {
37
cpu_set_pc(cs, info->smp_loader_start);
53
.parent = TYPE_SYS_BUS_DEVICE,
38
}
54
.instance_size = sizeof(AwA10PITState),
39
55
.instance_init = a10_pit_init,
40
-static void setup_boot(MachineState *machine, int version, size_t ram_size)
56
+ .instance_finalize = a10_pit_finalize,
41
+static void setup_boot(MachineState *machine, RaspiProcessorId processor_id,
57
.class_init = a10_pit_class_init,
42
+ size_t ram_size)
58
};
43
{
59
44
RaspiMachineState *s = RASPI_MACHINE(machine);
45
int r;
46
@@ -XXX,XX +XXX,XX @@ static void setup_boot(MachineState *machine, int version, size_t ram_size)
47
s->binfo.ram_size = ram_size;
48
s->binfo.nb_cpus = machine->smp.cpus;
49
50
- if (version <= 2) {
51
- /* The rpi1 and 2 require some custom setup code to run in Secure
52
- * mode before booting a kernel (to set up the SMC vectors so
53
- * that we get a no-op SMC; this is used by Linux to call the
54
+ if (processor_id <= PROCESSOR_ID_BCM2836) {
55
+ /*
56
+ * The BCM2835 and BCM2836 require some custom setup code to run
57
+ * in Secure mode before booting a kernel (to set up the SMC vectors
58
+ * so that we get a no-op SMC; this is used by Linux to call the
59
* firmware for some cache maintenance operations.
60
- * The rpi3 doesn't need this.
61
+ * The BCM2837 doesn't need this.
62
*/
63
s->binfo.board_setup_addr = BOARDSETUP_ADDR;
64
s->binfo.write_board_setup = write_board_setup;
65
@@ -XXX,XX +XXX,XX @@ static void setup_boot(MachineState *machine, int version, size_t ram_size)
66
s->binfo.secure_boot = true;
67
}
68
69
- /* Pi2 and Pi3 requires SMP setup */
70
- if (version >= 2) {
71
+ /* BCM2836 and BCM2837 requires SMP setup */
72
+ if (processor_id >= PROCESSOR_ID_BCM2836) {
73
s->binfo.smp_loader_start = SMPBOOT_ADDR;
74
- if (version == 2) {
75
+ if (processor_id == PROCESSOR_ID_BCM2836) {
76
s->binfo.write_secondary_boot = write_smpboot;
77
} else {
78
s->binfo.write_secondary_boot = write_smpboot64;
79
@@ -XXX,XX +XXX,XX @@ static void raspi_machine_init(MachineState *machine)
80
RaspiMachineClass *mc = RASPI_MACHINE_GET_CLASS(machine);
81
RaspiMachineState *s = RASPI_MACHINE(machine);
82
uint32_t board_rev = mc->board_rev;
83
- int version = board_version(board_rev);
84
uint64_t ram_size = board_ram_size(board_rev);
85
uint32_t vcram_size;
86
DriveInfo *di;
87
@@ -XXX,XX +XXX,XX @@ static void raspi_machine_init(MachineState *machine)
88
89
vcram_size = object_property_get_uint(OBJECT(&s->soc), "vcram-size",
90
&error_abort);
91
- setup_boot(machine, version, machine->ram_size - vcram_size);
92
+ setup_boot(machine, board_processor_id(mc->board_rev),
93
+ machine->ram_size - vcram_size);
94
}
95
96
static void raspi_machine_class_common_init(MachineClass *mc,
97
--
60
--
98
2.20.1
61
2.20.1
99
62
100
63
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
1
From: Gan Qixin <ganqixin@huawei.com>
2
2
3
The firmware load address depends on the SoC ("processor id") used,
3
When running device-introspect-test, a memory leak occurred in the
4
not on the version of the board.
4
exynos4210_rtc_init function, so use ptimer_free() in the finalize function to
5
avoid it.
5
6
6
Suggested-by: Luc Michel <luc.michel@greensocs.com>
7
ASAN shows memory leak stack:
7
Reviewed-by: Luc Michel <luc.michel@greensocs.com>
8
8
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
9
Indirect leak of 96 byte(s) in 1 object(s) allocated from:
9
Message-id: 20200924111808.77168-8-f4bug@amsat.org
10
#0 0xffffab97e1f0 in __interceptor_calloc (/lib64/libasan.so.5+0xee1f0)
11
#1 0xffffab256800 in g_malloc0 (/lib64/libglib-2.0.so.0+0x56800)
12
#2 0xaaabf555db78 in ptimer_init /qemu/hw/core/ptimer.c:432
13
#3 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>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
27
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
28
---
12
hw/arm/raspi.c | 3 ++-
29
hw/rtc/exynos4210_rtc.c | 9 +++++++++
13
1 file changed, 2 insertions(+), 1 deletion(-)
30
1 file changed, 9 insertions(+)
14
31
15
diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c
32
diff --git a/hw/rtc/exynos4210_rtc.c b/hw/rtc/exynos4210_rtc.c
16
index XXXXXXX..XXXXXXX 100644
33
index XXXXXXX..XXXXXXX 100644
17
--- a/hw/arm/raspi.c
34
--- a/hw/rtc/exynos4210_rtc.c
18
+++ b/hw/arm/raspi.c
35
+++ b/hw/rtc/exynos4210_rtc.c
19
@@ -XXX,XX +XXX,XX @@ static void setup_boot(MachineState *machine, int version, size_t ram_size)
36
@@ -XXX,XX +XXX,XX @@ static void exynos4210_rtc_init(Object *obj)
20
* the normal Linux boot process
37
sysbus_init_mmio(dev, &s->iomem);
21
*/
38
}
22
if (machine->firmware) {
39
23
- hwaddr firmware_addr = version == 3 ? FIRMWARE_ADDR_3 : FIRMWARE_ADDR_2;
40
+static void exynos4210_rtc_finalize(Object *obj)
24
+ hwaddr firmware_addr = processor_id <= PROCESSOR_ID_BCM2836
41
+{
25
+ ? FIRMWARE_ADDR_2 : FIRMWARE_ADDR_3;
42
+ Exynos4210RTCState *s = EXYNOS4210_RTC(obj);
26
/* load the firmware image (typically kernel.img) */
43
+
27
r = load_image_targphys(machine->firmware, firmware_addr,
44
+ ptimer_free(s->ptimer);
28
ram_size - firmware_addr);
45
+ ptimer_free(s->ptimer_1Hz);
46
+}
47
+
48
static void exynos4210_rtc_class_init(ObjectClass *klass, void *data)
49
{
50
DeviceClass *dc = DEVICE_CLASS(klass);
51
@@ -XXX,XX +XXX,XX @@ static const TypeInfo exynos4210_rtc_info = {
52
.parent = TYPE_SYS_BUS_DEVICE,
53
.instance_size = sizeof(Exynos4210RTCState),
54
.instance_init = exynos4210_rtc_init,
55
+ .instance_finalize = exynos4210_rtc_finalize,
56
.class_init = exynos4210_rtc_class_init,
57
};
58
29
--
59
--
30
2.20.1
60
2.20.1
31
61
32
62
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
From: Gan Qixin <ganqixin@huawei.com>
2
2
3
The mte update missed a bit when producing clean addresses.
3
When running device-introspect-test, a memory leak occurred in the
4
exynos4210_pwm_init function, so use ptimer_free() in the finalize function to
5
avoid it.
4
6
5
Fixes: b2aa8879b88
7
ASAN shows memory leak stack:
6
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
7
Message-id: 20200916014102.2446323-1-richard.henderson@linaro.org
9
Indirect leak of 240 byte(s) in 5 object(s) allocated from:
10
#0 0xffffab97e1f0 in __interceptor_calloc (/lib64/libasan.so.5+0xee1f0)
11
#1 0xffffab256800 in g_malloc0 (/lib64/libglib-2.0.so.0+0x56800)
12
#2 0xaaabf555db84 in timer_new_full /qemu/include/qemu/timer.h:523
13
#3 0xaaabf555db84 in timer_new /qemu/include/qemu/timer.h:544
14
#4 0xaaabf555db84 in timer_new_ns /qemu/include/qemu/timer.h:562
15
#5 0xaaabf555db84 in ptimer_init /qemu/hw/core/ptimer.c:433
16
#6 0xaaabf56a36cc in exynos4210_pwm_init /qemu/hw/timer/exynos4210_pwm.c:401
17
#7 0xaaabf6339f6c in object_initialize_with_type /qemu/qom/object.c:515
18
#8 0xaaabf633a1e0 in object_new_with_type /qemu/qom/object.c:729
19
#9 0xaaabf6375e40 in qmp_device_list_properties /qemu/qom/qom-qmp-cmds.c:153
20
#10 0xaaabf653d8ec in qmp_marshal_device_list_properties /qemu/qapi/qapi-commands-qdev.c:59
21
#11 0xaaabf6587d08 in do_qmp_dispatch_bh /qemu/qapi/qmp-dispatch.c:110
22
#12 0xaaabf6552708 in aio_bh_call /qemu/util/async.c:136
23
24
Reported-by: Euler Robot <euler.robot@huawei.com>
25
Signed-off-by: Gan Qixin <ganqixin@huawei.com>
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
26
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
27
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
28
---
11
target/arm/translate-sve.c | 4 ++--
29
hw/timer/exynos4210_pwm.c | 11 +++++++++++
12
1 file changed, 2 insertions(+), 2 deletions(-)
30
1 file changed, 11 insertions(+)
13
31
14
diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c
32
diff --git a/hw/timer/exynos4210_pwm.c b/hw/timer/exynos4210_pwm.c
15
index XXXXXXX..XXXXXXX 100644
33
index XXXXXXX..XXXXXXX 100644
16
--- a/target/arm/translate-sve.c
34
--- a/hw/timer/exynos4210_pwm.c
17
+++ b/target/arm/translate-sve.c
35
+++ b/hw/timer/exynos4210_pwm.c
18
@@ -XXX,XX +XXX,XX @@ static void do_ldr(DisasContext *s, uint32_t vofs, int len, int rn, int imm)
36
@@ -XXX,XX +XXX,XX @@ static void exynos4210_pwm_init(Object *obj)
19
for (i = 0; i < len_align; i += 8) {
37
sysbus_init_mmio(dev, &s->iomem);
20
tcg_gen_qemu_ld_i64(t0, clean_addr, midx, MO_LEQ);
38
}
21
tcg_gen_st_i64(t0, cpu_env, vofs + i);
39
22
- tcg_gen_addi_i64(clean_addr, cpu_reg_sp(s, rn), 8);
40
+static void exynos4210_pwm_finalize(Object *obj)
23
+ tcg_gen_addi_i64(clean_addr, clean_addr, 8);
41
+{
24
}
42
+ Exynos4210PWMState *s = EXYNOS4210_PWM(obj);
25
tcg_temp_free_i64(t0);
43
+ int i;
26
} else {
44
+
27
@@ -XXX,XX +XXX,XX @@ static void do_str(DisasContext *s, uint32_t vofs, int len, int rn, int imm)
45
+ for (i = 0; i < EXYNOS4210_PWM_TIMERS_NUM; i++) {
28
for (i = 0; i < len_align; i += 8) {
46
+ ptimer_free(s->timer[i].ptimer);
29
tcg_gen_ld_i64(t0, cpu_env, vofs + i);
47
+ }
30
tcg_gen_qemu_st_i64(t0, clean_addr, midx, MO_LEQ);
48
+}
31
- tcg_gen_addi_i64(clean_addr, cpu_reg_sp(s, rn), 8);
49
+
32
+ tcg_gen_addi_i64(clean_addr, clean_addr, 8);
50
static void exynos4210_pwm_class_init(ObjectClass *klass, void *data)
33
}
51
{
34
tcg_temp_free_i64(t0);
52
DeviceClass *dc = DEVICE_CLASS(klass);
35
} else {
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
};
60
36
--
61
--
37
2.20.1
62
2.20.1
38
63
39
64
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
1
From: Gan Qixin <ganqixin@huawei.com>
2
2
3
Using class_data pointer to create a MachineClass is not
3
When running device-introspect-test, a memory leak occurred in the
4
the recommended way anymore. The correct way is to open-code
4
mss_timer_init function, so use ptimer_free() in the finalize function to avoid
5
the MachineClass::fields in the class_init() method.
5
it.
6
6
7
We can not use TYPE_RASPI_MACHINE::class_base_init() because
7
ASAN shows memory leak stack:
8
it is called *before* each machine class_init(), therefore the
9
board_rev field is not populated. We have to manually call
10
raspi_machine_class_common_init() for each machine.
11
8
12
This partly reverts commit a03bde3674e.
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
13
23
14
Suggested-by: Igor Mammedov <imammedo@redhat.com>
24
Reported-by: Euler Robot <euler.robot@huawei.com>
15
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
25
Signed-off-by: Gan Qixin <ganqixin@huawei.com>
16
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
26
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
17
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
18
Message-id: 20200924111808.77168-5-f4bug@amsat.org
19
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
27
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
20
---
28
---
21
hw/arm/raspi.c | 34 ++++++++++++++++++++++++----------
29
hw/timer/mss-timer.c | 13 +++++++++++++
22
1 file changed, 24 insertions(+), 10 deletions(-)
30
1 file changed, 13 insertions(+)
23
31
24
diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c
32
diff --git a/hw/timer/mss-timer.c b/hw/timer/mss-timer.c
25
index XXXXXXX..XXXXXXX 100644
33
index XXXXXXX..XXXXXXX 100644
26
--- a/hw/arm/raspi.c
34
--- a/hw/timer/mss-timer.c
27
+++ b/hw/arm/raspi.c
35
+++ b/hw/timer/mss-timer.c
28
@@ -XXX,XX +XXX,XX @@ static void raspi_machine_init(MachineState *machine)
36
@@ -XXX,XX +XXX,XX @@ static void mss_timer_init(Object *obj)
29
setup_boot(machine, version, machine->ram_size - vcram_size);
37
sysbus_init_mmio(SYS_BUS_DEVICE(obj), &t->mmio);
30
}
38
}
31
39
32
-static void raspi_machine_class_init(ObjectClass *oc, void *data)
40
+static void mss_timer_finalize(Object *obj)
33
+static void raspi_machine_class_common_init(MachineClass *mc,
41
+{
34
+ uint32_t board_rev)
42
+ MSSTimerState *t = MSS_TIMER(obj);
35
{
43
+ int i;
36
- MachineClass *mc = MACHINE_CLASS(oc);
44
+
37
- RaspiMachineClass *rmc = RASPI_MACHINE_CLASS(oc);
45
+ for (i = 0; i < NUM_TIMERS; i++) {
38
- uint32_t board_rev = (uint32_t)(uintptr_t)data;
46
+ struct Msf2Timer *st = &t->timers[i];
39
-
47
+
40
- rmc->board_rev = board_rev;
48
+ ptimer_free(st->ptimer);
41
mc->desc = g_strdup_printf("Raspberry Pi %s (revision 1.%u)",
49
+ }
42
board_type(board_rev),
50
+}
43
FIELD_EX32(board_rev, REV_CODE, REVISION));
51
+
44
@@ -XXX,XX +XXX,XX @@ static void raspi_machine_class_init(ObjectClass *oc, void *data)
52
static const VMStateDescription vmstate_timers = {
45
mc->default_ram_id = "ram";
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,
46
};
61
};
47
62
48
+static void raspi2b_machine_class_init(ObjectClass *oc, void *data)
49
+{
50
+ MachineClass *mc = MACHINE_CLASS(oc);
51
+ RaspiMachineClass *rmc = RASPI_MACHINE_CLASS(oc);
52
+
53
+ rmc->board_rev = 0xa21041;
54
+ raspi_machine_class_common_init(mc, rmc->board_rev);
55
+};
56
+
57
+#ifdef TARGET_AARCH64
58
+static void raspi3b_machine_class_init(ObjectClass *oc, void *data)
59
+{
60
+ MachineClass *mc = MACHINE_CLASS(oc);
61
+ RaspiMachineClass *rmc = RASPI_MACHINE_CLASS(oc);
62
+
63
+ rmc->board_rev = 0xa02082;
64
+ raspi_machine_class_common_init(mc, rmc->board_rev);
65
+};
66
+#endif /* TARGET_AARCH64 */
67
+
68
static const TypeInfo raspi_machine_types[] = {
69
{
70
.name = MACHINE_TYPE_NAME("raspi2"),
71
.parent = TYPE_RASPI_MACHINE,
72
- .class_init = raspi_machine_class_init,
73
- .class_data = (void *)0xa21041,
74
+ .class_init = raspi2b_machine_class_init,
75
#ifdef TARGET_AARCH64
76
}, {
77
.name = MACHINE_TYPE_NAME("raspi3"),
78
.parent = TYPE_RASPI_MACHINE,
79
- .class_init = raspi_machine_class_init,
80
- .class_data = (void *)0xa02082,
81
+ .class_init = raspi3b_machine_class_init,
82
#endif
83
}, {
84
.name = TYPE_RASPI_MACHINE,
85
--
63
--
86
2.20.1
64
2.20.1
87
65
88
66
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
1
From: Gan Qixin <ganqixin@huawei.com>
2
2
3
The 'first_cpu' is more a QEMU accelerator-related concept
3
When running device-introspect-test, a memory leak occurred in the
4
than a variable the machine requires to use.
4
mv88w8618_pit_init function, so use ptimer_free() in the finalize function to
5
Since the machine is aware of its CPUs, directly use the
5
avoid it.
6
first one to load the firmware.
7
6
8
Reviewed-by: Luc Michel <luc.michel@greensocs.com>
7
ASAN shows memory leak stack:
9
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
8
10
Message-id: 20200924111808.77168-3-f4bug@amsat.org
9
Indirect leak of 192 byte(s) in 4 object(s) allocated from:
10
#0 0xffffab97e1f0 in __interceptor_calloc (/lib64/libasan.so.5+0xee1f0)
11
#1 0xffffab256800 in g_malloc0 (/lib64/libglib-2.0.so.0+0x56800)
12
#2 0xaaabf555db84 in timer_new_full /qemu/include/qemu/timer.h:523
13
#3 0xaaabf555db84 in timer_new /qemu/include/qemu/timer.h:544
14
#4 0xaaabf555db84 in timer_new_ns /qemu/include/qemu/timer.h:562
15
#5 0xaaabf555db84 in ptimer_init /qemu/hw/core/ptimer.c:433
16
#6 0xaaabf5bb2290 in mv88w8618_timer_init /qemu/hw/arm/musicpal.c:862
17
#7 0xaaabf5bb2290 in mv88w8618_pit_init /qemu/hw/arm/musicpal.c:954
18
#8 0xaaabf6339f6c in object_initialize_with_type /qemu/qom/object.c:515
19
#9 0xaaabf633a1e0 in object_new_with_type /qemu/qom/object.c:729
20
#10 0xaaabf6375e40 in qmp_device_list_properties /qemu/qom/qom-qmp-cmds.c:153
21
#11 0xaaabf5a95540 in qdev_device_help /qemu/softmmu/qdev-monitor.c:283
22
#12 0xaaabf5a96940 in qmp_device_add /qemu/softmmu/qdev-monitor.c:801
23
24
Reported-by: Euler Robot <euler.robot@huawei.com>
25
Signed-off-by: Gan Qixin <ganqixin@huawei.com>
26
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
27
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
---
28
---
13
hw/arm/raspi.c | 3 ++-
29
hw/arm/musicpal.c | 12 ++++++++++++
14
1 file changed, 2 insertions(+), 1 deletion(-)
30
1 file changed, 12 insertions(+)
15
31
16
diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c
32
diff --git a/hw/arm/musicpal.c b/hw/arm/musicpal.c
17
index XXXXXXX..XXXXXXX 100644
33
index XXXXXXX..XXXXXXX 100644
18
--- a/hw/arm/raspi.c
34
--- a/hw/arm/musicpal.c
19
+++ b/hw/arm/raspi.c
35
+++ b/hw/arm/musicpal.c
20
@@ -XXX,XX +XXX,XX @@ static void reset_secondary(ARMCPU *cpu, const struct arm_boot_info *info)
36
@@ -XXX,XX +XXX,XX @@ static void mv88w8618_pit_init(Object *obj)
21
37
sysbus_init_mmio(dev, &s->iomem);
22
static void setup_boot(MachineState *machine, int version, size_t ram_size)
23
{
24
+ RaspiMachineState *s = RASPI_MACHINE(machine);
25
static struct arm_boot_info binfo;
26
int r;
27
28
@@ -XXX,XX +XXX,XX @@ static void setup_boot(MachineState *machine, int version, size_t ram_size)
29
binfo.firmware_loaded = true;
30
}
31
32
- arm_load_kernel(ARM_CPU(first_cpu), machine, &binfo);
33
+ arm_load_kernel(&s->soc.cpu[0].core, machine, &binfo);
34
}
38
}
35
39
36
static void raspi_machine_init(MachineState *machine)
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
37
--
62
--
38
2.20.1
63
2.20.1
39
64
40
65
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
1
From: Gan Qixin <ganqixin@huawei.com>
2
2
3
Commit 1c3db49d39 added the raspi3, which uses the same peripherals
3
When running device-introspect-test, a memory leak occurred in the
4
than the raspi2 (but with different ARM cores). The raspi3 was
4
exynos4210_mct_init function, so use ptimer_free() in the finalize function to
5
introduced without the ignore_memory_transaction_failures flag.
5
avoid it.
6
Almost 2 years later, the machine is usable running U-Boot and
7
Linux.
8
In commit 00cbd5bd74 we mapped a lot of unimplemented devices,
9
commit d442d95f added thermal block and commit 0e5bbd7406 the
10
system timer.
11
As we are happy with the raspi3, let's remove this flag on the
12
raspi2.
13
6
14
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
ASAN shows memory leak stack:
15
Reviewed-by: Luc Michel <luc.michel@greensocs.com>
8
16
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
9
Indirect leak of 96 byte(s) in 1 object(s) allocated from:
17
Message-id: 20200921034729.432931-4-f4bug@amsat.org
10
#0 0xffffab97e1f0 in __interceptor_calloc (/lib64/libasan.so.5+0xee1f0)
11
#1 0xffffab256800 in g_malloc0 (/lib64/libglib-2.0.so.0+0x56800)
12
#2 0xaaabf555db78 in ptimer_init /qemu/hw/core/ptimer.c:432
13
#3 0xaaabf56b01a0 in exynos4210_mct_init /qemu/hw/timer/exynos4210_mct.c:1505
14
#4 0xaaabf6339f6c in object_initialize_with_type /qemu/qom/object.c:515
15
#5 0xaaabf633a1e0 in object_new_with_type /qemu/qom/object.c:729
16
#6 0xaaabf6375e40 in qmp_device_list_properties /qemu/qom/qom-qmp-cmds.c:153
17
#7 0xaaabf653d8ec in qmp_marshal_device_list_properties /qemu/qapi/qapi-commands-qdev.c:59
18
#8 0xaaabf6587d08 in do_qmp_dispatch_bh /qemu/qapi/qmp-dispatch.c:110
19
#9 0xaaabf6552708 in aio_bh_call /qemu/util/async.c:136
20
#10 0xaaabf6552708 in aio_bh_poll /qemu/util/async.c:164
21
#11 0xaaabf655f19c in aio_dispatch /qemu/util/aio-posix.c:381
22
#12 0xaaabf65523f4 in aio_ctx_dispatch /qemu/util/async.c:306
23
24
Reported-by: Euler Robot <euler.robot@huawei.com>
25
Signed-off-by: Gan Qixin <ganqixin@huawei.com>
26
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
18
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
27
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
19
---
28
---
20
hw/arm/raspi.c | 3 ---
29
hw/timer/exynos4210_mct.c | 14 ++++++++++++++
21
1 file changed, 3 deletions(-)
30
1 file changed, 14 insertions(+)
22
31
23
diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c
32
diff --git a/hw/timer/exynos4210_mct.c b/hw/timer/exynos4210_mct.c
24
index XXXXXXX..XXXXXXX 100644
33
index XXXXXXX..XXXXXXX 100644
25
--- a/hw/arm/raspi.c
34
--- a/hw/timer/exynos4210_mct.c
26
+++ b/hw/arm/raspi.c
35
+++ b/hw/timer/exynos4210_mct.c
27
@@ -XXX,XX +XXX,XX @@ static void raspi_machine_class_init(ObjectClass *oc, void *data)
36
@@ -XXX,XX +XXX,XX @@ static void exynos4210_mct_init(Object *obj)
28
mc->default_cpus = mc->min_cpus = mc->max_cpus = cores_count(board_rev);
37
sysbus_init_mmio(dev, &s->iomem);
29
mc->default_ram_size = board_ram_size(board_rev);
38
}
30
mc->default_ram_id = "ram";
39
31
- if (board_version(board_rev) == 2) {
40
+static void exynos4210_mct_finalize(Object *obj)
32
- mc->ignore_memory_transaction_failures = true;
41
+{
33
- }
42
+ int i;
43
+ Exynos4210MCTState *s = EXYNOS4210_MCT(obj);
44
+
45
+ ptimer_free(s->g_timer.ptimer_frc);
46
+
47
+ for (i = 0; i < 2; i++) {
48
+ ptimer_free(s->l_timer[i].tick_timer.ptimer_tick);
49
+ ptimer_free(s->l_timer[i].ptimer_frc);
50
+ }
51
+}
52
+
53
static void exynos4210_mct_class_init(ObjectClass *klass, void *data)
54
{
55
DeviceClass *dc = DEVICE_CLASS(klass);
56
@@ -XXX,XX +XXX,XX @@ static const TypeInfo exynos4210_mct_info = {
57
.parent = TYPE_SYS_BUS_DEVICE,
58
.instance_size = sizeof(Exynos4210MCTState),
59
.instance_init = exynos4210_mct_init,
60
+ .instance_finalize = exynos4210_mct_finalize,
61
.class_init = exynos4210_mct_class_init,
34
};
62
};
35
63
36
static const TypeInfo raspi_machine_types[] = {
37
--
64
--
38
2.20.1
65
2.20.1
39
66
40
67
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
1
From: Bin Meng <bin.meng@windriver.com>
2
2
3
The bcm2835-v3d is used since Linux 4.7, see commit
3
U-Boot expects PMU_MISC0 register bit 7 is set (see init_bandgap()
4
49ac67e0c39c ("ARM: bcm2835: Add VC4 to the device tree"),
4
in arch/arm/mach-imx/mx6/soc.c) during boot. This bit indicates the
5
and the bcm2835-txp since Linux 4.19, see commit
5
bandgap has stabilized.
6
b7dd29b401f5 ("ARM: dts: bcm283x: Add Transposer block").
7
6
8
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
7
With this change, the latest upstream U-Boot (v2021.01-rc3) for imx6
9
Reviewed-by: Luc Michel <luc.michel@greensocs.com>
8
sabrelite board (mx6qsabrelite_defconfig), with a slight change made
10
Message-id: 20200921034729.432931-3-f4bug@amsat.org
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
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
53
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
---
54
---
13
include/hw/arm/bcm2835_peripherals.h | 2 ++
55
hw/misc/imx6_ccm.c | 2 +-
14
hw/arm/bcm2835_peripherals.c | 2 ++
56
1 file changed, 1 insertion(+), 1 deletion(-)
15
2 files changed, 4 insertions(+)
16
57
17
diff --git a/include/hw/arm/bcm2835_peripherals.h b/include/hw/arm/bcm2835_peripherals.h
58
diff --git a/hw/misc/imx6_ccm.c b/hw/misc/imx6_ccm.c
18
index XXXXXXX..XXXXXXX 100644
59
index XXXXXXX..XXXXXXX 100644
19
--- a/include/hw/arm/bcm2835_peripherals.h
60
--- a/hw/misc/imx6_ccm.c
20
+++ b/include/hw/arm/bcm2835_peripherals.h
61
+++ b/hw/misc/imx6_ccm.c
21
@@ -XXX,XX +XXX,XX @@ struct BCM2835PeripheralState {
62
@@ -XXX,XX +XXX,XX @@ static void imx6_ccm_reset(DeviceState *dev)
22
63
s->analog[PMU_REG_3P0] = 0x00000F74;
23
BCM2835SystemTimerState systmr;
64
s->analog[PMU_REG_2P5] = 0x00005071;
24
BCM2835MphiState mphi;
65
s->analog[PMU_REG_CORE] = 0x00402010;
25
+ UnimplementedDeviceState txp;
66
- s->analog[PMU_MISC0] = 0x04000000;
26
UnimplementedDeviceState armtmr;
67
+ s->analog[PMU_MISC0] = 0x04000080;
27
UnimplementedDeviceState cprman;
68
s->analog[PMU_MISC1] = 0x00000000;
28
UnimplementedDeviceState a2w;
69
s->analog[PMU_MISC2] = 0x00272727;
29
@@ -XXX,XX +XXX,XX @@ struct BCM2835PeripheralState {
30
UnimplementedDeviceState otp;
31
UnimplementedDeviceState dbus;
32
UnimplementedDeviceState ave0;
33
+ UnimplementedDeviceState v3d;
34
UnimplementedDeviceState bscsl;
35
UnimplementedDeviceState smi;
36
DWC2State dwc2;
37
diff --git a/hw/arm/bcm2835_peripherals.c b/hw/arm/bcm2835_peripherals.c
38
index XXXXXXX..XXXXXXX 100644
39
--- a/hw/arm/bcm2835_peripherals.c
40
+++ b/hw/arm/bcm2835_peripherals.c
41
@@ -XXX,XX +XXX,XX @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp)
42
qdev_get_gpio_in_named(DEVICE(&s->ic), BCM2835_IC_GPU_IRQ,
43
INTERRUPT_USB));
44
45
+ create_unimp(s, &s->txp, "bcm2835-txp", TXP_OFFSET, 0x1000);
46
create_unimp(s, &s->armtmr, "bcm2835-sp804", ARMCTRL_TIMER0_1_OFFSET, 0x40);
47
create_unimp(s, &s->cprman, "bcm2835-cprman", CPRMAN_OFFSET, 0x1000);
48
create_unimp(s, &s->a2w, "bcm2835-a2w", A2W_OFFSET, 0x1000);
49
@@ -XXX,XX +XXX,XX @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp)
50
create_unimp(s, &s->otp, "bcm2835-otp", OTP_OFFSET, 0x80);
51
create_unimp(s, &s->dbus, "bcm2835-dbus", DBUS_OFFSET, 0x8000);
52
create_unimp(s, &s->ave0, "bcm2835-ave0", AVE0_OFFSET, 0x8000);
53
+ create_unimp(s, &s->v3d, "bcm2835-v3d", V3D_OFFSET, 0x1000);
54
create_unimp(s, &s->sdramc, "bcm2835-sdramc", SDRAMC_OFFSET, 0x100);
55
}
56
70
57
--
71
--
58
2.20.1
72
2.20.1
59
73
60
74
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
1
From: Bin Meng <bin.meng@windriver.com>
2
2
3
As we only support a reduced set of the REV_CODE_PROCESSOR id
3
Currently when U-Boot boots, it prints "??" for i.MX processor:
4
encoded in the board revision, define the PROCESSOR_ID values
5
as an enum. We can simplify the board_soc_type and cores_count
6
methods.
7
4
8
Reviewed-by: Luc Michel <luc.michel@greensocs.com>
5
CPU: Freescale i.MX?? rev1.0 at 792 MHz
9
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
6
10
Message-id: 20200924111808.77168-7-f4bug@amsat.org
7
The register that was used to determine the silicon type is
8
undocumented in the latest IMX6DQRM (Rev. 6, 05/2020), but we
9
can refer to get_cpu_rev() in arch/arm/mach-imx/mx6/soc.c in
10
the U-Boot source codes that USB_ANALOG_DIGPROG is used.
11
12
Update its reset value to indicate i.MX6Q.
13
14
Signed-off-by: Bin Meng <bin.meng@windriver.com>
15
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
16
Message-id: 20210106063504.10841-3-bmeng.cn@gmail.com
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
17
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
---
18
---
13
hw/arm/raspi.c | 45 +++++++++++++++++++++------------------------
19
hw/misc/imx6_ccm.c | 2 +-
14
1 file changed, 21 insertions(+), 24 deletions(-)
20
1 file changed, 1 insertion(+), 1 deletion(-)
15
21
16
diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c
22
diff --git a/hw/misc/imx6_ccm.c b/hw/misc/imx6_ccm.c
17
index XXXXXXX..XXXXXXX 100644
23
index XXXXXXX..XXXXXXX 100644
18
--- a/hw/arm/raspi.c
24
--- a/hw/misc/imx6_ccm.c
19
+++ b/hw/arm/raspi.c
25
+++ b/hw/misc/imx6_ccm.c
20
@@ -XXX,XX +XXX,XX @@ FIELD(REV_CODE, MANUFACTURER, 16, 4);
26
@@ -XXX,XX +XXX,XX @@ static void imx6_ccm_reset(DeviceState *dev)
21
FIELD(REV_CODE, MEMORY_SIZE, 20, 3);
27
s->analog[USB_ANALOG_USB2_VBUS_DETECT] = 0x00000004;
22
FIELD(REV_CODE, STYLE, 23, 1);
28
s->analog[USB_ANALOG_USB2_CHRG_DETECT] = 0x00000000;
23
29
s->analog[USB_ANALOG_USB2_MISC] = 0x00000002;
24
+typedef enum RaspiProcessorId {
30
- s->analog[USB_ANALOG_DIGPROG] = 0x00000000;
25
+ PROCESSOR_ID_BCM2836 = 1,
31
+ s->analog[USB_ANALOG_DIGPROG] = 0x00630000;
26
+ PROCESSOR_ID_BCM2837 = 2,
32
27
+} RaspiProcessorId;
33
/* all PLLs need to be locked */
28
+
34
s->analog[CCM_ANALOG_PLL_ARM] |= CCM_ANALOG_PLL_LOCK;
29
+static const struct {
30
+ const char *type;
31
+ int cores_count;
32
+} soc_property[] = {
33
+ [PROCESSOR_ID_BCM2836] = {TYPE_BCM2836, BCM283X_NCPUS},
34
+ [PROCESSOR_ID_BCM2837] = {TYPE_BCM2837, BCM283X_NCPUS},
35
+};
36
+
37
static uint64_t board_ram_size(uint32_t board_rev)
38
{
39
assert(FIELD_EX32(board_rev, REV_CODE, STYLE)); /* Only new style */
40
return 256 * MiB << FIELD_EX32(board_rev, REV_CODE, MEMORY_SIZE);
41
}
42
43
-static int board_processor_id(uint32_t board_rev)
44
+static RaspiProcessorId board_processor_id(uint32_t board_rev)
45
{
46
+ int proc_id = FIELD_EX32(board_rev, REV_CODE, PROCESSOR);
47
+
48
assert(FIELD_EX32(board_rev, REV_CODE, STYLE)); /* Only new style */
49
- return FIELD_EX32(board_rev, REV_CODE, PROCESSOR);
50
+ assert(proc_id < ARRAY_SIZE(soc_property) && soc_property[proc_id].type);
51
+
52
+ return proc_id;
53
}
54
55
static int board_version(uint32_t board_rev)
56
@@ -XXX,XX +XXX,XX @@ static int board_version(uint32_t board_rev)
57
58
static const char *board_soc_type(uint32_t board_rev)
59
{
60
- static const char *soc_types[] = {
61
- NULL, TYPE_BCM2836, TYPE_BCM2837,
62
- };
63
- int proc_id = board_processor_id(board_rev);
64
-
65
- if (proc_id >= ARRAY_SIZE(soc_types) || !soc_types[proc_id]) {
66
- error_report("Unsupported processor id '%d' (board revision: 0x%x)",
67
- proc_id, board_rev);
68
- exit(1);
69
- }
70
- return soc_types[proc_id];
71
+ return soc_property[board_processor_id(board_rev)].type;
72
}
73
74
static int cores_count(uint32_t board_rev)
75
{
76
- static const int soc_cores_count[] = {
77
- 0, BCM283X_NCPUS, BCM283X_NCPUS,
78
- };
79
- int proc_id = board_processor_id(board_rev);
80
-
81
- if (proc_id >= ARRAY_SIZE(soc_cores_count) || !soc_cores_count[proc_id]) {
82
- error_report("Unsupported processor id '%d' (board revision: 0x%x)",
83
- proc_id, board_rev);
84
- exit(1);
85
- }
86
- return soc_cores_count[proc_id];
87
+ return soc_property[board_processor_id(board_rev)].cores_count;
88
}
89
90
static const char *board_type(uint32_t board_rev)
91
--
35
--
92
2.20.1
36
2.20.1
93
37
94
38
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
1
From: Bin Meng <bin.meng@windriver.com>
2
2
3
Now that we can instantiate different machines based on their
3
At present, when booting U-Boot on QEMU sabrelite, we see:
4
board_rev register value, we can have various raspi2 and raspi3.
5
4
6
In commit fc78a990ec103 we corrected the machine description.
5
Net: Board Net Initialization Failed
7
Correct the machine names too. For backward compatibility, add
6
No ethernet found.
8
an alias to the previous generic name.
9
7
10
Reviewed-by: Luc Michel <luc.michel@greensocs.com>
8
U-Boot scans PHY at address 4/5/6/7 (see board_eth_init() in the
11
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
9
U-Boot source: board/boundary/nitrogen6x/nitrogen6x.c). On the real
12
Message-id: 20200924111808.77168-6-f4bug@amsat.org
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
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
29
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
---
30
---
15
hw/arm/raspi.c | 6 ++++--
31
hw/arm/sabrelite.c | 4 ++++
16
1 file changed, 4 insertions(+), 2 deletions(-)
32
1 file changed, 4 insertions(+)
17
33
18
diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c
34
diff --git a/hw/arm/sabrelite.c b/hw/arm/sabrelite.c
19
index XXXXXXX..XXXXXXX 100644
35
index XXXXXXX..XXXXXXX 100644
20
--- a/hw/arm/raspi.c
36
--- a/hw/arm/sabrelite.c
21
+++ b/hw/arm/raspi.c
37
+++ b/hw/arm/sabrelite.c
22
@@ -XXX,XX +XXX,XX @@ static void raspi2b_machine_class_init(ObjectClass *oc, void *data)
38
@@ -XXX,XX +XXX,XX @@ static void sabrelite_init(MachineState *machine)
23
MachineClass *mc = MACHINE_CLASS(oc);
39
24
RaspiMachineClass *rmc = RASPI_MACHINE_CLASS(oc);
40
s = FSL_IMX6(object_new(TYPE_FSL_IMX6));
25
41
object_property_add_child(OBJECT(machine), "soc", OBJECT(s));
26
+ mc->alias = "raspi2";
42
+
27
rmc->board_rev = 0xa21041;
43
+ /* Ethernet PHY address is 6 */
28
raspi_machine_class_common_init(mc, rmc->board_rev);
44
+ object_property_set_int(OBJECT(s), "fec-phy-num", 6, &error_fatal);
29
};
45
+
30
@@ -XXX,XX +XXX,XX @@ static void raspi3b_machine_class_init(ObjectClass *oc, void *data)
46
qdev_realize(DEVICE(s), NULL, &error_fatal);
31
MachineClass *mc = MACHINE_CLASS(oc);
47
32
RaspiMachineClass *rmc = RASPI_MACHINE_CLASS(oc);
48
memory_region_add_subregion(get_system_memory(), FSL_IMX6_MMDC_ADDR,
33
34
+ mc->alias = "raspi3";
35
rmc->board_rev = 0xa02082;
36
raspi_machine_class_common_init(mc, rmc->board_rev);
37
};
38
@@ -XXX,XX +XXX,XX @@ static void raspi3b_machine_class_init(ObjectClass *oc, void *data)
39
40
static const TypeInfo raspi_machine_types[] = {
41
{
42
- .name = MACHINE_TYPE_NAME("raspi2"),
43
+ .name = MACHINE_TYPE_NAME("raspi2b"),
44
.parent = TYPE_RASPI_MACHINE,
45
.class_init = raspi2b_machine_class_init,
46
#ifdef TARGET_AARCH64
47
}, {
48
- .name = MACHINE_TYPE_NAME("raspi3"),
49
+ .name = MACHINE_TYPE_NAME("raspi3b"),
50
.parent = TYPE_RASPI_MACHINE,
51
.class_init = raspi3b_machine_class_init,
52
#endif
53
--
49
--
54
2.20.1
50
2.20.1
55
51
56
52
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
1
From: Bin Meng <bin.meng@windriver.com>
2
2
3
The Raspberry firmware is closed-source. While running it, it
3
This adds the target guide for SABRE Lite board, and documents how
4
accesses various I/O registers. Logging these accesses as UNIMP
4
to boot a Linux kernel and U-Boot bootloader.
5
(unimplemented) help to understand what the firmware is doing
6
(ideally we want it able to boot a Linux kernel).
7
5
8
Document various blocks we might use later.
6
Signed-off-by: Bin Meng <bin.meng@windriver.com>
9
10
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
7
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
11
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
8
Message-id: 20210106063504.10841-5-bmeng.cn@gmail.com
12
Reviewed-by: Luc Michel <luc.michel@greensocs.com>
13
Message-id: 20200921034729.432931-2-f4bug@amsat.org
14
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
15
---
10
---
16
include/hw/arm/raspi_platform.h | 51 +++++++++++++++++++++++++++------
11
docs/system/arm/sabrelite.rst | 119 ++++++++++++++++++++++++++++++++++
17
1 file changed, 43 insertions(+), 8 deletions(-)
12
docs/system/target-arm.rst | 1 +
13
2 files changed, 120 insertions(+)
14
create mode 100644 docs/system/arm/sabrelite.rst
18
15
19
diff --git a/include/hw/arm/raspi_platform.h b/include/hw/arm/raspi_platform.h
16
diff --git a/docs/system/arm/sabrelite.rst b/docs/system/arm/sabrelite.rst
17
new file mode 100644
18
index XXXXXXX..XXXXXXX
19
--- /dev/null
20
+++ b/docs/system/arm/sabrelite.rst
21
@@ -XXX,XX +XXX,XX @@
22
+Boundary Devices SABRE Lite (``sabrelite``)
23
+===========================================
24
+
25
+Boundary Devices SABRE Lite i.MX6 Development Board is a low-cost development
26
+platform featuring the powerful Freescale / NXP Semiconductor's i.MX 6 Quad
27
+Applications Processor.
28
+
29
+Supported devices
30
+-----------------
31
+
32
+The SABRE Lite machine supports the following devices:
33
+
34
+ * Up to 4 Cortex A9 cores
35
+ * Generic Interrupt Controller
36
+ * 1 Clock Controller Module
37
+ * 1 System Reset Controller
38
+ * 5 UARTs
39
+ * 2 EPIC timers
40
+ * 1 GPT timer
41
+ * 2 Watchdog timers
42
+ * 1 FEC Ethernet controller
43
+ * 3 I2C controllers
44
+ * 7 GPIO controllers
45
+ * 4 SDHC storage controllers
46
+ * 4 USB 2.0 host controllers
47
+ * 5 ECSPI controllers
48
+ * 1 SST 25VF016B flash
49
+
50
+Please note above list is a complete superset the QEMU SABRE Lite machine can
51
+support. For a normal use case, a device tree blob that represents a real world
52
+SABRE Lite board, only exposes a subset of devices to the guest software.
53
+
54
+Boot options
55
+------------
56
+
57
+The SABRE Lite machine can start using the standard -kernel functionality
58
+for loading a Linux kernel, U-Boot bootloader or ELF executable.
59
+
60
+Running Linux kernel
61
+--------------------
62
+
63
+Linux mainline v5.10 release is tested at the time of writing. To build a Linux
64
+mainline kernel that can be booted by the SABRE Lite machine, simply configure
65
+the kernel using the imx_v6_v7_defconfig configuration:
66
+
67
+.. code-block:: bash
68
+
69
+ $ export ARCH=arm
70
+ $ export CROSS_COMPILE=arm-linux-gnueabihf-
71
+ $ make imx_v6_v7_defconfig
72
+ $ make
73
+
74
+To boot the newly built Linux kernel in QEMU with the SABRE Lite machine, use:
75
+
76
+.. code-block:: bash
77
+
78
+ $ qemu-system-arm -M sabrelite -smp 4 -m 1G \
79
+ -display none -serial null -serial stdio \
80
+ -kernel arch/arm/boot/zImage \
81
+ -dtb arch/arm/boot/dts/imx6q-sabrelite.dtb \
82
+ -initrd /path/to/rootfs.ext4 \
83
+ -append "root=/dev/ram"
84
+
85
+Running U-Boot
86
+--------------
87
+
88
+U-Boot mainline v2020.10 release is tested at the time of writing. To build a
89
+U-Boot mainline bootloader that can be booted by the SABRE Lite machine, use
90
+the mx6qsabrelite_defconfig with similar commands as described above for Linux:
91
+
92
+.. code-block:: bash
93
+
94
+ $ export CROSS_COMPILE=arm-linux-gnueabihf-
95
+ $ make mx6qsabrelite_defconfig
96
+
97
+Note we need to adjust settings by:
98
+
99
+.. code-block:: bash
100
+
101
+ $ make menuconfig
102
+
103
+then manually select the following configuration in U-Boot:
104
+
105
+ Device Tree Control > Provider of DTB for DT Control > Embedded DTB
106
+
107
+To start U-Boot using the SABRE Lite machine, provide the u-boot binary to
108
+the -kernel argument, along with an SD card image with rootfs:
109
+
110
+.. code-block:: bash
111
+
112
+ $ qemu-system-arm -M sabrelite -smp 4 -m 1G \
113
+ -display none -serial null -serial stdio \
114
+ -kernel u-boot
115
+
116
+The following example shows booting Linux kernel from dhcp, and uses the
117
+rootfs on an SD card. This requires some additional command line parameters
118
+for QEMU:
119
+
120
+.. code-block:: none
121
+
122
+ -nic user,tftp=/path/to/kernel/zImage \
123
+ -drive file=sdcard.img,id=rootfs -device sd-card,drive=rootfs
124
+
125
+The directory for the built-in TFTP server should also contain the device tree
126
+blob of the SABRE Lite board. The sample SD card image was populated with the
127
+root file system with one single partition. You may adjust the kernel "root="
128
+boot parameter accordingly.
129
+
130
+After U-Boot boots, type the following commands in the U-Boot command shell to
131
+boot the Linux kernel:
132
+
133
+.. code-block:: none
134
+
135
+ => setenv ethaddr 00:11:22:33:44:55
136
+ => setenv bootfile zImage
137
+ => dhcp
138
+ => tftpboot 14000000 imx6q-sabrelite.dtb
139
+ => setenv bootargs root=/dev/mmcblk3p1
140
+ => bootz 12000000 - 14000000
141
diff --git a/docs/system/target-arm.rst b/docs/system/target-arm.rst
20
index XXXXXXX..XXXXXXX 100644
142
index XXXXXXX..XXXXXXX 100644
21
--- a/include/hw/arm/raspi_platform.h
143
--- a/docs/system/target-arm.rst
22
+++ b/include/hw/arm/raspi_platform.h
144
+++ b/docs/system/target-arm.rst
23
@@ -XXX,XX +XXX,XX @@
145
@@ -XXX,XX +XXX,XX @@ undocumented; you can get a complete list by running
24
* You should have received a copy of the GNU General Public License
146
arm/versatile
25
* along with this program; if not, write to the Free Software
147
arm/vexpress
26
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
148
arm/aspeed
27
+ *
149
+ arm/sabrelite
28
+ * Various undocumented addresses and names come from Herman Hermitage's VC4
150
arm/digic
29
+ * documentation:
151
arm/musicpal
30
+ * https://github.com/hermanhermitage/videocoreiv/wiki/MMIO-Register-map
152
arm/gumstix
31
*/
32
33
#ifndef HW_ARM_RASPI_PLATFORM_H
34
#define HW_ARM_RASPI_PLATFORM_H
35
36
#define MSYNC_OFFSET 0x0000 /* Multicore Sync Block */
37
-#define IC0_OFFSET 0x2000
38
+#define CCPT_OFFSET 0x1000 /* Compact Camera Port 2 TX */
39
+#define INTE_OFFSET 0x2000 /* VC Interrupt controller */
40
#define ST_OFFSET 0x3000 /* System Timer */
41
+#define TXP_OFFSET 0x4000 /* Transposer */
42
+#define JPEG_OFFSET 0x5000
43
#define MPHI_OFFSET 0x6000 /* Message-based Parallel Host Intf. */
44
#define DMA_OFFSET 0x7000 /* DMA controller, channels 0-14 */
45
-#define ARM_OFFSET 0xB000 /* BCM2708 ARM control block */
46
+#define ARBA_OFFSET 0x9000
47
+#define BRDG_OFFSET 0xa000
48
+#define ARM_OFFSET 0xB000 /* ARM control block */
49
#define ARMCTRL_OFFSET (ARM_OFFSET + 0x000)
50
#define ARMCTRL_IC_OFFSET (ARM_OFFSET + 0x200) /* Interrupt controller */
51
-#define ARMCTRL_TIMER0_1_OFFSET (ARM_OFFSET + 0x400) /* Timer 0 and 1 */
52
+#define ARMCTRL_TIMER0_1_OFFSET (ARM_OFFSET + 0x400) /* Timer 0 and 1 (SP804) */
53
#define ARMCTRL_0_SBM_OFFSET (ARM_OFFSET + 0x800) /* User 0 (ARM) Semaphores
54
* Doorbells & Mailboxes */
55
#define CPRMAN_OFFSET 0x100000 /* Power Management, Watchdog */
56
@@ -XXX,XX +XXX,XX @@
57
#define AVS_OFFSET 0x103000 /* Audio Video Standard */
58
#define RNG_OFFSET 0x104000
59
#define GPIO_OFFSET 0x200000
60
-#define UART0_OFFSET 0x201000
61
-#define MMCI0_OFFSET 0x202000
62
-#define I2S_OFFSET 0x203000
63
-#define SPI0_OFFSET 0x204000
64
+#define UART0_OFFSET 0x201000 /* PL011 */
65
+#define MMCI0_OFFSET 0x202000 /* Legacy MMC */
66
+#define I2S_OFFSET 0x203000 /* PCM */
67
+#define SPI0_OFFSET 0x204000 /* SPI master */
68
#define BSC0_OFFSET 0x205000 /* BSC0 I2C/TWI */
69
+#define PIXV0_OFFSET 0x206000
70
+#define PIXV1_OFFSET 0x207000
71
+#define DPI_OFFSET 0x208000
72
+#define DSI0_OFFSET 0x209000 /* Display Serial Interface */
73
+#define PWM_OFFSET 0x20c000
74
+#define PERM_OFFSET 0x20d000
75
+#define TEC_OFFSET 0x20e000
76
#define OTP_OFFSET 0x20f000
77
+#define SLIM_OFFSET 0x210000 /* SLIMbus */
78
+#define CPG_OFFSET 0x211000
79
#define THERMAL_OFFSET 0x212000
80
-#define BSC_SL_OFFSET 0x214000 /* SPI slave */
81
+#define AVSP_OFFSET 0x213000
82
+#define BSC_SL_OFFSET 0x214000 /* SPI slave (bootrom) */
83
#define AUX_OFFSET 0x215000 /* AUX: UART1/SPI1/SPI2 */
84
#define EMMC1_OFFSET 0x300000
85
+#define EMMC2_OFFSET 0x340000
86
+#define HVS_OFFSET 0x400000
87
#define SMI_OFFSET 0x600000
88
+#define DSI1_OFFSET 0x700000
89
+#define UCAM_OFFSET 0x800000
90
+#define CMI_OFFSET 0x802000
91
#define BSC1_OFFSET 0x804000 /* BSC1 I2C/TWI */
92
#define BSC2_OFFSET 0x805000 /* BSC2 I2C/TWI */
93
+#define VECA_OFFSET 0x806000
94
+#define PIXV2_OFFSET 0x807000
95
+#define HDMI_OFFSET 0x808000
96
+#define HDCP_OFFSET 0x809000
97
+#define ARBR0_OFFSET 0x80a000
98
#define DBUS_OFFSET 0x900000
99
#define AVE0_OFFSET 0x910000
100
#define USB_OTG_OFFSET 0x980000 /* DTC_OTG USB controller */
101
+#define V3D_OFFSET 0xc00000
102
#define SDRAMC_OFFSET 0xe00000
103
+#define L2CC_OFFSET 0xe01000 /* Level 2 Cache controller */
104
+#define L1CC_OFFSET 0xe02000 /* Level 1 Cache controller */
105
+#define ARBR1_OFFSET 0xe04000
106
#define DMA15_OFFSET 0xE05000 /* DMA controller, channel 15 */
107
+#define DCRC_OFFSET 0xe07000
108
+#define AXIP_OFFSET 0xe08000
109
110
/* GPU interrupts */
111
#define INTERRUPT_TIMER0 0
112
--
153
--
113
2.20.1
154
2.20.1
114
155
115
156
diff view generated by jsdifflib