Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp3255915imm; Mon, 6 Aug 2018 01:11:29 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcQtxqa/jvgFogNADDDgOCMK8iXk01ch/qf1SgfIGqsblmbBraW/fie31v6QbaHBnoT1gdq X-Received: by 2002:a65:6699:: with SMTP id b25-v6mr13597287pgw.426.1533543089498; Mon, 06 Aug 2018 01:11:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533543089; cv=none; d=google.com; s=arc-20160816; b=ehOQaH70wJOzmjMjymrfbrxm21sVY7OruZx2BSnVBst5d2BA7JqeFmPxqbxob7BgIh spdQdJaFTCKJOpQY3NsGDysgPzB90MsuVKNvr7rGC44yM+VdP29vMmcTcM2aCs6/Je1h AFrZm4+13Oi8ob9A3q4f6+tID3J+p85wRmD9HFvYEVRgt9spTtCitP5w5s1InpMGzI4l 3TKmA1NJaYTML5CTwpatAP0cXsTCnH6WNtDh/wor8mY5HA9r3Das2SmgRHdJXZYI0XZ/ 4sDgXJmaa21YsOAT77ffjIGj9T/gGQ7eirKeDh3YZg3y4baJoyLV9bYrI/AQw9d5VCyJ oYmA== 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=TcZmq5IIRJPxefKxlqnR0Uf+yS6l8Knm7KUwDdoIH4U=; b=FKUGB4o5+pvFoMrcxLxaC/FFy4KKG0fYBuRvWZMgF3AXxA6iNnb/KFgWTKhNo3fLaN p7Ub4E84Wbw6az+wUhxhT+DE8zOjeKbhaL8ZK1VojILrO4O4tiC93j8Qft5fRvu4qBPe wC45TdS8gRnB3HKz5I2Qgpa55BpZnr6aDNa4nc37hR/DdT8HfaBHMC0D2vAEhrD0IF2m dhLdp/gU4kK94RxH3cGg+PoYrgFplW77kQavE2iYHvIA/RZXfotaTAYuZ21T7jFM+Vy2 AoxHB+NJhBJjfqMhBUwJMhC74MOtRPdQ4MLyXZEcZdtVCM4laS+GdJqqJjKrUXiUENRN VcNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=V2TDMlJ1; 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 j8-v6si9663182pgp.548.2018.08.06.01.11.14; Mon, 06 Aug 2018 01:11:29 -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=V2TDMlJ1; 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 S1726855AbeHFKSR (ORCPT + 99 others); Mon, 6 Aug 2018 06:18:17 -0400 Received: from mail-it0-f67.google.com ([209.85.214.67]:36145 "EHLO mail-it0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726468AbeHFKSQ (ORCPT ); Mon, 6 Aug 2018 06:18:16 -0400 Received: by mail-it0-f67.google.com with SMTP id p81-v6so16950043itp.1 for ; Mon, 06 Aug 2018 01:10:23 -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=TcZmq5IIRJPxefKxlqnR0Uf+yS6l8Knm7KUwDdoIH4U=; b=V2TDMlJ1n9brYekclqJGPgg4ovKQu0xxMJdrd4Kqblrot9qNjOPj2IhA9C3FXYGFvL VwFllcXmh0W7xvUNJCPCehuivQkJrVTs5FOzjwGlO4H6AWitjJ5EyAVYv+7MOB5G70rV bWPkulTMQs99XKHE8XeQCTaRJrKNwpF3eHbUU= 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=TcZmq5IIRJPxefKxlqnR0Uf+yS6l8Knm7KUwDdoIH4U=; b=KX9us5mB+8RsJLnxFS5dP1ZBS770t5MB7QI6fwE8bgzeluz2XMAZbxK3O2mpSr4g4R NxNVtmeMc+NbbP3y4Rpka59psGFAW1pAq9Gw+Py9F9wvN154oVR3IPHIXSwrvH2jUcek qB1xwYpgDE0KHw4ySrhilG1oXrJHRi6WRMptwtNS9K/2aesiyd4BBS8QFar5+qCjvk5+ skNFbMlqOYTG9wmpNkxCa7U8DmJfBwBBmpu+h+D2KvofWeLP/pSmo6LKCntRa+sEHY+j XLKjIOs1iaYHq73IRiINvuA+25fjU6d1Wdmo151amhx362g0OdAt40tmjxlOohizJct7 MOVw== X-Gm-Message-State: AOUpUlG1J8a5pgLRRpl9cOFzx4V7HXclBx36uC0vIE7CqBbZWjbiHiL3 HPlboNwsXuuvVaB8qEM1UqfFa61fT+oPlCrxMETXdg== X-Received: by 2002:a24:610d:: with SMTP id s13-v6mr14507155itc.68.1533543023514; Mon, 06 Aug 2018 01:10:23 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a6b:ac05:0:0:0:0:0 with HTTP; Mon, 6 Aug 2018 01:10:22 -0700 (PDT) In-Reply-To: References: <9acdacdb-3bd5-b71a-3003-e48132ee1371@redhat.com> <11f9185a-7f71-83df-3a57-0a0ae9c1f934@arm.com> From: Ard Biesheuvel Date: Mon, 6 Aug 2018 10:10:22 +0200 Message-ID: Subject: Re: framebuffer corruption due to overlapping stp instructions on arm64 To: Mikulas Patocka Cc: Florian Weimer , Andrew Pinski , Richard Earnshaw , Ramana Radhakrishnan , Thomas Petazzoni , GNU C Library , Catalin Marinas , Will Deacon , Russell King , LKML , 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: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.