From patchwork Thu Nov 24 13:55:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 25546 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp3410856wrr; Thu, 24 Nov 2022 05:58:01 -0800 (PST) X-Google-Smtp-Source: AA0mqf6WjXF29+zGUl7neOYeqObnBKyIFaOwk+dfEOwjzHXcd41casyV/81rUKO5VAA8dvXnANVU X-Received: by 2002:a17:906:1713:b0:7a3:fc74:7fb4 with SMTP id c19-20020a170906171300b007a3fc747fb4mr28991650eje.17.1669298281247; Thu, 24 Nov 2022 05:58:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669298281; cv=none; d=google.com; s=arc-20160816; b=RG3G2KZ/oB6MbDWHKnep34WeOytHitBazUDj02drQG3DmGqyYqErqq3qoJFpNIPprZ qfSaxur3py+dTI/ZsOdkvLrREdxcqM4KslHxZH19A4z8JR84+/FB350JSq5Ah83JVCLn 6F2+Zt8iTKZAcvkoHLa1RvjOAJa/2VgLnBXPkfeo8Bf+Cpen4XnzMMbW3ZGjqNC0f9LU s70ObmQL3zHxAGHYNnroeJsG9yl3Ej/9sM7DRemgGMoL3QuERL3TJZGkNvmOIZxBZZnm p/gbjK2fo9dHj/fuaKk9yTvBSk080GdCEB6epAk4MkhajWRqBWtsRHGYmsh1zyXxG7C9 kacQ== 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=ptF3+UGs4RT73xf2t1eIkj3kEEU2mVqh+94Ww0mBJ/Y=; b=Cv6Jxnn3HF4H5EOXK/3HtpIUUc6ZCPFz/z+ogTHTnbU7qKD4f4njyV8NGDUoB+9PC9 Vc2FsLW9lOr9WCqDQs7exnMM1/fdo0liy3KGdn3Fn+dQ/cTkB/+xxNfhFCTr4ojeOD6L 3xYx7Lw/yFgzSaJoxKLLjMk04xJ9MGFM07xhuwk7iFZxGajsntbth+bEDE96KLe2iru5 oh57eEADTRTY3buAZNfCJtWFGAXo9LsxDjjmVKCUVSHrVQeI2lciAX58cbvuxnUhaOxM 6rln7hgqoi+fJCOfQSSiXGRiusFo7O1ojJW5CHTiaoJbkaHlwpipIqwajz+I0RWcCeLm qBHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=AnW4r+Os; 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 by4-20020a0564021b0400b0045be16903d0si969454edb.310.2022.11.24.05.57.37; Thu, 24 Nov 2022 05:58:01 -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=AnW4r+Os; 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 S230233AbiKXN5J (ORCPT + 99 others); Thu, 24 Nov 2022 08:57:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49446 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230121AbiKXN4g (ORCPT ); Thu, 24 Nov 2022 08:56:36 -0500 Received: from mout.gmx.net (mout.gmx.net [212.227.15.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 959531144A0; 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=ptF3+UGs4RT73xf2t1eIkj3kEEU2mVqh+94Ww0mBJ/Y=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=AnW4r+OsnxZ+EYbiLrZC1GEfrkwBMKkGjVbunHu9MVuFBEg8tJv4TkeXrSLD8HVib 2pL4ZWpLDB/eD/XjdwtKOR9haHd/ygJ6ThKqgy9/vfglCvO6Pbo1kuqmRc0bZj3mQY /f8di0hXImAOFVtsTfmQx+PYBCWY2sP79gtebkLS9Z4HuOd91+qjJX3OJKePk60qeQ l8hDjg7fSqtIjxHmL9x1u2WHIQXjKaouDYKWr11xC6htp67F/b/morily0q26F37N9 RYQ40TQZ6JMYnsIVae5hINasFXYcMTIQYx0F+Yxz/OBSLs/U80QpK6RTlJydrAY71c /6JnRskhZrXug== 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 1MjS9I-1pLxfF1RgQ-00kulG; 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 04/14] tpm, tpm_tis: Do not skip reset of original interrupt vector Date: Thu, 24 Nov 2022 14:55:28 +0100 Message-Id: <20221124135538.31020-5-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:xa3nABt20tkSDNQZTlmJqGyJFMR+Hbk/kMbprAIaZ7AODF6LfDJ Ga0c6+Iat/fGjI8FJXKlN6Y9C2aNPvUmcmx5LzMenvb2JTFxXVDHdC6ureaQ7UKKFobQMW7 XZbwotp3OCfIyfy9i35yO3DFlo9WhGXR1BKBPiDVYPyWupMdSJaUjIlU3aMBqdP2chOexIU kCDWZSOL7frbQ5qM+piSg== UI-OutboundReport: notjunk:1;M01:P0:2Hr5OHt1gBo=;NUhu4G4cDfH7sTC3pjO8cBUfk7h tZCb0PHuDXpJsMonJd/CvI5LHnzBltvRtPHblBrRTMe5zFPGZSBmlWjqTefk1dH/wNHET60lr MrAaRG4l1xqlw+AEztk4wr1UoiS6tI2dwXuae9XpRuOE3eZVLYJ2J0O86eHVn1ZZBQ6tmQPJ0 Ge7zmvA0ZYoWmruFXMO7b8+rIhuMzo1aXOvI8IIHY0jLKvemekT3PSHPNOzntqA3SwPG+7lUc mVX+T0njRTLcGoWJSiuJFFH4RJrCgwST+L0/cINzUydQbzfJbN1YfpstXTvd8FE9NeHEhbqaI bkG7d8K7NKmauHaF+dZ1tSDhMsn1Qt2zCcNRZgXZ0NcN75qE8OR9x35gWfmKgAA3snMok0kl4 fPJinvr5oX6R/ZrNrqJ7sU0B3xbNsAnzneaCcHxCdTR2jO5VMiXN6U3PG6xjxlUwprDeXoNE4 FUZMvVyz90wGq+t0BSgnjFgMPIHh3oJChdWNRrghoX3GjFFEFqVvEAUJGGbPqnptk5dfkiirr RNdt/t65fxSfRF+HhsZqF8x3SYQMfD24J7pfbAOihuafH3q3z5le9d+juhl/puqHxTjG5QOqb 4hpAjCxlS/ELD80617vknBZlTnXp/49vAQfqJVjEKRx5kFiYHZIC+HMUnWJZd8RkWGTpuhHWD bLfwdAKSTe26fFaf449kTB6P+D080NwhGsgde3udeqt3o/H5V2wbiL0MHDmgxOkCu2nrpSGZG B5UwJmzvN47wxJWSOMXE0mcxWjPENKu/8C57BAXYUCL1XHBrlWi5zZC47PqWil4BLb6Q76cKs hg2Jbw47bupIuN4sC9OOsHMJiCZkdw9Z1qfqqNTbQROvsUxxA86weCLHZ+T9xA1Uo5gOa8ARg vMuYmSUIxQaxA1qjmg1zDKADcCxzIxg397Ivy4DzgSzzACqQg73a84aE1+/+NVZM2ZNaz8NvS OmIYpA== 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?1750386114490977339?= X-GMAIL-MSGID: =?utf-8?q?1750386114490977339?= From: Lino Sanfilippo If in tpm_tis_probe_irq_single() an error occurs after the original interrupt vector has been read, restore the interrupts before the error is returned. Since the caller does not check the error value, return -1 in any case that the TPM_CHIP_FLAG_IRQ flag is not set. Since the return value of function tpm_tis_gen_interrupt() is not longer used, make it a void function. Fixes: 1107d065fdf1 ("tpm_tis: Introduce intermediate layer for TPM access") Signed-off-by: Lino Sanfilippo Reviewed-by: Jarkko Sakkinen --- drivers/char/tpm/tpm_tis_core.c | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c index 603b82ca56da..81b9726d3ed2 100644 --- a/drivers/char/tpm/tpm_tis_core.c +++ b/drivers/char/tpm/tpm_tis_core.c @@ -729,7 +729,7 @@ static irqreturn_t tis_int_handler(int dummy, void *dev_id) return IRQ_HANDLED; } -static int tpm_tis_gen_interrupt(struct tpm_chip *chip) +static void tpm_tis_gen_interrupt(struct tpm_chip *chip) { const char *desc = "attempting to generate an interrupt"; u32 cap2; @@ -738,7 +738,7 @@ static int tpm_tis_gen_interrupt(struct tpm_chip *chip) ret = request_locality(chip, 0); if (ret < 0) - return ret; + return; if (chip->flags & TPM_CHIP_FLAG_TPM2) ret = tpm2_get_tpm_pt(chip, 0x100, &cap2, desc); @@ -746,8 +746,6 @@ static int tpm_tis_gen_interrupt(struct tpm_chip *chip) ret = tpm1_getcap(chip, TPM_CAP_PROP_TIS_TIMEOUT, &cap, desc, 0); release_locality(chip, 0); - - return ret; } /* Register the IRQ and issue a command that will cause an interrupt. If an @@ -777,42 +775,37 @@ static int tpm_tis_probe_irq_single(struct tpm_chip *chip, u32 intmask, rc = tpm_tis_write8(priv, TPM_INT_VECTOR(priv->locality), irq); if (rc < 0) - return rc; + goto restore_irqs; rc = tpm_tis_read32(priv, TPM_INT_STATUS(priv->locality), &int_status); if (rc < 0) - return rc; + goto restore_irqs; /* Clear all existing */ rc = tpm_tis_write32(priv, TPM_INT_STATUS(priv->locality), int_status); if (rc < 0) - return rc; - + goto restore_irqs; /* Turn on */ rc = tpm_tis_write32(priv, TPM_INT_ENABLE(priv->locality), intmask | TPM_GLOBAL_INT_ENABLE); if (rc < 0) - return rc; + goto restore_irqs; clear_bit(TPM_TIS_IRQ_TESTED, &priv->flags); /* Generate an interrupt by having the core call through to * tpm_tis_send */ - rc = tpm_tis_gen_interrupt(chip); - if (rc < 0) - return rc; + tpm_tis_gen_interrupt(chip); +restore_irqs: /* tpm_tis_send will either confirm the interrupt is working or it * will call disable_irq which undoes all of the above. */ if (!(chip->flags & TPM_CHIP_FLAG_IRQ)) { - rc = tpm_tis_write8(priv, original_int_vec, - TPM_INT_VECTOR(priv->locality)); - if (rc < 0) - return rc; - - return 1; + tpm_tis_write8(priv, original_int_vec, + TPM_INT_VECTOR(priv->locality)); + return -1; } return 0;