All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/6] Don't use BIT() macro in UAPI headers
@ 2021-05-20 10:43 ` Joe Richey
  0 siblings, 0 replies; 63+ messages in thread
From: Joe Richey @ 2021-05-20 10:43 UTC (permalink / raw)
  To: trivial
  Cc: Joe Richey, Thomas Gleixner, Ingo Molnar, Borislav Petkov, x86,
	H. Peter Anvin, Paolo Bonzini, Mark Rutland, Lorenzo Pieralisi,
	Mauro Carvalho Chehab, Zhangfei Gao, Zhou Wang, linux-kernel,
	kvm, linux-arm-kernel, linux-media, linux-accelerators

From: Joe Richey <joerichey@google.com>

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

-- 
2.31.1


^ permalink raw reply	[flat|nested] 63+ messages in thread

end of thread, other threads:[~2021-05-25  1:36 UTC | newest]

Thread overview: 63+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-20 10:43 [PATCH 0/6] Don't use BIT() macro in UAPI headers Joe Richey
2021-05-20 10:43 ` Joe Richey
2021-05-20 10:43 ` [PATCH 1/6] x86/elf: " Joe Richey
2021-05-20 10:43   ` Joe Richey
2021-05-20 10:43 ` [PATCH 2/6] KVM: X86: " Joe Richey
2021-05-20 10:43   ` Joe Richey
2021-05-20 15:46   ` Sean Christopherson
2021-05-20 15:46     ` Sean Christopherson
2021-05-20 10:43 ` [PATCH 3/6] drivers: firmware: psci: " Joe Richey
2021-05-20 10:43   ` Joe Richey
2021-05-20 10:43 ` [PATCH 4/6] uacce: " Joe Richey
2021-05-20 10:43   ` Joe Richey
2021-05-20 10:43 ` [PATCH 5/6] media: vicodec: " Joe Richey
2021-05-20 10:43   ` Joe Richey
2021-05-20 10:43 ` [PATCH 6/6] tools headers UAPI: Sync pkt_sched.h with the kernel sources Joe Richey
2021-05-20 10:43   ` Joe Richey
2021-05-20 11:07 ` [PATCH 0/6] Don't use BIT() macro in UAPI headers Borislav Petkov
2021-05-20 11:07   ` Borislav Petkov
2021-05-20 11:50   ` Joseph Richey
2021-05-20 11:50     ` Joseph Richey
2021-05-20 15:59     ` Borislav Petkov
2021-05-20 15:59       ` Borislav Petkov
2021-05-20 15:50   ` Sean Christopherson
2021-05-20 15:50     ` Sean Christopherson
2021-05-20 11:11 ` Mark Rutland
2021-05-20 11:11   ` Mark Rutland
2021-05-20 11:40   ` Joseph Richey
2021-05-20 11:40     ` Joseph Richey
2021-05-20 12:09 ` Paolo Bonzini
2021-05-20 12:09   ` Paolo Bonzini
2021-05-20 15:47 ` Sean Christopherson
2021-05-20 15:47   ` Sean Christopherson
2021-05-21  8:58 ` [PATCH v2 0/7] " Joe Richey
2021-05-21  8:58   ` Joe Richey
2021-05-21  8:58   ` [PATCH v2 1/7] x86/elf: Use _BITUL() " Joe Richey
2021-05-21  8:58     ` Joe Richey
2021-05-21  9:25     ` [tip: x86/misc] " tip-bot2 for Joe Richey
2021-05-21  8:58   ` [PATCH v2 2/7] KVM: X86: " Joe Richey
2021-05-21  8:58     ` Joe Richey
2021-05-24 12:28     ` Paolo Bonzini
2021-05-24 12:28       ` Paolo Bonzini
2021-05-21  8:58   ` [PATCH v2 3/7] drivers: firmware: psci: " Joe Richey
2021-05-21  8:58     ` Joe Richey
2021-05-21 13:25     ` Mark Rutland
2021-05-21 13:25       ` Mark Rutland
2021-05-21  8:58   ` [PATCH v2 4/7] uacce: " Joe Richey
2021-05-21  8:58     ` Joe Richey
2021-05-21 13:56     ` Zhangfei Gao
2021-05-21 13:56       ` Zhangfei Gao
2021-05-21  8:58   ` [PATCH v2 5/7] media: vicodec: " Joe Richey
2021-05-21  8:58     ` Joe Richey
2021-05-21  8:58   ` [PATCH v2 6/7] tools headers UAPI: Sync pkt_sched.h with the kernel sources Joe Richey
2021-05-21  8:58     ` Joe Richey
2021-05-21  8:58   ` [PATCH v2 7/7] checkpatch: suggest _BITULL() and _BITUL() for UAPI headers Joe Richey
2021-05-21  8:58     ` Joe Richey
2021-05-21 14:45     ` Joe Perches
2021-05-21 14:45       ` Joe Perches
2021-05-24 11:46 ` [PATCH 0/6] Don't use BIT() macro in " Christoph Hellwig
2021-05-24 11:46   ` Christoph Hellwig
2021-05-24 12:29   ` Mark Rutland
2021-05-24 12:29     ` Mark Rutland
2021-05-24 16:34     ` David Laight
2021-05-24 16:34       ` David Laight

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.