Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp523407imm; Fri, 3 Aug 2018 07:18:43 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeMWqxIluM6f1eCMd4Qgn92Cwy4a+n7ChrdXnZt9L4AhSAKsR3D3Wh1yjaFFomMY1a2XNeY X-Received: by 2002:a17:902:6802:: with SMTP id h2-v6mr3738727plk.113.1533305923533; Fri, 03 Aug 2018 07:18:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533305923; cv=none; d=google.com; s=arc-20160816; b=W0GYy+jyRCUUbmEJ05rER8UbByC3rV9I81+5QCEQdoMSWxex3lFfON7Jm4ZedWIDkC 3AiP/Mcv5KCAzF1uAtV7kksg9QYw5wpe2jkWNQVUySrMudDAJiMv2Fq0ZKe8Av75Y1Fd JiwDw1SSOTbqLJhIPi0vXP845VIBpRAB+TfFx+lh9NS9OwcSVmC85sZR+vGygvtu0qyL 0rWhzg+FR62LWeXwliYYs9iC6Ee0flaH91XWyEXnAm8Ij8306FWKhWNRFu+JrCOH7DfT iRbzYDc30Cae2CfaCMAtcCFDebI1t91ezVC5/wxjbs4s6KKru69FD/E+oHaMuh7U63eu tSlA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:openpgp:from:references:cc:to:subject :arc-authentication-results; bh=V4GCswSW9u3cVAj9F+kurmIyWZKCoy1rIBSoP6uUhw8=; b=CJID2A95WpijozKgi8PlvMrXAaxsPYSmGKFmW4IDeZ0lK4pI9Qkx7ni9KIQLzljD8u BadjlBC9eTIMvyRNV8eMzg+eYA+r5v+x6qetygp73H3BBlcFmwkMDq+ocJn6kCmhpl+W EHnjhlC9NWm05VWY6KVdW41BEchOFr+eeUZbf4rkqhysrYMMl23oCU9tcTyqU7xc/O+q 1aB5bQuwcivTP0KkB/Qq4nbQGYpk59zmu49o5htQ1MvCLGBEpEyJA6/V2pX/YFJQInz2 6M6DCwC2V9wbQBO7shj0+mD9azJXuNfgHSW7sBiKckN+rFXQWGmbGWsCePAvWaAx2sZ2 0hgA== 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 l10-v6si5142277pgb.510.2018.08.03.07.18.28; Fri, 03 Aug 2018 07:18:43 -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 S1732266AbeHCQON (ORCPT + 99 others); Fri, 3 Aug 2018 12:14:13 -0400 Received: from foss.arm.com ([217.140.101.70]:43438 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731948AbeHCQON (ORCPT ); Fri, 3 Aug 2018 12:14:13 -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 1E07C80D; Fri, 3 Aug 2018 07:17:40 -0700 (PDT) Received: from e120077-lin.cambridge.arm.com (e120077-lin.cambridge.arm.com [10.2.207.74]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 6F4623F2EA; Fri, 3 Aug 2018 07:17:38 -0700 (PDT) Subject: Re: framebuffer corruption due to overlapping stp instructions on arm64 To: Mikulas Patocka , Andrew Pinski Cc: Catalin Marinas , Will Deacon , linux@armlinux.org.uk, thomas.petazzoni@free-electrons.com, linux-arm-kernel@lists.infradead.org, LKML , GNU C Library References: From: "Richard Earnshaw (lists)" Openpgp: preference=signencrypt Message-ID: Date: Fri, 3 Aug 2018 15:17:36 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=us-ascii Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03/08/18 14:31, Mikulas Patocka wrote: > > > On Fri, 3 Aug 2018, Andrew Pinski wrote: > >> On Thu, Aug 2, 2018 at 12:31 PM Mikulas Patocka wrote: >>> >>> Hi >>> >>> I tried to use a PCIe graphics card on the MacchiatoBIN board and I hit a >>> strange problem. >>> >>> When I use the links browser in graphics mode on the framebuffer, I get >>> occasional pixel corruption. Links does memcpy, memset and 4-byte writes >>> on the framebuffer - nothing else. >>> >>> I found out that the pixel corruption is caused by overlapping unaligned >>> stp instructions inside memcpy. In order to avoid branching, the arm64 >>> memcpy implementation may write the same destination twice with different >>> alignment. If I put "dmb sy" between the overlapping stp instructions, the >>> pixel corruption goes away. >>> >>> This seems like a hardware bug. Is it a known errata? Do you have any >>> workarounds for it? >> >> Yes fix Links not to use memcpy on the framebuffer. >> It is undefined behavior to use device memory with memcpy. >> >> Thanks, >> Andrew Pinski > > Links can be fixed easily - but there is exterme amount of code that > accesses videoram via C pointers in the Xserver and in the GPU drivers. > How do you intend to fix that? > > What should we use instead of direct access or memcpy? Libc doesn't > provide any macros or functions for framebuffer access. Using hardcoded > assembler doesn't make the the programs portable. > > Mikulas > Dialing back the optimization levels when building the Xserver so the compilers plays by its rules is one thing. Dialing back the optimizations in the C library to handle a non-conforming program is quite another. That affects every program on the system, even if it turns out to be a server with no graphics system. R.