Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp274927ybj; Fri, 8 May 2020 11:30:44 -0700 (PDT) X-Google-Smtp-Source: APiQypKyGFeHyYep+O6iAppoA/UTTXQckO5RQm2bQ1sN65CznecXF4MWsCMAAWW9fYKfoy9xxSIv X-Received: by 2002:a17:906:8699:: with SMTP id g25mr3119880ejx.365.1588962644364; Fri, 08 May 2020 11:30:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588962644; cv=none; d=google.com; s=arc-20160816; b=qnBckEy2xWcTqJzBEPUpCIuJAvjWbJKF9PHtYUn7V/m8ldsOTBjoZM1Ef4GDFFvmlk r6b2ScJ4YcYVRHAhKwafofhY2bZ4lOsaEeQoQYq4S2z5EM4mLFNWAMbz7EM39yg336Ds KAWiIAmZ8/SBmL0sBxBHb5zX0rV97xdZODn6QdsHQNtKh+cbvj8FSjJYOCfC+0inPQ0u ZWciMd+JRRarhNwKJbezhOeW+1pCukQ1dd8noa2ep7T7GBn6hE8h5j6owfYRpT2JRP+Z 0bKQmQFWsiycDSHMlp5hXCKtmOoEExUHHHcpaP0r8m8yvS6LCZJJ0xelIEEVevoBmJkS Eb1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:references :mime-version:message-id:in-reply-to:date:dkim-signature; bh=gHn/2PDn6yjgb3WH2Lc+VyVXY4H0phF5Pi1gV5PCjZk=; b=v6tMzrVFpwX4+Kph7ui8woINB/ZqMgMdb8nCW7kmtahHUikQY59Z3N51bJ9v2+EV9h 9mtKWMSK2r9iUarWsItyVtIZVlgDoPhcxt+WWPtdwePVpyTc3z6BMtf4utyPq34LXLcm QBVUWOuy+c34rGODlKI2yKeiZXDIgd1z1ae8lCgJVdr4bxW9bVtJqHkXJEmisfIkN3pI UxSDzwyFrW1JRGXVGvaJ2PXez9JJ3/x0+3wPfxcS8LSs4zhuGXlWaDLGsbqA7cIY+3lw hcgjFzNWEXTaQW43g5sPJJQxqh9f9yJhMIrUf9rnt4WQTCCmSjCrmaEa3cKM+1UT3jCI xqzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=rjvUB1eL; 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 h60si758833edd.238.2020.05.08.11.30.20; Fri, 08 May 2020 11:30:44 -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=rjvUB1eL; 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 S1727109AbgEHS24 (ORCPT + 99 others); Fri, 8 May 2020 14:28:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57214 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726864AbgEHS24 (ORCPT ); Fri, 8 May 2020 14:28:56 -0400 Received: from mail-qt1-x849.google.com (mail-qt1-x849.google.com [IPv6:2607:f8b0:4864:20::849]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 22074C061A0C for ; Fri, 8 May 2020 11:28:56 -0700 (PDT) Received: by mail-qt1-x849.google.com with SMTP id g14so2905533qts.7 for ; Fri, 08 May 2020 11:28:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=gHn/2PDn6yjgb3WH2Lc+VyVXY4H0phF5Pi1gV5PCjZk=; b=rjvUB1eL7MzUUYdWtuJAUwfONXpWbiaW5x98GWLZRBmtGsh7aH3Bt/OtGn2CkgI4jt Y8Y2B2rLSZh4ueT/jkcCsS/uWV2wpJm+rBPnbrh23K+Co3EwfSrm0JK1picj8efKaQNs eLhZaMbm23NU/p+Vli/n+G7qrVeYJ+0lI1Za8fBB6gZKPKyNgdIG+BvqOUIdK9eYc0Ct wU3bc/WOzLbYjAimo3amzE8XAXkmYLFjz2kGQ3pSgwtuFKkG43c32ThK6zTLajBgPJTF tqzZfu0sqGuKRbcP8T0aWYPn34hLcEJ2dzLxVne8M7l2HPRSIdnKxVCqOgGqdpRz46Bw /BRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=gHn/2PDn6yjgb3WH2Lc+VyVXY4H0phF5Pi1gV5PCjZk=; b=R2RHWdSowS0QD3bpOtP85KyUD7TuPbh/edP+n4v0UGYGg+cjO0+OL4hBKJeHWB5fyw JlnP7YyLR6DJlnGH/81sVVRyXqZkFXbrHYtz3LzndtvuBdf9sWhhe9lYU6X3wVV7rdXs SigNtL29eV8oZtwquS/GIn5mn+DPXnO1U4QHIvTv0G2CIG3RWv9lxjTb+gquETKpm1Tk gkSixfgHwArziImNTqaoIY1lBZtifXarhRLNSf4k92RCA65QqH46Uh1cOD01sd2R7QYr NfAFc6E2zd5F+uwdNHJ/uAXk+eLelaMN9SBM5tY56dMcU+9+9tL7eOTcvmqnEOMcfEdf SssQ== X-Gm-Message-State: AGi0PuaVbpENwocpMLNl/IPMfB6tsVsK/W8FT/wjuVElZ0PKARzR0iqW jUSYqgmbLCzBa5akWU1iokkzaCeRd/gymS7znIQ= X-Received: by 2002:a0c:f1d1:: with SMTP id u17mr4080224qvl.146.1588962535235; Fri, 08 May 2020 11:28:55 -0700 (PDT) Date: Fri, 8 May 2020 11:28:35 -0700 In-Reply-To: Message-Id: <20200508182835.228107-1-ndesaulniers@google.com> Mime-Version: 1.0 References: X-Mailer: git-send-email 2.26.2.645.ge9eca65c58-goog Subject: [PATCH v4] x86: bitops: fix build regression From: Nick Desaulniers To: Thomas Gleixner , Ingo Molnar , Borislav Petkov Cc: Nick Desaulniers , Jesse Brandeburg , Sedat Dilek , "kernelci . org bot" , Andy Shevchenko , Brian Gerst , "H . Peter Anvin" , Ilie Halip , x86@kernel.org, Marco Elver , "Paul E. McKenney" , Andrew Morton , Daniel Axtens , Masahiro Yamada , Luc Van Oostenryck , "Peter Zijlstra (Intel)" , linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com 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 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 V3 -> V4: * drop (u8) cast from arch_change_bit() as well. 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). * Take over authorship. 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 | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/arch/x86/include/asm/bitops.h b/arch/x86/include/asm/bitops.h index b392571c1f1d..8a8b7bb9677b 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"); @@ -125,7 +125,7 @@ arch_change_bit(long nr, volatile unsigned long *addr) if (__builtin_constant_p(nr)) { asm volatile(LOCK_PREFIX "xorb %1,%0" : CONST_MASK_ADDR(nr, addr) - : "iq" ((u8)CONST_MASK(nr))); + : "iq" (CONST_MASK(nr))); } else { asm volatile(LOCK_PREFIX __ASM_SIZE(btc) " %1,%0" : : RLONG_ADDR(addr), "Ir" (nr) : "memory"); -- 2.26.2.645.ge9eca65c58-goog