From patchwork Fri Jun 14 03:08:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 166772 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp1506268ilk; Thu, 13 Jun 2019 20:13:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqwPF+s7wri7atdQU/iHgh33YQ6L7L+LfKjD8J82e1Kj20Ui4RBYbYgUCOdAOBcyTnhg0pOf X-Received: by 2002:a17:902:760a:: with SMTP id k10mr70788313pll.83.1560482005555; Thu, 13 Jun 2019 20:13:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560482005; cv=none; d=google.com; s=arc-20160816; b=pxHPTEwlXWlX74Oj2FoH4BW0/C6hmkOhnkNYgsvGjwrOBMqXJuaeI73oWLhRMGtMe/ hv5CwAF5Z3/lmmX7ONFM/2CJfSKG9UupsfaahiuIwKexo91xmwmY8hnStSPf0mHY6kPA 3g8uxLhL0a6Mm/xTz1e/vJkrKogZZxv11prd4a1z9yJ8MyMH/vhXxWfa+P4JX6j9Mfyw Q/yf9Fyf5WQvppncwlYoEOmpfu+N+ViO7qXUfaOVnKh92s3LFUBK9dJcZvcrIj0BjWi6 Has84OE5dcgiw59S3ijwecCMg1osM4GbNMozP62fy7vpcs7a5ym0HiEAIly9dMKgmaX8 hUsw== 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=4cjUvWF1fG1uJf64DV9LIZ2qblEK4Qh4cwDlO2OXHlc=; b=ZM6vw3Hv1kVihAYUx9RzkNcAbcjkzEMNtJD2/4ikyZ4FcDkLHGrxHuHK1Vb6Mia/HH izg9gz2x2FZBOkxmOoQa9o6FX2dwkGWLt5rPdI3m+57iTXE+f5C69ExUR952yWDdSOgb rWXAzQRk9O21PM04pmUWJsJLknFD9FR1axSVgx9cGYITWoLwCHnA98jgHYlQw6ccsAnV FbKngKGOZCS5L7t6ZkAwKHXd23O6QEu7OQYpxrNmCnMwbWEEak+atBUGirS1tmMyuSib wAk/aruIPiKt5LIswsnGzoX0wR+NYPbn0AU2fQLkG+zSi8epkXAS9F9bfEJmkxcxqhxx 2t8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=sFWQWr9W; 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.25; Thu, 13 Jun 2019 20:13:25 -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=sFWQWr9W; 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 S1726707AbfFNDNZ (ORCPT + 14 others); Thu, 13 Jun 2019 23:13:25 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:34885 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725819AbfFNDNY (ORCPT ); Thu, 13 Jun 2019 23:13:24 -0400 Received: by mail-pf1-f195.google.com with SMTP id d126so503961pfd.2 for ; Thu, 13 Jun 2019 20:13:24 -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=4cjUvWF1fG1uJf64DV9LIZ2qblEK4Qh4cwDlO2OXHlc=; b=sFWQWr9WQVIoODnq13osUci8fXXwEGt2JIkyrqUTrbBm4bd7VB/u8y0UxppVd+BeiR UtJXoGi1ehpyDUqs0e+ubar9YWT057q4MMJ/bKxw+xgLk1CyMMDO7hhq1T1pBX5UmLjs B5rQdnQ1JEvgyyBHk/Gy2qptGPg2I94HqYxOjVeSouPZN5f/0YJc8VbqPpFuDDEwW3Lt aQBgpKRwEs98T1ALDuHy0H2ZWiKHpgj0p91BRIyGEptiEu7RGwz9vWTkk6cvMhx/7lzq lBYMXv4P2NwEPJa9GKD61+FgGjo/iIZK/QRSGYBghxS5ZCiizlV5quX9rJ+mM5Fkq6M+ e5Ww== 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=4cjUvWF1fG1uJf64DV9LIZ2qblEK4Qh4cwDlO2OXHlc=; b=ZJrDPzYSB+izyqsOUlKSqeh6AFSI/6IT7BTbEDlDo73GW+fOkHulzHZCcyyW9ydfCq IUJhGenpfVqqVxgwMIYuRT9U0c862mMoLJi2X8ywpWklbtdY1vG4XRKHaPEAm7H+K3Bw q9fH4dzXlKOuqw3YGh/LwsfsrdmpFL0FuRP6adbsPCLjPV2k4MhVetV8PLYTYLvadZNU zT8VoThUavVPu3dAr3hmYzpldvLU5Qap+7n0tToBtoC7rBX/UpAd4oUBeAuve1MieUxJ ZVUSNFKWpzPpd8CLimNn3MDVOySw+rMhSFUFrlo+zN9N25OMEvy7x0VjTvPjg8hg0vTI WxOQ== X-Gm-Message-State: APjAAAVKTVvK07rpkJxZGlkHCaXzsn/4pUA9N902G0TFNL1woBJ/Pmx0 3knUlEC6VKQGIF+OuImREdGgFg== X-Received: by 2002:a63:f146:: with SMTP id o6mr32948616pgk.179.1560482003778; Thu, 13 Jun 2019 20:13:23 -0700 (PDT) Received: from localhost ([122.172.66.84]) by smtp.gmail.com with ESMTPSA id m2sm1083791pgq.48.2019.06.13.20.13.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jun 2019 20:13:23 -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 34/45] arm/arm64: KVM: Implement PSCI 1.0 support Date: Fri, 14 Jun 2019 08:38:17 +0530 Message-Id: <673b7f2b7b85c228bf5136a273da7fc97d43c4d8.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: Marc Zyngier commit 58e0b2239a4d997094ba63986ef4de29ddc91d87 upstream. PSCI 1.0 can be trivially implemented by providing the FEATURES call on top of PSCI 0.2 and returning 1.0 as the PSCI version. We happily ignore everything else, as they are either optional or are clarifications that do not require any additional change. PSCI 1.0 is now the default until we decide to add a userspace selection API. Reviewed-by: Christoffer Dall Tested-by: Ard Biesheuvel Signed-off-by: Marc Zyngier Signed-off-by: Catalin Marinas [ v4.4: account for files moved to virt/ upstream ] Signed-off-by: Viresh Kumar --- arch/arm/kvm/psci.c | 45 +++++++++++++++++++++++++++++++++++++++++- include/kvm/arm_psci.h | 3 +++ 2 files changed, 47 insertions(+), 1 deletion(-) -- 2.21.0.rc0.269.g1a574e7a288b diff --git a/arch/arm/kvm/psci.c b/arch/arm/kvm/psci.c index 7ef6cdd22163..23428a3ac69b 100644 --- a/arch/arm/kvm/psci.c +++ b/arch/arm/kvm/psci.c @@ -232,7 +232,7 @@ static void kvm_psci_system_reset(struct kvm_vcpu *vcpu) int kvm_psci_version(struct kvm_vcpu *vcpu) { if (test_bit(KVM_ARM_VCPU_PSCI_0_2, vcpu->arch.features)) - return KVM_ARM_PSCI_0_2; + return KVM_ARM_PSCI_LATEST; return KVM_ARM_PSCI_0_1; } @@ -311,6 +311,47 @@ static int kvm_psci_0_2_call(struct kvm_vcpu *vcpu) return ret; } +static int kvm_psci_1_0_call(struct kvm_vcpu *vcpu) +{ + u32 psci_fn = smccc_get_function(vcpu); + u32 feature; + unsigned long val; + int ret = 1; + + switch(psci_fn) { + case PSCI_0_2_FN_PSCI_VERSION: + val = KVM_ARM_PSCI_1_0; + break; + case PSCI_1_0_FN_PSCI_FEATURES: + feature = smccc_get_arg1(vcpu); + switch(feature) { + case PSCI_0_2_FN_PSCI_VERSION: + case PSCI_0_2_FN_CPU_SUSPEND: + case PSCI_0_2_FN64_CPU_SUSPEND: + case PSCI_0_2_FN_CPU_OFF: + case PSCI_0_2_FN_CPU_ON: + case PSCI_0_2_FN64_CPU_ON: + case PSCI_0_2_FN_AFFINITY_INFO: + case PSCI_0_2_FN64_AFFINITY_INFO: + case PSCI_0_2_FN_MIGRATE_INFO_TYPE: + case PSCI_0_2_FN_SYSTEM_OFF: + case PSCI_0_2_FN_SYSTEM_RESET: + case PSCI_1_0_FN_PSCI_FEATURES: + val = 0; + break; + default: + val = PSCI_RET_NOT_SUPPORTED; + break; + } + break; + default: + return kvm_psci_0_2_call(vcpu); + } + + smccc_set_retval(vcpu, val, 0, 0, 0); + return ret; +} + static int kvm_psci_0_1_call(struct kvm_vcpu *vcpu) { struct kvm *kvm = vcpu->kvm; @@ -353,6 +394,8 @@ static int kvm_psci_0_1_call(struct kvm_vcpu *vcpu) int kvm_psci_call(struct kvm_vcpu *vcpu) { switch (kvm_psci_version(vcpu)) { + case KVM_ARM_PSCI_1_0: + return kvm_psci_1_0_call(vcpu); case KVM_ARM_PSCI_0_2: return kvm_psci_0_2_call(vcpu); case KVM_ARM_PSCI_0_1: diff --git a/include/kvm/arm_psci.h b/include/kvm/arm_psci.h index 5659343580a3..32360432cff5 100644 --- a/include/kvm/arm_psci.h +++ b/include/kvm/arm_psci.h @@ -22,6 +22,9 @@ #define KVM_ARM_PSCI_0_1 PSCI_VERSION(0, 1) #define KVM_ARM_PSCI_0_2 PSCI_VERSION(0, 2) +#define KVM_ARM_PSCI_1_0 PSCI_VERSION(1, 0) + +#define KVM_ARM_PSCI_LATEST KVM_ARM_PSCI_1_0 int kvm_psci_version(struct kvm_vcpu *vcpu); int kvm_psci_call(struct kvm_vcpu *vcpu);