Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp263270ybj; Fri, 8 May 2020 11:12:55 -0700 (PDT) X-Google-Smtp-Source: APiQypI6WvpDNCHeLka8dvsPK7FFDSnST2Bc8Ai8HDO9eZjX6wyOBQkCSVAfo4fCQZcWrfC5rREp X-Received: by 2002:a17:906:a417:: with SMTP id l23mr897499ejz.213.1588961575257; Fri, 08 May 2020 11:12:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588961575; cv=none; d=google.com; s=arc-20160816; b=E1Me+u+eYTw8+xg+HrfMP7j4cwimzDG8qJYEHAbX9zrcGBM0hapmuKaNLzRCimI2PM OEIJspezCydlKqyzNN7bYfvQ9q8dZz2Bo7Q5QwwilRxIzytnmUY267Stf0La52GsoOip EIc40Ko5D25h+Bnckfyt+v2G7YWouB9nBkJH1/r6q1phM5Uh1H4jTIYOycKiA/6QbLP+ koXLk52EWOhnlmaAMVH3hQLCUGu5dlVbYOBQh7bvBgTmP0HkiJ0wC7gyEJY2Dfa9mZ9m n0QNjN53ttBN1nZVFwOHnzeImPNs4vhMyPUimgsco5e4tuBDyLYb8gG0xAtVt5DXXMCG Nxrw== 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 :in-reply-to:references:mime-version:dkim-signature; bh=tJNLqaW1D1Ksqfi1Sayg+EttVMlVbom/Q1FHT26F8tA=; b=XQrdmVfDD+aOa4PUvq47pO31u2/eFhlhHj8Llh606hf75DHuQ39bL0cPJLlo4CRlJg nNexaR5m/ja20aQg1i1DrXaN5QFvYQtm6glWUwGspj5FiwFWenUDnqqwzzL6zYl7U8d6 D64I/CCXpvuQ8cw5m4vXqKdz6IaW83f14Si+q/HtYKXTVhe45GllJF7Ikn0XuDXqQoeH d1DxuPiZcCnkpA6rHZPXO5o3LemjQM9ofis5ZSrTIDzu7bER1BwfVaJG2f+eiIwEY39M 9uO3f/psijAlBMdxIoqU7cXXyggyjRYX/bIK6kl0xTPk3GepcLRs6jF65s/WdqCm6DyC zRdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=V4A8WiHx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lw23si1326777ejb.423.2020.05.08.11.12.30; Fri, 08 May 2020 11:12:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=V4A8WiHx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726885AbgEHSI7 (ORCPT + 99 others); Fri, 8 May 2020 14:08:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54004 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726756AbgEHSI6 (ORCPT ); Fri, 8 May 2020 14:08:58 -0400 Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B0125C061A0C for ; Fri, 8 May 2020 11:08:58 -0700 (PDT) Received: by mail-pf1-x443.google.com with SMTP id r14so1361447pfg.2 for ; Fri, 08 May 2020 11:08:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=tJNLqaW1D1Ksqfi1Sayg+EttVMlVbom/Q1FHT26F8tA=; b=V4A8WiHx1E1i/LBjiNpolLKJ52Q2hroM81XQDlZdFRHTiwiYQrDBxpCVnnNNM3+DCx EsdenIzIIFoiYs6wGbL20uCQzBnNKy4FDU5YRK2ySEK/5bRcAM9rSsrZDFqD2b9whIWD nuL45rCmvbfeFQcr3dObr9c0xtA1S+V13iTjvmekpFdCQ/R7l7lpGmjU0FU1ImdZb4Lx znEbn+VOjSwe0HzZQc5KLVjEazrBR046dwuramCZ+BK2n+FhkrzwyKDmfyyS7/mAXWsI GavJgB8Au+xf2RVQURHOqSuBnPZTHOzwQffRy2XhNIWCwpAS1QaQzpCsBOrLxmdcSMWQ FJ1g== 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; bh=tJNLqaW1D1Ksqfi1Sayg+EttVMlVbom/Q1FHT26F8tA=; b=jX5EGj/b8DBod885nKLyvDqP54Daq85a34l+McX0wyaGHqj4U1FVieCCiJh6cTl1IY SyVIBkgt0B8VwOQpsuz1QPSng0LL1tSe2CjHghiDvEYpKZIGGhIpkBQ8dhu7ePhD7vzf 54aYQIbkc9/0dBCn+umsVFXS0Q5av+N/kaXGRnfIT6SLARwMRXIGQswKP+/K5+E4h/GV b7CnZWg6l9+uzCa1ctVYkekPBZLLlfqtBxDVCgdjfBzShniX26qNZL0y+QP2VSgg57od tkEEoc3xrxQzfmX1pJZc4lLK+X/6ZngDhAWERPRjqLXL4whyRtn2a81c8miVMfaHhUVH izuA== X-Gm-Message-State: AGi0PubgzFmPlKAzqejNx7GIrtaPTbqf8/gsAhz4XugdwjUf1T41386Y l8p5MUWOdKzZGu/eDKnVE3/jSfP1WGSyc1B13Rn7HA== X-Received: by 2002:a63:6546:: with SMTP id z67mr3087884pgb.10.1588961337845; Fri, 08 May 2020 11:08:57 -0700 (PDT) MIME-Version: 1.0 References: <8f53b69e-86cc-7ff9-671e-5e0a67ff75a2@zytor.com> <20200508180549.212957-1-ndesaulniers@google.com> In-Reply-To: <20200508180549.212957-1-ndesaulniers@google.com> From: Nick Desaulniers Date: Fri, 8 May 2020 11:08:46 -0700 Message-ID: Subject: Re: [PATCH v3] x86: bitops: fix build regression To: Thomas Gleixner , Ingo Molnar , Borislav Petkov Cc: Jesse Brandeburg , Sedat Dilek , "kernelci . org bot" , Andy Shevchenko , Brian Gerst , "H . Peter Anvin" , Ilie Halip , "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" , Marco Elver , "Paul E. McKenney" , Andrey Ryabinin , Andrew Morton , Masahiro Yamada , Daniel Axtens , Luc Van Oostenryck , "Peter Zijlstra (Intel)" , LKML , clang-built-linux 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 Fri, May 8, 2020 at 11:06 AM Nick Desaulniers wrote: > > This is easily reproducible via CC=clang+CONFIG_STAGING=y+CONFIG_VT6656=m. > > It turns out that if your config tickles __builtin_constant_p via > differences in choices to inline or not, these statements produce > invalid assembly: > > $ cat foo.c > long a(long b, long c) { > asm("orb\t%1, %0" : "+q"(c): "r"(b)); > return c; > } > $ gcc foo.c > foo.c: Assembler messages: > foo.c:2: Error: `%rax' not allowed with `orb' > > Use the `%b` "x86 Operand Modifier" to instead force register allocation > to select a lower-8-bit GPR operand. > > The "q" constraint only has meaning on -m32 otherwise is treated as > "r". Not all GPRs have low-8-bit aliases for -m32. > > Cc: Jesse Brandeburg > Link: https://github.com/ClangBuiltLinux/linux/issues/961 > Link: https://lore.kernel.org/lkml/20200504193524.GA221287@google.com/ > Link: https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html#x86Operandmodifiers > Fixes: 1651e700664b4 ("x86: Fix bitops.h warning with a moved cast") > Reported-by: Sedat Dilek > Reported-by: kernelci.org bot > Suggested-by: Andy Shevchenko > Suggested-by: Brian Gerst > Suggested-by: H. Peter Anvin > Suggested-by: Ilie Halip > Signed-off-by: Nick Desaulniers > --- > Changes V2 -> V3: > * use `%b` "x86 Operand Modifier" instead of bitwise op then cast. > * reword commit message. > * add Brian and HPA suggested by tags > * drop Nathan & Sedat Tested by/reviewed by tags (new patch is different > enough). Oh, and I took over authorship for this version. > > Changes V1 -> V2: > * change authorship/signed-off-by to Ilie > * add Nathan's Tested by/reviewed by > * update commit message slightly with info sent to HPA. > > arch/x86/include/asm/bitops.h | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/arch/x86/include/asm/bitops.h b/arch/x86/include/asm/bitops.h > index b392571c1f1d..03e24286e4eb 100644 > --- a/arch/x86/include/asm/bitops.h > +++ b/arch/x86/include/asm/bitops.h > @@ -52,9 +52,9 @@ static __always_inline void > arch_set_bit(long nr, volatile unsigned long *addr) > { > if (__builtin_constant_p(nr)) { > - asm volatile(LOCK_PREFIX "orb %1,%0" > + asm volatile(LOCK_PREFIX "orb %b1,%0" > : CONST_MASK_ADDR(nr, addr) > - : "iq" (CONST_MASK(nr) & 0xff) > + : "iq" (CONST_MASK(nr)) > : "memory"); > } else { > asm volatile(LOCK_PREFIX __ASM_SIZE(bts) " %1,%0" > @@ -72,9 +72,9 @@ static __always_inline void > arch_clear_bit(long nr, volatile unsigned long *addr) > { > if (__builtin_constant_p(nr)) { > - asm volatile(LOCK_PREFIX "andb %1,%0" > + asm volatile(LOCK_PREFIX "andb %b1,%0" > : CONST_MASK_ADDR(nr, addr) > - : "iq" (CONST_MASK(nr) ^ 0xff)); > + : "iq" (~CONST_MASK(nr))); > } else { > asm volatile(LOCK_PREFIX __ASM_SIZE(btr) " %1,%0" > : : RLONG_ADDR(addr), "Ir" (nr) : "memory"); > -- > 2.26.2.645.ge9eca65c58-goog > -- Thanks, ~Nick Desaulniers