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 68D43CCF9F8 for ; Fri, 31 Oct 2025 10:28:09 +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-Transfer-Encoding: Content-Type:MIME-Version:References:In-Reply-To:Subject:Cc:To:From: Message-ID:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=4CLdWpbtsaz7AxzWGa2ZTuA2qYGRebmOLebreTcJpPw=; b=b3Qg7JjEw1FgDFCMDtlrj61xR+ uA92QK1yL7MBzJZcDIlvrqaof2V0VyxuCp8WLOK0WzRhqu8ulwEMUHP5xjBsMTTsRjXA4TlVNYzpL /yUEmfRn//Zs+66xzkvSqgrSTA0XcVw1WVX4lQR4lCJCphxtQf7/P3I3l0fHvdfvfMe+ShprgfNdd IHRE4LqV6Q8DZy0nyCGN3lkG0iAqtaUT44/ORFxE8QPyEQRJ5bQh+9Os3jo/TrF3PxLzINp1incfL +m3IxbHI7DIyDZ4/DPU29m1wXgLh+FYtS2I/hOWE2EvrNGTc8bxsZfpjviC9gW1Yr/ImGccg9AjgC KGA+doNA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1vEmMU-00000005uDC-3hnp; Fri, 31 Oct 2025 10:28:02 +0000 Received: from sea.source.kernel.org ([172.234.252.31]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1vEmMS-00000005uCr-0Opr for linux-arm-kernel@lists.infradead.org; Fri, 31 Oct 2025 10:28:01 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sea.source.kernel.org (Postfix) with ESMTP id 80C7C4368B; Fri, 31 Oct 2025 10:27:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5B28FC4CEE7; Fri, 31 Oct 2025 10:27:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1761906479; bh=C/ilvYRg1PDqrY14E+0VQggPCx55FHA3pPia0NFlTNg=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=ELWWp+tScjY8aW4PiV3jwFuShngNP+fLll9QRe9cFYQ+K6UTWoarOzVuEP2CV9ZF8 woa/GC9T6a6c0fL9XUyoEGSbDX68OOEMqoFhyfgmVPujrfHwuh9h7PlyW+r+V1jb0K Uc6WaXBtqH+Q+tqvqB70HJGHEiTgIEDplmdjSLhrECznpexOApGNMBhaA5om+wkMuj bYaJQN5Xk/pQA3Q2G4clUbznQGFXthxNwcM2GrEsbmRVqVPYucfC+VT63z4M++X4yN diT9M5+WIOEwlENQEgu02fj0DaNEA8J+0RPpQ4BpVdEwKGqPWlODHL1HLLmq9eWuos 9NaspX6FeU1lQ== Received: from sofa.misterjones.org ([185.219.108.64] helo=goblin-girl.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1vEmMO-00000001I45-44za; Fri, 31 Oct 2025 10:27:57 +0000 Date: Fri, 31 Oct 2025 10:27:56 +0000 Message-ID: <86ms57v00j.wl-maz@kernel.org> From: Marc Zyngier To: Yeoreum Yun Cc: Sebastian Ene , oliver.upton@linux.dev, joey.gouly@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, catalin.marinas@arm.com, will@kernel.org, perlarsen@google.com, ayrton@google.com, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/2] KVM: arm64: fix FF-A call failure when ff-a driver is built-in In-Reply-To: References: <20251027191729.1704744-1-yeoreum.yun@arm.com> <20251027191729.1704744-2-yeoreum.yun@arm.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/30.1 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: yeoreum.yun@arm.com, sebastianene@google.com, oliver.upton@linux.dev, joey.gouly@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, catalin.marinas@arm.com, will@kernel.org, perlarsen@google.com, ayrton@google.com, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-kernel@vger.kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20251031_032800_186573_9D955DE2 X-CRM114-Status: GOOD ( 29.22 ) 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 On Fri, 31 Oct 2025 10:08:37 +0000, Yeoreum Yun wrote: >=20 > Hi Sebastian, >=20 > > > Until has_version_negotiated is set to true, > > > all FF-A function calls fail except FFA_VERSION. > > > The has_version_negotiated flag is set to true when > > > the first FFA_VERSION call is made after init_hyp_mode(). > > > > > > This works fine when the FF-A driver is built as a module, > > > since ffa_init() is invoked after kvm_arm_init(), allowing do_ffa_ver= sion() > > > to set has_version_negotiated to true. > > > > > > However, when the FF-A driver is built-in (CONFIG_ARM_FFA_TRANSPORT= =3Dy), > > > all FF-A calls fail. This happens because ffa_init() runs before > > > kvm_arm_init() =E2=80=94 the init level of ffa_init() is rootfs_initc= all. > > > As a result, the hypervisor cannot set has_version_negotiated, > > > since the FFA_VERSION call made in ffa_init() does not trap to the hy= pervisor > > > (HCR_EL2.TSC is cleared before kvm_arm_init()). > > > > > > > I understand the reason behind the patch but this is problematic to have > > the builtin driver load before pKVM because the hypervisor would be > > un-aware of the host mapped buffers. (eg. the call from ffa_rxtx_map is > > not trapped because it is too early). Essentially, you will end up > > bypassing the hyp FF-A proxy which I think you will want to avoid. >=20 > Ah. I've overlooed the ffa_rxtx_map proxy. > But unfortunately, some of depndency with the driver using arm_ffa > driver, ffa_init() should be called first then other drivers' initcall > (usually, these kind of driver defines its one initcall with > device_initcall()) (i.e) https://lore.kernel.org/all/20250618102302.23790= 29-1-yeoreum.yun@arm.com/. >=20 > Though I arm_ffa driver provide an API getting mapped rx/tx buffer, > But this seems to reverse dependency -- kvm depends on arm_ffa driver. No it doesn't. KVM doesn't give a damn about the kernel FFA driver. It just makes sure that the driver doesn't do anything stupid. > I=E2=80=99ve been thinking about some possible solutions, > but in my narrow idea, valid solution is kvm_arm_init() as > subsys_initcall_sync() and call kvm_init() in module_init() like > attached modification. >=20 > Do you have any idea? There is no way we can accept such a change. It makes something fragile even more brittle. If anything, make the FFA driver check for KVM being initialised, and make the probing defer if not. M. --=20 Without deviation from the norm, progress is not possible.