From patchwork Sat May 1 13:57:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 12234777 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING,MIME_BASE64_TEXT,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5BD92C43460 for ; Sat, 1 May 2021 14:01:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 354CD61606 for ; Sat, 1 May 2021 14:01:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232218AbhEAOC3 (ORCPT ); Sat, 1 May 2021 10:02:29 -0400 Received: from mout.gmx.net ([212.227.17.20]:50487 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232107AbhEAOC2 (ORCPT ); Sat, 1 May 2021 10:02:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1619877685; bh=RgBW5Llz3Gd05UPmRrb/vbkD7pYHh6Mi+0IqtBPln2I=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date; b=XdKvzKFbe3iEtKke6KioJXeTfxgB2SPHwT5Si4Wwmenh2pv/+fk201mHIjpIwlKCh CpNDzs++OuAruXQWmfWiRK1imqAtCxK/qwX6A+0pyUzIJFsIahBkdU974UPSYaEVvc b4/si9yddez5SwFZMJHRKSslOio9LVTZ5qlFGCZA= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from Venus.fritz.box ([78.42.220.31]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MtwYu-1lHzyr0OUe-00uMYz; Sat, 01 May 2021 16:01:25 +0200 From: Lino Sanfilippo To: peterhuewe@gmx.de, jarkko@kernel.org, jgg@ziepe.ca Cc: stefanb@linux.vnet.ibm.com, James.Bottomley@hansenpartnership.com, keescook@chromium.org, jsnitsel@redhat.com, ml.linux@elloe.vision, linux-integrity@vger.kernel.org, linux-kernel@vger.kernel.org, LinoSanfilippo@gmx.de Subject: [PATCH v3 0/4] Fixes for TPM interrupt handling Date: Sat, 1 May 2021 15:57:23 +0200 Message-Id: <20210501135727.17747-1-LinoSanfilippo@gmx.de> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-Provags-ID: V03:K1:aiaCLqpOKyoGAAuVi0cfk9zRy3LK1+nvq+0Xw8lzQKVUVwohYzV 3jgYWbp9klzCLC6lx1PRgDV7i19Or4k3NZmeDkMyBJXWmSTrvPqDkPf0ziCt49HFxGNkydO e+mRJOETdKVVQDEFf7j4gzDXWNzGxeOt3XN8tNBoO7zLY9CJwovtwGMmgPVf4G6dG5UjCbk y573jfjNtG1JLjXA9IHGA== X-UI-Out-Filterresults: notjunk:1;V03:K0:gAzax5rgC1s=:dnfqU71FG/BrKDmGP5C8Kr Cjq1Mzkm5nPdRthUYok3cMeMjJ64dIgQy3qV6VXJpHgb5N3fbvRQm5ohHus5q4G1DAzKemTFA csKyb5zvj7+c+xfO/xLa10/9nlZSWMACb6Ouu05SbEA64tNseq7o2wx2qltbfiodoCeiA90Gu OF2BaLcgUFJB0bf/KcLSI9O7xLSUWdMC/1H2Llgqy7qyq14+flk087YXxUwNDCZmfj+OLNoea gwLhmKll0a7ii2g+Xnzof2dvAEe0EU6xADD3H3x9SydZRpdSLlVtBxgKYccK1r5fzO/+FXyXk kHFrcqHIE5dimuLleXZrtnnmkQzRGJgJIFZk5fCZBP3beCnpbFINUI3DW7wluQRp06TeNBrHb +21jzxRWQ0gS2XQ3ga1IO1t5rjS++rRZ919uQGbAlI6Rid7HQRw5GnvRvkqri+rufw3OKjj4n MsPiRRRs+kAmtnAM4tT9Zo6iIAwHjEB11tMaKeRWQQMjm4440D+40ZPDBa/jal3xZLAdz04I8 Ztr12dO8kOyzweAVMeI+YkqVwxa+t9AMydrgVbiMAjvvwwHVA/lj2MRpRmlUkDOmYQA8b26Jr YbXLkq9QMc1sZkpN1fulxj/ia5hmWqDPAr5eS073YoMvJ1vaggfaxJCZFACnXeQelOJrMuEaF qs2XqfYW0ITmlRahjyul8fVq7Ep1osTISb4NTZTMl5nNFup0QepKdKD/4ZxrwK8G88BTlk2HL sMwMZFYtnCw2s6Tmcwqz3RoIbgs9ArwC2+22us7c7G58Pj02MYA53i/Yd2sW7UQcKLaClZxBI +2fQ/1IBXLqQD19/ehVsDK/DBFpIYh/lO3sqqORwxBQvtpqeRRgu3+kPLAqhESJTGGBjFPKTT Ln5KJHp6GWFEkvEnrksa28iHSoGsUukjITD/ZDbeGc2xuyNIkWLJb/UTznfFKhiRSRMGvExnk lXqiw6o/kiXwiBoGe0B7K+rl/wAt4aW2CdWpvK7vFeunyHDAlxjkIJ8kt0MTmrka4MM6ITo1F NfVK8CyZIXZJuTecD2RsS1aaOO/nnnEDON6cUtwngJMZoq9SVrQWFgyBbtw8FiCcMqfzcAU4l yeirbBuskgl0+LqvYIrGsL2xJCyxaaPqlmFsSG0PiPOhHaUB+07pFeVxTy7ivw/HX5mw3iDP1 q1YbbWiAgSleS/Uck8pjgxLA65EFvTIaixjjv9gJwkQ/r1kQekZ6Eri4tisvEN6ZBvCcKq4kT Q+H1ZQATwOly8ZCCk Precedence: bulk List-ID: X-Mailing-List: linux-integrity@vger.kernel.org This series enables interrupts for TPM. For this some obstacles had to be removed first, like the interrupt handler running in interrupt context and thus not allowing to access registers over SPI. Also the locality handling has been simplified to make a complicated synchronization between threads and irq handler unnecessary. As a side effect of this simplification a bug is fixed in which a TMP command is issued without a claimed locality in case of TPM 2. Another fix concerns the interrupt test which currently is broken. Finally the results of the capability query at startup is used to only set the interrupts which are actually supported by the hardware. These patches are based on commit 9f67672a817e ("Merge tag 'ext4_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4") and tested on on a SLB 9670 which is connected via SPI. Of course any further testing is highly appreciated. PATCH 1: The SPI implementation of the functions to read/write to/from registers uses mutexes and thus require a sleepable context. For this reason request a threaded interrupt handler. PATCH 2: Simplify locality handling by taking the driver locality (0) at driver startup and releasing it at driver shutdown. This also fixes a bug in case of TMP 2. PATCH 3: Fix and simplify the test for interrupts. PATCH 4: Only set the interrupts which are reported as being available. Changes in v3: - fixed compiler error reported by kernel test robot - rephrased commit message as suggested by Jarko Sakkinen - added Reviewed-by tag Changes in v2: - rebase against 5.12 - free irq on error path Lino Sanfilippo (4): tpm: Use a threaded interrupt handler tpm: Simplify locality handling tpm: Fix test for interrupts tpm: Only enable supported irqs drivers/char/tpm/tpm-chip.c | 40 -------- drivers/char/tpm/tpm_tis_core.c | 170 +++++++++++++------------------- drivers/char/tpm/tpm_tis_core.h | 2 +- include/linux/tpm.h | 5 +- 4 files changed, 72 insertions(+), 145 deletions(-) base-commit: 9f67672a817ec046f7554a885f0fe0d60e1bf99f