Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp7066408imu; Thu, 31 Jan 2019 04:29:42 -0800 (PST) X-Google-Smtp-Source: ALg8bN4hcT9NxixURp+vlJEi+FXyUK84PIXjf+Sw1EVa2YS8zn/sGKwzBw9E1pvRrhUclTpZ5prA X-Received: by 2002:a63:9501:: with SMTP id p1mr31338364pgd.149.1548937782543; Thu, 31 Jan 2019 04:29:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548937782; cv=none; d=google.com; s=arc-20160816; b=PKGvdiFognkKgQ3t7mJDm/+EZ6DjLenl/sfrLXptozD0KRaWDkJlR65wqqqRK32h9u pAkuunVvQ3Z2OnIpbJKHcIlozNY/mDFnnZm6MTlkUt74OjggDwiYSSP6Ki22ScuGdkai dfmHiI49YgfNqVPaj/GlI7ZdgC5GXdbuwSYEY9MPbY9zeIjQJpPYeWNPHERqdAtAUG/u jAzn3Kx2P1pIHGLo5d7Tut3w1yJiSoKhK0QaHdGl2r99/TPA2hOkAWHt/dF0SWBDLYLL NeijtahJ3I1nUFuOqByV90mA5twFhvoaJs3sbs95Uw6o9Ea+x3qZoHsRYDIIiEjzoeRj tNdw== 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=zLtCcj1K8F16j1Dq1/4OVW6eqKm0NSSMoM0VVXeuczE=; b=PCYIDy1F+pf2W+sP6hm1cWZ2pEokD0ITzo9IF6qXVniSgN+7VkjYwz5iV5+eGM2ICw xSrhccJ780JfhHqw44DK1uZO4//XgljZk6GXsYZa2zEla2OkUV4bGbpxQNGpt+kZk7zh 9UizCZIYDL7Pj+Mb6DW7Kk+tFp9e3GUkXPmE9oUs6+QZ9RuxKkrH5XWjHwJLH/D11DNU RmQ35Ga0ZxWrHp4+/2FvatbJYqTFh5zdDlWTre1JC23E1sM4U4qr1EZZJ29gnl6kHGTG 39bhEbN0l7/0BkxNyTTe9saDDHKrkPVo6ajYFNUxCYwm9H/dMI6owf3zcFI5qYs/KE8i AtYw== 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 h191si4054976pgc.302.2019.01.31.04.29.26; Thu, 31 Jan 2019 04:29:42 -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 S1732644AbfAaM0L (ORCPT + 99 others); Thu, 31 Jan 2019 07:26:11 -0500 Received: from mga07.intel.com ([134.134.136.100]:20557 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726153AbfAaM0L (ORCPT ); Thu, 31 Jan 2019 07:26:11 -0500 X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 31 Jan 2019 04:26:10 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,544,1539673200"; d="scan'208";a="134732579" Received: from jsakkine-mobl1.tm.intel.com (HELO localhost) ([10.237.50.172]) by orsmga001.jf.intel.com with ESMTP; 31 Jan 2019 04:26:07 -0800 Date: Thu, 31 Jan 2019 14:26:06 +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 , tomas.winkler@intel.com Subject: Re: Getting weird TPM error after rebasing my tree to security/next-general Message-ID: <20190131122606.GA12470@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> <20190129132016.GA1602@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190129132016.GA1602@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 Tue, Jan 29, 2019 at 03:20:16PM +0200, Jarkko Sakkinen wrote: > On Thu, Jan 24, 2019 at 07:43:30AM +1300, Linus Torvalds wrote: > > On Thu, Jan 24, 2019 at 4:36 AM Jarkko Sakkinen > > wrote: > > > > > > > > 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; > > > > Ok, strange. > > > > So what *used* to happen is that the memcpy_fromio() would just expand > > as a "memcpy()", and in this case, gcc would then inline the memcpy(). > > In fact, gcc does it as a 4-byte access and a two-byte access from > > what I can tell. > > I verified, and it is exactly as you stated: > > 0xffffffff814aaa33 <+51>: mov (%rax),%edx > 0xffffffff814aaa35 <+53>: mov %edx,0x0(%rbp) > 0xffffffff814aaa38 <+56>: movzwl 0x4(%rax),%eax > 0xffffffff814aaa3c <+60>: mov %ax,0x4(%rbp) > > And your new version does exactly the same thing to the first six bytes > (with different opcode, but the same memory access pattern). I think I have found the root cause: memcpy_fromio(&__rsp_pa, &priv->regs_t->ctrl_rsp_pa, 8); This is from crb_map_io(). This should be read as quad word. I'll change it to ioread64() and see what happens. I don't know why it even has used memcpy_fromio() in the first place. I guess, when I first implemented the driver, I used that for no logical reason, and it has worked since up until now. /Jarkko