From patchwork Fri Jan 11 20:51:39 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 1967451 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork1.kernel.org (Postfix) with ESMTP id 702FB40232 for ; Fri, 11 Jan 2013 20:55:11 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TtlZz-0004Pq-Hk; Fri, 11 Jan 2013 20:51:55 +0000 Received: from mail-vb0-f52.google.com ([209.85.212.52]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1TtlZs-0004PX-Kc for linux-arm-kernel@lists.infradead.org; Fri, 11 Jan 2013 20:51:49 +0000 Received: by mail-vb0-f52.google.com with SMTP id ez10so1868761vbb.11 for ; Fri, 11 Jan 2013 12:51:46 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer :x-gm-message-state; bh=WWzmfxLAH+x7+48ZsucbpCHBkKb50sFm7WuYAJwkkHw=; b=mhRVANQoaPVNUt1+jnZE1sA5x3EGY+CO6sWL/i3TtVJjAELbatkY2s+A/+AqK/PvB0 ELsbBvoOOqAlYPnOzfp6N50DXSgd1myNIwkBC7RTgztcznmbJFfvcaznmwZV62VXXU8p OgW4jjedVMyGQ1Q6njVbvDVOwUYCvp31SvWOhH3piO7PZ1SBi9oLxtJ/ealq/wj70jfV yfLmmS4iI7R0XxwZorYNnJidyC/ALJ9yuudlVS93rYNmP6IoCCNEMPA0B3r1W3e3GNW5 Dev+/Lt/pLyc/qiq4lxZYALf6n+eOpbBYOXOu9mDcpb+o7eIiEiG/eWPMQrlJhUQgoly PRhQ== X-Received: by 10.52.174.71 with SMTP id bq7mr83602302vdc.49.1357937506823; Fri, 11 Jan 2013 12:51:46 -0800 (PST) Received: from localhost.localdomain (pool-72-80-83-148.nycmny.fios.verizon.net. [72.80.83.148]) by mx.google.com with ESMTPS id bm2sm2671766vdc.6.2013.01.11.12.51.45 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 11 Jan 2013 12:51:46 -0800 (PST) From: Christoffer Dall To: kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org Subject: [PATCH] KVM: ARM: Change psci_call return value to bool Date: Fri, 11 Jan 2013 15:51:39 -0500 Message-Id: <1357937499-3946-1-git-send-email-c.dall@virtualopensystems.com> X-Mailer: git-send-email 1.7.9.5 X-Gm-Message-State: ALoCoQn/WIxjB4jveHxYB4txGxifcM1LQXI2BVMl7ItLzNvoKVCQHcaIK201gZrS+Pooz3/I3Q5A X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130111_155148_781459_5C37A318 X-CRM114-Status: GOOD ( 14.78 ) X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.212.52 listed in list.dnswl.org] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Marc Zyngier , Christoffer Dall , Russell King X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org To avoid either using -1 or -EINVAL in return from kvm_psci_call change the function to return a bool like the coprocessor handling functions do. Also clearly document this on on the function. Cc: Marc Zyngier Cc: Russell King Signed-off-by: Christoffer Dall --- arch/arm/include/asm/kvm_psci.h | 2 +- arch/arm/kvm/arm.c | 2 +- arch/arm/kvm/psci.c | 21 ++++++++++++++++++--- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/arch/arm/include/asm/kvm_psci.h b/arch/arm/include/asm/kvm_psci.h index 992d7f1..9a83d98 100644 --- a/arch/arm/include/asm/kvm_psci.h +++ b/arch/arm/include/asm/kvm_psci.h @@ -18,6 +18,6 @@ #ifndef __ARM_KVM_PSCI_H__ #define __ARM_KVM_PSCI_H__ -int kvm_psci_call(struct kvm_vcpu *vcpu); +bool kvm_psci_call(struct kvm_vcpu *vcpu); #endif /* __ARM_KVM_PSCI_H__ */ diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c index 4d5ed244..d3f1877 100644 --- a/arch/arm/kvm/arm.c +++ b/arch/arm/kvm/arm.c @@ -498,7 +498,7 @@ static int handle_svc_hyp(struct kvm_vcpu *vcpu, struct kvm_run *run) static int handle_hvc(struct kvm_vcpu *vcpu, struct kvm_run *run) { - if (!kvm_psci_call(vcpu)) + if (kvm_psci_call(vcpu)) return 1; kvm_inject_undefined(vcpu); diff --git a/arch/arm/kvm/psci.c b/arch/arm/kvm/psci.c index 4a1c4f0..6be3687 100644 --- a/arch/arm/kvm/psci.c +++ b/arch/arm/kvm/psci.c @@ -21,6 +21,11 @@ #include #include +/* + * This is an implementation of the Power State Coordination Interface + * as described in ARM document number ARM DEN 0022A. + */ + static void kvm_psci_vcpu_off(struct kvm_vcpu *vcpu) { wait_queue_head_t *wq = kvm_arch_vcpu_wq(vcpu); @@ -63,7 +68,17 @@ static unsigned long kvm_psci_vcpu_on(struct kvm_vcpu *source_vcpu) return KVM_PSCI_RET_SUCCESS; } -int kvm_psci_call(struct kvm_vcpu *vcpu) +/** + * kvm_psci_call - handle PSCI call if r0 value is in range + * @vcpu: Pointer to the VCPU struct + * + * Handle PSCI calls from guests through traps from HVC or SMC instructions. + * The calling convention is similar to SMC calls to the secure world where + * the function number is placed in r0 and this function returns true if the + * function number specified in r0 is withing the PSCI range, and false + * otherwise. + */ +bool kvm_psci_call(struct kvm_vcpu *vcpu) { unsigned long psci_fn = *vcpu_reg(vcpu, 0) & ~((u32) 0); unsigned long val; @@ -82,9 +97,9 @@ int kvm_psci_call(struct kvm_vcpu *vcpu) break; default: - return -1; + return false; } *vcpu_reg(vcpu, 0) = val; - return 0; + return true; }