Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'kbuild-v6.8' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild

Pull Kbuild updates from Masahiro Yamada:

- Make Kconfig parse the input .config more precisely

- Support W=c and W=e options for Kconfig

- Set Kconfig int/hex symbols to zero if the 'default' property is
missing

- Add .editorconfig

- Add scripts/git.orderFile

- Add a script to detect backward-incompatible changes in UAPI headers

- Resolve the symlink passed to O= option properly

- Use the user-supplied mtime for all files in the builtin initramfs,
which provides better reproducible builds

- Fix the direct execution of debian/rules for Debian package builds

- Use build ID instead of the .gnu_debuglink section for the Debian dbg
package

* tag 'kbuild-v6.8' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild: (53 commits)
kbuild: deb-pkg: use debian/<package> for tmpdir
kbuild: deb-pkg: move 'make headers' to build-arch
kbuild: deb-pkg: do not search for 'scripts' directory under arch/
kbuild: deb-pkg: use build ID instead of debug link for dbg package
kbuild: deb-pkg: use more debhelper commands in builddeb
kbuild: deb-pkg: remove unneeded '-f $srctree/Makefile' in debian/rules
kbuild: deb-pkg: allow to run debian/rules from output directory
kbuild: deb-pkg: set DEB_* variables if debian/rules is directly executed
kbuild: deb-pkg: squash scripts/package/deb-build-option to debian/rules
kbuild: deb-pkg: factor out common Make options in debian/rules
kbuild: deb-pkg: hard-code Build-Depends
kbuild: deb-pkg: split debian/copyright from the mkdebian script
gen_init_cpio: Apply mtime supplied by user to all file types
kbuild: resolve symlinks for O= properly
docs: dev-tools: Add UAPI checker documentation
check-uapi: Introduce check-uapi.sh
scripts: Introduce a default git.orderFile
kconfig: WERROR unmet symbol dependency
Add .editorconfig file for basic formatting
kconfig: Use KCONFIG_CONFIG instead of .config
...

