Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp2124141lqb; Mon, 27 May 2024 08:34:30 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXQmMGh9X25V8Bt9O1HyolvDCVtsTWkPMytRoH5Tu1jpQ9RZsvIszOY/RVwu3A3SpqvZ6qKUUSlIV9Lty/JHEJRPqQpjWkpi11zkwtzxA== X-Google-Smtp-Source: AGHT+IGy5FroaFTJJ6FXGe2U5Gk6I1rn8u7f4C1/VmlCoqVChyUbLy2Z6Hy95RZdKUeSqFf+RABs X-Received: by 2002:a17:906:2dd7:b0:a59:ccbb:595b with SMTP id a640c23a62f3a-a62642e937amr897114066b.25.1716824070105; Mon, 27 May 2024 08:34:30 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716824070; cv=pass; d=google.com; s=arc-20160816; b=IPwbstfO3E77ei0gpMIyVk7LIr5UXzWb9qR9wYLWEvwUC9jMQqV2+y7sFPNaoGYaVH ZVS8tZcji7jWYWvY+FThpPtJP7e3kQEGzsvYPi9QWlj8ZaSsdDIBjXZj35ZV8WOcqnjT J+bUT975sDSWX2IGpdioUnsljBJwJffZ3Nb1b+xZI0ey7SKjfi/N83jeCx/ni6Sln75u Ym1ApzUXX422fsUgFii4RMnfx6K2gP8iKr8GTA103y/Lz7EIkeDgiqTgPOgfbTkEpstO Fx3SgZ9hskpaOoTll1qG36gxMvAESqER74WB1YvSZUUsPNSOC7d/2ugdCMweh+t4xKVd CuNQ== 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=LrfkFv0M1mkdns0VxOb2bwmL0a6bKbjb8RNGrrtUXx0=; fh=yuCYQ7HIoP60MtyoFLu00ufkCuNieanFqc8q9aCj4MI=; b=vSiPmYL/RYlJik6Pqp6xmVQbvLyaKg6MYCs8wMsgzq+y6bXVgCLzpZyu8aOrQ73V4Y sDStS4XPONb/FjyJtE0nNmUNLzlB1xemPiWbyerR1Mlf1ILPnZazo/D68Qof215ZujjI 07Jvm6G2INc8hp0RmYFpUCoPgDGi1DM/gFmuzpsT2vKqdL2gJs4SJqcbsgWV2eDAiHVo NJ5QtVvS9oR4VgyKiYz/chpi3zrxUfJbTfQUrefSf4/h1XtnmIYLPwhU5UVfaIreeyVc /0Or11SQgutr6CODQm0kvppYMhZyzj+w140vAwBtQ9vwjNzLWAtpdpf1kmfIto3cM+gG 6s6w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=S9LQcvId; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-191080-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-191080-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a640c23a62f3a-a626cd959aasi381259066b.887.2024.05.27.08.34.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 May 2024 08:34:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-191080-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=S9LQcvId; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-191080-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-191080-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 997871F235B8 for ; Mon, 27 May 2024 15:34:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0E7EB61FEE; Mon, 27 May 2024 15:34:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="S9LQcvId" 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 1A73717E8EE; Mon, 27 May 2024 15:34:08 +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=1716824049; cv=none; b=atqtR8K52oKolUXgJozRgAvMvVOFAyXQIhWtZN4q1siRbe+cyCqiPZZ53oLV5L7jHR74fgVmuPindEmTVesUXOnnpmxvvK+nxp1B0wP5Np2c8zMoEjqpHlIuSCQ24B1LFKTWdz+Pt46H8iAwxifloh11TWsvT+tddPFTNK/g9bU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716824049; c=relaxed/simple; bh=9Z8aW8EOSlQCc9328Ru+wW9mtQVAXa7pMChCkwHdm2g=; h=Mime-Version:Content-Type:Date:Message-Id:Cc:Subject:From:To: References:In-Reply-To; b=EpO56oKHj6IIzQx5QhK7iNGW2HbkGdbs7cOL7T/k17Nld/UkEYnjwZoC61plniCYzAvZxEctcqNwfcPABfn2krZRvb7JlJ6W6Bt7BJqBKK7eW3oRRxgl37b1qkgMTWw+aIUrFFLhIy6W2H/be+xD8zlYerAhZAZgsQOE8szufJk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=S9LQcvId; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id BA671C4AF07; Mon, 27 May 2024 15:34:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1716824048; bh=9Z8aW8EOSlQCc9328Ru+wW9mtQVAXa7pMChCkwHdm2g=; h=Date:Cc:Subject:From:To:References:In-Reply-To:From; b=S9LQcvIdN654rNWQLGatJnNi//JKdlKhGRJPVr/+1HYI8v8ARsZxMPDM1fBxTR3f/ VZ6MuU65+YbJzLSwbIe/aVoaQu5WkYrYnGSLkwme/ltHVAbkRIK3OevYhoQH2GqAh1 XML8Xdmwvbio+Tzo8HwHkuJ+yMquvXPZCDAFzITBEp7HINM37f98He1lV+sNVihUzQ /ldhnPm62C2z5eLMHEWhtZFYh6OlF5sUEm5PzSIDzvdQ+ilHUwabk+k4KU2U9cqdFJ 8YMbQ6zisfA3yNkNuuwXzfChnL3ArEhonC2BhGjVYXqoc9M1ETgrx5jO0l6D4XWQ26 n4s/2lShs/Y0g== 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, 27 May 2024 18:34:03 +0300 Message-Id: Cc: , "Peter Huewe" , "Jason Gunthorpe" , "Mimi Zohar" , "David Howells" , "Paul Moore" , "James Morris" , "Serge E. Hallyn" , , Subject: Re: [PATCH 1/3] tpm: Disable TCG_TPM2_HMAC by default From: "Jarkko Sakkinen" To: "Jarkko Sakkinen" , "Vitor Soares" , "James Bottomley" , X-Mailer: aerc 0.17.0 References: <20240519235122.3380-1-jarkko@kernel.org> <20240519235122.3380-2-jarkko@kernel.org> <850862655008f84ef0b6ecd99750e8dc395304d1.camel@gmail.com> <17dc838120b56ce342c34611596c7b46dcd9ab5a.camel@HansenPartnership.com> <2dd8d49516ec9c7cb8c1182b5b8537b1e82d7067.camel@gmail.com> <17a5dcd7aceb356587ef7c8f45b0f6359b2d2a91.camel@HansenPartnership.com> <0c12c9ea10aa97e246230fc33e6b35c571102b48.camel@gmail.com> <3e4bbd0f0fe9f57fd7555a3775e8d71031c0d6c5.camel@gmail.com> In-Reply-To: On Mon May 27, 2024 at 6:12 PM EEST, Jarkko Sakkinen wrote: > On Mon May 27, 2024 at 6:01 PM EEST, Jarkko Sakkinen wrote: > > On Mon May 27, 2024 at 5:51 PM EEST, Jarkko Sakkinen wrote: > > > On Thu May 23, 2024 at 10:59 AM EEST, Vitor Soares wrote: > > > > On Wed, 2024-05-22 at 19:11 +0300, Jarkko Sakkinen wrote: > > > > > On Wed May 22, 2024 at 5:58 PM EEST, Vitor Soares wrote: > > > > > > I did run with ftrace, but need some more time to go through it= . > > > > > >=20 > > > > > > Here the step I did: > > > > > > kernel config: > > > > > > =C2=A0 CONFIG_FUNCTION_TRACER > > > > > > =C2=A0 CONFIG_FUNCTION_GRAPH_TRACER > > > > > >=20 > > > > > > ftrace: > > > > > > =C2=A0 # set filters > > > > > > =C2=A0 echo tpm* > set_ftrace_filter > > > > > >=20 > > > > > > =C2=A0 # set tracer > > > > > > =C2=A0 echo function_graph > current_tracer > > > > > >=20 > > > > > > =C2=A0 # take the sample > > > > > > =C2=A0 echo 1 > tracing_on; time modprobe tpm_tis_spi; echo 0 >= tracing_on > > > > > >=20 > > > > > > regards, > > > > > > Vitor Soares > > > > >=20 > > > > > I'm now compiling distro kernel (OpenSUSE) for NUC7 with v6.10 co= ntents. > > > > >=20 > > > > > After I have that setup, I'll develop a perf test either with per= f or > > > > > bpftrace. I'll come back with the possible CONFIG_* that should b= e in > > > > > place in your kernel. Might take up until next week as I have som= e > > > > > conference stuff to prepare but I try to have stuff ready early n= ext > > > > > week. > > > > >=20 > > > > > No need to rush with this as long as possible patches go to rc2 o= r rc3. > > > > > Let's do a proper analysis instead. > > > > >=20 > > > > > In the meantime you could check if you get perf and/or bpftrace t= o=20 > > > > > your image that use to boot up your device. Preferably both but > > > > > please inform about this. > > > > >=20 > > > > > > > > I already have perf running, for the bpftrace I might not be able t= o help. > > > > > > The interesting function to look at with/without hmac is probably > > > tpm2_get_random(). > > > > > > I attached a patch that removes hmac shenigans out of tpm2_get_random= () > > > for the sake of proper comparative testing. > > > > Other thing that we need to measure is to split the cost into > > two parts: > > > > 1. Handshake, i.e. setting up and shutdowning a session. > > 2. Transaction, payload TPM command. > > > > This could be done by setting up couple of kprobes_events: > > > > payload_event: tpm2_get_random() etc. > > hmac_event: tpm2_start_auth_session(), tpm2_end_auth_session() etc. > > > > And just summing up the time for a boot to get a cost for hmac. > > > > I'd use bootconfig for this: > > > > https://www.kernel.org/doc/html/v6.9/trace/boottime-trace.html > > > > So I've made up plans how measure the incident but not sure when I > > have time to pro-actively work on a benchmark (thus sharing details). > > > > So I think with just proper bootconfig wtih no other tools uses this > > can be measured. > > > I'll disable this for anything else than X86_64 by default, and put > such patch to my next pull request. > > Someone needs to do the perf analysis properly based on the above > descriptions. I cannot commit my time to promise them to get the > perf regressions fixed by time. I can only commit on limiting the > feature ;-) > > It is thus better be conservative and reconsider opt-in post 6.10. > X86_64 is safeplay because even in that 2018 NUC7 based on Celeron, > hmac is just fine. While looking at code I started to wanted what was the reasoning for adding *undocumented* "TPM2_OA_TMPL" in include/linux/tpm.h. It should really be in tpm2-sessions.c and named something like TPM2_NULL_KEY_OA or similar. Obfuscation *on purpose* by definition... Since I see such spots (liked e.g. tpm_buf_parameters() to name another instance) sprinkled, I've pretty much locked in the decision to limit hmac to x86_64. It is right thing to do given not so great maturity level. Whatever on x86_64 I'm confident we can fix for sure any issue but cannot make such analysis on other platforms. BR, Jarkko