Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp271076ybj; Fri, 8 May 2020 11:24:42 -0700 (PDT) X-Google-Smtp-Source: APiQypJwvWbP+dElq9zUMXWU/A2Xsf8TDu8WZnG0NTJrNILCYdAbMxYyCUNmoEN5uuctCitIy7jp X-Received: by 2002:a50:b286:: with SMTP id p6mr3322302edd.350.1588962281983; Fri, 08 May 2020 11:24:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588962281; cv=none; d=google.com; s=arc-20160816; b=krpBV6LImETBhYpO0TGhZqeD1sT9QoxDAI2qq1LIMLhhBWFU0o5p/nSlis+4bULaPV kB6ZPvgL9yQUfw8m4eG1QxBu4NSXmz5r0MNkVS210mTRZAv8H0uj32WGaGnP3VKHwJB+ nL09a6oo7VIctfIGObAr5WXZoNwS7xmcxHceh4DYtyyQVw4MpaTyivacc38dF/A8MVOm 90jk6Crn6GjJlWTb6BH38puTTau6yN0L5lB2CxFqyb5W/ULXWoVl1ojgIETBh/hEQPeL EHPjA5zl2G94/LhElPu0zIOVpZxJ/GeU8rTY71cfUEHpkQ06tDSXGrt+HhCiDU1oGnkD vgFA== 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=CuLGBSMOTYn4dAx7WFdAghXNS6+9FS80m4Fr5hGuJ/Y=; b=hGCPxpxtcmq3pXo7G0jS1QMKhrlb7UUepr9cHeO0egzvpXuSHEQ+jNATku+L8iLU2S DWAktM2kf/LPnoTmyrwtcxa//yNvYAuGzKXV6DX4oUoLBqLEvDDNIu4Ud3FmYwzGWmyH t7dhZDaTaAU8CP9N4ksdB1eBLNImOJfhwzjLGNDfS7fleQBbwiVvsor1OTU6R2GzWRqt JCS6MEzsTv1/IbgIe1yuiIOQ0nFL8gxEVWPt8OvyP+fUHFe/Vn9z4kxTyUMyveg0vbpu ObS0BO53u17NBUAsQb5laSWg9wRDtLh++cl/bgu2kJJpYv8wvXPbhTFUzu0qz4qohchP 8yTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=oo4EcoTS; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e19si1148476ejd.174.2020.05.08.11.24.18; Fri, 08 May 2020 11:24:41 -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=@gmail.com header.s=20161025 header.b=oo4EcoTS; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726885AbgEHSWg (ORCPT + 99 others); Fri, 8 May 2020 14:22:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56158 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726636AbgEHSWg (ORCPT ); Fri, 8 May 2020 14:22:36 -0400 Received: from mail-io1-xd43.google.com (mail-io1-xd43.google.com [IPv6:2607:f8b0:4864:20::d43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DDE11C061A0C for ; Fri, 8 May 2020 11:22:34 -0700 (PDT) Received: by mail-io1-xd43.google.com with SMTP id z2so2710926iol.11 for ; Fri, 08 May 2020 11:22:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=CuLGBSMOTYn4dAx7WFdAghXNS6+9FS80m4Fr5hGuJ/Y=; b=oo4EcoTSJnRzGK1caVtJqQpbOCfEmRASCbjGqaAJzHumOfLSUu7XlJ/LUsCESdEdMe PH+6h0hr/UwnzhbInLEUiwDOC0H0LqovghEWw1L1ednOMarEoe2f+Lqz3Fhfwxli3j4f wosVZwjt3c93VlHjHJdvMq9Gvc6jPd9M2G2hSZS+JmeQV5M01m3vkFHyWbaLen+6hbDw CWEd+wA9cJSOTBIwXJZutPoeuYdry7eoXDOqTyO8h/LHm7EVn80sXVRylYlBotJAcD8O 0F/dAI6cXDyL4b5QM6+jFd52TEKA9jCja2naDEkQJ9x39n43u+TBiyh2lNK47Tpkoa40 Cjaw== 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=CuLGBSMOTYn4dAx7WFdAghXNS6+9FS80m4Fr5hGuJ/Y=; b=Ax6V57G0jz5oBsccrepWPlVU7L97BXzxvDGpt39wcmCD0EIKdz/e+PRLzzwCAx9ST9 YFk8MKRvEBHAyQz4L72CcRYYm1vpSGW0lfcOu1add2FSXvo2XzuqM0MbJAa1phnVZejw DCxOXWcr4DFqD6M5ZK1qAXoxCoQb5iDolA3jnEHEXzJ/OjD6Ikp9raEt7zWXdBnAri/h FCvkMEg6iwHAKGRa0g+ZCmMVUHu1ppcgc8HciqvPZB5VymtORtdmMQKptTSekjACEt+Q Ipfv2iv1d/1KQ5cymvzCqhWi48+uTR4BWifVKwtUuij1yNxZE/f/EegsGAVd8PoBO7an pD2g== X-Gm-Message-State: AGi0Puabup2HABN1uUmBtaEgC9RPGAvhfRTE/7GEyEkuo9yqJabbw8Tv PT4kVOihyUNhGBGkQv1Jt08bRtiu4BGIRWFv+0U0Cp8= X-Received: by 2002:a02:c848:: with SMTP id r8mr3811480jao.55.1588962154227; Fri, 08 May 2020 11:22:34 -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: Brian Gerst Date: Fri, 8 May 2020 14:22:23 -0400 Message-ID: Subject: Re: [PATCH v3] x86: bitops: fix build regression To: Nick Desaulniers Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Jesse Brandeburg , Sedat Dilek , "kernelci . org bot" , Andy Shevchenko , "H . Peter Anvin" , Ilie Halip , "the arch/x86 maintainers" , Marco Elver , "Paul E. McKenney" , Andrey Ryabinin , Andrew Morton , Masahiro Yamada , Daniel Axtens , Luc Van Oostenryck , "Peter Zijlstra (Intel)" , Linux Kernel Mailing List , 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 2:06 PM 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). > > 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"); arch_change_bit() should also be changed, but otherwise looks good. -- Brian Gerst