Lines Matching +full:uapi +full:- +full:header
1 .. SPDX-License-Identifier: GPL-2.0-only
4 UAPI Checker
7 The UAPI checker (``scripts/check-uapi.sh``) is a shell script which
8 checks UAPI header files for userspace backwards-compatibility across
14 This section will describe the options with which ``check-uapi.sh``
19 check-uapi.sh [-b BASE_REF] [-p PAST_REF] [-j N] [-l ERROR_LOG] [-i] [-q] [-v]
23 -b BASE_REF Base git reference to use for comparison. If unspecified or empty,
24 will use any dirty changes in tree to UAPI files. If there are no
26 -p PAST_REF Compare BASE_REF to PAST_REF (e.g. -p v6.1). If unspecified or empty,
29 -j JOBS Number of checks to run in parallel (default: number of CPU cores).
30 -l ERROR_LOG Write error log to file (default: no error log is generated).
31 -i Ignore ambiguous changes that may or may not break UAPI compatibility.
32 -q Quiet operation.
33 -v Verbose operation (print more information about each header being checked).
51 -----------
53 First, let's try making a change to a UAPI header file that obviously
56 cat << 'EOF' | patch -l -p1
57 --- a/include/uapi/linux/acct.h
58 +++ b/include/uapi/linux/acct.h
59 @@ -21,7 +21,9 @@
63 -/*
67 * comp_t is a 16-bit "floating" point number with a 3-bit base 8
68 * exponent and a 13-bit fraction.
69 * comp2_t is 24-bit with 5-bit base 2 exponent and 20 bit fraction
70 diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h
75 % ./scripts/check-uapi.sh
76 Installing user-facing UAPI headers from dirty tree... OK
77 Installing user-facing UAPI headers from HEAD... OK
78 Checking changes to UAPI headers between HEAD and dirty tree...
79 All 912 UAPI headers compatible with x86 appear to be backwards compatible
83 cat << 'EOF' | patch -l -p1
84 --- a/include/uapi/linux/bpf.h
85 +++ b/include/uapi/linux/bpf.h
86 @@ -74,7 +74,7 @@ struct bpf_insn {
90 - __s32 imm; /* signed immediate constant */
99 % ./scripts/check-uapi.sh
100 Installing user-facing UAPI headers from dirty tree... OK
101 Installing user-facing UAPI headers from HEAD... OK
102 Checking changes to UAPI headers between HEAD and dirty tree...
103 ==== ABI differences detected in include/linux/bpf.h from HEAD -> dirty tree ====
108 typedef name changed from __s32 to __u32 at int-ll64.h:27:1
114 error - 1/912 UAPI headers compatible with x86 appear _not_ to be backwards compatible
120 anything. You can pass the ``-i`` flag to the script to ignore changes
123 % ./scripts/check-uapi.sh -i
124 Installing user-facing UAPI headers from dirty tree... OK
125 Installing user-facing UAPI headers from HEAD... OK
126 Checking changes to UAPI headers between HEAD and dirty tree...
127 All 912 UAPI headers compatible with x86 appear to be backwards compatible
131 cat << 'EOF' | patch -l -p1
132 --- a/include/uapi/linux/bpf.h
133 +++ b/include/uapi/linux/bpf.h
134 @@ -71,8 +71,8 @@ enum {
138 - __u8 dst_reg:4; /* dest register */
146 Since we're re-ordering an existing struct member, there's no ambiguity,
147 and the script will report the breakage even if you pass ``-i``::
149 % ./scripts/check-uapi.sh -i
150 Installing user-facing UAPI headers from dirty tree... OK
151 Installing user-facing UAPI headers from HEAD... OK
152 Checking changes to UAPI headers between HEAD and dirty tree...
153 ==== ABI differences detected in include/linux/bpf.h from HEAD -> dirty tree ====
158 '__u8 src_reg' offset changed from 12 to 8 (in bits) (by -4 bits)
161 error - 1/912 UAPI headers compatible with x86 appear _not_ to be backwards compatible
165 % git commit -m 'Breaking UAPI change' include/uapi/linux/bpf.h
166 [detached HEAD f758e574663a] Breaking UAPI change
167 1 file changed, 1 insertion(+), 1 deletion(-)
168 % git commit -m 'Innocuous UAPI change' include/uapi/linux/acct.h
169 [detached HEAD 2e87df769081] Innocuous UAPI change
170 1 file changed, 3 insertions(+), 1 deletion(-)
174 % ./scripts/check-uapi.sh
175 Installing user-facing UAPI headers from HEAD... OK
176 Installing user-facing UAPI headers from HEAD^1... OK
177 Checking changes to UAPI headers between HEAD^1 and HEAD...
178 All 912 UAPI headers compatible with x86 appear to be backwards compatible
183 use the ``-p`` option to pass a different past reference. In this case,
184 let's pass ``-p HEAD~2`` to the script so it checks UAPI changes between
187 % ./scripts/check-uapi.sh -p HEAD~2
188 Installing user-facing UAPI headers from HEAD... OK
189 Installing user-facing UAPI headers from HEAD~2... OK
190 Checking changes to UAPI headers between HEAD~2 and HEAD...
191 ==== ABI differences detected in include/linux/bpf.h from HEAD~2 -> HEAD ====
196 '__u8 src_reg' offset changed from 12 to 8 (in bits) (by -4 bits)
199 error - 1/912 UAPI headers compatible with x86 appear _not_ to be backwards compatible
201 Alternatively, we could have also run with ``-b HEAD~``. This would set the
204 Architecture-specific Headers
205 -----------------------------
209 cat << 'EOF' | patch -l -p1
210 --- a/arch/arm64/include/uapi/asm/sigcontext.h
211 +++ b/arch/arm64/include/uapi/asm/sigcontext.h
212 @@ -70,6 +70,7 @@ struct sigcontext {
222 This is a change to an arm64-specific UAPI header file. In this example, I'm
224 the script only checks x86-compatible UAPI header files::
226 % ./scripts/check-uapi.sh
227 Installing user-facing UAPI headers from dirty tree... OK
228 Installing user-facing UAPI headers from HEAD... OK
229 No changes to UAPI headers were applied between HEAD and dirty tree
231 With an x86 compiler, we can't check header files in ``arch/arm64``, so the
234 If we want to check the header file, we'll have to use an arm64 compiler and
237 % CC=aarch64-linux-gnu-gcc ARCH=arm64 ./scripts/check-uapi.sh
238 Installing user-facing UAPI headers from dirty tree... OK
239 Installing user-facing UAPI headers from HEAD... OK
240 Checking changes to UAPI headers between HEAD and dirty tree...
241 ==== ABI differences detected in include/asm/sigcontext.h from HEAD -> dirty tree ====
246 -- snip --
254 error - 1/884 UAPI headers compatible with arm64 appear _not_ to be backwards compatible
257 change is reported properly. Also notice that the total number of UAPI
258 header files checked by the script changes. This is because the number
261 Cross-Dependency Breakages
262 --------------------------
266 cat << 'EOF' | patch -l -p1
267 --- a/include/uapi/linux/types.h
268 +++ b/include/uapi/linux/types.h
269 @@ -52,7 +52,7 @@ typedef __u32 __bitwise __wsum;
273 -typedef unsigned __bitwise __poll_t;
281 a UAPI in ``types.h``, but other UAPIs in the tree may break due to
284 % ./scripts/check-uapi.sh
285 Installing user-facing UAPI headers from dirty tree... OK
286 Installing user-facing UAPI headers from HEAD... OK
287 Checking changes to UAPI headers between HEAD and dirty tree...
288 ==== ABI differences detected in include/linux/eventpoll.h from HEAD -> dirty tree ====
296 '__u64 data' offset changed from 32 to 16 (in bits) (by -16 bits)
303 Note that the script noticed the failing header file did not change,
307 UAPI Header Removals
308 --------------------
312 cat << 'EOF' | patch -l -p1
313 diff --git a/include/uapi/asm-generic/Kbuild b/include/uapi/asm-generic/Kbuild
315 --- a/include/uapi/asm-generic/Kbuild
316 +++ b/include/uapi/asm-generic/Kbuild
317 @@ -31,6 +31,6 @@ mandatory-y += stat.h
318 mandatory-y += statfs.h
319 mandatory-y += swab.h
320 mandatory-y += termbits.h
321 -mandatory-y += termios.h
322 +#mandatory-y += termios.h
323 mandatory-y += types.h
324 mandatory-y += unistd.h
327 This script removes a UAPI header file from the install list. Let's run
330 % ./scripts/check-uapi.sh
331 Installing user-facing UAPI headers from dirty tree... OK
332 Installing user-facing UAPI headers from HEAD... OK
333 Checking changes to UAPI headers between HEAD and dirty tree...
334 ==== UAPI header include/asm/termios.h was removed between HEAD and dirty tree ====
336 error - 1/912 UAPI headers compatible with x86 appear _not_ to be backwards compatible
338 Removing a UAPI header is considered a breaking change, and the script
341 Checking Historic UAPI Compatibility
342 ------------------------------------
344 You can use the ``-b`` and ``-p`` options to examine different chunks of your
345 git tree. For example, to check all changed UAPI header files between tags
348 % ./scripts/check-uapi.sh -b v6.1 -p v6.0
349 Installing user-facing UAPI headers from v6.1... OK
350 Installing user-facing UAPI headers from v6.0... OK
351 Checking changes to UAPI headers between v6.0 and v6.1...
353 --- snip ---
354 error - 37/907 UAPI headers compatible with x86 appear _not_ to be backwards compatible
356 Note: Before v5.3, a header file needed by the script is not present,
359 You'll notice that the script detected many UAPI changes that are not
367 The UAPI checker makes no assumptions about the author's intention, so some
368 types of changes may be flagged even though they intentionally break UAPI.
371 ---------------------------------------
375 % ./scripts/check-uapi.sh -b ba47652ba655
376 Installing user-facing UAPI headers from ba47652ba655... OK
377 Installing user-facing UAPI headers from ba47652ba655^1... OK
378 Checking changes to UAPI headers between ba47652ba655^1 and ba47652ba655...
379 ==== UAPI header include/linux/meye.h was removed between ba47652ba655^1 and ba47652ba655 ====
381 error - 1/910 UAPI headers compatible with x86 appear _not_ to be backwards compatible
386 -----------------
389 expands a struct could be non-breaking.
435 pass ``-i`` to the script, and struct expansions like this will be ignored.
438 --------------------
441 still flag initial migration to flex arrays from 1-element fake flex
446 - __u32 flex[1]; /* fake flex */
464 -------
468 which does not break UAPI. It's also possible a change which *does*
474 maintainers or automated tooling, not as the end-all authority on
476 (and ideally a unit test in userspace) to make sure your UAPI changes
477 are backwards-compatible!