Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp230982ybj; Fri, 8 May 2020 10:24:10 -0700 (PDT) X-Google-Smtp-Source: APiQypIWEkJ7MIEvx2SQQJmEvocQ1wTifwUbxX2q6zlXEtGwfXS8oyDHCBcCWnVhIF7x31f3Mmbo X-Received: by 2002:aa7:d0c2:: with SMTP id u2mr3214606edo.78.1588958649871; Fri, 08 May 2020 10:24:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588958649; cv=none; d=google.com; s=arc-20160816; b=O0VI0LxKfmhQ4NmkLwfVOLjbx9YQeYbgz+nXlM8kcR29NAmiJAYXS4giGa7AhtNujG o7Nw7dMvPIRG2pKrZj6EVL/Xr0xN1QwKNcVvvlRG+gsSzj3laHAbZKUwojuVENtDtWtV fSnq7cExUNMvGMClM+r4yFwMewGb3ayGiPupljTpOfQhckiwSdC6LcIszj9aqgm7mCzR Oj51JoWmOIEYWvvtP9fTzYUYa9z6ufD1Ar4Y/Som4gpb9Km7F5iLyzmnA9Zl8Ddu4zZh H1cuo4l98fUU7/RCkYfbHULnbGNWeZ9wN279MnnZsR/EgxMX39VU/z7YCtDFXWUpZkVu qIIA== 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=FDmOxQMCuaw5F6/Weoldmrv8lAutINkccOcvV//08Lo=; b=GTd6u9SjUfjIgFioSt+taBw5mhj3GhPmovKGbeYAgauxufwFAjLtY9GTMv+9+A3lf6 2Kj88HYVefF1Tg59cBMOTONjHxUemOFNVKZIEhxjG9Dg6fKH8r9os4kZ6smsysYpxJsU F5v9Ne1kfdU1LEckvU629AkYbvdwKBBc9S2LFijXuBAeTnmW8K30c4YSXkqvuHLlQQzo Y6933Ept+5s37haDcKaVGhVMnJXOWeXWiCFHWuOHH171xnVv2jqX6NY4aJRc/7x5toOi nOwrnBA1JeWDhX8JijLarHBTa9Sgon5P8xLbnUOiZ1qFq9CBGjH0naDRz+pojzFmIbqV 7AHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=uz6CQxh4; 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 a24si1311849edy.1.2020.05.08.10.23.46; Fri, 08 May 2020 10:24:09 -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=uz6CQxh4; 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 S1727788AbgEHRWB (ORCPT + 99 others); Fri, 8 May 2020 13:22:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46602 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727083AbgEHRWA (ORCPT ); Fri, 8 May 2020 13:22:00 -0400 Received: from mail-pj1-x1041.google.com (mail-pj1-x1041.google.com [IPv6:2607:f8b0:4864:20::1041]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D5412C05BD43 for ; Fri, 8 May 2020 10:22:00 -0700 (PDT) Received: by mail-pj1-x1041.google.com with SMTP id t9so4630008pjw.0 for ; Fri, 08 May 2020 10:22:00 -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=FDmOxQMCuaw5F6/Weoldmrv8lAutINkccOcvV//08Lo=; b=uz6CQxh4gx44MIkOb4uoPsulQcoadM4lvLN8PW4twq6GXEyiBPwb4BpfSqGisSWHU8 KgUz23Sy4OHg4McVtDGkn1shgfffYfuSoTyYAp3cSjJqjMzB/uChi69dqKS3z0+CIhSX DpqZWBMvLuY6Yy9OqKHgQOFn+0nNEXzJKOl4XRO+5kH9YpeoVN2u+KziL+wT3kg7kobt 8HspgqpP3STPysPB9h+RHLEusRGic/V2t62HNpOYC6ZiqEU3ZLZp0oRdcKkmTrdWrNjD yEU6b7VACRfdgG7SsFhLBl9kmiNt3HJy5MaLxj3VP16jk5qCLTutzRyTzSlcDNAOnAEQ qndw== 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=FDmOxQMCuaw5F6/Weoldmrv8lAutINkccOcvV//08Lo=; b=iIPs3BPt+2rMO1zs0NQyaut7c3l3nG5fJbqEqM3A2w/3EOaPmCYNmRumQ8AAG8mXWO No4kwXP6mq3XyOWMs60JxM6B/w1dFV2B5HlAMVmS83Q4FV31gLpw70uR5WmP4ymc9AJC 551WQwyUJU6pY4woz8PRyMZ8A+L8qSuTd0+lbkE7Wx7cjgI8l7fEvibrfe2jfDa7QZ6n MaZfu+s1CB3ZbkrXPiRgOhvs/CHl2pNmQFuwaWHqWdLmjYUtT6U9rHLTHrXjGuUhHPMo 3HHzGj/8vBj8FSjH7Zgwj614ULQmFXXyexxJdWrv8ayXkiP1WNboIJyKqK24lPpyZFg5 +FSQ== X-Gm-Message-State: AGi0PuaUqBKzCs/IB6ET1McHsWUcWBcf/Db/0o2UmACwevFkxxm+NGsr td3XfjdOfSqu9dl9MzpEZSrupvo/IEfLO3WEu7MvAQ== X-Received: by 2002:a17:90b:2302:: with SMTP id mt2mr3301097pjb.25.1588958519887; Fri, 08 May 2020 10:21:59 -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: Fri, 8 May 2020 10:21:48 -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 6:57 PM Brian Gerst wrote: > > On Thu, May 7, 2020 at 6:29 PM Nick Desaulniers wrote: > > > > 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. > > One last suggestion. Add the "b" modifier to the mask operand: "orb > %b1, %0". That forces the compiler to use the 8-bit register name > instead of trying to deduce the width from the input. Ah right: https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html#x86Operandmodifiers Looks like that works for both compilers. In that case, we can likely drop the `& 0xff`, too. Let me play with that, then I'll hopefully send a v3 today. -- Thanks, ~Nick Desaulniers