Received: by 10.223.176.5 with SMTP id f5csp1729276wra; Sun, 4 Feb 2018 10:39:45 -0800 (PST) X-Google-Smtp-Source: AH8x224lIaz3tt0Z+lUkgEZ4bM7L+C/XuEpgBfJMbkqhllhqIY5AVOE0o6OBZsualB+ajsJwGs63 X-Received: by 2002:a17:902:8307:: with SMTP id bd7-v6mr21210495plb.369.1517769585762; Sun, 04 Feb 2018 10:39:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517769585; cv=none; d=google.com; s=arc-20160816; b=MmLjGvpztAHyF7lKQ3FwaVhkoy9uS5Nt2U6mYi1LWUxcWlRyyoP40kmaQHhODgnRUi 0MXO0cDeaIBHdyoyX/LZH4M+rwWC0ZVMCAXeYEVSXkN3/DS7hwNt2uZRvJpzWVawyXEV 96QXODiIfOtfrDq5JFM6yIa/c3JKNfNMz21OQ2XSA904MS/nfrcZInqX4ca6zRMB707p jzqcULAo7Dslvu8u8t8vnu65wizTCWIe4wsESODNVzCA4acmtgH8DVMn3KhSK8O3Xru0 DCuLPAc1rPjNDEYPgqSZLmzrMtXb+4Y2CK+zSHJ2Cxm56LvYEgiwcL4MPGIKPTb889IN Gb6Q== 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=9CTlkW4fsfMM7rVjbCJqeUuSw6PjSV8x9Dzx/Xdqdcw=; b=Y32bw7M6jEdVzuyc5oe88sZqEely5Z3iPOLLQpozREyOxccLTgu4XDu07GLt3yTan1 GAROIJJ2S0g5RS9H5e65Zr7O17vBpA77cPZ0QaZKHCeBzHoR8unRm2isQ+kcOOuD53XK YnA8RC3qeh0F9/IvpIUASXAx2gvpz1GQ9UXJlZbcYfKLaLRgWWP2k/3WPRyez/B6OorP l4LaeD1fc5akkJ89WZTrs+hadKcAjktHVJ5P3bFIaTAxViXW1d2O2HPgnDV8f1G878aY olKPIPjtR8rYH/myzqYk/cPAG8teErT4ywQNz+wuNlI+jaFGdGJ/2d5pYDpw6EI13Vps dbjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=T9FQbwPc; 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=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 s9-v6si5769795plq.187.2018.02.04.10.39.31; Sun, 04 Feb 2018 10:39:45 -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=pass header.i=@linaro.org header.s=google header.b=T9FQbwPc; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752114AbeBDSi5 (ORCPT + 99 others); Sun, 4 Feb 2018 13:38:57 -0500 Received: from mail-wm0-f65.google.com ([74.125.82.65]:36109 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751577AbeBDSiv (ORCPT ); Sun, 4 Feb 2018 13:38:51 -0500 Received: by mail-wm0-f65.google.com with SMTP id f3so21796942wmc.1 for ; Sun, 04 Feb 2018 10:38:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=9CTlkW4fsfMM7rVjbCJqeUuSw6PjSV8x9Dzx/Xdqdcw=; b=T9FQbwPcHRto/JpiHnaIkZyMVYbFWR4tWJbBjl3m1MxejIZRhAV71FA8QIswBpKHQX W1S3y3DwMkFjfJzgUOL5hpllKstidSnesTVIdJ+HgwXjEtWMVHLhXi0KTK9hSLT5VRzO tMBSuLVObINwnk2+hIPwY+32v0SdJqmUI9lRI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=9CTlkW4fsfMM7rVjbCJqeUuSw6PjSV8x9Dzx/Xdqdcw=; b=BhywUMc01CHw9DpgjqP7u9DY9k/AKG2aTjdOfGPaD99N5SIEiIsTwWKlNIrYWTSAX1 wrM37reEgSXEpmLl9lndLg80l94+RAxB3yRU735wSFGgelyKeKv7sORiLPZVOMLvM9m6 um8+ukuYYJ1E7bCpEdLyyUuXuNBvwjnDO/No7qur5moj0yX6cJAV8rs6fGJvvCUTqHER eTZcp7JWFNlWUEUdRiItlD6zKdIjTHqXeB2DabK5PQx9ETK3HOo+POSvDEVjR118Ev/P mtA4uchBpFGXHqokMxKA38Kk2anjf5cEDL3lPTagd8ewe1RREQIojP8qeZhgfTy2mTim gsjg== X-Gm-Message-State: AKwxytdnCNNkXLmgnRgzgsteEGlDT7ofjs9VQndlgy+WVdKIP743GRgj AC5e9S2hbLpsyT3UfB8zj1Qokw== X-Received: by 10.80.144.13 with SMTP id b13mr47371505eda.165.1517769530182; Sun, 04 Feb 2018 10:38:50 -0800 (PST) Received: from localhost (x50d2404e.cust.hiper.dk. [80.210.64.78]) by smtp.gmail.com with ESMTPSA id c45sm5993287edb.17.2018.02.04.10.38.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 04 Feb 2018 10:38:49 -0800 (PST) Date: Sun, 4 Feb 2018 19:38:48 +0100 From: Christoffer Dall To: Marc Zyngier Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, Catalin Marinas , Will Deacon , Peter Maydell , Lorenzo Pieralisi , Mark Rutland , Robin Murphy , Ard Biesheuvel , Andrew Jones , Hanjun Guo , Jayachandran C , Jon Masters , Russell King - ARM Linux Subject: Re: [PATCH v3 09/18] arm/arm64: KVM: Advertise SMCCC v1.1 Message-ID: <20180204183848.GM21802@cbox> References: <20180201114657.7323-1-marc.zyngier@arm.com> <20180201114657.7323-10-marc.zyngier@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180201114657.7323-10-marc.zyngier@arm.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Feb 01, 2018 at 11:46:48AM +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. > Reviewed-by: Christoffer Dall > Signed-off-by: Marc Zyngier > --- > 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 +++++++++++++++++++++++- > 5 files changed, 39 insertions(+), 4 deletions(-) > > diff --git a/arch/arm/kvm/handle_exit.c b/arch/arm/kvm/handle_exit.c > index 230ae4079108..910bd8dabb3c 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 588f910632a7..e5e741bfffe1 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 4ee098c39e01..7b2e12697d4f 100644 > --- a/include/kvm/arm_psci.h > +++ b/include/kvm/arm_psci.h > @@ -27,7 +27,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 5c8366b71639..53272e8e0d37 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 > @@ -351,6 +352,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: > @@ -405,7 +407,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: > @@ -419,6 +421,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 = PSCI_RET_NOT_SUPPORTED; > + > + switch (func_id) { > + case ARM_SMCCC_VERSION_FUNC_ID: > + val = ARM_SMCCC_VERSION_1_1; > + break; > + case ARM_SMCCC_ARCH_FEATURES_FUNC_ID: > + /* 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 >