[PATCH] D93103: Enable the _ExtInt extension on the BPF Target

Yonghong Song via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Dec 16 12:50:28 PST 2020


yonghong-song added a comment.

We could enable ExtIntType in bpf backend. But we need some kernel changes related to BTF to accommodate the new types.
Currently, the kernel uapi file (linux/include/uapi/linux/btf.h) defines

  #define BTF_INT_BITS(VAL)       ((VAL)  & 0x000000ff)

which means the maximum permitted number of bits for int type is 255.

Here, we try to define an int type 256 which will not fit in the BTF. Currently llvm can encode 256 in BTF as the last 4 bytes are available and llvm did not do strict checking.
But kernel will reject it. Based on available bits, the maximum allowed bits are

  #define BTF_INT_BITS(VAL)       ((VAL)  & 0x0000ffff)

But I do not think we need that big range, maybe

  #define BTF_INT_BITS(VAL)       ((VAL)  & 0x000003ff)

which encode up to 512 bit integer (for power-of-2)? Do you have an use case for even bigger number of int?

Anyway, in parallel to this llvm patch, you need to have kernel change to accept such ext int's, the following are main changes in kernel:

- extend the above uapi to allow more bits in int type.
- make sure btf pretty print can work properly with these big ints, it can handle __int128 (in both kernel and bpftool), you will need to extend to make it generic to handler 128/192/256/... bytes, I think.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D93103/new/

https://reviews.llvm.org/D93103



More information about the cfe-commits mailing list