From patchwork Wed May 15 17:22:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Ene X-Patchwork-Id: 13665428 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 827FEC25B75 for ; Wed, 15 May 2024 17:23:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:Message-ID: References:Mime-Version:In-Reply-To:Date:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=EGx3rnpMNBzfCnY03VYeoRVbiAE0/96INcN0D1DLAFc=; b=sT+UrWY5CoqKO2s08KI5mq5PYY I+ptzrAfohWUKQHx2fnFVQiD75cYueCwLJW+wDJ2ZPbCNfzDk8dYvwyBT05bG/EbkxOD0KaM+OAlz 2JDGzo1jBvHjfquKMzKRP1mCQSUmi+6Z/G1LZoAvDEnOfFXrL1e9A6AlQH2Kj9ApYABL0whSybbZi cGPryctcq4SEHia0MLy1r2CsFbbr9WcGh8T3BPDaHLnEQNzMBEOG/iyV09t6IFZqaAjfjo8FP5JJr AG+LgMZIgTahG7flwlk4GoQN7Tomh3ENmvyAU+pC/5HWcxZc5H07Zdx/mxFdP2VyRM1pPAUreYSOq ujTlgclw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s7ILp-00000002NDY-2GEL; Wed, 15 May 2024 17:23:37 +0000 Received: from mail-yw1-x114a.google.com ([2607:f8b0:4864:20::114a]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s7ILR-00000002Mv2-0CsE for linux-arm-kernel@lists.infradead.org; Wed, 15 May 2024 17:23:19 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-61be325413eso90100057b3.1 for ; Wed, 15 May 2024 10:23:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1715793790; x=1716398590; darn=lists.infradead.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=WQNv0L9f8Ur9QycJthQG4bmvCcJmqN/f24s1YQ7H6/M=; b=Eo8cDTrQ2emT1z3KLCymUmnUTqzSVzgIVKxvKew+VkmZ2lQ0+bZwgn7Qgf0lXFVAc/ /71UEVQX6YH0Vw2a9REpBXhvHcqQ/NvuQ8pg0uSVOd6Rc0kK0PKGTY1j//z6qp4RhR6L DV8DyLMaeKGBz9lcIvEaR/08mD7VcWcB/ciJq+zqhR9349dnojOvRgfwWNRJvvAF7NPd Qi5YxENknf7tMxgHIK79U2F6OfM4d/125/L+IMuUB2t9FN7d6p0Avvbb/VbK4RoM2fv0 DK0z6hxawH94j8NVdMzxRH56XBasq7n40+1TEk+qcDE2mxllBr4r/Lm41q3A3Dgake/m oA+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715793790; x=1716398590; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=WQNv0L9f8Ur9QycJthQG4bmvCcJmqN/f24s1YQ7H6/M=; b=ZdVf6ArutG8SzWi+w7hynhQ681X9/BLpuJmSg68mKJEZ5/3WI2kntrhIpHFtMYYl4n XbQ7LCoii4KP1pabOwMexL4bqB3WBgqdsy1RbjZMk/AmApOBzU/SI4f45aApo4jm+D4e +wlQr+BKRrae83IHbJaLXtl9ESyudJSuJ73J8VxrTd7dgMHbN0ZAQxdseeS0v9WgnZh/ ZRKJgWmJchdpKVRPY8+aQgulNqe1S7ZClXabKQFhpmntmbjwb9uYZjnDuaM84CuxHX/g kHexH/EA6D6I6endLVLJkoEGSvQ6NRh+ezUrcW+dRxJZMBMRgYmMRT5hg03C+RjfQgeI P0uA== X-Forwarded-Encrypted: i=1; AJvYcCV0UHvy/y7FS1qRHOXJH3UeWfEGjINGcRLhFiDt2011JZtVonzsUSQmXSobvhkBCHu7NilhwNbYl9pfcSUazrXBMXZfk+IlO1W00zEeSTrLJMMoVY0= X-Gm-Message-State: AOJu0YydKZbounXcclHn1heBB5MQ+f9/DGPkgrgJ1k0tR5dyO8i4VHzQ 8JYe0vkEGwkgYuzuib99kVaVWzK/EGBRE9gpAwK7zay0K3yp0KAqVXi/e17Jvp1B5Vfjh7XPpvw gAEDIbtK8OGc/06xDv/RN7AEDyA== X-Google-Smtp-Source: AGHT+IFWj0CPWZNjkZCa8D6KDWXhJ9Flvad+9yi5Xs81Nbt0wNqI/d2+oXKWmpATfuUhMILUHaW60rmoGvWSagTvTps= X-Received: from sebkvm.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:cd5]) (user=sebastianene job=sendgmr) by 2002:a05:690c:6904:b0:611:6f24:62b1 with SMTP id 00721157ae682-622af7a98aamr44278057b3.1.1715793790276; Wed, 15 May 2024 10:23:10 -0700 (PDT) Date: Wed, 15 May 2024 17:22:55 +0000 In-Reply-To: <20240515172258.1680881-1-sebastianene@google.com> Mime-Version: 1.0 References: <20240515172258.1680881-1-sebastianene@google.com> X-Mailer: git-send-email 2.45.0.rc1.225.g2a3ae87e7f-goog Message-ID: <20240515172258.1680881-2-sebastianene@google.com> Subject: [PATCH v2 1/4] KVM: arm64: Trap FFA_VERSION host call in pKVM From: Sebastian Ene To: catalin.marinas@arm.com, james.morse@arm.com, jean-philippe@linaro.org, maz@kernel.org, oliver.upton@linux.dev, qperret@google.com, qwandor@google.com, sudeep.holla@arm.com, suzuki.poulose@arm.com, tabba@google.com, will@kernel.org, yuzenghui@huawei.com, lpieralisi@kernel.org Cc: kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kernel-team@android.com, Sebastian Ene X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240515_102313_298413_17A6C84E X-CRM114-Status: GOOD ( 21.04 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The pKVM hypervisor initializes with FF-A version 1.0. The spec requires that no other FF-A calls to be issued before the version negotiation phase is complete. Split the hypervisor proxy initialization code in two parts so that we can move the later one after the host negotiates its version. Without trapping the call, the host drivers can negotiate a higher version number with TEE which can result in a different memory layout described during the memory sharing calls. Signed-off-by: Sebastian Ene Reviewed-by: Sudeep Holla --- arch/arm64/kvm/hyp/nvhe/ffa.c | 123 +++++++++++++++++++++++++--------- 1 file changed, 92 insertions(+), 31 deletions(-) diff --git a/arch/arm64/kvm/hyp/nvhe/ffa.c b/arch/arm64/kvm/hyp/nvhe/ffa.c index 320f2eaa14a9..72f1206c85fb 100644 --- a/arch/arm64/kvm/hyp/nvhe/ffa.c +++ b/arch/arm64/kvm/hyp/nvhe/ffa.c @@ -1,4 +1,5 @@ // SPDX-License-Identifier: GPL-2.0-only +// /* * FF-A v1.0 proxy to filter out invalid memory-sharing SMC calls issued by * the host. FF-A is a slightly more palatable abbreviation of "Arm Firmware @@ -67,6 +68,9 @@ struct kvm_ffa_buffers { */ static struct kvm_ffa_buffers hyp_buffers; static struct kvm_ffa_buffers host_buffers; +static u32 hyp_ffa_version; +static bool has_version_negotiated; +static hyp_spinlock_t version_lock; static void ffa_to_smccc_error(struct arm_smccc_res *res, u64 ffa_errno) { @@ -640,6 +644,83 @@ static bool do_ffa_features(struct arm_smccc_res *res, return true; } +static int hyp_ffa_post_init(void) +{ + size_t min_rxtx_sz; + struct arm_smccc_res res; + + arm_smccc_1_1_smc(FFA_ID_GET, 0, 0, 0, 0, 0, 0, 0, &res); + if (res.a0 != FFA_SUCCESS) + return -EOPNOTSUPP; + + if (res.a2 != HOST_FFA_ID) + return -EINVAL; + + arm_smccc_1_1_smc(FFA_FEATURES, FFA_FN64_RXTX_MAP, + 0, 0, 0, 0, 0, 0, &res); + if (res.a0 != FFA_SUCCESS) + return -EOPNOTSUPP; + + switch (res.a2) { + case FFA_FEAT_RXTX_MIN_SZ_4K: + min_rxtx_sz = SZ_4K; + break; + case FFA_FEAT_RXTX_MIN_SZ_16K: + min_rxtx_sz = SZ_16K; + break; + case FFA_FEAT_RXTX_MIN_SZ_64K: + min_rxtx_sz = SZ_64K; + break; + default: + return -EINVAL; + } + + if (min_rxtx_sz > PAGE_SIZE) + return -EOPNOTSUPP; + + return 0; +} + +static void do_ffa_version(struct arm_smccc_res *res, + struct kvm_cpu_context *ctxt) +{ + DECLARE_REG(u32, ffa_req_version, ctxt, 1); + + if (FFA_MAJOR_VERSION(ffa_req_version) != 1) { + res->a0 = FFA_RET_NOT_SUPPORTED; + return; + } + + hyp_spin_lock(&version_lock); + if (has_version_negotiated) { + res->a0 = hyp_ffa_version; + goto unlock; + } + + /* + * If the client driver tries to downgrade the version, we need to ask + * first if TEE supports it. + */ + if (FFA_MINOR_VERSION(ffa_req_version) < FFA_MINOR_VERSION(hyp_ffa_version)) { + arm_smccc_1_1_smc(FFA_VERSION, ffa_req_version, 0, + 0, 0, 0, 0, 0, + res); + if (res->a0 == FFA_RET_NOT_SUPPORTED) + goto unlock; + + hyp_ffa_version = ffa_req_version; + } + + if (hyp_ffa_post_init()) + res->a0 = FFA_RET_NOT_SUPPORTED; + else { + has_version_negotiated = true; + res->a0 = hyp_ffa_version; + } +unlock: + hyp_spin_unlock(&version_lock); +} + bool kvm_host_ffa_handler(struct kvm_cpu_context *host_ctxt, u32 func_id) { struct arm_smccc_res res; @@ -660,6 +741,11 @@ bool kvm_host_ffa_handler(struct kvm_cpu_context *host_ctxt, u32 func_id) if (!is_ffa_call(func_id)) return false; + if (!has_version_negotiated && func_id != FFA_VERSION) { + ffa_to_smccc_error(&res, FFA_RET_INVALID_PARAMETERS); + goto out_handled; + } + switch (func_id) { case FFA_FEATURES: if (!do_ffa_features(&res, host_ctxt)) @@ -686,6 +772,9 @@ bool kvm_host_ffa_handler(struct kvm_cpu_context *host_ctxt, u32 func_id) case FFA_MEM_FRAG_TX: do_ffa_mem_frag_tx(&res, host_ctxt); goto out_handled; + case FFA_VERSION: + do_ffa_version(&res, host_ctxt); + goto out_handled; } if (ffa_call_supported(func_id)) @@ -700,7 +789,6 @@ bool kvm_host_ffa_handler(struct kvm_cpu_context *host_ctxt, u32 func_id) int hyp_ffa_init(void *pages) { struct arm_smccc_res res; - size_t min_rxtx_sz; void *tx, *rx; if (kvm_host_psci_config.smccc_version < ARM_SMCCC_VERSION_1_2) @@ -726,35 +814,7 @@ int hyp_ffa_init(void *pages) if (FFA_MAJOR_VERSION(res.a0) != 1) return -EOPNOTSUPP; - arm_smccc_1_1_smc(FFA_ID_GET, 0, 0, 0, 0, 0, 0, 0, &res); - if (res.a0 != FFA_SUCCESS) - return -EOPNOTSUPP; - - if (res.a2 != HOST_FFA_ID) - return -EINVAL; - - arm_smccc_1_1_smc(FFA_FEATURES, FFA_FN64_RXTX_MAP, - 0, 0, 0, 0, 0, 0, &res); - if (res.a0 != FFA_SUCCESS) - return -EOPNOTSUPP; - - switch (res.a2) { - case FFA_FEAT_RXTX_MIN_SZ_4K: - min_rxtx_sz = SZ_4K; - break; - case FFA_FEAT_RXTX_MIN_SZ_16K: - min_rxtx_sz = SZ_16K; - break; - case FFA_FEAT_RXTX_MIN_SZ_64K: - min_rxtx_sz = SZ_64K; - break; - default: - return -EINVAL; - } - - if (min_rxtx_sz > PAGE_SIZE) - return -EOPNOTSUPP; - + hyp_ffa_version = FFA_VERSION_1_0; tx = pages; pages += KVM_FFA_MBOX_NR_PAGES * PAGE_SIZE; rx = pages; @@ -773,8 +833,9 @@ int hyp_ffa_init(void *pages) }; host_buffers = (struct kvm_ffa_buffers) { - .lock = __HYP_SPIN_LOCK_UNLOCKED, + .lock = __HYP_SPIN_LOCK_UNLOCKED, }; + version_lock = __HYP_SPIN_LOCK_UNLOCKED; return 0; } From patchwork Wed May 15 17:22:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Ene X-Patchwork-Id: 13665436 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CEB85C25B75 for ; Wed, 15 May 2024 17:31:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:Message-ID: References:Mime-Version:In-Reply-To:Date:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=UharPUDSPyK6n+Th1YhveX9C8Y2hp2tV3FQ7Zq4H45c=; b=uVHPU/Ygqokl+iomYKcMKMHO8c du+O1Lx6wIsFYAcM1KuDV0FmkxJOXk//p6zuMOdaST8nQVkpj7gTrlpQFCJCTrKeGd9rM59rHbffQ js2NKYtfoOrYo+01D52JmziptIuUPje+xB7YYiflKUwoFgQM4X1omQUNp0T41vChFHu3yWyY6LJ8y Koz8xcbYvNVVNvy1Db5OCLmRAUV+tzOQv+qO0ruQf6yiCCaGg51qt9wmUOShw5M8WWW15GxtNjxRV VCE/6ufjtjU4qx6pJsAuaX4qOFSdeiFgG8FAW5gJphbWnp4kXzkSRXlC0Gl0Z/sHD1dcd0ObF5qKe vk2+tYWA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s7ITP-00000002Pzt-0SCz; Wed, 15 May 2024 17:31:27 +0000 Received: from mail-lj1-x249.google.com ([2a00:1450:4864:20::249]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s7ITK-00000002Pv7-2uf5 for linux-arm-kernel@lists.infradead.org; Wed, 15 May 2024 17:31:25 +0000 Received: by mail-lj1-x249.google.com with SMTP id 38308e7fff4ca-2e21d6edfe9so62627941fa.2 for ; Wed, 15 May 2024 10:31:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1715794277; x=1716399077; darn=lists.infradead.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=PcqaauEjDoHXh8ji52zP7N4xCK0LJvzWgGd8bzIHFvQ=; b=oIxYZVobvIdd7vKzFbjZBSV/+kl+kajpQ7Ua3d9tnLGxhGD2gpwbS4zaeMsKCTWOUp AAojdBaSniTLHTrHG2Fs4viDjePW6vq4tvO8KmUQUNw7ixVGvkv7tAOupyEemdk6SCn2 nQY4xM6vQ5++Fup6YiZQ1KZHg6JqvLzdSovq2KEOuFfD8+Dv8Qq30/wz3zvKx7JRr8nJ fmWFYAGGbCT8fJfzM0xAvbYSTQBBr6Zfa86Og7Fm9nZLsFYedTVRLwGJuDCMpc2XHeMY 35XVJcAQWp8Khg2vUXQ+QWSIR3UL9b49VWLcSnW9Il9EplC7uswDQd1sXa/8F5tLF2yi SalA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715794277; x=1716399077; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=PcqaauEjDoHXh8ji52zP7N4xCK0LJvzWgGd8bzIHFvQ=; b=jPBM8JsliWIcwCL/2EP9ISNMuNCX7pFATNl/L6GUIlQPgZb4MvkOs6HBHHz+ccJ8Gk ycGJBMkSYuGLN+l5OTzZPP0ZX79VfGL+fa59RjqZzDUkysauPredfLonB3U+Jd95iqx+ gn+ipcGWb4/cYML1amnuDXzfz1ybiZ8W5Z8n//qRZ3tzTbOXlSolQxpScXKJJ2cQujwm E60sRoe3UgXh6IeMJH2TkXcDB2KSpyBajEPRuwD+a3E1c+kPiIkE+Oq7aUytRqxYOT/+ 6xzgTWSQGMbmiD9+cRPXZQvnVecUbj4yrxrhRVdMlJc6Y00uCWO7Dkaox0P397t7Ek4m WvDA== X-Forwarded-Encrypted: i=1; AJvYcCWSiSACNxv7yJ0t52Ldge9UNgsnbE4chMIK9j7osNOqvnl27WBkKWCWuH+yUGqvDI3mkWLLN10pkfQuol5YSEBKR2T6JfEmbIaF6xyBrrNTw6Y1ckc= X-Gm-Message-State: AOJu0Ywhiu9SlcH2JAE5Gnvmd4shJsgTA/FJZNCBXWpUZRfIjJTy1V+l pGyvJwGOcMb90KliplM6b0fRdHYJPS6B0EbxVc+awJbzgpDWUErU/S3Dh4oSH6NlBZxIda+N2d+ upV4P+lsJBuSrBfPgSznAF7HuHQ== X-Google-Smtp-Source: AGHT+IGGUIJb5pGjjG4rjRgqRcd958BlLvK0rXB3oHHp6PSS+i2nJgNusaT1TQYCxhhQR4CzKLUcSXY1cFz2pqMA+h8= X-Received: from sebkvm.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:cd5]) (user=sebastianene job=sendgmr) by 2002:a05:600c:502b:b0:420:217f:4f7 with SMTP id 5b1f17b1804b1-420217f0761mr367455e9.6.1715793792652; Wed, 15 May 2024 10:23:12 -0700 (PDT) Date: Wed, 15 May 2024 17:22:56 +0000 In-Reply-To: <20240515172258.1680881-1-sebastianene@google.com> Mime-Version: 1.0 References: <20240515172258.1680881-1-sebastianene@google.com> X-Mailer: git-send-email 2.45.0.rc1.225.g2a3ae87e7f-goog Message-ID: <20240515172258.1680881-3-sebastianene@google.com> Subject: [PATCH v2 2/4] KVM: arm64: Add support for FFA_PARTITION_INFO_GET From: Sebastian Ene To: catalin.marinas@arm.com, james.morse@arm.com, jean-philippe@linaro.org, maz@kernel.org, oliver.upton@linux.dev, qperret@google.com, qwandor@google.com, sudeep.holla@arm.com, suzuki.poulose@arm.com, tabba@google.com, will@kernel.org, yuzenghui@huawei.com, lpieralisi@kernel.org Cc: kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kernel-team@android.com, Sebastian Ene X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240515_103122_756696_453E3ADC X-CRM114-Status: GOOD ( 15.98 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Handle the FFA_PARTITION_INFO_GET host call inside the pKVM hypervisor and copy the response message back to the host buffers. Save the returned FF-A version as we will need it later to interpret the response from the TEE. Signed-off-by: Sebastian Ene Reviewed-by: Sudeep Holla --- arch/arm64/kvm/hyp/nvhe/ffa.c | 52 +++++++++++++++++++++++++++++++++++ include/linux/arm_ffa.h | 3 ++ 2 files changed, 55 insertions(+) diff --git a/arch/arm64/kvm/hyp/nvhe/ffa.c b/arch/arm64/kvm/hyp/nvhe/ffa.c index 72f1206c85fb..f9664c4a348e 100644 --- a/arch/arm64/kvm/hyp/nvhe/ffa.c +++ b/arch/arm64/kvm/hyp/nvhe/ffa.c @@ -721,6 +721,55 @@ static void do_ffa_version(struct arm_smccc_res *res, hyp_spin_unlock(&version_lock); } +static void do_ffa_part_get(struct arm_smccc_res *res, + struct kvm_cpu_context *ctxt) +{ + DECLARE_REG(u32, uuid0, ctxt, 1); + DECLARE_REG(u32, uuid1, ctxt, 2); + DECLARE_REG(u32, uuid2, ctxt, 3); + DECLARE_REG(u32, uuid3, ctxt, 4); + DECLARE_REG(u32, flags, ctxt, 5); + u32 count, partition_sz, copy_sz; + + hyp_spin_lock(&host_buffers.lock); + if (!host_buffers.rx) { + ffa_to_smccc_res(res, FFA_RET_BUSY); + goto out_unlock; + } + + arm_smccc_1_1_smc(FFA_PARTITION_INFO_GET, uuid0, uuid1, + uuid2, uuid3, flags, 0, 0, + res); + + if (res->a0 != FFA_SUCCESS) + goto out_unlock; + + count = res->a2; + if (!count) + goto out_unlock; + + if (hyp_ffa_version > FFA_VERSION_1_0) { + /* Get the number of partitions deployed in the system */ + if (flags & 0x1) + goto out_unlock; + + partition_sz = res->a3; + } else { + /* FFA_VERSION_1_0 lacks the size in the response */ + partition_sz = FFA_1_0_PARTITON_INFO_SZ; + } + + copy_sz = partition_sz * count; + if (copy_sz > KVM_FFA_MBOX_NR_PAGES * PAGE_SIZE) { + ffa_to_smccc_res(res, FFA_RET_ABORTED); + goto out_unlock; + } + + memcpy(host_buffers.rx, hyp_buffers.rx, copy_sz); +out_unlock: + hyp_spin_unlock(&host_buffers.lock); +} + bool kvm_host_ffa_handler(struct kvm_cpu_context *host_ctxt, u32 func_id) { struct arm_smccc_res res; @@ -775,6 +824,9 @@ bool kvm_host_ffa_handler(struct kvm_cpu_context *host_ctxt, u32 func_id) case FFA_VERSION: do_ffa_version(&res, host_ctxt); goto out_handled; + case FFA_PARTITION_INFO_GET: + do_ffa_part_get(&res, host_ctxt); + goto out_handled; } if (ffa_call_supported(func_id)) diff --git a/include/linux/arm_ffa.h b/include/linux/arm_ffa.h index c906f666ff5d..12a7fa2d6550 100644 --- a/include/linux/arm_ffa.h +++ b/include/linux/arm_ffa.h @@ -211,6 +211,9 @@ bool ffa_device_is_valid(struct ffa_device *ffa_dev) { return false; } extern const struct bus_type ffa_bus_type; +/* The FF-A 1.0 partition structure lacks the uuid[4] */ +#define FFA_1_0_PARTITON_INFO_SZ (8) + /* FFA transport related */ struct ffa_partition_info { u16 id; From patchwork Wed May 15 17:22:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Ene X-Patchwork-Id: 13665427 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 47BE9C25B78 for ; Wed, 15 May 2024 17:23:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:Message-ID: References:Mime-Version:In-Reply-To:Date:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=uvgQonT8p7Zu2Z9iZ6/YFMp5fqcbQ74YMphQofU2j+c=; b=MLt4CF+hYO4/Hqhz3pW+vklRDs 1jXepR3GBs1mn1x8GE6WFR1Yrp+BOoXzLah7XX6e6lrnhtNxcMrh8mhQZ7TjHHiasJKu2Gp3l9OtU kSzCoALgaRGzaBW2NQW/IefSfKGSn60LhODQ54dqFM4K5MFCK/WiB6BKNFv9b/qehihXXUjzVeu99 pa14bf73By2nFmIkHRV1jAHcVCck8rTFvnlkWeWx0FcdWVb0MpIaykeqwv7gJlAKxjEX3Kc6hRk9o /aELHxbRGz07VJI/VhsIfsoJRyoQtwEIoJFFJQA1QLYMjOQZ1xKPMP2afswJu68mGuxI8vc4O4aL6 u6Us/Sxw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s7ILq-00000002NEY-3yhQ; Wed, 15 May 2024 17:23:38 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s7ILc-00000002N7a-0ho4 for linux-arm-kernel@bombadil.infradead.org; Wed, 15 May 2024 17:23:33 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Type:Cc:To:From:Subject: Message-ID:References:Mime-Version:In-Reply-To:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=B0DAehK5iEGC7D6F2LaIGrwd7yaT6oZGo7c2srRK8ao=; b=AJeDnnYzj23us40gEsDrcCjr1k WGvEghO2NFqsXQsPnR0PqXbQb05H7y13vp1XIUB2y17FR7JwfS1qf4nOALS2HSpvb8EHpT9717pUw +VXEQ6cjiwBPh4ufwqVywuFO+9+en0ECJbW8Hvkb+Dll+dJCjeyKIG4281NrKupIgPwvV8crU+fkM 2yGruXpxz1/tZZ3NC5G5SYyMk3WRAEY8xeYU3D87Eu4243HEfiaAJud0cpwxKqDoLRkEehIFBhK/m 5DSauYCdwC7+HF+dA5GsT/7H1XPxV8oVYGqViNa2BGkGlE2DqTMYQJqdc+rH1QeMrjzcDTwLDUerX sFWPIg7w==; Received: from mail-wr1-x44a.google.com ([2a00:1450:4864:20::44a]) by casper.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s7ILW-0000000AhsH-0alh for linux-arm-kernel@lists.infradead.org; Wed, 15 May 2024 17:23:23 +0000 Received: by mail-wr1-x44a.google.com with SMTP id ffacd0b85a97d-351c67dbc8dso1280405f8f.2 for ; Wed, 15 May 2024 10:23:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1715793795; x=1716398595; darn=lists.infradead.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=B0DAehK5iEGC7D6F2LaIGrwd7yaT6oZGo7c2srRK8ao=; b=dLTslfuJgfTXPlR0PyVp2E4o8IoD53DpWpxZN0MgdkUeQ0vvjqS+f2qyeN7B96sKYY xWevyKOnrZmi9bhZckuw26p1AuTtY9XCgqQmFXqC/8Va/jLIPOyuBv24VsMihxp8ekoD POlh5rym4v7fy98DCnXiM0Em54IHykwQQxJ62qdhKZylXFTK6kMVR14RrQDQKT7N5P4G Qj42NkWSAssZBLSTD27uWpu5dSJwJljvLh2+XY8/oeVcAr+vGfSwU3gFafJW3eu9v7sC AMd27unw5j/EzwJJwBnNb2cA6oz53AsKwKFVDXlWnImFa6PTb53lrltjhlTO2iItc6S6 D/Wg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715793795; x=1716398595; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=B0DAehK5iEGC7D6F2LaIGrwd7yaT6oZGo7c2srRK8ao=; b=cfBaSWHNaMKEkFqt42flzTw8GuWbgD6Rl1jX7G/PV3hsFIoeXgDUorA5bKKsiQxyNC F02FyO3pVsHDZCskWFC1M7lrsS9+sa0g0J6GfY5EN6LkgOwKJ2g9x7dN0HKVYMWPmhnW SXeZVce1KxBQlQlVcKhlRtsnTMvJ0ZSvd9y3PZEYrKIN1aSau9iw645BAw5l1frNRsCv KLuG7N4mkzOxjlzXjcNiH8H2x7BbyPm2pFU/LMGiKZNbaFuwRnlOcwIGBPW9HXXW//9C fhUUH3YYx7sz7Rsz3YLlVUQsBScZJckrfYPHVB4oazbFdJYkEIh/BthZ3hfSXGSiToMv rnGg== X-Forwarded-Encrypted: i=1; AJvYcCX/r8hLKsnxBagpPeYIlDWLcrqUkipj2cFbHz9ViSnBs+rUpAeHt3g2jinAa3OsypKv1WCE7op9zlPHWEhltJui4Xa1PKAhutXVKYhtgDQLZCt7mRc= X-Gm-Message-State: AOJu0YxyHV6KZ4UpxgDCNd85Um5R4bIFvJfeNgkpubK+rsZVi44qqtta 7BKkH/ZCayX5yXdKm1RIXKqi6ZYQnSEJixOnliazRDKTXZ5qPmfAu3jo/g8iYfe+Tg8dUBJMo2L lZr1qLY6e8c8KRf/14G6pixJCIw== X-Google-Smtp-Source: AGHT+IH03ZoGLJfBqC8Eh4MTyJx29qZ/mRDItFO9N0niAZcln5o7llsonWFoglyUwHcG4HXvFRo52sD+v+QqQnvnw4k= X-Received: from sebkvm.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:cd5]) (user=sebastianene job=sendgmr) by 2002:a5d:4750:0:b0:34d:a979:e99b with SMTP id ffacd0b85a97d-3504a10f83dmr32508f8f.0.1715793794931; Wed, 15 May 2024 10:23:14 -0700 (PDT) Date: Wed, 15 May 2024 17:22:57 +0000 In-Reply-To: <20240515172258.1680881-1-sebastianene@google.com> Mime-Version: 1.0 References: <20240515172258.1680881-1-sebastianene@google.com> X-Mailer: git-send-email 2.45.0.rc1.225.g2a3ae87e7f-goog Message-ID: <20240515172258.1680881-4-sebastianene@google.com> Subject: [PATCH v2 3/4] KVM: arm64: Fix the identification range for the FF-A smcs From: Sebastian Ene To: catalin.marinas@arm.com, james.morse@arm.com, jean-philippe@linaro.org, maz@kernel.org, oliver.upton@linux.dev, qperret@google.com, qwandor@google.com, sudeep.holla@arm.com, suzuki.poulose@arm.com, tabba@google.com, will@kernel.org, yuzenghui@huawei.com, lpieralisi@kernel.org Cc: kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kernel-team@android.com, Sebastian Ene X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240515_182318_194412_74B207C3 X-CRM114-Status: GOOD ( 10.23 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The FF-A spec 1.2 reserves the following ranges for identifying FF-A calls: 0x84000060-0x840000FF: FF-A 32-bit calls 0xC4000060-0xC40000FF: FF-A 64-bit calls. Use the range identification according to the spec and allow calls that are currently out of the range(eg. FFA_MSG_SEND_DIRECT_REQ2) to be identified correctly. Acked-by: Will Deacon Signed-off-by: Sebastian Ene Reviewed-by: Sudeep Holla --- arch/arm64/kvm/hyp/include/nvhe/ffa.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm64/kvm/hyp/include/nvhe/ffa.h b/arch/arm64/kvm/hyp/include/nvhe/ffa.h index d9fd5e6c7d3c..146e0aebfa1c 100644 --- a/arch/arm64/kvm/hyp/include/nvhe/ffa.h +++ b/arch/arm64/kvm/hyp/include/nvhe/ffa.h @@ -9,7 +9,7 @@ #include #define FFA_MIN_FUNC_NUM 0x60 -#define FFA_MAX_FUNC_NUM 0x7F +#define FFA_MAX_FUNC_NUM 0xFF int hyp_ffa_init(void *pages); bool kvm_host_ffa_handler(struct kvm_cpu_context *host_ctxt, u32 func_id); From patchwork Wed May 15 17:22:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Ene X-Patchwork-Id: 13665429 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D759CC25B78 for ; Wed, 15 May 2024 17:23:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:Message-ID: References:Mime-Version:In-Reply-To:Date:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=rP90K3K/X/ee6prGW8OAiA7QG4MNG6xhdRmZ8tfvI+c=; b=I++HLBz1VN1Vx6Ce37GGljfMm2 1PO3kCm2MZvIxE+FQKusPqEhroGoMZ38+r0bNpMqyRfxvFf6qhfFzmJmznq9uKXcxMcXFJfkbmkqB OELCWdejnH/e0trtovw/nU1CDi3/nMHSTYE9D9nRwsLsmrk3nG3Kz6v96vHDgphQ796j2wizppPAC r/UcQoxqsPFcvQK54jaj0JsiX1qE0WeYhYr1vw7ztXwseguA1wZR/uyD0vLCc27357pkZ0/8UetNK sDvrc2JbKDxcKfs82TTkBzmeSTBPlqXpCvy7jlxVTowiou2TB6pBzuDL+fuKD2KVGyEC4g1VeyYIz lhxYFBDQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s7ILs-00000002NG7-39EW; Wed, 15 May 2024 17:23:40 +0000 Received: from mail-wm1-f73.google.com ([209.85.128.73]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s7ILY-00000002N2b-3YvG for linux-arm-kernel@lists.infradead.org; Wed, 15 May 2024 17:23:33 +0000 Received: by mail-wm1-f73.google.com with SMTP id 5b1f17b1804b1-4200ef4fb81so22587825e9.1 for ; Wed, 15 May 2024 10:23:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1715793797; x=1716398597; darn=lists.infradead.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=9HVNMjO2akSMcTTiBfbdxnnFw0wMMSm8FW4gVmT1QRI=; b=tvm+wFmI6IUnO2fw0Ef0ri3YnduXrsO0WIvEkx2ivoJzqI7D6d3vqSA4rgk2TQO98Y aUBG3PX7udhhwkksXVMf/laH2/pWH3XQ+eMr6yKi7bqmPDaL4CypeKoUNL1xQxWvq8+M G6xVk+QcsfkbSUpchhNDRzIhioxi9yJl5ZjIkYPIypxyO1d3LtxfPxmzMw3U4RVRKOpd wnxrS8hcA664JQ0u0QoAc3dWEw0f2ECfPh5lE6QOqzVeXauanAf84XuDKni4taBtpZF3 XNLW4YwBq5VTL5sW3vy0ZrzYUn6/gFHIYyDwmFGYDcQdOWPvATFT8/knzy9UsrymJFwD iJVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715793797; x=1716398597; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=9HVNMjO2akSMcTTiBfbdxnnFw0wMMSm8FW4gVmT1QRI=; b=CcwVjOTe7rkjZp3+D2/wpTXuztzp/tQYteWwPusSmo2vY2cMqwU41kQXOMtKEnBzvL qKyOwDpDxdeNFPQHnP/px0/cmaiORh+c6ZW23W9+CCOzx4q/c0bslrXW758D9qdk72Rr +biiMJ7MdS0UypJabevA5Yx20JA7d41jM3zR6Jx3g018lELrddkTsfK3nu/RlPI8zOwL Gw00mNTXwINUR84qAmU9idQYRlLs1nQQgK5KIY9DD+CH5o6VATdVdKYzHYfLbyDX8Ud8 bX3bLmka0FprWLxQBriicSjHM/xlowsZ81i83VqFpZ21I21DpaogDFH3AAHENuPqXraF aAeQ== X-Forwarded-Encrypted: i=1; AJvYcCX14wNiFzNORFmnEz8/5RQJBm8eoqg2OUDPzmxSo2uLPjz5t2eoRbjVANlnPVr0KHaZRpehP5fQw7QzgI5om1tid6X1LWgWB44NaVCnvGKtYrPOgWg= X-Gm-Message-State: AOJu0Yx+aDeVrVN4+Iy1Ieb389PiiMb/fToXIzO6qajiLlZqVRH+1Frs xzsg5aBjkplA/WQhHfFNnf0XV0hpIfRLp3AXzkbC1BeADMjzMmzbPH0JQxTqFvzuoIbURruf6Ao q1tJD/ICUMYNNc01H3QmNFfeHCw== X-Google-Smtp-Source: AGHT+IF2+ZdhABrnKPyUROWJCaWhOUajRbqGLHWL21MZQxT/ip0TW6XIGdVRzaMZh4Ur0gPZC6lIS0u4//WU4M/kut0= X-Received: from sebkvm.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:cd5]) (user=sebastianene job=sendgmr) by 2002:a05:600c:511d:b0:41e:8c00:94a4 with SMTP id 5b1f17b1804b1-41fead6accamr2395155e9.3.1715793797270; Wed, 15 May 2024 10:23:17 -0700 (PDT) Date: Wed, 15 May 2024 17:22:58 +0000 In-Reply-To: <20240515172258.1680881-1-sebastianene@google.com> Mime-Version: 1.0 References: <20240515172258.1680881-1-sebastianene@google.com> X-Mailer: git-send-email 2.45.0.rc1.225.g2a3ae87e7f-goog Message-ID: <20240515172258.1680881-5-sebastianene@google.com> Subject: [PATCH v2 4/4] KVM: arm64: Use FF-A 1.1 with pKVM From: Sebastian Ene To: catalin.marinas@arm.com, james.morse@arm.com, jean-philippe@linaro.org, maz@kernel.org, oliver.upton@linux.dev, qperret@google.com, qwandor@google.com, sudeep.holla@arm.com, suzuki.poulose@arm.com, tabba@google.com, will@kernel.org, yuzenghui@huawei.com, lpieralisi@kernel.org Cc: kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kernel-team@android.com, Sebastian Ene X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240515_102321_129264_5427CC6A X-CRM114-Status: GOOD ( 15.33 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Now that the layout of the structures is compatible with 1.1 it is time to probe the 1.1 version of the FF-A protocol inside the hypervisor. If the TEE doesn't support it, it should return the minimum supported version. Signed-off-by: Sebastian Ene Reviewed-by: Sudeep Holla --- arch/arm64/kvm/hyp/nvhe/ffa.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/arch/arm64/kvm/hyp/nvhe/ffa.c b/arch/arm64/kvm/hyp/nvhe/ffa.c index f9664c4a348e..bdd70eb4114e 100644 --- a/arch/arm64/kvm/hyp/nvhe/ffa.c +++ b/arch/arm64/kvm/hyp/nvhe/ffa.c @@ -458,7 +458,7 @@ static __always_inline void do_ffa_mem_xfer(const u64 func_id, memcpy(buf, host_buffers.tx, fraglen); ep_mem_access = (void *)buf + - ffa_mem_desc_offset(buf, 0, FFA_VERSION_1_0); + ffa_mem_desc_offset(buf, 0, hyp_ffa_version); offset = ep_mem_access->composite_off; if (!offset || buf->ep_count != 1 || buf->sender_id != HOST_FFA_ID) { ret = FFA_RET_INVALID_PARAMETERS; @@ -537,7 +537,7 @@ static void do_ffa_mem_reclaim(struct arm_smccc_res *res, fraglen = res->a2; ep_mem_access = (void *)buf + - ffa_mem_desc_offset(buf, 0, FFA_VERSION_1_0); + ffa_mem_desc_offset(buf, 0, hyp_ffa_version); offset = ep_mem_access->composite_off; /* * We can trust the SPMD to get this right, but let's at least @@ -846,7 +846,7 @@ int hyp_ffa_init(void *pages) if (kvm_host_psci_config.smccc_version < ARM_SMCCC_VERSION_1_2) return 0; - arm_smccc_1_1_smc(FFA_VERSION, FFA_VERSION_1_0, 0, 0, 0, 0, 0, 0, &res); + arm_smccc_1_1_smc(FFA_VERSION, FFA_VERSION_1_1, 0, 0, 0, 0, 0, 0, &res); if (res.a0 == FFA_RET_NOT_SUPPORTED) return 0; @@ -866,7 +866,11 @@ int hyp_ffa_init(void *pages) if (FFA_MAJOR_VERSION(res.a0) != 1) return -EOPNOTSUPP; - hyp_ffa_version = FFA_VERSION_1_0; + if (FFA_MINOR_VERSION(res.a0) < FFA_MINOR_VERSION(FFA_VERSION_1_1)) + hyp_ffa_version = res.a0; + else + hyp_ffa_version = FFA_VERSION_1_1; + tx = pages; pages += KVM_FFA_MBOX_NR_PAGES * PAGE_SIZE; rx = pages;