From patchwork Fri Mar 9 09:07:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Shi X-Patchwork-Id: 10270159 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B529F602BD for ; Fri, 9 Mar 2018 09:18:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B489D29D99 for ; Fri, 9 Mar 2018 09:18:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A955F29D9D; Fri, 9 Mar 2018 09:18:14 +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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID 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 25B3E29D99 for ; Fri, 9 Mar 2018 09:18:14 +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:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: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=GbIfZeSa84m7lk5q6UEweUi75639v+SFOr+SX1W1wp8=; b=Ks8wqT+eKen2AZbEbZtitdU9iE sbWg/AxNV50cqock3TqZcdSWhZkV9UfsVhzORTPg2ckeHJ+1ws/0jL8CtTSdxG+muxf6wk+3T3lBs RJ2wZy0tiwxxeHF5Juv1TAMbkFcoZGm9qibvo56LWfnw6I7FPlauNyXsHyDbpvK080Nv8qgIVMOo3 o687U+DQ0+ilAqDS0698GRWWC01+DFTik53QHhhqSjSTsAyUVfL8WKXBb9N9NAdyuiD8H8ZYj3uVJ wQ+xleY8SEcZGjFtNSsMr/DQLPO5v1kk+Q1+xpURDDUMFmvM8CDdeSCyQ2Z16dZejAoi6G8Cu0py/ C6b6a09g==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1euEAA-00034s-NZ; Fri, 09 Mar 2018 09:18:06 +0000 Received: from mail-pg0-x244.google.com ([2607:f8b0:400e:c05::244]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1euE3H-0005pE-31 for linux-arm-kernel@lists.infradead.org; Fri, 09 Mar 2018 09:12:28 +0000 Received: by mail-pg0-x244.google.com with SMTP id s13so422566pgn.12 for ; Fri, 09 Mar 2018 01:10:48 -0800 (PST) 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; bh=V1RePzY+LGZljFUK8ArfEqRd0jmbv4vUuHlnNrPizP0=; b=PriyG1G3qOo4J91ULG07TP2qD02MOR2qN2TtYHQ/S6vyU2hP8WGzdY3H39me9Gfmqh 0Y01YZCFPzEJgJjH30qZnf8Q/UplJ26pbEkxvahdE9vVaouxVEIkLEA4cJO4otdu1hAT 2EbowlEzGWELcUZW7buyj6QPkE50XSiPcHHWc= 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; bh=V1RePzY+LGZljFUK8ArfEqRd0jmbv4vUuHlnNrPizP0=; b=F+mdcXzky+Qw8pXTUHvlXpBXYeWNJvZuM7JIMOHBXknr2QkyxR7Gohl5UAJUx/TTxs DHUorq1a2wZQP1E1zJ25ZzUgKln07eiFOX+mW2BnVJFlZBt66/Lcfq2E955PhDXnHIrh yAihjTtlM653g/tf2fkNbIZLoWVvsvcbU8lnNntsyu5gQZaZ2Beti267qygimP09r41q yTxII/eGxlnGTuRFGgKvDd0QAbyjachWQ9yTz2ShlKmYm4gr5mSIJUE0TYK5Hc/OMc0t kTfUkmodyfgSC23Ieh5NPf9qpC7A8LDyoWjtUunDrOzOVuF0qXHrmBbKtLMUZyGcqa2u etBA== X-Gm-Message-State: AElRT7HYNmu1a8hV2ovwPGcRaUD6WhgyzrAoSaxKO94qA9ndXdJUThBp ZTVlzZvq1At6IKufzBtJqNLdVA== X-Google-Smtp-Source: AG47ELtQBpu3tPrhpanVveW4kTXsMST8Xkn3fG4hhkEdOBx7H8neEp3b1xCip0fFey4wCGjlyirogw== X-Received: by 10.99.149.15 with SMTP id p15mr1040618pgd.154.1520586648341; Fri, 09 Mar 2018 01:10:48 -0800 (PST) Received: from localhost.localdomain (176.122.172.82.16clouds.com. [176.122.172.82]) by smtp.gmail.com with ESMTPSA id c7sm1961752pfg.36.2018.03.09.01.10.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 09 Mar 2018 01:10:47 -0800 (PST) From: Alex Shi To: Marc Zyngier , Will Deacon , Ard Biesheuvel , Catalin Marinas , broonie@linaro.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 24/39] arm/arm64: KVM: Add PSCI_VERSION helper Date: Fri, 9 Mar 2018 17:07:07 +0800 Message-Id: <20180309090722.26279-25-alex.shi@linaro.org> X-Mailer: git-send-email 2.16.2.440.gc6284da In-Reply-To: <20180309090722.26279-1-alex.shi@linaro.org> References: <20180309090722.26279-1-alex.shi@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180309_011059_837599_264A7BE3 X-CRM114-Status: GOOD ( 14.52 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alex Shi MIME-Version: 1.0 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: Marc Zyngier commit d0a144f12a7c upstream. As we're about to trigger a PSCI version explosion, it doesn't hurt to introduce a PSCI_VERSION helper that is going to be used everywhere. Reviewed-by: Christoffer Dall Tested-by: Ard Biesheuvel Signed-off-by: Marc Zyngier Signed-off-by: Catalin Marinas Signed-off-by: Will Deacon Signed-off-by: Alex Shi --- arch/arm/kvm/psci.c | 2 +- include/kvm/arm_psci.h | 6 ++++-- include/uapi/linux/psci.h | 3 +++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/arch/arm/kvm/psci.c b/arch/arm/kvm/psci.c index 237ff1e392f8..85fc21b43f6f 100644 --- a/arch/arm/kvm/psci.c +++ b/arch/arm/kvm/psci.c @@ -219,7 +219,7 @@ static int kvm_psci_0_2_call(struct kvm_vcpu *vcpu) * Bits[31:16] = Major Version = 0 * Bits[15:0] = Minor Version = 2 */ - val = 2; + val = KVM_ARM_PSCI_0_2; break; case PSCI_0_2_FN_CPU_SUSPEND: case PSCI_0_2_FN64_CPU_SUSPEND: diff --git a/include/kvm/arm_psci.h b/include/kvm/arm_psci.h index 2042bb909474..5659343580a3 100644 --- a/include/kvm/arm_psci.h +++ b/include/kvm/arm_psci.h @@ -18,8 +18,10 @@ #ifndef __KVM_ARM_PSCI_H__ #define __KVM_ARM_PSCI_H__ -#define KVM_ARM_PSCI_0_1 1 -#define KVM_ARM_PSCI_0_2 2 +#include + +#define KVM_ARM_PSCI_0_1 PSCI_VERSION(0, 1) +#define KVM_ARM_PSCI_0_2 PSCI_VERSION(0, 2) int kvm_psci_version(struct kvm_vcpu *vcpu); int kvm_psci_call(struct kvm_vcpu *vcpu); diff --git a/include/uapi/linux/psci.h b/include/uapi/linux/psci.h index 3d7a0fc021a7..39930ca998cd 100644 --- a/include/uapi/linux/psci.h +++ b/include/uapi/linux/psci.h @@ -87,6 +87,9 @@ (((ver) & PSCI_VERSION_MAJOR_MASK) >> PSCI_VERSION_MAJOR_SHIFT) #define PSCI_VERSION_MINOR(ver) \ ((ver) & PSCI_VERSION_MINOR_MASK) +#define PSCI_VERSION(maj, min) \ + ((((maj) << PSCI_VERSION_MAJOR_SHIFT) & PSCI_VERSION_MAJOR_MASK) | \ + ((min) & PSCI_VERSION_MINOR_MASK)) /* PSCI features decoding (>=1.0) */ #define PSCI_1_0_FEATURES_CPU_SUSPEND_PF_SHIFT 1