mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@siemens.com>
To: Ard Biesheuvel <ardb@kernel.org>, Sumit Garg <sumit.garg@linaro.org>
Cc: Masahisa Kojima <masahisa.kojima@linaro.org>,
	Jens Wiklander <jens.wiklander@linaro.org>,
	linux-kernel@vger.kernel.org, op-tee@lists.trustedfirmware.org,
	Ilias Apalodimas <ilias.apalodimas@linaro.org>,
	Johan Hovold <johan+linaro@kernel.org>,
	Maxime Coquelin <mcoquelin.stm32@gmail.com>,
	Alexandre Torgue <alexandre.torgue@foss.st.com>,
	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)" <baocheng.su@siemens.com>
Subject: Re: [PATCH v5 3/3] efi: Add tee-based EFI variable driver
Date: Tue, 6 Jun 2023 09:52:50 +0200	[thread overview]
Message-ID: <4ff09002-e871-38b9-43ec-227a64bac731@siemens.com> (raw)
In-Reply-To: <CAMj1kXFM45PCTU--+CCed6Cq_N5XqDG6tTu6fnQTSCpW2BWA5A@mail.gmail.com>

On 06.06.23 08:57, Ard Biesheuvel wrote:
> On Tue, 6 Jun 2023 at 08:52, Sumit Garg <sumit.garg@linaro.org> wrote:
>>
>> Hi Jan,
>>
>> On Tue, 6 Jun 2023 at 12:09, Jan Kiszka <jan.kiszka@siemens.com> wrote:
>>>
>>> On 26.05.23 03:07, Masahisa Kojima wrote:
>>>> When the flash is not owned by the non-secure world, accessing the EFI
>>>> variables is straightforward and done via EFI Runtime Variable Services.
>>>> In this case, critical variables for system integrity and security
>>>> are normally stored in the dedicated secure storage and only accessible
>>>> from the secure world.
>>>>
>>>> On the other hand, the small embedded devices don't have the special
>>>> dedicated secure storage. The eMMC device with an RPMB partition is
>>>> becoming more common, we can use an RPMB partition to store the
>>>> EFI Variables.
>>>>
>>>> The eMMC device is typically owned by the non-secure world(linux in
>>>> this case). There is an existing solution utilizing eMMC RPMB partition
>>>> for EFI Variables, it is implemented by interacting with
>>>> TEE(OP-TEE in this case), StandaloneMM(as EFI Variable Service Pseudo TA),
>>>> eMMC driver and tee-supplicant. The last piece is the tee-based
>>>> variable access driver to interact with TEE and StandaloneMM.
>>>>
>>>> So let's add the kernel functions needed.
>>>>
>>>> This feature is implemented as a kernel module.
>>>> StMM PTA has TA_FLAG_DEVICE_ENUM_SUPP flag when registered to OP-TEE
>>>> so that this tee_stmm_efi module is probed after tee-supplicant starts,
>>>> since "SetVariable" EFI Runtime Variable Service requires to
>>>> interact with tee-supplicant.
>>>>
>>>> Acked-by: Sumit Garg <sumit.garg@linaro.org>
>>>> Co-developed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
>>>> Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
>>>> Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org>
>>>> ---
>>>>  drivers/firmware/efi/Kconfig                 |  15 +
>>>>  drivers/firmware/efi/Makefile                |   1 +
>>>>  drivers/firmware/efi/stmm/mm_communication.h | 236 +++++++
>>>>  drivers/firmware/efi/stmm/tee_stmm_efi.c     | 638 +++++++++++++++++++
>>>>  4 files changed, 890 insertions(+)
>>>>  create mode 100644 drivers/firmware/efi/stmm/mm_communication.h
>>>>  create mode 100644 drivers/firmware/efi/stmm/tee_stmm_efi.c
>>>>
> ...
>>>
>>> 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

Jan

-- 
Siemens AG, Technology
Competence Center Embedded Linux


  parent reply	other threads:[~2023-06-06  7:57 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-26  1:07 [PATCH v5 0/3] introduce tee-based EFI Runtime Variable Service Masahisa Kojima
2023-05-26  1:07 ` [PATCH v5 1/3] efi: expose efivar generic ops register function Masahisa Kojima
2023-05-26  1:07 ` [PATCH v5 2/3] efi: Add EFI_ACCESS_DENIED status code Masahisa Kojima
2023-05-26  1:07 ` [PATCH v5 3/3] efi: Add tee-based EFI variable driver Masahisa Kojima
2023-06-06  6:39   ` Jan Kiszka
2023-06-06  6:51     ` Sumit Garg
2023-06-06  6:57       ` Ard Biesheuvel
2023-06-06  7:51         ` Sumit Garg
2023-06-06  7:52         ` Jan Kiszka [this message]
2023-06-07  6:34           ` Ilias Apalodimas
2023-06-07  6:35             ` Ilias Apalodimas
2023-06-07  7:25             ` Sumit Garg
2023-06-07  8:25               ` Ilias Apalodimas
2023-06-07 12:40                 ` Jan Kiszka
2023-06-07 15:18                   ` Sumit Garg
2023-06-07 16:04                     ` Jan Kiszka
2023-06-07 16:09                       ` Ilias Apalodimas
2023-06-07 16:59                         ` Ilias Apalodimas
2023-06-07 17:14                           ` Jan Kiszka
2023-06-07 18:17                             ` Ilias Apalodimas
2023-06-07 19:46                               ` Jan Kiszka
2023-06-08  6:21                                 ` Ilias Apalodimas
2023-06-08 13:52                                   ` Ard Biesheuvel
2023-06-08 19:38                                     ` Ilias Apalodimas
2023-06-09  6:18                                       ` Jan Kiszka
2023-06-09  6:34                                         ` Ilias Apalodimas
2023-06-09  6:40                                           ` Jan Kiszka
2023-06-09  8:00                                             ` Ilias Apalodimas
2023-06-09  6:16                                     ` Jan Kiszka
2023-06-09  6:22                                       ` Ilias Apalodimas
2023-06-09  6:36                                         ` Jan Kiszka
2023-05-26 13:09 ` [PATCH v5 0/3] introduce tee-based EFI Runtime Variable Service Ard Biesheuvel
2023-05-29  9:05   ` Jens Wiklander
2023-05-29 13:29     ` Ard Biesheuvel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4ff09002-e871-38b9-43ec-227a64bac731@siemens.com \
    --to=jan.kiszka@siemens.com \
    --cc=alexandre.torgue@foss.st.com \
    --cc=ardb@kernel.org \
    --cc=baocheng.su@siemens.com \
    --cc=ilias.apalodimas@linaro.org \
    --cc=jens.wiklander@linaro.org \
    --cc=johan+linaro@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-efi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-stm32@st-md-mailman.stormreply.com \
    --cc=masahisa.kojima@linaro.org \
    --cc=mcoquelin.stm32@gmail.com \
    --cc=op-tee@lists.trustedfirmware.org \
    --cc=sumit.garg@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®