From patchwork Wed Mar 26 11:38:59 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Ene X-Patchwork-Id: 14029998 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 683E9C36008 for ; Wed, 26 Mar 2025 11:42: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: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=GXpneY+J8yPscOLP7jhAaiNlTKvyhknsIBSzw8J5v1o=; b=1JF6Ez6iW3LwSuJhZJ27NFzk2q ygQZYJZVe/Ir922LoHApzRfXCBYGew+sUWl0zto9xeFt4o1zxS/sm5K7/NTXbqBCdBBi540ILopIK WR1Gi1bOgWX6IByHMXIKCREc6mXsr+rQKhzKvDyzgsKU0fxYqIXafF+M4waQqbBQRJz4I7xr2RT/O I/HohaopjKyeXWTv4+yNkxl446zhkOrYzDYu7kGGHaqbarLgz9ULNtUJ8J3VMmlMSD2x9aaQwEIcn xMqO6ouT59XsIXB212uI+BrEnDQrg/CGaxkuCkhWRYExPCSd6OmowKpqleJvd2W4Tc8p770B4kl0i gg2Pef9Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.1 #2 (Red Hat Linux)) id 1txP9b-00000008O8w-3xGL; Wed, 26 Mar 2025 11:42:39 +0000 Received: from mail-wr1-x44a.google.com ([2a00:1450:4864:20::44a]) by bombadil.infradead.org with esmtps (Exim 4.98.1 #2 (Red Hat Linux)) id 1txP6D-00000008NfL-0UlU for linux-arm-kernel@lists.infradead.org; Wed, 26 Mar 2025 11:39:10 +0000 Received: by mail-wr1-x44a.google.com with SMTP id ffacd0b85a97d-39142ce2151so2810685f8f.1 for ; Wed, 26 Mar 2025 04:39:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1742989147; x=1743593947; 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=GXpneY+J8yPscOLP7jhAaiNlTKvyhknsIBSzw8J5v1o=; b=pwDSJfUg/Azt7SGVb2qkKeoU5AF5d3XX2/Hq1GDT4I8sV51bhWGb9BGGNwRiIepQMS ZzQO2mV5S+jEPgoDH7Lk0y/yUOpl/LXYbyx57lMA4s4qgw4q5CysvoX6bvyPlzeijG2/ eUNqlBhilQ8d05EH77xuvh2HMcOXGblm8bpTGpSUV/xlz8Bo1BTQgEFKH/H8/fIxbDAS XdUPMRmjz63yvkrpFgiQt9F9twfvKd6D367d07qZJG1MtwhINiOb8hrN1vvvYXt6t3lK SCNVzxgQ0sySQhydWOqVjvqUBzuByJMANPHxg6RxR5oiZs7EAuvnrfTe9m7QTlMf3kR7 KsGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742989147; x=1743593947; 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=GXpneY+J8yPscOLP7jhAaiNlTKvyhknsIBSzw8J5v1o=; b=s5+eulmreTbrRanQPGRabCuiRuG3zV6wATTjkiuT/DIRdMewCPajHYDT1uYGye9PCm Y4mefek/cKuGd8Xtl2W6rMZ/TmPt7cgHrOlFZXSF0wPZskZ27zVdwolOp2/w/Gl/h+rZ gAUkU2sDLtuIVN/SWDAkRXMrYRY1oKpuxGDzXR7BpM+hWxOapov88gHnymmr5EMvOjjA F1jKdLgSARn9yu1TQO+IX2B3j7lqvB0zjsBN4V7fb/PnAvBtRN24tKEqzqWJTg0Dzn9L vnfD4LYfGO9tm34GTopZ9i0a0hiFgvA1oDQ/0bAVOmONb/y+FyyphxdQrRgRSKvdQFpN 3VjA== X-Forwarded-Encrypted: i=1; AJvYcCVmyfC+WeZlHGvnghRBRrV7fsapeVpk8b9kmkURjOMNk1acfth15aZ0l2Ttuc3A2La/PB579jd/RB5GVE6eA266@lists.infradead.org X-Gm-Message-State: AOJu0Yz3Oo5+3ynm050fGeGaFvQOUyukOtykvO+OOKDq9gnNrOoyVHQo /j8U6N9E2ff/p1r7S0fFaz6kaxcrsyCpSt2jz+pG0uMNClJGICrufess2BS/Ar/NBL6I9Sx9aRa ayHgU40YWIFW4b8BYRiywfCHJIw== X-Google-Smtp-Source: AGHT+IGmIIwQP0bm2M7IlxhsZXhvvis8SEyv8YAEqMxAp7vxQ4ixz0CF6DGy8JLA3pEu/5AAb31WyHaG1CNXPPwbNdA= X-Received: from wrxt15.prod.google.com ([2002:a05:6000:1cf:b0:39a:bf28:66d8]) (user=sebastianene job=prod-delivery.src-stubby-dispatcher) by 2002:a5d:59a6:0:b0:390:f6aa:4e72 with SMTP id ffacd0b85a97d-3997f8fabdbmr17862518f8f.18.1742989146887; Wed, 26 Mar 2025 04:39:06 -0700 (PDT) Date: Wed, 26 Mar 2025 11:38:59 +0000 In-Reply-To: <20250326113901.3308804-1-sebastianene@google.com> Mime-Version: 1.0 References: <20250326113901.3308804-1-sebastianene@google.com> X-Mailer: git-send-email 2.49.0.395.g12beb8f557-goog Message-ID: <20250326113901.3308804-2-sebastianene@google.com> Subject: [PATCH v4 1/3] KVM: arm64: Use the static initializer for the version lock From: Sebastian Ene To: catalin.marinas@arm.com, joey.gouly@arm.com, maz@kernel.org, oliver.upton@linux.dev, sebastianene@google.com, snehalreddy@google.com, sudeep.holla@arm.com, suzuki.poulose@arm.com, vdonnefort@google.com, will@kernel.org, yuzenghui@huawei.com, qperret@google.com Cc: kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kernel-team@android.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250326_043909_159248_92160E89 X-CRM114-Status: GOOD ( 11.83 ) 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 Replace the definition of the hypervisor version lock with a static initializer. Signed-off-by: Sebastian Ene Acked-by: Will Deacon Reviewed-by: Quentin Perret --- arch/arm64/kvm/hyp/nvhe/ffa.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/arch/arm64/kvm/hyp/nvhe/ffa.c b/arch/arm64/kvm/hyp/nvhe/ffa.c index e433dfab882a..6df6131f1107 100644 --- a/arch/arm64/kvm/hyp/nvhe/ffa.c +++ b/arch/arm64/kvm/hyp/nvhe/ffa.c @@ -69,7 +69,7 @@ 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 DEFINE_HYP_SPINLOCK(version_lock); static void ffa_to_smccc_error(struct arm_smccc_res *res, u64 ffa_errno) { @@ -911,6 +911,5 @@ int hyp_ffa_init(void *pages) .lock = __HYP_SPIN_LOCK_UNLOCKED, }; - version_lock = __HYP_SPIN_LOCK_UNLOCKED; return 0; } From patchwork Wed Mar 26 11:39:00 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Ene X-Patchwork-Id: 14030000 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 2554CC36008 for ; Wed, 26 Mar 2025 11:44:38 +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=D8ajkpiQTqtR9VJRMGj5F4HjopRvHwcyjLs80bQ1Ix0=; b=boQwCpkVWnX+p4IzqJ68fY7BUp 6ayZRalVeRUfb2inNegI8pQcZ+KsjWpCzuwOtKUUzV45/NDrWSWeCTCSaBHLr6OR72hXr/4B+dqqZ a19WfiktleX8uJjCdqE7F/5JjacI/y3szW1DNvJJtVOTnmAFjUlc2EGO/XcA4Nvv33uJcNokZVygb r5VomlUxKv7BwBK35Vy1fbaXf2TQhOatoZOZE7WXLwW4gE0aECQZO/Peg+DiArh6PkBFX9o4RVbwE E1vVHsngAkHd1suK2ftxivBL2IYDQsIklBnaXq798LEGmnjEwcE4Mvde6WZrBZEQvuhDMt9jrRd2U 2blRv+1g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.1 #2 (Red Hat Linux)) id 1txPBJ-00000008OOP-31fS; Wed, 26 Mar 2025 11:44:25 +0000 Received: from mail-wr1-x449.google.com ([2a00:1450:4864:20::449]) by bombadil.infradead.org with esmtps (Exim 4.98.1 #2 (Red Hat Linux)) id 1txP6F-00000008Nfs-0nES for linux-arm-kernel@lists.infradead.org; Wed, 26 Mar 2025 11:39:12 +0000 Received: by mail-wr1-x449.google.com with SMTP id ffacd0b85a97d-3912d5f6689so3597631f8f.1 for ; Wed, 26 Mar 2025 04:39:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1742989149; x=1743593949; 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=D8ajkpiQTqtR9VJRMGj5F4HjopRvHwcyjLs80bQ1Ix0=; b=1QaLVYJT/x0vbwIV65yurqenm5MaLZzzML2SWB2dOvtraXoRcP0Qzx3OshhGfkzql1 PFBuRPMRCohj0nDRXY6o50DraozGvo3tbYzTkEvOYsdk04HdjRJux9UHHJvl46RaLXpu D3CjNEBrCuHsAz1okI6VWKtHe+cEYWuA/LWk8utQRZCEA6Hr+dUN4LNxX8bUH0q+Ab+o 2DqXNMo/tfEGCjKsee5fbz5Z/CnZDkKqUTTD70b+AefKv40r0K+9XvGBp3pcLWTyzX9t mbaWxm30a8G98odPeLogLGRKiWNdimvtxs3DtLixtULOH82mUIv/O9CDAr7ApHG4v+cX QmGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742989149; x=1743593949; 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=D8ajkpiQTqtR9VJRMGj5F4HjopRvHwcyjLs80bQ1Ix0=; b=jutl2rlKqBUnjUoYeNLQuL0z6m9EORGNxmepNKzU6lVcYOQB2bAyVdtTZLjvnS1sDP 33VBDXLiZFx78fT04aEK7bAs87wcL1eXdJWWNd6ZITsnqZYKYH8hQrTeapy9w5iDm9Rr tesgVzkpEXOIxj43PTBHyP/Jv5pmH4c8CY30c8G/AFhHmlfWDyNZVoMnGATjstj/AvOG QQNfQR3wt7zIv+m+kSgbmxO/sxT+9LRufza3UyRxA9DFWoay7JcdATIqp8cF5qhp9MUJ AuuO+TkfmBbSq1oJXXM/JftOBmzWrrgHpkMUlALg6rkm127DUgKI5D/VP4pOinPIS7e8 +e9Q== X-Forwarded-Encrypted: i=1; AJvYcCXdJG1anad7b4gFoVMXzUuJG7NWzo3CzxCJIuPlncZGoncAtdiuaW6PdCpAjrqq8Ez78+8YThhClWsEc6U+r3Sm@lists.infradead.org X-Gm-Message-State: AOJu0Yz3pNoSx0iSxOsS2dslP4Zu8+EBsb6LCnDtwAZx//hctTrt9J/o Vap1HstD9eU2j6aNamoIolpj8shLd5U+5iPpLCLv9b9LSTolOMu8NtO1K9ce0vJLXxmnuk7/CVI i/B4AnN+0tOn0nnFu/gOdpOiVqw== X-Google-Smtp-Source: AGHT+IGt24UV1F1gn3DBiJA89bM8xyxzcFBTUpe7uN0vVj4Q/IEqACUFIlVuS9cdYKWGLRea4OJ8IMRq4qWmWhdzPh4= X-Received: from wmqe22.prod.google.com ([2002:a05:600c:4e56:b0:43d:8f:dd29]) (user=sebastianene job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6000:1882:b0:391:12a5:3c95 with SMTP id ffacd0b85a97d-3997f91202dmr20021811f8f.22.1742989149185; Wed, 26 Mar 2025 04:39:09 -0700 (PDT) Date: Wed, 26 Mar 2025 11:39:00 +0000 In-Reply-To: <20250326113901.3308804-1-sebastianene@google.com> Mime-Version: 1.0 References: <20250326113901.3308804-1-sebastianene@google.com> X-Mailer: git-send-email 2.49.0.395.g12beb8f557-goog Message-ID: <20250326113901.3308804-3-sebastianene@google.com> Subject: [PATCH v4 2/3] firmware: arm_ffa: Move the ffa_to_linux definition to the ffa header From: Sebastian Ene To: catalin.marinas@arm.com, joey.gouly@arm.com, maz@kernel.org, oliver.upton@linux.dev, sebastianene@google.com, snehalreddy@google.com, sudeep.holla@arm.com, suzuki.poulose@arm.com, vdonnefort@google.com, will@kernel.org, yuzenghui@huawei.com, qperret@google.com Cc: kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kernel-team@android.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250326_043911_228897_F7A1627E X-CRM114-Status: GOOD ( 16.67 ) 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 Keep the ffa_to_linux error map in the header and move it away from the arm ffa driver to make it accessible for other components. Signed-off-by: Sebastian Ene Reviewed-by: Sudeep Holla Reviewed-by: Quentin Perret --- drivers/firmware/arm_ffa/driver.c | 26 -------------------------- include/linux/arm_ffa.h | 27 +++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 26 deletions(-) diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c index 2c2ec3c35f15..3f88509a15b7 100644 --- a/drivers/firmware/arm_ffa/driver.c +++ b/drivers/firmware/arm_ffa/driver.c @@ -61,30 +61,6 @@ static ffa_fn *invoke_ffa_fn; -static const int ffa_linux_errmap[] = { - /* better than switch case as long as return value is continuous */ - 0, /* FFA_RET_SUCCESS */ - -EOPNOTSUPP, /* FFA_RET_NOT_SUPPORTED */ - -EINVAL, /* FFA_RET_INVALID_PARAMETERS */ - -ENOMEM, /* FFA_RET_NO_MEMORY */ - -EBUSY, /* FFA_RET_BUSY */ - -EINTR, /* FFA_RET_INTERRUPTED */ - -EACCES, /* FFA_RET_DENIED */ - -EAGAIN, /* FFA_RET_RETRY */ - -ECANCELED, /* FFA_RET_ABORTED */ - -ENODATA, /* FFA_RET_NO_DATA */ - -EAGAIN, /* FFA_RET_NOT_READY */ -}; - -static inline int ffa_to_linux_errno(int errno) -{ - int err_idx = -errno; - - if (err_idx >= 0 && err_idx < ARRAY_SIZE(ffa_linux_errmap)) - return ffa_linux_errmap[err_idx]; - return -EINVAL; -} - struct ffa_pcpu_irq { struct ffa_drv_info *info; }; @@ -238,8 +214,6 @@ static int ffa_features(u32 func_feat_id, u32 input_props, return 0; } -#define PARTITION_INFO_GET_RETURN_COUNT_ONLY BIT(0) - /* buffer must be sizeof(struct ffa_partition_info) * num_partitions */ static int __ffa_partition_info_get(u32 uuid0, u32 uuid1, u32 uuid2, u32 uuid3, diff --git a/include/linux/arm_ffa.h b/include/linux/arm_ffa.h index 74169dd0f659..cdaa162060f4 100644 --- a/include/linux/arm_ffa.h +++ b/include/linux/arm_ffa.h @@ -223,6 +223,9 @@ 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) +/* Return the count of partitions deployed in the system */ +#define PARTITION_INFO_GET_RETURN_COUNT_ONLY BIT(0) + /* FFA transport related */ struct ffa_partition_info { u16 id; @@ -475,4 +478,28 @@ struct ffa_ops { const struct ffa_notifier_ops *notifier_ops; }; +static const int ffa_linux_errmap[] = { + /* better than switch case as long as return value is continuous */ + 0, /* FFA_RET_SUCCESS */ + -EOPNOTSUPP, /* FFA_RET_NOT_SUPPORTED */ + -EINVAL, /* FFA_RET_INVALID_PARAMETERS */ + -ENOMEM, /* FFA_RET_NO_MEMORY */ + -EBUSY, /* FFA_RET_BUSY */ + -EINTR, /* FFA_RET_INTERRUPTED */ + -EACCES, /* FFA_RET_DENIED */ + -EAGAIN, /* FFA_RET_RETRY */ + -ECANCELED, /* FFA_RET_ABORTED */ + -ENODATA, /* FFA_RET_NO_DATA */ + -EAGAIN, /* FFA_RET_NOT_READY */ +}; + +static inline int ffa_to_linux_errno(int errno) +{ + int err_idx = -errno; + + if (err_idx >= 0 && err_idx < ARRAY_SIZE(ffa_linux_errmap)) + return ffa_linux_errmap[err_idx]; + return -EINVAL; +} + #endif /* _LINUX_ARM_FFA_H */ From patchwork Wed Mar 26 11:39:01 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Ene X-Patchwork-Id: 14030001 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 7C822C36008 for ; Wed, 26 Mar 2025 11:46:20 +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=GHf91QhT51iYy83lJisFmODA+pFXdAkAB/GuCBpC2zk=; b=vKfVeH68qP7Qpie2/MoxJsXTvl bS6UbANxzGXxPe5P68+TJ8zL6DhJnNMT4Ei1dKlMtc+YCspoPUU6IkiUfMWeT61e1spYw7r1axjUD 3R99sbJUYAK+nd4gCFvzTlXJ5UAllNdEBBnM5+LbuvvmmSKnn8dRbW4V3Ql6Pfadm/T3WpuFMaBGC rXnaIr7o0lFl+mPafTPNvck6okPgDyYNsb3phPQo0HXqYMLlLBErsCMv59R0kaNSCYK7BLM8LTaZ4 JAlMn4parGW4FY+a4sZ9nUmpLVVDLydJHpya6Fl4Fy4ckz1ELntukChuBA5+nKTfGXS/lVWngbouD xwV69KcA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.1 #2 (Red Hat Linux)) id 1txPD0-00000008OdA-1at9; Wed, 26 Mar 2025 11:46:10 +0000 Received: from mail-wm1-x34a.google.com ([2a00:1450:4864:20::34a]) by bombadil.infradead.org with esmtps (Exim 4.98.1 #2 (Red Hat Linux)) id 1txP6H-00000008Ngg-1SZF for linux-arm-kernel@lists.infradead.org; Wed, 26 Mar 2025 11:39:14 +0000 Received: by mail-wm1-x34a.google.com with SMTP id 5b1f17b1804b1-43d5ca7c86aso24393245e9.0 for ; Wed, 26 Mar 2025 04:39:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1742989151; x=1743593951; 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=GHf91QhT51iYy83lJisFmODA+pFXdAkAB/GuCBpC2zk=; b=sbk0bLAdaRP9sM77T/hO3ZaARWmWJhVnTK/cZaUYgB1+hgu9jGeOCJxuyD9q+q9IEi dCdvZ5vw/SkVIGyLPB7ZB1B9X1YLRWcCwM+h19DvEGJtOa5zsTK5jKAKrJaIhmkHhsEL iedGdYLL6DsnHu2jzc7rZvtN49y0UrOgfSJWSVdBiXg0MXQBcJGQRDWG1qwSVxWpTkGv SV7/blOavQLvVC4/KdcRJw7eDhy4uAOzmF9WMgKSm+5ZZXnsAdcfqK12DskN6moh19Sb LJSHE9BtJ+biyI68fclI/BeZDoLjaq0lrtys9TPs7o8YRTeb3Nnx/70lUQPHR5Cs7jOG JR8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742989151; x=1743593951; 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=GHf91QhT51iYy83lJisFmODA+pFXdAkAB/GuCBpC2zk=; b=PvBkigUrY1UHdLi9CQCoWHEA1w0P6O3zQfs4a4OFa452+sRVYPZNH7Dkf7OurWxKOJ 34Ky30C75HWQGaFtqd7HJeukw9IGMS+y8k0Ojgz6K3lIo5Gw0ZFF3Vz28NX5BU7SXZ+h MakxfEycuHbuTT14cTEAznHJ0ZZuxHOkbfZAaAKEEQwdxtuiot/WG6ZyBxshRjHl6toN gAAkf5QUVRhrQ66inor9Tph4xcKoh9hwSI1RilHvJ2fJpElaGD9TI/tppat0Iqq5ojyO 8nPTEbgpNQR2YZyQfv1yoV3HUBkT0L9ap0NO2xU5k/xOWwez3p0B4TBCoH06HKK9pmW6 aE4Q== X-Forwarded-Encrypted: i=1; AJvYcCXngxdfypU4BxjalWQNqjXtMP+gPmxXAIhyOdt1UK0l0TSjgbH3EIR+PYjIUXsVnysmCVnoxT9ro5/VPZ3ranqd@lists.infradead.org X-Gm-Message-State: AOJu0YysZQ7EwQBpBuhmBEa0CJtJBO5otqA4ktkXueppZOwus9XGrzS6 kIpdi4tvluXnXPWM0CQ2HVFawFjZuRySbs4hy2qCD3Z3Eq3AIaTK0FXjN8z4pHEru94jfiwKUSE FaKIw8bl9o2/sn7gCqrcBdMunHA== X-Google-Smtp-Source: AGHT+IHs0QnGDLw9n/4cRwsa7oyAsEcllQx68V0oWKnfOqB/3TAlLPJ14NKv8m2ojEKJA3YBjubucjAO0uNkMu+4Lz4= X-Received: from wrck14.prod.google.com ([2002:a5d:524e:0:b0:390:e325:456e]) (user=sebastianene job=prod-delivery.src-stubby-dispatcher) by 2002:a5d:6c61:0:b0:390:f902:f973 with SMTP id ffacd0b85a97d-3997f8f5c08mr18860296f8f.8.1742989151526; Wed, 26 Mar 2025 04:39:11 -0700 (PDT) Date: Wed, 26 Mar 2025 11:39:01 +0000 In-Reply-To: <20250326113901.3308804-1-sebastianene@google.com> Mime-Version: 1.0 References: <20250326113901.3308804-1-sebastianene@google.com> X-Mailer: git-send-email 2.49.0.395.g12beb8f557-goog Message-ID: <20250326113901.3308804-4-sebastianene@google.com> Subject: [PATCH v4 3/3] KVM: arm64: Release the ownership of the hyp rx buffer to Trustzone From: Sebastian Ene To: catalin.marinas@arm.com, joey.gouly@arm.com, maz@kernel.org, oliver.upton@linux.dev, sebastianene@google.com, snehalreddy@google.com, sudeep.holla@arm.com, suzuki.poulose@arm.com, vdonnefort@google.com, will@kernel.org, yuzenghui@huawei.com, qperret@google.com Cc: kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kernel-team@android.com, Andrei Homescu X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250326_043913_384136_2BEC2EA0 X-CRM114-Status: GOOD ( 12.45 ) 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 Introduce the release FF-A call to notify Trustzone that the hypervisor has finished copying the data from the buffer shared with Trustzone to the non-secure partition. Reported-by: Andrei Homescu Signed-off-by: Sebastian Ene --- arch/arm64/kvm/hyp/nvhe/ffa.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/arch/arm64/kvm/hyp/nvhe/ffa.c b/arch/arm64/kvm/hyp/nvhe/ffa.c index 6df6131f1107..ac898ea6274a 100644 --- a/arch/arm64/kvm/hyp/nvhe/ffa.c +++ b/arch/arm64/kvm/hyp/nvhe/ffa.c @@ -749,6 +749,7 @@ static void do_ffa_part_get(struct arm_smccc_res *res, DECLARE_REG(u32, uuid3, ctxt, 4); DECLARE_REG(u32, flags, ctxt, 5); u32 count, partition_sz, copy_sz; + struct arm_smccc_res _res; hyp_spin_lock(&host_buffers.lock); if (!host_buffers.rx) { @@ -765,11 +766,11 @@ static void do_ffa_part_get(struct arm_smccc_res *res, count = res->a2; if (!count) - goto out_unlock; + goto release_rx; if (hyp_ffa_version > FFA_VERSION_1_0) { /* Get the number of partitions deployed in the system */ - if (flags & 0x1) + if (flags & PARTITION_INFO_GET_RETURN_COUNT_ONLY) goto out_unlock; partition_sz = res->a3; @@ -781,10 +782,12 @@ static void do_ffa_part_get(struct arm_smccc_res *res, 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; + goto release_rx; } memcpy(host_buffers.rx, hyp_buffers.rx, copy_sz); +release_rx: + ffa_rx_release(&_res); out_unlock: hyp_spin_unlock(&host_buffers.lock); }