+1490 -509
+32
.editorconfig
··· 1 + # SPDX-License-Identifier: GPL-2.0-only 2 + 3 + root = true 4 + 5 + [{*.{awk,c,dts,dtsi,dtso,h,mk,s,S},Kconfig,Makefile,Makefile.*}] 6 + charset = utf-8 7 + end_of_line = lf 8 + trim_trailing_whitespace = true 9 + insert_final_newline = true 10 + indent_style = tab 11 + indent_size = 8 12 + 13 + [*.{json,py,rs}] 14 + charset = utf-8 15 + end_of_line = lf 16 + trim_trailing_whitespace = true 17 + insert_final_newline = true 18 + indent_style = space 19 + indent_size = 4 20 + 21 + # this must be below the general *.py to overwrite it 22 + [tools/{perf,power,rcu,testing/kunit}/**.py,] 23 + indent_style = tab 24 + indent_size = 8 25 + 26 + [*.yaml] 27 + charset = utf-8 28 + end_of_line = lf 29 + trim_trailing_whitespace = unset 30 + insert_final_newline = true 31 + indent_style = space 32 + indent_size = 2
+1
.gitignore
··· 96 96 # 97 97 !.clang-format 98 98 !.cocciconfig 99 + !.editorconfig 99 100 !.get_maintainer.ignore 100 101 !.gitattributes 101 102 !.gitignore
+477
Documentation/dev-tools/checkuapi.rst
··· 1 + .. SPDX-License-Identifier: GPL-2.0-only 2 + 3 + ============ 4 + UAPI Checker 5 + ============ 6 + 7 + The UAPI checker (``scripts/check-uapi.sh``) is a shell script which 8 + checks UAPI header files for userspace backwards-compatibility across 9 + the git tree. 10 + 11 + Options 12 + ======= 13 + 14 + This section will describe the options with which ``check-uapi.sh`` 15 + can be run. 16 + 17 + Usage:: 18 + 19 + check-uapi.sh [-b BASE_REF] [-p PAST_REF] [-j N] [-l ERROR_LOG] [-i] [-q] [-v] 20 + 21 + Available options:: 22 + 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 25 + dirty changes, HEAD will be used. 26 + -p PAST_REF Compare BASE_REF to PAST_REF (e.g. -p v6.1). If unspecified or empty, 27 + will use BASE_REF^1. Must be an ancestor of BASE_REF. Only headers 28 + that exist on PAST_REF will be checked for compatibility. 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). 34 + 35 + Environmental args:: 36 + 37 + ABIDIFF Custom path to abidiff binary 38 + CC C compiler (default is "gcc") 39 + ARCH Target architecture of C compiler (default is host arch) 40 + 41 + Exit codes:: 42 + 43 + 0) Success 44 + 1) ABI difference detected 45 + 2) Prerequisite not met 46 + 47 + Examples 48 + ======== 49 + 50 + Basic Usage 51 + ----------- 52 + 53 + First, let's try making a change to a UAPI header file that obviously 54 + won't break userspace:: 55 + 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 @@ 60 + #include <asm/param.h> 61 + #include <asm/byteorder.h> 62 + 63 + -/* 64 + +#define FOO 65 + + 66 + +/* 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 71 + EOF 72 + 73 + Now, let's use the script to validate:: 74 + 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 80 + 81 + Let's add another change that *might* break userspace:: 82 + 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 { 87 + __u8 dst_reg:4; /* dest register */ 88 + __u8 src_reg:4; /* source register */ 89 + __s16 off; /* signed offset */ 90 + - __s32 imm; /* signed immediate constant */ 91 + + __u32 imm; /* unsigned immediate constant */ 92 + }; 93 + 94 + /* Key of an a BPF_MAP_TYPE_LPM_TRIE entry */ 95 + EOF 96 + 97 + The script will catch this:: 98 + 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 ==== 104 + [C] 'struct bpf_insn' changed: 105 + type size hasn't changed 106 + 1 data member change: 107 + type of '__s32 imm' changed: 108 + typedef name changed from __s32 to __u32 at int-ll64.h:27:1 109 + underlying type 'int' changed: 110 + type name changed from 'int' to 'unsigned int' 111 + type size hasn't changed 112 + ================================================================================== 113 + 114 + error - 1/912 UAPI headers compatible with x86 appear _not_ to be backwards compatible 115 + 116 + In this case, the script is reporting the type change because it could 117 + break a userspace program that passes in a negative number. Now, let's 118 + say you know that no userspace program could possibly be using a negative 119 + value in ``imm``, so changing to an unsigned type there shouldn't hurt 120 + anything. You can pass the ``-i`` flag to the script to ignore changes 121 + in which the userspace backwards compatibility is ambiguous:: 122 + 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 128 + 129 + Now, let's make a similar change that *will* break userspace:: 130 + 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 { 135 + 136 + struct bpf_insn { 137 + __u8 code; /* opcode */ 138 + - __u8 dst_reg:4; /* dest register */ 139 + __u8 src_reg:4; /* source register */ 140 + + __u8 dst_reg:4; /* dest register */ 141 + __s16 off; /* signed offset */ 142 + __s32 imm; /* signed immediate constant */ 143 + }; 144 + EOF 145 + 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``:: 148 + 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 ==== 154 + [C] 'struct bpf_insn' changed: 155 + type size hasn't changed 156 + 2 data member changes: 157 + '__u8 dst_reg' offset changed from 8 to 12 (in bits) (by +4 bits) 158 + '__u8 src_reg' offset changed from 12 to 8 (in bits) (by -4 bits) 159 + ================================================================================== 160 + 161 + error - 1/912 UAPI headers compatible with x86 appear _not_ to be backwards compatible 162 + 163 + Let's commit the breaking change, then commit the innocuous change:: 164 + 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(-) 171 + 172 + Now, let's run the script again with no arguments:: 173 + 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 179 + 180 + It doesn't catch any breaking change because, by default, it only 181 + compares ``HEAD`` to ``HEAD^1``. The breaking change was committed on 182 + ``HEAD~2``. If we wanted the search scope to go back further, we'd have to 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 185 + ``HEAD~2`` and ``HEAD``:: 186 + 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 ==== 192 + [C] 'struct bpf_insn' changed: 193 + type size hasn't changed 194 + 2 data member changes: 195 + '__u8 dst_reg' offset changed from 8 to 12 (in bits) (by +4 bits) 196 + '__u8 src_reg' offset changed from 12 to 8 (in bits) (by -4 bits) 197 + ============================================================================== 198 + 199 + error - 1/912 UAPI headers compatible with x86 appear _not_ to be backwards compatible 200 + 201 + Alternatively, we could have also run with ``-b HEAD~``. This would set the 202 + base reference to ``HEAD~`` so then the script would compare it to ``HEAD~^1``. 203 + 204 + Architecture-specific Headers 205 + ----------------------------- 206 + 207 + Consider this change:: 208 + 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 { 213 + struct _aarch64_ctx { 214 + __u32 magic; 215 + __u32 size; 216 + + __u32 new_var; 217 + }; 218 + 219 + #define FPSIMD_MAGIC 0x46508001 220 + EOF 221 + 222 + This is a change to an arm64-specific UAPI header file. In this example, I'm 223 + running the script from an x86 machine with an x86 compiler, so, by default, 224 + the script only checks x86-compatible UAPI header files:: 225 + 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 230 + 231 + With an x86 compiler, we can't check header files in ``arch/arm64``, so the 232 + script doesn't even try. 233 + 234 + If we want to check the header file, we'll have to use an arm64 compiler and 235 + set ``ARCH`` accordingly:: 236 + 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 ==== 242 + [C] 'struct _aarch64_ctx' changed: 243 + type size changed from 64 to 96 (in bits) 244 + 1 data member insertion: 245 + '__u32 new_var', at offset 64 (in bits) at sigcontext.h:73:1 246 + -- snip -- 247 + [C] 'struct zt_context' changed: 248 + type size changed from 128 to 160 (in bits) 249 + 2 data member changes (1 filtered): 250 + '__u16 nregs' offset changed from 64 to 96 (in bits) (by +32 bits) 251 + '__u16 __reserved[3]' offset changed from 80 to 112 (in bits) (by +32 bits) 252 + ======================================================================================= 253 + 254 + error - 1/884 UAPI headers compatible with arm64 appear _not_ to be backwards compatible 255 + 256 + We can see with ``ARCH`` and ``CC`` set properly for the file, the ABI 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 259 + of headers installed for arm64 platforms is different than x86. 260 + 261 + Cross-Dependency Breakages 262 + -------------------------- 263 + 264 + Consider this change:: 265 + 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; 270 + #define __aligned_be64 __be64 __attribute__((aligned(8))) 271 + #define __aligned_le64 __le64 __attribute__((aligned(8))) 272 + 273 + -typedef unsigned __bitwise __poll_t; 274 + +typedef unsigned short __bitwise __poll_t; 275 + 276 + #endif /* __ASSEMBLY__ */ 277 + #endif /* _UAPI_LINUX_TYPES_H */ 278 + EOF 279 + 280 + Here, we're changing a ``typedef`` in ``types.h``. This doesn't break 281 + a UAPI in ``types.h``, but other UAPIs in the tree may break due to 282 + this change:: 283 + 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 ==== 289 + [C] 'struct epoll_event' changed: 290 + type size changed from 96 to 80 (in bits) 291 + 2 data member changes: 292 + type of '__poll_t events' changed: 293 + underlying type 'unsigned int' changed: 294 + type name changed from 'unsigned int' to 'unsigned short int' 295 + type size changed from 32 to 16 (in bits) 296 + '__u64 data' offset changed from 32 to 16 (in bits) (by -16 bits) 297 + ======================================================================================== 298 + include/linux/eventpoll.h did not change between HEAD and dirty tree... 299 + It's possible a change to one of the headers it includes caused this error: 300 + #include <linux/fcntl.h> 301 + #include <linux/types.h> 302 + 303 + Note that the script noticed the failing header file did not change, 304 + so it assumes one of its includes must have caused the breakage. Indeed, 305 + we can see ``linux/types.h`` is used from ``eventpoll.h``. 306 + 307 + UAPI Header Removals 308 + -------------------- 309 + 310 + Consider this change:: 311 + 312 + cat << 'EOF' | patch -l -p1 313 + diff --git a/include/uapi/asm-generic/Kbuild b/include/uapi/asm-generic/Kbuild 314 + index ebb180aac74e..a9c88b0a8b3b 100644 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 325 + EOF 326 + 327 + This script removes a UAPI header file from the install list. Let's run 328 + the script:: 329 + 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 ==== 335 + 336 + error - 1/912 UAPI headers compatible with x86 appear _not_ to be backwards compatible 337 + 338 + Removing a UAPI header is considered a breaking change, and the script 339 + will flag it as such. 340 + 341 + Checking Historic UAPI Compatibility 342 + ------------------------------------ 343 + 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 346 + v6.0 and v6.1, you'd run:: 347 + 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... 352 + 353 + --- snip --- 354 + error - 37/907 UAPI headers compatible with x86 appear _not_ to be backwards compatible 355 + 356 + Note: Before v5.3, a header file needed by the script is not present, 357 + so the script is unable to check changes before then. 358 + 359 + You'll notice that the script detected many UAPI changes that are not 360 + backwards compatible. Knowing that kernel UAPIs are supposed to be stable 361 + forever, this is an alarming result. This brings us to the next section: 362 + caveats. 363 + 364 + Caveats 365 + ======= 366 + 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. 369 + 370 + Removals For Refactoring or Deprecation 371 + --------------------------------------- 372 + 373 + Sometimes drivers for very old hardware are removed, such as in this example:: 374 + 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 ==== 380 + 381 + error - 1/910 UAPI headers compatible with x86 appear _not_ to be backwards compatible 382 + 383 + The script will always flag removals (even if they're intentional). 384 + 385 + Struct Expansions 386 + ----------------- 387 + 388 + Depending on how a structure is handled in kernelspace, a change which 389 + expands a struct could be non-breaking. 390 + 391 + If a struct is used as the argument to an ioctl, then the kernel driver 392 + must be able to handle ioctl commands of any size. Beyond that, you need 393 + to be careful when copying data from the user. Say, for example, that 394 + ``struct foo`` is changed like this:: 395 + 396 + struct foo { 397 + __u64 a; /* added in version 1 */ 398 + + __u32 b; /* added in version 2 */ 399 + + __u32 c; /* added in version 2 */ 400 + } 401 + 402 + By default, the script will flag this kind of change for further review:: 403 + 404 + [C] 'struct foo' changed: 405 + type size changed from 64 to 128 (in bits) 406 + 2 data member insertions: 407 + '__u32 b', at offset 64 (in bits) 408 + '__u32 c', at offset 96 (in bits) 409 + 410 + However, it is possible that this change was made safely. 411 + 412 + If a userspace program was built with version 1, it will think 413 + ``sizeof(struct foo)`` is 8. That size will be encoded in the 414 + ioctl value that gets sent to the kernel. If the kernel is built 415 + with version 2, it will think the ``sizeof(struct foo)`` is 16. 416 + 417 + The kernel can use the ``_IOC_SIZE`` macro to get the size encoded 418 + in the ioctl code that the user passed in and then use 419 + ``copy_struct_from_user()`` to safely copy the value:: 420 + 421 + int handle_ioctl(unsigned long cmd, unsigned long arg) 422 + { 423 + switch _IOC_NR(cmd) { 424 + 0x01: { 425 + struct foo my_cmd; /* size 16 in the kernel */ 426 + 427 + ret = copy_struct_from_user(&my_cmd, arg, sizeof(struct foo), _IOC_SIZE(cmd)); 428 + ... 429 + 430 + ``copy_struct_from_user`` will zero the struct in the kernel and then copy 431 + only the bytes passed in from the user (leaving new members zeroized). 432 + If the user passed in a larger struct, the extra members are ignored. 433 + 434 + If you know this situation is accounted for in the kernel code, you can 435 + pass ``-i`` to the script, and struct expansions like this will be ignored. 436 + 437 + Flex Array Migration 438 + -------------------- 439 + 440 + While the script handles expansion into an existing flex array, it does 441 + still flag initial migration to flex arrays from 1-element fake flex 442 + arrays. For example:: 443 + 444 + struct foo { 445 + __u32 x; 446 + - __u32 flex[1]; /* fake flex */ 447 + + __u32 flex[]; /* real flex */ 448 + }; 449 + 450 + This change would be flagged by the script:: 451 + 452 + [C] 'struct foo' changed: 453 + type size changed from 64 to 32 (in bits) 454 + 1 data member change: 455 + type of '__u32 flex[1]' changed: 456 + type name changed from '__u32[1]' to '__u32[]' 457 + array type size changed from 32 to 'unknown' 458 + array type subrange 1 changed length from 1 to 'unknown' 459 + 460 + At this time, there's no way to filter these types of changes, so be 461 + aware of this possible false positive. 462 + 463 + Summary 464 + ------- 465 + 466 + While many types of false positives are filtered out by the script, 467 + it's possible there are some cases where the script flags a change 468 + which does not break UAPI. It's also possible a change which *does* 469 + break userspace would not be flagged by this script. While the script 470 + has been run on much of the kernel history, there could still be corner 471 + cases that are not accounted for. 472 + 473 + The intention is for this script to be used as a quick check for 474 + maintainers or automated tooling, not as the end-all authority on 475 + patch compatibility. It's best to remember: use your best judgment 476 + (and ideally a unit test in userspace) to make sure your UAPI changes 477 + are backwards-compatible!
+1
Documentation/dev-tools/index.rst
··· 31 31 kselftest 32 32 kunit/index 33 33 ktap 34 + checkuapi 34 35 35 36 36 37 .. only:: subproject and html
+4
Documentation/process/4.Coding.rst
··· 66 66 See the file :ref:`Documentation/process/clang-format.rst <clangformat>` 67 67 for more details. 68 68 69 + Some basic editor settings, such as indentation and line endings, will be 70 + set automatically if you are using an editor that is compatible with 71 + EditorConfig. See the official EditorConfig website for more information: 72 + https://editorconfig.org/ 69 73 70 74 Abstraction layers 71 75 ******************
+4
Documentation/process/coding-style.rst
··· 735 735 See the file :ref:`Documentation/process/clang-format.rst <clangformat>` 736 736 for more details. 737 737 738 + Some basic editor settings, such as indentation and line endings, will be 739 + set automatically if you are using an editor that is compatible with 740 + EditorConfig. See the official EditorConfig website for more information: 741 + https://editorconfig.org/ 738 742 739 743 10) Kconfig configuration files 740 744 -------------------------------
+14 -9
Makefile
··· 155 155 156 156 export KBUILD_EXTMOD 157 157 158 + # backward compatibility 159 + KBUILD_EXTRA_WARN ?= $(KBUILD_ENABLE_EXTRA_GCC_CHECKS) 160 + 161 + ifeq ("$(origin W)", "command line") 162 + KBUILD_EXTRA_WARN := $(W) 163 + endif 164 + 165 + export KBUILD_EXTRA_WARN 166 + 158 167 # Kbuild will save output files in the current working directory. 159 168 # This does not need to match to the root of the kernel source tree. 160 169 # ··· 190 181 endif 191 182 192 183 ifneq ($(KBUILD_OUTPUT),) 193 - # Make's built-in functions such as $(abspath ...), $(realpath ...) cannot 194 - # expand a shell special character '~'. We use a somewhat tedious way here. 195 - abs_objtree := $(shell mkdir -p $(KBUILD_OUTPUT) && cd $(KBUILD_OUTPUT) && pwd) 196 - $(if $(abs_objtree),, \ 197 - $(error failed to create output directory "$(KBUILD_OUTPUT)")) 198 - 184 + # $(realpath ...) gets empty if the path does not exist. Run 'mkdir -p' first. 185 + $(shell mkdir -p "$(KBUILD_OUTPUT)") 199 186 # $(realpath ...) resolves symlinks 200 - abs_objtree := $(realpath $(abs_objtree)) 187 + abs_objtree := $(realpath $(KBUILD_OUTPUT)) 188 + $(if $(abs_objtree),,$(error failed to create output directory "$(KBUILD_OUTPUT)")) 201 189 endif # ifneq ($(KBUILD_OUTPUT),) 202 190 203 191 ifneq ($(words $(subst :, ,$(abs_srctree))), 1) ··· 615 609 export RCS_FIND_IGNORE := \( -name SCCS -o -name BitKeeper -o -name .svn -o \ 616 610 -name CVS -o -name .pc -o -name .hg -o -name .git \) \ 617 611 -prune -o 618 - export RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn \ 619 - --exclude CVS --exclude .pc --exclude .hg --exclude .git 620 612 621 613 # =========================================================================== 622 614 # Rules shared between *config targets and build targets ··· 1666 1662 @echo ' 1: warnings which may be relevant and do not occur too often' 1667 1663 @echo ' 2: warnings which occur quite often but may still be relevant' 1668 1664 @echo ' 3: more obscure warnings, can most likely be ignored' 1665 + @echo ' c: extra checks in the configuration stage (Kconfig)' 1669 1666 @echo ' e: warnings are being treated as errors' 1670 1667 @echo ' Multiple levels can be combined with W=12 or W=123' 1671 1668 @$(if $(dtstree), \
+4 -14
arch/sparc/vdso/Makefile
··· 3 3 # Building vDSO images for sparc. 4 4 # 5 5 6 - VDSO64-$(CONFIG_SPARC64) := y 7 - VDSOCOMPAT-$(CONFIG_COMPAT) := y 8 - 9 6 # files to link into the vdso 10 7 vobjs-y := vdso-note.o vclock_gettime.o 11 8 ··· 10 13 obj-y += vma.o 11 14 12 15 # vDSO images to build 13 - vdso_img-$(VDSO64-y) += 64 14 - vdso_img-$(VDSOCOMPAT-y) += 32 16 + obj-$(CONFIG_SPARC64) += vdso-image-64.o 17 + obj-$(CONFIG_COMPAT) += vdso-image-32.o 15 18 16 - vobjs := $(foreach F,$(vobjs-y),$(obj)/$F) 19 + vobjs := $(addprefix $(obj)/, $(vobjs-y)) 17 20 18 21 $(obj)/vdso.o: $(obj)/vdso.so 19 22 20 23 targets += vdso.lds $(vobjs-y) 21 - 22 - # Build the vDSO image C files and link them in. 23 - vdso_img_objs := $(vdso_img-y:%=vdso-image-%.o) 24 - vdso_img_cfiles := $(vdso_img-y:%=vdso-image-%.c) 25 - vdso_img_sodbg := $(vdso_img-y:%=vdso%.so.dbg) 26 - obj-y += $(vdso_img_objs) 27 - targets += $(vdso_img_cfiles) 28 - targets += $(vdso_img_sodbg) $(vdso_img-y:%=vdso%.so) 24 + targets += $(foreach x, 32 64, vdso-image-$(x).c vdso$(x).so vdso$(x).so.dbg) 29 25 30 26 CPPFLAGS_vdso.lds += -P -C 31 27
-18
include/linux/export.h
··· 7 7 #include <linux/stringify.h> 8 8 9 9 /* 10 - * Export symbols from the kernel to modules. Forked from module.h 11 - * to reduce the amount of pointless cruft we feed to gcc when only 12 - * exporting a simple symbol or two. 13 - * 14 - * Try not to add #includes here. It slows compilation and makes kernel 15 - * hackers place grumpy comments in header files. 16 - */ 17 - 18 - /* 19 10 * This comment block is used by fixdep. Please do not remove. 20 11 * 21 12 * When CONFIG_MODVERSIONS is changed from n to y, all source files having 22 13 * EXPORT_SYMBOL variants must be re-compiled because genksyms is run as a 23 14 * side effect of the *.o build rule. 24 15 */ 25 - 26 - #ifndef __ASSEMBLY__ 27 - #ifdef MODULE 28 - extern struct module __this_module; 29 - #define THIS_MODULE (&__this_module) 30 - #else 31 - #define THIS_MODULE ((struct module *)0) 32 - #endif 33 - #endif /* __ASSEMBLY__ */ 34 16 35 17 #ifdef CONFIG_64BIT 36 18 #define __EXPORT_SYMBOL_REF(sym) \
+7
include/linux/init.h
··· 179 179 180 180 extern bool initcall_debug; 181 181 182 + #ifdef MODULE 183 + extern struct module __this_module; 184 + #define THIS_MODULE (&__this_module) 185 + #else 186 + #define THIS_MODULE ((struct module *)0) 187 + #endif 188 + 182 189 #endif 183 190 184 191 #ifndef MODULE
-9
scripts/Makefile.extrawarn
··· 82 82 # Warn if there is an enum types mismatch 83 83 KBUILD_CFLAGS += $(call cc-option,-Wenum-conversion) 84 84 85 - # backward compatibility 86 - KBUILD_EXTRA_WARN ?= $(KBUILD_ENABLE_EXTRA_GCC_CHECKS) 87 - 88 - ifeq ("$(origin W)", "command line") 89 - KBUILD_EXTRA_WARN := $(W) 90 - endif 91 - 92 - export KBUILD_EXTRA_WARN 93 - 94 85 # 95 86 # W=1 - warnings which may be relevant and do not occur too often 96 87 #
+2 -2
scripts/Makefile.lib
··· 83 83 multi-dtb-y := $(call multi-search, $(dtb-y), .dtb, -dtbs) 84 84 # Primitive DTB compiled from *.dts 85 85 real-dtb-y := $(call real-search, $(dtb-y), .dtb, -dtbs) 86 - # Base DTB that overlay is applied onto (each first word of $(*-dtbs) expansion) 87 - base-dtb-y := $(foreach m, $(multi-dtb-y), $(firstword $(call suffix-search, $m, .dtb, -dtbs))) 86 + # Base DTB that overlay is applied onto 87 + base-dtb-y := $(filter %.dtb, $(call real-search, $(multi-dtb-y), .dtb, -dtbs)) 88 88 89 89 always-y += $(dtb-y) 90 90
+2 -26
scripts/Makefile.package
··· 4 4 include $(srctree)/scripts/Kbuild.include 5 5 include $(srctree)/scripts/Makefile.lib 6 6 7 - KERNELPATH := kernel-$(subst -,_,$(KERNELRELEASE)) 8 - # Include only those top-level files that are needed by make, plus the GPL copy 9 - TAR_CONTENT := Documentation LICENSES arch block certs crypto drivers fs \ 10 - include init io_uring ipc kernel lib mm net rust \ 11 - samples scripts security sound tools usr virt \ 12 - .config Makefile \ 13 - Kbuild Kconfig COPYING $(wildcard localversion*) 14 - 15 - quiet_cmd_src_tar = TAR $(2).tar.gz 16 - cmd_src_tar = \ 17 - if test "$(objtree)" != "$(srctree)"; then \ 18 - echo >&2; \ 19 - echo >&2 " ERROR:"; \ 20 - echo >&2 " Building source tarball is not possible outside the"; \ 21 - echo >&2 " kernel source tree. Don't set KBUILD_OUTPUT"; \ 22 - echo >&2; \ 23 - false; \ 24 - fi ; \ 25 - tar -I $(KGZIP) -c $(RCS_TAR_IGNORE) -f $(2).tar.gz \ 26 - --transform 's:^:$(2)/:S' $(TAR_CONTENT) $(3) 27 - 28 7 # Git 29 8 # --------------------------------------------------------------------------- 30 9 ··· 109 130 cp $< ../$(orig-name); \ 110 131 fi 111 132 112 - KBUILD_PKG_ROOTCMD ?= 'fakeroot -u' 113 - 114 133 PHONY += deb-pkg srcdeb-pkg bindeb-pkg 115 134 116 135 deb-pkg: private build-type := source,binary ··· 123 146 $(if $(findstring source, $(build-type)), \ 124 147 --unsigned-source --compression=$(KDEB_SOURCE_COMPRESS)) \ 125 148 $(if $(findstring binary, $(build-type)), \ 126 - --rules-file='$(MAKE) -f debian/rules' --jobs=1 -r$(KBUILD_PKG_ROOTCMD) -a$$(cat debian/arch), \ 149 + -R'$(MAKE) -f debian/rules' -j1 -a$$(cat debian/arch), \ 127 150 --no-check-builddeps) \ 128 151 $(DPKG_FLAGS)) 129 152 ··· 134 157 rm -rf $(objtree)/snap 135 158 mkdir $(objtree)/snap 136 159 $(MAKE) clean 137 - $(call cmd,src_tar,$(KERNELPATH)) 138 160 sed "s@KERNELRELEASE@$(KERNELRELEASE)@; \ 139 - s@SRCTREE@$(shell realpath $(KERNELPATH).tar.gz)@" \ 161 + s@SRCTREE@$(abs_srctree)@" \ 140 162 $(srctree)/scripts/package/snapcraft.template > \ 141 163 $(objtree)/snap/snapcraft.yaml 142 164 cd $(objtree)/snap && \
+573
scripts/check-uapi.sh
··· 1 + #!/bin/bash 2 + # SPDX-License-Identifier: GPL-2.0-only 3 + # Script to check commits for UAPI backwards compatibility 4 + 5 + set -o errexit 6 + set -o pipefail 7 + 8 + print_usage() { 9 + name=$(basename "$0") 10 + cat << EOF 11 + $name - check for UAPI header stability across Git commits 12 + 13 + By default, the script will check to make sure the latest commit (or current 14 + dirty changes) did not introduce ABI changes when compared to HEAD^1. You can 15 + check against additional commit ranges with the -b and -p options. 16 + 17 + The script will not check UAPI headers for architectures other than the one 18 + defined in ARCH. 19 + 20 + Usage: $name [-b BASE_REF] [-p PAST_REF] [-j N] [-l ERROR_LOG] [-i] [-q] [-v] 21 + 22 + Options: 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 25 + dirty changes, HEAD will be used. 26 + -p PAST_REF Compare BASE_REF to PAST_REF (e.g. -p v6.1). If unspecified or empty, 27 + will use BASE_REF^1. Must be an ancestor of BASE_REF. Only headers 28 + that exist on PAST_REF will be checked for compatibility. 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). 34 + 35 + Environmental args: 36 + ABIDIFF Custom path to abidiff binary 37 + CC C compiler (default is "gcc") 38 + ARCH Target architecture for the UAPI check (default is host arch) 39 + 40 + Exit codes: 41 + $SUCCESS) Success 42 + $FAIL_ABI) ABI difference detected 43 + $FAIL_PREREQ) Prerequisite not met 44 + EOF 45 + } 46 + 47 + readonly SUCCESS=0 48 + readonly FAIL_ABI=1 49 + readonly FAIL_PREREQ=2 50 + 51 + # Print to stderr 52 + eprintf() { 53 + # shellcheck disable=SC2059 54 + printf "$@" >&2 55 + } 56 + 57 + # Expand an array with a specific character (similar to Python string.join()) 58 + join() { 59 + local IFS="$1" 60 + shift 61 + printf "%s" "$*" 62 + } 63 + 64 + # Create abidiff suppressions 65 + gen_suppressions() { 66 + # Common enum variant names which we don't want to worry about 67 + # being shifted when new variants are added. 68 + local -a enum_regex=( 69 + ".*_AFTER_LAST$" 70 + ".*_CNT$" 71 + ".*_COUNT$" 72 + ".*_END$" 73 + ".*_LAST$" 74 + ".*_MASK$" 75 + ".*_MAX$" 76 + ".*_MAX_BIT$" 77 + ".*_MAX_BPF_ATTACH_TYPE$" 78 + ".*_MAX_ID$" 79 + ".*_MAX_SHIFT$" 80 + ".*_NBITS$" 81 + ".*_NETDEV_NUMHOOKS$" 82 + ".*_NFT_META_IIFTYPE$" 83 + ".*_NL80211_ATTR$" 84 + ".*_NLDEV_NUM_OPS$" 85 + ".*_NUM$" 86 + ".*_NUM_ELEMS$" 87 + ".*_NUM_IRQS$" 88 + ".*_SIZE$" 89 + ".*_TLSMAX$" 90 + "^MAX_.*" 91 + "^NUM_.*" 92 + ) 93 + 94 + # Common padding field names which can be expanded into 95 + # without worrying about users. 96 + local -a padding_regex=( 97 + ".*end$" 98 + ".*pad$" 99 + ".*pad[0-9]?$" 100 + ".*pad_[0-9]?$" 101 + ".*padding$" 102 + ".*padding[0-9]?$" 103 + ".*padding_[0-9]?$" 104 + ".*res$" 105 + ".*resv$" 106 + ".*resv[0-9]?$" 107 + ".*resv_[0-9]?$" 108 + ".*reserved$" 109 + ".*reserved[0-9]?$" 110 + ".*reserved_[0-9]?$" 111 + ".*rsvd[0-9]?$" 112 + ".*unused$" 113 + ) 114 + 115 + cat << EOF 116 + [suppress_type] 117 + type_kind = enum 118 + changed_enumerators_regexp = $(join , "${enum_regex[@]}") 119 + EOF 120 + 121 + for p in "${padding_regex[@]}"; do 122 + cat << EOF 123 + [suppress_type] 124 + type_kind = struct 125 + has_data_member_inserted_at = offset_of_first_data_member_regexp(${p}) 126 + EOF 127 + done 128 + 129 + if [ "$IGNORE_AMBIGUOUS_CHANGES" = "true" ]; then 130 + cat << EOF 131 + [suppress_type] 132 + type_kind = struct 133 + has_data_member_inserted_at = end 134 + has_size_change = yes 135 + EOF 136 + fi 137 + } 138 + 139 + # Check if git tree is dirty 140 + tree_is_dirty() { 141 + ! git diff --quiet 142 + } 143 + 144 + # Get list of files installed in $ref 145 + get_file_list() { 146 + local -r ref="$1" 147 + local -r tree="$(get_header_tree "$ref")" 148 + 149 + # Print all installed headers, filtering out ones that can't be compiled 150 + find "$tree" -type f -name '*.h' -printf '%P\n' | grep -v -f "$INCOMPAT_LIST" 151 + } 152 + 153 + # Add to the list of incompatible headers 154 + add_to_incompat_list() { 155 + local -r ref="$1" 156 + 157 + # Start with the usr/include/Makefile to get a list of the headers 158 + # that don't compile using this method. 159 + if [ ! -f usr/include/Makefile ]; then 160 + eprintf "error - no usr/include/Makefile present at %s\n" "$ref" 161 + eprintf "Note: usr/include/Makefile was added in the v5.3 kernel release\n" 162 + exit "$FAIL_PREREQ" 163 + fi 164 + { 165 + # shellcheck disable=SC2016 166 + printf 'all: ; @echo $(no-header-test)\n' 167 + cat usr/include/Makefile 168 + } | SRCARCH="$ARCH" make --always-make -f - | tr " " "\n" \ 169 + | grep -v "asm-generic" >> "$INCOMPAT_LIST" 170 + 171 + # The makefile also skips all asm-generic files, but prints "asm-generic/%" 172 + # which won't work for our grep match. Instead, print something grep will match. 173 + printf "asm-generic/.*\.h\n" >> "$INCOMPAT_LIST" 174 + } 175 + 176 + # Compile the simple test app 177 + do_compile() { 178 + local -r inc_dir="$1" 179 + local -r header="$2" 180 + local -r out="$3" 181 + printf "int main(void) { return 0; }\n" | \ 182 + "$CC" -c \ 183 + -o "$out" \ 184 + -x c \ 185 + -O0 \ 186 + -std=c90 \ 187 + -fno-eliminate-unused-debug-types \ 188 + -g \ 189 + "-I${inc_dir}" \ 190 + -include "$header" \ 191 + - 192 + } 193 + 194 + # Run make headers_install 195 + run_make_headers_install() { 196 + local -r ref="$1" 197 + local -r install_dir="$(get_header_tree "$ref")" 198 + make -j "$MAX_THREADS" ARCH="$ARCH" INSTALL_HDR_PATH="$install_dir" \ 199 + headers_install > /dev/null 200 + } 201 + 202 + # Install headers for both git refs 203 + install_headers() { 204 + local -r base_ref="$1" 205 + local -r past_ref="$2" 206 + 207 + for ref in "$base_ref" "$past_ref"; do 208 + printf "Installing user-facing UAPI headers from %s... " "${ref:-dirty tree}" 209 + if [ -n "$ref" ]; then 210 + git archive --format=tar --prefix="${ref}-archive/" "$ref" \ 211 + | (cd "$TMP_DIR" && tar xf -) 212 + ( 213 + cd "${TMP_DIR}/${ref}-archive" 214 + run_make_headers_install "$ref" 215 + add_to_incompat_list "$ref" "$INCOMPAT_LIST" 216 + ) 217 + else 218 + run_make_headers_install "$ref" 219 + add_to_incompat_list "$ref" "$INCOMPAT_LIST" 220 + fi 221 + printf "OK\n" 222 + done 223 + sort -u -o "$INCOMPAT_LIST" "$INCOMPAT_LIST" 224 + sed -i -e '/^$/d' "$INCOMPAT_LIST" 225 + } 226 + 227 + # Print the path to the headers_install tree for a given ref 228 + get_header_tree() { 229 + local -r ref="$1" 230 + printf "%s" "${TMP_DIR}/${ref}/usr" 231 + } 232 + 233 + # Check file list for UAPI compatibility 234 + check_uapi_files() { 235 + local -r base_ref="$1" 236 + local -r past_ref="$2" 237 + local -r abi_error_log="$3" 238 + 239 + local passed=0; 240 + local failed=0; 241 + local -a threads=() 242 + set -o errexit 243 + 244 + printf "Checking changes to UAPI headers between %s and %s...\n" "$past_ref" "${base_ref:-dirty tree}" 245 + # Loop over all UAPI headers that were installed by $past_ref (if they only exist on $base_ref, 246 + # there's no way they're broken and no way to compare anyway) 247 + while read -r file; do 248 + if [ "${#threads[@]}" -ge "$MAX_THREADS" ]; then 249 + if wait "${threads[0]}"; then 250 + passed=$((passed + 1)) 251 + else 252 + failed=$((failed + 1)) 253 + fi 254 + threads=("${threads[@]:1}") 255 + fi 256 + 257 + check_individual_file "$base_ref" "$past_ref" "$file" & 258 + threads+=("$!") 259 + done < <(get_file_list "$past_ref") 260 + 261 + for t in "${threads[@]}"; do 262 + if wait "$t"; then 263 + passed=$((passed + 1)) 264 + else 265 + failed=$((failed + 1)) 266 + fi 267 + done 268 + 269 + if [ -n "$abi_error_log" ]; then 270 + printf 'Generated by "%s %s" from git ref %s\n\n' \ 271 + "$0" "$*" "$(git rev-parse HEAD)" > "$abi_error_log" 272 + fi 273 + 274 + while read -r error_file; do 275 + { 276 + cat "$error_file" 277 + printf "\n\n" 278 + } | tee -a "${abi_error_log:-/dev/null}" >&2 279 + done < <(find "$TMP_DIR" -type f -name '*.error' | sort) 280 + 281 + total="$((passed + failed))" 282 + if [ "$failed" -gt 0 ]; then 283 + eprintf "error - %d/%d UAPI headers compatible with %s appear _not_ to be backwards compatible\n" \ 284 + "$failed" "$total" "$ARCH" 285 + if [ -n "$abi_error_log" ]; then 286 + eprintf "Failure summary saved to %s\n" "$abi_error_log" 287 + fi 288 + else 289 + printf "All %d UAPI headers compatible with %s appear to be backwards compatible\n" \ 290 + "$total" "$ARCH" 291 + fi 292 + 293 + return "$failed" 294 + } 295 + 296 + # Check an individual file for UAPI compatibility 297 + check_individual_file() { 298 + local -r base_ref="$1" 299 + local -r past_ref="$2" 300 + local -r file="$3" 301 + 302 + local -r base_header="$(get_header_tree "$base_ref")/${file}" 303 + local -r past_header="$(get_header_tree "$past_ref")/${file}" 304 + 305 + if [ ! -f "$base_header" ]; then 306 + mkdir -p "$(dirname "$base_header")" 307 + printf "==== UAPI header %s was removed between %s and %s ====" \ 308 + "$file" "$past_ref" "$base_ref" \ 309 + > "${base_header}.error" 310 + return 1 311 + fi 312 + 313 + compare_abi "$file" "$base_header" "$past_header" "$base_ref" "$past_ref" 314 + } 315 + 316 + # Perform the A/B compilation and compare output ABI 317 + compare_abi() { 318 + local -r file="$1" 319 + local -r base_header="$2" 320 + local -r past_header="$3" 321 + local -r base_ref="$4" 322 + local -r past_ref="$5" 323 + local -r log="${TMP_DIR}/log/${file}.log" 324 + local -r error_log="${TMP_DIR}/log/${file}.error" 325 + 326 + mkdir -p "$(dirname "$log")" 327 + 328 + if ! do_compile "$(get_header_tree "$base_ref")/include" "$base_header" "${base_header}.bin" 2> "$log"; then 329 + { 330 + warn_str=$(printf "==== Could not compile version of UAPI header %s at %s ====\n" \ 331 + "$file" "$base_ref") 332 + printf "%s\n" "$warn_str" 333 + cat "$log" 334 + printf -- "=%.0s" $(seq 0 ${#warn_str}) 335 + } > "$error_log" 336 + return 1 337 + fi 338 + 339 + if ! do_compile "$(get_header_tree "$past_ref")/include" "$past_header" "${past_header}.bin" 2> "$log"; then 340 + { 341 + warn_str=$(printf "==== Could not compile version of UAPI header %s at %s ====\n" \ 342 + "$file" "$past_ref") 343 + printf "%s\n" "$warn_str" 344 + cat "$log" 345 + printf -- "=%.0s" $(seq 0 ${#warn_str}) 346 + } > "$error_log" 347 + return 1 348 + fi 349 + 350 + local ret=0 351 + "$ABIDIFF" --non-reachable-types \ 352 + --suppressions "$SUPPRESSIONS" \ 353 + "${past_header}.bin" "${base_header}.bin" > "$log" || ret="$?" 354 + if [ "$ret" -eq 0 ]; then 355 + if [ "$VERBOSE" = "true" ]; then 356 + printf "No ABI differences detected in %s from %s -> %s\n" \ 357 + "$file" "$past_ref" "$base_ref" 358 + fi 359 + else 360 + # Bits in abidiff's return code can be used to determine the type of error 361 + if [ $((ret & 0x2)) -gt 0 ]; then 362 + eprintf "error - abidiff did not run properly\n" 363 + exit 1 364 + fi 365 + 366 + if [ "$IGNORE_AMBIGUOUS_CHANGES" = "true" ] && [ "$ret" -eq 4 ]; then 367 + return 0 368 + fi 369 + 370 + # If the only changes were additions (not modifications to existing APIs), then 371 + # there's no problem. Ignore these diffs. 372 + if grep "Unreachable types summary" "$log" | grep -q "0 removed" && 373 + grep "Unreachable types summary" "$log" | grep -q "0 changed"; then 374 + return 0 375 + fi 376 + 377 + { 378 + warn_str=$(printf "==== ABI differences detected in %s from %s -> %s ====" \ 379 + "$file" "$past_ref" "$base_ref") 380 + printf "%s\n" "$warn_str" 381 + sed -e '/summary:/d' -e '/changed type/d' -e '/^$/d' -e 's/^/ /g' "$log" 382 + printf -- "=%.0s" $(seq 0 ${#warn_str}) 383 + if cmp "$past_header" "$base_header" > /dev/null 2>&1; then 384 + printf "\n%s did not change between %s and %s...\n" "$file" "$past_ref" "${base_ref:-dirty tree}" 385 + printf "It's possible a change to one of the headers it includes caused this error:\n" 386 + grep '^#include' "$base_header" 387 + printf "\n" 388 + fi 389 + } > "$error_log" 390 + 391 + return 1 392 + fi 393 + } 394 + 395 + # Check that a minimum software version number is satisfied 396 + min_version_is_satisfied() { 397 + local -r min_version="$1" 398 + local -r version_installed="$2" 399 + 400 + printf "%s\n%s\n" "$min_version" "$version_installed" \ 401 + | sort -Vc > /dev/null 2>&1 402 + } 403 + 404 + # Make sure we have the tools we need and the arguments make sense 405 + check_deps() { 406 + ABIDIFF="${ABIDIFF:-abidiff}" 407 + CC="${CC:-gcc}" 408 + ARCH="${ARCH:-$(uname -m)}" 409 + if [ "$ARCH" = "x86_64" ]; then 410 + ARCH="x86" 411 + fi 412 + 413 + local -r abidiff_min_version="2.4" 414 + local -r libdw_min_version_if_clang="0.171" 415 + 416 + if ! command -v "$ABIDIFF" > /dev/null 2>&1; then 417 + eprintf "error - abidiff not found!\n" 418 + eprintf "Please install abigail-tools version %s or greater\n" "$abidiff_min_version" 419 + eprintf "See: https://sourceware.org/libabigail/manual/libabigail-overview.html\n" 420 + return 1 421 + fi 422 + 423 + local -r abidiff_version="$("$ABIDIFF" --version | cut -d ' ' -f 2)" 424 + if ! min_version_is_satisfied "$abidiff_min_version" "$abidiff_version"; then 425 + eprintf "error - abidiff version too old: %s\n" "$abidiff_version" 426 + eprintf "Please install abigail-tools version %s or greater\n" "$abidiff_min_version" 427 + eprintf "See: https://sourceware.org/libabigail/manual/libabigail-overview.html\n" 428 + return 1 429 + fi 430 + 431 + if ! command -v "$CC" > /dev/null 2>&1; then 432 + eprintf 'error - %s not found\n' "$CC" 433 + return 1 434 + fi 435 + 436 + if "$CC" --version | grep -q clang; then 437 + local -r libdw_version="$(ldconfig -v 2>/dev/null | grep -v SKIPPED | grep -m 1 -o 'libdw-[0-9]\+.[0-9]\+' | cut -c 7-)" 438 + if ! min_version_is_satisfied "$libdw_min_version_if_clang" "$libdw_version"; then 439 + eprintf "error - libdw version too old for use with clang: %s\n" "$libdw_version" 440 + eprintf "Please install libdw from elfutils version %s or greater\n" "$libdw_min_version_if_clang" 441 + eprintf "See: https://sourceware.org/elfutils/\n" 442 + return 1 443 + fi 444 + fi 445 + 446 + if [ ! -d "arch/${ARCH}" ]; then 447 + eprintf 'error - ARCH "%s" is not a subdirectory under arch/\n' "$ARCH" 448 + eprintf "Please set ARCH to one of:\n%s\n" "$(find arch -maxdepth 1 -mindepth 1 -type d -printf '%f ' | fmt)" 449 + return 1 450 + fi 451 + 452 + if ! git rev-parse --is-inside-work-tree > /dev/null 2>&1; then 453 + eprintf "error - this script requires the kernel tree to be initialized with Git\n" 454 + return 1 455 + fi 456 + 457 + if ! git rev-parse --verify "$past_ref" > /dev/null 2>&1; then 458 + printf 'error - invalid git reference "%s"\n' "$past_ref" 459 + return 1 460 + fi 461 + 462 + if [ -n "$base_ref" ]; then 463 + if ! git merge-base --is-ancestor "$past_ref" "$base_ref" > /dev/null 2>&1; then 464 + printf 'error - "%s" is not an ancestor of base ref "%s"\n' "$past_ref" "$base_ref" 465 + return 1 466 + fi 467 + if [ "$(git rev-parse "$base_ref")" = "$(git rev-parse "$past_ref")" ]; then 468 + printf 'error - "%s" and "%s" are the same reference\n' "$past_ref" "$base_ref" 469 + return 1 470 + fi 471 + fi 472 + } 473 + 474 + run() { 475 + local base_ref="$1" 476 + local past_ref="$2" 477 + local abi_error_log="$3" 478 + shift 3 479 + 480 + if [ -z "$KERNEL_SRC" ]; then 481 + KERNEL_SRC="$(realpath "$(dirname "$0")"/..)" 482 + fi 483 + 484 + cd "$KERNEL_SRC" 485 + 486 + if [ -z "$base_ref" ] && ! tree_is_dirty; then 487 + base_ref=HEAD 488 + fi 489 + 490 + if [ -z "$past_ref" ]; then 491 + if [ -n "$base_ref" ]; then 492 + past_ref="${base_ref}^1" 493 + else 494 + past_ref=HEAD 495 + fi 496 + fi 497 + 498 + if ! check_deps; then 499 + exit "$FAIL_PREREQ" 500 + fi 501 + 502 + TMP_DIR=$(mktemp -d) 503 + readonly TMP_DIR 504 + trap 'rm -rf "$TMP_DIR"' EXIT 505 + 506 + readonly INCOMPAT_LIST="${TMP_DIR}/incompat_list.txt" 507 + touch "$INCOMPAT_LIST" 508 + 509 + readonly SUPPRESSIONS="${TMP_DIR}/suppressions.txt" 510 + gen_suppressions > "$SUPPRESSIONS" 511 + 512 + # Run make install_headers for both refs 513 + install_headers "$base_ref" "$past_ref" 514 + 515 + # Check for any differences in the installed header trees 516 + if diff -r -q "$(get_header_tree "$base_ref")" "$(get_header_tree "$past_ref")" > /dev/null 2>&1; then 517 + printf "No changes to UAPI headers were applied between %s and %s\n" "$past_ref" "${base_ref:-dirty tree}" 518 + exit "$SUCCESS" 519 + fi 520 + 521 + if ! check_uapi_files "$base_ref" "$past_ref" "$abi_error_log"; then 522 + exit "$FAIL_ABI" 523 + fi 524 + } 525 + 526 + main() { 527 + MAX_THREADS=$(nproc) 528 + VERBOSE="false" 529 + IGNORE_AMBIGUOUS_CHANGES="false" 530 + quiet="false" 531 + local base_ref="" 532 + while getopts "hb:p:j:l:iqv" opt; do 533 + case $opt in 534 + h) 535 + print_usage 536 + exit "$SUCCESS" 537 + ;; 538 + b) 539 + base_ref="$OPTARG" 540 + ;; 541 + p) 542 + past_ref="$OPTARG" 543 + ;; 544 + j) 545 + MAX_THREADS="$OPTARG" 546 + ;; 547 + l) 548 + abi_error_log="$OPTARG" 549 + ;; 550 + i) 551 + IGNORE_AMBIGUOUS_CHANGES="true" 552 + ;; 553 + q) 554 + quiet="true" 555 + VERBOSE="false" 556 + ;; 557 + v) 558 + VERBOSE="true" 559 + quiet="false" 560 + ;; 561 + *) 562 + exit "$FAIL_PREREQ" 563 + esac 564 + done 565 + 566 + if [ "$quiet" = "true" ]; then 567 + exec > /dev/null 2>&1 568 + fi 569 + 570 + run "$base_ref" "$past_ref" "$abi_error_log" "$@" 571 + } 572 + 573 + main "$@"
+3 -12
scripts/gdb/linux/tasks.py
··· 82 82 83 83 thread_info_type = utils.CachedType("struct thread_info") 84 84 85 - ia64_task_size = None 86 - 87 85 88 86 def get_thread_info(task): 89 87 thread_info_ptr_type = thread_info_type.get_type().pointer() 90 - if utils.is_target_arch("ia64"): 91 - global ia64_task_size 92 - if ia64_task_size is None: 93 - ia64_task_size = gdb.parse_and_eval("sizeof(struct task_struct)") 94 - thread_info_addr = task.address + ia64_task_size 95 - thread_info = thread_info_addr.cast(thread_info_ptr_type) 96 - else: 97 - if task.type.fields()[0].type == thread_info_type.get_type(): 98 - return task['thread_info'] 99 - thread_info = task['stack'].cast(thread_info_ptr_type) 88 + if task.type.fields()[0].type == thread_info_type.get_type(): 89 + return task['thread_info'] 90 + thread_info = task['stack'].cast(thread_info_ptr_type) 100 91 return thread_info.dereference() 101 92 102 93
+1 -21
scripts/genksyms/genksyms.c
··· 16 16 #include <unistd.h> 17 17 #include <assert.h> 18 18 #include <stdarg.h> 19 - #ifdef __GNU_LIBRARY__ 20 19 #include <getopt.h> 21 - #endif /* __GNU_LIBRARY__ */ 22 20 23 21 #include "genksyms.h" 24 22 /*----------------------------------------------------------------------*/ ··· 716 718 static void genksyms_usage(void) 717 719 { 718 720 fputs("Usage:\n" "genksyms [-adDTwqhVR] > /path/to/.tmp_obj.ver\n" "\n" 719 - #ifdef __GNU_LIBRARY__ 720 - " -s, --symbol-prefix Select symbol prefix\n" 721 721 " -d, --debug Increment the debug level (repeatable)\n" 722 722 " -D, --dump Dump expanded symbol defs (for debugging only)\n" 723 723 " -r, --reference file Read reference symbols from a file\n" ··· 725 729 " -q, --quiet Disable warnings (default)\n" 726 730 " -h, --help Print this message\n" 727 731 " -V, --version Print the release version\n" 728 - #else /* __GNU_LIBRARY__ */ 729 - " -s Select symbol prefix\n" 730 - " -d Increment the debug level (repeatable)\n" 731 - " -D Dump expanded symbol defs (for debugging only)\n" 732 - " -r file Read reference symbols from a file\n" 733 - " -T file Dump expanded types into file\n" 734 - " -p Preserve reference modversions or fail\n" 735 - " -w Enable warnings\n" 736 - " -q Disable warnings (default)\n" 737 - " -h Print this message\n" 738 - " -V Print the release version\n" 739 - #endif /* __GNU_LIBRARY__ */ 740 732 , stderr); 741 733 } 742 734 ··· 733 749 FILE *dumpfile = NULL, *ref_file = NULL; 734 750 int o; 735 751 736 - #ifdef __GNU_LIBRARY__ 737 752 struct option long_opts[] = { 738 753 {"debug", 0, 0, 'd'}, 739 754 {"warnings", 0, 0, 'w'}, ··· 746 763 {0, 0, 0, 0} 747 764 }; 748 765 749 - while ((o = getopt_long(argc, argv, "s:dwqVDr:T:ph", 766 + while ((o = getopt_long(argc, argv, "dwqVDr:T:ph", 750 767 &long_opts[0], NULL)) != EOF) 751 - #else /* __GNU_LIBRARY__ */ 752 - while ((o = getopt(argc, argv, "s:dwqVDr:T:ph")) != EOF) 753 - #endif /* __GNU_LIBRARY__ */ 754 768 switch (o) { 755 769 case 'd': 756 770 flag_debug++;
+42
scripts/git.orderFile
··· 1 + # SPDX-License-Identifier: GPL-2.0 2 + 3 + # order file for git, to produce patches which are easier to review 4 + # by diffing the important stuff like header changes first. 5 + # 6 + # one-off usage: 7 + # git diff -O scripts/git.orderFile ... 8 + # 9 + # add to git config: 10 + # git config diff.orderFile scripts/git.orderFile 11 + # 12 + 13 + MAINTAINERS 14 + 15 + # Documentation 16 + Documentation/* 17 + *.rst 18 + 19 + # git-specific 20 + .gitignore 21 + scripts/git.orderFile 22 + 23 + # build system 24 + Kconfig* 25 + */Kconfig* 26 + Kbuild* 27 + */Kbuild* 28 + Makefile* 29 + */Makefile* 30 + *.mak 31 + *.mk 32 + scripts/* 33 + 34 + # semantic patches 35 + *.cocci 36 + 37 + # headers 38 + *types.h 39 + *.h 40 + 41 + # code 42 + *.c
-1
scripts/head-object-list.txt
··· 17 17 arch/arm/kernel/head.o 18 18 arch/csky/kernel/head.o 19 19 arch/hexagon/kernel/head.o 20 - arch/ia64/kernel/head.o 21 20 arch/loongarch/kernel/head.o 22 21 arch/m68k/68000/head.o 23 22 arch/m68k/coldfire/head.o
+11 -3
scripts/kconfig/Makefile
··· 27 27 endif 28 28 KCONFIG_DEFCONFIG_LIST += arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG) 29 29 30 + ifneq ($(findstring c, $(KBUILD_EXTRA_WARN)),) 31 + export KCONFIG_WARN_UNKNOWN_SYMBOLS=1 32 + endif 33 + 34 + ifneq ($(findstring e, $(KBUILD_EXTRA_WARN)),) 35 + export KCONFIG_WERROR=1 36 + endif 37 + 30 38 # We need this, in case the user has it in its environment 31 39 unexport CONFIG_ 32 40 ··· 107 99 108 100 %.config: $(obj)/conf 109 101 $(if $(config-fragments),, $(error $@ fragment does not exists on this architecture)) 110 - $(Q)$(CONFIG_SHELL) $(srctree)/scripts/kconfig/merge_config.sh -m .config $(config-fragments) 102 + $(Q)$(CONFIG_SHELL) $(srctree)/scripts/kconfig/merge_config.sh -m $(KCONFIG_CONFIG) $(config-fragments) 111 103 $(Q)$(MAKE) -f $(srctree)/Makefile olddefconfig 112 104 113 105 PHONY += tinyconfig ··· 174 166 175 167 # nconf: Used for the nconfig target based on ncurses 176 168 hostprogs += nconf 177 - nconf-objs := nconf.o nconf.gui.o $(common-objs) 169 + nconf-objs := nconf.o nconf.gui.o mnconf-common.o $(common-objs) 178 170 179 171 HOSTLDLIBS_nconf = $(call read-file, $(obj)/nconf-libs) 180 172 HOSTCFLAGS_nconf.o = $(call read-file, $(obj)/nconf-cflags) ··· 187 179 hostprogs += mconf 188 180 lxdialog := $(addprefix lxdialog/, \ 189 181 checklist.o inputbox.o menubox.o textbox.o util.o yesno.o) 190 - mconf-objs := mconf.o $(lxdialog) $(common-objs) 182 + mconf-objs := mconf.o $(lxdialog) mnconf-common.o $(common-objs) 191 183 192 184 HOSTLDLIBS_mconf = $(call read-file, $(obj)/mconf-libs) 193 185 $(foreach f, mconf.o $(lxdialog), \
+6
scripts/kconfig/conf.c
··· 827 827 break; 828 828 } 829 829 830 + if (conf_errors()) 831 + exit(1); 832 + 830 833 if (sync_kconfig) { 831 834 name = getenv("KCONFIG_NOSILENTUPDATE"); 832 835 if (name && *name) { ··· 892 889 default: 893 890 break; 894 891 } 892 + 893 + if (sym_dep_errors()) 894 + exit(1); 895 895 896 896 if (input_mode == savedefconfig) { 897 897 if (conf_write_defconfig(defconfig_file)) {
+82 -87
scripts/kconfig/confdata.c
··· 155 155 static const char *conf_filename; 156 156 static int conf_lineno, conf_warnings; 157 157 158 + bool conf_errors(void) 159 + { 160 + if (conf_warnings) 161 + return getenv("KCONFIG_WERROR"); 162 + return false; 163 + } 164 + 158 165 static void conf_warning(const char *fmt, ...) 159 166 { 160 167 va_list ap; ··· 296 289 #define LINE_GROWTH 16 297 290 static int add_byte(int c, char **lineptr, size_t slen, size_t *n) 298 291 { 299 - char *nline; 300 292 size_t new_size = slen + 1; 293 + 301 294 if (new_size > *n) { 302 295 new_size += LINE_GROWTH - 1; 303 296 new_size *= 2; 304 - nline = xrealloc(*lineptr, new_size); 305 - if (!nline) 306 - return -1; 307 - 308 - *lineptr = nline; 297 + *lineptr = xrealloc(*lineptr, new_size); 309 298 *n = new_size; 310 299 } 311 300 ··· 344 341 return -1; 345 342 } 346 343 344 + /* like getline(), but the newline character is stripped away */ 345 + static ssize_t getline_stripped(char **lineptr, size_t *n, FILE *stream) 346 + { 347 + ssize_t len; 348 + 349 + len = compat_getline(lineptr, n, stream); 350 + 351 + if (len > 0 && (*lineptr)[len - 1] == '\n') { 352 + len--; 353 + (*lineptr)[len] = '\0'; 354 + 355 + if (len > 0 && (*lineptr)[len - 1] == '\r') { 356 + len--; 357 + (*lineptr)[len] = '\0'; 358 + } 359 + } 360 + 361 + return len; 362 + } 363 + 347 364 int conf_read_simple(const char *name, int def) 348 365 { 349 366 FILE *in = NULL; 350 367 char *line = NULL; 351 368 size_t line_asize = 0; 352 - char *p, *p2; 369 + char *p, *val; 353 370 struct symbol *sym; 354 371 int i, def_flags; 355 - const char *warn_unknown; 356 - const char *werror; 372 + const char *warn_unknown, *sym_name; 357 373 358 374 warn_unknown = getenv("KCONFIG_WARN_UNKNOWN_SYMBOLS"); 359 - werror = getenv("KCONFIG_WERROR"); 360 375 if (name) { 361 376 in = zconf_fopen(name); 362 377 } else { ··· 438 417 case S_INT: 439 418 case S_HEX: 440 419 case S_STRING: 441 - if (sym->def[def].val) 442 - free(sym->def[def].val); 420 + free(sym->def[def].val); 443 421 /* fall through */ 444 422 default: 445 423 sym->def[def].val = NULL; ··· 446 426 } 447 427 } 448 428 449 - while (compat_getline(&line, &line_asize, in) != -1) { 429 + while (getline_stripped(&line, &line_asize, in) != -1) { 450 430 conf_lineno++; 451 - sym = NULL; 431 + 432 + if (!line[0]) /* blank line */ 433 + continue; 434 + 452 435 if (line[0] == '#') { 453 - if (memcmp(line + 2, CONFIG_, strlen(CONFIG_))) 436 + if (line[1] != ' ') 454 437 continue; 455 - p = strchr(line + 2 + strlen(CONFIG_), ' '); 438 + p = line + 2; 439 + if (memcmp(p, CONFIG_, strlen(CONFIG_))) 440 + continue; 441 + sym_name = p + strlen(CONFIG_); 442 + p = strchr(sym_name, ' '); 456 443 if (!p) 457 444 continue; 458 445 *p++ = 0; 459 - if (strncmp(p, "is not set", 10)) 446 + if (strcmp(p, "is not set")) 460 447 continue; 461 - if (def == S_DEF_USER) { 462 - sym = sym_find(line + 2 + strlen(CONFIG_)); 463 - if (!sym) { 464 - if (warn_unknown) 465 - conf_warning("unknown symbol: %s", 466 - line + 2 + strlen(CONFIG_)); 467 448 468 - conf_set_changed(true); 469 - continue; 470 - } 471 - } else { 472 - sym = sym_lookup(line + 2 + strlen(CONFIG_), 0); 473 - if (sym->type == S_UNKNOWN) 474 - sym->type = S_BOOLEAN; 475 - } 476 - if (sym->flags & def_flags) { 477 - conf_warning("override: reassigning to symbol %s", sym->name); 478 - } 479 - switch (sym->type) { 480 - case S_BOOLEAN: 481 - case S_TRISTATE: 482 - sym->def[def].tri = no; 483 - sym->flags |= def_flags; 484 - break; 485 - default: 486 - ; 487 - } 488 - } else if (memcmp(line, CONFIG_, strlen(CONFIG_)) == 0) { 489 - p = strchr(line + strlen(CONFIG_), '='); 490 - if (!p) 491 - continue; 492 - *p++ = 0; 493 - p2 = strchr(p, '\n'); 494 - if (p2) { 495 - *p2-- = 0; 496 - if (*p2 == '\r') 497 - *p2 = 0; 498 - } 499 - 500 - sym = sym_find(line + strlen(CONFIG_)); 501 - if (!sym) { 502 - if (def == S_DEF_AUTO) { 503 - /* 504 - * Reading from include/config/auto.conf 505 - * If CONFIG_FOO previously existed in 506 - * auto.conf but it is missing now, 507 - * include/config/FOO must be touched. 508 - */ 509 - conf_touch_dep(line + strlen(CONFIG_)); 510 - } else { 511 - if (warn_unknown) 512 - conf_warning("unknown symbol: %s", 513 - line + strlen(CONFIG_)); 514 - 515 - conf_set_changed(true); 516 - } 517 - continue; 518 - } 519 - 520 - if (sym->flags & def_flags) { 521 - conf_warning("override: reassigning to symbol %s", sym->name); 522 - } 523 - if (conf_set_sym_val(sym, def, def_flags, p)) 524 - continue; 449 + val = "n"; 525 450 } else { 526 - if (line[0] != '\r' && line[0] != '\n') 527 - conf_warning("unexpected data: %.*s", 528 - (int)strcspn(line, "\r\n"), line); 451 + if (memcmp(line, CONFIG_, strlen(CONFIG_))) { 452 + conf_warning("unexpected data: %s", line); 453 + continue; 454 + } 529 455 456 + sym_name = line + strlen(CONFIG_); 457 + p = strchr(sym_name, '='); 458 + if (!p) { 459 + conf_warning("unexpected data: %s", line); 460 + continue; 461 + } 462 + *p = 0; 463 + val = p + 1; 464 + } 465 + 466 + sym = sym_find(sym_name); 467 + if (!sym) { 468 + if (def == S_DEF_AUTO) { 469 + /* 470 + * Reading from include/config/auto.conf. 471 + * If CONFIG_FOO previously existed in auto.conf 472 + * but it is missing now, include/config/FOO 473 + * must be touched. 474 + */ 475 + conf_touch_dep(sym_name); 476 + } else { 477 + if (warn_unknown) 478 + conf_warning("unknown symbol: %s", sym_name); 479 + 480 + conf_set_changed(true); 481 + } 530 482 continue; 531 483 } 484 + 485 + if (sym->flags & def_flags) 486 + conf_warning("override: reassigning to symbol %s", sym->name); 487 + 488 + if (conf_set_sym_val(sym, def, def_flags, val)) 489 + continue; 532 490 533 491 if (sym && sym_is_choice_value(sym)) { 534 492 struct symbol *cs = prop_get_symbol(sym_get_choice_prop(sym)); ··· 530 532 } 531 533 free(line); 532 534 fclose(in); 533 - 534 - if (conf_warnings && werror) 535 - exit(1); 536 535 537 536 return 0; 538 537 } ··· 589 594 /* Reset a string value if it's out of range */ 590 595 if (sym_string_within_range(sym, sym->def[S_DEF_USER].val)) 591 596 break; 592 - sym->flags &= ~(SYMBOL_VALID|SYMBOL_DEF_USER); 597 + sym->flags &= ~SYMBOL_VALID; 593 598 conf_unsaved++; 594 599 break; 595 600 default:
-1
scripts/kconfig/expr.c
··· 1131 1131 default: 1132 1132 return -1; 1133 1133 } 1134 - printf("[%dgt%d?]", t1, t2); 1135 1134 return 0; 1136 1135 } 1137 1136
-2
scripts/kconfig/lkc.h
··· 99 99 bool menu_has_prompt(struct menu *menu); 100 100 const char *menu_get_prompt(struct menu *menu); 101 101 struct menu *menu_get_parent_menu(struct menu *menu); 102 - bool menu_has_help(struct menu *menu); 103 - const char *menu_get_help(struct menu *menu); 104 102 int get_jump_key_char(void); 105 103 struct gstr get_relations_str(struct symbol **sym_arr, struct list_head *head); 106 104 void menu_get_ext_help(struct menu *menu, struct gstr *help);
+7
scripts/kconfig/lkc_proto.h
··· 1 1 /* SPDX-License-Identifier: GPL-2.0 */ 2 + #ifndef LKC_PROTO_H 3 + #define LKC_PROTO_H 4 + 2 5 #include <stdarg.h> 3 6 4 7 /* confdata.c */ ··· 15 12 bool conf_get_changed(void); 16 13 void conf_set_changed_callback(void (*fn)(void)); 17 14 void conf_set_message_callback(void (*fn)(const char *s)); 15 + bool conf_errors(void); 18 16 19 17 /* symbol.c */ 20 18 extern struct symbol * symbol_hash[SYMBOL_HASHSIZE]; ··· 26 22 struct symbol ** sym_re_search(const char *pattern); 27 23 const char * sym_type_name(enum symbol_type type); 28 24 void sym_calc_value(struct symbol *sym); 25 + bool sym_dep_errors(void); 29 26 enum symbol_type sym_get_type(struct symbol *sym); 30 27 bool sym_tristate_within_range(struct symbol *sym,tristate tri); 31 28 bool sym_set_tristate_value(struct symbol *sym,tristate tri); ··· 55 50 56 51 /* expr.c */ 57 52 void expr_print(struct expr *e, void (*fn)(void *, struct symbol *, const char *), void *data, int prevtoken); 53 + 54 + #endif /* LKC_PROTO_H */
+2 -54
scripts/kconfig/mconf.c
··· 21 21 22 22 #include "lkc.h" 23 23 #include "lxdialog/dialog.h" 24 + #include "mnconf-common.h" 24 25 25 26 static const char mconf_readme[] = 26 27 "Overview\n" ··· 248 247 " -> PCI support (PCI [=y])\n" 249 248 "(1) -> PCI access mode (<choice> [=y])\n" 250 249 " Defined at drivers/pci/Kconfig:47\n" 251 - " Depends on: X86_LOCAL_APIC && X86_IO_APIC || IA64\n" 250 + " Depends on: X86_LOCAL_APIC && X86_IO_APIC\n" 252 251 " Selects: LIBCRC32\n" 253 252 " Selected by: BAR [=n]\n" 254 253 "-----------------------------------------------------------------\n" ··· 287 286 static int show_all_options; 288 287 static int save_and_exit; 289 288 static int silent; 290 - static int jump_key_char; 291 289 292 290 static void conf(struct menu *menu, struct menu *active_menu); 293 291 ··· 376 376 377 377 show_helptext(menu_get_prompt(menu), str_get(&help)); 378 378 str_free(&help); 379 - } 380 - 381 - struct search_data { 382 - struct list_head *head; 383 - struct menu *target; 384 - }; 385 - 386 - static int next_jump_key(int key) 387 - { 388 - if (key < '1' || key > '9') 389 - return '1'; 390 - 391 - key++; 392 - 393 - if (key > '9') 394 - key = '1'; 395 - 396 - return key; 397 - } 398 - 399 - static int handle_search_keys(int key, size_t start, size_t end, void *_data) 400 - { 401 - struct search_data *data = _data; 402 - struct jump_key *pos; 403 - int index = 0; 404 - 405 - if (key < '1' || key > '9') 406 - return 0; 407 - 408 - list_for_each_entry(pos, data->head, entries) { 409 - index = next_jump_key(index); 410 - 411 - if (pos->offset < start) 412 - continue; 413 - 414 - if (pos->offset >= end) 415 - break; 416 - 417 - if (key == index) { 418 - data->target = pos->target; 419 - return 1; 420 - } 421 - } 422 - 423 - return 0; 424 - } 425 - 426 - int get_jump_key_char(void) 427 - { 428 - jump_key_char = next_jump_key(jump_key_char); 429 - 430 - return jump_key_char; 431 379 } 432 380 433 381 static void search_conf(void)
+2 -15
scripts/kconfig/menu.c
··· 673 673 return menu; 674 674 } 675 675 676 - bool menu_has_help(struct menu *menu) 677 - { 678 - return menu->help != NULL; 679 - } 680 - 681 - const char *menu_get_help(struct menu *menu) 682 - { 683 - if (menu->help) 684 - return menu->help; 685 - else 686 - return ""; 687 - } 688 - 689 676 static void get_def_str(struct gstr *r, struct menu *menu) 690 677 { 691 678 str_printf(r, "Defined at %s:%d\n", ··· 843 856 struct symbol *sym = menu->sym; 844 857 const char *help_text = nohelp_text; 845 858 846 - if (menu_has_help(menu)) { 859 + if (menu->help) { 847 860 if (sym->name) 848 861 str_printf(help, "%s%s:\n\n", CONFIG_, sym->name); 849 - help_text = menu_get_help(menu); 862 + help_text = menu->help; 850 863 } 851 864 str_printf(help, "%s\n", help_text); 852 865 if (sym)
+53
scripts/kconfig/mnconf-common.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-only 2 + #include "expr.h" 3 + #include "list.h" 4 + #include "mnconf-common.h" 5 + 6 + int jump_key_char; 7 + 8 + int next_jump_key(int key) 9 + { 10 + if (key < '1' || key > '9') 11 + return '1'; 12 + 13 + key++; 14 + 15 + if (key > '9') 16 + key = '1'; 17 + 18 + return key; 19 + } 20 + 21 + int handle_search_keys(int key, size_t start, size_t end, void *_data) 22 + { 23 + struct search_data *data = _data; 24 + struct jump_key *pos; 25 + int index = 0; 26 + 27 + if (key < '1' || key > '9') 28 + return 0; 29 + 30 + list_for_each_entry(pos, data->head, entries) { 31 + index = next_jump_key(index); 32 + 33 + if (pos->offset < start) 34 + continue; 35 + 36 + if (pos->offset >= end) 37 + break; 38 + 39 + if (key == index) { 40 + data->target = pos->target; 41 + return 1; 42 + } 43 + } 44 + 45 + return 0; 46 + } 47 + 48 + int get_jump_key_char(void) 49 + { 50 + jump_key_char = next_jump_key(jump_key_char); 51 + 52 + return jump_key_char; 53 + }
+18
scripts/kconfig/mnconf-common.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0-only */ 2 + #ifndef MNCONF_COMMON_H 3 + #define MNCONF_COMMON_H 4 + 5 + #include <stddef.h> 6 + 7 + struct search_data { 8 + struct list_head *head; 9 + struct menu *target; 10 + }; 11 + 12 + extern int jump_key_char; 13 + 14 + int next_jump_key(int key); 15 + int handle_search_keys(int key, size_t start, size_t end, void *_data); 16 + int get_jump_key_char(void); 17 + 18 + #endif /* MNCONF_COMMON_H */
+2 -53
scripts/kconfig/nconf.c
··· 12 12 #include <stdlib.h> 13 13 14 14 #include "lkc.h" 15 + #include "mnconf-common.h" 15 16 #include "nconf.h" 16 17 #include <ctype.h> 17 18 ··· 217 216 "Symbol: FOO [ = m]\n" 218 217 "Prompt: Foo bus is used to drive the bar HW\n" 219 218 "Defined at drivers/pci/Kconfig:47\n" 220 - "Depends on: X86_LOCAL_APIC && X86_IO_APIC || IA64\n" 219 + "Depends on: X86_LOCAL_APIC && X86_IO_APIC\n" 221 220 "Location:\n" 222 221 " -> Bus options (PCI, PCMCIA, EISA, ISA)\n" 223 222 " -> PCI support (PCI [ = y])\n" ··· 280 279 281 280 static char *dialog_input_result; 282 281 static int dialog_input_result_len; 283 - static int jump_key_char; 284 282 285 283 static void selected_conf(struct menu *menu, struct menu *active_menu); 286 284 static void conf(struct menu *menu); ··· 691 691 return 0; 692 692 } 693 693 694 - struct search_data { 695 - struct list_head *head; 696 - struct menu *target; 697 - }; 698 - 699 - static int next_jump_key(int key) 700 - { 701 - if (key < '1' || key > '9') 702 - return '1'; 703 - 704 - key++; 705 - 706 - if (key > '9') 707 - key = '1'; 708 - 709 - return key; 710 - } 711 - 712 - static int handle_search_keys(int key, size_t start, size_t end, void *_data) 713 - { 714 - struct search_data *data = _data; 715 - struct jump_key *pos; 716 - int index = 0; 717 - 718 - if (key < '1' || key > '9') 719 - return 0; 720 - 721 - list_for_each_entry(pos, data->head, entries) { 722 - index = next_jump_key(index); 723 - 724 - if (pos->offset < start) 725 - continue; 726 - 727 - if (pos->offset >= end) 728 - break; 729 - 730 - if (key == index) { 731 - data->target = pos->target; 732 - return 1; 733 - } 734 - } 735 - 736 - return 0; 737 - } 738 - 739 - int get_jump_key_char(void) 740 - { 741 - jump_key_char = next_jump_key(jump_key_char); 742 - 743 - return jump_key_char; 744 - } 745 694 746 695 static void search_conf(void) 747 696 {
+23 -14
scripts/kconfig/symbol.c
··· 29 29 .flags = SYMBOL_CONST|SYMBOL_VALID, 30 30 }; 31 31 32 - static struct symbol symbol_empty = { 33 - .name = "", 34 - .curr = { "", no }, 35 - .flags = SYMBOL_VALID, 36 - }; 37 - 38 32 struct symbol *modules_sym; 39 33 static tristate modules_val; 34 + static int sym_warnings; 40 35 41 36 enum symbol_type sym_get_type(struct symbol *sym) 42 37 { ··· 312 317 " Selected by [m]:\n"); 313 318 314 319 fputs(str_get(&gs), stderr); 320 + sym_warnings++; 321 + } 322 + 323 + bool sym_dep_errors(void) 324 + { 325 + if (sym_warnings) 326 + return getenv("KCONFIG_WERROR"); 327 + return false; 315 328 } 316 329 317 330 void sym_calc_value(struct symbol *sym) ··· 347 344 348 345 switch (sym->type) { 349 346 case S_INT: 347 + newval.val = "0"; 348 + break; 350 349 case S_HEX: 350 + newval.val = "0x0"; 351 + break; 351 352 case S_STRING: 352 - newval = symbol_empty.curr; 353 + newval.val = ""; 353 354 break; 354 355 case S_BOOLEAN: 355 356 case S_TRISTATE: ··· 704 697 { 705 698 struct property *prop; 706 699 struct symbol *ds; 707 - const char *str; 700 + const char *str = ""; 708 701 tristate val; 709 702 710 703 sym_calc_visibility(sym); 711 704 sym_calc_value(modules_sym); 712 705 val = symbol_no.curr.tri; 713 - str = symbol_empty.curr.val; 714 706 715 707 /* If symbol has a default value look it up */ 716 708 prop = sym_get_default_prop(sym); ··· 759 753 case yes: return "y"; 760 754 } 761 755 case S_INT: 756 + if (!str[0]) 757 + str = "0"; 758 + break; 762 759 case S_HEX: 763 - return str; 764 - case S_STRING: 765 - return str; 766 - case S_UNKNOWN: 760 + if (!str[0]) 761 + str = "0x0"; 762 + break; 763 + default: 767 764 break; 768 765 } 769 - return ""; 766 + return str; 770 767 } 771 768 772 769 const char *sym_get_string_value(struct symbol *sym)
+1 -2
scripts/kconfig/util.c
··· 42 42 /* Free storage for growable string */ 43 43 void str_free(struct gstr *gs) 44 44 { 45 - if (gs->s) 46 - free(gs->s); 45 + free(gs->s); 47 46 gs->s = NULL; 48 47 gs->len = 0; 49 48 }
+8 -9
scripts/mod/modpost.c
··· 60 60 61 61 #define MODULE_NAME_LEN (64 - sizeof(Elf_Addr)) 62 62 63 - void __attribute__((format(printf, 2, 3))) 64 - modpost_log(enum loglevel loglevel, const char *fmt, ...) 63 + void modpost_log(enum loglevel loglevel, const char *fmt, ...) 65 64 { 66 65 va_list arglist; 67 66 ··· 89 90 if (loglevel == LOG_ERROR) 90 91 error_occurred = true; 91 92 } 93 + 94 + void __attribute__((alias("modpost_log"))) 95 + modpost_log_noret(enum loglevel loglevel, const char *fmt, ...); 92 96 93 97 static inline bool strends(const char *str, const char *postfix) 94 98 { ··· 476 474 fatal("%s: not relocatable object.", filename); 477 475 478 476 /* Check if file offset is correct */ 479 - if (hdr->e_shoff > info->size) { 477 + if (hdr->e_shoff > info->size) 480 478 fatal("section header offset=%lu in file '%s' is bigger than filesize=%zu\n", 481 479 (unsigned long)hdr->e_shoff, filename, info->size); 482 - return 0; 483 - } 484 480 485 481 if (hdr->e_shnum == SHN_UNDEF) { 486 482 /* ··· 516 516 const char *secname; 517 517 int nobits = sechdrs[i].sh_type == SHT_NOBITS; 518 518 519 - if (!nobits && sechdrs[i].sh_offset > info->size) { 519 + if (!nobits && sechdrs[i].sh_offset > info->size) 520 520 fatal("%s is truncated. sechdrs[i].sh_offset=%lu > sizeof(*hrd)=%zu\n", 521 521 filename, (unsigned long)sechdrs[i].sh_offset, 522 522 sizeof(*hdr)); 523 - return 0; 524 - } 523 + 525 524 secname = secstrings + sechdrs[i].sh_name; 526 525 if (strcmp(secname, ".modinfo") == 0) { 527 526 if (nobits) ··· 1418 1419 1419 1420 for (rel = start; rel < stop; rel++) { 1420 1421 Elf_Sym *tsym; 1421 - Elf_Addr taddr = 0, r_offset; 1422 + Elf_Addr taddr, r_offset; 1422 1423 unsigned int r_type, r_sym; 1423 1424 void *loc; 1424 1425
+6 -2
scripts/mod/modpost.h
··· 197 197 LOG_FATAL 198 198 }; 199 199 200 - void modpost_log(enum loglevel loglevel, const char *fmt, ...); 200 + void __attribute__((format(printf, 2, 3))) 201 + modpost_log(enum loglevel loglevel, const char *fmt, ...); 202 + 203 + void __attribute__((format(printf, 2, 3), noreturn)) 204 + modpost_log_noret(enum loglevel loglevel, const char *fmt, ...); 201 205 202 206 /* 203 207 * warn - show the given message, then let modpost continue running, still ··· 218 214 */ 219 215 #define warn(fmt, args...) modpost_log(LOG_WARN, fmt, ##args) 220 216 #define error(fmt, args...) modpost_log(LOG_ERROR, fmt, ##args) 221 - #define fatal(fmt, args...) modpost_log(LOG_FATAL, fmt, ##args) 217 + #define fatal(fmt, args...) modpost_log_noret(LOG_FATAL, fmt, ##args)
+33 -71
scripts/package/builddeb
··· 25 25 } 26 26 27 27 create_package() { 28 - local pname="$1" pdir="$2" 29 - local dpkg_deb_opts 28 + export DH_OPTIONS="-p${1}" 30 29 31 - mkdir -m 755 -p "$pdir/DEBIAN" 32 - mkdir -p "$pdir/usr/share/doc/$pname" 33 - cp debian/copyright "$pdir/usr/share/doc/$pname/" 34 - cp debian/changelog "$pdir/usr/share/doc/$pname/changelog.Debian" 35 - gzip -n -9 "$pdir/usr/share/doc/$pname/changelog.Debian" 36 - sh -c "cd '$pdir'; find . -type f ! -path './DEBIAN/*' -printf '%P\0' \ 37 - | xargs -r0 md5sum > DEBIAN/md5sums" 38 - 39 - # Fix ownership and permissions 40 - if [ "$DEB_RULES_REQUIRES_ROOT" = "no" ]; then 41 - dpkg_deb_opts="--root-owner-group" 42 - else 43 - chown -R root:root "$pdir" 44 - fi 45 - # a+rX in case we are in a restrictive umask environment like 0077 46 - # ug-s in case we build in a setuid/setgid directory 47 - chmod -R go-w,a+rX,ug-s "$pdir" 48 - 49 - # Create the package 50 - dpkg-gencontrol -p$pname -P"$pdir" 51 - dpkg-deb $dpkg_deb_opts ${KDEB_COMPRESS:+-Z$KDEB_COMPRESS} --build "$pdir" .. 30 + dh_installdocs 31 + dh_installchangelogs 32 + dh_compress 33 + dh_fixperms 34 + dh_gencontrol 35 + dh_md5sums 36 + dh_builddeb -- ${KDEB_COMPRESS:+-Z$KDEB_COMPRESS} 52 37 } 53 38 54 39 install_linux_image () { 55 - pdir=$1 56 - pname=$2 40 + pname=$1 41 + pdir=debian/$1 57 42 58 43 rm -rf ${pdir} 59 44 ··· 47 62 ${MAKE} -f ${srctree}/Makefile INSTALL_DTBS_PATH="${pdir}/usr/lib/linux-image-${KERNELRELEASE}" dtbs_install 48 63 fi 49 64 50 - ${MAKE} -f ${srctree}/Makefile INSTALL_MOD_PATH="${pdir}" modules_install 65 + ${MAKE} -f ${srctree}/Makefile INSTALL_MOD_PATH="${pdir}" INSTALL_MOD_STRIP=1 modules_install 51 66 rm -f "${pdir}/lib/modules/${KERNELRELEASE}/build" 52 67 53 68 # Install the kernel ··· 107 122 } 108 123 109 124 install_linux_image_dbg () { 110 - pdir=$1 111 - image_pdir=$2 125 + pdir=debian/$1 112 126 113 127 rm -rf ${pdir} 114 128 115 - for module in $(find ${image_pdir}/lib/modules/ -name *.ko -printf '%P\n'); do 116 - module=lib/modules/${module} 117 - mkdir -p $(dirname ${pdir}/usr/lib/debug/${module}) 118 - # only keep debug symbols in the debug file 119 - ${OBJCOPY} --only-keep-debug ${image_pdir}/${module} ${pdir}/usr/lib/debug/${module} 120 - # strip original module from debug symbols 121 - ${OBJCOPY} --strip-debug ${image_pdir}/${module} 122 - # then add a link to those 123 - ${OBJCOPY} --add-gnu-debuglink=${pdir}/usr/lib/debug/${module} ${image_pdir}/${module} 124 - done 129 + # Parse modules.order directly because 'make modules_install' may sign, 130 + # compress modules, and then run unneeded depmod. 131 + while read -r mod; do 132 + mod="${mod%.o}.ko" 133 + dbg="${pdir}/usr/lib/debug/lib/modules/${KERNELRELEASE}/kernel/${mod}" 134 + buildid=$("${READELF}" -n "${mod}" | sed -n 's@^.*Build ID: \(..\)\(.*\)@\1/\2@p') 135 + link="${pdir}/usr/lib/debug/.build-id/${buildid}.debug" 125 136 126 - # re-sign stripped modules 127 - if is_enabled CONFIG_MODULE_SIG_ALL; then 128 - ${MAKE} -f ${srctree}/Makefile INSTALL_MOD_PATH="${image_pdir}" modules_sign 129 - fi 137 + mkdir -p "${dbg%/*}" "${link%/*}" 138 + "${OBJCOPY}" --only-keep-debug "${mod}" "${dbg}" 139 + ln -sf --relative "${dbg}" "${link}" 140 + done < modules.order 130 141 131 142 # Build debug package 132 143 # Different tools want the image in different locations ··· 137 156 } 138 157 139 158 install_kernel_headers () { 140 - pdir=$1 141 - version=$2 159 + pdir=debian/$1 160 + version=${1#linux-headers-} 142 161 143 162 rm -rf $pdir 144 163 ··· 149 168 } 150 169 151 170 install_libc_headers () { 152 - pdir=$1 171 + pdir=debian/$1 153 172 154 173 rm -rf $pdir 155 174 156 - $MAKE -f $srctree/Makefile headers 157 175 $MAKE -f $srctree/Makefile headers_install INSTALL_HDR_PATH=$pdir/usr 158 176 159 177 # move asm headers to /usr/include/<libc-machine>/asm to match the structure 160 178 # used by Debian-based distros (to support multi-arch) 161 - host_arch=$(dpkg-architecture -a$DEB_HOST_ARCH -qDEB_HOST_MULTIARCH) 162 - mkdir $pdir/usr/include/$host_arch 163 - mv $pdir/usr/include/asm $pdir/usr/include/$host_arch/ 179 + mkdir "$pdir/usr/include/${DEB_HOST_MULTIARCH}" 180 + mv "$pdir/usr/include/asm" "$pdir/usr/include/${DEB_HOST_MULTIARCH}" 164 181 } 165 182 166 183 rm -f debian/files ··· 169 190 do 170 191 case ${package} in 171 192 *-dbg) 172 - # This must be done after linux-image, that is, we expect the 173 - # debug package appears after linux-image in debian/control. 174 - install_linux_image_dbg debian/linux-image-dbg debian/linux-image;; 193 + install_linux_image_dbg "${package}";; 175 194 linux-image-*|user-mode-linux-*) 176 - install_linux_image debian/linux-image ${package};; 195 + install_linux_image "${package}";; 177 196 linux-libc-dev) 178 - install_libc_headers debian/linux-libc-dev;; 197 + install_libc_headers "${package}";; 179 198 linux-headers-*) 180 - install_kernel_headers debian/linux-headers ${package#linux-headers-};; 199 + install_kernel_headers "${package}";; 181 200 esac 201 + create_package "${package}" 182 202 done 183 - 184 - for package in ${packages_enabled} 185 - do 186 - case ${package} in 187 - *-dbg) 188 - create_package ${package} debian/linux-image-dbg;; 189 - linux-image-*|user-mode-linux-*) 190 - create_package ${package} debian/linux-image;; 191 - linux-libc-dev) 192 - create_package ${package} debian/linux-libc-dev;; 193 - linux-headers-*) 194 - create_package ${package} debian/linux-headers;; 195 - esac 196 - done 197 - 198 - exit 0
+2 -6
scripts/package/buildtar
··· 23 23 # 24 24 rm -rf -- "${tmpdir}" 25 25 mkdir -p -- "${tmpdir}/boot" 26 - dirs=boot 27 26 28 27 29 28 # ··· 37 38 38 39 39 40 # 40 - # Try to install modules 41 + # Install modules 41 42 # 42 - if grep -q '^CONFIG_MODULES=y' include/config/auto.conf; then 43 - make ARCH="${ARCH}" -f ${srctree}/Makefile INSTALL_MOD_PATH="${tmpdir}" modules_install 44 - dirs="$dirs lib" 45 - fi 43 + make ARCH="${ARCH}" -f ${srctree}/Makefile INSTALL_MOD_PATH="${tmpdir}" modules_install 46 44 47 45 48 46 #
-14
scripts/package/deb-build-option
··· 1 - #!/bin/sh 2 - # SPDX-License-Identifier: GPL-2.0-only 3 - 4 - # Set up CROSS_COMPILE if not defined yet 5 - if [ "${CROSS_COMPILE+set}" != "set" -a "${DEB_HOST_ARCH}" != "${DEB_BUILD_ARCH}" ]; then 6 - echo CROSS_COMPILE=${DEB_HOST_GNU_TYPE}- 7 - fi 8 - 9 - version=$(dpkg-parsechangelog -S Version) 10 - debian_revision="${version##*-}" 11 - 12 - if [ "${version}" != "${debian_revision}" ]; then 13 - echo KBUILD_BUILD_VERSION=${debian_revision} 14 - fi
+16
scripts/package/debian/copyright
··· 1 + This is a packaged upstream version of the Linux kernel. 2 + 3 + The sources may be found at most Linux archive sites, including: 4 + https://www.kernel.org/pub/linux/kernel 5 + 6 + Copyright: 1991 - 2023 Linus Torvalds and others. 7 + 8 + The git repository for mainline kernel development is at: 9 + git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 10 + 11 + This program is free software; you can redistribute it and/or modify 12 + it under the terms of the GNU General Public License as published by 13 + the Free Software Foundation; version 2 dated June, 1991. 14 + 15 + On Debian GNU/Linux systems, the complete text of the GNU General Public 16 + License version 2 can be found in `/usr/share/common-licenses/GPL-2'.
+24 -11
scripts/package/debian/rules
··· 1 1 #!/usr/bin/make -f 2 2 # SPDX-License-Identifier: GPL-2.0-only 3 3 4 - include debian/rules.vars 4 + # in case debian/rules is executed directly 5 + export DEB_RULES_REQUIRES_ROOT := no 5 6 6 - srctree ?= . 7 + include debian/rules.vars 7 8 8 9 ifneq (,$(filter-out parallel=1,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))) 9 10 NUMJOBS = $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS))) 10 11 MAKEFLAGS += -j$(NUMJOBS) 11 12 endif 12 13 14 + revision = $(lastword $(subst -, ,$(shell dpkg-parsechangelog -S Version))) 15 + CROSS_COMPILE ?= $(filter-out $(DEB_BUILD_GNU_TYPE)-, $(DEB_HOST_GNU_TYPE)-) 16 + make-opts = ARCH=$(ARCH) KERNELRELEASE=$(KERNELRELEASE) KBUILD_BUILD_VERSION=$(revision) $(addprefix CROSS_COMPILE=,$(CROSS_COMPILE)) 17 + 13 18 .PHONY: binary binary-indep binary-arch 14 19 binary: binary-arch binary-indep 15 20 binary-indep: build-indep 16 21 binary-arch: build-arch 17 - $(MAKE) -f $(srctree)/Makefile ARCH=$(ARCH) \ 18 - KERNELRELEASE=$(KERNELRELEASE) \ 19 - run-command KBUILD_RUN_COMMAND=+$(srctree)/scripts/package/builddeb 22 + $(MAKE) $(make-opts) \ 23 + run-command KBUILD_RUN_COMMAND='+$$(srctree)/scripts/package/builddeb' 20 24 21 25 .PHONY: build build-indep build-arch 22 26 build: build-arch build-indep 23 27 build-indep: 24 28 build-arch: 25 - $(MAKE) -f $(srctree)/Makefile ARCH=$(ARCH) \ 26 - KERNELRELEASE=$(KERNELRELEASE) \ 27 - $(shell $(srctree)/scripts/package/deb-build-option) \ 28 - olddefconfig all 29 + $(MAKE) $(make-opts) olddefconfig 30 + $(MAKE) $(make-opts) $(if $(filter um,$(ARCH)),,headers) all 29 31 30 32 .PHONY: clean 31 33 clean: 32 - rm -rf debian/files debian/linux-* 33 - $(MAKE) -f $(srctree)/Makefile ARCH=$(ARCH) clean 34 + rm -rf debian/files debian/linux-* debian/deb-env.vars* 35 + $(MAKE) ARCH=$(ARCH) clean 36 + 37 + # If DEB_HOST_ARCH is empty, it is likely that debian/rules was executed 38 + # directly. Run 'dpkg-architecture --print-set --print-format=make' to 39 + # generate a makefile construct that exports all DEB_* variables. 40 + ifndef DEB_HOST_ARCH 41 + include debian/deb-env.vars 42 + 43 + debian/deb-env.vars: 44 + dpkg-architecture -a$$(cat debian/arch) --print-set --print-format=make > $@.tmp 45 + mv $@.tmp $@ 46 + endif
+1 -1
scripts/package/install-extmod-build
··· 20 20 find "arch/${SRCARCH}" -maxdepth 1 -name 'Makefile*' 21 21 find include scripts -type f -o -type l 22 22 find "arch/${SRCARCH}" -name Kbuild.platforms -o -name Platform 23 - find "arch/${SRCARCH}" -name include -o -name scripts -type d 23 + find "arch/${SRCARCH}" -name include -type d 24 24 ) | tar -c -f - -C "${srctree}" -T - | tar -xf - -C "${destdir}" 25 25 26 26 {
-6
scripts/package/kernel.spec
··· 56 56 57 57 %install 58 58 mkdir -p %{buildroot}/boot 59 - %ifarch ia64 60 - mkdir -p %{buildroot}/boot/efi 61 - cp $(%{make} %{makeflags} -s image_name) %{buildroot}/boot/efi/vmlinuz-%{KERNELRELEASE} 62 - ln -s efi/vmlinuz-%{KERNELRELEASE} %{buildroot}/boot/ 63 - %else 64 59 cp $(%{make} %{makeflags} -s image_name) %{buildroot}/boot/vmlinuz-%{KERNELRELEASE} 65 - %endif 66 60 %{make} %{makeflags} INSTALL_MOD_PATH=%{buildroot} modules_install 67 61 %{make} %{makeflags} INSTALL_HDR_PATH=%{buildroot}/usr headers_install 68 62 cp System.map %{buildroot}/boot/System.map-%{KERNELRELEASE}
+4 -24
scripts/package/mkdebian
··· 26 26 27 27 # Attempt to find the correct Debian architecture 28 28 case "$UTS_MACHINE" in 29 - i386|ia64|alpha|m68k|riscv*) 29 + i386|alpha|m68k|riscv*) 30 30 debarch="$UTS_MACHINE" ;; 31 31 x86_64) 32 32 debarch=amd64 ;; ··· 176 176 fi 177 177 178 178 echo $debarch > debian/arch 179 - extra_build_depends=", $(if_enabled_echo CONFIG_UNWINDER_ORC libelf-dev:native)" 180 - extra_build_depends="$extra_build_depends, $(if_enabled_echo CONFIG_SYSTEM_TRUSTED_KEYRING libssl-dev:native)" 181 179 182 180 # Generate a simple changelog template 183 181 cat <<EOF > debian/changelog ··· 186 188 -- $maintainer $(date -R) 187 189 EOF 188 190 189 - # Generate copyright file 190 - cat <<EOF > debian/copyright 191 - This is a packaged upstream version of the Linux kernel. 192 - 193 - The sources may be found at most Linux archive sites, including: 194 - https://www.kernel.org/pub/linux/kernel 195 - 196 - Copyright: 1991 - 2018 Linus Torvalds and others. 197 - 198 - The git repository for mainline kernel development is at: 199 - git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 200 - 201 - This program is free software; you can redistribute it and/or modify 202 - it under the terms of the GNU General Public License as published by 203 - the Free Software Foundation; version 2 dated June, 1991. 204 - 205 - On Debian GNU/Linux systems, the complete text of the GNU General Public 206 - License version 2 can be found in \`/usr/share/common-licenses/GPL-2'. 207 - EOF 208 - 209 191 # Generate a control file 210 192 cat <<EOF > debian/control 211 193 Source: $sourcename ··· 193 215 Priority: optional 194 216 Maintainer: $maintainer 195 217 Rules-Requires-Root: no 196 - Build-Depends: bc, debhelper, rsync, kmod, cpio, bison, flex $extra_build_depends 218 + Build-Depends: debhelper-compat (= 12) 219 + Build-Depends-Arch: bc, bison, cpio, flex, kmod, libelf-dev:native, libssl-dev:native, rsync 197 220 Homepage: https://www.kernel.org/ 198 221 199 222 Package: $packagename-$version ··· 247 268 KERNELRELEASE := ${KERNELRELEASE} 248 269 EOF 249 270 271 + cp "${srctree}/scripts/package/debian/copyright" debian/ 250 272 cp "${srctree}/scripts/package/debian/rules" debian/ 251 273 252 274 exit 0
+1 -1
scripts/package/snapcraft.template
··· 10 10 kernel: 11 11 plugin: kernel 12 12 source: SRCTREE 13 - source-type: tar 13 + source-type: local 14 14 kernel-with-firmware: false
-1
scripts/recordmcount.c
··· 590 590 ideal_nop = ideal_nop4_arm64; 591 591 is_fake_mcount64 = arm64_is_fake_mcount; 592 592 break; 593 - case EM_IA_64: reltype = R_IA64_IMM64; break; 594 593 case EM_MIPS: /* reltype: e_class */ break; 595 594 case EM_LOONGARCH: /* reltype: e_class */ break; 596 595 case EM_PPC: reltype = R_PPC_ADDR32; break;
-7
scripts/recordmcount.pl
··· 275 275 $section_type = '%progbits'; 276 276 $mcount_regex = "^\\s*([0-9a-fA-F]+):\\s*R_AARCH64_CALL26\\s+_mcount\$"; 277 277 $type = ".quad"; 278 - } elsif ($arch eq "ia64") { 279 - $mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\s_mcount\$"; 280 - $type = "data8"; 281 - 282 - if ($is_module eq "0") { 283 - $cc .= " -mconstant-gp"; 284 - } 285 278 } elsif ($arch eq "sparc64") { 286 279 # In the objdump output there are giblets like: 287 280 # 0000000000000000 <igmp_net_exit-0x18>:
-1
scripts/xz_wrap.sh
··· 15 15 case $SRCARCH in 16 16 x86) BCJ=--x86 ;; 17 17 powerpc) BCJ=--powerpc ;; 18 - ia64) BCJ=--ia64; LZMA2OPTS=pb=4 ;; 19 18 arm) BCJ=--arm ;; 20 19 sparc) BCJ=--sparc ;; 21 20 esac
+21 -12
usr/gen_init_cpio.c
··· 27 27 static unsigned int offset; 28 28 static unsigned int ino = 721; 29 29 static time_t default_mtime; 30 + static bool do_file_mtime; 30 31 static bool do_csum = false; 31 32 32 33 struct file_handler { ··· 330 329 int file; 331 330 int retval; 332 331 int rc = -1; 332 + time_t mtime; 333 333 int namesize; 334 334 unsigned int i; 335 335 uint32_t csum = 0; ··· 349 347 goto error; 350 348 } 351 349 352 - if (buf.st_mtime > 0xffffffff) { 353 - fprintf(stderr, "%s: Timestamp exceeds maximum cpio timestamp, clipping.\n", 354 - location); 355 - buf.st_mtime = 0xffffffff; 356 - } 350 + if (do_file_mtime) { 351 + mtime = default_mtime; 352 + } else { 353 + mtime = buf.st_mtime; 354 + if (mtime > 0xffffffff) { 355 + fprintf(stderr, "%s: Timestamp exceeds maximum cpio timestamp, clipping.\n", 356 + location); 357 + mtime = 0xffffffff; 358 + } 357 359 358 - if (buf.st_mtime < 0) { 359 - fprintf(stderr, "%s: Timestamp negative, clipping.\n", 360 - location); 361 - buf.st_mtime = 0; 360 + if (mtime < 0) { 361 + fprintf(stderr, "%s: Timestamp negative, clipping.\n", 362 + location); 363 + mtime = 0; 364 + } 362 365 } 363 366 364 367 if (buf.st_size > 0xffffffff) { ··· 394 387 (long) uid, /* uid */ 395 388 (long) gid, /* gid */ 396 389 nlinks, /* nlink */ 397 - (long) buf.st_mtime, /* mtime */ 390 + (long) mtime, /* mtime */ 398 391 size, /* filesize */ 399 392 3, /* major */ 400 393 1, /* minor */ ··· 543 536 "file /sbin/kinit /usr/src/klibc/kinit/kinit 0755 0 0\n" 544 537 "\n" 545 538 "<timestamp> is time in seconds since Epoch that will be used\n" 546 - "as mtime for symlinks, special files and directories. The default\n" 547 - "is to use the current time for these entries.\n" 539 + "as mtime for symlinks, directories, regular and special files.\n" 540 + "The default is to use the current time for all files, but\n" 541 + "preserve modification time for regular files.\n" 548 542 "-c: calculate and store 32-bit checksums for file data.\n", 549 543 prog); 550 544 } ··· 602 594 usage(argv[0]); 603 595 exit(1); 604 596 } 597 + do_file_mtime = true; 605 598 break; 606 599 case 'c': 607 600 do_csum = true;