Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp376788rwd; Wed, 7 Jun 2023 00:52:23 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6CF034b/WRXlvjvsLJpSruxBh6hsQHURlDueuGxATY3AGVVzaTdOJQY27BehNseQMO5iDL X-Received: by 2002:aa7:88c7:0:b0:662:5146:c77a with SMTP id k7-20020aa788c7000000b006625146c77amr410669pff.31.1686124343484; Wed, 07 Jun 2023 00:52:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686124343; cv=none; d=google.com; s=arc-20160816; b=tqKZfM7rrAeZHF7+zFZ7F0SKA6a6HsUEenLTeawLLV0yCypwcjLlMc/z1+quUWEtPX TgpSpTFTLzIQ2ChRWyvAig1b9qYUEhqF8hIXjkWl5WyvsWqlPyZBIUvwxaW9BeabPTve I3r+AL5GQFWUS3mATxpFBNq/XfxdRa/slfAc9l4GMlC3a8vZkLHjEUP3Pwchu8QidyKt PJ+Vs9k/WOXqvU6j+cjY6u2GTTJ/38UcgfJzF3GZQgi0CNaQmAPTveSPnyPMOAfYjwp7 7vi6EnTQC1u8bkVOlFzx1z5LTYyKSp4O7lpCEHyvWQVVQoCtQrfIT8BsDQHZ1X6TjSPN ppcw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=ZbZsMTtgivDoJEuH3IaNChHHrvk2Q0PtcwAfQDF1PA8=; b=CQK6VlLePkQfGCzgHho5AUvIyE1yCCjoVRPFmNIKuyW3mRiX1Lsovt+I61NhIAGlW4 MwCLyhPTNYVjj6UneKjRz3t/DCQkp/rwJgV2V4GYU3L+1tE4vxUSWm57MB4zjwJ0KKyk 3DRkfoWcPCAGp/st1XyZzV3iPTOZlHC4jbBWnEsVAxGvKCteOolH+2/7OGe/hr7UaPtU hPC5Wgs2X7gVjmqk9lNA2LOxF2fnlwrp03A0oWAQj8l46T2NhUHinjeTvL5t31gjyM7v 4LwV2cPEpuAO2F04LimJInzp6+tQAXgOkdFM4a1x6LDipBxkBOQkRi2bIois5hscZvUZ 3GXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=P+xL9+U3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o5-20020aa79785000000b00654355ac8a5si7276679pfp.56.2023.06.07.00.52.09; Wed, 07 Jun 2023 00:52:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=P+xL9+U3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238757AbjFGH3X (ORCPT + 99 others); Wed, 7 Jun 2023 03:29:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53860 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239145AbjFGH2P (ORCPT ); Wed, 7 Jun 2023 03:28:15 -0400 Received: from mail-vs1-xe2b.google.com (mail-vs1-xe2b.google.com [IPv6:2607:f8b0:4864:20::e2b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7FB3E30DE for ; Wed, 7 Jun 2023 00:25:31 -0700 (PDT) Received: by mail-vs1-xe2b.google.com with SMTP id ada2fe7eead31-43b57e0a76bso660184137.0 for ; Wed, 07 Jun 2023 00:25:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1686122730; x=1688714730; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=ZbZsMTtgivDoJEuH3IaNChHHrvk2Q0PtcwAfQDF1PA8=; b=P+xL9+U37Z+N4Mg9/jK1h93OPPuF7gNd5e682jUXmulyGnYN7E2Lt1E0pV3vImjW6i E+JGjPeeSkHP8lHcNLCr8FpcXhdFn63NHO3RRD9Uw58Rm8TX3nWeC0ypMRI7EQkHmcKg kskP06M+dRD2l41gqVSq+ToUSy/qs/4jcme5Kw6bZbXm4ViBSiUP7+mcI667Q7ddZ3GF h8Www7jgcJBNIIFrnpj8wOAzwHTqfKbAT+KMDzQjHnmfEzFOHVwF/QwwEjPzhHBoskeW sshaKLWse0H+qPYbgIuRvS35+lpdvSzaAvxWmeStc+QJFjSiUQE8AViznEohsbl1zNBc Tlxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686122730; x=1688714730; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=ZbZsMTtgivDoJEuH3IaNChHHrvk2Q0PtcwAfQDF1PA8=; b=hv7wCGB1BEF8c2wQWyFKYivLHiOtONx2udZgRdE2oqI0Pf94uSjIjeth4MG2SVBSkP lIjtzV6Pzk9ZYPomxwilAQgIx1xzdk9GkH1iADQvUmFW/YRTkKZD1PPMSYPdB+dH6T6b uG52NhE2kb/Z5DsjYF4pPdu+r/jknLlZ9hjz7keHjmvQ7jFaJmxL8VTpSZWeKlcGp7u/ kwvCW9+Gw2+G1kqtYr5rGArlwZ98apokCnkZjs4QxQV7rbSn1OQ6f2yLyC+e9PfojMZa NcBsS3l5Ph+HrmvwrtcYEGUaZPRhxAmNy0lRka4zf+BjvWwih4BNkUia6Fa9wyPFm2+J NjOg== X-Gm-Message-State: AC+VfDzl/I2ay1d0eZ5rizjG+i8tJuRLqp/YTJcFssTZIEJ1hDyJozkv yJLxeuz+ZfRmf7buoHTIXv47tB88HiAH76cjU5VuXQ== X-Received: by 2002:a67:bd09:0:b0:426:b2d8:17e9 with SMTP id y9-20020a67bd09000000b00426b2d817e9mr634816vsq.20.1686122730438; Wed, 07 Jun 2023 00:25:30 -0700 (PDT) MIME-Version: 1.0 References: <20230526010748.1222-1-masahisa.kojima@linaro.org> <20230526010748.1222-4-masahisa.kojima@linaro.org> <0d3e0370-eb76-010f-3d30-9acc9b59645c@siemens.com> <4ff09002-e871-38b9-43ec-227a64bac731@siemens.com> In-Reply-To: From: Sumit Garg Date: Wed, 7 Jun 2023 12:55:19 +0530 Message-ID: Subject: Re: [PATCH v5 3/3] efi: Add tee-based EFI variable driver To: Ilias Apalodimas Cc: Jan Kiszka , Ard Biesheuvel , Masahisa Kojima , Jens Wiklander , linux-kernel@vger.kernel.org, op-tee@lists.trustedfirmware.org, Johan Hovold , Maxime Coquelin , Alexandre Torgue , linux-efi@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, "Su, Bao Cheng (RC-CN DF FA R&D)" Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Ilias, On Wed, 7 Jun 2023 at 12:05, Ilias Apalodimas wrote: > > Hi Jan, > > [...] > > > >>>> > > > ... > > >>> > > >>> I think we have a probe ordering issue with this driver: > > >>> efivarfs_fill_super() may be called before the TEE bus was probed, thus > > >>> with the default efivar ops still registered. And that means > > >>> efivar_supports_writes() will return false, and the fs declares itself > > >>> as readonly. I've seen systemd mounting it r/o initialling, and you need > > >>> to remount the fs to enable writability. > > >>> > > >>> Is there anything that could be done to re-order things reliably, probe > > >>> the tee bus earlier etc.? > > >> > > >> This driver has a dependency on user-space daemon: tee-supplicant to > > >> be running for RPMB access. So once you start that daemon the > > >> corresponding device will be enumerated on the TEE bus and this driver > > >> probe will be invoked. So I would suggest you to load this daemon very > > >> early in the boot process or better to make it a part of initramfs. > > >> > > > > > > That is not the point, really. > > > > > > If this dependency exists, the code should be aware of that, and made > > > to work correctly in spite of it. Requiring a module to be part of > > > initramfs is not a reasonable fix. > > > > In fact, I've tested a non-modularized build as well, just to exclude > > that issue. The daemon dependency is more likely the problem here. > > > > > > > > IIUC, this also means that the efivar ops are updated while there is > > > already a client. This seems less than ideal as well > > As Sumit pointed out, the 'device' won't be available from OP-TEE > until the supplicant is up and running and as a result, the module > _probe() function won't run. Unfortunately, this isn't something we > can avoid since the supplicant is responsible for the RPMB writes. > The only thing I can think of is moving parts of the supplicant to the > kernel and wiring up the RPC calls for reading/writing data to the > eMMC subsystem. There was another discussion here [0] requesting the > same thing for different reasons. But unless I am missing something > this won't solve the problem completely either. You still have a > timing dependency of "when did the RT callbacks change" -- "when was > my efivarfs mounted". With the RPMB writes wired through the kernel [1], the only dependency left is when do you load the tee-stmm-efi driver to have real EFI runtime variables support. IMO, tee-stmm-efi driver should be built-in to support systems without initramfs. The distro installers may choose to bundle it in initramfs. Do you still see a timing dependency with this approach? [1] Of Course here we need the eMMC and TEE/OPTEE drivers to be built-in too. -Sumit > > Thanks > /Ilias > > > > Jan > > > > -- > > Siemens AG, Technology > > Competence Center Embedded Linux > >