All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Laight <David.Laight@ACULAB.COM>
To: 'Arnd Bergmann' <arnd@arndb.de>, Mikulas Patocka <mpatocka@redhat.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>,
	Thomas Petazzoni <thomas.petazzoni@free-electrons.com>,
	Joao Pinto <Joao.Pinto@synopsys.com>,
	Ard Biesheuvel <ard.biesheuvel@linaro.org>,
	linux-pci <linux-pci@vger.kernel.org>,
	Will Deacon <will.deacon@arm.com>,
	"Russell King - ARM Linux" <linux@armlinux.org.uk>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	"neko@bakuhatsu.net" <neko@bakuhatsu.net>,
	Jingoo Han <jingoohan1@gmail.com>,
	Linux ARM <linux-arm-kernel@lists.infradead.org>
Subject: RE: framebuffer corruption due to overlapping stp instructions on arm64
Date: Wed, 8 Aug 2018 16:43:46 +0000	[thread overview]
Message-ID: <a804913d98ae4598a725cb40a6d19b4e@AcuMS.aculab.com> (raw)
In-Reply-To: <CAK8P3a3iURkU8LThO3xLtaNjkYArdpw+6_WqJQog4EgrcQy23g@mail.gmail.com>

From: Arnd Bergmann
> Sent: 08 August 2018 17:31
..
> > 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]

I've done that myself (on x86) copied the last 'word' first then
everything else in increasing address order.

> > The ARM64 memcpy uses this trick heavily in order to reduce branching, and
> > this is what makes the PCIe controller choke.

More likely the write combining buffer?

> 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.

Write combining should generate a much longer TLP.
Depending on the size of the write combining buffer.

But in the above case I'd have thought that the second write
would fail to 'combine' - because it isn't contiguous with the
stored data.

So something more complex will be going on.

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)

WARNING: multiple messages have this Message-ID (diff)
From: David Laight <David.Laight@ACULAB.COM>
To: 'Arnd Bergmann' <arnd@arndb.de>, Mikulas Patocka <mpatocka@redhat.com>
Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>,
	Joao Pinto <Joao.Pinto@synopsys.com>,
	Ard Biesheuvel <ard.biesheuvel@linaro.org>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Will Deacon <will.deacon@arm.com>,
	Russell King - ARM Linux <linux@armlinux.org.uk>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	"neko@bakuhatsu.net" <neko@bakuhatsu.net>,
	linux-pci <linux-pci@vger.kernel.org>,
	Jingoo Han <jingoohan1@gmail.com>,
	Linux ARM <linux-arm-kernel@lists.infradead.org>
Subject: RE: framebuffer corruption due to overlapping stp instructions on arm64
Date: Wed, 8 Aug 2018 16:43:46 +0000	[thread overview]
Message-ID: <a804913d98ae4598a725cb40a6d19b4e@AcuMS.aculab.com> (raw)
In-Reply-To: <CAK8P3a3iURkU8LThO3xLtaNjkYArdpw+6_WqJQog4EgrcQy23g@mail.gmail.com>

From: Arnd Bergmann
> Sent: 08 August 2018 17:31
..
> > 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]

I've done that myself (on x86) copied the last 'word' first then
everything else in increasing address order.

> > The ARM64 memcpy uses this trick heavily in order to reduce branching, and
> > this is what makes the PCIe controller choke.

More likely the write combining buffer?

> 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.

Write combining should generate a much longer TLP.
Depending on the size of the write combining buffer.

But in the above case I'd have thought that the second write
would fail to 'combine' - because it isn't contiguous with the
stored data.

So something more complex will be going on.

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

WARNING: multiple messages have this Message-ID (diff)
From: David.Laight@ACULAB.COM (David Laight)
To: linux-arm-kernel@lists.infradead.org
Subject: framebuffer corruption due to overlapping stp instructions on arm64
Date: Wed, 8 Aug 2018 16:43:46 +0000	[thread overview]
Message-ID: <a804913d98ae4598a725cb40a6d19b4e@AcuMS.aculab.com> (raw)
In-Reply-To: <CAK8P3a3iURkU8LThO3xLtaNjkYArdpw+6_WqJQog4EgrcQy23g@mail.gmail.com>

