Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1183200imu; Wed, 23 Jan 2019 12:11:28 -0800 (PST) X-Google-Smtp-Source: ALg8bN7Y1/dixzmUsjbkrBqE/Dvqk8o1808RN2xjDRJ9myJ0J/+8rxtoZsKXo5nUWvrrKuf+KmL2 X-Received: by 2002:a63:6442:: with SMTP id y63mr3275656pgb.450.1548274288193; Wed, 23 Jan 2019 12:11:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548274288; cv=none; d=google.com; s=arc-20160816; b=T37C2uwgtO34iVHwS6HILehZYfUFNzTGiBzZXE98ksd/2CpxASGPFaivm3fBFXqrQa DFqpQUfe230dStwL7OJl4KQV/NR58hZCD0cDEDSg1oqIiPjmEDFyLkV94oy9peu7Uc+S oa3kuFVGV2uOQFuD+Bsockd1jtPQVQzZCwIJaIMu/3ugkG3yLeqclIlVoKeCQyxXHYI4 jaVK1k+LPHOTUWU5G8yw6XkRumVbsbXNwOBc8Xx3k9ecaoe++FnYC2J00IKUJlhr5axT R08PdQABURrlC9JJO9cqLOsh6UpWD+A8XJ8ZaojuiIM470UlnUijiyuGg38fZ5MTnTLw VcUw== 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=wSWSnQhyJJhNIQdw472jEsK7z2WGLwUTFosrkgApOwo=; b=vO/SE++QP7zmyvsSx/NSCYnYbtcmoz7WjocKVJZ4w0C14HI767ObEhBBDxOtN7JX+4 Y7DGSRLZqdY5xXz6p1uy9mJGehISMR8ybBfk1YIvJTGdGsMqoNk1Xcv9s5Hl6NOvx2Fn 37TUQi1Tc4qVpKjN0ulcbWGwoxl7QZQLbM/Uv5m2zlSjXRAsAEF9ir76I7AOm2xYyrWu pv9BMLJqe1w8HC28K+ajssjMvR0vGTZXUzgVG2KJJZjA1MHAx5n4WSA8z5IdUsAOPWMV vJ72+bYG8cp+sC8bOVuDagCX2ziECYOR72uRGyyVLKOWELhDTRq1n4NgWpXyxjj90D8X RbAQ== 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 s80si10916351pfa.130.2019.01.23.12.11.12; Wed, 23 Jan 2019 12:11:28 -0800 (PST) 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 S1726234AbfAWULH (ORCPT + 99 others); Wed, 23 Jan 2019 15:11:07 -0500 Received: from mga18.intel.com ([134.134.136.126]:37380 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726035AbfAWULG (ORCPT ); Wed, 23 Jan 2019 15:11:06 -0500 X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Jan 2019 12:11:05 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,513,1539673200"; d="scan'208";a="112117495" Received: from rkazants-mobl.ccr.corp.intel.com (HELO localhost) ([10.249.254.156]) by orsmga008.jf.intel.com with ESMTP; 23 Jan 2019 12:11:01 -0800 Date: Wed, 23 Jan 2019 22:11:00 +0200 From: Jarkko Sakkinen To: Linus Torvalds , tomas.winkler@intel.com Cc: Jason Gunthorpe , James Bottomley , linux-integrity@vger.kernel.org, linux-security-module@vger.kernel.org, Linux List Kernel Mailing Subject: Re: Getting weird TPM error after rebasing my tree to security/next-general Message-ID: <20190123201100.GA21074@linux.intel.com> References: <20190118142559.GA4080@linux.intel.com> <1547849358.2794.90.camel@HansenPartnership.com> <20190120160413.GB30478@linux.intel.com> <20190122010218.GA26713@linux.intel.com> <20190122025836.GH25163@ziepe.ca> <20190122132910.GA2720@linux.intel.com> <20190123153638.GA8727@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190123153638.GA8727@linux.intel.com> 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 Wed, Jan 23, 2019 at 05:36:38PM +0200, Jarkko Sakkinen wrote: > On Wed, Jan 23, 2019 at 07:26:42AM +1300, Linus Torvalds wrote: > > On Wed, Jan 23, 2019 at 2:29 AM Jarkko Sakkinen > > wrote: > > > > > > > > > > > > > Fails on commit 170d13ca3a2fdaaa0283399247631b76b441cca2. Still works on > > > > > preceding commit a959dc88f9c8900296ccf13e2f3e1cbc555a8917. > > > > > > > > This changes the IO access pattern in memcpy_to/fromio.. Presumably > > > > CRB HW doesn't like the new 4 byte move? Swap each one in crb to > > > > memcpy to confirm.. > > > > > > > > If the HW requires particular access patterns you can't use > > > > memcpy_to/fromio > > > > > > Did not have time to look at the commit at all but your deduction > > > is correct. I know it without testing. > > > > > > Memory controller will feed 1's on unaligned read from IO memory, > > > and as we can see from the TPM header, this change causes two of > > > those: > > > > Funky. But how did it work before then? > > > > The new memcpy_fromio() is designed to have _predictable_ access > > patterns. Not necessarily the best, but at least consistent. > > > > Prevously, we used whatever random "memcpy()" implementation we > > happened to pick, which *could* be aligned (particularly "rep movsb" - > > absolutely horrible performance for MMIO, but by doing IO one byte at > > a time it was certainly aligned ;), but most of our x86 memcpy > > implementations don't actually try all that hard to align the source. > > And the manual version will actually copy things *backwards* for some > > cases. > > > > Is it just that this particular hardware always happened to trigger > > the ERMS case (ie "rep movsb")? > > This is the particular snippet in question: > > memcpy_fromio(buf, priv->rsp, 6); > expected = be32_to_cpup((__be32 *) &buf[2]); > if (expected > count || expected < 6) > return -EIO; > > memcpy_fromio(&buf[6], &priv->rsp[6], expected - 6); > > I guess it did in the first memcpy_fromio operation since it is less > than a quad word, right? Not sure why the 2nd memcpy_fromio() operation > has worked, though. And I wonder why 32-bit has worked before. Tomas, you've been more involved with ME and fTPM runs there. Do you have any clues where this could be rooted? /Jarkko