From patchwork Fri Jun 14 03:08:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 10994217 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BE3A7924 for ; Fri, 14 Jun 2019 03:25:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AF55F2018E for ; Fri, 14 Jun 2019 03:25:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A33A227D4A; Fri, 14 Jun 2019 03:25:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1699C2018E for ; Fri, 14 Jun 2019 03:25:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=vHKotN0CPymWxY5msQJ3hRzTffzqtDxB/Sf71N33jLc=; b=K7roMVuVdhQxtC P5n++/tMynOFdASQBxJbyH1kGZksXzn1ScUyvNPi9he11oFrYrLYm4oW1xQuDbNdnFypUNpMJ3SGS syipxKzX/i4f5/x+4GAGuCSw9h4w2HecpcewVcTu/LRukB+VHK+7azishoThRCx4PX1/bWzU2ku2D wpfNWeGclgnSH+KCTFA608ubYH8/du9HwtAMKjSIm+50QUi4xTtezUGdQpQEPNuO2IGGrTVZWq9rz uIS7Xgz05GsKkn4Cf8fVVmCj8BeAGJI/z8hgtOF+KL3gKt6q0zCdPaysNS1rMDQBkFnYnVnYdIvx1 nYFaAL0Ng68mQIzP5mrg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hbcpu-0004qf-Un; Fri, 14 Jun 2019 03:25:06 +0000 Received: from mail-pl1-x644.google.com ([2607:f8b0:4864:20::644]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hbceg-00010T-2l for linux-arm-kernel@lists.infradead.org; Fri, 14 Jun 2019 03:13:32 +0000 Received: by mail-pl1-x644.google.com with SMTP id bh12so378443plb.4 for ; Thu, 13 Jun 2019 20:13:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ciH+Cy/cnjaV+iKRh72NhJx15MiI+P9rVJovcPRWoV0=; b=zCj6UOkk9rYxjGZ76Celb+F4P6OxrLaT+sclkYVehSDNSu0d3hzajx04mK0DZZfSEQ vDvFo25Jg/ib3RMKhnrEqeIxgYSGrX2tKBBxSJNNc9SOelWDPYolRRdEBqvLnhUACalH 11zfuSBeyOZyNrXcL3xld8rwkwpKoT6a2T6EmzQVJl+EwwwOxYfhPdZ4fmL2CZ3Esq4s sr1vf56kZhY7Rp1oXoB39fzJ/m0MdsABjb3Q+rlB5RXEKVJuv+ELEZnSmXPtr96D2lgI qflaeiBy5vRwtZhLlfqThBj3abiDuudnqZ5WLGRPoDpWYiMlTytnrqxuB1FQrL0LFBRw UvZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ciH+Cy/cnjaV+iKRh72NhJx15MiI+P9rVJovcPRWoV0=; b=bt/u+wRJ8ESEp4lMjm+FAgEY0vBnybTYdC+GwVrJgzzgoRklX0iqf0yhVzjFstesqn yJZXkTmRV7VTc2CZecQ2X0HSLbsM3ahIxjNn+jvgPUslXZ+UtXQ60Q0pGl1RPsB8JcqX 0EqwlRuUQt6KOX/wsgYbLxEBadjYhToE+pRDlumK/dbRD5mfzjyeRwqqsKi8d/FG2SOG EwUBRTEg2sH6kvNnDF8MBwL6Tu9QQ56pIIpzr2scBmA96YcpCIBLeq2+c27Ez4lQNrqW QHbExADUv3bBhIrrJBItN6vZMZP/c04MA6ilHhOd2A50Ltat5pOd99MGfqt1ctliBBdS ZOsg== X-Gm-Message-State: APjAAAVh5T+GjhCjwS9mxpk8vvqYOznIu3qkDRaOJphhalhmQhXFUPfw Es0AWPR08+adbNvvq2zoF2zzsUU6sy0= X-Google-Smtp-Source: APXvYqzdSrwX7zpx4mVVNZDCkgcqlYmaMymBCeJxs0WBFABZ+RRjkEeu1ROtPUwmdF1tTRVtN5gq8g== X-Received: by 2002:a17:902:54d:: with SMTP id 71mr88735600plf.140.1560482008787; Thu, 13 Jun 2019 20:13:28 -0700 (PDT) Received: from localhost ([122.172.66.84]) by smtp.gmail.com with ESMTPSA id n7sm1105325pff.59.2019.06.13.20.13.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jun 2019 20:13:28 -0700 (PDT) From: Viresh Kumar To: linux-arm-kernel@lists.infradead.org, Julien Thierry Subject: [PATCH v4.4 36/45] arm/arm64: KVM: Turn kvm_psci_version into a static inline Date: Fri, 14 Jun 2019 08:38:19 +0530 Message-Id: <2ea4ac93fe2fdb5faad8e80347747673cb89d93e.1560480942.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.21.0.rc0.269.g1a574e7a288b In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190613_201330_219066_5D96663C X-CRM114-Status: GOOD ( 15.62 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Marc Zyngier , Viresh Kumar , Will Deacon , stable@vger.kernel.org, mark.brown@arm.com, Catalin Marinas , Russell King Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Mark Rutland commit a4097b351118e821841941a79ec77d3ce3f1c5d9 upstream. We're about to need kvm_psci_version in HYP too. So let's turn it into a static inline, and pass the kvm structure as a second parameter (so that HYP can do a kern_hyp_va on it). Tested-by: Ard Biesheuvel Reviewed-by: Christoffer Dall Signed-off-by: Marc Zyngier Signed-off-by: Catalin Marinas [ v4.4: account for files moved to virt/ upstream and drop switch.c changes ] Signed-off-by: Viresh Kumar --- arch/arm/kvm/psci.c | 12 ++---------- include/kvm/arm_psci.h | 21 ++++++++++++++++++++- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/arch/arm/kvm/psci.c b/arch/arm/kvm/psci.c index 76821adf4fde..9abf40734723 100644 --- a/arch/arm/kvm/psci.c +++ b/arch/arm/kvm/psci.c @@ -120,7 +120,7 @@ static unsigned long kvm_psci_vcpu_on(struct kvm_vcpu *source_vcpu) if (!vcpu) return PSCI_RET_INVALID_PARAMS; if (!vcpu->arch.power_off) { - if (kvm_psci_version(source_vcpu) != KVM_ARM_PSCI_0_1) + if (kvm_psci_version(source_vcpu, kvm) != KVM_ARM_PSCI_0_1) return PSCI_RET_ALREADY_ON; else return PSCI_RET_INVALID_PARAMS; @@ -230,14 +230,6 @@ static void kvm_psci_system_reset(struct kvm_vcpu *vcpu) kvm_prepare_system_event(vcpu, KVM_SYSTEM_EVENT_RESET); } -int kvm_psci_version(struct kvm_vcpu *vcpu) -{ - if (test_bit(KVM_ARM_VCPU_PSCI_0_2, vcpu->arch.features)) - return KVM_ARM_PSCI_LATEST; - - return KVM_ARM_PSCI_0_1; -} - static int kvm_psci_0_2_call(struct kvm_vcpu *vcpu) { struct kvm *kvm = vcpu->kvm; @@ -395,7 +387,7 @@ static int kvm_psci_0_1_call(struct kvm_vcpu *vcpu) */ static int kvm_psci_call(struct kvm_vcpu *vcpu) { - switch (kvm_psci_version(vcpu)) { + switch (kvm_psci_version(vcpu, vcpu->kvm)) { case KVM_ARM_PSCI_1_0: return kvm_psci_1_0_call(vcpu); case KVM_ARM_PSCI_0_2: diff --git a/include/kvm/arm_psci.h b/include/kvm/arm_psci.h index ed1dd8088f1c..e518e4e3dfb5 100644 --- a/include/kvm/arm_psci.h +++ b/include/kvm/arm_psci.h @@ -18,6 +18,7 @@ #ifndef __KVM_ARM_PSCI_H__ #define __KVM_ARM_PSCI_H__ +#include #include #define KVM_ARM_PSCI_0_1 PSCI_VERSION(0, 1) @@ -26,7 +27,25 @@ #define KVM_ARM_PSCI_LATEST KVM_ARM_PSCI_1_0 -int kvm_psci_version(struct kvm_vcpu *vcpu); +/* + * We need the KVM pointer independently from the vcpu as we can call + * this from HYP, and need to apply kern_hyp_va on it... + */ +static inline int kvm_psci_version(struct kvm_vcpu *vcpu, struct kvm *kvm) +{ + /* + * Our PSCI implementation stays the same across versions from + * v0.2 onward, only adding the few mandatory functions (such + * as FEATURES with 1.0) that are required by newer + * revisions. It is thus safe to return the latest. + */ + if (test_bit(KVM_ARM_VCPU_PSCI_0_2, vcpu->arch.features)) + return KVM_ARM_PSCI_LATEST; + + return KVM_ARM_PSCI_0_1; +} + + int kvm_hvc_call_handler(struct kvm_vcpu *vcpu); #endif /* __KVM_ARM_PSCI_H__ */