Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp3301350imm; Mon, 6 Aug 2018 02:12:50 -0700 (PDT) X-Google-Smtp-Source: AAOMgpc9EAfeshe+VTZ2iOyLAnwcXf6ncznni8HaRnkfhy1AEczgmWLzl/GXJ53sIT6CUbQBOnq1 X-Received: by 2002:a62:b40c:: with SMTP id h12-v6mr16329147pfn.18.1533546770655; Mon, 06 Aug 2018 02:12:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533546770; cv=none; d=google.com; s=arc-20160816; b=hnsOgkmDVLbHMKJubAf3PQw+jmMLL3hyREfsEVn9nhr+WeQViWwaoYMGOY/IXakFm/ xxBeYlQMYNj5ggS00oJZDqeFa/0ukmHxvONDRa0T1xvKllyAMWjACA0qFQ32Qa5cftiw kOAzY9t4BjRyFqj/IQhn9/t7x8kJJxS5tniLRCTJRlNH+aC1xKTbs2IGz+ytdKOOLxiE CQ26mh6NMfKo73gzI0ACP0ALRdH4Toup7IwzowrSo4cszqxUvKFeddDVJXWN/58LngQw VfAWzpHG7haElbC5LBX3aV+Igzu/QQ7aUiWliF5aSdqfOAena2e9F2dB/DQKlwuw7ca0 SgTw== 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 :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=RCZB0ZVFv8FIOgUmlL30m9L8ABGmQae2nWiAXL6pPFc=; b=zvbLO38tKKSJo7r667/e3vSOkJ7YeJ0K0oE+tSkPU+qjeKEweaX1qBD9ZYse4iI439 ku8wzyHsozQqO6dXkc2IujrauZjDvOwwZR9pGrcJRkEGhbZO44kOzLPGX8wB4i07gU2N I07Bmtc3gpBH+4gAPDAPQpxl6qd9+a6q8BHg3wlH5RXWuxX5qkwRts8t+fiz400n3JBZ JGiMeOcBzX7ld/Pby0XrYaKROuMjARyi5YohY1K/maZIhuK82H0vCaz/B5KCXinNBDpz tJNqCRqxBOV55LFVa+aF7eyPhlEkEGrFJ2b6F80RYZp5Iyy7RJFouXUvZWoKsEClO+mO 67wA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=e0734X0D; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h29-v6si12369296pgb.53.2018.08.06.02.12.35; Mon, 06 Aug 2018 02:12:50 -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; dkim=pass header.i=@linaro.org header.s=google header.b=e0734X0D; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727595AbeHFLTr (ORCPT + 99 others); Mon, 6 Aug 2018 07:19:47 -0400 Received: from mail-it0-f43.google.com ([209.85.214.43]:51533 "EHLO mail-it0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726572AbeHFLTr (ORCPT ); Mon, 6 Aug 2018 07:19:47 -0400 Received: by mail-it0-f43.google.com with SMTP id e14-v6so16466897itf.1 for ; Mon, 06 Aug 2018 02:11:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=RCZB0ZVFv8FIOgUmlL30m9L8ABGmQae2nWiAXL6pPFc=; b=e0734X0D6CvG96klnOoFsmXUrPtt1v4JBiUgYNtEV9cINU++NOIVLGMplBcpbldh1w 9NFB5KOPnmO647JB3xfMQbtrSWBYBrjJt2JMTeSQk9kLDFiUD8fvHtAHUlUyZfhPgfIL Qrs1PW/74EtYCK6RwUa0gayixSs//gKvgrVbw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=RCZB0ZVFv8FIOgUmlL30m9L8ABGmQae2nWiAXL6pPFc=; b=GRulKTwS16IkOAR3io45YqhI/rHQaVNjQN/qtwTbGxLyq79sQ7158lAZ2BZIlH/nGL wOqIRjOAx+BdplVc00q9Po5OR1xJKoZVf2fwRWF8BvNcP/IkCdyNl8bmc69UdszV+C2U zJC8NDa89eZf/si87s+JkkYJwo6POsFa3YBgJacJ2Q8qMwZ8OJFbtPb/WwMgILRRePmT 0y7/2J3E5wP9xQhIyaELpDJj6dgLtwOZJjxdRItlgWCQvpOMe7x9ZgOnlaOfNgGHVEXG nVV3YZSmd9olVC4sUkM0/XMsCMwkfBlxkwRnNjiahFgp4b8ALbtJXLqJEnrysR+J6XnA 4qCA== X-Gm-Message-State: AOUpUlG1CRIyaWBWs66aMuFX6vxGuRRgZq1bF08v9/2ogCVChYksVnNe r2nzQ4kdIT/EA4+hxsuhZ42xt6F7Av117lXAf2gv5Q== X-Received: by 2002:a24:5242:: with SMTP id d63-v6mr14568370itb.138.1533546699871; Mon, 06 Aug 2018 02:11:39 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a6b:ac05:0:0:0:0:0 with HTTP; Mon, 6 Aug 2018 02:11:39 -0700 (PDT) In-Reply-To: <20180806084451.GB19523@amd> References: <20180805213615.GA1862@amd> <20180806084451.GB19523@amd> From: Ard Biesheuvel Date: Mon, 6 Aug 2018 11:11:39 +0200 Message-ID: Subject: Re: framebuffer corruption due to overlapping stp instructions on arm64 To: Pavel Machek Cc: Ramana Radhakrishnan , Thomas Petazzoni , GNU C Library , Andrew Pinski , Catalin Marinas , Will Deacon , Russell King , LKML , Mikulas Patocka , linux-arm-kernel 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 6 August 2018 at 10:44, Pavel Machek wrote: > On Mon 2018-08-06 09:04:33, Ramana Radhakrishnan wrote: >> On Sun, Aug 5, 2018 at 10:36 PM, Pavel Machek 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. >> > >> > No, I don't think so. Why do you think so? >> >> It is undefined behaviour in the architecture. > > Why do you think so? Pointer to documentation would be helpful. > > Normal access is used for mmapped areas, and I don't think we want to > change that. Pavel, In this context, 'device mapping' specifically means one of the Device-{G,nG}{R,nR}{E,nE} mapping attributes as defined by the ARM ARM, where G, R and E stand for Gathering, Reordering and Early acknowledgement, respectively. There is no disagreement whether memcpy() is suitable for such regions - it is not. These mappings are intended for memory mapped device registers, not for memory. The issue under discussion here is whether PCIe can provide outbound windows with true memory semantics, which is the assumption that is present all throughout the Linux graphics stack.