Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp2074106ybj; Wed, 6 May 2020 10:08:00 -0700 (PDT) X-Google-Smtp-Source: APiQypIgCnoK3Y7SRfO4zY7zP/aPCsSHdvK8AHmyZPAKaMzJwqEEA0f2Dl0fxVh8xuxYyc9c+05c X-Received: by 2002:a17:906:551:: with SMTP id k17mr8477139eja.350.1588784879895; Wed, 06 May 2020 10:07:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588784879; cv=none; d=google.com; s=arc-20160816; b=R88j60lWJp5NcVUdBzKZtXnQW5RppokWn7bPWthzTLLcKKPaFdc/y3L9DH7VKOADrj wTT9k1KHhRoDyhUNCE2EO/Fy6TmTdrZhdRul0zSOI2B9F5gJG+RAzOVHNzKKA4e7vA+Z nDSv5G03wVCibZfpy1IIwYh/fzrnwc5P7snGO9I5GiUiKr5V5jxhuOjya+MRl6bFZGJZ RkeCvlcBpRilbBLZWRXqjdCfFy0ucHo0lhgvmH95ij5XNzzfNEmwTUuweTYVyMbxGcbL x6k5Iwa9BpDJ8/FqUTfRLj97BuN51NH+9GIyb1EDNk2qZ6rHPpN9C7NnJn1gkQG9RAYi 0UMg== 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=38D9XAXV7mzVHBBpOcAS7ARBaUBu+dmzE+ZxtJSi07k=; b=WcFZe9tQlEPinZj2DY7cri6oDD6JhMaUI29ikgsgrpD26f031YoqAKKElKNq5wlJjU o2vMWs276b8JygnUmBW9bfqz1bjKj4KBAtzlyc2WmkBtwTgrgVV0ypPhnnmEDspNX+Hd HKGTUblUGd02cTTSYwuf/9RBhPw5owlF26j385EaNRNCxdsBHSrFdq9DkqMOTPcztcg+ Gr6VW99KHonwB5sEqxJ3YhyT+sRW8FRD2/RKQ/6GwTHZczHesgYlWOD6qF+YSGyoDLbT v0syigEhoXHshr+X2Y91Gs0OApSxS6nOoNHCs8VoAxS8MyrHlk84+j939T4dYWvAAXG6 pO1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Vpdo5MHE; 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 e23si1411046edy.578.2020.05.06.10.07.35; Wed, 06 May 2020 10:07:59 -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=Vpdo5MHE; 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 S1730159AbgEFRGE (ORCPT + 99 others); Wed, 6 May 2020 13:06:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46554 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1729414AbgEFRGD (ORCPT ); Wed, 6 May 2020 13:06:03 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 501BBC061A0F for ; Wed, 6 May 2020 10:06:02 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id 186so3366031ybq.1 for ; Wed, 06 May 2020 10:06:02 -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=38D9XAXV7mzVHBBpOcAS7ARBaUBu+dmzE+ZxtJSi07k=; b=Vpdo5MHEmM/Z+zw+EZQC/et7d3BOBcK04yt396UAXf4EYchp8p81hgVpWWHHtvD+dw VKpdIoiUMGfavJAcMjRkTu/ew5mzMiMbAuESyzFmO94XO1clTnQNFqO9TXMTprL2jAhb 5nR3rK+jblYJcry7j/dtvDXsLOAJu+I8EiljrGJAF+IkMFzLIvd+AZlbAmKHEoHeWIbn quoFL4QuPqfcAuLvFlpaEon62y3uS+iWRxLU+zbJ15Muo5P7sXmSSTvqt6g78AQ0W+2B Wa6KcU8oXNrKFVNBpecTO+rJjMjVL3kXNuSghLpR5TN0h4Ww8tbIlo4M4snmTdg1O/js xF3w== 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=38D9XAXV7mzVHBBpOcAS7ARBaUBu+dmzE+ZxtJSi07k=; b=K4iLuyCFAahVAvfV8WeHGw5Z9M7dFJQdakFBpkbXiSH426UQaDT+ep0eUT8TIIzlNU cu/oIZ30lbg233JP76WMDxdcaHc8LKHF7ap0ZMznmggVcqmnL31BZWzXVPkixwoJvYj0 /bBA6Q34NblP/ddZi0T5eVuKi/6DgrjpL9NYfpwo5uMsgnSgM1cddCv0k2HetlR7tmSW dMK0INFBC/6BYA96ma/TWBzi12ko73Ms7AvKn3DBoSo2GKTkxV8eUs9d/E/AdwOxbF7M BlnHMRF4n8bsBs3PWjDWAg6gwrohyUCousTGzV8xSClNvtVYR7OEsqxm6temcSljJnBz +JLA== X-Gm-Message-State: AGi0PuZeOKkoi5OKG1NChAMM+iblLCOr78OsynUelxKutjY0pMqw7mzD 04pz9DHv+mjfMgRYR/PJj6iOr3Ql4PoQxtWKe6o= X-Received: by 2002:a25:3555:: with SMTP id c82mr15199015yba.378.1588784761448; Wed, 06 May 2020 10:06:01 -0700 (PDT) Date: Wed, 6 May 2020 10:05:53 -0700 In-Reply-To: Message-Id: <20200506170554.54635-1-ndesaulniers@google.com> Mime-Version: 1.0 References: X-Mailer: git-send-email 2.26.2.526.g744177e7f7-goog Subject: [PATCH v2] x86: bitops: fix build regression From: Nick Desaulniers To: Thomas Gleixner , Ingo Molnar , Borislav Petkov Cc: Ilie Halip , Jesse Brandeburg , Sedat Dilek , "kernelci . org bot" , Andy Shevchenko , Nathan Chancellor , Nick Desaulniers , x86@kernel.org, "H. Peter Anvin" , Marco Elver , "Paul E. McKenney" , Michael Ellerman , Masahiro Yamada , Daniel Axtens , 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 From: Ilie Halip It turns out that if your config tickles __builtin_constant_p via differences in choices to inline or not, this now produces 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' The "q" constraint only has meanting on -m32 otherwise is treated as "r". This is easily reproducible via Clang+CONFIG_STAGING=y+CONFIG_VT6656=m. Without the cast to u8, gcc and clang will not select low-8-bit registers required for the `b` suffix on `orb` and `andb`, which results in an assembler error. Without the mask, sparse will warn about the upper bytes of the value being truncated. [Nick: reworded] Cc: Jesse Brandeburg Link: https://github.com/ClangBuiltLinux/linux/issues/961 Link: https://lore.kernel.org/lkml/20200504193524.GA221287@google.com/ 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: Ilie Halip Tested-by: Sedat Dilek Tested-by: Nathan Chancellor Reviewed-by: Nathan Chancellor Signed-off-by: Ilie Halip Signed-off-by: Nick Desaulniers --- 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 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/x86/include/asm/bitops.h b/arch/x86/include/asm/bitops.h index b392571c1f1d..139122e5b25b 100644 --- a/arch/x86/include/asm/bitops.h +++ b/arch/x86/include/asm/bitops.h @@ -54,7 +54,7 @@ arch_set_bit(long nr, volatile unsigned long *addr) if (__builtin_constant_p(nr)) { asm volatile(LOCK_PREFIX "orb %1,%0" : CONST_MASK_ADDR(nr, addr) - : "iq" (CONST_MASK(nr) & 0xff) + : "iq" ((u8)(CONST_MASK(nr) & 0xff)) : "memory"); } else { asm volatile(LOCK_PREFIX __ASM_SIZE(bts) " %1,%0" @@ -74,7 +74,7 @@ arch_clear_bit(long nr, volatile unsigned long *addr) if (__builtin_constant_p(nr)) { asm volatile(LOCK_PREFIX "andb %1,%0" : CONST_MASK_ADDR(nr, addr) - : "iq" (CONST_MASK(nr) ^ 0xff)); + : "iq" ((u8)(CONST_MASK(nr) ^ 0xff))); } else { asm volatile(LOCK_PREFIX __ASM_SIZE(btr) " %1,%0" : : RLONG_ADDR(addr), "Ir" (nr) : "memory"); -- 2.26.2.526.g744177e7f7-goog