Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp1350001rdb; Mon, 19 Feb 2024 12:20:38 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXxd6bH2G87ZoZdfFm1KlWZgp5qdZSFCNfLlI5HaSOV3yCvdapZtcPz7DLKNBKrNCig+/HeTlT18OOpO/8RUoj2NppoBl1JrJNh89TnIQ== X-Google-Smtp-Source: AGHT+IGfDV42ze0hYTKo1VfyrQ/jck530ZwMvzJ7MolGS/nwimH2O4LnRY7zqM7x53VxBXuIzEf6 X-Received: by 2002:a17:90a:8990:b0:299:58b2:b9d1 with SMTP id v16-20020a17090a899000b0029958b2b9d1mr5309861pjn.36.1708374038206; Mon, 19 Feb 2024 12:20:38 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708374038; cv=pass; d=google.com; s=arc-20160816; b=SjXH67Wj/Xr2W2fdMB7xAfW7JU8cAIlFwFrAIMjeICjPIBpOKKzKpNJFstNFaQWRQi U1gPenNRtA0qICbBzJ0r+zaUXjIehwOpTK9EXyi/R6E4S6jdVCUOdn21QhJ0chNngZMT z1GtKsHHlgTiSRdoMDPw+bd0/TIN1CjTQHtxxzUKT7s1HbSZG6sUr0FVkY4FAIfbu8mN 3F9b/J84pm9nUCBdFIqF5gdzI/5OJw5jpzw2NXDrxG9H4xlSDcjHoLP98DOZPY0B1/n7 LmUDrZsuzkADu3jahZ4hVZupu8qcRoTQxLDJWLQSYjtq0zZjT2B1CjoNN6Bb1dSWr2NE 4ECA== 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=7rj54g8oFsl11DwpnQ41TN1NBC+21jids3MdtNNyj9k=; fh=P2Y5q1k2D/QWx5qwKdr24638gKDz33RxjzUIh6QodO4=; b=0RjLg/rp6mQslS3iDk7Xr6YqcOZveV6ck+CfdyKYA1yRtfIgZ+0koMuqjlckOmPntL CHflJbtZzV/Elg13J4m2gPB0cHhPG6vPy1ibRmTQyvKk+1qqgb4ebkvMroPdXxb4nGSZ kxKO10DxCiD5o9w0Cj8HF54FPClGiiL50+O6JEjepu0zPTzFLu9Zp7s0bPOZ2mUWQVw0 8Ty5x5abUU5tib+JqvkTXD2Ij+67Z1rY55nO4AiTqj0HYFeUF22Mt+xVACIQnfSfpgDu +LmOjb+tLP3rr3xCnl8xW6EWjiaTMyRJlK61FBxcT2OLaV8hUoRRrL0IXilaRrexhI3H f82Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=F+E0kHhs; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-71945-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71945-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id cl20-20020a17090af69400b002963d0fe262si4998168pjb.77.2024.02.19.12.20.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 12:20:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-71945-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=F+E0kHhs; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-71945-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71945-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id F41E3288C1C for ; Mon, 19 Feb 2024 20:14:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 58EA3535B6; Mon, 19 Feb 2024 20:13:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="F+E0kHhs" 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 6AF6953E14; Mon, 19 Feb 2024 20:13:18 +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=1708373598; cv=none; b=hG99hK8cswFwZLHYdYAYEEjSBHk7zULChJkKdvs/PO8vPk/v8lG+3J40mb7WmXYFKv3MgaFpoH7CyyERvn9wxy6Os+ggYovG74GhDjeaeFNUydJdhsxgZwZMYGP8ELUQCgSnd5z3B3ssivdiXdNlndX3eunMr2xgHGT2pM0Q6OA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708373598; c=relaxed/simple; bh=tx/TfnzZDoT1xc33L7S2O95jgvmeHSm+n3Hd+KXFKug=; h=Mime-Version:Content-Type:Date:Message-Id:Cc:Subject:From:To: References:In-Reply-To; b=NDXshKvqL6GqBXMhiKY+JGb3gfcO6S/H60J35jdQRbue727YIIe5amixIB6mlM5tgWCB/SlbL0wOuclJhIcedxAk6G56mmji/OoMIxgv+iRWcAIO0jJLaWmypixc4gyrCluTy0VG4G2bc9OSBLTAkCw50jFm3p1Jl7KmX8SWh40= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=F+E0kHhs; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id CFBF4C433C7; Mon, 19 Feb 2024 20:13:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708373597; bh=tx/TfnzZDoT1xc33L7S2O95jgvmeHSm+n3Hd+KXFKug=; h=Date:Cc:Subject:From:To:References:In-Reply-To:From; b=F+E0kHhsWnbpdV4fYP618TSw+he67latBuAV2MowUC+oXcBU04zMlV0vllkfTjbzD up4tIWcbCqgtBx5Y4SMH9Jiz3mklIxyGJ3Wq+DnQtGHOvqAFhmtCl8F/XMnE6UeBuv 4HxhPuE3c3r36XHap/50FJsS+y4bFOR+/p0FfsR4PCrB3aSvPaXVPOOPaZrcVNq9hJ ezE3QeHhjtclg5u7LcD5JttuEwHtJd7fo90Ixo4k9ah6T5o8bfh+T3ADLSg6/KqMF4 2qEKuogN4WkPrvMB5R2ND6KFAhzYxip/UdUQvxDZo5q1bBxAYs2aJolUX1cj3tLjYj eptSBGVuhGtyA== 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: Mon, 19 Feb 2024 20:13:14 +0000 Message-Id: Cc: , Subject: =?utf-8?q?Re:_init=5Ftis()_takes_50_ms_on_Dell_XPS_13_9360_=E2=80=93_almo?= =?utf-8?q?st_10_%_of_whole_time_until_initrd?= From: "Jarkko Sakkinen" To: "Paul Menzel" , "Peter Huewe" X-Mailer: aerc 0.15.2 References: <0eba23c7-f62a-4a85-a383-60dec9d198f9@molgen.mpg.de> <512bdab4-1779-4407-aa7b-57d1af015fc1@molgen.mpg.de> In-Reply-To: <512bdab4-1779-4407-aa7b-57d1af015fc1@molgen.mpg.de> On Fri Feb 16, 2024 at 10:20 PM UTC, Paul Menzel wrote: > Dear Jarkko, > > > Thank you for your reply. > > Am 16.02.24 um 23:07 schrieb Jarkko Sakkinen: > > On Wed Feb 14, 2024 at 3:10 PM UTC, Paul Menzel wrote: > > >> Trying to optimize the boot time of Linux on the Dell XPS 13 9360, > >> probing of MSFT0101:00 takes 52 ms, making `init_tis()` taking almost = 10 > >> % alone until starting the initrd: > >> > >> [ 0.000000] Linux version 6.8.0-rc4 (build@bohemianrhapsody.m= olgen.mpg.de) (gcc (Debian 13.2.0-13) 13.2.0, > >> GNU ld (GNU Binutils for Debian) 2.42) #20 SMP PREEMPT_DYNAMIC Mon Feb= 12 09:40:49 CET 2024 > >> [=E2=80=A6] > >> [ 0.000000] DMI: Dell Inc. XPS 13 9360/0596KF, BIOS 2.21.0 06= /02/2022 > >> [=E2=80=A6] > >> [ 0.320057] calling init_tis+0x0/0x100 @ 1 > >> [ 0.332190] tpm_tis MSFT0101:00: 2.0 TPM (device-id 0xFE, rev= -id 4) > >> [ 0.372164] probe of MSFT0101:00 returned 0 after 52101 usecs > >> [ 0.372186] initcall init_tis+0x0/0x100 returned 0 after 5212= 7 usecs > >> [=E2=80=A6] > >> [ 0.588643] Freeing unused decrypted memory: 2036K > >> [ 0.589068] Freeing unused kernel image (initmem) memory: 397= 6K > >> [ 0.606115] Write protecting the kernel read-only data: 22528= k > >> [ 0.606527] Freeing unused kernel image (rodata/data gap) mem= ory: 276K > >> [ 0.652327] x86/mm: Checked W+X mappings: passed, no W+X page= s found. > >> [ 0.652329] x86/mm: Checking user space page tables > >> [ 0.695968] x86/mm: Checked W+X mappings: passed, no W+X page= s found. > >> [ 0.696104] Run /init as init process > >> [=E2=80=A6] > >> > >> For users, where boot time is most important, can this be moved out of > >> the hot path somehow? > >=20 > > It can't be IRQ probing as IRQ's are *disabled* by default. So we can > > disclose that. > >=20 > > I think the delay is caused by tpm2_probe(), which is called by > > tpm_tis_core_init(). It sends an idempotent TPM2 command to the TPM > > chip to know whether it is TPM 1.x or TPM2 chip. > >=20 > > That detection is definitely required. > >=20 > > Even some other subsystems in the kernel require to know the correct > > TPM version, like hwrng and IMA. > Understood. The TPM in my laptop does not change, so could this be=20 > cached, or does a Linux CLI paramater exist, that I can specify the versi= on? Oops, I totally ignored tpm_chip_register() which runs more TPM commands: 1. PCR alloction: tpm2_get_pcr_allocation() 2. self-test: tpm2_do_selftest() (in some cases also tpm2_startup()) Just probe (a single trivial TPM command doing zero calcuation) causing that long delay would not make sense, so sorry for misleading with this! So the problem here is in-kernel clients of TPM that initialize during the boot such as IMA and hwrng. The call for tpm_chip_register() is in the tail of each chip driver, i.e. it is in the "overall" framework and thus theoretically could be relocated to a workqueue. This requires tho changes to all clients and error code for the case where tpm_transmit() flushes this workqueue but initialization fails. So *I think* (was not fully scientifical feasibility study) it is possible but it is not as small change as you would first think.=20 > Kind regards, > > Paul BR, Jarkko