Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp737597ybj; Thu, 7 May 2020 06:35:05 -0700 (PDT) X-Google-Smtp-Source: APiQypKsxNNOsSrZF2HOFwWYDVmR3pGs9vzoOAW2x6VSgjKCsgN+H9eTBIa2ysu4r6Pl/lEdFGKI X-Received: by 2002:a05:6402:22ed:: with SMTP id dn13mr11649627edb.212.1588858505771; Thu, 07 May 2020 06:35:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588858505; cv=none; d=google.com; s=arc-20160816; b=EoCKMk8FwK51sV41wk+h2NpTb8spSFfVkfMUnCgvBOiSYgREIPs9vQIHWS+PkI7S1+ hB4ff3rLd1M8VP6Rqau8EKaBpVcGrpZHLU2PT7Y8/DN7UGpJWKaGVPfpSq+oKrwHnZq2 NDkloJB0Ltsw/gkACU363Yl8YjiyQ6EssPaijNfGuzcwVD2L+tj1Pbg+pnZWy5E86J+/ 7GHf//IwXSMxND9fNrcxix3GFBykp4WeAoZ88x2hPI7o0Xy2LXJYmsygRr2Sm+kNZQQn 63Cz6jC8grwweEk9gOc950NfoiLX/mqXbMcSr+IVuHYdx+jwM5WEZrSPsK6GH2YvLVWV hjpQ== 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=IWNT0grjCY4sGAusEiDjhM/Qhpke9FBN+ida4mrV6O0=; b=bvyHpf9vub9appM3t8iCM60yF3R9ptzvv63V0MDz7f7uBVkVZ1Ndi9pQ2eiv+mQVOd xarHV0XdmqmVtjRtphI+tBphuMaiKX4NifCN8mmeznDAGGinJIcOtZGTTokbF0JjqX2Q k1HhLqXzBMGJAUgf9gS7dT8f2EswbInouN+vKtsin/zV9Pckv8b+6EN78hq7yz62jtwK Zcp0VZVHLxAWd83wMASRwOC1isEfbUpZch2QaFHALAR7RS0amRPDtyjKYTR3ECXZi0th EULHqn68NkuTgPHFQECbShOhDMwiCS8jRSunC6uFReYcGVamy7aE8f8eeDSxWsscqSsZ bJXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=cK5Jj4DL; 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 i10si3191822ejc.284.2020.05.07.06.34.38; Thu, 07 May 2020 06:35:05 -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=cK5Jj4DL; 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 S1726491AbgEGNcj (ORCPT + 99 others); Thu, 7 May 2020 09:32:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1725848AbgEGNch (ORCPT ); Thu, 7 May 2020 09:32:37 -0400 Received: from mail-io1-xd42.google.com (mail-io1-xd42.google.com [IPv6:2607:f8b0:4864:20::d42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BC7A2C05BD43; Thu, 7 May 2020 06:32:37 -0700 (PDT) Received: by mail-io1-xd42.google.com with SMTP id 19so454755ioz.10; Thu, 07 May 2020 06:32:37 -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=IWNT0grjCY4sGAusEiDjhM/Qhpke9FBN+ida4mrV6O0=; b=cK5Jj4DLgzKQcXk2KuajxjCOogoztYExUvzMIIBEZmHQsdfJxe0mhLJuderGZR8ucu JfAHoC1OoXxpuWwsy5afVZB/dLh92gN01aasrHoRyJJ1ZmD8+3Q3JnLkqtNzjoduOrEv Wk6lkpBhKTthGUcxXcYO6RvwKBQ3bQdK7Uhthl9D1/9ClA2VbzmALiQS77JEqxKARK+H MjQBY6v1Ic8GyMLPbUQcD0UYzroJgI9rpUkERaZZhADvtEKKcBXo6cpZhMCmNMVKEqEH x26OyvQlgvDDdt77/bfWT8ZQW7e3PMC3EKSFa5MgSaa606Kb3hyrIoWxapnxqGwh3OaM s7kQ== 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=IWNT0grjCY4sGAusEiDjhM/Qhpke9FBN+ida4mrV6O0=; b=iwqaREHAmU1XdmsjthOJacxeb+AmUktYOiVyQKIdIvpSWoQNtu5rIwLG0/w1i4R5LU tD6wi9mYkuSLN8nmzUoMJ2rKVgf122P5eR/eA4drtkZh9GMaGkkzBbxDEMFZoTUMWh5Q /MaqLOZmPEUQhhNJu7tqoLv4qNESrvAHPGFZyeviai4yvpV9/ennGuQxVut4lZ3Emzp+ tb8JubdkNPD8pHO4k9Y+pj1PloDiVC/PwcSAsAdvO4z6jbqhzT3aI8oA1xVW92WIYgVJ 7VFu88dB3eChTQaQlnOWH2qeUk/H5aaUXBHPJfOkO1FriOWHItAPiW4VgnvXCnzKWigR dYBQ== X-Gm-Message-State: AGi0PuaDd8PNShVFECH1/ywM10ivBGK9DP0U8qeyYFTHOGlhK69/xaCr W1c5ySgWvUNTkv5YL1sop2Ab//hBhJPwMKOq7g== X-Received: by 2002:a05:6638:f0f:: with SMTP id h15mr14334812jas.142.1588858355459; Thu, 07 May 2020 06:32:35 -0700 (PDT) MIME-Version: 1.0 References: <20200505174423.199985-1-ndesaulniers@google.com> <6A99766A-59FB-42DF-9350-80EA671A42B0@zytor.com> In-Reply-To: <6A99766A-59FB-42DF-9350-80EA671A42B0@zytor.com> From: Brian Gerst Date: Thu, 7 May 2020 09:32:24 -0400 Message-ID: Subject: Re: [PATCH] x86: bitops: fix build regression To: "H. Peter Anvin" Cc: Nick Desaulniers , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Sedat Dilek , stable , Jesse Brandeburg , "kernelci . org bot" , Andy Shevchenko , Ilie Halip , "the arch/x86 maintainers" , Marco Elver , "Paul E. McKenney" , "Peter Zijlstra (Intel)" , Daniel Axtens , Masahiro Yamada , Luc Van Oostenryck , Linux Kernel Mailing List , 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 On Thu, May 7, 2020 at 3:02 AM wrote: > > On May 6, 2020 11:18:09 PM PDT, Brian Gerst wrote: > >On Tue, May 5, 2020 at 1:47 PM Nick Desaulniers > > wrote: > >> > >> From: Sedat Dilek > >> > >> 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, > >> or Clang+allyesconfig. > >> > >> Keep the masking operation to appease sparse (`make C=1`), add back > >the > >> cast in order to properly select the proper 8b register alias. > >> > >> [Nick: reworded] > >> > >> Cc: stable@vger.kernel.org > >> 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 > >> Signed-off-by: Sedat Dilek > >> Signed-off-by: Nick Desaulniers > >> --- > >> 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)) > > > >I think a better fix would be to make CONST_MASK() return a u8 value > >rather than have to cast on every use. > > > >Also I question the need for the "q" constraint. It was added in > >commit 437a0a54 as a workaround for GCC 3.4.4. Now that the minimum > >GCC version is 4.6, is this still necessary? > > > >-- > >Brian Gerst > > Yes, "q" is needed on i386. I think the bug this worked around was that the compiler didn't detect that CONST_MASK(nr) was also constant and doesn't need to be put into a register. The question is does that bug still exist on compiler versions we care about? -- Brian Gerst