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 3F130E7717F for ; Thu, 12 Dec 2024 08:51:35 +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:MIME-Version: References:In-Reply-To:Subject:Cc:To:From:Message-ID: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=hjW6maEJJVj5hEPJTPYw0nPQemWE/Wj5gozDJiPFiSk=; b=4Gba37o1y22HFRNqSdVl0yhy/s fcsRu14sc6g924dbty22J5OXBmSlWvQH19AsAx+9v1/76B6GUCWZm2Z8mBQvU4zX0KnlrSgXuqTeg o51PxtgF5bXbdDcy6jGCCyvyNjG+zy3JQ/v7gjWTx58abuLsDIu3AkY6QNsHxbMdT72dWAostsL/o x8MtpOfIniVoET08fLwJ4JCMm5qKtjg1SjEXuJzDQ3enAWimq0YOlLP85rou9kMHNPqOnPMAZ7iB9 6WWsRD7eqmT/HDCY5IW2a4zylV7n0lPFZ80gO9QF0GszXHTfiIC0rkv2TUpNthQjfCiB6eE85XVKQ +V09qEHA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tLeuq-0000000HNMQ-2mew; Thu, 12 Dec 2024 08:51:24 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tLetm-0000000HNDk-1E5t for linux-arm-kernel@lists.infradead.org; Thu, 12 Dec 2024 08:50:19 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 5B8EB5C5A1D; Thu, 12 Dec 2024 08:49:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 659C3C4CECE; Thu, 12 Dec 2024 08:50:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1733993417; bh=zgsaiFELnog4Xiom7qwaEuaJS+Gl1kORV0fiEphdXaM=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=kYVVMFy4ufIN76e6GyVm6iB4f5LjG16IcfW7uVpQr6sgVxpXo41AW/xv5wEGLB9Ve b/B8sqnCvpDo0VwF8awAng/J8PQjLv7faesdgiqmRYautwSfLo2QQ0S9FVXDNOegUl zB0J4Gc6M4WDyLtuCyQCstGVOFbYfUk1GIc+hgn1Ba+FzxsARTJaCB3AeAjBbHn5j2 4yeZBiJIo9UgxbSVrp3h2w1QNHupelqwWAUHGwFp+273tckBBucRgM6FfWlglCC/7g ddsvv0O0AGpvpEfaQGF3zZYNxoZ9EjjmllHH+NA1h2j2du970W2wXSoju5otbMd4s+ 6klzlx38+EWyQ== Received: from 82-132-221-83.dab.02.net ([82.132.221.83] helo=wait-a-minute.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1tLeti-0030Yi-Rd; Thu, 12 Dec 2024 08:50:15 +0000 Date: Thu, 12 Dec 2024 08:50:12 +0000 Message-ID: <87bjxhs2t7.wl-maz@kernel.org> From: Marc Zyngier To: Pavan Kondeti Cc: Akhil P Oommen , Rob Clark , Sean Paul , Konrad Dybcio , Abhinav Kumar , Dmitry Baryshkov , Marijn Suijten , David Airlie , Simona Vetter , Elliot Berman , , , , , Subject: Re: [PATCH] drm/msm/a6xx: Skip gpu secure fw load in EL2 mode In-Reply-To: References: <20241209-drm-msm-kvm-support-v1-1-1c983a8a8087@quicinc.com> <87ed2fs03w.wl-maz@kernel.org> <92cee905-a505-4ce9-9bbc-6fba4cea1d80@quicinc.com> <86sequsdtp.wl-maz@kernel.org> 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/29.4 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 82.132.221.83 X-SA-Exim-Rcpt-To: quic_pkondeti@quicinc.com, quic_akhilpo@quicinc.com, robdclark@gmail.com, sean@poorly.run, konradybcio@kernel.org, quic_abhinavk@quicinc.com, dmitry.baryshkov@linaro.org, marijn.suijten@somainline.org, airlied@gmail.com, simona@ffwll.ch, quic_eberman@quicinc.com, linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.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-20241212_005018_416484_333E9288 X-CRM114-Status: GOOD ( 34.28 ) 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 Thu, 12 Dec 2024 05:31:00 +0000, Pavan Kondeti wrote: > > On Wed, Dec 11, 2024 at 10:40:02AM +0000, Marc Zyngier wrote: > > On Wed, 11 Dec 2024 00:37:34 +0000, > > Pavan Kondeti wrote: > > > > > > On Tue, Dec 10, 2024 at 09:24:03PM +0000, Marc Zyngier wrote: > > > > > +static int a6xx_switch_secure_mode(struct msm_gpu *gpu) > > > > > +{ > > > > > + int ret; > > > > > + > > > > > +#ifdef CONFIG_ARM64 > > > > > + /* > > > > > + * We can access SECVID_TRUST_CNTL register when kernel is booted in EL2 mode. So, use it > > > > > + * to switch the secure mode to avoid the dependency on zap shader. > > > > > + */ > > > > > + if (is_kernel_in_hyp_mode()) > > > > > + goto direct_switch; > > > > > > > > No, please. To check whether you are *booted* at EL2, you need to > > > > check for is_hyp_available(). Whether the kernel runs at EL1 or EL2 is > > > > none of the driver's business, really. This is still absolutely > > > > disgusting from an abstraction perspective, but I guess we don't have > > > > much choice here. > > > > > > > > > > Thanks Marc. Any suggestions on how we can make is_hyp_mode_available() > > > available for modules? Do you prefer exporting > > > kvm_protected_mode_initialized and __boot_cpu_mode symbols directly or > > > try something like [1]? > > > > Ideally, neither. These were bad ideas nine years ago, and they still > > are. The least ugly hack I can come up with is the patch below, and > > you'd write something like: > > > > if (cpus_have_cap(ARM64_HAS_EL2_OWNERSHIP)) > > blah(); > > > > This is obviously completely untested. > > > > I have tested your patch. It works as intended. Thanks Marc. Note that you will probably get some push-back from the arm64 maintainers on this front, because this is a fairly incomplete (and fragile) solution. It would be much better if the discriminant came from the device tree. After all, the hypervisor is fscking-up^W^Wchanging the programming model of the GPU, and that should be reflected in the DT. Because for all intent and purposes, this is not the same hardware anymore. The GPU isn't the only device that needs fixing in that way: the SMMUv3 needs to be exposed to the OS, and the PCIe ports need to be linked to it and the ITS. So at the end of the day, detecting EL2 only serves a limited purpose. You need to handle these cases, and might as well put the GPU in the same bag. Which means that you'd either have a pair of static DTs (one that exposes the brokenness of the firmware, and one that doesn't), or you go the dtbhack route to compose the DT at boot time. Thanks, M. -- Without deviation from the norm, progress is not possible.