From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0C50EC4646D for ; Wed, 8 Aug 2018 16:42:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C48DF21A27 for ; Wed, 8 Aug 2018 16:42:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C48DF21A27 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ACULAB.COM Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729208AbeHHTCk (ORCPT ); Wed, 8 Aug 2018 15:02:40 -0400 Received: from eu-smtp-delivery-211.mimecast.com ([207.82.80.211]:53494 "EHLO eu-smtp-delivery-211.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728159AbeHHTCj (ORCPT ); Wed, 8 Aug 2018 15:02:39 -0400 Received: from AcuMS.aculab.com (156.67.243.126 [156.67.243.126]) (Using TLS) by eu-smtp-1.mimecast.com with ESMTP id uk-mta-70-hVx3zmF7MYSdjDil8YEeXQ-1; Wed, 08 Aug 2018 17:42:07 +0100 Received: from AcuMS.Aculab.com (fd9f:af1c:a25b::d117) by AcuMS.aculab.com (fd9f:af1c:a25b::d117) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Wed, 8 Aug 2018 17:43:46 +0100 Received: from AcuMS.Aculab.com ([fe80::43c:695e:880f:8750]) by AcuMS.aculab.com ([fe80::43c:695e:880f:8750%12]) with mapi id 15.00.1347.000; Wed, 8 Aug 2018 17:43:46 +0100 From: David Laight To: 'Arnd Bergmann' , Mikulas Patocka CC: Catalin Marinas , Thomas Petazzoni , Joao Pinto , Ard Biesheuvel , linux-pci , Will Deacon , "Russell King - ARM Linux" , Linux Kernel Mailing List , "neko@bakuhatsu.net" , Jingoo Han , Linux ARM Subject: RE: framebuffer corruption due to overlapping stp instructions on arm64 Thread-Topic: framebuffer corruption due to overlapping stp instructions on arm64 Thread-Index: AQHULxGqyzS7gP0u+Em6lFS72D3AkaS10FEA///9OACAABjskIAAJmTwgAAB3mA= Date: Wed, 8 Aug 2018 16:43:46 +0000 Message-ID: References: <20180803094129.GB17798@arm.com> <20180808121641.GB24736@iMac.local> <19c70d2a0b224db78f72dd316ad006b8@AcuMS.aculab.com> <20180808145017.GE24736@iMac.local> In-Reply-To: Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.33] MIME-Version: 1.0 X-MC-Unique: hVx3zmF7MYSdjDil8YEeXQ-1 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: base64 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org RnJvbTogQXJuZCBCZXJnbWFubg0KPiBTZW50OiAwOCBBdWd1c3QgMjAxOCAxNzozMQ0KLi4NCj4g PiBUaGV5IGRvIG1vZGlmeSB0aGUgc2FtZSBieXRlLCBidXQgd2l0aCB0aGUgc2FtZSB2YWx1ZS4g U3VwcG9zZSB0aGF0IHlvdQ0KPiA+IHdhbnQgdG8gY29weSBhIHBpZWNlIG9mIGRhdGEgdGhhdCBp cyBiZXR3ZWVuIDggYW5kIDE2IGJ5dGVzIGxvbmcuIFlvdSBjYW4NCj4gPiBkbyB0aGlzOg0KPiA+ DQo+ID4gYWRkIHNyY19lbmQsIHNyYywgbG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pbmluZyBidWZmZXIuDQoNCkJ1dCBpbiB0aGUgYWJvdmUgY2FzZSBJ J2QgaGF2ZSB0aG91Z2h0IHRoYXQgdGhlIHNlY29uZCB3cml0ZQ0Kd291bGQgZmFpbCB0byAnY29t YmluZScgLSBiZWNhdXNlIGl0IGlzbid0IGNvbnRpZ3VvdXMgd2l0aCB0aGUNCnN0b3JlZCBkYXRh Lg0KDQpTbyBzb21ldGhpbmcgbW9yZSBjb21wbGV4IHdpbGwgYmUgZ29pbmcgb24uDQoNCglEYXZp ZA0KDQotDQpSZWdpc3RlcmVkIEFkZHJlc3MgTGFrZXNpZGUsIEJyYW1sZXkgUm9hZCwgTW91bnQg RmFybSwgTWlsdG9uIEtleW5lcywgTUsxIDFQVCwgVUsNClJlZ2lzdHJhdGlvbiBObzogMTM5NzM4 NiAoV2FsZXMpDQo= From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Return-Path: From: David Laight To: 'Arnd Bergmann' , Mikulas Patocka Subject: RE: framebuffer corruption due to overlapping stp instructions on arm64 Date: Wed, 8 Aug 2018 16:43:46 +0000 Message-ID: References: <20180803094129.GB17798@arm.com> <20180808121641.GB24736@iMac.local> <19c70d2a0b224db78f72dd316ad006b8@AcuMS.aculab.com> <20180808145017.GE24736@iMac.local> In-Reply-To: MIME-Version: 1.0 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Petazzoni , Joao Pinto , Ard Biesheuvel , Catalin Marinas , Will Deacon , Russell King - ARM Linux , Linux Kernel Mailing List , "neko@bakuhatsu.net" , linux-pci , Jingoo Han , Linux ARM Content-Type: text/plain; charset="us-ascii" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+bjorn=helgaas.com@lists.infradead.org List-ID: 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 From mboxrd@z Thu Jan 1 00:00:00 1970 From: David.Laight@ACULAB.COM (David Laight) Date: Wed, 8 Aug 2018 16:43:46 +0000 Subject: framebuffer corruption due to overlapping stp instructions on arm64 In-Reply-To: References: <20180803094129.GB17798@arm.com> <20180808121641.GB24736@iMac.local> <19c70d2a0b224db78f72dd316ad006b8@AcuMS.aculab.com> <20180808145017.GE24736@iMac.local> Message-ID: To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org 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)