Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp318081rwd; Tue, 6 Jun 2023 23:52:06 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6tjLBWVNsRnHhO72GvIcpkRCDDUeLmPvNPA3gcHxMTLqwHKdLAJOGTlbDwpMVagXo5am39 X-Received: by 2002:aca:f09:0:b0:39c:6a30:cc7f with SMTP id 9-20020aca0f09000000b0039c6a30cc7fmr538298oip.21.1686120726502; Tue, 06 Jun 2023 23:52:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686120726; cv=none; d=google.com; s=arc-20160816; b=PH4pNEuaM0yOAUUKGNcIerCGk0nUJgoZcuoYE0IWszv+Q7+1Pmx5ApvcXkzRFMa5zU 4pvGQUKgzGaeoBR+GQ7XwpMhHK5tUts1o6Tf8qKJKg7JwoB0i5HblpqRTuPlNXRbtHrz GOKMkAKGQTySIyZpbU4YpI9M/5k4wVw5VjiRo3/V1GsBk/5hpsoEoVG8ZVPyoY4P1Z+A dBYIQpLdkbQo3eRl7sxc/vkX0fkz+HA9j4E0dZHsM44VmaJgibbwdgu27pMY+lc6QQlw 09eNHPo8vAIrZWt7X5/YnTgf5nbmPGTvqeHHa4gpaPGsGzgXknO9pTC89Jho5k3XF+FD hlqg== 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=GDLhbIj1h1brePs46a8+9RVwoL3klUcsVNRfX5GYZHU=; b=xzGve8LiS+CbT90LUYvq7PMbfxG/MW0XD2XaKcoOEFa8kafojBApt06IwAXllC8aTu 41ZXK217jZZPOdy+NIZSAPQEbW4ZGeAu+pHQrz8VKTDiWtzjyEZID8zya68ue1wCT+Be B8i24mzwsDzRBhuPZDBe4cbbhu0PCeuj5OeS5pC7264TdC1X4R2JSuj1c0xrMqc+qtzh MYC+9jAZ/3NE5WnDwIWFCPtwaeOAu7PRSZVuTm46Qq8A8XLFzyVaDjQxBm+RI2Gze+fi U6nA3zwjX6ujq98IxW1+UN/8YRs1EvVl7odCgTJWU/d6a8gPRCZFtw0AbpuhxAOh2BQa cvww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=f+4fDFos; 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 l12-20020a170902f68c00b001a5089fe47fsi8634428plg.326.2023.06.06.23.51.51; Tue, 06 Jun 2023 23:52:06 -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=f+4fDFos; 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 S236424AbjFGGg1 (ORCPT + 99 others); Wed, 7 Jun 2023 02:36:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55584 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235252AbjFGGgC (ORCPT ); Wed, 7 Jun 2023 02:36:02 -0400 Received: from mail-lj1-x230.google.com (mail-lj1-x230.google.com [IPv6:2a00:1450:4864:20::230]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 57F2C272B for ; Tue, 6 Jun 2023 23:35:08 -0700 (PDT) Received: by mail-lj1-x230.google.com with SMTP id 38308e7fff4ca-2b15a327c20so82446191fa.1 for ; Tue, 06 Jun 2023 23:35:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1686119701; x=1688711701; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=GDLhbIj1h1brePs46a8+9RVwoL3klUcsVNRfX5GYZHU=; b=f+4fDFosW9vw+ywjmYnEr0xgmF/taWie23nQww982PJApOEAKYXdl/oqboBfDEL/xJ HCyDxeVUOG66QN9GUNGUfqs6vZzkPmU3K8Bs1v7okPvHW197gxdLXBab3To9UiQsl6U1 FwvLmMB4mjIPN4yxUfhZR3fwZgX6GWKqScUBn28K36UDqtwgyL1KA0OrZYbgZDqM6dDH 4aSnwdV5uUUxUduonTIj1rOtYhwhQLtCRmpOVwTDrR5TZQdu+Nqc1QczEGi62jrmVMHU ecuNlkE2o1HCadiYU000ULSL+DiFiOfBR4grYwxxY0rgAizA1datInUlNvvmya3k5GdI W1Fw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686119701; x=1688711701; 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=GDLhbIj1h1brePs46a8+9RVwoL3klUcsVNRfX5GYZHU=; b=TA2I9/DrmwSK435jBxHHjqO7TO/yZYHa5fv99mCHRKCyVTl/TT8m5uqZhTdqW3XWWt wNGBLEYKKsnwbywNgJkPPSrBKiXaN6yZiiIAHvDELMlcne6C66/YowxwwBKy1pE4LZ/H 3S0/WgG4C1pxoBvIVi8qL4wGiKwOtwmowBc01Xq3Jc+PmtfJGmX2a+3bsP1wZSmjdPnF /726BXfRDUcH/55szDc1VDV8AwNXq2Ga1AYglifynhXaJlMl588bGFw0M4NDq4yPMd/q ZmBIerwikO/zDt5erOtebq0fueuKSZpv3VjrhK6O+6XTojUQtTkR63b+PL+0GioW7b66 ESvA== X-Gm-Message-State: AC+VfDyiUWS77/bTyhVpawCXcPRSrpqjBkZnxpXRIHng+5GMIJiKhcDy n6BwIgQrAPeovDlCpKjPpIYi8aFCEZ3bIOvL+xlwSA== X-Received: by 2002:a05:651c:102b:b0:2a8:adc4:a928 with SMTP id w11-20020a05651c102b00b002a8adc4a928mr2042361ljm.18.1686119701151; Tue, 06 Jun 2023 23:35:01 -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: <4ff09002-e871-38b9-43ec-227a64bac731@siemens.com> From: Ilias Apalodimas Date: Wed, 7 Jun 2023 09:34:25 +0300 Message-ID: Subject: Re: [PATCH v5 3/3] efi: Add tee-based EFI variable driver To: Jan Kiszka Cc: Ard Biesheuvel , Sumit Garg , 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=ham 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 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". Thanks /Ilias > > Jan > > -- > Siemens AG, Technology > Competence Center Embedded Linux >