From mboxrd@z Thu Jan 1 00:00:00 1970 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 507B7C67861 for ; Tue, 9 Apr 2024 15:19:50 +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: Mime-Version:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=qE/ZHNzT8477vPxvq9swoJWJoDqaRAVXNCvWcO4QrS8=; b=jmc 9b7Moihjix7n/yoryHAQh/++qu9LVCBENbMeslStzKNJTqnnUYZ4GseK1amSn8wx50Sz4h5BDLnNy jKAZQZXJrYpAFzcMWAnB7w3twzxWdoxF1MMVXBvZrsWRhL8hz3xFwruYMIXMUY873U+rB3OVU1CiD uEIfTtNhQaoBQLdSrJjne/NA0syJ6wU6LucXJ1wNLL7YD5+yXagVDQYqDugMZkN8hZbzkgmd2WYnE jF+cHa2QSsap1c8tHsm1ZRrJO/QgNMh/x9DJl8iVKgVJ/TxvPAlys8CF7GSrYEpI6h5khUs2g6UeW CJOv3wWwsbTWMb4XMbHZ8hGHRd3dhBw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1ruDG0-00000002faF-1wmt; Tue, 09 Apr 2024 15:19:32 +0000 Received: from mail-wm1-x349.google.com ([2a00:1450:4864:20::349]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1ruDFw-00000002fYR-3ArZ for linux-arm-kernel@lists.infradead.org; Tue, 09 Apr 2024 15:19:30 +0000 Received: by mail-wm1-x349.google.com with SMTP id 5b1f17b1804b1-416b92eb902so1587495e9.3 for ; Tue, 09 Apr 2024 08:19:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1712675966; x=1713280766; darn=lists.infradead.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=rfLKcjfj+XVvS9PzbzE1iRQzwMkmoIsOxyakIn1NJAE=; b=RkdpmpKKuY+DQau3vQZt2a54W6skhQrxa9R5+lin3qtWfV6fvSkBhq1U6+vQGxM+Mb mTdIls3Itn6AJr54QU8iYKxYBdeegkUyVlpcIWkHvlkFNPNKU61MFyjY3pSQnNKmtg4e wH6DNufIxF2J5af0/WBflVqgM6z52+zh7TMqaptzNQlckzbOGGDdYU6egYsCm2mU0Fbk tbHe/Cefde6ekESIK0n+8ule+h4fma2RUDSKY76FgKEM75Zec2mmZ2Ei+kOJi2tvNaF+ boywnGbxrv3x1U4rYqUHgE9za1BRvrUA+rqVhlXZZU9fcZo1/5i3hjg2W4yGg2jBo3X5 zG2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712675966; x=1713280766; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=rfLKcjfj+XVvS9PzbzE1iRQzwMkmoIsOxyakIn1NJAE=; b=vgGJZL3LnPtbrKVmxE3MrFtL6CERC450FeH/mX4Em3hoZnoaYt9qJ4NUR6zdZpPQoT RKoX3imizc8xUOJ99xWXTGkoMDJ2TpY/RMyiw0BrZ+vHux3l07nJnk1hxDQveL218LzO iccjzs487+PAg1ESnSmsRcNXvTTW3nhjIFHJxbIH94K0PLt0cf9YnzLY1MSzCQ6/zG7+ rwbdWCWvK4Kk1pwMT61Z/yKyU9oXgPxTxE5Hvqbstf6V2b1bffrbgRc2xchamllZjGCE 79n6SKog73EXCBhbSxBsnlDNOE+MItCF8I1JX3jlg/roZ3Cw7E476cXyAc4eZNr9Ug7x bKIA== X-Forwarded-Encrypted: i=1; AJvYcCVW5gjg9ffj85Y3fg+NYagOJMJTIwJ46cdPJU93+70jUvvwpZHRnzwLGmo8pBEP1/bXTWJ1VgVCMi1I0jPE+k42TiWbOBcd0qPeI6/s6/UzE7FI9+E= X-Gm-Message-State: AOJu0Yy2qtjdQI4Y95jHWDLPn8cybOrqE2Z7TV69wh8NkkLYMbQKQ+OT AnHfPJ+F1acVHvFzs5UZouFs3KepO9nn6xYeKCcs356rgnyiu6Iw8pQQwWqggSOaDB/0kRbif72 McWlytvyBOhjY6oy+/EpQ2hy3NA== X-Google-Smtp-Source: AGHT+IGHvEApjIEO0DRVEt1Bw/UBZ1HmWAyKiDAFHhRF+TTiaNI0l7ccuCy8aYTQBRfw/ptwRlzeTLQxeA4pxCCDt3Q= X-Received: from sebkvm.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:cd5]) (user=sebastianene job=sendgmr) by 2002:a5d:5a8e:0:b0:345:e93b:37fc with SMTP id bp14-20020a5d5a8e000000b00345e93b37fcmr82wrb.0.1712675965766; Tue, 09 Apr 2024 08:19:25 -0700 (PDT) Date: Tue, 9 Apr 2024 15:19:08 +0000 Mime-Version: 1.0 X-Mailer: git-send-email 2.44.0.478.gd926399ef9-goog Message-ID: <20240409151908.541589-1-sebastianene@google.com> Subject: [PATCH] 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, vdonnefort@google.com 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-20240409_081928_933090_363737AE X-CRM114-Status: GOOD ( 16.28 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 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 --- arch/arm64/kvm/hyp/nvhe/ffa.c | 49 +++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/arch/arm64/kvm/hyp/nvhe/ffa.c b/arch/arm64/kvm/hyp/nvhe/ffa.c index 320f2eaa14a9..72fc365bc7a8 100644 --- a/arch/arm64/kvm/hyp/nvhe/ffa.c +++ b/arch/arm64/kvm/hyp/nvhe/ffa.c @@ -67,6 +67,7 @@ struct kvm_ffa_buffers { */ static struct kvm_ffa_buffers hyp_buffers; static struct kvm_ffa_buffers host_buffers; +static u32 ffa_version; static void ffa_to_smccc_error(struct arm_smccc_res *res, u64 ffa_errno) { @@ -640,6 +641,49 @@ static bool do_ffa_features(struct arm_smccc_res *res, return true; } +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 off, count, sz, buf_sz; + + hyp_spin_lock(&host_buffers.lock); + if (!host_buffers.rx) { + ffa_to_smccc_res(res, FFA_RET_INVALID_PARAMETERS); + 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 (ffa_version > FFA_VERSION_1_0) { + buf_sz = sz = res->a3; + if (sz > sizeof(struct ffa_partition_info)) + buf_sz = sizeof(struct ffa_partition_info); + } else { + /* FFA_VERSION_1_0 lacks the size in the response */ + buf_sz = sz = 8; + } + + WARN_ON((count - 1) * sz + buf_sz > PAGE_SIZE); + for (off = 0; off < count * sz; off += sz) + memcpy(host_buffers.rx + off, hyp_buffers.rx + off, buf_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; @@ -686,6 +730,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_PARTITION_INFO_GET: + do_ffa_part_get(&res, host_ctxt); + break; } if (ffa_call_supported(func_id)) @@ -726,6 +773,8 @@ int hyp_ffa_init(void *pages) if (FFA_MAJOR_VERSION(res.a0) != 1) return -EOPNOTSUPP; + ffa_version = res.a0; + arm_smccc_1_1_smc(FFA_ID_GET, 0, 0, 0, 0, 0, 0, 0, &res); if (res.a0 != FFA_SUCCESS) return -EOPNOTSUPP; -- 2.44.0.478.gd926399ef9-goog _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel