Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp7723379imu; Tue, 22 Jan 2019 10:29:02 -0800 (PST) X-Google-Smtp-Source: ALg8bN5og7juovVaUGOYNoivD0gcEFh7+yhfE/aPqW0H1xo/SmsdgmzgeTz7byWId3dbewD9fbyl X-Received: by 2002:a62:2c4d:: with SMTP id s74mr34155299pfs.6.1548181742262; Tue, 22 Jan 2019 10:29:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548181742; cv=none; d=google.com; s=arc-20160816; b=lJCTqOQxZMGbZNeQixVTJj63G4Lr5FL6D5dSzaEaP1x6qwDYZHT3pz3V5c/IvacYrE w3bAWsb+udrfin8eiX1Xf8sTFfk508frvtrxDHR8Pza9gGcp5P005+0FiD9pdW5KBFX2 ldY7/QKKud8wTQh2X9yZp9bXuE4GIZ9Bd1O/WEYO5bNkqesFKhRip0AnzOpnz1iv3Eyi PeIAdUwnJSeKkyI52j0FtYHyhoY7Eld6xkm30g2Q25WG9OaokY9usD3ZkkpL0QSaQ+Zw dObphCk7MOh7vuSIlPReEDWdaIh44OHr+JbHyQSSjmOC1y4wl1MqZ4VPh2APBUVOhI96 BVHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=XUBcaPRcuqOLEl2SYy/Q6oqpj8zeKWGuZM5V88FmHF8=; b=PknxQ//s20VjO/D9N5FC35Ru4+qGOpzuPS6vYG9YQ5tpIWA0GqwTCiR4d8B0HrQUk2 LfJ8cG7GFEk+sFG8gomyGp8NEtpDaV3d5CDtxTnRQoUutikH/ircWAdgwpeUGINuyLBP JG96VodyM6MG87pTetoPw+klbI8vYAB0N6TQRPDEzq6Bc4t+X6SqdGw/cHxS+uTQKM0Q 8mcbjuECUH1KfeJ8FJBxRHGbYfjx0D1jjIqo0H74HKXgjWXlsFN9vUvzxDAT0gtT5L1p 8IKaZOA2iffeSKnEgwG15So+2RkUF+40eE1tyLDtslkMITUuX/Y7lUTcIx13++YGOK7v MkJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=CMl+ODFK; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f15si14976885plr.144.2019.01.22.10.28.46; Tue, 22 Jan 2019 10:29:02 -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; dkim=pass header.i=@linux-foundation.org header.s=google header.b=CMl+ODFK; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726256AbfAVS1E (ORCPT + 99 others); Tue, 22 Jan 2019 13:27:04 -0500 Received: from mail-lf1-f65.google.com ([209.85.167.65]:35027 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726005AbfAVS1D (ORCPT ); Tue, 22 Jan 2019 13:27:03 -0500 Received: by mail-lf1-f65.google.com with SMTP id e26so18838645lfc.2 for ; Tue, 22 Jan 2019 10:27:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=XUBcaPRcuqOLEl2SYy/Q6oqpj8zeKWGuZM5V88FmHF8=; b=CMl+ODFKCfVLcBaWLY/tCSTTxYCbhG1V/NxINTD3f7ytfFq5M59K9J2K6RH2Pm/OSn q7GCuvuWVGKVYV62U5nCjKlbBy782E6y+co8/T6PIdApkhHe0go43LUfYd6CwWmR5Ef5 WvkZWSVRmstQbxD52e4AK1z18Q87hMRWG808E= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=XUBcaPRcuqOLEl2SYy/Q6oqpj8zeKWGuZM5V88FmHF8=; b=Wr/SI1eyGQKsSjIYtDVPyFRliJpAIKVgxR+IZs2Mq1I/e29KZl7XEiYj9zmq4X4StL jjxzHJG+Fmcy1uWUGo0Al4xe8eyCaA8jp/I1rrt/tQeRiXvOLUBJHNgbgLdZuG4PpVSg 0324HJcJ9vyqJOk4mQhfaROtMBipJEpdn8cd4BhFiC8JE8h1DCrAtahRPVz0VLrZ8AEa ArBi4nlvzFGKzMuU3IZeAP3rlXtNlHCdUuZeFpQjyAi2mKX4ZA1MmrNLS/zvkIQC9u7g CP+KwPK3sgnUgKCMACeM6HOWONdd9y1fDSRDVQpX2wOsT4VKje2+XR8u8ChQN046fjRg 21EQ== X-Gm-Message-State: AJcUukeST6r6mddx8zaJIegrdBFiTYqWDRHVIeutHMB/4Ajg3I0mcffS Kp6KNsK065pf/7UnHgFipnqGcQoRq994XA== X-Received: by 2002:a19:c396:: with SMTP id t144mr20951905lff.110.1548181620207; Tue, 22 Jan 2019 10:27:00 -0800 (PST) Received: from mail-lf1-f47.google.com (mail-lf1-f47.google.com. [209.85.167.47]) by smtp.gmail.com with ESMTPSA id y131sm114055lfc.43.2019.01.22.10.26.58 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Jan 2019 10:26:59 -0800 (PST) Received: by mail-lf1-f47.google.com with SMTP id a8so18832910lfk.5 for ; Tue, 22 Jan 2019 10:26:58 -0800 (PST) X-Received: by 2002:a19:980f:: with SMTP id a15mr22707685lfe.103.1548181618431; Tue, 22 Jan 2019 10:26:58 -0800 (PST) MIME-Version: 1.0 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> In-Reply-To: <20190122132910.GA2720@linux.intel.com> From: Linus Torvalds Date: Wed, 23 Jan 2019 07:26:42 +1300 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: Getting weird TPM error after rebasing my tree to security/next-general To: Jarkko Sakkinen Cc: Jason Gunthorpe , James Bottomley , linux-integrity@vger.kernel.org, linux-security-module@vger.kernel.org, Linux List Kernel Mailing Content-Type: text/plain; charset="UTF-8" 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 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")? 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