Re: [PATCH 0/6] Don't use BIT() macro in UAPI headers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 20/05/21 12:43, Joe Richey wrote:
From: Joe Richey <joerichey@xxxxxxxxxx>

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. For example, compiling the following program:

     #include <sys/auxv.h>
     #include <asm/hwcap2.h>

     // 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.
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.

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(-)


Will queue the KVM one, thanks!

Paolo




[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux