Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp3366370imm; Mon, 6 Aug 2018 03:34:22 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcQ3v08xd/rqik3Mx2lvvlY/4Z1lr2pqfNf01XG5VjIrBxrp8nXW0wjDjlqyWkZhXZCIRAH X-Received: by 2002:a65:5307:: with SMTP id m7-v6mr14282289pgq.431.1533551662800; Mon, 06 Aug 2018 03:34:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533551662; cv=none; d=google.com; s=arc-20160816; b=IFbPQDXDSLvxUaU4nT4A6Ypuf4WcQCnffr/TIV7QjHIrUWma4izNVzi9PqfInjd3sE vYHi9ugkdLnNsYL7SCWscNOuP6cEupGncHgrdkHR5G8jrxg1GQus6zBCg36HYTu1il7G 8/3j43bD5Be5VPHyq5HOFTCFDi1WB53GxuiL3dgrqjh7QxPi7Yo71TMAh8rcQLnIw71z Nf1v+v8rHKp2p1OqOKWY59xAFwIZdPOvPlURIX2l/Bm1BOjZTlplXGOl6ig694nUXYng FrvrAwsnrIjPCRQp0MZ+a04bZiD8HHXvL7ntGjDYki3sHs0vmbTvLbOm/oqp9BTpEsni FUmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date :arc-authentication-results; bh=odtt4oYHPx+Zc0GdzgHYM477oChvAPYlR2r4w0MOxY0=; b=PBLNAQWVgKbnYIbXDrRk1QZD3PY/2fEkoD+dJSTTE0FOxeujXCrz99jQATgiS8zlMA /rkitoRlTJKIEUTT5NMcNrtI8xpM1nTDUMl2m8jPJCStUC1MhkxNxT+zgszFQL4sNz8N w8D1iDja6iMeDtCOqXMY7h2HqAY3CHu2Dcq3VArj3QafdO+224UWSW1uxxrAEFaod+Qt cXC2rPS6Uzi5pa6kiAlyr+uYfe+pIu/hcC37XfJMf2RURXU06LKPMcYiYLWRDyliEHWO lSlNRJqWCVf1SGNFtkdI6OZc9m6mrP0QbCKRvkb44xDIqXerfgpz67C9N7/UFKUs3rdk 5lbA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k30-v6si13111580pgf.415.2018.08.06.03.34.07; Mon, 06 Aug 2018 03:34:22 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729741AbeHFMkS (ORCPT + 99 others); Mon, 6 Aug 2018 08:40:18 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:53344 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727517AbeHFMkS (ORCPT ); Mon, 6 Aug 2018 08:40:18 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0A5218011454; Mon, 6 Aug 2018 10:31:52 +0000 (UTC) Received: from file01.intranet.prod.int.rdu2.redhat.com (file01.intranet.prod.int.rdu2.redhat.com [10.11.5.7]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D8132178BE; Mon, 6 Aug 2018 10:31:51 +0000 (UTC) Received: from file01.intranet.prod.int.rdu2.redhat.com (localhost [127.0.0.1]) by file01.intranet.prod.int.rdu2.redhat.com (8.14.4/8.14.4) with ESMTP id w76AVpX7004481; Mon, 6 Aug 2018 06:31:51 -0400 Received: from localhost (mpatocka@localhost) by file01.intranet.prod.int.rdu2.redhat.com (8.14.4/8.14.4/Submit) with ESMTP id w76AVpgd004373; Mon, 6 Aug 2018 06:31:51 -0400 X-Authentication-Warning: file01.intranet.prod.int.rdu2.redhat.com: mpatocka owned process doing -bs Date: Mon, 6 Aug 2018 06:31:51 -0400 (EDT) From: Mikulas Patocka X-X-Sender: mpatocka@file01.intranet.prod.int.rdu2.redhat.com To: Ard Biesheuvel cc: Florian Weimer , Andrew Pinski , Richard Earnshaw , Ramana Radhakrishnan , Thomas Petazzoni , GNU C Library , Catalin Marinas , Will Deacon , Russell King , LKML , linux-arm-kernel Subject: Re: framebuffer corruption due to overlapping stp instructions on arm64 In-Reply-To: Message-ID: References: <9acdacdb-3bd5-b71a-3003-e48132ee1371@redhat.com> <11f9185a-7f71-83df-3a57-0a0ae9c1f934@arm.com> User-Agent: Alpine 2.02 (LRH 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Mon, 06 Aug 2018 10:31:52 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Mon, 06 Aug 2018 10:31:52 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'mpatocka@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 6 Aug 2018, Ard Biesheuvel wrote: > On 6 August 2018 at 10:02, Mikulas Patocka wrote: > > > > > > On Sun, 5 Aug 2018, Florian Weimer wrote: > > > >> On 08/04/2018 01:04 PM, Mikulas Patocka wrote: > >> > There's plenty of memcpy's in the graphics stack. No one will be rewriting > >> > all the graphics drivers because of tiny market share that ARM has in > >> > desktop computers. So if you refuse to fix things and blame everyone else, > >> > you can as well announce that you don't want to have PCIe graphics on ARM > >> > at all. > >> > >> The POWER toolchain maintainers said pretty much the same thing not too > >> long ago. I wonder how many architectures need to fail until the > >> graphics stack is finally fixed. > >> > >> Thanks, > >> Florian > > > > If you say that your architecture doesn't support unaligned accesses at > > all, there's no problem - the compiler won't generate them and the libc > > won't contain them. > > > > But if you say that your architecture supports unaligned accesses except > > for the framebuffer, then you have a problem - the compiler can't know > > which pointers point to the framebuffer and libc can't know either - you > > caused this problem by your architectural decision. > > > > You can use 'volatile' to suppress memory optimizations, but it's > > impossible to go through the whole Linux graphics stack and add volatile > > to every pointer that may point to videoram. Even if you succeesed, new > > videoram accesses without volatile will appear after a year of > > development. > > > > See for example the macros READ_ONCE and WRITE_ONCE in Linux kernel - they > > should be used when there's concurrent access to the particular variable, > > but mainstream architectures don't require them, so many kernel developers > > are omitting them in their code. > > > > If you are building a supercomputer with a particular GPU, you can force > > the GPU vendor to provide POWER-compliant drivers. If you are building a > > workstation where the user can plug any GPU, forcing developers will go > > nowhere. You have to emulate the unaligned accesses and make sure that the > > next versions of your architecture support them in hardware. > > > > I have the feeling this discussion is going off the rails again. > > The original report is about corruption when doing overlapping writes. > Matt Sealey said you cannot have PCI outbound windows with memory > semantics on ARM, and so you should be using device mappings (which do > not tolerate unaligned accesses) > > In this context, 'device mapping' does not mean 'any non-DRAM region', > but it refers to a particular type of MMU mapping attribute defined by > the ARM architecture. > > I think we can all agree that memcpy() should be usable on any region > of memory that has true memory semantics, even if it is backed by VRAM > on a graphics card. > > The question is if PCIe can provide such regions on ARM. I think there are three possible solutions: 1. provide an alternative memcpy implementation that doesn't do unaligned accesses and recompile the graphics software with -mstrict-align 2. map the PCI BAR as device memory and emulate the unaligned instructions 3. find some hardware workaround that could insert delays between the PCIe accesses (but the hardware engineers need to cooperate on this instead of asserting that they refuse tu support it) Mikulas