All of lore.kernel.org
 help / color / mirror / Atom feed
From: Johan Hovold <johan@kernel.org>
To: Maximilian Luz <luzmaximilian@gmail.com>
Cc: Ard Biesheuvel <ardb@kernel.org>, Andy Gross <agross@kernel.org>,
	Bjorn Andersson <bjorn.andersson@linaro.org>,
	Konrad Dybcio <konrad.dybcio@somainline.org>,
	Rob Herring <robh+dt@kernel.org>,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
	Steev Klimaszewski <steev@kali.org>,
	Shawn Guo <shawn.guo@linaro.org>,
	Sudeep Holla <sudeep.holla@arm.com>,
	Cristian Marussi <cristian.marussi@arm.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-arm-msm@vger.kernel.org, linux-efi@vger.kernel.org,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/4] firmware: Add support for Qualcomm UEFI Secure Application
Date: Thu, 19 Jan 2023 17:47:57 +0100	[thread overview]
Message-ID: <Y8l0PdZlXLym//xS@hovoldconsulting.com> (raw)
In-Reply-To: <2b0fdc2d-6457-059b-bbdf-27e7de59abeb@gmail.com>

On Wed, Jan 18, 2023 at 09:45:18PM +0100, Maximilian Luz wrote:
> On 1/17/23 09:24, Johan Hovold wrote:
> > On Sun, Jul 24, 2022 at 12:49:48AM +0200, Maximilian Luz wrote:

> >> +module_platform_driver(qcom_uefisecapp_driver);
> > 
> > I noticed that for efivarfs to work, you're currently relying on having
> > the firmware still claim that the variable services are supported in the
> > RT_PROP table so that efi core registers the default ops at subsys init
> > time (which are later overridden by this driver).
> > 
> > Otherwise efivarfs may fail to initialise when built in:
> > 
> > 	static __init int efivarfs_init(void)
> > 	{
> > 		if (!efivars_kobject())
> > 			return -ENODEV;
> > 
> > 		return register_filesystem(&efivarfs_type);
> > 	}
> > 
> > 	module_init(efivarfs_init);
> > 
> > With recent X13s firmware the corresponding bit in the RT_PROP table has
> > been cleared so that efivarfs would fail to initialise. Similar problem
> > when booting with 'efi=noruntime'.
> > 
> > One way to handle this is to register also the qcom_uefisecapp_driver at
> > subsys init time and prevent it from being built as a module (e.g. as is
> > done for the SCM driver). I'm using the below patch for this currently.
> 
> So I've had another look and I'm not sure this will work reliably:
> 
> First, you are correct in case the RT_PROP table is cleared. In that
> case, using subsys_initcall() will move the efivar registration before
> the efivarfs_init() call.
> 
> However, in case EFI indicates support for variables, we will then have
> generic_ops_register() and the uefisecapp's driver call running both in
> subsys_initcall(). So if I'm not mistaken, this could cause the generic
> ops to be registered after the uefisecapp ones, which we want to avoid.

Good catch, I was using 'efi=noruntime' on the CRD so I did not notice
that race.

> One solution is bumping uefisecapp to fs_initcall(). Or do you have any
> other suggestions?

I think it would be best to avoid that if we can, but that should work.

The problem here is that the firmware claims to support the EFI variable
services even when it clearly does not and the corresponding callbacks
just return EFI_UNSUPPORTED. As far as I understand, this is still spec
compliant though so we just need to handle that.

One way to address this could be to have efi core not register the
default efivars ops in this case. That would require checking that the
services are indeed available by making one of those calls during
initialisation.

This would however expose the fact that the Google SMI implementation
implicitly relies on overriding the default ops, but I think that's a
good thing as what we have now is racy in multiple ways.

Instead I think we should move the efivarfs availability check from
module init to mount time. That should allow the Google driver, and your
SCM implementation, to continue to be built as modules.

Any consumers (e.g. the Qualcomm RTC driver) would instead need to
check if efivars is available or else defer probe.

Alternatively, it seems all efivars implementation would need to be
always-built in which is not ideal for generic kernels.

I just posted a series here as food for thought:

	https://lore.kernel.org/r/20230119164255.28091-1-johan+linaro@kernel.org

Johan

  reply	other threads:[~2023-01-19 16:47 UTC|newest]

