Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp908238pxb; Wed, 13 Jan 2021 20:17:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJxvnCJEQHv32YetSFLc3cMJfXIxNJS46sLH3El8/nEnCquWfJq7XVc9UA+qZ/+VAqTuEoy4 X-Received: by 2002:a50:cdc8:: with SMTP id h8mr4380451edj.293.1610597840778; Wed, 13 Jan 2021 20:17:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610597840; cv=none; d=google.com; s=arc-20160816; b=d8BVHp99bE5vUevxLmgmUrvPVwp8aTblArXUsNZcHQnHWbiT0dIiqpZVFhZOOV3GaD IESnfU9pmKZI7z0Grb8oE9A7a5tDlFOV18EQyvbQqn1XVhm++aY/57+FbhGCznjt7f8o 6AWb9Q1iv7L/UlQ7dJo3Gbe8ONBkphVif/h2afsrYMywW8Y8KdboX2xjadDtNQzSyfYK Y30bgehKR+NRN4DuxZ8MheRt2GVkhBnlVfVoo7ZgysznXZRgMfwrT1Biaq839shnNpth kENm7vj2wb1P6HbPdF1RWjoolin10Zhr1iER6bwKaxRFRbPf206P8772HXTiqEK8htYj GMWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=VB8CS8RHwEPuimN6GNgazgZcwi29OqIs1+MD+blGzBc=; b=DPvpKtek5skauhLByPEX6zMPWM9v/JKfsV+1kpg+gF7HJOWvLnIXFN08SJUos3hiEw ut97pfk9Q8PZ+2uoMI+mqfFyfidqSRwRw9qhaN5ghfJnloCVLB8BokZrNvRqZAoMo2Sa LHX4u/jTNV4Bu5mktAEsm/O4g6k9bLd6Be0+MlT7C5bX2wyJf1jrSgyYaaR/vW8GK159 QqKbwS44PAbRsjKG3SQu7L41eIicHWASN6en9kSMEjQmRTAz3NUuloD7Plqzvk/ygNaq WiTdYEKhNLFwaDGAzB9yslHGkA8ePWwApXVzSb7EvC6Lr+q5NXC2H5gsFh6c1lVJotPI hvrQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k20si1902545edo.493.2021.01.13.20.16.57; Wed, 13 Jan 2021 20:17:20 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727063AbhANENE (ORCPT + 99 others); Wed, 13 Jan 2021 23:13:04 -0500 Received: from out30-45.freemail.mail.aliyun.com ([115.124.30.45]:41688 "EHLO out30-45.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726013AbhANEND (ORCPT ); Wed, 13 Jan 2021 23:13:03 -0500 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R831e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e01424;MF=tianjia.zhang@linux.alibaba.com;NM=1;PH=DS;RN=6;SR=0;TI=SMTPD_---0ULg9c1f_1610597536; Received: from B-455UMD6M-2027.local(mailfrom:tianjia.zhang@linux.alibaba.com fp:SMTPD_---0ULg9c1f_1610597536) by smtp.aliyun-inc.com(127.0.0.1); Thu, 14 Jan 2021 12:12:16 +0800 Subject: Re: [PATCH] tpm/tpm_tis: Fix variable reset during IRQ probing To: Jarkko Sakkinen Cc: Peter Huewe , Jason Gunthorpe , linux-integrity@vger.kernel.org, linux-kernel@vger.kernel.org, Jia Zhang References: <20210113120021.59045-1-tianjia.zhang@linux.alibaba.com> From: Tianjia Zhang Message-ID: <44c35c27-0cd4-e451-1b9c-d6fe48e58e51@linux.alibaba.com> Date: Thu, 14 Jan 2021 12:12:16 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.6.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. IRQ tpm_tis_core_init() tpm2_probe() tpm_tis_send() -----------+ | tpm_tis_probe_irq_single() | | devm_request_irq() | 1 priv->irq_tested = false | tpm_tis_gen_interrupt() | | tpm_tis_send() | irq_tested = true | <------------------+ if (priv->irq_tested) return tpm_tis_send_main() /* probe IRQ */ tpm_tis_send_main() --------+ | 2 chip->flags |= FLAG_IRQ <-------+ priv->irq_tested = true Best regards, Tianjia