Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp225873pxb; Fri, 15 Jan 2021 01:27:10 -0800 (PST) X-Google-Smtp-Source: ABdhPJxy5i0+RvJFaLnN7vh5oevKN48TnMMsze+EZWnIPS+H8BAyyLvOhVKzHvhbhQ03ugmux4Sp X-Received: by 2002:a17:906:46c7:: with SMTP id k7mr7987027ejs.33.1610702830618; Fri, 15 Jan 2021 01:27:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610702830; cv=none; d=google.com; s=arc-20160816; b=FINKbtoXg3qHZZ77aPa6vRT9oOxf8ra7KKeSagvSsbHuUoH/qHqg6Eih/TTINS+m2G ZCOH2Lsoq7Gl+Cmlnrt3WtbAPVpDaoE0x7W4hMie9V8ODmWkltP7YHZO32yPsFMPiRH7 ibhm7kka9QzU1O3g2iHZuZr10kw9GHny01boaVUjiEBZrx4exHaUs++JNOi85AZWopOE QpevC6B64Zno7ZxSRJjCuoa9/E+36YEpxtfjef/qJDecqpJtz9QrNqOEYs7NoJNFanV9 c5C4BvZmLdvVJzERoE1ZDp3DETiHnkrFEpX19VIFNLhfG9IcQh/19qy4iFQ9q4iIeR3j FlOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Def5aM1WBoBwsosBx/xs4GTfQdN99s58VWJaZiX+YeI=; b=aQcqBekwRI+XROo+yvvk+PBo5sg9Il/NlNQZ/ZeA3L+pj+gjriQmEGyoVWJWh/2eEA bJ7j1nxX4UOV3oZfJfotA5a/c/R8N4qMyudF5KDjZw2260rpugV+2kI1LwDfNSrsbPG4 0+E2B+06VgJyh2XtSCrn5Sbf+o2XHYWmL/vgX8DlkbrSVOy6AeJPASrwAwk+9HDw608n m/zb675lTHMQ4oZmBNCW6TTGbfX55bbN09KMm1W/5kTLiYUQRAtnqS9wBaO9GqnsjIZl LZ8aniHYOXaR7iVRH3n6IXvbzKzHJEULhyJP+mpofVhmc9AabLulyQb1HH3L6w/ilJmq Ax/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=aEdo1JA6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v24si553419edy.557.2021.01.15.01.26.46; Fri, 15 Jan 2021 01:27:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=aEdo1JA6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728937AbhAOJYc (ORCPT + 99 others); Fri, 15 Jan 2021 04:24:32 -0500 Received: from mail.kernel.org ([198.145.29.99]:39432 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727204AbhAOJYb (ORCPT ); Fri, 15 Jan 2021 04:24:31 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id AC61A2339D; Fri, 15 Jan 2021 09:23:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1610702631; bh=VCDpaZeUdppA614VVCSLc4aWw7dTZlkr+EHOCN3aUfQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=aEdo1JA6/YfMV06tEfWDZpY8hbvb8EAbWe2pBi5L8Dw6h2GNDMjqCaxpLExYEJbSk /QtmoEtSr+OhlsIdR9oxDk3jz3Sg/cUI855MqtuZFmOdmc7tYK0IkNg+Hnd8J8KzhA FDkKnAyJv4z3diOOEDgyIP4EJIW8bcM4wpdgd7bR2h+gKlGxECRHkHY9VD1GiQmS8O FM88DYAUdKkI/qQl3jhWSUjoOI6dOPL3xX9b8KsAwFIl2D04v5cfDUgz4LeGchbc80 W5H6J9i1GRgSr/UaWYUW+fOW/x6RjgQN1kxXsQTbE5mUi7My1sa8d8nY2iBLPX0diq YYpqtz80ilwOw== Date: Fri, 15 Jan 2021 11:23:46 +0200 From: Jarkko Sakkinen To: Tianjia Zhang Cc: Peter Huewe , Jason Gunthorpe , linux-integrity@vger.kernel.org, linux-kernel@vger.kernel.org, Jia Zhang Subject: Re: [PATCH] tpm/tpm_tis: Fix variable reset during IRQ probing Message-ID: References: <20210113120021.59045-1-tianjia.zhang@linux.alibaba.com> <44c35c27-0cd4-e451-1b9c-d6fe48e58e51@linux.alibaba.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <44c35c27-0cd4-e451-1b9c-d6fe48e58e51@linux.alibaba.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 14, 2021 at 12:12:16PM +0800, Tianjia Zhang wrote: > > > On 1/14/21 10:51 AM, Jarkko Sakkinen wrote: > > On Wed, Jan 13, 2021 at 08:00:21PM +0800, Tianjia Zhang wrote: > > > In tpm_tis_core_init(), tpm2_probe() will be called first, this > > > function will eventually call tpm_tis_send(), and then > > > tpm_tis_probe_irq_single() will detect whether the interrupt is > > > normal, mainly the installation interrupted, set `priv->irq_tested` > > > to false. The logic will eventually be executed to tpm_tis_send() > > > to trigger an interrupt. > > > > > > There is currently such a scenario, which will cause the IRQ probe > > > code to never be executed, so that the TPM device is in polling > > > mode: after setting irq_tested to false, an interrupt occurs > > > between entering the ttpm_tis_send() function, and the interrupt > > > will be first set irq_tested to true will cause the IRQ probe code > > > to never be executed. > > > > Can you describe the scenario more detail? > > > > The problematic scenario we encountered is like this. The following figure > shows the execution flow of tpm_tis_core_init(). An interrupt occurred > before the IRQ probe. This interrupt was caused by tpm2_probe(), but it was > triggered before the IRQ probe was executed, and the interrupt handler would > set irq_tested to true, so the IRQ probe code can never execute, that is, > the code marked 2 in the figure will never happen. TPM_INT_ENABLE is cleared on reset [*]. [*] Section 5.9.1 https://trustedcomputinggroup.org/resource/pc-client-work-group-pc-client-specific-tpm-interface-specification-tis/ /Jarkko