From patchwork Thu Nov 24 13:55:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 25548 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp3411053wrr; Thu, 24 Nov 2022 05:58:25 -0800 (PST) X-Google-Smtp-Source: AA0mqf6AELj5OA+2uy1lk5neCnfMhyNIv0uWzMMRu9/8D1EfvJfjlBLjiEBm359M7Qk9vVjNb9CE X-Received: by 2002:a17:906:64e:b0:7b7:c1b9:8cb4 with SMTP id t14-20020a170906064e00b007b7c1b98cb4mr13082896ejb.96.1669298305662; Thu, 24 Nov 2022 05:58:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669298305; cv=none; d=google.com; s=arc-20160816; b=nulpELpYMGZH7p3qONe58N7NA7GQFna4+PsreM0WIaHY8wfMYNjELHYkhnSgJESoaq 0/6oTUvyGNCRHIbbjEKn/9CW0hjOc55TnmjTv5Z7de91zVS/y3qqmKIHzSp+aI7o6Nez gJvTugvQBCwGQe8dRCrYZvLXX+2FR9HiBtrGJ8Y45tpMrG0lfqm5R8EG6vR3FVcilBxR QXBH1z4zxbSUs49EzGg9Bg8M5Fuh26tJHTO9eC/EHu7IG2iotcMoYKLQx82iUTadkjRq Fr1XmPhE3MctwILOiBFZTVeXbPEAulN3o/XILWN3ydO0PNeO3W6S+dFZMyS5J00wRQ57 R/dA== 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=nfj6LxEEakS1d9oZm1Vln0mVngkSUD4WhjDUy9R8goU=; b=08KvaMStT0/W4rPrBlqWNJeyuGyO9T/15THw/iYVXZ0wefxDj0mZie2O/5cj0Dou+h oSJsBRTtVN/GD0D60UX5GchEHQ09EGasn+y4DCfMqV1yNkG6LhWgiaW2vPW5W98r2t42 yOk1VcI31S0d7OpSE5bL51We7aUD4BCQMxXgpVrdZactYXOYFb9rptiiAnWYwtnO6ZgU gEgDbNFG9gFBC4o5Xe/D5qUZIk0eHB8sMUlfbLb4+1VfuxQrCrgW58FOelmZ5sgjO+ea WL6Td8PnT8g7JeUtw9x/86ir2RtPA4d7VdNkDtITqGZQmBm5831TN4J0pCpu9+G9z8MQ DlTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=SIpKaQvo; 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 wz2-20020a170906fe4200b0078e176ef65csi843898ejb.723.2022.11.24.05.58.02; Thu, 24 Nov 2022 05:58:25 -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=SIpKaQvo; 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 S230319AbiKXN5P (ORCPT + 99 others); Thu, 24 Nov 2022 08:57:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49458 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230134AbiKXN4g (ORCPT ); Thu, 24 Nov 2022 08:56:36 -0500 Received: from mout.gmx.net (mout.gmx.net [212.227.15.15]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B75CE11604C; Thu, 24 Nov 2022 05:56:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1669298171; bh=nfj6LxEEakS1d9oZm1Vln0mVngkSUD4WhjDUy9R8goU=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=SIpKaQvo39+/4NrHUTAzIjtNS5X9hGHJXHnX2qgwSeaYMSlJAWLIEIOrpYEZJ5YJb B0FJwZQ6RQrFs2+hPoNhUklaYNeB+c+bHvNV/20JwkWh3cr1XpvJme9DSfu9WDBgiZ AYOnCW2Nte1anJo7A70I0jbPaI0gIS4wOcGbfuyCLvNBHwCgmXLvJQ7694NghaNXt9 KjrCrIwLFuYGHuXZdVXm9Zz5jNnla+R2GMK3sYObxu0LszAQqUkVx9JjcbZLP0uo8U SVXp280OBqTY5qX+yrhhefftRzbsp6nAjJ8pwSucyofUNTAGwhEdvxUN5P7HV6fEZo A12ltdQolCm3g== 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 1Mjj8D-1pLgY42t7j-00lBsR; Thu, 24 Nov 2022 14:56:11 +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 05/14] tpm, tpm_tis: Claim locality before writing interrupt registers Date: Thu, 24 Nov 2022 14:55:29 +0100 Message-Id: <20221124135538.31020-6-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:VB7psXmoZkW0IM+pjguIbLL50aHa+0ppnyDiamI4IevQAzorTbS DN1FMlxqHjwgFCmjNlcT78/3720y6XYjrRdytKbwNyd144yREiDnpOfPqeUEm0EIJQDZjGp tEY69lnVO+hH7TRvSapOJ6ScMoYrJ5h+pBUw/wKv/wO4H1LxHxMqeP1ht+jq7PInvG+ddyV 3yK5Qmy5ivPI8+G76VBPA== UI-OutboundReport: notjunk:1;M01:P0:HR9zpvCBO74=;u5PMihDoYh3FpZMRJEm9ZrHdye6 1SNHWZzEn+F0ZHl2nXdF8XG0FN+EbfqlIb8rCY3GUf2RXY2kvY5bxJo6/5XOpopibay6itEoz xhrKNV4nIB48OfkcZzLDjKuoR+vcQ5AFjn7LBpcvoHsfV13GdUraeCE/bPQ7H6hjqGWvEyPKw eX2YryeXpKPDaGoC/4QJgpUN63LNf/PddP1CAJjnZ9hc7moa6J8uonaAcs3cqpLRsxcE78YI/ 6L/+QtrCgQpChjWP9TODeOQX65QExUgwEOAL84CKCn6BPpriCMl/ToqMj/zGUOLrs0nL3SZOo 8YJc9VcbCGoiyT/x1gPRRFRqftFNAxS5fkWeNoWC5HIt2OQbJujvgz9MGDLAqK/CUN9tYcKIp jK1j9mTg9omWDmnttzGcWaPW2qJmne/VPubOIaX1OHTiS/cjXX8ImSz5WP5Pe05sVhMZA/vvB vTFked3bgOXobgiPm7o4BXcSwtTMKokJ1BOVGoyMTWccmccl0ysqFHSNVTbYmV8hMjpoSeZm7 XPcQh5ug9TX1vdtBE4DOh1fx1GGwGADRT1oaYZr3JS+nlugIz/aP4tSnLuIKscWYLzuI0jH69 zMxdjlR5IA5pNOp1wjdXBG+n4U4OwOEgAL6oM6o3hRkfJrxYwY6CRPuAY9ZTFK7+3nggpTgw1 z65G4KJiV5Q+ejVsbUumDicWvn+JPyxeKYYLSu9QCGzmztoPUS4msyJKM5shswK3ZuIeL8SF8 hpsgFRA6bS4BbThyZ7k61tZb6w+c0mGimoLZEQ20WmU6YdXBZ7kQB+aL8al4ET5f6+in/wtKn Z+Rqo4wf4z5Rd7tFlfobyQM63xai5jf6t23bZjMYvBY/jKZw2yLJ1ONWUVqjNQfj5p3x4If7x 3M1b8oZqBUUUt3e/yauhsJsqo0atO3Ql4r/feU7yc5R2wOKJsZiD/Evi5UpjkHbKBJ9sh11IQ Az97XcDFLwnor90Ro5xyscPImiM= X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,MIME_BASE64_TEXT, RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H2,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?1750386140208164123?= X-GMAIL-MSGID: =?utf-8?q?1750386140208164123?= From: Lino Sanfilippo In tpm_tis_probe_single_irq() interrupt registers TPM_INT_VECTOR, TPM_INT_STATUS and TPM_INT_ENABLE are modified to setup the interrupts. Currently these modifications are done without holding a locality thus they have no effect. Fix this by claiming the (default) locality before the registers are written. Since now tpm_tis_gen_interrupt() is called with the locality already claimed remove locality request and release from this function. Signed-off-by: Lino Sanfilippo Reviewed-by: Jarkko Sakkinen --- drivers/char/tpm/tpm_tis_core.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c index 81b9726d3ed2..49848268f547 100644 --- a/drivers/char/tpm/tpm_tis_core.c +++ b/drivers/char/tpm/tpm_tis_core.c @@ -736,16 +736,10 @@ static void tpm_tis_gen_interrupt(struct tpm_chip *chip) cap_t cap; int ret; - ret = request_locality(chip, 0); - if (ret < 0) - return; - if (chip->flags & TPM_CHIP_FLAG_TPM2) ret = tpm2_get_tpm_pt(chip, 0x100, &cap2, desc); else ret = tpm1_getcap(chip, TPM_CAP_PROP_TIS_TIMEOUT, &cap, desc, 0); - - release_locality(chip, 0); } /* Register the IRQ and issue a command that will cause an interrupt. If an @@ -768,10 +762,16 @@ static int tpm_tis_probe_irq_single(struct tpm_chip *chip, u32 intmask, } priv->irq = irq; + rc = request_locality(chip, 0); + if (rc < 0) + return rc; + rc = tpm_tis_read8(priv, TPM_INT_VECTOR(priv->locality), &original_int_vec); - if (rc < 0) + if (rc < 0) { + release_locality(chip, priv->locality); return rc; + } rc = tpm_tis_write8(priv, TPM_INT_VECTOR(priv->locality), irq); if (rc < 0) @@ -805,10 +805,12 @@ static int tpm_tis_probe_irq_single(struct tpm_chip *chip, u32 intmask, if (!(chip->flags & TPM_CHIP_FLAG_IRQ)) { tpm_tis_write8(priv, original_int_vec, TPM_INT_VECTOR(priv->locality)); - return -1; + rc = -1; } - return 0; + release_locality(chip, priv->locality); + + return rc; } /* Try to find the IRQ the TPM is using. This is for legacy x86 systems that