From: Arnd Bergmann
> Sent: 08 August 2018 17:31
..
> > 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]

I've done that myself (on x86) copied the last 'word' first then
everything else in increasing address order.

> > The ARM64 memcpy uses this trick heavily in order to reduce branching, and
> > this is what makes the PCIe controller choke.

More likely the write combining buffer?

> 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.

Write combining should generate a much longer TLP.
Depending on the size of the write combining buffer.

But in the above case I'd have thought that the second write
would fail to 'combine' - because it isn't contiguous with the
stored data.

So something more complex will be going on.

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)

  reply	other threads:[~2018-08-08 16:42 UTC|newest]

Thread overview: 238+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-02 19:31 framebuffer corruption due to overlapping stp instructions on arm64 Mikulas Patocka
2018-08-02 19:31 ` Mikulas Patocka
     [not found] ` <CAHCPf3tFGqkYEcWNN4LaWThw_rVqT316pzLv6T7RfxwO-eZ0EA@mail.gmail.com>
2018-08-03  6:35   ` Mikulas Patocka
2018-08-03  6:35     ` Mikulas Patocka
2018-08-03  7:16     ` Ard Biesheuvel
2018-08-03  7:16       ` Ard Biesheuvel
2018-08-03  9:41       ` Will Deacon
2018-08-03  9:41         ` Will Deacon
2018-08-03 17:09         ` Mikulas Patocka
2018-08-03 17:09           ` Mikulas Patocka
2018-08-03 17:09           ` Mikulas Patocka
2018-08-03 17:32           ` Sinan Kaya
2018-08-03 17:32             ` Sinan Kaya
2018-08-03 17:32             ` Sinan Kaya
2018-08-03 17:33           ` Ard Biesheuvel
2018-08-03 17:33             ` Ard Biesheuvel
2018-08-03 17:33             ` Ard Biesheuvel
2018-08-03 18:25             ` Mikulas Patocka
2018-08-03 18:25               ` Mikulas Patocka
2018-08-03 18:25               ` Mikulas Patocka
2018-08-03 20:44               ` Matt Sealey
2018-08-03 20:44                 ` Matt Sealey
2018-08-03 20:44                 ` Matt Sealey
2018-08-03 21:20                 ` Ard Biesheuvel
2018-08-03 21:20                   ` Ard Biesheuvel
2018-08-03 21:20                   ` Ard Biesheuvel
2018-08-06 10:25                   ` Mikulas Patocka
2018-08-06 10:25                     ` Mikulas Patocka
2018-08-06 10:25                     ` Mikulas Patocka
2018-08-06 12:42                     ` Robin Murphy
2018-08-06 12:42                       ` Robin Murphy
2018-08-06 12:42                       ` Robin Murphy
2018-08-06 12:53                       ` Ard Biesheuvel
2018-08-06 12:53                         ` Ard Biesheuvel
2018-08-06 12:53                         ` Ard Biesheuvel
2018-08-06 13:41                       ` Marcin Wojtas
2018-08-06 13:41                         ` Marcin Wojtas
2018-08-06 13:41                         ` Marcin Wojtas
2018-08-06 13:48                         ` Ard Biesheuvel
2018-08-06 13:48                           ` Ard Biesheuvel
2018-08-06 13:48                           ` Ard Biesheuvel
2018-08-06 14:07                           ` Marcin Wojtas
2018-08-06 14:07                             ` Marcin Wojtas
2018-08-06 14:07                             ` Marcin Wojtas
2018-08-06 14:13                             ` Mikulas Patocka
2018-08-06 14:13                               ` Mikulas Patocka
2018-08-06 14:13                               ` Mikulas Patocka
2018-08-06 15:47                       ` Ard Biesheuvel
2018-08-06 15:47                         ` Ard Biesheuvel
2018-08-06 15:47                         ` Ard Biesheuvel
2018-08-06 17:09                         ` Mikulas Patocka
2018-08-06 17:09                           ` Mikulas Patocka
2018-08-06 17:09                           ` Mikulas Patocka
2018-08-06 17:21                           ` Ard Biesheuvel
2018-08-06 17:21                             ` Ard Biesheuvel
2018-08-06 17:21                             ` Ard Biesheuvel
2018-08-06 19:54                             ` Mikulas Patocka
2018-08-06 19:54                               ` Mikulas Patocka
2018-08-06 19:54                               ` Mikulas Patocka
2018-08-06 20:11                               ` Ard Biesheuvel
2018-08-06 20:11                                 ` Ard Biesheuvel
2018-08-06 20:11                                 ` Ard Biesheuvel
2018-08-06 20:31                                 ` Mikulas Patocka
2018-08-06 20:31                                   ` Mikulas Patocka
2018-08-06 20:31                                   ` Mikulas Patocka
2018-08-07 16:40                                 ` Marcin Wojtas
2018-08-07 16:40                                   ` Marcin Wojtas
2018-08-07 16:40                                   ` Marcin Wojtas
2018-08-07 17:39                                   ` Mikulas Patocka
2018-08-07 17:39                                     ` Mikulas Patocka
2018-08-07 17:39                                     ` Mikulas Patocka
2018-08-07 18:07                                     ` Ard Biesheuvel
2018-08-07 18:07                                       ` Ard Biesheuvel
2018-08-07 18:07                                       ` Ard Biesheuvel
2018-08-07 18:17                                       ` Mikulas Patocka
2018-08-07 18:17                                         ` Mikulas Patocka
2018-08-07 18:17                                         ` Mikulas Patocka
     [not found]                                     ` <CAPv3WKcKoEe=Qysp6Oac2C=G9bUhUQf1twSRCY+_qJ6XEC-iag@mail.gmail.com>
