From patchwork Fri Nov 22 17:17:13 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 21715 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ve0-f199.google.com (mail-ve0-f199.google.com [209.85.128.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 5BB9623FDB for ; Fri, 22 Nov 2013 17:17:34 +0000 (UTC) Received: by mail-ve0-f199.google.com with SMTP id c14sf2999790vea.6 for ; Fri, 22 Nov 2013 09:17:34 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=mDP+sd1lsmJI/EsRJJEm91utlQtF4JrPlrsnURlDr+s=; b=Wfv0la/5OSHEoGkrzo66i2Xw9cIfcnpgsTdqiIvirVvjURJWs2dk7+gqqtE08xbEPP v0FnECpYjnCcF24GwLSvVAdRcQZ8xO46zRVtJMARLn/qDuwcF046fDMeq8pM/j20Ic75 BJrsbIOfYmYdOGCDNp8jf1Hg+NDDhaL1T1HGi+ADDHheN3I9+JE7YLp0L1bEy5N7rYYJ //KNXhtovCVsjXzT8mmO+InHPkcYZclKpuscl+Fd0cMdxrTynWi+lX6ohGCox6VxHC/4 xUmNw+IqqCoQiCH9+2a+sGAPfmpO4zewPDqmtQYZLmTER0yDMePz6ydcRX06N3Pw4hU/ IMxA== X-Gm-Message-State: ALoCoQne5oJgZS/HvZj7PwZAD9pvzMejnAX6OvG9RuMfK5AQKuzmbtDOzqqFpjV+iTtKtisvTm3m X-Received: by 10.236.176.229 with SMTP id b65mr6236851yhm.10.1385140654214; Fri, 22 Nov 2013 09:17:34 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.17.7 with SMTP id k7ls1008229qed.96.gmail; Fri, 22 Nov 2013 09:17:34 -0800 (PST) X-Received: by 10.220.169.203 with SMTP id a11mr2860108vcz.26.1385140654124; Fri, 22 Nov 2013 09:17:34 -0800 (PST) Received: from mail-vc0-f180.google.com (mail-vc0-f180.google.com [209.85.220.180]) by mx.google.com with ESMTPS id tw10si12936665vec.120.2013.11.22.09.17.34 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 22 Nov 2013 09:17:34 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.180 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.180; Received: by mail-vc0-f180.google.com with SMTP id if17so1030912vcb.39 for ; Fri, 22 Nov 2013 09:17:34 -0800 (PST) X-Received: by 10.220.64.69 with SMTP id d5mr12466674vci.11.1385140653992; Fri, 22 Nov 2013 09:17:33 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp55013vcz; Fri, 22 Nov 2013 09:17:33 -0800 (PST) X-Received: by 10.204.226.135 with SMTP id iw7mr10423809bkb.4.1385140652614; Fri, 22 Nov 2013 09:17:32 -0800 (PST) Received: from mnementh.archaic.org.uk (1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.d.1.0.0.b.8.0.1.0.0.2.ip6.arpa. [2001:8b0:1d0::1]) by mx.google.com with ESMTPS id yz9si5999763bkb.17.2013.11.22.09.17.32 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 22 Nov 2013 09:17:32 -0800 (PST) Received-SPF: neutral (google.com: 2001:8b0:1d0::1 is neither permitted nor denied by best guess record for domain of pm215@archaic.org.uk) client-ip=2001:8b0:1d0::1; Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.80) (envelope-from ) id 1VjuM3-0002jI-23; Fri, 22 Nov 2013 17:17:19 +0000 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, kvmarm@lists.cs.columbia.edu Subject: [PATCH v9 06/11] target-arm: Allow secondary KVM CPUs to be booted via PSCI Date: Fri, 22 Nov 2013 17:17:13 +0000 Message-Id: <1385140638-10444-7-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1385140638-10444-1-git-send-email-peter.maydell@linaro.org> References: <1385140638-10444-1-git-send-email-peter.maydell@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: peter.maydell@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.180 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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: Peter Maydell --- target-arm/cpu-qom.h | 3 +++ target-arm/cpu.c | 7 +++++++ target-arm/kvm.c | 3 +++ 3 files changed, 13 insertions(+) diff --git a/target-arm/cpu-qom.h b/target-arm/cpu-qom.h index cbb9eec..8bd3e36 100644 --- a/target-arm/cpu-qom.h +++ b/target-arm/cpu-qom.h @@ -94,6 +94,9 @@ typedef struct ARMCPU { /* 'compatible' string for this CPU for Linux device trees */ const char *dtb_compatible; + /* Should CPU start in PSCI powered-off state? */ + bool start_powered_off; + /* The instance init functions for implementation-specific subclasses * set these fields to specify the implementation-dependent values of * various constant registers and reset values of non-constant diff --git a/target-arm/cpu.c b/target-arm/cpu.c index 4c8d9c7..0325815 100644 --- a/target-arm/cpu.c +++ b/target-arm/cpu.c @@ -20,6 +20,7 @@ #include "cpu.h" #include "qemu-common.h" +#include "hw/qdev-properties.h" #if !defined(CONFIG_USER_ONLY) #include "hw/loader.h" #endif @@ -944,6 +945,11 @@ static const ARMCPUInfo arm_cpus[] = { #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) { ARMCPUClass *acc = ARM_CPU_CLASS(oc); @@ -952,6 +958,7 @@ static void arm_cpu_class_init(ObjectClass *oc, void *data) acc->parent_realize = dc->realize; dc->realize = arm_cpu_realizefn; + dc->props = arm_cpu_properties; acc->parent_reset = cc->reset; cc->reset = arm_cpu_reset; diff --git a/target-arm/kvm.c b/target-arm/kvm.c index 3098456..80c58c5 100644 --- a/target-arm/kvm.c +++ b/target-arm/kvm.c @@ -79,6 +79,9 @@ int kvm_arch_init_vcpu(CPUState *cs) init.target = KVM_ARM_TARGET_CORTEX_A15; 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); if (ret) { return ret;