Received: by 10.223.176.5 with SMTP id f5csp3622869wra; Mon, 29 Jan 2018 16:25:18 -0800 (PST) X-Google-Smtp-Source: AH8x227cFWiiehA86c8K+nX5ISOYV+v23YGK+X5wtH0myynn44X/Ct4ndnNtzlvpz8+Oxb54jcEV X-Received: by 10.98.5.129 with SMTP id 123mr28720429pff.75.1517271918083; Mon, 29 Jan 2018 16:25:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517271918; cv=none; d=google.com; s=arc-20160816; b=sXRmgGSlt//BsQPtgIYyRKfEDk1vn9A+jTe3LcSs8xBnmX+1RTU6rhPfRVDVk12vMC anE0kxHgCjhQiA1xHnTL4i19ryauvY+CPUX4116xC0gxQ/7b32grZH0EjGqiOGfU3onQ zHBajEjBSKCB92FunkOYMCf1l2/5yaij895tM8Wlh7VM0ypumQbL/J2KNg6GfXwN4zXD gMW7myv2wXf6yKdUS8OfVNtbzswmSDDf35ZRJt+jBNasEXU91YdKFXD1g3EOEE7qKOhu zSzUfegEF4zql9HjJXsG2fToqYh40jWrGaeBwP3stfca6pViWkednIAyMQGJsYSX256U VbrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=fFfKfqfhzapkwGA+4m3ESI6f35o4Tl8HhgWFiDKBKtI=; b=RCJQ+oBKr7W5q1D29BvUuIXNZ1paqzpPeRsIBCllgtCfWxwU5WoyNGY9O1PuQIfNwC /p6OHIe2F0e18L6K2OD0XM2NmEZshBdJo5f5RikrZFrgzeIA75mGZLtKiJEilieKcJKU ALsKVaZD3C3dJnCcB9L1ZtnRNUGWNpKmB6BvOlWfaA+uFbzdt6ITexRclJQOteZHg+yq E0TQSKm6jNjtqgA5OOhWKL2UVkr5fGhto5HEtvv22R8t0Jt0WQISGw61/FlTuvw+r0SZ 8C6Lj17uzubg8F7/Cd11FbUL5/tQWgyCoMI7eWLBlw2CqH94o6G3GdfTIxIqvuwNMMeG 9LDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@armlinux.org.uk header.s=pandora-2014 header.b=T6ONd66+; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h189si550112pgc.784.2018.01.29.16.25.03; Mon, 29 Jan 2018 16:25:18 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@armlinux.org.uk header.s=pandora-2014 header.b=T6ONd66+; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752365AbeA3AXn (ORCPT + 99 others); Mon, 29 Jan 2018 19:23:43 -0500 Received: from pandora.armlinux.org.uk ([78.32.30.218]:37604 "EHLO pandora.armlinux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752329AbeA3AXj (ORCPT ); Mon, 29 Jan 2018 19:23:39 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2014; h=Sender:In-Reply-To:Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date; bh=fFfKfqfhzapkwGA+4m3ESI6f35o4Tl8HhgWFiDKBKtI=; b=T6ONd66+N2q/xcfAonwYuyE/2l2JswOe302AgnL9IS8MJYWfAUS7R9h1gAolg5VnXpTLhim1zNm5WwSxy6Mixcs305sXb3fIjUq1fZRBdDnK/C7m5suLMtmXLMtDJebo5/p61L1rq70pyxnrKPI8rdgv6Y7W3KeJlNUd1WD2MwU=; Received: from n2100.armlinux.org.uk ([2002:4e20:1eda:1:214:fdff:fe10:4f86]:47331) by pandora.armlinux.org.uk with esmtpsa (TLSv1:DHE-RSA-AES256-SHA:256) (Exim 4.82_1-5b7a7c0-XX) (envelope-from ) id 1egJi0-0007Jt-8v; Tue, 30 Jan 2018 00:23:32 +0000 Received: from linux by n2100.armlinux.org.uk with local (Exim 4.76) (envelope-from ) id 1egJhw-0002SQ-Ru; Tue, 30 Jan 2018 00:23:28 +0000 Date: Tue, 30 Jan 2018 00:23:28 +0000 From: Russell King - ARM Linux To: Marc Zyngier Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, Mark Rutland , Peter Maydell , Lorenzo Pieralisi , Ard Biesheuvel , Catalin Marinas , Will Deacon , Jon Masters , Robin Murphy , Christoffer Dall Subject: Re: [PATCH v2 08/16] arm/arm64: KVM: Advertise SMCCC v1.1 Message-ID: <20180130002328.GB9418@n2100.armlinux.org.uk> References: <20180129174559.1866-1-marc.zyngier@arm.com> <20180129174559.1866-9-marc.zyngier@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180129174559.1866-9-marc.zyngier@arm.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jan 29, 2018 at 05:45:51PM +0000, Marc Zyngier wrote: > The new SMC Calling Convention (v1.1) allows for a reduced overhead > when calling into the firmware, and provides a new feature discovery > mechanism. > > Make it visible to KVM guests. > > Signed-off-by: Marc Zyngier > --- > Documentation/virtual/kvm/arm/psci.txt | 12 +++++++----- > arch/arm/kvm/handle_exit.c | 2 +- > arch/arm64/kvm/handle_exit.c | 2 +- > include/kvm/arm_psci.h | 2 +- > include/linux/arm-smccc.h | 13 +++++++++++++ > virt/kvm/arm/psci.c | 24 +++++++++++++++++++++++- > 6 files changed, 46 insertions(+), 9 deletions(-) > > diff --git a/Documentation/virtual/kvm/arm/psci.txt b/Documentation/virtual/kvm/arm/psci.txt > index 2e49a4e9f084..aafdab887b04 100644 > --- a/Documentation/virtual/kvm/arm/psci.txt > +++ b/Documentation/virtual/kvm/arm/psci.txt > @@ -13,7 +13,7 @@ a migration causes a different PSCI version to be exposed out of the > blue to an unsuspecting guest. > > In order to remedy this situation, KVM exposes a set of "firmware > -pseuodo-registers" that can be manipulated using the GET/SET_ONE_REG > +pseudo-registers" that can be manipulated using the GET/SET_ONE_REG This should surely be in patch 7? > interface. These registers can be saved/restored by userspace, and set > to a convenient value if required. > > @@ -21,8 +21,10 @@ The following register is defined: > > * KVM_REG_ARM_PSCI_VERSION: > > - - Only valid if the vcpu has KVM_ARM_VCPU_PSCI_0_2 feature set > - - Returns the current PSCI version on GET_ONE_REG > - - Allows any supported PSCI version compatible with v0.2 to be set > - with SET_ONE_REG > + - Only valid if the vcpu has the KVM_ARM_VCPU_PSCI_0_2 feature set > + (and thus has already been initialized) > + - Returns the current PSCI version on GET_ONE_REG (defaulting to the > + highest PSCI version implemented by KVM and compatible with v0.2) > + - Allows any PSCI version implemented by KVM and compatible with > + v0.2 to be set with SET_ONE_REG > - Affects the whole VM (even if the register view is per-vcpu) > diff --git a/arch/arm/kvm/handle_exit.c b/arch/arm/kvm/handle_exit.c > index e020cc82c4b1..a4520c7118d2 100644 > --- a/arch/arm/kvm/handle_exit.c > +++ b/arch/arm/kvm/handle_exit.c > @@ -36,7 +36,7 @@ static int handle_hvc(struct kvm_vcpu *vcpu, struct kvm_run *run) > kvm_vcpu_hvc_get_imm(vcpu)); > vcpu->stat.hvc_exit_stat++; > > - ret = kvm_psci_call(vcpu); > + ret = kvm_hvc_call_handler(vcpu); > if (ret < 0) { > vcpu_set_reg(vcpu, 0, ~0UL); > return 1; > diff --git a/arch/arm64/kvm/handle_exit.c b/arch/arm64/kvm/handle_exit.c > index 97e8d64a203d..bb6e1518d819 100644 > --- a/arch/arm64/kvm/handle_exit.c > +++ b/arch/arm64/kvm/handle_exit.c > @@ -52,7 +52,7 @@ static int handle_hvc(struct kvm_vcpu *vcpu, struct kvm_run *run) > kvm_vcpu_hvc_get_imm(vcpu)); > vcpu->stat.hvc_exit_stat++; > > - ret = kvm_psci_call(vcpu); > + ret = kvm_hvc_call_handler(vcpu); > if (ret < 0) { > vcpu_set_reg(vcpu, 0, ~0UL); > return 1; > diff --git a/include/kvm/arm_psci.h b/include/kvm/arm_psci.h > index f2fa7d752c4e..4876bfac2195 100644 > --- a/include/kvm/arm_psci.h > +++ b/include/kvm/arm_psci.h > @@ -26,7 +26,7 @@ > #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); > +int kvm_hvc_call_handler(struct kvm_vcpu *vcpu); > > struct kvm_one_reg; > > diff --git a/include/linux/arm-smccc.h b/include/linux/arm-smccc.h > index 4c5bca38c653..dc68aa5a7261 100644 > --- a/include/linux/arm-smccc.h > +++ b/include/linux/arm-smccc.h > @@ -60,6 +60,19 @@ > #define ARM_SMCCC_QUIRK_NONE 0 > #define ARM_SMCCC_QUIRK_QCOM_A6 1 /* Save/restore register a6 */ > > +#define ARM_SMCCC_VERSION_1_0 0x10000 > +#define ARM_SMCCC_VERSION_1_1 0x10001 > + > +#define ARM_SMCCC_VERSION_FUNC_ID \ > + ARM_SMCCC_CALL_VAL(ARM_SMCCC_FAST_CALL, \ > + ARM_SMCCC_SMC_32, \ > + 0, 0) > + > +#define ARM_SMCCC_ARCH_FEATURES_FUNC_ID \ > + ARM_SMCCC_CALL_VAL(ARM_SMCCC_FAST_CALL, \ > + ARM_SMCCC_SMC_32, \ > + 0, 1) > + > #ifndef __ASSEMBLY__ > > #include > diff --git a/virt/kvm/arm/psci.c b/virt/kvm/arm/psci.c > index 682f9be6264b..3bb336ac7d7d 100644 > --- a/virt/kvm/arm/psci.c > +++ b/virt/kvm/arm/psci.c > @@ -15,6 +15,7 @@ > * along with this program. If not, see . > */ > > +#include > #include > #include > #include > @@ -353,6 +354,7 @@ static int kvm_psci_1_0_call(struct kvm_vcpu *vcpu) > case PSCI_0_2_FN_SYSTEM_OFF: > case PSCI_0_2_FN_SYSTEM_RESET: > case PSCI_1_0_FN_PSCI_FEATURES: > + case ARM_SMCCC_VERSION_FUNC_ID: > val = 0; > break; > default: > @@ -407,7 +409,7 @@ static int kvm_psci_0_1_call(struct kvm_vcpu *vcpu) > * Errors: > * -EINVAL: Unrecognized PSCI function > */ > -int kvm_psci_call(struct kvm_vcpu *vcpu) > +static int kvm_psci_call(struct kvm_vcpu *vcpu) > { > switch (kvm_psci_version(vcpu)) { > case KVM_ARM_PSCI_1_0: > @@ -421,6 +423,26 @@ int kvm_psci_call(struct kvm_vcpu *vcpu) > }; > } > > +int kvm_hvc_call_handler(struct kvm_vcpu *vcpu) > +{ > + u32 func_id = smccc_get_function(vcpu); > + u32 val; > + > + switch (func_id) { > + case ARM_SMCCC_VERSION_FUNC_ID: > + val = ARM_SMCCC_VERSION_1_1; > + break; > + case ARM_SMCCC_ARCH_FEATURES_FUNC_ID: > + val = -1; /* Nothing supported yet */ > + break; > + default: > + return kvm_psci_call(vcpu); > + } > + > + smccc_set_retval(vcpu, val, 0, 0, 0); > + return 1; > +} > + > int kvm_arm_get_fw_num_regs(struct kvm_vcpu *vcpu) > { > return 1; /* PSCI version */ > -- > 2.14.2 > > > _______________________________________________ > linux-arm-kernel mailing list > linux-arm-kernel@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel -- RMK's Patch system: http://www.armlinux.org.uk/developer/patches/ FTTC broadband for 0.8mile line in suburbia: sync at 8.8Mbps down 630kbps up According to speedtest.net: 8.21Mbps down 510kbps up