Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp1123068ybj; Thu, 7 May 2020 15:33:56 -0700 (PDT) X-Google-Smtp-Source: APiQypL0OioWn8+cQIRnNmHD1sx/TnySkX7cPv7bHDhhODo51dQGczuTG+JPARWASdhA/pXjYvWk X-Received: by 2002:a50:ba83:: with SMTP id x3mr13542713ede.193.1588890835804; Thu, 07 May 2020 15:33:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588890835; cv=none; d=google.com; s=arc-20160816; b=iWM10PZqaPveyjdcS8yJRRTc8RWaGHks3U0u4ifdrJhRgCSB21n4C5asz0J1b1/qv0 7Olctb25ZRFIwhMkM3/JQvPqwYsZTLLI3c8HvysZ2DP6DiD8VGNMOxlHo8J3hl7w7lbI iky72+vO2IhjjfAJVWWSaPNxRWPuOFOECblT9zYpXChqcpuSziAXxIkdi1AbYI6satST d3oEevQFgR1hd1cS25CXi9IP74Jn6mYj5jSPCPZnJsX39Zl+RRAW6tlCYd60De3qV+ez CBkx8BR4wdcGwINhl9eSN+ReiW8pxQIGguqYhao3R3yVgp5bfegzMQcfH7Z9D7gqnXF6 ilaw== 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=XBVohqdeB+6SWxRGmmFJuyeMSq6V5Fxg2K5EHMfRPbg=; b=RZQYePmTFvaq8H4c4L8Mwfi5mEr31o705k1VHiMY+TS92Kz1AF8NjtPle733GYH4O6 bWQLxSPZzBEJJKnfR85Sfy5S4PEePg5FyMoVhg0yJ94IzbPQZzYtvxkTTmHmxnjS40yG 6KE9Gp3udn+V+K4dQeCXf/G8Dstm8aleubYWVjTRBpK6nPKl8qKJpISMogiRuhefK0ZG 37+nrKfocP0VglzVEEjFFCyAepKggTdgeBcoLIOHie5hLzmoC2X5x2X00MppF7R1pevc aRDsactUFrTauIijLBb1rs/uQONptFlQUuEhtVCU8XmX0v8MLirJIvOJWfLwXa1B5s3y YxJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="SVUtOgJ/"; 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 o12si3999551edv.257.2020.05.07.15.33.30; Thu, 07 May 2020 15:33: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="SVUtOgJ/"; 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 S1726750AbgEGW3t (ORCPT + 99 others); Thu, 7 May 2020 18:29:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39440 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726437AbgEGW3s (ORCPT ); Thu, 7 May 2020 18:29:48 -0400 Received: from mail-pl1-x642.google.com (mail-pl1-x642.google.com [IPv6:2607:f8b0:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A02D2C05BD43 for ; Thu, 7 May 2020 15:29:48 -0700 (PDT) Received: by mail-pl1-x642.google.com with SMTP id x10so2669011plr.4 for ; Thu, 07 May 2020 15:29:48 -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=XBVohqdeB+6SWxRGmmFJuyeMSq6V5Fxg2K5EHMfRPbg=; b=SVUtOgJ/cbUQqk9bkdROMWL4W5JPsDsiMZDZf8AsZ1frUJ8JhyuudTUE8rWn529fjt zBBBhj1sr+5Ac5H+SEfGbO6TcoE3arpFO1nWFhp/k5r9b0JIc3JY5ADF0/roHkioIe8w 5kiQJQkIUWgxXIQADgZFJyqwB4E/hAKXXyBYpT8twbgfwkNGMUnAV3pChZC9RXia55oa biM+bv7h3CAtQj81S3lvq6TpHuMIIqGfdYCkWhpm7CDU9idd7SWS6Jp2DqPT2v1C6PMx o8FjWzNlv6hP4GhvRpSu5UD3x1e6dQlLc2qO4LBvMIqUGS+AV5eapsn2T9JAr9hgmaDS yN6A== 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=XBVohqdeB+6SWxRGmmFJuyeMSq6V5Fxg2K5EHMfRPbg=; b=BA64SEOGSnZ/mAtX2qC072YwcEjsPiEYSCxIkqXaZSKx9FD+fUcf+Gudhx6k50lgOT ATlSi1FGqm6+kzQ2nqv59rH+Jf/uYp9qXT6py8NQ0AZTyMl9jrpZVaO39s90ytcRN1/6 SHyiwxA58os/wKQzZpBZWk/g9GoIsZpz42jw1Fp0tEbIWKzyfShBHb8zL5lK7WmHcS91 ir+mgDCwEgUMNN4aGR82Fx2ISyQ/ESKXztuEdC80Cyod5OdV9XfKwBacIbaH9TrDGDHg KyvM5FfqdArD8PjyXMrvqgyrx1hvF22kOqBJ0hiPqTtX2NqPa6CwZB/3JhOvf3TV59aZ XnVA== X-Gm-Message-State: AGi0Puaw8XBXWtxeJ31YGw8DVKC8WaTzB0irVxiL3zjWBeWg0Qv6Fuv6 l+8RExy8W4T0noW/INQEgiL1ZPDsu113A7NHd0oSxg== X-Received: by 2002:a17:90a:6d03:: with SMTP id z3mr2573417pjj.32.1588890587535; Thu, 07 May 2020 15:29:47 -0700 (PDT) MIME-Version: 1.0 References: <20200505174423.199985-1-ndesaulniers@google.com> <8A776DBC-03AF-485B-9AA6-5920E3C4ACB2@zytor.com> <20200507113422.GA3762@hirez.programming.kicks-ass.net> In-Reply-To: From: Nick Desaulniers Date: Thu, 7 May 2020 15:29:35 -0700 Message-ID: Subject: Re: [PATCH] x86: bitops: fix build regression To: Brian Gerst Cc: Peter Zijlstra , "H. Peter Anvin" , 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" , Daniel Axtens , Masahiro Yamada , Luc Van Oostenryck , 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 Thu, May 7, 2020 at 12:19 PM Nick Desaulniers wrote: > > On Thu, May 7, 2020 at 7:00 AM Brian Gerst wrote: > > > > This change will make sparse happy and allow these cleanups: > > #define CONST_MASK(nr) ((u8)1 << ((nr) & 7)) > > yep, this is more elegant, IMO. Will send a v3 later with this > change. Looking at the uses of CONST_MASK, I noticed > arch_change_bit() currently has the (u8) cast from commit > 838e8bb71dc0c ("x86: Implement change_bit with immediate operand as > "lock xorb""), so that instance can get cleaned up with the above > suggestion. Oh, we need the cast to be the final operation. The binary AND and XOR in 2 of the 3 uses of CONST_MASK implicitly promote the operands of the binary operand to int, so the type of the evaluated subexpression is int. https://wiki.sei.cmu.edu/confluence/display/c/EXP14-C.+Beware+of+integer+promotion+when+performing+bitwise+operations+on+integer+types+smaller+than+int So I think this version (v2) is most precise fix, and would be better than defining more macros or (worse) using metaprogramming. -- Thanks, ~Nick Desaulniers