From patchwork Wed Nov 16 17:03:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quentin Perret X-Patchwork-Id: 13045598 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 239E1C4332F for ; Wed, 16 Nov 2022 17:06:40 +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=otLz3A53awwLAZO7R72N6IWREF41Tyky70WBKR/+7cw=; b=anfdP/F36X6d2JW6k0FeSWut0c sM8dPp9qp0taTFzos7Pb7pleo9WlO940UeiHMQPu1aMHqhlRSNQuQn2kWW88DeKY/w/7YlwujAvIu 4d4SEuYPUL0sevXgnruJQynZINMeSgRhoEeDEy3SJrpj6cuFhJe2x1ZdWK6m16kZw1cfgk6PwsSEI 3CO/DmaDhRZH8D5YRfCEioasBCu2Dp2d7AUdhtzxHtNPjXzQIudoLweDZr+myMMukZnVn6/+7sYqd Yu1cpw6auJZav29C2T3k1nkFdl73THsTXs1E7MFss/Od36UxLugViEaTRXVqkDQ0NPhZTouxEEpaH TymPV4jg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ovLqz-006F1p-F7; Wed, 16 Nov 2022 17:05:37 +0000 Received: from mail-yb1-xb49.google.com ([2607:f8b0:4864:20::b49]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ovLpK-006Dyc-Qq for linux-arm-kernel@lists.infradead.org; Wed, 16 Nov 2022 17:03:56 +0000 Received: by mail-yb1-xb49.google.com with SMTP id e189-20020a25e7c6000000b006e37f21e689so6461217ybh.10 for ; Wed, 16 Nov 2022 09:03:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=IGAnxq8TxsaiJ4rE+mUN7BVSpa7cDNjlDGASV4bWpCs=; b=WJwAIwpyllGWtU5Y33F3Liqf/YIvtoOmru97wtImoiBp3Nn+xEqI6tv0y2+K8Y7cd8 YfsCJHf+g7pz4Ql+A0xh0aj+hrJ3JREtrpdk3cKf9lbVimZUCy1iAsJ5cwZHBLNJRolK 5jQqTJEtMgZ86xyOJjcSpBktYOO7HT4+lfBK2eT41evfRAQV5Cf+m1iZqzrGhPIW8RVp aEvLZXtdDp8b0NVmT8T9eYdv5M0+GP80sE6m6X621AVRDbLPf0YYJdjQI5PwhOf6h3Kz 88A+3FNo2ZLDA3i4G6zrNrfv1BzdATpngxJnltogw/VIaQjQM3T2MaxhaGjR9j0UuV7A 0l0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=IGAnxq8TxsaiJ4rE+mUN7BVSpa7cDNjlDGASV4bWpCs=; b=W5lkwtxWp9iu2YVTm0bkE2Po2uzySgiBIa1hXKWzT1i9hoL8QbVBgyB6RLOGmOXcDm jkAAQ9MRfZZJVsf7nZlixWjosN8sdkA9vCXuzupDpIVsjeLWdQvpsKREnmF3uTNrrOqW ZLCl872XIZ0OVUYkfiBu2VKNLj7dw2nS3ubp8Lr366tOuoDcGy1xZo80BOJ1pLsfzBQ9 py7D+O7BQ8KD/gZif2RK/B878AIkq6mpsHUD7etl7+M5kcjuTfnrNTaqZrOEpNiTO27i K2DSdEmkZcVGUTI5mc9wxniiM0PYVhXORknY0BuWftnwfgBhoLGRd8BO/v3fQ/4c8WWb Tytw== X-Gm-Message-State: ACrzQf120qKAx8ficLKWdxYqLfJwQwETvvm4JdQW+llT985+qWhk29L4 f44I12plSk/1Fwk6J/6H624keJqtbGa5 X-Google-Smtp-Source: AMsMyM6LpibcCa3tAvXcPcc9JdUaf9/9fnPypWpp5sDfstjX9mSh84f9tOoNKg6gUA/4AaKj5a/N2Zknhusm X-Received: from big-boi.c.googlers.com ([fda3:e722:ac3:cc00:31:98fb:c0a8:129]) (user=qperret job=sendgmr) by 2002:a0d:f647:0:b0:36f:f93c:c543 with SMTP id g68-20020a0df647000000b0036ff93cc543mr60967412ywf.325.1668618230643; Wed, 16 Nov 2022 09:03:50 -0800 (PST) Date: Wed, 16 Nov 2022 17:03:28 +0000 In-Reply-To: <20221116170335.2341003-1-qperret@google.com> Mime-Version: 1.0 References: <20221116170335.2341003-1-qperret@google.com> X-Mailer: git-send-email 2.38.1.431.g37b22c650d-goog Message-ID: <20221116170335.2341003-6-qperret@google.com> Subject: [PATCH 05/12] KVM: arm64: Handle FFA_FEATURES call from the host From: Quentin Perret To: Marc Zyngier , James Morse , Alexandru Elisei , Suzuki K Poulose , Oliver Upton , Catalin Marinas , Will Deacon , Sudeep Holla , Andrew Walbran Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org, kernel-team@android.com, qperret@google.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221116_090354_912760_98E1196E X-CRM114-Status: GOOD ( 13.58 ) 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 From: Fuad Tabba Filter out advertising unsupported features, and only advertise features and properties that are supported by the hypervisor proxy. Signed-off-by: Fuad Tabba Signed-off-by: Quentin Perret --- arch/arm64/kvm/hyp/nvhe/ffa.c | 44 +++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/arch/arm64/kvm/hyp/nvhe/ffa.c b/arch/arm64/kvm/hyp/nvhe/ffa.c index 969d72390844..d199f868583e 100644 --- a/arch/arm64/kvm/hyp/nvhe/ffa.c +++ b/arch/arm64/kvm/hyp/nvhe/ffa.c @@ -45,6 +45,16 @@ static void ffa_to_smccc_error(struct arm_smccc_res *res, u64 ffa_errno) }; } +static void ffa_to_smccc_res_prop(struct arm_smccc_res *res, int ret, u64 prop) +{ + if (ret == FFA_RET_SUCCESS) { + *res = (struct arm_smccc_res) { .a0 = FFA_SUCCESS, + .a2 = prop }; + } else { + ffa_to_smccc_error(res, ret); + } +} + static void ffa_set_retval(struct kvm_cpu_context *ctxt, struct arm_smccc_res *res) { @@ -89,6 +99,35 @@ static bool ffa_call_unsupported(u64 func_id) return false; } +static bool do_ffa_features(struct arm_smccc_res *res, + struct kvm_cpu_context *ctxt) +{ + DECLARE_REG(u32, id, ctxt, 1); + u64 prop = 0; + int ret = 0; + + if (ffa_call_unsupported(id)) { + ret = FFA_RET_NOT_SUPPORTED; + goto out_handled; + } + + switch (id) { + case FFA_MEM_SHARE: + case FFA_FN64_MEM_SHARE: + case FFA_MEM_LEND: + case FFA_FN64_MEM_LEND: + ret = FFA_RET_SUCCESS; + prop = 0; /* No support for dynamic buffers */ + goto out_handled; + default: + return false; + } + +out_handled: + ffa_to_smccc_res_prop(res, ret, prop); + return true; +} + bool kvm_host_ffa_handler(struct kvm_cpu_context *host_ctxt) { DECLARE_REG(u64, func_id, host_ctxt, 0); @@ -98,6 +137,10 @@ bool kvm_host_ffa_handler(struct kvm_cpu_context *host_ctxt) return false; switch (func_id) { + case FFA_FEATURES: + if (!do_ffa_features(&res, host_ctxt)) + return false; + goto out_handled; /* Memory management */ case FFA_FN64_RXTX_MAP: case FFA_RXTX_UNMAP: @@ -114,6 +157,7 @@ bool kvm_host_ffa_handler(struct kvm_cpu_context *host_ctxt) return false; /* Pass through */ ffa_to_smccc_error(&res, FFA_RET_NOT_SUPPORTED); +out_handled: ffa_set_retval(host_ctxt, &res); return true; }