Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1153081imm; Wed, 8 Aug 2018 11:41:24 -0700 (PDT) X-Google-Smtp-Source: AA+uWPzfwrmdX/HCtgHNDJCjHG3bhrkkzPu8K/+IQEO1n6z7TZB+64C7s3fbbuRQAYQlnny+2zwy X-Received: by 2002:a65:658d:: with SMTP id u13-v6mr3662303pgv.20.1533753684017; Wed, 08 Aug 2018 11:41:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533753683; cv=none; d=google.com; s=arc-20160816; b=DAsn55eCK/stKsgN7P79hUmne37GGI0HRaEbAM2u+hnuQ6p35diNiPyh0jPpWUJLvv jhuJ4Cl/HjwmFO5Ah/Qzd0QlJE6xO8KLl5+XfaxUq32RYvVXa/u4HqDQEVnAsQvom8lI M/HeVnqku+wLnqYitE+4smBff8+LMIujwk2P4IdTTCZE1cvXGYUwm/ID0yP7OMPEQ2aw PWfw1xi+ghjh+1BOQXLDu9CFL3iEp+MtSrwnccvxZVXHbE4c27PLwVokH11wbLlgYQJ2 DVf0z69SfDY0AcZpWqYaP9sNEdvMJNxRkmOL3gpEHq3U1z77zAkUW3UC6Y8ZqRwyhOLm N16A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date :arc-authentication-results; bh=4OHLabqSNsP4AIucK/OR3jicqDC1V0WXmBSZC9avt0o=; b=hMJEulkwyldYOU4Enj78RKAoudtAd7eMVCeMqhMLNZmyOhaqrc0JDkCO0tskLHvfHB 8eU/wQaB3ZQEX53sICSOJMVhJMKqDlU5ryeYmx2/5ijD4SGJkHIt9Ez/0/URR6qWaT0N XrjZ9nVlUbh6y8KtkhiXNNfjYiPu9dzRj56RbP5uChtwTq8b4b79wjxqmL00lWOEhg2u C0pZausZZN4xJItGOQhvvUSLgdSIuxwnwxQSQgSbbVUFDwiSVMUa8n6iXC83sl9i8Ywy oN8AtP22gS/7LqG+a9sYRYM7hzrVKmU47ZpUaOa/3ZudZ9T5OgtF67Y+rE5fqcNc5n6S Ff7w== 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x1-v6si4554753pga.480.2018.08.08.11.41.09; Wed, 08 Aug 2018 11:41:23 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729721AbeHHVBP (ORCPT + 99 others); Wed, 8 Aug 2018 17:01:15 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:36984 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727295AbeHHVBP (ORCPT ); Wed, 8 Aug 2018 17:01:15 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2BCD540216E7; Wed, 8 Aug 2018 18:40:17 +0000 (UTC) Received: from file01.intranet.prod.int.rdu2.redhat.com (file01.intranet.prod.int.rdu2.redhat.com [10.11.5.7]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1A52110CD629; Wed, 8 Aug 2018 18:40:17 +0000 (UTC) Received: from file01.intranet.prod.int.rdu2.redhat.com (localhost [127.0.0.1]) by file01.intranet.prod.int.rdu2.redhat.com (8.14.4/8.14.4) with ESMTP id w78IeHVU027839; Wed, 8 Aug 2018 14:40:17 -0400 Received: from localhost (mpatocka@localhost) by file01.intranet.prod.int.rdu2.redhat.com (8.14.4/8.14.4/Submit) with ESMTP id w78IeGNn027835; Wed, 8 Aug 2018 14:40:16 -0400 X-Authentication-Warning: file01.intranet.prod.int.rdu2.redhat.com: mpatocka owned process doing -bs Date: Wed, 8 Aug 2018 14:40:16 -0400 (EDT) From: Mikulas Patocka X-X-Sender: mpatocka@file01.intranet.prod.int.rdu2.redhat.com To: Catalin Marinas 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 In-Reply-To: <20180808142852.GD24736@iMac.local> Message-ID: References: <20180803094129.GB17798@arm.com> <20180808113927.GA24736@iMac.local> <20180808142852.GD24736@iMac.local> User-Agent: Alpine 2.02 (LRH 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Wed, 08 Aug 2018 18:40:17 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Wed, 08 Aug 2018 18:40:17 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'mpatocka@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 8 Aug 2018, Catalin Marinas wrote: > 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. I believe that the SoC has logic for write-after-write detection, but the logic is broken and corrupts data. If I insert "dmb sy" between the overlapping writes, there's no corruption (the PCIe controller won't see any overlapping writes in that case). > It may be worth trying with a byte-only memcpy() function while keeping > the default memcmp(). I tried that and byte-only memcpy works without any corruption. > -- > Catalin Mikulas