Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp2199366ybe; Tue, 3 Sep 2019 09:18:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqyFXaxEl32D4tEeSPjosrpFao9vNgQNCZhOThj1RtWR2MAXfY0o6hLwnzUy0od0o5lDf6q0 X-Received: by 2002:a17:902:7c13:: with SMTP id x19mr7000883pll.322.1567527482934; Tue, 03 Sep 2019 09:18:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567527482; cv=none; d=google.com; s=arc-20160816; b=kKLZwXF/E+zMSb8TAiIaHypf1vUPlh6yUXhxaf7T2e2UkLe2PFrhNp+M2s9YZkMRox A1Y96+T71wWcTpQO920fsijr86dLR8dj5izAWriowf/JPCA1Hu4X/kqI2hon+09la2sh D7Ih1Oj94SLsA17PzMhgQwB5znLUnF+1fDvXiyXc5iaKBDP6vA+4i8VnP9arEh7CRawp kVvFfg3qz2SZMWoBrLbjBoNQiHsU/YttZ4Ka6NUjrAzzS7FiAak4XmBjkDLRB1e1lfz5 IYc0ZXPTUONtdyWPbh13nUVasifjP+qb7C1HY7MIIloqYYjg00wt4BrqRa2jljXOkqvf 1YlA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:organization:references:in-reply-to:date:cc:to:from :subject:message-id; bh=HMvRQ8pjGqm452E3huSRxtQt8HMvoIxmyX5bmolPAQI=; b=c7D2k+D0j+5scL5txZh3TiITidxXnN+c2SA520tViK/+LsLJE7dLFbkOICbRu3eMjr dG8Ni7GbEg6JZdmdeuf3/nZLIrACR05jrtgyVoT7oZolzY+pA8iRphX/2CuR9c9WuQ3L ugMz6UyEvT1BGorR35fG0ePJ/gyQCwVJLMgr69Ky28iwSgAF/fuJOF6d8c7k30nS0eYl aJLt0LNcfr5nOLgpblWifK5rh3CK2VZqXtexmLkKBIfmKwm5v5iHO3RrbbeAT/dfTPTU dEVp2otSrUNcT0gn0cWoTUM48usIyMW+i7avsQHY1ksnUqoqoizu01XgWYQXuFq6Z+ZQ xx1w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j25si17190452pfh.142.2019.09.03.09.17.47; Tue, 03 Sep 2019 09:18:02 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729953AbfICQQy (ORCPT + 99 others); Tue, 3 Sep 2019 12:16:54 -0400 Received: from mga18.intel.com ([134.134.136.126]:44742 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728571AbfICQQy (ORCPT ); Tue, 3 Sep 2019 12:16:54 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Sep 2019 09:16:53 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,463,1559545200"; d="scan'208";a="184805065" Received: from vkuppusa-mobl2.ger.corp.intel.com ([10.252.39.67]) by orsmga003.jf.intel.com with ESMTP; 03 Sep 2019 09:16:50 -0700 Message-ID: <3f3ce42707f09eded801ff8543be6aee6ef35cf8.camel@linux.intel.com> Subject: Re: [PATCH 2/2] tpm: tpm_crb: enhance resource mapping mechanism for supporting AMD's fTPM From: Jarkko Sakkinen To: Seunghun Han , "Safford, David (GE Global Research, US)" Cc: Jason Gunthorpe , Peter Huewe , "open list:TPM DEVICE DRIVER" , Linux Kernel Mailing List Date: Tue, 03 Sep 2019 19:16:49 +0300 In-Reply-To: References: <20190830095639.4562-1-kkamagui@gmail.com> <20190830095639.4562-3-kkamagui@gmail.com> <20190830124334.GA10004@ziepe.ca> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.32.2-1 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2019-09-03 at 18:56 +0900, Seunghun Han wrote: > Thank you for your notification. I am sorry. I missed it and > misunderstood Jarkko's idea. So, I would like to invite Matthew > Garrett to this thread and attach my opinion on that. The problem is > that command and response buffers are in ACPI NVS area. ACPI NVS area > is saved and restored by drivers/acpi/nvs.c during hibernation, so > command and response buffers in ACPI NVS are also handled by nvs.c > file. However, TPM CRB driver uses the buffers to control a TPM > device, therefore, something may break. > > I agree on that point. To remove uncertainty and find the solution, > I read the threads we discussed and did research about two points, 1) > the race condition and 2) the unexpected behavior of the TPM device. > > 1) The race condition concern comes from unknowing buffer access order > while hibernation. > If nvs.c and TPM CRB driver access the buffers concurrently, the race > condition occurs. Then, we can't know the contents of the buffers > deterministically, and it may occur the failure of TPM device. > However, hibernation_snapshot() function calls dpm_suspend() and > suspend_nvs_save() in order when the system enters into hibernation. > It also calls suspend_nvs_restore() and dpm_resume() in order when the > system exits from hibernation. So, no race condition occurs while > hibernation, and we always guarantee the contents of buffers as we > expect. > > 2) The unexpected behavior of the TPM device. > If nvs.c saves and restores the contents of the TPM CRB buffers while > hibernation, it may occur the unexpected behavior of the TPM device > because the buffers are used to control the TPM device. When the > system entered into hibernation, suspend_nvs_save() saved the command > and response buffers, and they had the last command and response data. > After exiting from hibernation, suspend_nvs_restore() restored the > last command and response data into the buffers and nothing happened. > I realized that they were just buffers. If we want to send a command > to the TPM device, we have to set the CRB_START_INVOKE bit to a > control_start register of a control area. The control area was not in > the ACPI NVS area, so it was not affected by nvs.c file. We can > guarantee the behavior of the TPM device. > > Because of these two reasons, I agreed on Jarkko's idea in > https://lkml.org/lkml/2019/8/29/962 . It seems that removing or > changing regions described in the ACPI table is not natural after > setup. In my view, saving and restoring buffers was OK like other NVS > areas were expected because the buffers were in ACPI NVS area. > > So, I made and sent this patch series. I would like to solve this > AMD's fTPM problem because I have been doing research on TPM and this > problem is critical for me (as you know fTPM doesn't work). If you > have any other concern or advice on the patch I made, please let me > know. Please take time to edit your responses. Nobody will read that properly because it is way too exhausting. A long prose only indicates unclear thoughts in the end. If you know what you are doing, you can put things into nutshell only in few senteces. /Jarkko