Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp746532ybl; Fri, 9 Aug 2019 13:14:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqw0Pl74x43cFPBzXEKubU32Ec7Sjp658TkXur9AT4PHN3jlIFxZ5t5Qe4wL5C1QkVTSLUHk X-Received: by 2002:a62:1807:: with SMTP id 7mr22802668pfy.149.1565381645759; Fri, 09 Aug 2019 13:14:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565381645; cv=none; d=google.com; s=arc-20160816; b=1Gv8qq1v8hMcg7xwd9p7sdXd23OsQEWhR5mQ5rq3Uiyg3DaWGTzbDk7jvGWje05KME vc2yamRrh0+/dOrjzHtULEzprcct6PCweJ04WD+Totq4d4AtGCz/Cq72SNlyp8fPA34i UvrojFPjBP4PzWPZOc+acFHD8PSlhUwG3WCcK2u5JFZnLglgbVIIkYskIthRUMLh7AYW 0D86NN4fRzjwb8wfl1x+qcwUWsFkQ3PREJv8HJhRrNI3dC6Lpeafs00l8sRSLynrn+qu AkReoxLF+1PprqOLPNFqAXpVRX5DlumFLQ2if4B+r8iry+VnR4AtqBMrhc/paOVelXXA LjDw== 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:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version; bh=lqt3W3Yimah7KMV8CzMPoBkWHp4ps1hEGVaMueNidMo=; b=UBVD2AZgKmKxLTfDOqhf86zX36DWwpjfuhpsRtBzBjZaV/6B4z6B+djoGyjsz8iv7q z2JJXoU87UQ8nOg0/dze7V9VQ7mRTBMeJmWYn7ilJpUQtT3vOdwm+Iyz1Q8JJ+1Llk/c TMchxqJD+xGaaUKeCnfokDx1EGbS5ulwC/0Xuou6ZJjtBZqMY6HZenMqzK6m5Op7eiuN dWjdp6W/X6kBkCcIybL6tw3oubeBJ/WERpYdI70aGSBC1JwhDVPxjXXI+0NZNUFyXesJ AuJ5odM1HHGIBdfF4Be+Y7MfcA+DhTpIYufnucug/ksry8rawSkWr4KkrhQ4m8ZuZtwD 2fqQ== 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 c1si52501609pld.418.2019.08.09.13.13.49; Fri, 09 Aug 2019 13:14:05 -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 S1726457AbfHIUNN convert rfc822-to-8bit (ORCPT + 99 others); Fri, 9 Aug 2019 16:13:13 -0400 Received: from mail-qt1-f195.google.com ([209.85.160.195]:33741 "EHLO mail-qt1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725927AbfHIUNN (ORCPT ); Fri, 9 Aug 2019 16:13:13 -0400 Received: by mail-qt1-f195.google.com with SMTP id v38so4653021qtb.0 for ; Fri, 09 Aug 2019 13:13:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=GbPWtVLcWUFZEanEykp/OCGxgAAWNiMhq/BzUwSZwpc=; b=Pfzv3Vx5kuVq9FwniEfM9fybl5j2vplgWPZHj3YsngCwPcRPIen54GkZxGk8idsHDg pYXCkFPxstZlTyXMMxSTdQcspaNQWVrV+tyu2DNY79C1Zmx3FXCR2b4OQn3nHwkdywOR 6+GjY7qaR7ggnrAN/Gkh1Fjy5lcYEqBNDdlZckTh1zHyZ6/+UkUpUJRd3loZwTOwgdOy 52J6BqTzQCnHImUev4yF5S3UQ8SkpHBlSqydheph6OgruWw0FK5FPBeLGapleWHt4VeU g0kjgDLs8gWmuHa6GwnLOy9e2MOdUt07oMEF4cRQ+CowPZnG4e0htzTor9mPARHw1TVt aLVg== X-Gm-Message-State: APjAAAW+OJVF5z1pvoSHy+1mql/DkCzGm0tH5+CO434YRz3yKTxh27v3 4Rt8fhgIejB2yEqN/6IWMQMq1nwZEsA+VexkPeA= X-Received: by 2002:a0c:ba2c:: with SMTP id w44mr19391116qvf.62.1565381592182; Fri, 09 Aug 2019 13:13:12 -0700 (PDT) MIME-Version: 1.0 References: <87h873zs88.fsf@concordia.ellerman.id.au> <20190809182106.62130-1-ndesaulniers@google.com> <20190809220301.Horde.AR6y4Bx4WGIq58V9K0En9g4@messagerie.si.c-s.fr> In-Reply-To: <20190809220301.Horde.AR6y4Bx4WGIq58V9K0En9g4@messagerie.si.c-s.fr> From: Arnd Bergmann Date: Fri, 9 Aug 2019 22:12:56 +0200 Message-ID: Subject: Re: [PATCH] powerpc: fix inline asm constraints for dcbz To: Christophe Leroy Cc: clang-built-linux , Linux Kernel Mailing List , linuxppc-dev , Paul Mackerras , Benjamin Herrenschmidt , kbuild test robot , Nathan Chancellor , Segher Boessenkool , Michael Ellerman , Nick Desaulniers Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Aug 9, 2019 at 10:02 PM Christophe Leroy wrote: > > Arnd Bergmann a écrit : > > 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". > > > > 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. > > As the benefit is null, I think the best is probably to reverse my > original commit until at least CLang is fixed, as initialy suggested > by mpe Yes, makes sense. There is one other use of the "Z" constraint, so on top of the revert, I think it might be helpful if Nick could check if the patch below makes any difference with clang and, if it does, whether the current version is broken. Arnd diff --git a/arch/powerpc/include/asm/io.h b/arch/powerpc/include/asm/io.h index 23e5d5d16c7e..28b467779328 100644 --- a/arch/powerpc/include/asm/io.h +++ b/arch/powerpc/include/asm/io.h @@ -106,7 +106,7 @@ static inline u##size name(const volatile u##size __iomem *addr) \ { \ u##size ret; \ __asm__ __volatile__("sync;"#insn" %0,%y1;twi 0,%0,0;isync" \ - : "=r" (ret) : "Z" (*addr) : "memory"); \ + : "=r" (ret) : "m" (*addr) : "memory"); \ return ret; \ } @@ -114,7 +114,7 @@ static inline u##size name(const volatile u##size __iomem *addr) \ static inline void name(volatile u##size __iomem *addr, u##size val) \ { \ __asm__ __volatile__("sync;"#insn" %1,%y0" \ - : "=Z" (*addr) : "r" (val) : "memory"); \ + : "=m" (*addr) : "r" (val) : "memory"); \ mmiowb_set_pending(); \ }