From patchwork Thu Nov 24 13:55:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 25543 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp3410769wrr; Thu, 24 Nov 2022 05:57:48 -0800 (PST) X-Google-Smtp-Source: AA0mqf4cn/O9mR4iQ45Ut8NBgr/58lB98EOflVwikQf/roBZA7tzDeuu0LC5PSLAd/5KpdXycsqV X-Received: by 2002:a17:906:c7d1:b0:7ae:fdcd:8198 with SMTP id dc17-20020a170906c7d100b007aefdcd8198mr28790041ejb.475.1669298268341; Thu, 24 Nov 2022 05:57:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669298268; cv=none; d=google.com; s=arc-20160816; b=lYrCYGUY2eFsfjjtVy83NQrDK4yBppbLcHy8KgQCAE95dEqE1J4ZeZeakuC7vxY4/s BdfiL3eCWpcjOiSEZ3RPl0jhETNVtJZUklPoFGVuVlXklFABkfYOlMVnCySVnMfQITx9 SsqxEJc52dagsYSrP+0plPGlZm4gfEYhczQ8N1bSdjSR2dcqaLwAbBHWl8KhsgGHNqHm dZAv4Pp0Dk2drnzaz2NLHkXLr3ytvK61CHs+zohXjSwEtg59XbEQ8qS2vM6NZ07JRitn bkoXQgO5/zfRbqjRLrkwUlDz2i+p073WbPfn9qlSVBqW+O+PZVt/C4MFACsHx6ReUgpr 7e8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:ui-outboundreport:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=1jiHlANZ8thD5aPn63BXGYT+VamFBFNIAjBcdG+2s2o=; b=ckeW8jTWeKJgI6kvzuGkGwJ8L7Ia7XQ201Bb32/C+tnWXZQ91c0o8LxwFbyA5+STev duHg5vTyOX1sXbdT8ZbWF483UEXvS84mEW/qDcmDaCCcKb3MQt1Gq/mHHnOKDth5M50n 3SH7b2X9HHXca2f+daThKowBV7jdpYBMiJLZEco318ZNhYRfl6iVoU6X9pkT+DSX1iyX cfjoYtSS5HBcBNkoC/xA1MI7SAOI5rTrcmJMpphkpUQrLr7ptHoQp5oF4517pHKO1WPH dg7Eh/pfk8nsiQwGazW6RYhs7ZqNsPpNm9akfAaV7XEyT8qc3tk9yBqZyaqeWHG6p6IC Gy1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=UOWVQLAE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmx.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sa26-20020a1709076d1a00b0078db1343eedsi1096797ejc.774.2022.11.24.05.57.24; Thu, 24 Nov 2022 05:57:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=UOWVQLAE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmx.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230218AbiKXN5D (ORCPT + 99 others); Thu, 24 Nov 2022 08:57:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49498 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230111AbiKXN4f (ORCPT ); Thu, 24 Nov 2022 08:56:35 -0500 Received: from mout.gmx.net (mout.gmx.net [212.227.15.19]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D4A90109581; Thu, 24 Nov 2022 05:56:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1669298170; bh=1jiHlANZ8thD5aPn63BXGYT+VamFBFNIAjBcdG+2s2o=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=UOWVQLAEwRmAhazeSMBLFFnEeZy4gaNKKbQmhUqSmkj6Ds/Ve8rIw9q2g/zYhgyS4 073XagHy1yL/rfdAnUv7rCaphbUI7buTJJQWBFr/+wjFBL0IGjG/vC/WwoHsNxDH7a IwMxByKnRINLR1UX/1aoCR6xfAtkAtvYxIFSAdX54CMYfF1qVQqe30y0u/1JPjNOBT h1OSSuf1GrbwBERkRaMAREm82q6wx3mKvQdIejQyuxyyKwtsL5chZexwF+HNYEvvHA ShZBo1Z2+XrNENaTX2Nts2UX0b0FdKTr1R8CVpsoO4g/JTxsuvl73DnsJPlYRrrSBz B0znFO4OCbJ0g== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from Venus.speedport.ip ([84.162.7.17]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1M7b2d-1oqDQ72fZF-0081Ir; Thu, 24 Nov 2022 14:56:10 +0100 From: Lino Sanfilippo To: peterhuewe@gmx.de, jarkko@kernel.org, jgg@ziepe.ca Cc: stefanb@linux.vnet.ibm.com, linux@mniewoehner.de, linux-integrity@vger.kernel.org, linux-kernel@vger.kernel.org, jandryuk@gmail.com, pmenzel@molgen.mpg.de, l.sanfilippo@kunbus.com, LinoSanfilippo@gmx.de, lukas@wunner.de, p.rosenberger@kunbus.com Subject: [PATCH v11 02/14] tpm, tpm_tis: Claim locality before writing TPM_INT_ENABLE register Date: Thu, 24 Nov 2022 14:55:26 +0100 Message-Id: <20221124135538.31020-3-LinoSanfilippo@gmx.de> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20221124135538.31020-1-LinoSanfilippo@gmx.de> References: <20221124135538.31020-1-LinoSanfilippo@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:DZ1Si0DEmG0L5zHqGquL0G/lLXvo4a2ppnyqcfrgWJfcYCf7Evj S3kJKA7ORN7oi5wckuLKqgRyKtpzDQGPPW+gaaxPTAY/62eZs2hEzMb+LktxX5jXaPLZT7W 4UsVNmm3BRmeZIBJvlTodcp32nv9qgYVmr4gNEhMO7lXPO288X73suCMIwKiacAY/U5o+kh zPPJe5zd2kaImK7yWj7JQ== UI-OutboundReport: notjunk:1;M01:P0:+7AxXzLltVk=;pdVShctUccjd2fZJI04dQxP2BEN zjUxWppz68TTq2Cz61wHDjPFHD4XPz55tfD3UG72J3zU77dHfFGT+dRUwtk8G1HuLFGCtwdxv rnDwaBtx8+v/d9YRMH2yIavLhYVwyz79yreWrcHLjbhl217evFjHK2TPnfIb2iygOKTwbSqB3 gIjAWOctPSohtyq7UZTc+aIKvbkz4ka8JhiolhwPltFnS14+0R9FalLo6c4AHztfDirVPPP+q 3XKPa7L2TcL7RzzOsgBz5STmXEfgczQkl+GoxEaAsYbCDe+kJEdYXPpfsrRVDGb6s9ZdKjuvf dUY9/r+X7vvpfNN3bdFGaDuf9UXnD8QW2ombbj54EJRmdIhUefS0XQb4kL1N9F3eTal9VvGYh ao/RdyrE8U29s5yMOpEUZcGkLMvYnouTb/6CsxRpMEzbpPsL4QgEzhIwiqWkzCUwrnWYeQv/P 87cVWPoRW8m5cf1Laionh8QUl3jg1Ns9Jlqd/50FxP60nTv6I1NWiNexDZLT2Fk1tzZWuI3ev 3Z9PXh6GwfFvtkLTl0/ivZYqhOXWf4R26xRYNPNliZxdR65NCga85Sf5M7cVszBOoEIJbG/SJ /0/ANPdT4V/f49NCoYUfK4MDqqOQCLwAdMmrtxPuVKyDCxokyOJQtbayCcP17wFGnkGUiCClq Gbu23jugtQzzfPcOqs6YKarckYAzQVtLgldOhu+21u6bny5Z7I5FH22ykDwyLcpABdPuzHd2C TQnyaQvtTIcitTNeLnNCzmqbguAiDt4kCy4D5dZ42tKc3NCWZj+diZLHB/tJYpLEL5eirqHIJ 1I/trltoN1ki/n1CTSX1nAXgHtBdPAWOcav2G09awz/owNnaswUcTDVBkZ3GvyRJHp6xw4u31 2/+M63ZIFK1MCWe8xYE3n/Uc4IMb1cOjfCPcWFmwgkMzZh9z2arIynj7UvqKgjXVdJPVe8mdx 3UG0DA== X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750386101024984048?= X-GMAIL-MSGID: =?utf-8?q?1750386101024984048?= From: Lino Sanfilippo In disable_interrupts() the TPM_GLOBAL_INT_ENABLE bit is unset in the TPM_INT_ENABLE register to shut the interrupts off. However modifying the register is only possible with a held locality. So claim the locality before disable_interrupts() is called. Signed-off-by: Lino Sanfilippo Reviewed-by: Jarkko Sakkinen Tested-by: Michael Niewöhner --- drivers/char/tpm/tpm_tis_core.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c index c0008efb95dc..d2c9c9d76893 100644 --- a/drivers/char/tpm/tpm_tis_core.c +++ b/drivers/char/tpm/tpm_tis_core.c @@ -1098,7 +1098,11 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq, dev_err(&chip->dev, FW_BUG "TPM interrupt not working, polling instead\n"); + rc = request_locality(chip, 0); + if (rc < 0) + goto out_err; disable_interrupts(chip); + release_locality(chip, 0); } } else { tpm_tis_probe_irq(chip, intmask);