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: 166774 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp1506309ilk; Thu, 13 Jun 2019 20:13:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqxPbsxH0otkJFmedGMHJCj2smV7NH6WQdcSDQr0VmDojXnoCuFRy3TkasAdMazkY8yj2QQW X-Received: by 2002:a17:902:70cb:: with SMTP id l11mr30091687plt.343.1560482010319; Thu, 13 Jun 2019 20:13:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560482010; cv=none; d=google.com; s=arc-20160816; b=HDrsH6WbsHdlpStZv8pwPkgViVlxUUK57ZyTkN9/gURst1NkPQuRHNbUtq0eMug2jM 4nneUYi9ArsYJpLfXO+mUc3rnzmdBoIwTXOIWgiaSuA65DFc2obLmwcvVFND42A0IHy+ ivAHKtQS0xoAm9rK01Dzzgjwzv6+bal4ccj92zcFjxlNc/XFncEHzX1YhDOu0yUIszNf UNDw7PEg8yigOhYWXIUUGb7sMCguswpyi4LHFWu4+tCtXWW8b6X8K20KRpL/e0cazMMd 8qyoB5pdAsVOlnVFE+L4FY4qtkQCBIbmzBaE6G6MP15LPHxgyehubFo3yS/eZ0hdPG2+ 78WA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ciH+Cy/cnjaV+iKRh72NhJx15MiI+P9rVJovcPRWoV0=; b=jXUnWDJ+jz+MkCTgt99L/9pNa0N+JHPNEZPw8z2NfW9Wu9tYvDldOonWjwu9qDhTXa cnAEkjr0ZqSvUb5rcrjUP4qjOs/a6O17r50P8aHAUxmZUgTI/kS/9BQ0ShYCg1xqmZvX VXIZ4E30OCGEmObFyAdxtcHY3qk2JAnuS6Y4Jv3ZVYMBqYMpaqIsNznx6XtfkljgWHJ+ MxvsU1jXWRsDRLTi38Ti20ElF2yoWofZ0GkVczgUXcHdTfIg5ftF/D6TnqLUEmNa6xAo RPC6nv1uYpCC/8tGtW1jqRAnHw2DRNTMVl6qxvZhS1CEGTr2Kl+RrdfYPN22ELxMsTCY ZR6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zCj6UOkk; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e8si1073936plb.420.2019.06.13.20.13.30; Thu, 13 Jun 2019 20:13:30 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zCj6UOkk; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726734AbfFNDN3 (ORCPT + 14 others); Thu, 13 Jun 2019 23:13:29 -0400 Received: from mail-pl1-f193.google.com ([209.85.214.193]:46323 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726705AbfFNDN3 (ORCPT ); Thu, 13 Jun 2019 23:13:29 -0400 Received: by mail-pl1-f193.google.com with SMTP id e5so362564pls.13 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=Ri+9snRT55L6U8567aR0qGNdTkuF3ZY6GiyXmduADv5aJNm+RNBIFRjglMxAhwBt+r aaCzplnfpDYdU9BoM4/zpL0NDwAO99EhJGJAOyz0tQmP+j23dwxLWlxqxQOJhWyDdIKy IRfa2qdr2z6nhyegr06+oE8KgpF4k53cO7CrATlm/ow4Hy7XQ2FSwOeuIprxo+PSSmxj Hzddwt1V1VekMpGa//o/fWpXYg42NoHwvFDxnlxOkCUh/EOXII1xctv3F9nJedlykiuB AgjQluBuVUfXJP9jXij44XSltyFQLMBDFJhsmtZ/7RnuPN0gRc18OOryhDnZMQyAkqtb nvqA== X-Gm-Message-State: APjAAAWkfnoAA/D9CWf6XkNUIxQ5VSP34/1GgLo95cNnLkW7u/UdfvyP bfjkPpXUqFtfXR5MMv91ErHYxw== 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 Cc: Viresh Kumar , stable@vger.kernel.org, Catalin Marinas , Marc Zyngier , Mark Rutland , Will Deacon , Russell King , Vincent Guittot , mark.brown@arm.com 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 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org 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(-) -- 2.21.0.rc0.269.g1a574e7a288b 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__ */