2018-08-08 14:10                                       ` Mikulas Patocka
2018-08-08 14:10                                         ` Mikulas Patocka
2018-08-08 14:10                                         ` Mikulas Patocka
2018-08-06 17:13                         ` Catalin Marinas
2018-08-06 17:13                           ` Catalin Marinas
2018-08-06 17:13                           ` Catalin Marinas
2018-08-06 17:19                           ` Mikulas Patocka
2018-08-06 17:19                             ` Mikulas Patocka
2018-08-06 17:19                             ` Mikulas Patocka
2018-08-08 18:31                       ` Mikulas Patocka
2018-08-08 18:31                         ` Mikulas Patocka
2018-08-08 18:31                         ` Mikulas Patocka
2018-08-04 13:29                 ` Mikulas Patocka
2018-08-04 13:29                   ` Mikulas Patocka
2018-08-04 13:29                   ` Mikulas Patocka
2018-08-08 12:16                 ` Catalin Marinas
2018-08-08 12:16                   ` Catalin Marinas
2018-08-08 12:16                   ` Catalin Marinas
2018-08-08 13:02                   ` David Laight
2018-08-08 13:02                     ` David Laight
2018-08-08 13:02                     ` David Laight
2018-08-08 13:46                     ` Mikulas Patocka
2018-08-08 13:46                       ` Mikulas Patocka
2018-08-08 13:46                       ` Mikulas Patocka
2018-08-08 14:26                       ` David Laight
2018-08-08 14:26                         ` David Laight
2018-08-08 14:26                         ` David Laight
2018-08-08 14:50                         ` Catalin Marinas
2018-08-08 14:50                           ` Catalin Marinas
2018-08-08 14:50                           ` Catalin Marinas
2018-08-08 16:21                           ` Mikulas Patocka
2018-08-08 16:21                             ` Mikulas Patocka
2018-08-08 16:21                             ` Mikulas Patocka
2018-08-08 16:31                             ` Arnd Bergmann
2018-08-08 16:31                               ` Arnd Bergmann
2018-08-08 16:31                               ` Arnd Bergmann
2018-08-08 16:43                               ` David Laight [this message]
2018-08-08 16:43                                 ` David Laight
2018-08-08 16:43                                 ` David Laight
2018-08-08 18:56                                 ` Mikulas Patocka
2018-08-08 18:56                                   ` Mikulas Patocka
2018-08-08 18:56                                   ` Mikulas Patocka
2018-08-08 18:37                         ` Mikulas Patocka
2018-08-08 18:37                           ` Mikulas Patocka
2018-08-08 18:37                           ` Mikulas Patocka
2018-08-08 11:39           ` Catalin Marinas
2018-08-08 11:39             ` Catalin Marinas
2018-08-08 11:39             ` Catalin Marinas
2018-08-08 14:12             ` Mikulas Patocka
2018-08-08 14:12               ` Mikulas Patocka
2018-08-08 14:12               ` Mikulas Patocka
2018-08-08 14:28               ` Catalin Marinas
2018-08-08 14:28                 ` Catalin Marinas
2018-08-08 14:28                 ` Catalin Marinas
2018-08-08 18:40                 ` Mikulas Patocka
2018-08-08 18:40                   ` Mikulas Patocka
2018-08-08 18:40                   ` Mikulas Patocka
2018-08-08 15:01               ` Richard Earnshaw (lists)
2018-08-08 15:01                 ` Richard Earnshaw (lists)
2018-08-08 15:01                 ` Richard Earnshaw (lists)
2018-08-08 15:14                 ` Catalin Marinas
2018-08-08 15:14                   ` Catalin Marinas
2018-08-08 15:14                   ` Catalin Marinas
2018-08-08 16:01                   ` Arnd Bergmann
2018-08-08 16:01                     ` Arnd Bergmann
2018-08-08 16:01                     ` Arnd Bergmann
2018-08-08 18:25                     ` Mikulas Patocka
2018-08-08 18:25                       ` Mikulas Patocka
2018-08-08 18:25                       ` Mikulas Patocka
2018-08-08 21:51                       ` Arnd Bergmann
2018-08-08 21:51                         ` Arnd Bergmann
2018-08-08 21:51                         ` Arnd Bergmann
2018-08-09 15:29                         ` Arnd Bergmann
2018-08-09 15:29                           ` Arnd Bergmann
2018-08-09 15:29                           ` Arnd Bergmann
2018-08-03  7:11 ` Andrew Pinski
2018-08-03  7:11   ` Andrew Pinski
2018-08-03  7:53   ` Florian Weimer
2018-08-03  7:53     ` Florian Weimer
2018-08-03  9:12     ` Szabolcs Nagy
2018-08-03  9:12       ` Szabolcs Nagy
2018-08-03  9:15     ` Ramana Radhakrishnan
2018-08-03  9:15       ` Ramana Radhakrishnan
2018-08-03  9:29       ` Ard Biesheuvel
2018-08-03  9:29         ` Ard Biesheuvel
2018-08-03  9:37         ` Ramana Radhakrishnan
2018-08-03  9:37           ` Ramana Radhakrishnan
2018-08-03  9:42         ` Richard Earnshaw (lists)
2018-08-03  9:42           ` Richard Earnshaw (lists)
2018-08-04  0:58           ` Mikulas Patocka
2018-08-04  0:58             ` Mikulas Patocka
2018-08-04  1:13             ` Andrew Pinski
2018-08-04  1:13               ` Andrew Pinski
2018-08-04 11:04               ` Mikulas Patocka
2018-08-04 11:04                 ` Mikulas Patocka
2018-08-05 18:33                 ` Florian Weimer
2018-08-05 18:33                   ` Florian Weimer
2018-08-06  8:02                   ` Mikulas Patocka
2018-08-06  8:02                     ` Mikulas Patocka
2018-08-06  8:10                     ` Ard Biesheuvel
2018-08-06  8:10                       ` Ard Biesheuvel
2018-08-06 10:31                       ` Mikulas Patocka
2018-08-06 10:31                         ` Mikulas Patocka
2018-08-06 10:37                         ` Ard Biesheuvel
2018-08-06 10:37                           ` Ard Biesheuvel
2018-08-06 10:42                           ` Mikulas Patocka
2018-08-06 10:42                             ` Mikulas Patocka
2018-08-06 10:48                             ` Ard Biesheuvel
2018-08-06 10:48                               ` Ard Biesheuvel
2018-08-06 12:09                               ` Mikulas Patocka
2018-08-06 12:09                                 ` Mikulas Patocka
2018-08-06 12:19                                 ` Ard Biesheuvel
2018-08-06 12:19                                   ` Ard Biesheuvel
2018-08-06 12:22                                   ` Ard Biesheuvel
2018-08-06 12:22                                     ` Ard Biesheuvel
2018-08-07 14:14                                   ` Mikulas Patocka
2018-08-07 14:14                                     ` Mikulas Patocka
2018-08-07 14:40                                     ` Ard Biesheuvel
2018-08-07 14:40                                       ` Ard Biesheuvel
2018-08-08 19:15                                   ` Mikulas Patocka
2018-08-08 19:15                                     ` Mikulas Patocka
2018-08-06 11:19                         ` Siddhesh Poyarekar
2018-08-06 11:19                           ` Siddhesh Poyarekar
2018-08-06 11:29                           ` Ard Biesheuvel
2018-08-06 11:29                             ` Ard Biesheuvel
2018-08-06 14:26                   ` Tulio Magno Quites Machado Filho
2018-08-06 14:26                     ` Tulio Magno Quites Machado Filho
2018-08-05 21:51                 ` Pavel Machek
2018-08-05 21:51                   ` Pavel Machek
2018-08-06 14:30                   ` Mikulas Patocka
2018-08-06 14:30                     ` Mikulas Patocka
2018-08-03 11:24         ` David Laight
2018-08-03 11:24           ` David Laight
2018-08-03 12:04           ` Mikulas Patocka
2018-08-03 12:04             ` Mikulas Patocka
2018-08-03 13:04             ` David Laight
2018-08-03 13:04               ` David Laight
2018-08-05 14:36               ` Mikulas Patocka
2018-08-05 14:36                 ` Mikulas Patocka
2018-08-06 10:18                 ` David Laight
2018-08-06 10:18                   ` David Laight
2018-08-07 14:07                   ` Mikulas Patocka
2018-08-07 14:07                     ` Mikulas Patocka
2018-08-07 14:33                     ` David Laight
2018-08-07 14:33                       ` David Laight
2018-08-08 14:21                       ` Mikulas Patocka
2018-08-08 14:21                         ` Mikulas Patocka
2018-08-03 13:20     ` Mikulas Patocka
2018-08-03 13:20       ` Mikulas Patocka
2018-08-03 13:31   ` Mikulas Patocka
2018-08-03 13:31     ` Mikulas Patocka
2018-08-03 14:17     ` Richard Earnshaw (lists)
2018-08-03 14:17       ` Richard Earnshaw (lists)
2018-08-05 21:36   ` Pavel Machek
2018-08-05 21:36     ` Pavel Machek
2018-08-06  8:04     ` Ramana Radhakrishnan
2018-08-06  8:04       ` Ramana Radhakrishnan
2018-08-06  8:44       ` Pavel Machek
2018-08-06  8:44         ` Pavel Machek
2018-08-06  9:11         ` Ard Biesheuvel
2018-08-06  9:11           ` Ard Biesheuvel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a804913d98ae4598a725cb40a6d19b4e@AcuMS.aculab.com \
    --to=david.laight@aculab.com \
    --cc=Joao.Pinto@synopsys.com \
    --cc=ard.biesheuvel@linaro.org \
    --cc=arnd@arndb.de \
    --cc=catalin.marinas@arm.com \
    --cc=jingoohan1@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=mpatocka@redhat.com \
    --cc=neko@bakuhatsu.net \
    --cc=thomas.petazzoni@free-electrons.com \
    --cc=will.deacon@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.