Linux-EFI Archive mirror
 help / color / mirror / Atom feed
From: "Jarkko Sakkinen" <jarkko@kernel.org>
To: "Mikko Rapeli" <mikko.rapeli@linaro.org>,
	"Ard Biesheuvel" <ardb@kernel.org>, <linux-efi@vger.kernel.org>
Cc: <linux-kernel@vger.kernel.org>,
	"Ilias Apalodimas" <ilias.apalodimas@linaro.org>,
	"Lennart Poettering" <lennart@poettering.net>
Subject: Re: [PATCH] efi: expose TPM event log to userspace via sysfs
Date: Fri, 26 Apr 2024 14:48:39 +0300	[thread overview]
Message-ID: <D0U14GGWT2AW.XRFW7MB1QZFV@kernel.org> (raw)
In-Reply-To: <20240422112711.362779-1-mikko.rapeli@linaro.org>

On Mon Apr 22, 2024 at 2:27 PM EEST, Mikko Rapeli wrote:
>  Documentation/ABI/testing/sysfs-firmware-efi | 12 ++++++++++++
>  drivers/firmware/efi/efi.c                   | 13 +++++++++++++
>  2 files changed, 25 insertions(+)
>
> diff --git a/Documentation/ABI/testing/sysfs-firmware-efi b/Documentation/ABI/testing/sysfs-firmware-efi
> index 5e4d0b27cdfe..caaff27cc73e 100644
> --- a/Documentation/ABI/testing/sysfs-firmware-efi
> +++ b/Documentation/ABI/testing/sysfs-firmware-efi
> @@ -36,3 +36,15 @@ Description:	Displays the content of the Runtime Configuration Interface
>  		Table version 2 on Dell EMC PowerEdge systems in binary format
>  Users:		It is used by Dell EMC OpenManage Server Administrator tool to
>  		populate BIOS setup page.
> +
> +What:		/sys/firmware/efi/tpm_log

*Conditional* suggestion: s/tpm_log/tpm_event_log/

I.e. if we want this better to use the most popular name.

> +Date:		April 2024
> +Contact:	Mikko Rapeli <mikko.rapeli@linaro.org>
> +Description:	If EFI firmware supports TPM device and measurements were done
> +		then a TPM event log has very likely been generated and provided
> +		to the kernel. This serves as indicator for userspace to load
> +		TPM drivers and to start related service early in the boot sequence,
> +		e.g. initramfs, where full bus probes and device scans are not yet
> +		done.
> +Users:		systemd will use this interface to support TPM drivers as modules also
> +		for early initramfs
> diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
> index 4fcda50acfa4..94773e8b8806 100644
> --- a/drivers/firmware/efi/efi.c
> +++ b/drivers/firmware/efi/efi.c
> @@ -162,6 +162,13 @@ static ssize_t fw_platform_size_show(struct kobject *kobj,
>  	return sprintf(buf, "%d\n", efi_enabled(EFI_64BIT) ? 64 : 32);
>  }
>  
> +static ssize_t tpm_log_show(struct kobject *kobj,
> +				     struct kobj_attribute *attr, char *buf)
> +{
> +	return sprintf(buf, "TPMEventLog=0x%lx", efi.tpm_log);

It is also asymmetric with the log message as we can see here. Why you
want to put that prefix and not just print the number? Why hex and not
just %lu?


> +}
> +static struct kobj_attribute efi_attr_tpm_log = __ATTR_RO_MODE(tpm_log, 0400);
> +
>  extern __weak struct kobj_attribute efi_attr_fw_vendor;
>  extern __weak struct kobj_attribute efi_attr_runtime;
>  extern __weak struct kobj_attribute efi_attr_config_table;
> @@ -459,6 +466,12 @@ static int __init efisubsys_init(void)
>  		platform_device_register_simple("efi_secret", 0, NULL, 0);
>  #endif
>  
> +	if (efi.tpm_log != EFI_INVALID_TABLE_ADDR) {
> +		error = sysfs_create_file(efi_kobj, &efi_attr_tpm_log.attr);
> +		if (error)
> +			pr_err("sysfs create file failed with error %d.\n", error);
> +	}

s/err/warn/

Why "sys create file" and not "sys_create_file"?

> +
>  	return 0;
>  
>  err_remove_group:

BR, Jarkko

      parent reply	other threads:[~2024-04-26 11:48 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-22 11:27 [PATCH] efi: expose TPM event log to userspace via sysfs Mikko Rapeli
2024-04-22 12:42 ` James Bottomley
2024-04-22 13:08   ` Mikko Rapeli
2024-04-22 13:32     ` Ilias Apalodimas
2024-04-22 13:38       ` James Bottomley
2024-04-22 13:54         ` Ilias Apalodimas
2024-04-22 14:31           ` James Bottomley
2024-04-22 15:22             ` Ilias Apalodimas
2024-04-24 17:15               ` Ard Biesheuvel
2024-04-25  8:56                 ` Mikko Rapeli
2024-04-25 13:50                   ` Jarkko Sakkinen
2024-04-25  9:58                 ` Lennart Poettering
2024-04-25 10:36                   ` Ard Biesheuvel
2024-04-25 11:13                     ` Lennart Poettering
2024-04-25 11:47                       ` Ilias Apalodimas
2024-04-25 13:36                         ` Lennart Poettering
2024-04-25 13:46                           ` James Bottomley
2024-04-25 13:24                   ` James Bottomley
2024-04-25 13:39                     ` Mikko Rapeli
2024-04-25 13:40                     ` Lennart Poettering
2024-04-25 14:01                   ` Jarkko Sakkinen
2024-04-26  7:35                     ` Jarkko Sakkinen
2024-04-26  7:40                       ` Jarkko Sakkinen
2024-04-26  8:19                         ` Mikko Rapeli
2024-04-26  8:23                           ` Jarkko Sakkinen
2024-04-22 14:57           ` Mikko Rapeli
2024-04-26 11:41 ` Jarkko Sakkinen
2024-04-26 11:48 ` Jarkko Sakkinen [this message]

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=D0U14GGWT2AW.XRFW7MB1QZFV@kernel.org \
    --to=jarkko@kernel.org \
    --cc=ardb@kernel.org \
    --cc=ilias.apalodimas@linaro.org \
    --cc=lennart@poettering.net \
    --cc=linux-efi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mikko.rapeli@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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).