Received: by 2002:a25:b323:0:0:0:0:0 with SMTP id l35csp2017605ybj; Sun, 22 Sep 2019 17:41:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqzgZLUO+Z7C/rHJBghrYV4C67u6JBDjNNSjJIP3RY1R9G+clcUI/6WlIIKLYVQVgzQ2lslp X-Received: by 2002:a17:906:139b:: with SMTP id f27mr27368621ejc.195.1569199263098; Sun, 22 Sep 2019 17:41:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569199263; cv=none; d=google.com; s=arc-20160816; b=fmnn4CWj0qZuBHVOzIpYX8Jb/yUSnEuzZi70Od5jCLfNj7v44T8ww5hUA67hi14rtc JGsOY27Zfw7960znN6CN92Rj7zwQigN1wJPhxd+DOqX2cMIAdHUKnmweIM0gORkDr93U ibzg+LG2jaxT9ATJ0joZFDcNR0Oj92l18DxVVrE1OD3XnV/YJxLZeGDqyCN5KOTIUQF/ tu6HAvrQh4runl/4Es+x5YkWFNc7IXIvfwJ7RM1XQqZtQyiP+qh8HmZ+gfxWoSNb0Eos nzt9IX/QEdCa9XDWir0cy8Xzid/c0JyhUpQOlH/Hb3Ioxf1fjQvwfPj1NGnghGuLhwqv 4odg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:organization:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=UblFaFzKHSI+IfphGe4Z5TMNSEB5Vd+6ZEP+QAHAxtc=; b=q+bt/iLGjTBe0KVlg8IAi333Y2qFCMgWLZgFiMKhMov1nCoz15TkvhyMtCMOLVavfx i4Q3dxloGZW8onYwVlTDSfRIEAPDkzkN0Uj8lgDy9awM6utXWPAt5TYSXoAkCUFAGLWp KolfWPP0TkA3QfXLN8Qs6XHsz17Py2TlG58yOOzGiGhrGU5jKt+0yyIMnd7XweHYdtaE wdwD89mCTHX+7ejQIsIjz8icqtueb8KDK53++hLJUEWmGfWlpRVsv9FSQEPyUh1XEQSW ktlzpDPW4Ax54tuO3z7sCtAjUJ2ckBNpd1BDZuKf5lH6OPbdvSi2ASB1wFANvEfQ+Ytw cnpw== 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 d10si4272096ejb.259.2019.09.22.17.40.39; Sun, 22 Sep 2019 17:41:03 -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 S2390317AbfITPDC (ORCPT + 99 others); Fri, 20 Sep 2019 11:03:02 -0400 Received: from mga06.intel.com ([134.134.136.31]:20443 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387693AbfITPDC (ORCPT ); Fri, 20 Sep 2019 11:03:02 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Sep 2019 08:03:00 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,528,1559545200"; d="scan'208";a="387632241" Received: from eergin-mobl.ger.corp.intel.com (HELO localhost) ([10.252.40.12]) by fmsmga005.fm.intel.com with ESMTP; 20 Sep 2019 08:02:58 -0700 Date: Fri, 20 Sep 2019 18:02:57 +0300 From: Jarkko Sakkinen To: Vanya Lazeev Cc: Peter Huewe , Jason Gunthorpe , Arnd Bergmann , Greg Kroah-Hartman , linux-integrity@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v4] tpm_crb: fix fTPM on AMD Zen+ CPUs Message-ID: <20190920150257.GF9578@linux.intel.com> References: <20190914171743.22786-1-ivan.lazeev@gmail.com> <20190916055130.GA7925@linux.intel.com> <20190916200029.GA27567@hv-1.home> <20190917190950.GG10244@linux.intel.com> <20190917205402.GA2500@hv-1.home> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190917205402.GA2500@hv-1.home> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 17, 2019 at 11:54:03PM +0300, Vanya Lazeev wrote: > On Tue, Sep 17, 2019 at 10:10:13PM +0300, Jarkko Sakkinen wrote: > > On Mon, Sep 16, 2019 at 11:00:30PM +0300, Vanya Lazeev wrote: > > > On Mon, Sep 16, 2019 at 08:51:30AM +0300, Jarkko Sakkinen wrote: > > > > On Sat, Sep 14, 2019 at 08:17:44PM +0300, ivan.lazeev@gmail.com wrote: > > > > > + struct list_head acpi_resources, crb_resources; > > > > > > > > Please do not create crb_resources. I said this already last time. > > > > > > But then, if I'm not mistaken, it will be impossible to track pointers > > > to multiple remaped regions. In this particular case, it > > > doesn't matter, because both buffers are in different ACPI regions, > > > and using acpi_resources only to fix buffer will be enough. > > > However, this creates incosistency between single- and > > > multiple-region cases: in the latter iobase field of struct crb_priv > > > doesn't make any difference. Am I understanding the situation correctly? > > > Will such fix be ok? > > > > So why you need to track pointers other than in initialization as devm > > will take care of freeing them. Just trying to understand the problem. > > > > We need to know, which ioremap'ed address assign to control area, command > and response buffer, based on which ACPI region contains each of them. > Is there any method of getting remapped address for the raw one after > resouce containing it has been allocated? > And what do you mean by initialization? crb_resources lives only in > crb_map_io, which seems to run only once. Aah, I see. Well at leat we want the dynamic allocation away from the callback e.g. use a fixed array: #define TPM_CRB_MAX_RESOURCES 4 /* Or however many you need */ struct list_head acpi_res_list; struct acpi_resource *acpi_res_array[TPM_CRB_MAX_RESOURCES]; void __iomem *iobase_array[TPM_CRB_MAX_RESOURCES]; If there are more resources than the constant you could issue a warning to klog but still try top continue initialization. PS. Use for new symbols TPM_CRB_ and tpm_crb_ prefixes. Because of easier tracing of TPM code I want to move to this naming over time. /Jarkko