Thread overview: 65+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-23 22:49 [PATCH 0/4] firmware: Add support for Qualcomm UEFI Secure Application Maximilian Luz
2022-07-23 22:49 ` [PATCH 1/4] firmware: qcom_scm: Export SCM call functions Maximilian Luz
2022-07-23 22:49 ` [PATCH 2/4] firmware: Add support for Qualcomm Trusted Execution Environment SCM calls Maximilian Luz
2022-07-23 22:49 ` [PATCH 3/4] firmware: Add support for Qualcomm UEFI Secure Application Maximilian Luz
2023-01-17  8:24   ` Johan Hovold
2023-01-17  8:42     ` Maximilian Luz
2023-01-18 20:45     ` Maximilian Luz
2023-01-19 16:47       ` Johan Hovold [this message]
2023-01-19 17:19         ` Maximilian Luz
2023-01-17 11:05   ` Johan Hovold
2023-01-17 12:07     ` Maximilian Luz
2022-07-23 22:49 ` [PATCH 4/4] dt-bindings: firmware: Add Qualcomm UEFI Secure Application client Maximilian Luz
2022-07-25  1:06   ` Rob Herring
2022-07-26 10:17   ` Krzysztof Kozlowski
2022-07-26 11:15     ` Maximilian Luz
2022-07-26 13:25       ` Krzysztof Kozlowski
2022-07-26 15:00         ` Maximilian Luz
2022-07-27 11:24           ` Krzysztof Kozlowski
2022-07-27 13:00             ` Maximilian Luz
2022-07-28  7:48               ` Krzysztof Kozlowski
2022-07-28 10:25                 ` Maximilian Luz
2022-07-28 10:38                   ` Krzysztof Kozlowski
2022-07-28 10:49                     ` Maximilian Luz
2022-07-26 14:30   ` Sudeep Holla
2022-07-26 15:15     ` Maximilian Luz
2022-07-26 15:41       ` Sudeep Holla
2022-07-26 17:01         ` Maximilian Luz
2022-07-27 11:38           ` Krzysztof Kozlowski
2022-07-27 13:03             ` Maximilian Luz
2022-07-27 13:24               ` Sudeep Holla
2022-07-27 14:49                 ` Maximilian Luz
2022-07-28  6:03                 ` Ilias Apalodimas
2022-07-28 10:48                   ` Maximilian Luz
2022-07-28 11:33                     ` Sudeep Holla
2022-07-28 12:13                       ` Maximilian Luz
2022-07-28 12:24                       ` Ilias Apalodimas
2022-07-28 15:05                       ` Ard Biesheuvel
2022-07-28 15:16                         ` Ilias Apalodimas
2022-07-28 16:16                         ` Sudeep Holla
2022-07-28 16:24                           ` Konrad Dybcio
2022-07-28 12:35                     ` Ilias Apalodimas
2022-07-28 12:49                       ` Maximilian Luz
2022-07-28 16:56                         ` Ilias Apalodimas
2022-07-28 17:27                           ` Maximilian Luz
2022-07-29  8:52                             ` Sudeep Holla
2022-07-29 15:11                               ` Maximilian Luz
2022-07-31  9:54                             ` Ilias Apalodimas
2022-07-31 22:48                               ` Maximilian Luz
2022-07-28  8:23           ` Sudeep Holla
2022-07-28 10:05             ` Maximilian Luz
2022-07-28 11:21               ` Sudeep Holla
2022-07-28 11:45                 ` Maximilian Luz
2022-07-28 13:42                   ` Sudeep Holla
2022-07-28 14:09                     ` Maximilian Luz
2022-07-25 19:27 ` [PATCH 0/4] firmware: Add support for Qualcomm UEFI Secure Application Rob Herring
2022-07-25 20:16   ` Maximilian Luz
2022-08-02 11:51 ` Srinivas Kandagatla
2022-08-02 13:22   ` Maximilian Luz
2022-08-02 14:02     ` Ard Biesheuvel
2022-08-02 19:11       ` Maximilian Luz
2022-09-02  7:26     ` Sumit Garg
2022-09-02 13:18       ` Maximilian Luz
2022-09-05  6:50         ` Sumit Garg
2022-11-23 11:22     ` Srinivas Kandagatla
2022-11-23 12:05       ` Maximilian Luz

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=Y8l0PdZlXLym//xS@hovoldconsulting.com \
    --to=johan@kernel.org \
    --cc=agross@kernel.org \
    --cc=ardb@kernel.org \
    --cc=bjorn.andersson@linaro.org \
    --cc=cristian.marussi@arm.com \
    --cc=devicetree@vger.kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=konrad.dybcio@somainline.org \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-efi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luzmaximilian@gmail.com \
    --cc=robh+dt@kernel.org \
    --cc=shawn.guo@linaro.org \
    --cc=steev@kali.org \
    --cc=sudeep.holla@arm.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.