Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp893789imm; Wed, 8 Aug 2018 07:30:34 -0700 (PDT) X-Google-Smtp-Source: AA+uWPxNqzJaO5Gr/3ggL4o5iyx8UTIWahpf16m7I26i/3/NoCsVhfroxuBlVs6AMn3XB23WEiFW X-Received: by 2002:a62:3a9d:: with SMTP id v29-v6mr3222100pfj.215.1533738634692; Wed, 08 Aug 2018 07:30:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533738634; cv=none; d=google.com; s=arc-20160816; b=nvLcGIwSfuh95HSAA1NElLOE5l7dA35Y9e6jI9Xe6gDLoBIeEJhV797IxRPmugB8WM istLsms7WIqRKeCq2EsUyRQnaKKZbGB0n/vnwo4oeQ9h8x8/jUIEQxkW4ZpJetwj+6uT E+NYtnVpionDm5qKs3wWanMLA+AP5AVmidZi0EvWBMNntp09hcY7vWD+WHiF+whN8x+r LCP5POftb7j1eXogx2rKQtmZVYj46bVvVGIBxRji5qHtHpCpIf7yQAZBzc7KIuH1GLXs HAFQ2Sczr+Nc9UhX/jozECNy3r0CTwrVpvkTYBC+v3K4Li3/T3MT4eGUvtr1xec7yuFs KlDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=vh+Mou5cxKrXa8wVMnVMA31Y+zpqiotLuCcKxw/Zk9U=; b=hF981UzQW7ZQ7+sy6pxOsYl2g57vxgSU1C9rrDLmjmF1v/uHKSl5l+6hxeu6pdQiuG JmwmB1Hp93Od6Gg5ZasPKnlUMI1twNj1QRE7pFkZOJ48crWN7I0QhuOSZ2UDf6ktOdIl n7jUPKPvACPV0YoJro+Yh9d36U6uPnisEs0Q/ww6IEio4w2+WbOEz6/CxxYb1p0BU+N1 mmnQTkCycl8Oc85u3q2xNHDlcXIkVHViqWh04IqvBFm7x8Xv/xdmMPitT4sU57ykwjT+ Z5N4iuNej9r/iE7PS/iH7W9MYb8709EOKfplcjSUJB7eqZ/SvxWgZ+t4ggWyzowWmZzm 7OLw== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id be5-v6si3647597plb.67.2018.08.08.07.30.19; Wed, 08 Aug 2018 07:30:34 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727365AbeHHQsx (ORCPT + 99 others); Wed, 8 Aug 2018 12:48:53 -0400 Received: from foss.arm.com ([217.140.101.70]:39662 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727069AbeHHQsw (ORCPT ); Wed, 8 Aug 2018 12:48:52 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id E188C7A9; Wed, 8 Aug 2018 07:28:57 -0700 (PDT) Received: from iMac.local (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id CDB563F5D4; Wed, 8 Aug 2018 07:28:55 -0700 (PDT) Date: Wed, 8 Aug 2018 15:28:53 +0100 From: Catalin Marinas To: Mikulas Patocka Cc: Thomas Petazzoni , Joao Pinto , libc-alpha@sourceware.org, Ard Biesheuvel , Jingoo Han , Will Deacon , Russell King , Linux Kernel Mailing List , Matt Sealey , linux-pci@vger.kernel.org, linux-arm-kernel Subject: Re: framebuffer corruption due to overlapping stp instructions on arm64 Message-ID: <20180808142852.GD24736@iMac.local> References: <20180803094129.GB17798@arm.com> <20180808113927.GA24736@iMac.local> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.0 (2018-05-17) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 08, 2018 at 10:12:27AM -0400, Mikulas Patocka wrote: > On Wed, 8 Aug 2018, Catalin Marinas wrote: > > On Fri, Aug 03, 2018 at 01:09:02PM -0400, Mikulas Patocka wrote: > > > while (1) { > > > start = (unsigned)random() % (LEN + 1); > > > end = (unsigned)random() % (LEN + 1); > > > if (start > end) > > > continue; > > > for (i = start; i < end; i++) > > > data[i] = val++; > > > memcpy(map + start, data + start, end - start); > > > if (memcmp(map, data, LEN)) { > > > > It may be worth trying to do a memcmp(map+start, data+start, end-start) > > here to see whether the hazard logic fails when the writes are unaligned > > but the reads are not. > > > > This problem may as well appear if you do byte writes and read longs > > back (and I consider this a hardware problem on this specific board). > > I triad to insert usleep(10000) between the memcpy and memcmp, but the > same corruption occurs. So, it can't be read-after-write hazard. It is > caused by the improper handling of hazard between the overlapping writes > inside memcpy. It could get it wrong between subsequent writes to the same 64-bit range (e.g. the address & ~63 is the same but the data strobes for which bytes to write are different). If it somehow thinks that it's a write-after-write hazard even though the strobes are different, it could cancel one of the writes. It may be worth trying with a byte-only memcpy() function while keeping the default memcmp(). -- Catalin