Received: by 2002:ab2:3c46:0:b0:1f5:f2ab:c469 with SMTP id x6csp212425lqf; Fri, 26 Apr 2024 04:48:51 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW1iDkS7Zt3DADbk6VTvjZfHoEpWX8HUbY68qaLsBp7UEJCShPK16dLKTnIA3fe09Udgc9f4k5YQn4I2LmnplErDAKCgjJDBYXEF/FqMA== X-Google-Smtp-Source: AGHT+IGY4VNo9hMGKDnJkyP5IKtEnZ7pwoIJIGJxF6TJdoRITfzhIELUc3d+0DLtjPkBVHcv9qoW X-Received: by 2002:a05:6214:c86:b0:6a0:66ad:c29 with SMTP id r6-20020a0562140c8600b006a066ad0c29mr4332517qvr.10.1714132131718; Fri, 26 Apr 2024 04:48:51 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714132131; cv=pass; d=google.com; s=arc-20160816; b=ei1l+imXY2l9MJVZoAtehlyYoxcgjrmw9WrP+GomGYz5ywLh2tm2lH5Qr69lWc8unq i/yZuxuLD/uoxrtJB3wVum58caHW8K2NqIY6aSHv//egqdZYm9V/GYEM8vPx6wj2RG5u FmcbSC+ZnNFSbYgyOmNHw4NMi+aI5bzZz6b0sY5lUCd9e58lZjJF1SPhyXb0jfk1h/uv utELfXYNFCPrivU89CfDBXu4Xk8YE+jRLAeMu4g2O3B04T9kksg5UoQ3JNW3YULeBlzW waKubEh9dV0MeZDJQgnnfmZ2yZkyYGlnQ+JjD/1f1gMuGVxjSpbPSqNinJeVx6bKcX7J bvFA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:references:to:from:subject:cc:message-id:date :content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:dkim-signature; bh=6aPHmJWg9F8RaPzfm0RGlnUVOwJa/vfZPq3GAUNIe20=; fh=SlGUBxZQBm2ziWDg8QRQrRqT40IT6IccLCNxljvu+zs=; b=Ai/DKQLbhFkE7L8ISu2ZQxAvzZbicHZhixwyghu3kJH04xWW6mejWpqgggpUbXGN1z nxP/l8sUZ0RVJFeoo5ejL+6TZIsFECwURVt42GGzu4oIJMcjhzb5V465QjnhtMLYROQU oXWLquWYqMIj6gxF+j/GVh3WHgYkq/WHmV9HyihkHUiPK5bVusZAjyLOfkmTFiep8qto bFVqwvchhlhMLqPXmFsO+JMJghBxFGTjdfUEIZsrj9cPmHckvnTOQS63BFYGPL6LBIOw cc7KLcBSldaA25u/d+h/218U2dNo8wxzA+uxsyYW7UOk63pZNeUKpdbruM0Gabt/A4wa c6yQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jc1YRiUI; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-159951-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-159951-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id fq7-20020a056214258700b0069924c862b5si20711404qvb.43.2024.04.26.04.48.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Apr 2024 04:48:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-159951-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jc1YRiUI; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-159951-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-159951-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 627361C21DEC for ; Fri, 26 Apr 2024 11:48:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1801A145341; Fri, 26 Apr 2024 11:48:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="jc1YRiUI" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3CE7113F01A; Fri, 26 Apr 2024 11:48:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714132125; cv=none; b=eDCtvgUMPCLX8wJ+fg1Ctf/rhHziIxwjIBIUlqe8rq/JlzzGvB3GYWnU+kDcU1zy9fFvhPdFHyoLiuCCKNfiz6V3uzYqGcIh82yA3v0/4x0QxYJ8n7AveSckS/oRdGM5iRPLMW9VFLFoFuNdCbCXC9ga2PejgFuqr6fFIir0twI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714132125; c=relaxed/simple; bh=BQU2RBaoh+BYwZJxNG6MuOnWNxfKhQAz+I7OuG0h14w=; h=Mime-Version:Content-Type:Date:Message-Id:Cc:Subject:From:To: References:In-Reply-To; b=m/K94qL7bGs6x8V2YGDudxV38rQ5erCnfZyYTua//mttwk5/J43gL2+yPfjBAXgw/IcgZeGxSybbEMySW/EkHSEe8ec/wBm4jx+r5q642hqWnQobP7phNR5HmvqtB18kZyYpe4fKCsVInWrLLVPGdtIEOqdp7CKNaTwwkKtqHWs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=jc1YRiUI; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3A52FC113CD; Fri, 26 Apr 2024 11:48:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1714132124; bh=BQU2RBaoh+BYwZJxNG6MuOnWNxfKhQAz+I7OuG0h14w=; h=Date:Cc:Subject:From:To:References:In-Reply-To:From; b=jc1YRiUIsXBhWYGOKSR6jgCIgv+XlHiiqtK6/NnzcjiE8IS2t/qU1yHVH09olJebX 54DVzrcVs3eUA5hJ+/iTF+XPguh0JX9e/hRqrKfcYQVGVFH3uaJV12w77B9NRcd5an hIEs/GOl3RQ6TvACc65HcYj3tMLTDG4JHCcBjMjf6WNHHinEvUa6KbOqay0bk6+Bhf S/tvWke82H46+jMgWm8z3bkmrIWm0ZOFtQoDSc4LwGS3QOXkn3tsqwi1fLED//9kMH 0+1UkXw0uVqjWgDoeoDMKwZjwskjo3NbBiQZ9GhopmswJk0259hzGXhdrHPn6fGDtP D8g2D3JJOAL1g== Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Fri, 26 Apr 2024 14:48:39 +0300 Message-Id: Cc: , "Ilias Apalodimas" , "Lennart Poettering" Subject: Re: [PATCH] efi: expose TPM event log to userspace via sysfs From: "Jarkko Sakkinen" To: "Mikko Rapeli" , "Ard Biesheuvel" , X-Mailer: aerc 0.17.0 References: <20240422112711.362779-1-mikko.rapeli@linaro.org> 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 Confi= guration 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 > +Description: If EFI firmware supports TPM device and measurements were d= one > + 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 module= s 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); > } > =20 > +static ssize_t tpm_log_show(struct kobject *kobj, > + struct kobj_attribute *attr, char *buf) > +{ > + return sprintf(buf, "TPMEventLog=3D0x%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 =3D __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 > =20 > + if (efi.tpm_log !=3D EFI_INVALID_TABLE_ADDR) { > + error =3D 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; > =20 > err_remove_group: BR, Jarkko