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 59A3DC77B73 for ; Wed, 19 Apr 2023 12:22: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:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Bz1Um4Vzktu2VxSMd9qXUIZ3C/vmIJK/87BjQwQi26I=; b=XAA6lq62lJt8Wy u2JGyIjpq5B3JGBvUyVLHHcNbe//DSJJ1b3Klv7DOx6i78f0nwPDVwEIvSO2H+aP+ZRVy4LzWvGRO 5L/zND7lbkdEaoj41z6dZOry1vMzBhfNiW2Rp/RIQDToQmvvvMfkhs7f7yMG5yxwjjgmovuOQ5Kwn mbkibU40y4w9HiBBjmVTRrpEZ4LvBNVl849eRCz2FPpeFqvwk05U679eL7ReLPttNdWDjicVKhx0o OosW23YITz57IcP/w6dLZtHK48U8Hc8TrmO/2FuCZW3iygHOwwodeA6XPw4HOjA2nosEFPTnxhOWD ZK5Ru13WUXkWLpv5vu3A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pp6og-005Km9-0N; Wed, 19 Apr 2023 12:21:42 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pp6oM-005KZu-1C for linux-arm-kernel@lists.infradead.org; Wed, 19 Apr 2023 12:21:23 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id E664A63E6C; Wed, 19 Apr 2023 12:21:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EF1F5C4339B; Wed, 19 Apr 2023 12:21:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1681906881; bh=2HmF/rrmNTLMvR62HDkjMR+nhULL3D8G/C1iWDUA6cM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RCuP8SSjnupsi9wKkrWB/Afy1vHyUEbNrFk5lbucjuBu8vn2aIC+Sxaa2a2p1Im0e doA/fahslm4t8e8mSq7yIIDi64ltRSYla0dfQZ7kZDd0UoC6EVqTqWz0OlNQPOf3H0 Nunorhv9QpX/pLc2HYQdL4RZ1wpQbUcSus4fu3qTm2AYI5RLpJWgFhCXNHfkIyr9iG eIjyhBtgWN3hI54aA0kw5y/bMwegGseangIt6dePe7398YvRsC2X8YhygBerHhVYTH 1BXApBx4VKiSJfzjQO5IzEcMdNOVMRqZeZka780f4IxCcCKDLZ+IMBbIi0DxZi8QE3 aULNU2e3Ag96Q== From: Will Deacon To: linux-arm-kernel@lists.infradead.org Cc: Will Deacon , Quentin Perret , Marc Zyngier , Oliver Upton , James Morse , Alexandru Elisei , Suzuki K Poulose , Sudeep Holla , Sebastian Ene , Fuad Tabba , kvmarm@lists.linux.dev, kernel-team@android.com Subject: [PATCH v2 08/10] KVM: arm64: Handle FFA_MEM_LEND calls from the host Date: Wed, 19 Apr 2023 13:20:49 +0100 Message-Id: <20230419122051.1341-9-will@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20230419122051.1341-1-will@kernel.org> References: <20230419122051.1341-1-will@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230419_052122_486830_E28FBEDA X-CRM114-Status: GOOD ( 13.99 ) 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 FFA_MEM_LEND calls from the host by treating them identically to FFA_MEM_SHARE calls for the purposes of the host stage-2 page-table, but forwarding on the original request to EL3. Signed-off-by: Will Deacon --- arch/arm64/kvm/hyp/nvhe/ffa.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/arch/arm64/kvm/hyp/nvhe/ffa.c b/arch/arm64/kvm/hyp/nvhe/ffa.c index b23e3869ce63..45a2726d73ff 100644 --- a/arch/arm64/kvm/hyp/nvhe/ffa.c +++ b/arch/arm64/kvm/hyp/nvhe/ffa.c @@ -116,10 +116,10 @@ static int spmd_unmap_ffa_buffers(void) return res.a0 == FFA_SUCCESS ? FFA_RET_SUCCESS : res.a2; } -static void spmd_mem_share(struct arm_smccc_res *res, u32 len, u32 fraglen) +static void spmd_mem_xfer(struct arm_smccc_res *res, u64 func_id, u32 len, + u32 fraglen) { - arm_smccc_1_1_smc(FFA_FN64_MEM_SHARE, - len, fraglen, + arm_smccc_1_1_smc(func_id, len, fraglen, 0, 0, 0, 0, 0, res); } @@ -317,8 +317,9 @@ static int ffa_host_unshare_ranges(struct ffa_mem_region_addr_range *ranges, return ret; } -static void do_ffa_mem_share(struct arm_smccc_res *res, - struct kvm_cpu_context *ctxt) +static __always_inline void do_ffa_mem_xfer(const u64 func_id, + struct arm_smccc_res *res, + struct kvm_cpu_context *ctxt) { DECLARE_REG(u32, len, ctxt, 1); DECLARE_REG(u32, fraglen, ctxt, 2); @@ -329,6 +330,9 @@ static void do_ffa_mem_share(struct arm_smccc_res *res, int ret = 0; u32 offset; + BUILD_BUG_ON(func_id != FFA_FN64_MEM_SHARE && + func_id != FFA_FN64_MEM_LEND); + if (addr_mbz || npages_mbz || fraglen > len || fraglen > KVM_FFA_MBOX_NR_PAGES * PAGE_SIZE) { ret = FFA_RET_INVALID_PARAMETERS; @@ -378,7 +382,7 @@ static void do_ffa_mem_share(struct arm_smccc_res *res, if (ret) goto out_unlock; - spmd_mem_share(res, len, fraglen); + spmd_mem_xfer(res, func_id, len, fraglen); if (res->a0 != FFA_SUCCESS) { WARN_ON(ffa_host_unshare_ranges(reg->constituents, reg->addr_range_cnt)); @@ -502,11 +506,15 @@ bool kvm_host_ffa_handler(struct kvm_cpu_context *host_ctxt) goto out_handled; case FFA_MEM_SHARE: case FFA_FN64_MEM_SHARE: - do_ffa_mem_share(&res, host_ctxt); + do_ffa_mem_xfer(FFA_FN64_MEM_SHARE, &res, host_ctxt); goto out_handled; case FFA_MEM_RECLAIM: do_ffa_mem_reclaim(&res, host_ctxt); goto out_handled; + case FFA_MEM_LEND: + case FFA_FN64_MEM_LEND: + do_ffa_mem_xfer(FFA_FN64_MEM_LEND, &res, host_ctxt); + goto out_handled; } if (ffa_call_supported(func_id)) -- 2.40.0.634.g4ca3ef3211-goog _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel