From patchwork Thu Jun 13 13:20:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Ene X-Patchwork-Id: 13696797 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 CA929C27C4F for ; Thu, 13 Jun 2024 13:21:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:Cc:To:From: Subject:Message-ID:References:Mime-Version:In-Reply-To:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=85ojJxkNYXxh97Mo9k1gfrYfK0JeNvYJnaS4+QvvHCA=; b=sksaWmyemLbPt0YETBVTg/UAVF JgEKuWGgyybmv7M03Fw5TH5h7lTgfyUhLyPyaUOcryR0MM7MLrPbdom2yfxElcf+DM87TYaEAuDvq zh4vDVU45pmdlwfrX3JMuqjMgChwe4ifcHubB91QvtENJ2Nf47hufPO5ehRVP0inFgAFLRz9j3aeU 0sztxAHOJXGU2L0f/Y8OACiajI7f2qUbw28qy1+LEmhCQ0MsdEvVosCrpKFnsuVLEbPrfawnNePc4 KxFxoVyR/jZ2Q4OrNGyikH4A6NiAJANz4d21wiQx5TCsoekaYVYBZ37IWhzQHPxUUxno02CGwpWEo S06b9gYQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sHkO8-0000000GgZ4-1NfA; Thu, 13 Jun 2024 13:21:12 +0000 Received: from mail-wm1-x34a.google.com ([2a00:1450:4864:20::34a]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sHkO3-0000000GgTB-0i2t for linux-arm-kernel@lists.infradead.org; Thu, 13 Jun 2024 13:21:08 +0000 Received: by mail-wm1-x34a.google.com with SMTP id 5b1f17b1804b1-421f3b7b27eso9478455e9.1 for ; Thu, 13 Jun 2024 06:21:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1718284862; x=1718889662; 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=85ojJxkNYXxh97Mo9k1gfrYfK0JeNvYJnaS4+QvvHCA=; b=D6oJKZs/ijUdV6ImAib6HCiu/AZtVTtdtyoOIX/F+ReYM+K9t71XqREYgGIloHblAF Ww7+0/htAfq2XHjZC06RVSY+0x5eWxOvwKumOD9DYJZVz4Jou7ROQ4QMxgC/Eo8duGR7 smX59ePKRbQ0RqF3RYRw1aj1H+u8h0vA3QAy7gsdNBT6UOYFEtgGYpMCysSrxzuz+InN OtG9x7inae9+R4FRcFQLWDs5rMxZRd2RyxzVzQn1gssNQfhDb1Qj3GAQGFBBNsnn/MaC RfS/VtgBFRfU2rKTHSw5EMcXooaORPYfzIsNgVYVuCwFfRxerOpThax0yLKgWTgJ2s9R 9Pcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718284862; x=1718889662; 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=85ojJxkNYXxh97Mo9k1gfrYfK0JeNvYJnaS4+QvvHCA=; b=J2Bm6CikLD2dptCiGmZan2vwgazyf+zIQoh2a6NkD2jHOcxiB8RTsFLssgnI1y/D4W DvB0bn3GlXYt/bUpOOH1t2QZgs/96G3RaokQLp1WlLfhORWf9IR1f7xCFNKw8AeVj5Hp ZLLj5BJsOU0nxVKSfmd7jGRGYdOLT6BAD+WJ/DPAYA53imahJHNQpW9rDjOj0Amqvn29 ddXVPI+BPTlTdulwkdyl00yv4FinX30RE0kKG6LMp8AkXmiokza3oRfJdmsPAeTMyawa 7HpHgdbGFGs2vXpQF2NWjteCwrBaYJwPq+TMpqk+gpwmHKd37DvVHNUSql/UbxngtcY6 e4TQ== X-Forwarded-Encrypted: i=1; AJvYcCU1zBTk7f2uqHZ8uavrSPIGnRb3F0g157dKTn3ZQeiSQf2DfMedkeQXKfINz9TifSWMQ4Vu1uZJsEA1g5fMckWN/521v/yr8qVwdA+JENso3hNBq3o= X-Gm-Message-State: AOJu0YyiBv8vVY2Q60HYfmWxnLqzl/NRDN12J4OVf0WEZ6pmMydKVZnD zxFuFT+5pXbLhnLuQCJnIMju/I3gV8E4mPBfo8v3rIqMsVCQ9US1xcCJcEICWEhA73yypyMmxf1 k+2bVTDxM7MA7foKxqCFRAdRxdg== X-Google-Smtp-Source: AGHT+IEGmcAxjB2wRcZVPwbydQye9U+Lfxf52+t870ONm/t/2enRlN5yWNU9fxSxYfGOvDAZatwr0XKHsQNvtwSMq2I= X-Received: from sebkvm.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:cd5]) (user=sebastianene job=sendgmr) by 2002:a5d:4e09:0:b0:354:f4a4:6d35 with SMTP id ffacd0b85a97d-35fe8928988mr10512f8f.13.1718284862437; Thu, 13 Jun 2024 06:21:02 -0700 (PDT) Date: Thu, 13 Jun 2024 13:20:35 +0000 In-Reply-To: <20240613132035.1070360-1-sebastianene@google.com> Mime-Version: 1.0 References: <20240613132035.1070360-1-sebastianene@google.com> X-Mailer: git-send-email 2.45.2.505.gda0bf45e8d-goog Message-ID: <20240613132035.1070360-5-sebastianene@google.com> Subject: [PATCH v3 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-20240613_062107_242321_2E641286 X-CRM114-Status: GOOD ( 15.11 ) 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 Tested-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 4eaef673e98d..fdb63b7857ec 100644 --- a/arch/arm64/kvm/hyp/nvhe/ffa.c +++ b/arch/arm64/kvm/hyp/nvhe/ffa.c @@ -457,7 +457,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; @@ -536,7 +536,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 @@ -844,7 +844,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; @@ -864,7 +864,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;