From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 73FC3C433ED for ; Thu, 20 May 2021 11:12:59 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 076D060240 for ; Thu, 20 May 2021 11:12:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 076D060240 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=zqMoVeWSB5/U86IEr3wDDsv14IoSwDLtQi45XolAIlQ=; b=TnYxgW3sudhCJckgGnri0gB4xo NsX1bC/W1M9TT9rQvwJqOwI4EOkI/AUhw1bdO7xEajpLQHKGvK4tQZ4XW5/RlyhDNaBvlyI862a6Q bx+B42Pa+1UBRldU+o1Gm0EIP7gFZwofLbyApqz6ZkwJxh/ZUZ6g+z4EBLnGBhOW+ryokBL6inrGh AKRpcmEH05AQap/+J4SvJ0B6biHMqMLN1fBmzR/gOvYTLrYBFA7enj+FtdH2jR3VwkPne4ozKGml7 FArXJn46rZv4abkpOapZeDe3TDSVuRljUwZSZmFL6bu77IvTkV+FN7N4g9Q7xcN6ztDNt+T9frod0 qtarjjcA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ljgaU-000MjO-D9; Thu, 20 May 2021 11:11:35 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ljgaP-000MiD-B6 for linux-arm-kernel@desiato.infradead.org; Thu, 20 May 2021 11:11:29 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=XL4GYwsRffs8PHcjLepWClwZg5M/pooXOUDliw2NS4I=; b=UqEdzoIR6ur1BqHDf1A11yjJW/ tK7XlqqafxOBzl3AO/El7IywY1ZOub4/DOHYZcSwwy//xZHy6MX1uEkeCSGmw5dWuYnamzIRZNkGk rtj4qkzlfm1zueCmVaqb0qtYKINnH83/qKYT7XKI7kND83KHTb0nMYsrWKm/xzDFYDc+A4zG3GYCg 2WKkTzP+DTZvTNnS4DILTf8uzWpFtzcuC8mE5AblsE0O8WyM/fJOxqRKuhQE1Lk1GbBIrJtBd5Ue0 z9Dy5KpMNO7faoaogVCDWa5fjA0QBKmSfiVyJHKH0PycCEBnH6WJs8Zmn/vcWdT4joAnZFk8da6AY t4/VD8ZA==; Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1ljgaM-00GE2k-J5 for linux-arm-kernel@lists.infradead.org; Thu, 20 May 2021 11:11:28 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 4236311D4; Thu, 20 May 2021 04:11:25 -0700 (PDT) Received: from C02TD0UTHF1T.local (unknown [10.57.7.235]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D94AC3F719; Thu, 20 May 2021 04:11:21 -0700 (PDT) Date: Thu, 20 May 2021 12:11:19 +0100 From: Mark Rutland To: Joe Richey Cc: trivial@kernel.org, Joe Richey , Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org, "H. Peter Anvin" , Paolo Bonzini , Lorenzo Pieralisi , Mauro Carvalho Chehab , Zhangfei Gao , Zhou Wang , linux-kernel@vger.kernel.org, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-media@vger.kernel.org, linux-accelerators@lists.ozlabs.org Subject: Re: [PATCH 0/6] Don't use BIT() macro in UAPI headers Message-ID: <20210520111119.GC17233@C02TD0UTHF1T.local> References: <20210520104343.317119-1-joerichey94@gmail.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20210520104343.317119-1-joerichey94@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210520_041126_697200_49BB5D4C X-CRM114-Status: GOOD ( 21.73 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi, On Thu, May 20, 2021 at 03:43:37AM -0700, Joe Richey wrote: > From: Joe Richey > > The BIT(n) macro is used in the kernel as an alias for (1 << n). > However, it is not defined in the UAPI headers, which means that any > UAPI header files must be careful not to use it, or else the user > will get a linker error. Beware that the common definition of BIT() (in include/vdso/bits.h) is: | #define BIT(nr) (UL(1) << (nr)) That UL() can be important if `nr` is ever greater than bits per int. > For example, compiling the following program: > > #include > #include > > // Detect if FSGSBASE instructions are enabled > int main() { > unsigned long val = getauxval(AT_HWCAP2); > return !(val & HWCAP2_FSGSBASE); > } > > Results in the following likner error: > > /usr/bin/ld: /tmp/cceFpAdR.o: in function `main': > gs.c:(.text+0x21): undefined reference to `BIT' > > This patch series changes all UAPI uses of BIT() to just be open-coded. In include/uapi/linux/const.h we have an equivaleint _BITUL() macro, which I think should be used in preference of open-coding this (and is already used in a number of uapi headers). > However, there really should be a check for this in checkpatch.pl > Currently, the script actually _encourages_ users to use the BIT macro > even if adding things to UAPI. I think having something that suggests s/BIT()/_BITUL()/ under uapi would be good. Thanks, Mark. > > Running `rg "BIT\(" **/uapi/**` shows no more usage of BIT() in any > UAPI headers. Tested by building a basic kernel. Changes are trivial. > > Joe Richey (6): > x86/elf: Don't use BIT() macro in UAPI headers > KVM: X86: Don't use BIT() macro in UAPI headers > drivers: firmware: psci: Don't use BIT() macro in UAPI headers > uacce: Don't use BIT() macro in UAPI headers > media: vicodec: Don't use BIT() macro in UAPI headers > tools headers UAPI: Sync pkt_sched.h with the kernel sources > > arch/x86/include/uapi/asm/hwcap2.h | 2 +- > include/uapi/linux/kvm.h | 4 +- > include/uapi/linux/psci.h | 2 +- > include/uapi/linux/v4l2-controls.h | 22 ++--- > include/uapi/misc/uacce/uacce.h | 2 +- > tools/include/uapi/linux/kvm.h | 4 +- > tools/include/uapi/linux/pkt_sched.h | 122 ++++++++++++++++++++++++--- > 7 files changed, 130 insertions(+), 28 deletions(-) > > -- > 2.31.1 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel