Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp902329imu; Wed, 23 Jan 2019 07:38:40 -0800 (PST) X-Google-Smtp-Source: ALg8bN4QTFkD8R/PtqDWgSjSQyM6naITGT3JGssqaXkSCgMawP1X7TRHBntPLIL5cna3ievMaZOv X-Received: by 2002:a63:82c6:: with SMTP id w189mr2394164pgd.344.1548257920427; Wed, 23 Jan 2019 07:38:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548257920; cv=none; d=google.com; s=arc-20160816; b=pgLlVG1Ia9anWdvq4xbPrnxNU+VdhTsD+8stAlbuFxvms5qkYF1oMHHNhjLEiMZJiM Sxp6LRNLNeOJhYA/b36d/Ctqe91fnkGrX9AK1akXOlWXZ42MIsERXOgOyuxjQM+qurYy 0mOeSylLAsJiG0JeoMFm2WH2c2rTpMMSpF9+FAmY6HqJOdTdq3ARvc8NBnl+Cc1SlIjt /pn2W0NL4xu1jz0NPnB4qOCAquwBerjVFfmUjHqrj3dYGHQRE7V49y6v2ZSoHd93R8Ok qTmhbzjNEgKUX0NVWfbnN9ymNars/YABHJDJNE9dIfaLCPiMNgCFPl1Rh05JKbNwpNr0 966Q== 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=9iNujk0i+l42WU/CeqRjnXG6fy+A2kh6peWCaxdSoT0=; b=qxF/99wCJwx5g9m8dJ8dIygg3siIvm9kjfwtE/W0hfECmoLaVyCLNknTMiKEN3Ed1y jHGe71iODrh8jqVbrQ1Ba1rN95OHfRSX4jPOz7jSi4FpdG0uB92ufjEIgOQDqphI0Ny8 bIE6FC9ajx8tYyHBcK9bJ0U7sWpfhNSHn4u0tkqxdZeoh/gqj/M2Y/owtczki6QOzcFp QVyhOujK/EDV1FCGRyeD1cDBvN/fuq1yRg53MwWyy5NRXVUftiOUMGitxOBtis9RVXRg bBmFrQbKyX/wfKBovu0IEsZ5fGehESwMOL1x+k6QATq6H0UIXjKhYrWEBCuK2QppYE5w D6Bw== 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 c64si17568845pfg.239.2019.01.23.07.38.23; Wed, 23 Jan 2019 07:38:40 -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 S1726370AbfAWPgo (ORCPT + 99 others); Wed, 23 Jan 2019 10:36:44 -0500 Received: from mga14.intel.com ([192.55.52.115]:27462 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726008AbfAWPgo (ORCPT ); Wed, 23 Jan 2019 10:36:44 -0500 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Jan 2019 07:36:44 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,511,1539673200"; d="scan'208";a="127956733" Received: from rkazants-mobl.ccr.corp.intel.com (HELO localhost) ([10.249.254.156]) by FMSMGA003.fm.intel.com with ESMTP; 23 Jan 2019 07:36:40 -0800 Date: Wed, 23 Jan 2019 17:36:38 +0200 From: Jarkko Sakkinen To: Linus Torvalds 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: <20190123153638.GA8727@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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 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. > Anyway, Jason is correct that if a device has particular IO pattern > requirements, you shouldn't use "memcpy_fromio()" and friends, but > it's interesting how it apparently *happened* to work before. > > Linus Sure, I'll prepare a fix ASAP. /Jarkko