112 lines
3.8 KiB
Diff
112 lines
3.8 KiB
Diff
|
|
From 3e5f043c493fa4765c5637bec66be2bd620bc53f Mon Sep 17 00:00:00 2001
|
||
|
|
From: Salil Mehta <salil.mehta@huawei.com>
|
||
|
|
Date: Sat, 9 May 2020 18:10:24 +0100
|
||
|
|
Subject: [PATCH] hw/arm: Changes required for reset and to support next boot
|
||
|
|
|
||
|
|
Updates the firmware config with the next boot cpus information and also
|
||
|
|
registers the reset callback to be called when guest reboots to reset the cpu.
|
||
|
|
|
||
|
|
Co-developed-by: Salil Mehta <salil.mehta@huawei.com>
|
||
|
|
Signed-off-by: Salil Mehta <salil.mehta@huawei.com>
|
||
|
|
Co-developed-by: Keqian Zhu <zhukeqian1@huawei.com>
|
||
|
|
Signed-off-by: Keqian Zhu <zhukeqian1@huawei.com>
|
||
|
|
Signed-off-by: Salil Mehta <salil.mehta@huawei.com>
|
||
|
|
---
|
||
|
|
hw/arm/boot.c | 2 +-
|
||
|
|
hw/arm/virt.c | 18 +++++++++++++++---
|
||
|
|
include/hw/arm/boot.h | 2 ++
|
||
|
|
include/hw/arm/virt.h | 1 +
|
||
|
|
4 files changed, 19 insertions(+), 4 deletions(-)
|
||
|
|
|
||
|
|
diff --git a/hw/arm/boot.c b/hw/arm/boot.c
|
||
|
|
index d1671e1d42..345c7cfa19 100644
|
||
|
|
--- a/hw/arm/boot.c
|
||
|
|
+++ b/hw/arm/boot.c
|
||
|
|
@@ -683,7 +683,7 @@ fail:
|
||
|
|
return -1;
|
||
|
|
}
|
||
|
|
|
||
|
|
-static void do_cpu_reset(void *opaque)
|
||
|
|
+void do_cpu_reset(void *opaque)
|
||
|
|
{
|
||
|
|
ARMCPU *cpu = opaque;
|
||
|
|
CPUState *cs = CPU(cpu);
|
||
|
|
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
|
||
|
|
index 60cd560ab9..eedff8e525 100644
|
||
|
|
--- a/hw/arm/virt.c
|
||
|
|
+++ b/hw/arm/virt.c
|
||
|
|
@@ -46,6 +46,8 @@
|
||
|
|
#include "sysemu/device_tree.h"
|
||
|
|
#include "sysemu/numa.h"
|
||
|
|
#include "sysemu/runstate.h"
|
||
|
|
+#include "sysemu/reset.h"
|
||
|
|
+#include "sysemu/sysemu.h"
|
||
|
|
#include "sysemu/tpm.h"
|
||
|
|
#include "sysemu/tcg.h"
|
||
|
|
#include "sysemu/kvm.h"
|
||
|
|
@@ -1453,7 +1455,7 @@ static FWCfgState *create_fw_cfg(const VirtMachineState *vms, AddressSpace *as)
|
||
|
|
char *nodename;
|
||
|
|
|
||
|
|
fw_cfg = fw_cfg_init_mem_wide(base + 8, base, 8, base + 16, as);
|
||
|
|
- fw_cfg_add_i16(fw_cfg, FW_CFG_NB_CPUS, (uint16_t)ms->smp.cpus);
|
||
|
|
+ fw_cfg_add_i16(fw_cfg, FW_CFG_NB_CPUS, vms->boot_cpus);
|
||
|
|
|
||
|
|
nodename = g_strdup_printf("/fw-cfg@%" PRIx64, base);
|
||
|
|
qemu_fdt_add_subnode(ms->fdt, nodename);
|
||
|
|
@@ -3276,7 +3278,13 @@ static void virt_cpu_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
|
||
|
|
if (local_err) {
|
||
|
|
goto fail;
|
||
|
|
}
|
||
|
|
- /* TODO: register cpu for reset & update F/W info for the next boot */
|
||
|
|
+ /* register this cpu for reset & update F/W info for the next boot */
|
||
|
|
+ qemu_register_reset(do_cpu_reset, ARM_CPU(cs));
|
||
|
|
+ }
|
||
|
|
+
|
||
|
|
+ vms->boot_cpus++;
|
||
|
|
+ if (vms->fw_cfg) {
|
||
|
|
+ fw_cfg_modify_i16(vms->fw_cfg, FW_CFG_NB_CPUS, vms->boot_cpus);
|
||
|
|
}
|
||
|
|
|
||
|
|
cs->disabled = false;
|
||
|
|
@@ -3351,7 +3359,11 @@ static void virt_cpu_unplug(HotplugHandler *hotplug_dev, DeviceState *dev,
|
||
|
|
unwire_gic_cpu_irqs(vms, cs);
|
||
|
|
virt_update_gic(vms, cs);
|
||
|
|
|
||
|
|
- /* TODO: unregister cpu for reset & update F/W info for the next boot */
|
||
|
|
+ qemu_unregister_reset(do_cpu_reset, ARM_CPU(cs));
|
||
|
|
+ vms->boot_cpus--;
|
||
|
|
+ if (vms->fw_cfg) {
|
||
|
|
+ fw_cfg_modify_i16(vms->fw_cfg, FW_CFG_NB_CPUS, vms->boot_cpus);
|
||
|
|
+ }
|
||
|
|
|
||
|
|
qobject_unref(dev->opts);
|
||
|
|
dev->opts = NULL;
|
||
|
|
diff --git a/include/hw/arm/boot.h b/include/hw/arm/boot.h
|
||
|
|
index 80c492d742..f81326a1dc 100644
|
||
|
|
--- a/include/hw/arm/boot.h
|
||
|
|
+++ b/include/hw/arm/boot.h
|
||
|
|
@@ -178,6 +178,8 @@ AddressSpace *arm_boot_address_space(ARMCPU *cpu,
|
||
|
|
int arm_load_dtb(hwaddr addr, const struct arm_boot_info *binfo,
|
||
|
|
hwaddr addr_limit, AddressSpace *as, MachineState *ms);
|
||
|
|
|
||
|
|
+void do_cpu_reset(void *opaque);
|
||
|
|
+
|
||
|
|
/* Write a secure board setup routine with a dummy handler for SMCs */
|
||
|
|
void arm_write_secure_board_setup_dummy_smc(ARMCPU *cpu,
|
||
|
|
const struct arm_boot_info *info,
|
||
|
|
diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h
|
||
|
|
index 069c9f2a09..ae0f5beb26 100644
|
||
|
|
--- a/include/hw/arm/virt.h
|
||
|
|
+++ b/include/hw/arm/virt.h
|
||
|
|
@@ -167,6 +167,7 @@ struct VirtMachineState {
|
||
|
|
MemMapEntry *memmap;
|
||
|
|
char *pciehb_nodename;
|
||
|
|
const int *irqmap;
|
||
|
|
+ uint16_t boot_cpus;
|
||
|
|
int fdt_size;
|
||
|
|
uint32_t clock_phandle;
|
||
|
|
uint32_t gic_phandle;
|
||
|
|
--
|
||
|
|
2.27.0
|
||
|
|
|