Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1029108imm; Wed, 8 Aug 2018 09:32:28 -0700 (PDT) X-Google-Smtp-Source: AA+uWPz3bd+Jrjq3qMsXSEuiTAWbmX1PziPdqaIv7psGg14rTqa6QCTI8ZUZH4Dpd6Db707gnY8U X-Received: by 2002:a63:b91a:: with SMTP id z26-v6mr3275826pge.22.1533745948207; Wed, 08 Aug 2018 09:32:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533745948; cv=none; d=google.com; s=arc-20160816; b=IbGnOhv4eKXnahOTXkzGkfpHeHbWJm4f65wO9wmjgDOmMiIp2aHQSEZSdhzzOvOLRc QpdwdxWH5zlRqC8K0HNO34VChgLANldQok0KGX7ZAY37y6NpVYWf7h5n/8axOsZuW2Ql vNZR9G5nqGuGqBUsNC2E8rCVWkRX5q9LhW28Dw6JgFxWLl0p6yHrRu/8zmoZGr/wRtCz dJ7wZ0hv0O0MsNQVVmpsMd/KnYLRh0J4Coti6T8/4irgfQ6Ff7KMy+OH89o62LvB6cSn YHeobV6Pkf+AUWZ6WrHOj1qb7pUr8861wnZkgIPwWbaQLaR+hmVJCG4BkOMd7Qfgo4rm R+uQ== 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:arc-authentication-results; bh=qPypXWx+EYspLqawQLLHa9UTTkyJSSoYu+cUi7S+7Xw=; b=ywqsLlYTZuqId8xNcCaiAbRYUleCPusiJ5kHWqW8kMGwm2mb1cQBfG2HHSBvdxq9jJ Zawq9d7J0B8OlH+fgbuN+Uoz/QzpIu37+ynHi5AGR7VRFi4bjA18Q1A3CjUa0lbx8sZc GVohawLbOMx5qqZpVYu9egc3jgOv81agd/g5odqKazFcen/RDDRsT8w08WzMdsTAdUPg tztPRxDk4vIl6Bp4jPEnL44Mut/SkFhqmpchMsBtKxgTJgiGVvnIBbLjSZoN2AltxdXE sQhhQJLd8B+n3QKEU1mDaEw/itUFVGstUyqBCHUv31NVFHezaOjpsBMwWICTaTISkzFP ElsA== 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 h71-v6si4920667pge.13.2018.08.08.09.32.13; Wed, 08 Aug 2018 09:32:28 -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 S1729267AbeHHSvy (ORCPT + 99 others); Wed, 8 Aug 2018 14:51:54 -0400 Received: from mail-qt0-f170.google.com ([209.85.216.170]:42977 "EHLO mail-qt0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727480AbeHHSvy (ORCPT ); Wed, 8 Aug 2018 14:51:54 -0400 Received: by mail-qt0-f170.google.com with SMTP id z8-v6so3096600qto.9; Wed, 08 Aug 2018 09:31:27 -0700 (PDT) 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=qPypXWx+EYspLqawQLLHa9UTTkyJSSoYu+cUi7S+7Xw=; b=F+xh5KDDEqFIWqTWd6XLjrZ4Jq3pHXNPiZS9DUSO8iDPdTwsGaLT7y4SX5E9dHB0G8 jIev6thciidY204OtQMzocsayJrbEIPa8OvDT4gR8ZxMUsHhNjectX8SXilHbRqDAQXm v84+T/Ch4PME8t4kE+nPRRphi1cO8CiwS/i3bZDpgvr2nzp4B0oE9nOACGQf0LipotL4 /8m9GNpzAjt/TdxpzaoJ7cz5f1WAQw/jpJvjf44UUEjJ/wqBfBf60zMY1mM5h331j8EM GntNLkFpC79OmiWG3ykytsvdAhccuyH92ViWeOsbk683SahrITeBqfh+wEzE0ddDFvZg CDfg== X-Gm-Message-State: AOUpUlGFZ4/NN165nuSiXqDXgEuDWl0wgg4/h6DrFo1fX/o+DJXlkclS 9meDTQn0DCyKdWVu4gQMzqGXW9x/FzgmgiqiJLw= X-Received: by 2002:ac8:274a:: with SMTP id h10-v6mr3501502qth.187.1533745886372; Wed, 08 Aug 2018 09:31:26 -0700 (PDT) MIME-Version: 1.0 References: <20180803094129.GB17798@arm.com> <20180808121641.GB24736@iMac.local> <19c70d2a0b224db78f72dd316ad006b8@AcuMS.aculab.com> <20180808145017.GE24736@iMac.local> In-Reply-To: From: Arnd Bergmann Date: Wed, 8 Aug 2018 18:31:09 +0200 Message-ID: Subject: Re: framebuffer corruption due to overlapping stp instructions on arm64 To: Mikulas Patocka Cc: Catalin Marinas , Thomas Petazzoni , Joao Pinto , Ard Biesheuvel , linux-pci , Will Deacon , Russell King - ARM Linux , Linux Kernel Mailing List , David Laight , neko@bakuhatsu.net, Jingoo Han , Linux ARM 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, Aug 8, 2018 at 6:22 PM Mikulas Patocka wrote: > > On Wed, 8 Aug 2018, Catalin Marinas wrote: > > > On Wed, Aug 08, 2018 at 02:26:11PM +0000, David Laight wrote: > > > From: Mikulas Patocka > > > > Sent: 08 August 2018 14:47 > > > ... > > > > The problem on ARM is that I see data corruption when the overlapping > > > > unaligned writes are done just by a single core. > > > > > > Is this a sequence of unaligned writes (that shouldn't modify the > > > same physical locations) or an aligned write followed by an > > > unaligned one that updates part of the earlier write. > > > (Or the opposite order?) > > > > In the memcpy() case, there can be a sequence of unaligned writes but > > they would not modify the same byte (so no overlapping address at the > > byte level). > > They do modify the same byte, but with the same value. Suppose that you > want to copy a piece of data that is between 8 and 16 bytes long. You can > do this: > > add src_end, src, len > add dst_end, dst, len > ldr x0, [src] > ldr x1, [src_end - 8] > str x0, [dst] > str x1, [dst_end - 8] > > The ARM64 memcpy uses this trick heavily in order to reduce branching, and > this is what makes the PCIe controller choke. So when a single unaligned 'stp' gets translated into a PCIe with TLP with length=5 (20 bytes) and LastBE = ~1stBE, write combining the overlapping stores gives us a TLP with a longer length (5..8 for two stores), and byte-enable bits that are not exactly a complement. If the explanation is just that of the byte-enable settings of the merged TLP are wrong, maybe the problem is that one of them is always the complement of the other, which would work for power-of-two length but not the odd length of the TLP post write-combining? Arnd