Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp843777ybl; Fri, 9 Aug 2019 14:57:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqzRtVV7shSGEGUartW+vKcQVppDDi48riTwRK8LV+fSJSdVJquDyfZOL3//UOND1F4Al/1N X-Received: by 2002:a17:902:424:: with SMTP id 33mr5521643ple.34.1565387847595; Fri, 09 Aug 2019 14:57:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565387847; cv=none; d=google.com; s=arc-20160816; b=iENS13OCM8joQqiPIdNpD8TjQklQT/NRDzh7VqbyukEmUEUZBeVJzL3UkZf7NKzb9J 0fiAIY95MANcH3NOH8f+DmCBqGvgDiZ96yJd6Qn5wsL9IIP+Pwa3sBlcZnW3ON4pxc6i otHhiiibrxrpjyqH7JiWXAL88vn0iukfk7Cv5gD9dTeT98Yq0VsJf64+oQFh13UbcsHh wkbLab19Kvf6s1qXDrt/H/Im8EpPc5ab6pUe/kaGbhEcFapRcIcjxXSg9e4yy45Rx4sC vOw7VirwER56pGTBNlx1pSez7E0dyRHvltHHHP2XwoNDyr/AV1tTbLRIbppz0lcfkWTA ebPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=/rZEG6CcOetRqFIPcL4b0Og1hlvdPzyamUkDUhSPtzg=; b=XGUnHRGfA3onNiqwCZLMAwZxGAk5XJq/WNRwwoa3BmPiF2ns+J6oguW5KjHIN5ANq8 HyIwC0FjKagQNm3OFdIFMBskbDr9mDKVUotoIrZ36xRzDypYsA2IbzbSBDrU6DAYfSUw lrFhkACI3fMT/sso5s0BXqtHzSN2mLu18om2rSftrnWE5CJXlcGNk+kwGcCN1T/g7tN0 SUVjTCLx/o7s3C2UUjZkM24/nwo0WKTNtGfVU1k4QBdkHlgpIdSMNLmWde96wirpMfMQ DQIgfb9vnHw5WltS0CEf0cInlm4qOnPvE/5vL3m8a7sQXOWS2PmgfVHg5M1tVZ5ry/sT XBzA== 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 p20si57957433pgk.158.2019.08.09.14.57.11; Fri, 09 Aug 2019 14:57:27 -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 S1728245AbfHIV4T (ORCPT + 99 others); Fri, 9 Aug 2019 17:56:19 -0400 Received: from gate.crashing.org ([63.228.1.57]:48105 "EHLO gate.crashing.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726140AbfHIV4T (ORCPT ); Fri, 9 Aug 2019 17:56:19 -0400 Received: from gate.crashing.org (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.14.1) with ESMTP id x79LtXlt029610; Fri, 9 Aug 2019 16:55:33 -0500 Received: (from segher@localhost) by gate.crashing.org (8.14.1/8.14.1/Submit) id x79LtWbT029609; Fri, 9 Aug 2019 16:55:32 -0500 X-Authentication-Warning: gate.crashing.org: segher set sender to segher@kernel.crashing.org using -f Date: Fri, 9 Aug 2019 16:55:32 -0500 From: Segher Boessenkool To: Arnd Bergmann Cc: Nick Desaulniers , Michael Ellerman , christophe leroy , Nathan Chancellor , kbuild test robot , Benjamin Herrenschmidt , Paul Mackerras , linuxppc-dev , Linux Kernel Mailing List , clang-built-linux Subject: Re: [PATCH] powerpc: fix inline asm constraints for dcbz Message-ID: <20190809215531.GN31406@gate.crashing.org> References: <87h873zs88.fsf@concordia.ellerman.id.au> <20190809182106.62130-1-ndesaulniers@google.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2.3i Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Aug 09, 2019 at 08:28:19PM +0200, Arnd Bergmann wrote: > On Fri, Aug 9, 2019 at 8:21 PM 'Nick Desaulniers' via Clang Built > Linux wrote: > > > static inline void dcbz(void *addr) > > { > > - __asm__ __volatile__ ("dcbz %y0" : : "Z"(*(u8 *)addr) : "memory"); > > + __asm__ __volatile__ ("dcbz %y0" : "=Z"(*(u8 *)addr) :: "memory"); > > } > > > > static inline void dcbi(void *addr) > > { > > - __asm__ __volatile__ ("dcbi %y0" : : "Z"(*(u8 *)addr) : "memory"); > > + __asm__ __volatile__ ("dcbi %y0" : "=Z"(*(u8 *)addr) :: "memory"); > > } > > I think the result of the discussion was that an output argument only kind-of > makes sense for dcbz, but for the others it's really an input, and clang is > wrong in the way it handles the "Z" constraint by making a copy, which it > doesn't do for "m". Yes. And clang has probably miscompiled this in all kernels since we have used "Z" for the first time, in 2008 (0f3d6bcd391b). It is not necessarily fatal or at least not easily visible for the I/O accessors: it "just" gets memory ordering wrong slightly (it looks like it does the sync;tw;isync thing around an extra stack access, after it has performed the actual I/O as any other memory load, without any synchronisation). > I'm not sure whether it's correct to use "m" instead of "Z" here, which > would be a better workaround if that works. More importantly though, > clang really needs to be fixed to handle "Z" correctly. "m" allows offset addressing, which these insns do not. That is the same reason you need the "y" output modifier. "m" is wrong here. We have other memory constraints, but do those work with LLVM? Segher