提交 5de16430 编写于 作者: P Peter Maydell

target-arm: Allow secondary KVM CPUs to be booted via PSCI

New ARM boards are generally expected to boot their secondary CPUs
via the PSCI interface, rather than ad-hoc "loop around in holding
pen code" as hw/arm/boot.c implements. In particular this is
necessary for mach-virt kernels. For KVM we achieve this by creating
the VCPUs with a feature flag marking them as starting in PSCI
powered-down state; the guest kernel will then make a PSCI call
(implemented in the host kernel) to start the secondaries at
an address of its choosing once it has got the primary CPU up.

Implement this setting of the feature flag, controlled by a
qdev property for ARMCPU, which board code can set if it is a
PSCI system.
Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
Reviewed-by: NChristoffer Dall <christoffer.dall@linaro.org>
Message-id: 1385140638-10444-7-git-send-email-peter.maydell@linaro.org
上级 54d3e3f5
...@@ -94,6 +94,9 @@ typedef struct ARMCPU { ...@@ -94,6 +94,9 @@ typedef struct ARMCPU {
/* 'compatible' string for this CPU for Linux device trees */ /* 'compatible' string for this CPU for Linux device trees */
const char *dtb_compatible; const char *dtb_compatible;
/* Should CPU start in PSCI powered-off state? */
bool start_powered_off;
/* The instance init functions for implementation-specific subclasses /* The instance init functions for implementation-specific subclasses
* set these fields to specify the implementation-dependent values of * set these fields to specify the implementation-dependent values of
* various constant registers and reset values of non-constant * various constant registers and reset values of non-constant
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include "cpu.h" #include "cpu.h"
#include "qemu-common.h" #include "qemu-common.h"
#include "hw/qdev-properties.h"
#if !defined(CONFIG_USER_ONLY) #if !defined(CONFIG_USER_ONLY)
#include "hw/loader.h" #include "hw/loader.h"
#endif #endif
...@@ -944,6 +945,11 @@ static const ARMCPUInfo arm_cpus[] = { ...@@ -944,6 +945,11 @@ static const ARMCPUInfo arm_cpus[] = {
#endif #endif
}; };
static Property arm_cpu_properties[] = {
DEFINE_PROP_BOOL("start-powered-off", ARMCPU, start_powered_off, false),
DEFINE_PROP_END_OF_LIST()
};
static void arm_cpu_class_init(ObjectClass *oc, void *data) static void arm_cpu_class_init(ObjectClass *oc, void *data)
{ {
ARMCPUClass *acc = ARM_CPU_CLASS(oc); ARMCPUClass *acc = ARM_CPU_CLASS(oc);
...@@ -952,6 +958,7 @@ static void arm_cpu_class_init(ObjectClass *oc, void *data) ...@@ -952,6 +958,7 @@ static void arm_cpu_class_init(ObjectClass *oc, void *data)
acc->parent_realize = dc->realize; acc->parent_realize = dc->realize;
dc->realize = arm_cpu_realizefn; dc->realize = arm_cpu_realizefn;
dc->props = arm_cpu_properties;
acc->parent_reset = cc->reset; acc->parent_reset = cc->reset;
cc->reset = arm_cpu_reset; cc->reset = arm_cpu_reset;
......
...@@ -79,6 +79,9 @@ int kvm_arch_init_vcpu(CPUState *cs) ...@@ -79,6 +79,9 @@ int kvm_arch_init_vcpu(CPUState *cs)
init.target = KVM_ARM_TARGET_CORTEX_A15; init.target = KVM_ARM_TARGET_CORTEX_A15;
memset(init.features, 0, sizeof(init.features)); memset(init.features, 0, sizeof(init.features));
if (cpu->start_powered_off) {
init.features[0] = 1 << KVM_ARM_VCPU_POWER_OFF;
}
ret = kvm_vcpu_ioctl(cs, KVM_ARM_VCPU_INIT, &init); ret = kvm_vcpu_ioctl(cs, KVM_ARM_VCPU_INIT, &init);
if (ret) { if (ret) {
return ret; return ret;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册