diff options
Diffstat (limited to 'libc')
122 files changed, 1821 insertions, 1898 deletions
diff --git a/libc/Android.bp b/libc/Android.bp index 85e2ff0a8..4c3663589 100644 --- a/libc/Android.bp +++ b/libc/Android.bp @@ -777,6 +777,7 @@ cc_library_static { "bionic/android_set_abort_message.cpp", "bionic/strchr.cpp", + "bionic/strchrnul.cpp", "bionic/strnlen.c", "bionic/strrchr.cpp", ], @@ -837,25 +838,17 @@ cc_library_static { }, arm64: { srcs: [ - "arch-arm64/generic/bionic/memcmp.S", "arch-arm64/generic/bionic/memcpy.S", "arch-arm64/generic/bionic/memmove.S", "arch-arm64/generic/bionic/memset.S", - "arch-arm64/generic/bionic/stpcpy.S", - "arch-arm64/generic/bionic/strcpy.S", "arch-arm64/generic/bionic/wmemmove.S", - "arch-arm64/default/bionic/memchr.S", - "arch-arm64/default/bionic/strchr.S", - "arch-arm64/default/bionic/strcmp.S", - "arch-arm64/default/bionic/strlen.S", - "arch-arm64/default/bionic/strncmp.S", - "arch-arm64/default/bionic/strnlen.S", - "arch-arm64/mte/bionic/memchr.c", - "arch-arm64/mte/bionic/strchr.cpp", + "arch-arm64/mte/bionic/stpcpy.S", + "arch-arm64/mte/bionic/strchrnul.cpp", + "arch-arm64/mte/bionic/strrchr.cpp", "arch-arm64/mte/bionic/strcmp.c", - "arch-arm64/mte/bionic/strlen.c", + "arch-arm64/mte/bionic/strcpy.S", "arch-arm64/mte/bionic/strncmp.c", "arch-arm64/mte/bionic/strnlen.c", @@ -868,7 +861,9 @@ cc_library_static { exclude_srcs: [ "bionic/__memcpy_chk.cpp", "bionic/strchr.cpp", + "bionic/strchrnul.cpp", "bionic/strnlen.c", + "bionic/strrchr.cpp", ], }, @@ -911,6 +906,7 @@ cc_library_static { "arch-x86/bionic/setjmp.S", "arch-x86/bionic/syscall.S", "arch-x86/bionic/vfork.S", + "arch-x86/bionic/__x86.get_pc_thunk.S", // ssse3 functions "arch-x86/atom/string/ssse3-strcat-atom.S", @@ -1121,7 +1117,6 @@ cc_library_static { "bionic/spawn.cpp", "bionic/stat.cpp", "bionic/stdlib_l.cpp", - "bionic/strchrnul.cpp", "bionic/strerror.cpp", "bionic/string_l.cpp", "bionic/strings_l.cpp", @@ -1358,6 +1353,7 @@ cc_library_static { whole_static_libs: [ "gwp_asan", + "libarm-optimized-routines-string", "libc_bionic_ndk", "libc_bootstrap", "libc_fortify", @@ -1388,6 +1384,7 @@ cc_library_static { name: "libc_nopthread", whole_static_libs: [ + "libarm-optimized-routines-string", "libc_bionic", "libc_bionic_ndk", "libc_bootstrap", @@ -1643,6 +1640,8 @@ cc_library { srcs: [":libc_sources_shared_arm"], // special for arm cflags: ["-DCRT_LEGACY_WORKAROUND"], + + whole_static_libs: [ "libunwind_llvm" ], }, // Arm 32 bit does not produce complete exidx unwind information @@ -1652,8 +1651,6 @@ cc_library { strip: { keep_symbols_and_debug_frame: true, }, - - whole_static_libs: [ "libunwind_llvm" ], }, arm64: { version_script: ":libc.arm64.map", @@ -1664,7 +1661,9 @@ cc_library { keep_symbols: true, }, - whole_static_libs: [ "libgcc_stripped" ], + shared: { + whole_static_libs: [ "libgcc_stripped" ], + }, }, x86: { // TODO: This is to work around b/24465209. Remove after root cause is fixed. @@ -1679,7 +1678,9 @@ cc_library { keep_symbols: true, }, - whole_static_libs: [ "libgcc_stripped" ], + shared: { + whole_static_libs: [ "libgcc_stripped" ], + }, }, x86_64: { version_script: ":libc.x86_64.map", @@ -1690,7 +1691,9 @@ cc_library { keep_symbols: true, }, - whole_static_libs: [ "libgcc_stripped" ], + shared: { + whole_static_libs: [ "libgcc_stripped" ], + }, }, }, @@ -1748,6 +1751,7 @@ genrule { // Headers that only other parts of the platform can include. cc_library_headers { name: "bionic_libc_platform_headers", + defaults: ["linux_bionic_supported"], visibility: [ "//art:__subpackages__", "//bionic:__subpackages__", @@ -1756,9 +1760,9 @@ cc_library_headers { "//external/perfetto:__subpackages__", "//external/scudo:__subpackages__", "//system/core/debuggerd:__subpackages__", + "//system/core/libunwindstack:__subpackages__", "//system/memory/libmemunreachable:__subpackages__", ], - host_supported: true, vendor_available: true, ramdisk_available: true, recovery_available: true, diff --git a/libc/NOTICE b/libc/NOTICE index 8245ff890..85820540e 100644 --- a/libc/NOTICE +++ b/libc/NOTICE @@ -1,32 +1,3 @@ - Copyright (c) 2014, ARM Limited - All rights Reserved. - Copyright (c) 2014, Linaro Ltd. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - * Neither the name of the company nor the names of its contributors - may be used to endorse or promote products derived from this - software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -------------------------------------------------------------------- - Copyright (c) 2014, Linaro Limited All rights reserved. @@ -5225,34 +5196,6 @@ SUCH DAMAGE. ------------------------------------------------------------------- -Copyright (c) 2012, Linaro Limited - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - * Neither the name of the Linaro nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -------------------------------------------------------------------- - Copyright (c) 2012-2013, Linaro Limited All rights reserved. @@ -5465,33 +5408,6 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ------------------------------------------------------------------- -Copyright (c) 2013-2015, Linaro Limited - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - * Neither the name of the Linaro nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - -------------------------------------------------------------------- - Copyright (c) 2014, Intel Corporation All rights reserved. @@ -5632,34 +5548,6 @@ SUCH DAMAGE. ------------------------------------------------------------------- -Copyright (c) 2017 ARM Ltd -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: -1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. -2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. -3. The name of the company may not be used to endorse or promote - products derived from this software without specific prior written - permission. - -THIS SOFTWARE IS PROVIDED BY ARM LTD ``AS IS'' AND ANY EXPRESS OR IMPLIED -WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -IN NO EVENT SHALL ARM LTD BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -------------------------------------------------------------------- - Copyright (c)1999 Citrus Project, All rights reserved. diff --git a/libc/arch-arm64/default/bionic/memchr.S b/libc/arch-arm64/default/bionic/memchr.S deleted file mode 100644 index 7fbcc8fd4..000000000 --- a/libc/arch-arm64/default/bionic/memchr.S +++ /dev/null @@ -1,164 +0,0 @@ -/* - * - Copyright (c) 2014, ARM Limited - All rights Reserved. - Copyright (c) 2014, Linaro Ltd. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - * Neither the name of the company nor the names of its contributors - may be used to endorse or promote products derived from this - software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/* Assumptions: - * - * ARMv8-a, AArch64 - * Neon Available. - */ - -#include <private/bionic_asm.h> - -/* Arguments and results. */ -#define srcin x0 -#define chrin w1 -#define cntin x2 - -#define result x0 - -#define src x3 -#define tmp x4 -#define wtmp2 w5 -#define synd x6 -#define soff x9 -#define cntrem x10 - -#define vrepchr v0 -#define vdata1 v1 -#define vdata2 v2 -#define vhas_chr1 v3 -#define vhas_chr2 v4 -#define vrepmask v5 -#define vend v6 - -/* - * Core algorithm: - * - * For each 32-byte chunk we calculate a 64-bit syndrome value, with two bits - * per byte. For each tuple, bit 0 is set if the relevant byte matched the - * requested character and bit 1 is not used (faster than using a 32bit - * syndrome). Since the bits in the syndrome reflect exactly the order in which - * things occur in the original string, counting trailing zeros allows to - * identify exactly which byte has matched. - */ - -ENTRY(memchr_default) - /* - * Magic constant 0x40100401 allows us to identify which lane matches - * the requested byte. - */ - cbz cntin, .Lzero_length - mov wtmp2, #0x0401 - movk wtmp2, #0x4010, lsl #16 - dup vrepchr.16b, chrin - /* Work with aligned 32-byte chunks */ - bic src, srcin, #31 - dup vrepmask.4s, wtmp2 - ands soff, srcin, #31 - and cntrem, cntin, #31 - b.eq .Lloop - - /* - * Input string is not 32-byte aligned. We calculate the syndrome - * value for the aligned 32 bytes block containing the first bytes - * and mask the irrelevant part. - */ - - ld1 {vdata1.16b, vdata2.16b}, [src], #32 - sub tmp, soff, #32 - adds cntin, cntin, tmp - cmeq vhas_chr1.16b, vdata1.16b, vrepchr.16b - cmeq vhas_chr2.16b, vdata2.16b, vrepchr.16b - and vhas_chr1.16b, vhas_chr1.16b, vrepmask.16b - and vhas_chr2.16b, vhas_chr2.16b, vrepmask.16b - addp vend.16b, vhas_chr1.16b, vhas_chr2.16b /* 256->128 */ - addp vend.16b, vend.16b, vend.16b /* 128->64 */ - mov synd, vend.d[0] - /* Clear the soff*2 lower bits */ - lsl tmp, soff, #1 - lsr synd, synd, tmp - lsl synd, synd, tmp - /* The first block can also be the last */ - b.ls .Lmasklast - /* Have we found something already? */ - cbnz synd, .Ltail - -.Lloop: - ld1 {vdata1.16b, vdata2.16b}, [src], #32 - subs cntin, cntin, #32 - cmeq vhas_chr1.16b, vdata1.16b, vrepchr.16b - cmeq vhas_chr2.16b, vdata2.16b, vrepchr.16b - /* If we're out of data we finish regardless of the result */ - b.ls .Lend - /* Use a fast check for the termination condition */ - orr vend.16b, vhas_chr1.16b, vhas_chr2.16b - addp vend.2d, vend.2d, vend.2d - mov synd, vend.d[0] - /* We're not out of data, loop if we haven't found the character */ - cbz synd, .Lloop - -.Lend: - /* Termination condition found, let's calculate the syndrome value */ - and vhas_chr1.16b, vhas_chr1.16b, vrepmask.16b - and vhas_chr2.16b, vhas_chr2.16b, vrepmask.16b - addp vend.16b, vhas_chr1.16b, vhas_chr2.16b /* 256->128 */ - addp vend.16b, vend.16b, vend.16b /* 128->64 */ - mov synd, vend.d[0] - /* Only do the clear for the last possible block */ - b.hi .Ltail - -.Lmasklast: - /* Clear the (32 - ((cntrem + soff) % 32)) * 2 upper bits */ - add tmp, cntrem, soff - and tmp, tmp, #31 - sub tmp, tmp, #32 - neg tmp, tmp, lsl #1 - lsl synd, synd, tmp - lsr synd, synd, tmp - -.Ltail: - /* Count the trailing zeros using bit reversing */ - rbit synd, synd - /* Compensate the last post-increment */ - sub src, src, #32 - /* Check that we have found a character */ - cmp synd, #0 - /* And count the leading zeros */ - clz synd, synd - /* Compute the potential result */ - add result, src, synd, lsr #1 - /* Select result or NULL */ - csel result, xzr, result, eq - ret - -.Lzero_length: - mov result, xzr - ret -END(memchr_default) diff --git a/libc/arch-arm64/default/bionic/strchr.S b/libc/arch-arm64/default/bionic/strchr.S deleted file mode 100644 index f8cb724cc..000000000 --- a/libc/arch-arm64/default/bionic/strchr.S +++ /dev/null @@ -1,153 +0,0 @@ -/* - * - Copyright (c) 2014, ARM Limited - All rights Reserved. - Copyright (c) 2014, Linaro Ltd. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - * Neither the name of the company nor the names of its contributors - may be used to endorse or promote products derived from this - software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/* Assumptions: - * - * ARMv8-a, AArch64 - * Neon Available. - */ - -#include <private/bionic_asm.h> - -/* Arguments and results. */ -#define srcin x0 -#define chrin w1 - -#define result x0 - -#define src x2 -#define tmp1 x3 -#define wtmp2 w4 -#define tmp3 x5 - -#define vrepchr v0 -#define vdata1 v1 -#define vdata2 v2 -#define vhas_nul1 v3 -#define vhas_nul2 v4 -#define vhas_chr1 v5 -#define vhas_chr2 v6 -#define vrepmask_0 v7 -#define vrepmask_c v16 -#define vend1 v17 -#define vend2 v18 - -/* Core algorithm. - - For each 32-byte hunk we calculate a 64-bit syndrome value, with - two bits per byte (LSB is always in bits 0 and 1, for both big - and little-endian systems). For each tuple, bit 0 is set iff - the relevant byte matched the requested character; bit 1 is set - iff the relevant byte matched the NUL end of string (we trigger - off bit0 for the special case of looking for NUL). Since the bits - in the syndrome reflect exactly the order in which things occur - in the original string a count_trailing_zeros() operation will - identify exactly which byte is causing the termination, and why. */ - -/* Locals and temporaries. */ - -ENTRY(strchr_default) - /* Magic constant 0x40100401 to allow us to identify which lane - matches the requested byte. Magic constant 0x80200802 used - similarly for NUL termination. */ - mov wtmp2, #0x0401 - movk wtmp2, #0x4010, lsl #16 - dup vrepchr.16b, chrin - bic src, srcin, #31 /* Work with aligned 32-byte hunks. */ - dup vrepmask_c.4s, wtmp2 - ands tmp1, srcin, #31 - add vrepmask_0.4s, vrepmask_c.4s, vrepmask_c.4s /* equiv: lsl #1 */ - b.eq .Lloop - - /* Input string is not 32-byte aligned. Rather than forcing - the padding bytes to a safe value, we calculate the syndrome - for all the bytes, but then mask off those bits of the - syndrome that are related to the padding. */ - ld1 {vdata1.16b, vdata2.16b}, [src], #32 - neg tmp1, tmp1 - cmeq vhas_nul1.16b, vdata1.16b, #0 - cmeq vhas_chr1.16b, vdata1.16b, vrepchr.16b - cmeq vhas_nul2.16b, vdata2.16b, #0 - cmeq vhas_chr2.16b, vdata2.16b, vrepchr.16b - and vhas_nul1.16b, vhas_nul1.16b, vrepmask_0.16b - and vhas_nul2.16b, vhas_nul2.16b, vrepmask_0.16b - and vhas_chr1.16b, vhas_chr1.16b, vrepmask_c.16b - and vhas_chr2.16b, vhas_chr2.16b, vrepmask_c.16b - orr vend1.16b, vhas_nul1.16b, vhas_chr1.16b - orr vend2.16b, vhas_nul2.16b, vhas_chr2.16b - lsl tmp1, tmp1, #1 - addp vend1.16b, vend1.16b, vend2.16b // 256->128 - mov tmp3, #~0 - addp vend1.16b, vend1.16b, vend2.16b // 128->64 - lsr tmp1, tmp3, tmp1 - - mov tmp3, vend1.d[0] - bic tmp1, tmp3, tmp1 // Mask padding bits. - cbnz tmp1, .Ltail - -.Lloop: - ld1 {vdata1.16b, vdata2.16b}, [src], #32 - cmeq vhas_nul1.16b, vdata1.16b, #0 - cmeq vhas_chr1.16b, vdata1.16b, vrepchr.16b - cmeq vhas_nul2.16b, vdata2.16b, #0 - cmeq vhas_chr2.16b, vdata2.16b, vrepchr.16b - /* Use a fast check for the termination condition. */ - orr vend1.16b, vhas_nul1.16b, vhas_chr1.16b - orr vend2.16b, vhas_nul2.16b, vhas_chr2.16b - orr vend1.16b, vend1.16b, vend2.16b - addp vend1.2d, vend1.2d, vend1.2d - mov tmp1, vend1.d[0] - cbz tmp1, .Lloop - - /* Termination condition found. Now need to establish exactly why - we terminated. */ - and vhas_nul1.16b, vhas_nul1.16b, vrepmask_0.16b - and vhas_nul2.16b, vhas_nul2.16b, vrepmask_0.16b - and vhas_chr1.16b, vhas_chr1.16b, vrepmask_c.16b - and vhas_chr2.16b, vhas_chr2.16b, vrepmask_c.16b - orr vend1.16b, vhas_nul1.16b, vhas_chr1.16b - orr vend2.16b, vhas_nul2.16b, vhas_chr2.16b - addp vend1.16b, vend1.16b, vend2.16b // 256->128 - addp vend1.16b, vend1.16b, vend2.16b // 128->64 - - mov tmp1, vend1.d[0] -.Ltail: - /* Count the trailing zeros, by bit reversing... */ - rbit tmp1, tmp1 - /* Re-bias source. */ - sub src, src, #32 - clz tmp1, tmp1 /* And counting the leading zeros. */ - /* Tmp1 is even if the target charager was found first. Otherwise - we've found the end of string and we weren't looking for NUL. */ - tst tmp1, #1 - add result, src, tmp1, lsr #1 - csel result, result, xzr, eq - ret -END(strchr_default) diff --git a/libc/arch-arm64/default/bionic/strcmp.S b/libc/arch-arm64/default/bionic/strcmp.S deleted file mode 100644 index dfac7c42c..000000000 --- a/libc/arch-arm64/default/bionic/strcmp.S +++ /dev/null @@ -1,192 +0,0 @@ -/* Copyright (c) 2012, Linaro Limited - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - * Neither the name of the Linaro nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/* Assumptions: - * - * ARMv8-a, AArch64 - */ - -#include <private/bionic_asm.h> - -#define L(label) .L ## label - -#define REP8_01 0x0101010101010101 -#define REP8_7f 0x7f7f7f7f7f7f7f7f -#define REP8_80 0x8080808080808080 - -/* Parameters and result. */ -#define src1 x0 -#define src2 x1 -#define result x0 - -/* Internal variables. */ -#define data1 x2 -#define data1w w2 -#define data2 x3 -#define data2w w3 -#define has_nul x4 -#define diff x5 -#define syndrome x6 -#define tmp1 x7 -#define tmp2 x8 -#define tmp3 x9 -#define zeroones x10 -#define pos x11 - - /* Start of performance-critical section -- one 64B cache line. */ -ENTRY(strcmp_default) -.p2align 6 - eor tmp1, src1, src2 - mov zeroones, #REP8_01 - tst tmp1, #7 - b.ne L(misaligned8) - ands tmp1, src1, #7 - b.ne L(mutual_align) - /* NUL detection works on the principle that (X - 1) & (~X) & 0x80 - (=> (X - 1) & ~(X | 0x7f)) is non-zero iff a byte is zero, and - can be done in parallel across the entire word. */ -L(loop_aligned): - ldr data1, [src1], #8 - ldr data2, [src2], #8 -L(start_realigned): - sub tmp1, data1, zeroones - orr tmp2, data1, #REP8_7f - eor diff, data1, data2 /* Non-zero if differences found. */ - bic has_nul, tmp1, tmp2 /* Non-zero if NUL terminator. */ - orr syndrome, diff, has_nul - cbz syndrome, L(loop_aligned) - /* End of performance-critical section -- one 64B cache line. */ - -L(end): -#ifndef __AARCH64EB__ - rev syndrome, syndrome - rev data1, data1 - /* The MS-non-zero bit of the syndrome marks either the first bit - that is different, or the top bit of the first zero byte. - Shifting left now will bring the critical information into the - top bits. */ - clz pos, syndrome - rev data2, data2 - lsl data1, data1, pos - lsl data2, data2, pos - /* But we need to zero-extend (char is unsigned) the value and then - perform a signed 32-bit subtraction. */ - lsr data1, data1, #56 - sub result, data1, data2, lsr #56 - ret -#else - /* For big-endian we cannot use the trick with the syndrome value - as carry-propagation can corrupt the upper bits if the trailing - bytes in the string contain 0x01. */ - /* However, if there is no NUL byte in the dword, we can generate - the result directly. We can't just subtract the bytes as the - MSB might be significant. */ - cbnz has_nul, 1f - cmp data1, data2 - cset result, ne - cneg result, result, lo - ret -1: - /* Re-compute the NUL-byte detection, using a byte-reversed value. */ - rev tmp3, data1 - sub tmp1, tmp3, zeroones - orr tmp2, tmp3, #REP8_7f - bic has_nul, tmp1, tmp2 - rev has_nul, has_nul - orr syndrome, diff, has_nul - clz pos, syndrome - /* The MS-non-zero bit of the syndrome marks either the first bit - that is different, or the top bit of the first zero byte. - Shifting left now will bring the critical information into the - top bits. */ - lsl data1, data1, pos - lsl data2, data2, pos - /* But we need to zero-extend (char is unsigned) the value and then - perform a signed 32-bit subtraction. */ - lsr data1, data1, #56 - sub result, data1, data2, lsr #56 - ret -#endif - -L(mutual_align): - /* Sources are mutually aligned, but are not currently at an - alignment boundary. Round down the addresses and then mask off - the bytes that preceed the start point. */ - bic src1, src1, #7 - bic src2, src2, #7 - lsl tmp1, tmp1, #3 /* Bytes beyond alignment -> bits. */ - ldr data1, [src1], #8 - neg tmp1, tmp1 /* Bits to alignment -64. */ - ldr data2, [src2], #8 - mov tmp2, #~0 -#ifdef __AARCH64EB__ - /* Big-endian. Early bytes are at MSB. */ - lsl tmp2, tmp2, tmp1 /* Shift (tmp1 & 63). */ -#else - /* Little-endian. Early bytes are at LSB. */ - lsr tmp2, tmp2, tmp1 /* Shift (tmp1 & 63). */ -#endif - orr data1, data1, tmp2 - orr data2, data2, tmp2 - b L(start_realigned) - -L(misaligned8): - /* Align SRC1 to 8 bytes and then compare 8 bytes at a time, always - checking to make sure that we don't access beyond page boundary in - SRC2. */ - tst src1, #7 - b.eq L(loop_misaligned) -L(do_misaligned): - ldrb data1w, [src1], #1 - ldrb data2w, [src2], #1 - cmp data1w, #1 - ccmp data1w, data2w, #0, cs /* NZCV = 0b0000. */ - b.ne L(done) - tst src1, #7 - b.ne L(do_misaligned) - -L(loop_misaligned): - /* Test if we are within the last dword of the end of a 4K page. If - yes then jump back to the misaligned loop to copy a byte at a time. */ - and tmp1, src2, #0xff8 - eor tmp1, tmp1, #0xff8 - cbz tmp1, L(do_misaligned) - ldr data1, [src1], #8 - ldr data2, [src2], #8 - - sub tmp1, data1, zeroones - orr tmp2, data1, #REP8_7f - eor diff, data1, data2 /* Non-zero if differences found. */ - bic has_nul, tmp1, tmp2 /* Non-zero if NUL terminator. */ - orr syndrome, diff, has_nul - cbz syndrome, L(loop_misaligned) - b L(end) - -L(done): - sub result, data1, data2 - ret -END(strcmp_default) diff --git a/libc/arch-arm64/default/bionic/strlen.S b/libc/arch-arm64/default/bionic/strlen.S deleted file mode 100644 index 07c5294c2..000000000 --- a/libc/arch-arm64/default/bionic/strlen.S +++ /dev/null @@ -1,227 +0,0 @@ -/* Copyright (c) 2013-2015, Linaro Limited - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - * Neither the name of the Linaro nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - -/* Assumptions: - * - * ARMv8-a, AArch64, unaligned accesses, min page size 4k. - */ - -#include <private/bionic_asm.h> - -/* To test the page crossing code path more thoroughly, compile with - -DTEST_PAGE_CROSS - this will force all calls through the slower - entry path. This option is not intended for production use. */ - -/* Arguments and results. */ -#define srcin x0 -#define len x0 - -/* Locals and temporaries. */ -#define src x1 -#define data1 x2 -#define data2 x3 -#define has_nul1 x4 -#define has_nul2 x5 -#define tmp1 x4 -#define tmp2 x5 -#define tmp3 x6 -#define tmp4 x7 -#define zeroones x8 - -#define L(l) .L ## l - - /* NUL detection works on the principle that (X - 1) & (~X) & 0x80 - (=> (X - 1) & ~(X | 0x7f)) is non-zero iff a byte is zero, and - can be done in parallel across the entire word. A faster check - (X - 1) & 0x80 is zero for non-NUL ASCII characters, but gives - false hits for characters 129..255. */ - -#define REP8_01 0x0101010101010101 -#define REP8_7f 0x7f7f7f7f7f7f7f7f -#define REP8_80 0x8080808080808080 - -#ifdef TEST_PAGE_CROSS -# define MIN_PAGE_SIZE 15 -#else -# define MIN_PAGE_SIZE 4096 -#endif - - /* Since strings are short on average, we check the first 16 bytes - of the string for a NUL character. In order to do an unaligned ldp - safely we have to do a page cross check first. If there is a NUL - byte we calculate the length from the 2 8-byte words using - conditional select to reduce branch mispredictions (it is unlikely - strlen will be repeatedly called on strings with the same length). - - If the string is longer than 16 bytes, we align src so don't need - further page cross checks, and process 32 bytes per iteration - using the fast NUL check. If we encounter non-ASCII characters, - fallback to a second loop using the full NUL check. - - If the page cross check fails, we read 16 bytes from an aligned - address, remove any characters before the string, and continue - in the main loop using aligned loads. Since strings crossing a - page in the first 16 bytes are rare (probability of - 16/MIN_PAGE_SIZE ~= 0.4%), this case does not need to be optimized. - - AArch64 systems have a minimum page size of 4k. We don't bother - checking for larger page sizes - the cost of setting up the correct - page size is just not worth the extra gain from a small reduction in - the cases taking the slow path. Note that we only care about - whether the first fetch, which may be misaligned, crosses a page - boundary. */ - -ENTRY(strlen_default) - and tmp1, srcin, MIN_PAGE_SIZE - 1 - mov zeroones, REP8_01 - cmp tmp1, MIN_PAGE_SIZE - 16 - b.gt L(page_cross) - ldp data1, data2, [srcin] -#ifdef __AARCH64EB__ - /* For big-endian, carry propagation (if the final byte in the - string is 0x01) means we cannot use has_nul1/2 directly. - Since we expect strings to be small and early-exit, - byte-swap the data now so has_null1/2 will be correct. */ - rev data1, data1 - rev data2, data2 -#endif - sub tmp1, data1, zeroones - orr tmp2, data1, REP8_7f - sub tmp3, data2, zeroones - orr tmp4, data2, REP8_7f - bics has_nul1, tmp1, tmp2 - bic has_nul2, tmp3, tmp4 - ccmp has_nul2, 0, 0, eq - beq L(main_loop_entry) - - /* Enter with C = has_nul1 == 0. */ - csel has_nul1, has_nul1, has_nul2, cc - mov len, 8 - rev has_nul1, has_nul1 - clz tmp1, has_nul1 - csel len, xzr, len, cc - add len, len, tmp1, lsr 3 - ret - - /* The inner loop processes 32 bytes per iteration and uses the fast - NUL check. If we encounter non-ASCII characters, use a second - loop with the accurate NUL check. */ - .p2align 4 -L(main_loop_entry): - bic src, srcin, 15 - sub src, src, 16 -L(main_loop): - ldp data1, data2, [src, 32]! -.Lpage_cross_entry: - sub tmp1, data1, zeroones - sub tmp3, data2, zeroones - orr tmp2, tmp1, tmp3 - tst tmp2, zeroones, lsl 7 - bne 1f - ldp data1, data2, [src, 16] - sub tmp1, data1, zeroones - sub tmp3, data2, zeroones - orr tmp2, tmp1, tmp3 - tst tmp2, zeroones, lsl 7 - beq L(main_loop) - add src, src, 16 -1: - /* The fast check failed, so do the slower, accurate NUL check. */ - orr tmp2, data1, REP8_7f - orr tmp4, data2, REP8_7f - bics has_nul1, tmp1, tmp2 - bic has_nul2, tmp3, tmp4 - ccmp has_nul2, 0, 0, eq - beq L(nonascii_loop) - - /* Enter with C = has_nul1 == 0. */ -L(tail): -#ifdef __AARCH64EB__ - /* For big-endian, carry propagation (if the final byte in the - string is 0x01) means we cannot use has_nul1/2 directly. The - easiest way to get the correct byte is to byte-swap the data - and calculate the syndrome a second time. */ - csel data1, data1, data2, cc - rev data1, data1 - sub tmp1, data1, zeroones - orr tmp2, data1, REP8_7f - bic has_nul1, tmp1, tmp2 -#else - csel has_nul1, has_nul1, has_nul2, cc -#endif - sub len, src, srcin - rev has_nul1, has_nul1 - add tmp2, len, 8 - clz tmp1, has_nul1 - csel len, len, tmp2, cc - add len, len, tmp1, lsr 3 - ret - -L(nonascii_loop): - ldp data1, data2, [src, 16]! - sub tmp1, data1, zeroones - orr tmp2, data1, REP8_7f - sub tmp3, data2, zeroones - orr tmp4, data2, REP8_7f - bics has_nul1, tmp1, tmp2 - bic has_nul2, tmp3, tmp4 - ccmp has_nul2, 0, 0, eq - bne L(tail) - ldp data1, data2, [src, 16]! - sub tmp1, data1, zeroones - orr tmp2, data1, REP8_7f - sub tmp3, data2, zeroones - orr tmp4, data2, REP8_7f - bics has_nul1, tmp1, tmp2 - bic has_nul2, tmp3, tmp4 - ccmp has_nul2, 0, 0, eq - beq L(nonascii_loop) - b L(tail) - - /* Load 16 bytes from [srcin & ~15] and force the bytes that precede - srcin to 0x7f, so we ignore any NUL bytes before the string. - Then continue in the aligned loop. */ -L(page_cross): - bic src, srcin, 15 - ldp data1, data2, [src] - lsl tmp1, srcin, 3 - mov tmp4, -1 -#ifdef __AARCH64EB__ - /* Big-endian. Early bytes are at MSB. */ - lsr tmp1, tmp4, tmp1 /* Shift (tmp1 & 63). */ -#else - /* Little-endian. Early bytes are at LSB. */ - lsl tmp1, tmp4, tmp1 /* Shift (tmp1 & 63). */ -#endif - orr tmp1, tmp1, REP8_80 - orn data1, data1, tmp1 - orn tmp2, data2, tmp1 - tst srcin, 8 - csel data1, data1, tmp4, eq - csel data2, data2, tmp2, eq - b L(page_cross_entry) - -END(strlen_default) diff --git a/libc/arch-arm64/default/bionic/strncmp.S b/libc/arch-arm64/default/bionic/strncmp.S deleted file mode 100644 index 5432b738e..000000000 --- a/libc/arch-arm64/default/bionic/strncmp.S +++ /dev/null @@ -1,280 +0,0 @@ -/* Copyright (c) 2014, Linaro Limited - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - * Neither the name of the Linaro nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/* Assumptions: - * - * ARMv8-a, AArch64 - */ - -#include <private/bionic_asm.h> - -#define REP8_01 0x0101010101010101 -#define REP8_7f 0x7f7f7f7f7f7f7f7f -#define REP8_80 0x8080808080808080 - -/* Parameters and result. */ -#define src1 x0 -#define src2 x1 -#define limit x2 -#define result x0 - -/* Internal variables. */ -#define data1 x3 -#define data1w w3 -#define data2 x4 -#define data2w w4 -#define has_nul x5 -#define diff x6 -#define syndrome x7 -#define tmp1 x8 -#define tmp2 x9 -#define tmp3 x10 -#define zeroones x11 -#define pos x12 -#define limit_wd x13 -#define mask x14 -#define endloop x15 -#define count mask - - .text - .p2align 6 - .rep 7 - nop /* Pad so that the loop below fits a cache line. */ - .endr -ENTRY(strncmp_default) - cbz limit, .Lret0 - eor tmp1, src1, src2 - mov zeroones, #REP8_01 - tst tmp1, #7 - and count, src1, #7 - b.ne .Lmisaligned8 - cbnz count, .Lmutual_align - /* Calculate the number of full and partial words -1. */ - sub limit_wd, limit, #1 /* limit != 0, so no underflow. */ - lsr limit_wd, limit_wd, #3 /* Convert to Dwords. */ - - /* NUL detection works on the principle that (X - 1) & (~X) & 0x80 - (=> (X - 1) & ~(X | 0x7f)) is non-zero iff a byte is zero, and - can be done in parallel across the entire word. */ - /* Start of performance-critical section -- one 64B cache line. */ -.Lloop_aligned: - ldr data1, [src1], #8 - ldr data2, [src2], #8 -.Lstart_realigned: - subs limit_wd, limit_wd, #1 - sub tmp1, data1, zeroones - orr tmp2, data1, #REP8_7f - eor diff, data1, data2 /* Non-zero if differences found. */ - csinv endloop, diff, xzr, pl /* Last Dword or differences. */ - bics has_nul, tmp1, tmp2 /* Non-zero if NUL terminator. */ - ccmp endloop, #0, #0, eq - b.eq .Lloop_aligned - /* End of performance-critical section -- one 64B cache line. */ - - /* Not reached the limit, must have found the end or a diff. */ - tbz limit_wd, #63, .Lnot_limit - - /* Limit % 8 == 0 => all bytes significant. */ - ands limit, limit, #7 - b.eq .Lnot_limit - - lsl limit, limit, #3 /* Bits -> bytes. */ - mov mask, #~0 -#ifdef __AARCH64EB__ - lsr mask, mask, limit -#else - lsl mask, mask, limit -#endif - bic data1, data1, mask - bic data2, data2, mask - - /* Make sure that the NUL byte is marked in the syndrome. */ - orr has_nul, has_nul, mask - -.Lnot_limit: - orr syndrome, diff, has_nul - -#ifndef __AARCH64EB__ - rev syndrome, syndrome - rev data1, data1 - /* The MS-non-zero bit of the syndrome marks either the first bit - that is different, or the top bit of the first zero byte. - Shifting left now will bring the critical information into the - top bits. */ - clz pos, syndrome - rev data2, data2 - lsl data1, data1, pos - lsl data2, data2, pos - /* But we need to zero-extend (char is unsigned) the value and then - perform a signed 32-bit subtraction. */ - lsr data1, data1, #56 - sub result, data1, data2, lsr #56 - ret -#else - /* For big-endian we cannot use the trick with the syndrome value - as carry-propagation can corrupt the upper bits if the trailing - bytes in the string contain 0x01. */ - /* However, if there is no NUL byte in the dword, we can generate - the result directly. We can't just subtract the bytes as the - MSB might be significant. */ - cbnz has_nul, 1f - cmp data1, data2 - cset result, ne - cneg result, result, lo - ret -1: - /* Re-compute the NUL-byte detection, using a byte-reversed value. */ - rev tmp3, data1 - sub tmp1, tmp3, zeroones - orr tmp2, tmp3, #REP8_7f - bic has_nul, tmp1, tmp2 - rev has_nul, has_nul - orr syndrome, diff, has_nul - clz pos, syndrome - /* The MS-non-zero bit of the syndrome marks either the first bit - that is different, or the top bit of the first zero byte. - Shifting left now will bring the critical information into the - top bits. */ - lsl data1, data1, pos - lsl data2, data2, pos - /* But we need to zero-extend (char is unsigned) the value and then - perform a signed 32-bit subtraction. */ - lsr data1, data1, #56 - sub result, data1, data2, lsr #56 - ret -#endif - -.Lmutual_align: - /* Sources are mutually aligned, but are not currently at an - alignment boundary. Round down the addresses and then mask off - the bytes that precede the start point. - We also need to adjust the limit calculations, but without - overflowing if the limit is near ULONG_MAX. */ - bic src1, src1, #7 - bic src2, src2, #7 - ldr data1, [src1], #8 - neg tmp3, count, lsl #3 /* 64 - bits(bytes beyond align). */ - ldr data2, [src2], #8 - mov tmp2, #~0 - sub limit_wd, limit, #1 /* limit != 0, so no underflow. */ -#ifdef __AARCH64EB__ - /* Big-endian. Early bytes are at MSB. */ - lsl tmp2, tmp2, tmp3 /* Shift (count & 63). */ -#else - /* Little-endian. Early bytes are at LSB. */ - lsr tmp2, tmp2, tmp3 /* Shift (count & 63). */ -#endif - and tmp3, limit_wd, #7 - lsr limit_wd, limit_wd, #3 - /* Adjust the limit. Only low 3 bits used, so overflow irrelevant. */ - add limit, limit, count - add tmp3, tmp3, count - orr data1, data1, tmp2 - orr data2, data2, tmp2 - add limit_wd, limit_wd, tmp3, lsr #3 - b .Lstart_realigned - - .p2align 6 - /* Don't bother with dwords for up to 16 bytes. */ -.Lmisaligned8: - cmp limit, #16 - b.hs .Ltry_misaligned_words - -.Lbyte_loop: - /* Perhaps we can do better than this. */ - ldrb data1w, [src1], #1 - ldrb data2w, [src2], #1 - subs limit, limit, #1 - ccmp data1w, #1, #0, hi /* NZCV = 0b0000. */ - ccmp data1w, data2w, #0, cs /* NZCV = 0b0000. */ - b.eq .Lbyte_loop -.Ldone: - sub result, data1, data2 - ret - /* Align the SRC1 to a dword by doing a bytewise compare and then do - the dword loop. */ -.Ltry_misaligned_words: - lsr limit_wd, limit, #3 - cbz count, .Ldo_misaligned - - neg count, count - and count, count, #7 - sub limit, limit, count - lsr limit_wd, limit, #3 - -.Lpage_end_loop: - ldrb data1w, [src1], #1 - ldrb data2w, [src2], #1 - cmp data1w, #1 - ccmp data1w, data2w, #0, cs /* NZCV = 0b0000. */ - b.ne .Ldone - subs count, count, #1 - b.hi .Lpage_end_loop - -.Ldo_misaligned: - /* Prepare ourselves for the next page crossing. Unlike the aligned - loop, we fetch 1 less dword because we risk crossing bounds on - SRC2. */ - mov count, #8 - subs limit_wd, limit_wd, #1 - b.lo .Ldone_loop -.Lloop_misaligned: - and tmp2, src2, #0xff8 - eor tmp2, tmp2, #0xff8 - cbz tmp2, .Lpage_end_loop - - ldr data1, [src1], #8 - ldr data2, [src2], #8 - sub tmp1, data1, zeroones - orr tmp2, data1, #REP8_7f - eor diff, data1, data2 /* Non-zero if differences found. */ - bics has_nul, tmp1, tmp2 /* Non-zero if NUL terminator. */ - ccmp diff, #0, #0, eq - b.ne .Lnot_limit - subs limit_wd, limit_wd, #1 - b.pl .Lloop_misaligned - -.Ldone_loop: - /* We found a difference or a NULL before the limit was reached. */ - and limit, limit, #7 - cbz limit, .Lnot_limit - /* Read the last word. */ - sub src1, src1, 8 - sub src2, src2, 8 - ldr data1, [src1, limit] - ldr data2, [src2, limit] - sub tmp1, data1, zeroones - orr tmp2, data1, #REP8_7f - eor diff, data1, data2 /* Non-zero if differences found. */ - bics has_nul, tmp1, tmp2 /* Non-zero if NUL terminator. */ - ccmp diff, #0, #0, eq - b.ne .Lnot_limit - -.Lret0: - mov result, #0 - ret -END(strncmp_default) diff --git a/libc/arch-arm64/default/bionic/strnlen.S b/libc/arch-arm64/default/bionic/strnlen.S deleted file mode 100644 index 169453207..000000000 --- a/libc/arch-arm64/default/bionic/strnlen.S +++ /dev/null @@ -1,174 +0,0 @@ -/* Copyright (c) 2014, Linaro Limited - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - * Neither the name of the Linaro nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/* Assumptions: - * - * ARMv8-a, AArch64 - */ - -#include <private/bionic_asm.h> - -/* Arguments and results. */ -#define srcin x0 -#define len x0 -#define limit x1 - -/* Locals and temporaries. */ -#define src x2 -#define data1 x3 -#define data2 x4 -#define data2a x5 -#define has_nul1 x6 -#define has_nul2 x7 -#define tmp1 x8 -#define tmp2 x9 -#define tmp3 x10 -#define tmp4 x11 -#define zeroones x12 -#define pos x13 -#define limit_wd x14 - -#define REP8_01 0x0101010101010101 -#define REP8_7f 0x7f7f7f7f7f7f7f7f -#define REP8_80 0x8080808080808080 - - .text - .p2align 6 -.Lstart: - /* Pre-pad to ensure critical loop begins an icache line. */ - .rep 7 - nop - .endr - /* Put this code here to avoid wasting more space with pre-padding. */ -.Lhit_limit: - mov len, limit - ret - -ENTRY(strnlen_default) - cbz limit, .Lhit_limit - mov zeroones, #REP8_01 - bic src, srcin, #15 - ands tmp1, srcin, #15 - b.ne .Lmisaligned - /* Calculate the number of full and partial words -1. */ - sub limit_wd, limit, #1 /* Limit != 0, so no underflow. */ - lsr limit_wd, limit_wd, #4 /* Convert to Qwords. */ - - /* NUL detection works on the principle that (X - 1) & (~X) & 0x80 - (=> (X - 1) & ~(X | 0x7f)) is non-zero iff a byte is zero, and - can be done in parallel across the entire word. */ - /* The inner loop deals with two Dwords at a time. This has a - slightly higher start-up cost, but we should win quite quickly, - especially on cores with a high number of issue slots per - cycle, as we get much better parallelism out of the operations. */ - - /* Start of critial section -- keep to one 64Byte cache line. */ -.Lloop: - ldp data1, data2, [src], #16 -.Lrealigned: - sub tmp1, data1, zeroones - orr tmp2, data1, #REP8_7f - sub tmp3, data2, zeroones - orr tmp4, data2, #REP8_7f - bic has_nul1, tmp1, tmp2 - bic has_nul2, tmp3, tmp4 - subs limit_wd, limit_wd, #1 - orr tmp1, has_nul1, has_nul2 - ccmp tmp1, #0, #0, pl /* NZCV = 0000 */ - b.eq .Lloop - /* End of critical section -- keep to one 64Byte cache line. */ - - orr tmp1, has_nul1, has_nul2 - cbz tmp1, .Lhit_limit /* No null in final Qword. */ - - /* We know there's a null in the final Qword. The easiest thing - to do now is work out the length of the string and return - MIN (len, limit). */ - - sub len, src, srcin - cbz has_nul1, .Lnul_in_data2 -#ifdef __AARCH64EB__ - mov data2, data1 -#endif - sub len, len, #8 - mov has_nul2, has_nul1 -.Lnul_in_data2: -#ifdef __AARCH64EB__ - /* For big-endian, carry propagation (if the final byte in the - string is 0x01) means we cannot use has_nul directly. The - easiest way to get the correct byte is to byte-swap the data - and calculate the syndrome a second time. */ - rev data2, data2 - sub tmp1, data2, zeroones - orr tmp2, data2, #REP8_7f - bic has_nul2, tmp1, tmp2 -#endif - sub len, len, #8 - rev has_nul2, has_nul2 - clz pos, has_nul2 - add len, len, pos, lsr #3 /* Bits to bytes. */ - cmp len, limit - csel len, len, limit, ls /* Return the lower value. */ - ret - -.Lmisaligned: - /* Deal with a partial first word. - We're doing two things in parallel here; - 1) Calculate the number of words (but avoiding overflow if - limit is near ULONG_MAX) - to do this we need to work out - limit + tmp1 - 1 as a 65-bit value before shifting it; - 2) Load and mask the initial data words - we force the bytes - before the ones we are interested in to 0xff - this ensures - early bytes will not hit any zero detection. */ - sub limit_wd, limit, #1 - neg tmp4, tmp1 - cmp tmp1, #8 - - and tmp3, limit_wd, #15 - lsr limit_wd, limit_wd, #4 - mov tmp2, #~0 - - ldp data1, data2, [src], #16 - lsl tmp4, tmp4, #3 /* Bytes beyond alignment -> bits. */ - add tmp3, tmp3, tmp1 - -#ifdef __AARCH64EB__ - /* Big-endian. Early bytes are at MSB. */ - lsl tmp2, tmp2, tmp4 /* Shift (tmp1 & 63). */ -#else - /* Little-endian. Early bytes are at LSB. */ - lsr tmp2, tmp2, tmp4 /* Shift (tmp1 & 63). */ -#endif - add limit_wd, limit_wd, tmp3, lsr #4 - - orr data1, data1, tmp2 - orr data2a, data2, tmp2 - - csinv data1, data1, xzr, le - csel data2, data2, data2a, le - b .Lrealigned -END(strnlen_default) diff --git a/libc/arch-arm64/dynamic_function_dispatch.cpp b/libc/arch-arm64/dynamic_function_dispatch.cpp index 37abea429..5c6d4edef 100644 --- a/libc/arch-arm64/dynamic_function_dispatch.cpp +++ b/libc/arch-arm64/dynamic_function_dispatch.cpp @@ -47,16 +47,34 @@ DEFINE_IFUNC_FOR(memchr) { if (supports_mte(arg->_hwcap2)) { RETURN_FUNC(memchr_func, memchr_mte); } else { - RETURN_FUNC(memchr_func, memchr_default); + RETURN_FUNC(memchr_func, __memchr_aarch64); + } +} + +typedef int stpcpy_func(char*, const char*); +DEFINE_IFUNC_FOR(stpcpy) { + if (supports_mte(arg->_hwcap2)) { + RETURN_FUNC(stpcpy_func, stpcpy_mte); + } else { + RETURN_FUNC(stpcpy_func, __stpcpy_aarch64); } } typedef char* strchr_func(const char*, int); DEFINE_IFUNC_FOR(strchr) { if (supports_mte(arg->_hwcap2)) { - RETURN_FUNC(strchr_func, strchr_mte); + RETURN_FUNC(strchr_func, __strchr_aarch64_mte); + } else { + RETURN_FUNC(strchr_func, __strchr_aarch64); + } +} + +typedef char* strchrnul_func(const char*, int); +DEFINE_IFUNC_FOR(strchrnul) { + if (supports_mte(arg->_hwcap2)) { + RETURN_FUNC(strchrnul_func, strchrnul_mte); } else { - RETURN_FUNC(strchr_func, strchr_default); + RETURN_FUNC(strchrnul_func, __strchrnul_aarch64); } } @@ -65,16 +83,25 @@ DEFINE_IFUNC_FOR(strcmp) { if (supports_mte(arg->_hwcap2)) { RETURN_FUNC(strcmp_func, strcmp_mte); } else { - RETURN_FUNC(strcmp_func, strcmp_default); + RETURN_FUNC(strcmp_func, __strcmp_aarch64); + } +} + +typedef int strcpy_func(char*, const char*); +DEFINE_IFUNC_FOR(strcpy) { + if (supports_mte(arg->_hwcap2)) { + RETURN_FUNC(strcpy_func, strcpy_mte); + } else { + RETURN_FUNC(strcpy_func, __strcpy_aarch64); } } typedef size_t strlen_func(const char*); DEFINE_IFUNC_FOR(strlen) { if (supports_mte(arg->_hwcap2)) { - RETURN_FUNC(strlen_func, strlen_mte); + RETURN_FUNC(strlen_func, __strlen_aarch64_mte); } else { - RETURN_FUNC(strlen_func, strlen_default); + RETURN_FUNC(strlen_func, __strlen_aarch64); } } @@ -83,7 +110,7 @@ DEFINE_IFUNC_FOR(strncmp) { if (supports_mte(arg->_hwcap2)) { RETURN_FUNC(strncmp_func, strncmp_mte); } else { - RETURN_FUNC(strncmp_func, strncmp_default); + RETURN_FUNC(strncmp_func, __strncmp_aarch64); } } @@ -92,7 +119,16 @@ DEFINE_IFUNC_FOR(strnlen) { if (supports_mte(arg->_hwcap2)) { RETURN_FUNC(strnlen_func, strnlen_mte); } else { - RETURN_FUNC(strnlen_func, strnlen_default); + RETURN_FUNC(strnlen_func, __strnlen_aarch64); + } +} + +typedef char* strrchr_func(const char*, int); +DEFINE_IFUNC_FOR(strrchr) { + if (supports_mte(arg->_hwcap2)) { + RETURN_FUNC(strrchr_func, strrchr_mte); + } else { + RETURN_FUNC(strrchr_func, __strrchr_aarch64); } } diff --git a/libc/arch-arm64/generic/bionic/memcmp.S b/libc/arch-arm64/generic/bionic/memcmp.S deleted file mode 100644 index bff54aea3..000000000 --- a/libc/arch-arm64/generic/bionic/memcmp.S +++ /dev/null @@ -1,167 +0,0 @@ -/* - * Copyright (c) 2017 ARM Ltd - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the company may not be used to endorse or promote - * products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY ARM LTD ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL ARM LTD BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* Assumptions: - * - * ARMv8-a, AArch64, unaligned accesses. - */ - -#include <private/bionic_asm.h> - -#define L(l) .L ## l - -/* Parameters and result. */ -#define src1 x0 -#define src2 x1 -#define limit x2 -#define result w0 - -/* Internal variables. */ -#define data1 x3 -#define data1w w3 -#define data1h x4 -#define data2 x5 -#define data2w w5 -#define data2h x6 -#define tmp1 x7 -#define tmp2 x8 - -/* Small inputs of less than 8 bytes are handled separately. This allows the - main code to be speed up using unaligned loads since there are now at least - 8 bytes to be compared. If the first 8 bytes are equal, align src1. - This ensures each iteration does at most one unaligned access even if both - src1 and src2 are unaligned, and mutually aligned inputs behave as if - aligned. After the main loop, process the last 16 bytes using unaligned - accesses. */ - -ENTRY(memcmp) -.p2align 6 - subs limit, limit, 8 - b.lo L(less8) - - /* Limit >= 8, so check first 8 bytes using unaligned loads. */ - ldr data1, [src1], 8 - ldr data2, [src2], 8 - cmp data1, data2 - b.ne L(return) - - subs limit, limit, 8 - b.gt L(more16) - - ldr data1, [src1, limit] - ldr data2, [src2, limit] - b L(return) - -L(more16): - ldr data1, [src1], 8 - ldr data2, [src2], 8 - cmp data1, data2 - bne L(return) - - /* Jump directly to comparing the last 16 bytes for 32 byte (or less) - strings. */ - subs limit, limit, 16 - b.ls L(last_bytes) - - /* We overlap loads between 0-32 bytes at either side of SRC1 when we - try to align, so limit it only to strings larger than 128 bytes. */ - cmp limit, 96 - b.ls L(loop16) - - /* Align src1 and adjust src2 with bytes not yet done. */ - and tmp1, src1, 15 - add limit, limit, tmp1 - sub src1, src1, tmp1 - sub src2, src2, tmp1 - - /* Loop performing 16 bytes per iteration using aligned src1. - Limit is pre-decremented by 16 and must be larger than zero. - Exit if <= 16 bytes left to do or if the data is not equal. */ - .p2align 4 -L(loop16): - ldp data1, data1h, [src1], 16 - ldp data2, data2h, [src2], 16 - subs limit, limit, 16 - ccmp data1, data2, 0, hi - ccmp data1h, data2h, 0, eq - b.eq L(loop16) - - cmp data1, data2 - bne L(return) - mov data1, data1h - mov data2, data2h - cmp data1, data2 - bne L(return) - - /* Compare last 1-16 bytes using unaligned access. */ -L(last_bytes): - add src1, src1, limit - add src2, src2, limit - ldp data1, data1h, [src1] - ldp data2, data2h, [src2] - cmp data1, data2 - bne L(return) - mov data1, data1h - mov data2, data2h - cmp data1, data2 - - /* Compare data bytes and set return value to 0, -1 or 1. */ -L(return): -#ifndef __AARCH64EB__ - rev data1, data1 - rev data2, data2 -#endif - cmp data1, data2 -L(ret_eq): - cset result, ne - cneg result, result, lo - ret - - .p2align 4 - /* Compare up to 8 bytes. Limit is [-8..-1]. */ -L(less8): - adds limit, limit, 4 - b.lo L(less4) - ldr data1w, [src1], 4 - ldr data2w, [src2], 4 - cmp data1w, data2w - b.ne L(return) - sub limit, limit, 4 -L(less4): - adds limit, limit, 4 - beq L(ret_eq) -L(byte_loop): - ldrb data1w, [src1], 1 - ldrb data2w, [src2], 1 - subs limit, limit, 1 - ccmp data1w, data2w, 0, ne /* NZCV = 0b0000. */ - b.eq L(byte_loop) - sub result, data1w, data2w - ret - -END(memcmp) diff --git a/libc/arch-arm64/generic/bionic/stpcpy.S b/libc/arch-arm64/mte/bionic/stpcpy.S index e4a799387..e4a799387 100644 --- a/libc/arch-arm64/generic/bionic/stpcpy.S +++ b/libc/arch-arm64/mte/bionic/stpcpy.S diff --git a/libc/arch-arm64/mte/bionic/strlen.c b/libc/arch-arm64/mte/bionic/strchrnul.cpp index de88320ce..4f41a314c 100644 --- a/libc/arch-arm64/mte/bionic/strlen.c +++ b/libc/arch-arm64/mte/bionic/strchrnul.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 The Android Open Source Project + * Copyright (C) 2020 The Android Open Source Project * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -26,7 +26,5 @@ * SUCH DAMAGE. */ -#include <upstream-openbsd/android/include/openbsd-compat.h> - -#define strlen strlen_mte -#include <upstream-openbsd/lib/libc/string/strlen.c> +#define strchrnul strchrnul_mte +#include <bionic/strchrnul.cpp> diff --git a/libc/arch-arm64/generic/bionic/strcpy.S b/libc/arch-arm64/mte/bionic/strcpy.S index 260c32138..260c32138 100644 --- a/libc/arch-arm64/generic/bionic/strcpy.S +++ b/libc/arch-arm64/mte/bionic/strcpy.S diff --git a/libc/arch-arm64/generic/bionic/string_copy.S b/libc/arch-arm64/mte/bionic/string_copy.S index 2bf969d60..8b0b93a5b 100644 --- a/libc/arch-arm64/generic/bionic/string_copy.S +++ b/libc/arch-arm64/mte/bionic/string_copy.S @@ -97,9 +97,9 @@ #define REP8_80 0x8080808080808080 #if defined(STPCPY) -ENTRY(stpcpy) +ENTRY(stpcpy_mte) #elif defined(STRCPY) -ENTRY(strcpy) +ENTRY(strcpy_mte) #endif mov zeroones, #REP8_01 #if defined(STRCPY) diff --git a/libc/arch-arm64/mte/bionic/strchr.cpp b/libc/arch-arm64/mte/bionic/strrchr.cpp index 7d394df0a..3201b610c 100644 --- a/libc/arch-arm64/mte/bionic/strchr.cpp +++ b/libc/arch-arm64/mte/bionic/strrchr.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 The Android Open Source Project + * Copyright (C) 2020 The Android Open Source Project * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -26,5 +26,5 @@ * SUCH DAMAGE. */ -#define strchr strchr_mte -#include <bionic/strchr.cpp> +#define strrchr strrchr_mte +#include <bionic/strrchr.cpp> diff --git a/libc/arch-arm64/static_function_dispatch.S b/libc/arch-arm64/static_function_dispatch.S index 8e3a4c131..c89294bd2 100644 --- a/libc/arch-arm64/static_function_dispatch.S +++ b/libc/arch-arm64/static_function_dispatch.S @@ -34,8 +34,12 @@ ENTRY(name); \ END(name) FUNCTION_DELEGATE(memchr, memchr_mte) -FUNCTION_DELEGATE(strchr, strchr_mte) +FUNCTION_DELEGATE(stpcpy, stpcpy_mte) +FUNCTION_DELEGATE(strchr, __strchr_aarch64_mte) +FUNCTION_DELEGATE(strchrnul, strchrnul_mte) FUNCTION_DELEGATE(strcmp, strcmp_mte) -FUNCTION_DELEGATE(strlen, strlen_mte) +FUNCTION_DELEGATE(strcpy, strcpy_mte) +FUNCTION_DELEGATE(strlen, __strlen_aarch64_mte) +FUNCTION_DELEGATE(strrchr, strrchr_mte) FUNCTION_DELEGATE(strncmp, strncmp_mte) FUNCTION_DELEGATE(strnlen, strnlen_mte) diff --git a/libc/arch-x86/atom/string/sse2-memset-atom.S b/libc/arch-x86/atom/string/sse2-memset-atom.S index 016c49e58..e4cd03835 100644 --- a/libc/arch-x86/atom/string/sse2-memset-atom.S +++ b/libc/arch-x86/atom/string/sse2-memset-atom.S @@ -77,15 +77,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* We loaded the jump table and adjusted EDX. Go. */ \ jmp *%ebx - .section .gnu.linkonce.t.__x86.get_pc_thunk.bx,"ax",@progbits - .globl __x86.get_pc_thunk.bx - .hidden __x86.get_pc_thunk.bx - ALIGN(4) - .type __x86.get_pc_thunk.bx,@function -__x86.get_pc_thunk.bx: - movl (%esp), %ebx - ret - ENTRY(__memset_chk_atom) ENTRANCE diff --git a/libc/include/android/legacy_strings_inlines.h b/libc/arch-x86/bionic/__x86.get_pc_thunk.S index 2cc2da272..58dbb084a 100644 --- a/libc/include/android/legacy_strings_inlines.h +++ b/libc/arch-x86/bionic/__x86.get_pc_thunk.S @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017 The Android Open Source Project + * Copyright (C) 2020 The Android Open Source Project * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -26,19 +26,28 @@ * SUCH DAMAGE. */ -#pragma once - -#include <sys/cdefs.h> - -#if defined(__i386__) && __ANDROID_API__ < 18 - -#include <strings.h> - -__BEGIN_DECLS - -/* Everyone except x86 had ffs since the beginning. */ -static __inline int ffs(int __n) { return __builtin_ffs(__n); } - -__END_DECLS - -#endif +// Typically GCC outputs functions like these into any object file that needs a PIC base register, +// and one of the copies for each register is used. Clang doesn't use these functions, but some of +// the quasi-hand-written assembly in the optimized string routines does. + + .section .text.__x86.get_pc_thunk.bx,"axG",@progbits,__x86.get_pc_thunk.bx,comdat + .globl __x86.get_pc_thunk.bx + .hidden __x86.get_pc_thunk.bx + .p2align 4 + .type __x86.get_pc_thunk.bx,@function +__x86.get_pc_thunk.bx: + .cfi_startproc + movl (%esp), %ebx + ret + .cfi_endproc + + .section .text.__x86.get_pc_thunk.cx,"axG",@progbits,__x86.get_pc_thunk.cx,comdat + .globl __x86.get_pc_thunk.cx + .hidden __x86.get_pc_thunk.cx + .p2align 4 + .type __x86.get_pc_thunk.cx,@function +__x86.get_pc_thunk.cx: + .cfi_startproc + movl (%esp), %ecx + ret + .cfi_endproc diff --git a/libc/arch-x86/silvermont/string/sse2-memset-slm.S b/libc/arch-x86/silvermont/string/sse2-memset-slm.S index adaccae10..b7633f5c9 100644 --- a/libc/arch-x86/silvermont/string/sse2-memset-slm.S +++ b/libc/arch-x86/silvermont/string/sse2-memset-slm.S @@ -77,15 +77,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* We loaded the jump table and adjusted EDX. Go. */ \ jmp *%ebx - .section .gnu.linkonce.t.__x86.get_pc_thunk.bx,"ax",@progbits - .globl __x86.get_pc_thunk.bx - .hidden __x86.get_pc_thunk.bx - ALIGN(4) - .type __x86.get_pc_thunk.bx,@function -__x86.get_pc_thunk.bx: - movl (%esp), %ebx - ret - ENTRY(__memset_chk_generic) ENTRANCE diff --git a/libc/bionic/android_unsafe_frame_pointer_chase.cpp b/libc/bionic/android_unsafe_frame_pointer_chase.cpp index 0fb086e49..e25867b0e 100644 --- a/libc/bionic/android_unsafe_frame_pointer_chase.cpp +++ b/libc/bionic/android_unsafe_frame_pointer_chase.cpp @@ -57,6 +57,12 @@ __attribute__((no_sanitize("address", "hwaddress"))) size_t android_unsafe_frame auto begin = reinterpret_cast<uintptr_t>(__builtin_frame_address(0)); uintptr_t end = __get_thread()->stack_top; + + stack_t ss; + if (sigaltstack(nullptr, &ss) == 0 && (ss.ss_flags & SS_ONSTACK)) { + end = reinterpret_cast<uintptr_t>(ss.ss_sp) + ss.ss_size; + } + size_t num_frames = 0; while (1) { auto* frame = reinterpret_cast<frame_record*>(begin); diff --git a/libc/bionic/ffs.cpp b/libc/bionic/ffs.cpp index b2270e548..aa7e5043a 100644 --- a/libc/bionic/ffs.cpp +++ b/libc/bionic/ffs.cpp @@ -26,8 +26,5 @@ * SUCH DAMAGE. */ +#define __BIONIC_STRINGS_INLINE /* Out of line. */ #include <strings.h> - -int ffs(int x) { - return __builtin_ffs(x); -} diff --git a/libc/bionic/heap_tagging.cpp b/libc/bionic/heap_tagging.cpp index 62b5f5cbf..e5e8ec3f1 100644 --- a/libc/bionic/heap_tagging.cpp +++ b/libc/bionic/heap_tagging.cpp @@ -46,7 +46,8 @@ void SetDefaultHeapTaggingLevel() { // or hardware doesn't support MTE, and we will fall back to just enabling tagged pointers in // syscall arguments. if (prctl(PR_SET_TAGGED_ADDR_CTRL, - PR_TAGGED_ADDR_ENABLE | PR_MTE_TCF_ASYNC | (1 << PR_MTE_EXCL_SHIFT), 0, 0, 0) == 0) { + PR_TAGGED_ADDR_ENABLE | PR_MTE_TCF_ASYNC | (0xfffe << PR_MTE_TAG_SHIFT), 0, 0, + 0) == 0) { heap_tagging_level = M_HEAP_TAGGING_LEVEL_ASYNC; return; } diff --git a/libc/bionic/system_property_set.cpp b/libc/bionic/system_property_set.cpp index 56822acbd..212aafcc1 100644 --- a/libc/bionic/system_property_set.cpp +++ b/libc/bionic/system_property_set.cpp @@ -209,7 +209,6 @@ static int send_prop_msg(const prop_msg* msg) { // mostly for ctl.* properties, but we do try and wait 250 // ms so callers who do read-after-write can reliably see // what they've written. Most of the time. - // TODO: fix the system properties design. async_safe_format_log(ANDROID_LOG_WARN, "libc", "Property service has timed out while trying to set \"%s\" to \"%s\"", msg->name, msg->value); diff --git a/libc/bionic/tmpfile.cpp b/libc/bionic/tmpfile.cpp index 4378e84ab..d7ce897e1 100644 --- a/libc/bionic/tmpfile.cpp +++ b/libc/bionic/tmpfile.cpp @@ -31,6 +31,7 @@ */ #include <errno.h> +#include <fcntl.h> #include <signal.h> #include <stdio.h> #include <stdlib.h> @@ -39,48 +40,48 @@ #include <unistd.h> #include "private/ErrnoRestorer.h" -#include "private/ScopedSignalBlocker.h" -static FILE* __tmpfile_dir(const char* tmp_dir) { +static FILE* __fd_to_fp(int fd) { + FILE* fp = fdopen(fd, "w+"); + if (fp != nullptr) return fp; + + ErrnoRestorer errno_restorer; + close(fd); + return nullptr; +} + +static FILE* __tmpfile_dir_legacy(const char* tmp_dir) { char* path = nullptr; if (asprintf(&path, "%s/tmp.XXXXXXXXXX", tmp_dir) == -1) { return nullptr; } - int fd; - { - ScopedSignalBlocker ssb; - fd = mkstemp(path); - if (fd == -1) { - free(path); - return nullptr; - } - - // Unlink the file now so that it's removed when closed. - unlink(path); + int fd = mkstemp(path); + if (fd == -1) { free(path); - - // Can we still use the file now it's unlinked? - // File systems without hard link support won't have the usual Unix semantics. - struct stat sb; - int rc = fstat(fd, &sb); - if (rc == -1) { - ErrnoRestorer errno_restorer; - close(fd); - return nullptr; - } + return nullptr; } - // Turn the file descriptor into a FILE*. - FILE* fp = fdopen(fd, "w+"); - if (fp != nullptr) { - return fp; + // Unlink the file now so that it's removed when closed. + unlink(path); + free(path); + + // Can we still use the file now it's unlinked? + // File systems without hard link support won't have the usual Unix semantics. + struct stat sb; + if (fstat(fd, &sb) == -1) { + ErrnoRestorer errno_restorer; + close(fd); + return nullptr; } - // Failure. Clean up. We already unlinked, so we just need to close. - ErrnoRestorer errno_restorer; - close(fd); - return nullptr; + return __fd_to_fp(fd); +} + +static FILE* __tmpfile_dir(const char* tmp_dir) { + int fd = open(tmp_dir, O_TMPFILE | O_RDWR, S_IRUSR | S_IWUSR); + if (fd == -1) return __tmpfile_dir_legacy(tmp_dir); + return __fd_to_fp(fd); } FILE* tmpfile() { diff --git a/libc/include/bits/auxvec.h b/libc/include/bits/auxvec.h index 4d394776a..2d6522a80 100644 --- a/libc/include/bits/auxvec.h +++ b/libc/include/bits/auxvec.h @@ -37,6 +37,14 @@ #include <linux/auxvec.h> +// AT_HWCAP isn't useful without these constants. +#if __has_include(<asm/hwcap.h>) +#include <asm/hwcap.h> +#endif +#if __has_include(<asm/hwcap2.h>) +#include <asm/hwcap2.h> +#endif + /** Historical SuperH cruft. Irrelevant on Android. */ #define AT_FPUCW 18 /** Historical PowerPC cruft. Irrelevant on Android. */ diff --git a/libc/include/bits/glibc-syscalls.h b/libc/include/bits/glibc-syscalls.h index aabcaabe5..0e3014de6 100644 --- a/libc/include/bits/glibc-syscalls.h +++ b/libc/include/bits/glibc-syscalls.h @@ -702,6 +702,9 @@ #if defined(__NR_openat) #define SYS_openat __NR_openat #endif +#if defined(__NR_openat2) + #define SYS_openat2 __NR_openat2 +#endif #if defined(__NR_pause) #define SYS_pause __NR_pause #endif @@ -720,6 +723,9 @@ #if defined(__NR_personality) #define SYS_personality __NR_personality #endif +#if defined(__NR_pidfd_getfd) + #define SYS_pidfd_getfd __NR_pidfd_getfd +#endif #if defined(__NR_pidfd_open) #define SYS_pidfd_open __NR_pidfd_open #endif diff --git a/libc/include/bits/stdatomic.h b/libc/include/bits/stdatomic.h index 633cb8665..2ce6ee655 100644 --- a/libc/include/bits/stdatomic.h +++ b/libc/include/bits/stdatomic.h @@ -41,7 +41,7 @@ */ #include <stddef.h> /* For ptrdiff_t. */ -#include <stdint.h> /* TODO: don't drag in all the macros, just the types. */ +#include <stdint.h> // Include uchar.h only when available. Bionic's stdatomic.h is also used for // the host (via a copy in prebuilts/clang) and uchar.h is not available in the // glibc used for the host. diff --git a/libc/include/dirent.h b/libc/include/dirent.h index d6819f2e1..2328b1a8a 100644 --- a/libc/include/dirent.h +++ b/libc/include/dirent.h @@ -26,8 +26,12 @@ * SUCH DAMAGE. */ -#ifndef _DIRENT_H_ -#define _DIRENT_H_ +#pragma once + +/** + * @file dirent.h + * @brief Directory entry iteration. + */ #include <stdint.h> #include <sys/cdefs.h> @@ -35,17 +39,23 @@ __BEGIN_DECLS -#ifndef DT_UNKNOWN +/** d_type value when the type is not known. */ #define DT_UNKNOWN 0 +/** d_type value for a FIFO. */ #define DT_FIFO 1 +/** d_type value for a character device. */ #define DT_CHR 2 +/** d_type value for a directory. */ #define DT_DIR 4 +/** d_type value for a block device. */ #define DT_BLK 6 +/** d_type value for a regular file. */ #define DT_REG 8 +/** d_type value for a symbolic link. */ #define DT_LNK 10 +/** d_type value for a socket. */ #define DT_SOCK 12 #define DT_WHT 14 -#endif #if defined(__LP64__) #define __DIRENT64_INO_T ino_t @@ -60,7 +70,9 @@ __BEGIN_DECLS unsigned char d_type; \ char d_name[256]; \ +/** The structure returned by readdir(). Identical to dirent64 on Android. */ struct dirent { __DIRENT64_BODY }; +/** The structure returned by readdir64(). Identical to dirent on Android. */ struct dirent64 { __DIRENT64_BODY }; #undef __DIRENT64_BODY @@ -74,29 +86,158 @@ struct dirent64 { __DIRENT64_BODY }; #define d_fileno d_ino +/** The structure returned by opendir()/fopendir(). */ typedef struct DIR DIR; +/** + * [opendir(3)](http://man7.org/linux/man-pages/man3/opendir.3.html) + * opens a directory stream for the directory at `__path`. + * + * Returns null and sets `errno` on failure. + */ DIR* opendir(const char* __path); + +/** + * [fopendir(3)](http://man7.org/linux/man-pages/man3/opendir.3.html) + * opens a directory stream for the directory at `__dir_fd`. + * + * Returns null and sets `errno` on failure. + */ DIR* fdopendir(int __dir_fd); + +/** + * [readdir(3)](http://man7.org/linux/man-pages/man3/readdir.3.html) + * returns the next directory entry in the given directory. + * + * Returns a pointer to a directory entry on success, + * or returns null and leaves `errno` unchanged at the end of the directory, + * or returns null and sets `errno` on failure. + */ struct dirent* readdir(DIR* __dir); + +/** + * [readdir64(3)](http://man7.org/linux/man-pages/man3/readdir.3.html) + * returns the next directory entry in the given directory. + * + * Returns a pointer to a directory entry on success, + * or returns null and leaves `errno` unchanged at the end of the directory, + * or returns null and sets `errno` on failure. + */ struct dirent64* readdir64(DIR* __dir) __INTRODUCED_IN(21); + int readdir_r(DIR* __dir, struct dirent* __entry, struct dirent** __buffer) __attribute__((__deprecated__("readdir_r is deprecated; use readdir instead"))); int readdir64_r(DIR* __dir, struct dirent64* __entry, struct dirent64** __buffer) __INTRODUCED_IN(21) __attribute__((__deprecated__("readdir64_r is deprecated; use readdir64 instead"))); + +/** + * [closedir(3)](http://man7.org/linux/man-pages/man3/closedir.3.html) + * closes a directory stream. + * + * Returns 0 on success and returns -1 and sets `errno` on failure. + */ int closedir(DIR* __dir); + +/** + * [rewinddir(3)](http://man7.org/linux/man-pages/man3/rewinddir.3.html) + * rewinds a directory stream to the first entry. + */ void rewinddir(DIR* __dir); + +/** + * [seekdir(3)](http://man7.org/linux/man-pages/man3/seekdir.3.html) + * seeks a directory stream to the given entry, which must be a value returned + * by telldir(). + * + * Available since API level 23. + */ void seekdir(DIR* __dir, long __location) __INTRODUCED_IN(23); + +/** + * [telldir(3)](http://man7.org/linux/man-pages/man3/telldir.3.html) + * returns a value representing the current position in the directory + * for use with seekdir(). + * + * Returns the current position on success and returns -1 and sets `errno` on failure. + * + * Available since API level 23. + */ long telldir(DIR* __dir) __INTRODUCED_IN(23); + +/** + * [dirfd(3)](http://man7.org/linux/man-pages/man3/dirfd.3.html) + * returns the file descriptor backing the given directory stream. + * + * Returns a file descriptor on success and returns -1 and sets `errno` on failure. + */ int dirfd(DIR* __dir); + +/** + * [alphasort](http://man7.org/linux/man-pages/man3/alphasort.3.html) is a + * comparator for use with scandir() that uses strcoll(). + */ int alphasort(const struct dirent** __lhs, const struct dirent** __rhs); + +/** + * [alphasort64](http://man7.org/linux/man-pages/man3/alphasort.3.html) is a + * comparator for use with scandir64() that uses strcmp(). + * + * Available since API level 21. + */ int alphasort64(const struct dirent64** __lhs, const struct dirent64** __rhs) __INTRODUCED_IN(21); -int scandir64(const char* __path, struct dirent64*** __name_list, int (*__filter)(const struct dirent64*), int (*__comparator)(const struct dirent64**, const struct dirent64**)) __INTRODUCED_IN(21); + +/** + * [scandir(3)](http://man7.org/linux/man-pages/man3/scandir.3.html) + * scans all the directory `__path`, filtering entries with `__filter` and + * sorting them with qsort() using the given `__comparator`, and storing them + * into `__name_list`. Passing NULL as the filter accepts all entries. + * + * Returns the number of entries returned in the list on success, + * and returns -1 and sets `errno` on failure. + */ int scandir(const char* __path, struct dirent*** __name_list, int (*__filter)(const struct dirent*), int (*__comparator)(const struct dirent**, const struct dirent**)); +/** + * [scandir64(3)](http://man7.org/linux/man-pages/man3/scandir.3.html) + * scans all the directory `__path`, filtering entries with `__filter` and + * sorting them with qsort() using the given `__comparator`, and storing them + * into `__name_list`. Passing NULL as the filter accepts all entries. + * + * Returns the number of entries returned in the list on success, + * and returns -1 and sets `errno` on failure. + * + * Available since API level 21. + */ +int scandir64(const char* __path, struct dirent64*** __name_list, int (*__filter)(const struct dirent64*), int (*__comparator)(const struct dirent64**, const struct dirent64**)) __INTRODUCED_IN(21); + #if defined(__USE_GNU) + +/** + * [scandirat64(3)](http://man7.org/linux/man-pages/man3/scandirat.3.html) + * scans all the directory referenced by the pair of `__dir_fd` and `__path`, + * filtering entries with `__filter` and sorting them with qsort() using the + * given `__comparator`, and storing them into `__name_list`. Passing NULL as + * the filter accepts all entries. + * + * Returns the number of entries returned in the list on success, + * and returns -1 and sets `errno` on failure. + * + * Available since API level 24. + */ int scandirat64(int __dir_fd, const char* __path, struct dirent64*** __name_list, int (*__filter)(const struct dirent64*), int (*__comparator)(const struct dirent64**, const struct dirent64**)) __INTRODUCED_IN(24); + +/** + * [scandirat(3)](http://man7.org/linux/man-pages/man3/scandirat.3.html) + * scans all the directory referenced by the pair of `__dir_fd` and `__path`, + * filtering entries with `__filter` and sorting them with qsort() using the + * given `__comparator`, and storing them into `__name_list`. Passing NULL as + * the filter accepts all entries. + * + * Returns the number of entries returned in the list on success, + * and returns -1 and sets `errno` on failure. + * + * Available since API level 24. + */ int scandirat(int __dir_fd, const char* __path, struct dirent*** __name_list, int (*__filter)(const struct dirent*), int (*__comparator)(const struct dirent**, const struct dirent**)) __INTRODUCED_IN(24); + #endif __END_DECLS - -#endif diff --git a/libc/include/strings.h b/libc/include/strings.h index 08c2326bf..ba69c8d43 100644 --- a/libc/include/strings.h +++ b/libc/include/strings.h @@ -49,6 +49,10 @@ #include <bits/strcasecmp.h> +#if !defined(__BIONIC_STRINGS_INLINE) +#define __BIONIC_STRINGS_INLINE static __inline +#endif + __BEGIN_DECLS /** Deprecated. Use memmove() instead. */ @@ -63,19 +67,41 @@ static __inline__ __always_inline void __bionic_bzero(void* b, size_t len) { __builtin_memset(b, 0, len); } -#if !defined(__i386__) || __ANDROID_API__ >= 18 /** - * [ffs(3)](http://man7.org/linux/man-pages/man3/ffs.3.html) finds the first set bit in `__i`. + * [ffs(3)](http://man7.org/linux/man-pages/man3/ffs.3.html) finds the + * first set bit in `__n`. * - * Returns 0 if no bit is set, or the index of the lowest set bit (counting from 1) otherwise. + * Returns 0 if no bit is set, or the index of the lowest set bit (counting + * from 1) otherwise. */ -int ffs(int __i) __INTRODUCED_IN_X86(18); -#endif +__BIONIC_STRINGS_INLINE int ffs(int __n) { + return __builtin_ffs(__n); +} + +/** + * [ffsl(3)](http://man7.org/linux/man-pages/man3/ffsl.3.html) finds the + * first set bit in `__n`. + * + * Returns 0 if no bit is set, or the index of the lowest set bit (counting + * from 1) otherwise. + */ +__BIONIC_STRINGS_INLINE int ffsl(long __n) { + return __builtin_ffsl(__n); +} + +/** + * [ffsll(3)](http://man7.org/linux/man-pages/man3/ffsll.3.html) finds the + * first set bit in `__n`. + * + * Returns 0 if no bit is set, or the index of the lowest set bit (counting + * from 1) otherwise. + */ +__BIONIC_STRINGS_INLINE int ffsll(long long __n) { + return __builtin_ffsll(__n); +} #if defined(__BIONIC_INCLUDE_FORTIFY_HEADERS) #include <bits/fortify/strings.h> #endif __END_DECLS - -#include <android/legacy_strings_inlines.h> diff --git a/libc/include/sys/auxv.h b/libc/include/sys/auxv.h index c6519400d..bf70ddaac 100644 --- a/libc/include/sys/auxv.h +++ b/libc/include/sys/auxv.h @@ -40,7 +40,7 @@ __BEGIN_DECLS /** - * [getauxval(3)](http://man7.org/linux/man-pages/man2/personality.2.html) returns values from + * [getauxval(3)](http://man7.org/linux/man-pages/man3/getauxval.3.html) returns values from * the ELF auxiliary vector passed by the kernel. * * Returns the corresponding value on success, diff --git a/libc/kernel/tools/clean_header.py b/libc/kernel/tools/clean_header.py index 92a213920..2c2d001a2 100755 --- a/libc/kernel/tools/clean_header.py +++ b/libc/kernel/tools/clean_header.py @@ -112,6 +112,7 @@ def cleanupFile(dst_file, src_file, rel_path, no_update = True): if arch and arch in kernel_arch_token_replacements: blocks.replaceTokens(kernel_arch_token_replacements[arch]) + blocks.removeStructs(kernel_structs_to_remove) blocks.optimizeMacros(macros) blocks.optimizeIf01() blocks.removeVarsAndFuncs(kernel_known_generic_statics) diff --git a/libc/kernel/tools/cpp.py b/libc/kernel/tools/cpp.py index 1ada59e09..b6a153881 100755 --- a/libc/kernel/tools/cpp.py +++ b/libc/kernel/tools/cpp.py @@ -30,10 +30,7 @@ from clang.cindex import TranslationUnit # Note that setting LD_LIBRARY_PATH with os.putenv() sometimes doesn't help. clang.cindex.Config.set_library_file(os.path.join(top, 'prebuilts/sdk/tools/linux/lib64/libclang_android.so')) -from defaults import kCppUndefinedMacro -from defaults import kernel_remove_config_macros -from defaults import kernel_struct_replacements -from defaults import kernel_token_replacements +from defaults import * debugBlockParser = False @@ -1198,6 +1195,52 @@ class BlockList(object): if b.isIf(): b.expr.optimize(macros) + def removeStructs(self, structs): + """Remove structs.""" + for b in self.blocks: + # Have to look in each block for a top-level struct definition. + if b.directive: + continue + num_tokens = len(b.tokens) + # A struct definition has at least 5 tokens: + # struct + # ident + # { + # } + # ; + if num_tokens < 5: + continue + # This is a simple struct finder, it might fail if a top-level + # structure has an #if type directives that confuses the algorithm + # for finding th end of the structure. Or if there is another + # structure definition embedded in the structure. + i = 0 + while i < num_tokens - 2: + if (b.tokens[i].kind != TokenKind.KEYWORD or + b.tokens[i].id != "struct"): + i += 1 + continue + if (b.tokens[i + 1].kind == TokenKind.IDENTIFIER and + b.tokens[i + 2].kind == TokenKind.PUNCTUATION and + b.tokens[i + 2].id == "{" and b.tokens[i + 1].id in structs): + # Search forward for the end of the structure. + # Very simple search, look for } and ; tokens. If something + # more complicated is needed we can add it later. + j = i + 3 + while j < num_tokens - 1: + if (b.tokens[j].kind == TokenKind.PUNCTUATION and + b.tokens[j].id == "}" and + b.tokens[j + 1].kind == TokenKind.PUNCTUATION and + b.tokens[j + 1].id == ";"): + b.tokens = b.tokens[0:i] + b.tokens[j + 2:num_tokens] + num_tokens = len(b.tokens) + j = i + break + j += 1 + i = j + continue + i += 1 + def optimizeAll(self, macros): self.optimizeMacros(macros) self.optimizeIf01() @@ -1755,7 +1798,6 @@ class OptimizerTests(unittest.TestCase): def parse(self, text, macros=None): out = utils.StringOutput() blocks = BlockParser().parse(CppStringTokenizer(text)) - blocks.replaceTokens(kernel_token_replacements) blocks.optimizeAll(macros) blocks.write(out) return out.get() @@ -1931,8 +1973,8 @@ class OptimizerTests(unittest.TestCase): #endif /* SIGRTMAX */ """ expected = """\ -#ifndef __SIGRTMAX -#define __SIGRTMAX 123 +#ifndef SIGRTMAX +#define SIGRTMAX 123 #endif """ self.assertEqual(self.parse(text), expected) @@ -1948,6 +1990,146 @@ class OptimizerTests(unittest.TestCase): expected = "" self.assertEqual(self.parse(text), expected) +class RemoveStructsTests(unittest.TestCase): + def parse(self, text, structs): + out = utils.StringOutput() + blocks = BlockParser().parse(CppStringTokenizer(text)) + blocks.removeStructs(structs) + blocks.write(out) + return out.get() + + def test_remove_struct_from_start(self): + text = """\ +struct remove { + int val1; + int val2; +}; +struct something { + struct timeval val1; + struct timeval val2; +}; +""" + expected = """\ +struct something { + struct timeval val1; + struct timeval val2; +}; +""" + self.assertEqual(self.parse(text, set(["remove"])), expected) + + def test_remove_struct_from_end(self): + text = """\ +struct something { + struct timeval val1; + struct timeval val2; +}; +struct remove { + int val1; + int val2; +}; +""" + expected = """\ +struct something { + struct timeval val1; + struct timeval val2; +}; +""" + self.assertEqual(self.parse(text, set(["remove"])), expected) + + def test_remove_minimal_struct(self): + text = """\ +struct remove { +}; +""" + expected = ""; + self.assertEqual(self.parse(text, set(["remove"])), expected) + + def test_remove_struct_with_struct_fields(self): + text = """\ +struct something { + struct remove val1; + struct remove val2; +}; +struct remove { + int val1; + struct something val3; + int val2; +}; +""" + expected = """\ +struct something { + struct remove val1; + struct remove val2; +}; +""" + self.assertEqual(self.parse(text, set(["remove"])), expected) + + def test_remove_consecutive_structs(self): + text = """\ +struct keep1 { + struct timeval val1; + struct timeval val2; +}; +struct remove1 { + int val1; + int val2; +}; +struct remove2 { + int val1; + int val2; + int val3; +}; +struct keep2 { + struct timeval val1; + struct timeval val2; +}; +""" + expected = """\ +struct keep1 { + struct timeval val1; + struct timeval val2; +}; +struct keep2 { + struct timeval val1; + struct timeval val2; +}; +""" + self.assertEqual(self.parse(text, set(["remove1", "remove2"])), expected) + + def test_remove_multiple_structs(self): + text = """\ +struct keep1 { + int val; +}; +struct remove1 { + int val1; + int val2; +}; +struct keep2 { + int val; +}; +struct remove2 { + struct timeval val1; + struct timeval val2; +}; +struct keep3 { + int val; +}; +""" + expected = """\ +struct keep1 { + int val; +}; +struct keep2 { + int val; +}; +struct keep3 { + int val; +}; +""" + self.assertEqual(self.parse(text, set(["remove1", "remove2"])), expected) + + class FullPathTest(unittest.TestCase): """Test of the full path parsing.""" @@ -1956,9 +2138,12 @@ class FullPathTest(unittest.TestCase): keep = set() out = utils.StringOutput() blocks = BlockParser().parse(CppStringTokenizer(text)) + + blocks.removeStructs(kernel_structs_to_remove) blocks.removeVarsAndFuncs(keep) blocks.replaceTokens(kernel_token_replacements) blocks.optimizeAll(None) + blocks.write(out) return out.get() @@ -2241,6 +2426,38 @@ something that should still be kept """ self.assertEqual(self.parse(text), expected) + def test_verify_timeval_itemerval(self): + text = """\ +struct __kernel_old_timeval { + struct something val; +}; +struct __kernel_old_itimerval { + struct __kernel_old_timeval val; +}; +struct fields { + struct __kernel_old_timeval timeval; + struct __kernel_old_itimerval itimerval; +}; +""" + expected = """\ +struct fields { + struct timeval timeval; + struct itimerval itimerval; +}; +""" + self.assertEqual(self.parse(text), expected) + + def test_token_replacement(self): + text = """\ +#define SIGRTMIN 32 +#define SIGRTMAX _NSIG +""" + expected = """\ +#define __SIGRTMIN 32 +#define __SIGRTMAX _KERNEL__NSIG +""" + self.assertEqual(self.parse(text), expected) + if __name__ == '__main__': unittest.main() diff --git a/libc/kernel/tools/defaults.py b/libc/kernel/tools/defaults.py index 90b56f5a4..04eb5f111 100644 --- a/libc/kernel/tools/defaults.py +++ b/libc/kernel/tools/defaults.py @@ -35,6 +35,17 @@ kernel_known_macros = { "__kernel_old_timeval": "1", } +# this is the set of known kernel data structures we want to remove from +# the final headers +kernel_structs_to_remove = set( + [ + # Remove the structures since they are still the same as + # timeval, itimerval. + "__kernel_old_timeval", + "__kernel_old_itimerval", + ] + ) + # define to true if you want to remove all defined(CONFIG_FOO) tests # from the clean headers. testing shows that this is not strictly necessary # but just generates cleaner results @@ -86,6 +97,8 @@ kernel_token_replacements = { # If struct __kernel_old_timeval and struct timeval become different, # then a different solution needs to be implemented. "__kernel_old_timeval": "timeval", + # Do the same for __kernel_old_itimerval as for timeval. + "__kernel_old_itimerval": "itimerval", } diff --git a/libc/kernel/uapi/asm-arm/asm/unistd-common.h b/libc/kernel/uapi/asm-arm/asm/unistd-common.h index 091bd740e..261328e73 100644 --- a/libc/kernel/uapi/asm-arm/asm/unistd-common.h +++ b/libc/kernel/uapi/asm-arm/asm/unistd-common.h @@ -407,4 +407,6 @@ #define __NR_fspick (__NR_SYSCALL_BASE + 433) #define __NR_pidfd_open (__NR_SYSCALL_BASE + 434) #define __NR_clone3 (__NR_SYSCALL_BASE + 435) +#define __NR_openat2 (__NR_SYSCALL_BASE + 437) +#define __NR_pidfd_getfd (__NR_SYSCALL_BASE + 438) #endif diff --git a/libc/kernel/uapi/asm-arm64/asm/hwcap.h b/libc/kernel/uapi/asm-arm64/asm/hwcap.h index 8a38ab712..ebe2fa417 100644 --- a/libc/kernel/uapi/asm-arm64/asm/hwcap.h +++ b/libc/kernel/uapi/asm-arm64/asm/hwcap.h @@ -59,4 +59,12 @@ #define HWCAP2_SVESM4 (1 << 6) #define HWCAP2_FLAGM2 (1 << 7) #define HWCAP2_FRINT (1 << 8) +#define HWCAP2_SVEI8MM (1 << 9) +#define HWCAP2_SVEF32MM (1 << 10) +#define HWCAP2_SVEF64MM (1 << 11) +#define HWCAP2_SVEBF16 (1 << 12) +#define HWCAP2_I8MM (1 << 13) +#define HWCAP2_BF16 (1 << 14) +#define HWCAP2_DGH (1 << 15) +#define HWCAP2_RNG (1 << 16) #endif diff --git a/libc/kernel/uapi/asm-arm64/asm/kvm.h b/libc/kernel/uapi/asm-arm64/asm/kvm.h index efe1a9c1b..7c6481748 100644 --- a/libc/kernel/uapi/asm-arm64/asm/kvm.h +++ b/libc/kernel/uapi/asm-arm64/asm/kvm.h @@ -137,8 +137,8 @@ struct kvm_vcpu_events { #define KVM_REG_ARM_PTIMER_CVAL ARM64_SYS_REG(3, 3, 14, 2, 2) #define KVM_REG_ARM_PTIMER_CNT ARM64_SYS_REG(3, 3, 14, 0, 1) #define KVM_REG_ARM_TIMER_CTL ARM64_SYS_REG(3, 3, 14, 3, 1) -#define KVM_REG_ARM_TIMER_CNT ARM64_SYS_REG(3, 3, 14, 3, 2) #define KVM_REG_ARM_TIMER_CVAL ARM64_SYS_REG(3, 3, 14, 0, 2) +#define KVM_REG_ARM_TIMER_CNT ARM64_SYS_REG(3, 3, 14, 3, 2) #define KVM_REG_ARM_FW (0x0014 << KVM_REG_ARM_COPROC_SHIFT) #define KVM_REG_ARM_FW_REG(r) (KVM_REG_ARM64 | KVM_REG_SIZE_U64 | KVM_REG_ARM_FW | ((r) & 0xffff)) #define KVM_REG_ARM_PSCI_VERSION KVM_REG_ARM_FW_REG(0) diff --git a/libc/kernel/uapi/asm-arm64/asm/ptrace.h b/libc/kernel/uapi/asm-arm64/asm/ptrace.h index b3e0aea55..23ab4070d 100644 --- a/libc/kernel/uapi/asm-arm64/asm/ptrace.h +++ b/libc/kernel/uapi/asm-arm64/asm/ptrace.h @@ -37,6 +37,7 @@ #define PSR_SSBS_BIT 0x00001000 #define PSR_PAN_BIT 0x00400000 #define PSR_UAO_BIT 0x00800000 +#define PSR_DIT_BIT 0x01000000 #define PSR_V_BIT 0x10000000 #define PSR_C_BIT 0x20000000 #define PSR_Z_BIT 0x40000000 diff --git a/libc/kernel/uapi/asm-generic/unistd.h b/libc/kernel/uapi/asm-generic/unistd.h index 2128ff5cd..1b85b306f 100644 --- a/libc/kernel/uapi/asm-generic/unistd.h +++ b/libc/kernel/uapi/asm-generic/unistd.h @@ -396,8 +396,10 @@ #ifdef __ARCH_WANT_SYS_CLONE3 #define __NR_clone3 435 #endif +#define __NR_openat2 437 +#define __NR_pidfd_getfd 438 #undef __NR_syscalls -#define __NR_syscalls 436 +#define __NR_syscalls 439 #if __BITS_PER_LONG == 64 && !defined(__SYSCALL_COMPAT) #define __NR_fcntl __NR3264_fcntl #define __NR_statfs __NR3264_statfs diff --git a/libc/kernel/uapi/asm-x86/asm/kvm.h b/libc/kernel/uapi/asm-x86/asm/kvm.h index d4865fb1c..1e88a69c3 100644 --- a/libc/kernel/uapi/asm-x86/asm/kvm.h +++ b/libc/kernel/uapi/asm-x86/asm/kvm.h @@ -324,6 +324,7 @@ struct kvm_sync_regs { #define KVM_STATE_NESTED_GUEST_MODE 0x00000001 #define KVM_STATE_NESTED_RUN_PENDING 0x00000002 #define KVM_STATE_NESTED_EVMCS 0x00000004 +#define KVM_STATE_NESTED_MTF_PENDING 0x00000008 #define KVM_STATE_NESTED_SMM_GUEST_MODE 0x00000001 #define KVM_STATE_NESTED_SMM_VMXON 0x00000002 #define KVM_STATE_NESTED_VMX_VMCS_SIZE 0x1000 diff --git a/libc/kernel/uapi/asm-x86/asm/unistd_32.h b/libc/kernel/uapi/asm-x86/asm/unistd_32.h index 06e4a01f6..bbb0a6c6f 100644 --- a/libc/kernel/uapi/asm-x86/asm/unistd_32.h +++ b/libc/kernel/uapi/asm-x86/asm/unistd_32.h @@ -443,4 +443,6 @@ #define __NR_fspick 433 #define __NR_pidfd_open 434 #define __NR_clone3 435 +#define __NR_openat2 437 +#define __NR_pidfd_getfd 438 #endif diff --git a/libc/kernel/uapi/asm-x86/asm/unistd_64.h b/libc/kernel/uapi/asm-x86/asm/unistd_64.h index bcb6eaec1..6a59d7842 100644 --- a/libc/kernel/uapi/asm-x86/asm/unistd_64.h +++ b/libc/kernel/uapi/asm-x86/asm/unistd_64.h @@ -365,4 +365,6 @@ #define __NR_fspick 433 #define __NR_pidfd_open 434 #define __NR_clone3 435 +#define __NR_openat2 437 +#define __NR_pidfd_getfd 438 #endif diff --git a/libc/kernel/uapi/asm-x86/asm/unistd_x32.h b/libc/kernel/uapi/asm-x86/asm/unistd_x32.h index 3357bd10d..e674447c5 100644 --- a/libc/kernel/uapi/asm-x86/asm/unistd_x32.h +++ b/libc/kernel/uapi/asm-x86/asm/unistd_x32.h @@ -318,6 +318,8 @@ #define __NR_fspick (__X32_SYSCALL_BIT + 433) #define __NR_pidfd_open (__X32_SYSCALL_BIT + 434) #define __NR_clone3 (__X32_SYSCALL_BIT + 435) +#define __NR_openat2 (__X32_SYSCALL_BIT + 437) +#define __NR_pidfd_getfd (__X32_SYSCALL_BIT + 438) #define __NR_rt_sigaction (__X32_SYSCALL_BIT + 512) #define __NR_rt_sigreturn (__X32_SYSCALL_BIT + 513) #define __NR_ioctl (__X32_SYSCALL_BIT + 514) diff --git a/libc/kernel/uapi/asm-x86/asm/vmx.h b/libc/kernel/uapi/asm-x86/asm/vmx.h index e218d0d14..a0c748d72 100644 --- a/libc/kernel/uapi/asm-x86/asm/vmx.h +++ b/libc/kernel/uapi/asm-x86/asm/vmx.h @@ -23,7 +23,7 @@ #define EXIT_REASON_EXTERNAL_INTERRUPT 1 #define EXIT_REASON_TRIPLE_FAULT 2 #define EXIT_REASON_INIT_SIGNAL 3 -#define EXIT_REASON_PENDING_INTERRUPT 7 +#define EXIT_REASON_INTERRUPT_WINDOW 7 #define EXIT_REASON_NMI_WINDOW 8 #define EXIT_REASON_TASK_SWITCH 9 #define EXIT_REASON_CPUID 10 @@ -78,7 +78,7 @@ #define EXIT_REASON_XRSTORS 64 #define EXIT_REASON_UMWAIT 67 #define EXIT_REASON_TPAUSE 68 -#define VMX_EXIT_REASONS { EXIT_REASON_EXCEPTION_NMI, "EXCEPTION_NMI" }, { EXIT_REASON_EXTERNAL_INTERRUPT, "EXTERNAL_INTERRUPT" }, { EXIT_REASON_TRIPLE_FAULT, "TRIPLE_FAULT" }, { EXIT_REASON_INIT_SIGNAL, "INIT_SIGNAL" }, { EXIT_REASON_PENDING_INTERRUPT, "PENDING_INTERRUPT" }, { EXIT_REASON_NMI_WINDOW, "NMI_WINDOW" }, { EXIT_REASON_TASK_SWITCH, "TASK_SWITCH" }, { EXIT_REASON_CPUID, "CPUID" }, { EXIT_REASON_HLT, "HLT" }, { EXIT_REASON_INVD, "INVD" }, { EXIT_REASON_INVLPG, "INVLPG" }, { EXIT_REASON_RDPMC, "RDPMC" }, { EXIT_REASON_RDTSC, "RDTSC" }, { EXIT_REASON_VMCALL, "VMCALL" }, { EXIT_REASON_VMCLEAR, "VMCLEAR" }, { EXIT_REASON_VMLAUNCH, "VMLAUNCH" }, { EXIT_REASON_VMPTRLD, "VMPTRLD" }, { EXIT_REASON_VMPTRST, "VMPTRST" }, { EXIT_REASON_VMREAD, "VMREAD" }, { EXIT_REASON_VMRESUME, "VMRESUME" }, { EXIT_REASON_VMWRITE, "VMWRITE" }, { EXIT_REASON_VMOFF, "VMOFF" }, { EXIT_REASON_VMON, "VMON" }, { EXIT_REASON_CR_ACCESS, "CR_ACCESS" }, { EXIT_REASON_DR_ACCESS, "DR_ACCESS" }, { EXIT_REASON_IO_INSTRUCTION, "IO_INSTRUCTION" }, { EXIT_REASON_MSR_READ, "MSR_READ" }, { EXIT_REASON_MSR_WRITE, "MSR_WRITE" }, { EXIT_REASON_INVALID_STATE, "INVALID_STATE" }, { EXIT_REASON_MSR_LOAD_FAIL, "MSR_LOAD_FAIL" }, { EXIT_REASON_MWAIT_INSTRUCTION, "MWAIT_INSTRUCTION" }, { EXIT_REASON_MONITOR_TRAP_FLAG, "MONITOR_TRAP_FLAG" }, { EXIT_REASON_MONITOR_INSTRUCTION, "MONITOR_INSTRUCTION" }, { EXIT_REASON_PAUSE_INSTRUCTION, "PAUSE_INSTRUCTION" }, { EXIT_REASON_MCE_DURING_VMENTRY, "MCE_DURING_VMENTRY" }, { EXIT_REASON_TPR_BELOW_THRESHOLD, "TPR_BELOW_THRESHOLD" }, { EXIT_REASON_APIC_ACCESS, "APIC_ACCESS" }, { EXIT_REASON_EOI_INDUCED, "EOI_INDUCED" }, { EXIT_REASON_GDTR_IDTR, "GDTR_IDTR" }, { EXIT_REASON_LDTR_TR, "LDTR_TR" }, { EXIT_REASON_EPT_VIOLATION, "EPT_VIOLATION" }, { EXIT_REASON_EPT_MISCONFIG, "EPT_MISCONFIG" }, { EXIT_REASON_INVEPT, "INVEPT" }, { EXIT_REASON_RDTSCP, "RDTSCP" }, { EXIT_REASON_PREEMPTION_TIMER, "PREEMPTION_TIMER" }, { EXIT_REASON_INVVPID, "INVVPID" }, { EXIT_REASON_WBINVD, "WBINVD" }, { EXIT_REASON_XSETBV, "XSETBV" }, { EXIT_REASON_APIC_WRITE, "APIC_WRITE" }, { EXIT_REASON_RDRAND, "RDRAND" }, { EXIT_REASON_INVPCID, "INVPCID" }, { EXIT_REASON_VMFUNC, "VMFUNC" }, { EXIT_REASON_ENCLS, "ENCLS" }, { EXIT_REASON_RDSEED, "RDSEED" }, { EXIT_REASON_PML_FULL, "PML_FULL" }, { EXIT_REASON_XSAVES, "XSAVES" }, { EXIT_REASON_XRSTORS, "XRSTORS" }, { EXIT_REASON_UMWAIT, "UMWAIT" }, { EXIT_REASON_TPAUSE, "TPAUSE" } +#define VMX_EXIT_REASONS { EXIT_REASON_EXCEPTION_NMI, "EXCEPTION_NMI" }, { EXIT_REASON_EXTERNAL_INTERRUPT, "EXTERNAL_INTERRUPT" }, { EXIT_REASON_TRIPLE_FAULT, "TRIPLE_FAULT" }, { EXIT_REASON_INIT_SIGNAL, "INIT_SIGNAL" }, { EXIT_REASON_INTERRUPT_WINDOW, "INTERRUPT_WINDOW" }, { EXIT_REASON_NMI_WINDOW, "NMI_WINDOW" }, { EXIT_REASON_TASK_SWITCH, "TASK_SWITCH" }, { EXIT_REASON_CPUID, "CPUID" }, { EXIT_REASON_HLT, "HLT" }, { EXIT_REASON_INVD, "INVD" }, { EXIT_REASON_INVLPG, "INVLPG" }, { EXIT_REASON_RDPMC, "RDPMC" }, { EXIT_REASON_RDTSC, "RDTSC" }, { EXIT_REASON_VMCALL, "VMCALL" }, { EXIT_REASON_VMCLEAR, "VMCLEAR" }, { EXIT_REASON_VMLAUNCH, "VMLAUNCH" }, { EXIT_REASON_VMPTRLD, "VMPTRLD" }, { EXIT_REASON_VMPTRST, "VMPTRST" }, { EXIT_REASON_VMREAD, "VMREAD" }, { EXIT_REASON_VMRESUME, "VMRESUME" }, { EXIT_REASON_VMWRITE, "VMWRITE" }, { EXIT_REASON_VMOFF, "VMOFF" }, { EXIT_REASON_VMON, "VMON" }, { EXIT_REASON_CR_ACCESS, "CR_ACCESS" }, { EXIT_REASON_DR_ACCESS, "DR_ACCESS" }, { EXIT_REASON_IO_INSTRUCTION, "IO_INSTRUCTION" }, { EXIT_REASON_MSR_READ, "MSR_READ" }, { EXIT_REASON_MSR_WRITE, "MSR_WRITE" }, { EXIT_REASON_INVALID_STATE, "INVALID_STATE" }, { EXIT_REASON_MSR_LOAD_FAIL, "MSR_LOAD_FAIL" }, { EXIT_REASON_MWAIT_INSTRUCTION, "MWAIT_INSTRUCTION" }, { EXIT_REASON_MONITOR_TRAP_FLAG, "MONITOR_TRAP_FLAG" }, { EXIT_REASON_MONITOR_INSTRUCTION, "MONITOR_INSTRUCTION" }, { EXIT_REASON_PAUSE_INSTRUCTION, "PAUSE_INSTRUCTION" }, { EXIT_REASON_MCE_DURING_VMENTRY, "MCE_DURING_VMENTRY" }, { EXIT_REASON_TPR_BELOW_THRESHOLD, "TPR_BELOW_THRESHOLD" }, { EXIT_REASON_APIC_ACCESS, "APIC_ACCESS" }, { EXIT_REASON_EOI_INDUCED, "EOI_INDUCED" }, { EXIT_REASON_GDTR_IDTR, "GDTR_IDTR" }, { EXIT_REASON_LDTR_TR, "LDTR_TR" }, { EXIT_REASON_EPT_VIOLATION, "EPT_VIOLATION" }, { EXIT_REASON_EPT_MISCONFIG, "EPT_MISCONFIG" }, { EXIT_REASON_INVEPT, "INVEPT" }, { EXIT_REASON_RDTSCP, "RDTSCP" }, { EXIT_REASON_PREEMPTION_TIMER, "PREEMPTION_TIMER" }, { EXIT_REASON_INVVPID, "INVVPID" }, { EXIT_REASON_WBINVD, "WBINVD" }, { EXIT_REASON_XSETBV, "XSETBV" }, { EXIT_REASON_APIC_WRITE, "APIC_WRITE" }, { EXIT_REASON_RDRAND, "RDRAND" }, { EXIT_REASON_INVPCID, "INVPCID" }, { EXIT_REASON_VMFUNC, "VMFUNC" }, { EXIT_REASON_ENCLS, "ENCLS" }, { EXIT_REASON_RDSEED, "RDSEED" }, { EXIT_REASON_PML_FULL, "PML_FULL" }, { EXIT_REASON_XSAVES, "XSAVES" }, { EXIT_REASON_XRSTORS, "XRSTORS" }, { EXIT_REASON_UMWAIT, "UMWAIT" }, { EXIT_REASON_TPAUSE, "TPAUSE" } #define VMX_ABORT_SAVE_GUEST_MSR_FAIL 1 #define VMX_ABORT_LOAD_HOST_PDPTE_FAIL 2 #define VMX_ABORT_LOAD_HOST_MSR_FAIL 4 diff --git a/libc/kernel/uapi/drm/amdgpu_drm.h b/libc/kernel/uapi/drm/amdgpu_drm.h index b986d3034..a88e3d9db 100644 --- a/libc/kernel/uapi/drm/amdgpu_drm.h +++ b/libc/kernel/uapi/drm/amdgpu_drm.h @@ -428,6 +428,7 @@ struct drm_amdgpu_cs_chunk_data { #define AMDGPU_INFO_FW_GFX_RLC_RESTORE_LIST_SRM_MEM 0x11 #define AMDGPU_INFO_FW_DMCU 0x12 #define AMDGPU_INFO_FW_TA 0x13 +#define AMDGPU_INFO_FW_DMCUB 0x14 #define AMDGPU_INFO_NUM_BYTES_MOVED 0x0f #define AMDGPU_INFO_VRAM_USAGE 0x10 #define AMDGPU_INFO_GTT_USAGE 0x11 diff --git a/libc/kernel/uapi/drm/drm_fourcc.h b/libc/kernel/uapi/drm/drm_fourcc.h index a316269da..898d9adf9 100644 --- a/libc/kernel/uapi/drm/drm_fourcc.h +++ b/libc/kernel/uapi/drm/drm_fourcc.h @@ -145,6 +145,8 @@ extern "C" { #define I915_FORMAT_MOD_Yf_TILED fourcc_mod_code(INTEL, 3) #define I915_FORMAT_MOD_Y_TILED_CCS fourcc_mod_code(INTEL, 4) #define I915_FORMAT_MOD_Yf_TILED_CCS fourcc_mod_code(INTEL, 5) +#define I915_FORMAT_MOD_Y_TILED_GEN12_RC_CCS fourcc_mod_code(INTEL, 6) +#define I915_FORMAT_MOD_Y_TILED_GEN12_MC_CCS fourcc_mod_code(INTEL, 7) #define DRM_FORMAT_MOD_SAMSUNG_64_32_TILE fourcc_mod_code(SAMSUNG, 1) #define DRM_FORMAT_MOD_SAMSUNG_16_16_TILE fourcc_mod_code(SAMSUNG, 2) #define DRM_FORMAT_MOD_QCOM_COMPRESSED fourcc_mod_code(QCOM, 1) diff --git a/libc/kernel/uapi/drm/i915_drm.h b/libc/kernel/uapi/drm/i915_drm.h index 2e6127525..fce9c676f 100644 --- a/libc/kernel/uapi/drm/i915_drm.h +++ b/libc/kernel/uapi/drm/i915_drm.h @@ -250,6 +250,7 @@ typedef struct _drm_i915_sarea { #define DRM_IOCTL_I915_GEM_PWRITE DRM_IOW(DRM_COMMAND_BASE + DRM_I915_GEM_PWRITE, struct drm_i915_gem_pwrite) #define DRM_IOCTL_I915_GEM_MMAP DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_MMAP, struct drm_i915_gem_mmap) #define DRM_IOCTL_I915_GEM_MMAP_GTT DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_MMAP_GTT, struct drm_i915_gem_mmap_gtt) +#define DRM_IOCTL_I915_GEM_MMAP_OFFSET DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_MMAP_GTT, struct drm_i915_gem_mmap_offset) #define DRM_IOCTL_I915_GEM_SET_DOMAIN DRM_IOW(DRM_COMMAND_BASE + DRM_I915_GEM_SET_DOMAIN, struct drm_i915_gem_set_domain) #define DRM_IOCTL_I915_GEM_SW_FINISH DRM_IOW(DRM_COMMAND_BASE + DRM_I915_GEM_SW_FINISH, struct drm_i915_gem_sw_finish) #define DRM_IOCTL_I915_GEM_SET_TILING DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_SET_TILING, struct drm_i915_gem_set_tiling) @@ -441,6 +442,17 @@ struct drm_i915_gem_mmap_gtt { __u32 pad; __u64 offset; }; +struct drm_i915_gem_mmap_offset { + __u32 handle; + __u32 pad; + __u64 offset; + __u64 flags; +#define I915_MMAP_OFFSET_GTT 0 +#define I915_MMAP_OFFSET_WC 1 +#define I915_MMAP_OFFSET_WB 2 +#define I915_MMAP_OFFSET_UC 3 + __u64 extensions; +}; struct drm_i915_gem_set_domain { __u32 handle; __u32 read_domains; diff --git a/libc/kernel/uapi/drm/nouveau_drm.h b/libc/kernel/uapi/drm/nouveau_drm.h index 186ffcc58..150f72982 100644 --- a/libc/kernel/uapi/drm/nouveau_drm.h +++ b/libc/kernel/uapi/drm/nouveau_drm.h @@ -92,6 +92,7 @@ struct drm_nouveau_gem_pushbuf { __u64 push; __u32 suffix0; __u32 suffix1; +#define NOUVEAU_GEM_PUSHBUF_SYNC (1ULL << 0) __u64 vram_available; __u64 gart_available; }; diff --git a/libc/kernel/uapi/drm/vmwgfx_drm.h b/libc/kernel/uapi/drm/vmwgfx_drm.h index 753192bcf..04d30810a 100644 --- a/libc/kernel/uapi/drm/vmwgfx_drm.h +++ b/libc/kernel/uapi/drm/vmwgfx_drm.h @@ -55,6 +55,7 @@ extern "C" { #define DRM_VMW_CREATE_EXTENDED_CONTEXT 26 #define DRM_VMW_GB_SURFACE_CREATE_EXT 27 #define DRM_VMW_GB_SURFACE_REF_EXT 28 +#define DRM_VMW_MSG 29 #define DRM_VMW_PARAM_NUM_STREAMS 0 #define DRM_VMW_PARAM_NUM_FREE_STREAMS 1 #define DRM_VMW_PARAM_3D 2 @@ -351,6 +352,12 @@ union drm_vmw_gb_surface_reference_ext_arg { struct drm_vmw_gb_surface_ref_ext_rep rep; struct drm_vmw_surface_arg req; }; +struct drm_vmw_msg_arg { + __u64 send; + __u64 receive; + __s32 send_only; + __u32 receive_len; +}; #ifdef __cplusplus } #endif diff --git a/libc/kernel/uapi/linux/audit.h b/libc/kernel/uapi/linux/audit.h index d14f018d1..a4bb3b511 100644 --- a/libc/kernel/uapi/linux/audit.h +++ b/libc/kernel/uapi/linux/audit.h @@ -81,6 +81,7 @@ #define AUDIT_FANOTIFY 1331 #define AUDIT_TIME_INJOFFSET 1332 #define AUDIT_TIME_ADJNTPVAL 1333 +#define AUDIT_BPF 1334 #define AUDIT_AVC 1400 #define AUDIT_SELINUX_ERR 1401 #define AUDIT_AVC_PATH 1402 diff --git a/libc/kernel/uapi/linux/b1lli.h b/libc/kernel/uapi/linux/b1lli.h deleted file mode 100644 index 29c7fe844..000000000 --- a/libc/kernel/uapi/linux/b1lli.h +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** - **************************************************************************** - *** - *** This header was automatically generated from a Linux kernel header - *** of the same name, to make information necessary for userspace to - *** call into the kernel available to libc. It contains only constants, - *** structures, and macros generated from the original header, and thus, - *** contains no copyrightable information. - *** - *** To edit the content of this header, modify the corresponding - *** source file (e.g. under external/kernel-headers/original/) then - *** run bionic/libc/kernel/tools/update_all.py - *** - *** Any manual change here will be lost the next time this script will - *** be run. You've been warned! - *** - **************************************************************************** - ****************************************************************************/ -#ifndef _B1LLI_H_ -#define _B1LLI_H_ -typedef struct avmb1_t4file { - int len; - unsigned char * data; -} avmb1_t4file; -typedef struct avmb1_loaddef { - int contr; - avmb1_t4file t4file; -} avmb1_loaddef; -typedef struct avmb1_loadandconfigdef { - int contr; - avmb1_t4file t4file; - avmb1_t4file t4config; -} avmb1_loadandconfigdef; -typedef struct avmb1_resetdef { - int contr; -} avmb1_resetdef; -typedef struct avmb1_getdef { - int contr; - int cardtype; - int cardstate; -} avmb1_getdef; -typedef struct avmb1_carddef { - int port; - int irq; -} avmb1_carddef; -#define AVM_CARDTYPE_B1 0 -#define AVM_CARDTYPE_T1 1 -#define AVM_CARDTYPE_M1 2 -#define AVM_CARDTYPE_M2 3 -typedef struct avmb1_extcarddef { - int port; - int irq; - int cardtype; - int cardnr; -} avmb1_extcarddef; -#define AVMB1_LOAD 0 -#define AVMB1_ADDCARD 1 -#define AVMB1_RESETCARD 2 -#define AVMB1_LOAD_AND_CONFIG 3 -#define AVMB1_ADDCARD_WITH_TYPE 4 -#define AVMB1_GET_CARDINFO 5 -#define AVMB1_REMOVECARD 6 -#define AVMB1_REGISTERCARD_IS_OBSOLETE -#endif diff --git a/libc/kernel/uapi/linux/bcache.h b/libc/kernel/uapi/linux/bcache.h index 1bee0a30a..5e5377e73 100644 --- a/libc/kernel/uapi/linux/bcache.h +++ b/libc/kernel/uapi/linux/bcache.h @@ -56,11 +56,46 @@ struct bkey { #define BCACHE_SB_VERSION_BDEV_WITH_OFFSET 4 #define BCACHE_SB_MAX_VERSION 4 #define SB_SECTOR 8 +#define SB_OFFSET (SB_SECTOR << SECTOR_SHIFT) #define SB_SIZE 4096 #define SB_LABEL_SIZE 32 #define SB_JOURNAL_BUCKETS 256U #define MAX_CACHES_PER_SET 8 #define BDEV_DATA_START_DEFAULT 16 +struct cache_sb_disk { + __le64 csum; + __le64 offset; + __le64 version; + __u8 magic[16]; + __u8 uuid[16]; + union { + __u8 set_uuid[16]; + __le64 set_magic; + }; + __u8 label[SB_LABEL_SIZE]; + __le64 flags; + __le64 seq; + __le64 pad[8]; + union { + struct { + __le64 nbuckets; + __le16 block_size; + __le16 bucket_size; + __le16 nr_in_set; + __le16 nr_this_dev; + }; + struct { + __le64 data_offset; + }; + }; + __le32 last_mount; + __le16 first_bucket; + union { + __le16 njournal_buckets; + __le16 keys; + }; + __le64 d[SB_JOURNAL_BUCKETS]; +}; struct cache_sb { __u64 csum; __u64 offset; diff --git a/libc/kernel/uapi/linux/bpf.h b/libc/kernel/uapi/linux/bpf.h index 80a9febde..bebab62fe 100644 --- a/libc/kernel/uapi/linux/bpf.h +++ b/libc/kernel/uapi/linux/bpf.h @@ -95,6 +95,10 @@ enum bpf_cmd { BPF_MAP_LOOKUP_AND_DELETE_ELEM, BPF_MAP_FREEZE, BPF_BTF_GET_NEXT_ID, + BPF_MAP_LOOKUP_BATCH, + BPF_MAP_LOOKUP_AND_DELETE_BATCH, + BPF_MAP_UPDATE_BATCH, + BPF_MAP_DELETE_BATCH, }; enum bpf_map_type { BPF_MAP_TYPE_UNSPEC, @@ -123,6 +127,7 @@ enum bpf_map_type { BPF_MAP_TYPE_STACK, BPF_MAP_TYPE_SK_STORAGE, BPF_MAP_TYPE_DEVMAP_HASH, + BPF_MAP_TYPE_STRUCT_OPS, }; enum bpf_prog_type { BPF_PROG_TYPE_UNSPEC, @@ -152,6 +157,8 @@ enum bpf_prog_type { BPF_PROG_TYPE_RAW_TRACEPOINT_WRITABLE, BPF_PROG_TYPE_CGROUP_SOCKOPT, BPF_PROG_TYPE_TRACING, + BPF_PROG_TYPE_STRUCT_OPS, + BPF_PROG_TYPE_EXT, }; enum bpf_attach_type { BPF_CGROUP_INET_INGRESS, @@ -185,6 +192,7 @@ enum bpf_attach_type { #define MAX_BPF_ATTACH_TYPE __MAX_BPF_ATTACH_TYPE #define BPF_F_ALLOW_OVERRIDE (1U << 0) #define BPF_F_ALLOW_MULTI (1U << 1) +#define BPF_F_REPLACE (1U << 2) #define BPF_F_STRICT_ALIGNMENT (1U << 0) #define BPF_F_ANY_ALIGNMENT (1U << 1) #define BPF_F_TEST_RND_HI32 (1U << 2) @@ -237,6 +245,7 @@ union bpf_attr { __u32 btf_fd; __u32 btf_key_type_id; __u32 btf_value_type_id; + __u32 btf_vmlinux_value_type_id; }; struct { __u32 map_fd; @@ -248,6 +257,16 @@ union bpf_attr { __u64 flags; }; struct { + __aligned_u64 in_batch; + __aligned_u64 out_batch; + __aligned_u64 keys; + __aligned_u64 values; + __u32 count; + __u32 map_fd; + __u64 elem_flags; + __u64 flags; + } batch; + struct { __u32 prog_type; __u32 insn_cnt; __aligned_u64 insns; @@ -280,6 +299,7 @@ union bpf_attr { __u32 attach_bpf_fd; __u32 attach_type; __u32 attach_flags; + __u32 replace_bpf_fd; }; struct { __u32 prog_fd; @@ -341,7 +361,7 @@ union bpf_attr { __u64 probe_addr; } task_fd_query; } __attribute__((aligned(8))); -#define __BPF_FUNC_MAPPER(FN) FN(unspec), FN(map_lookup_elem), FN(map_update_elem), FN(map_delete_elem), FN(probe_read), FN(ktime_get_ns), FN(trace_printk), FN(get_prandom_u32), FN(get_smp_processor_id), FN(skb_store_bytes), FN(l3_csum_replace), FN(l4_csum_replace), FN(tail_call), FN(clone_redirect), FN(get_current_pid_tgid), FN(get_current_uid_gid), FN(get_current_comm), FN(get_cgroup_classid), FN(skb_vlan_push), FN(skb_vlan_pop), FN(skb_get_tunnel_key), FN(skb_set_tunnel_key), FN(perf_event_read), FN(redirect), FN(get_route_realm), FN(perf_event_output), FN(skb_load_bytes), FN(get_stackid), FN(csum_diff), FN(skb_get_tunnel_opt), FN(skb_set_tunnel_opt), FN(skb_change_proto), FN(skb_change_type), FN(skb_under_cgroup), FN(get_hash_recalc), FN(get_current_task), FN(probe_write_user), FN(current_task_under_cgroup), FN(skb_change_tail), FN(skb_pull_data), FN(csum_update), FN(set_hash_invalid), FN(get_numa_node_id), FN(skb_change_head), FN(xdp_adjust_head), FN(probe_read_str), FN(get_socket_cookie), FN(get_socket_uid), FN(set_hash), FN(setsockopt), FN(skb_adjust_room), FN(redirect_map), FN(sk_redirect_map), FN(sock_map_update), FN(xdp_adjust_meta), FN(perf_event_read_value), FN(perf_prog_read_value), FN(getsockopt), FN(override_return), FN(sock_ops_cb_flags_set), FN(msg_redirect_map), FN(msg_apply_bytes), FN(msg_cork_bytes), FN(msg_pull_data), FN(bind), FN(xdp_adjust_tail), FN(skb_get_xfrm_state), FN(get_stack), FN(skb_load_bytes_relative), FN(fib_lookup), FN(sock_hash_update), FN(msg_redirect_hash), FN(sk_redirect_hash), FN(lwt_push_encap), FN(lwt_seg6_store_bytes), FN(lwt_seg6_adjust_srh), FN(lwt_seg6_action), FN(rc_repeat), FN(rc_keydown), FN(skb_cgroup_id), FN(get_current_cgroup_id), FN(get_local_storage), FN(sk_select_reuseport), FN(skb_ancestor_cgroup_id), FN(sk_lookup_tcp), FN(sk_lookup_udp), FN(sk_release), FN(map_push_elem), FN(map_pop_elem), FN(map_peek_elem), FN(msg_push_data), FN(msg_pop_data), FN(rc_pointer_rel), FN(spin_lock), FN(spin_unlock), FN(sk_fullsock), FN(tcp_sock), FN(skb_ecn_set_ce), FN(get_listener_sock), FN(skc_lookup_tcp), FN(tcp_check_syncookie), FN(sysctl_get_name), FN(sysctl_get_current_value), FN(sysctl_get_new_value), FN(sysctl_set_new_value), FN(strtol), FN(strtoul), FN(sk_storage_get), FN(sk_storage_delete), FN(send_signal), FN(tcp_gen_syncookie), FN(skb_output), FN(probe_read_user), FN(probe_read_kernel), FN(probe_read_user_str), FN(probe_read_kernel_str), +#define __BPF_FUNC_MAPPER(FN) FN(unspec), FN(map_lookup_elem), FN(map_update_elem), FN(map_delete_elem), FN(probe_read), FN(ktime_get_ns), FN(trace_printk), FN(get_prandom_u32), FN(get_smp_processor_id), FN(skb_store_bytes), FN(l3_csum_replace), FN(l4_csum_replace), FN(tail_call), FN(clone_redirect), FN(get_current_pid_tgid), FN(get_current_uid_gid), FN(get_current_comm), FN(get_cgroup_classid), FN(skb_vlan_push), FN(skb_vlan_pop), FN(skb_get_tunnel_key), FN(skb_set_tunnel_key), FN(perf_event_read), FN(redirect), FN(get_route_realm), FN(perf_event_output), FN(skb_load_bytes), FN(get_stackid), FN(csum_diff), FN(skb_get_tunnel_opt), FN(skb_set_tunnel_opt), FN(skb_change_proto), FN(skb_change_type), FN(skb_under_cgroup), FN(get_hash_recalc), FN(get_current_task), FN(probe_write_user), FN(current_task_under_cgroup), FN(skb_change_tail), FN(skb_pull_data), FN(csum_update), FN(set_hash_invalid), FN(get_numa_node_id), FN(skb_change_head), FN(xdp_adjust_head), FN(probe_read_str), FN(get_socket_cookie), FN(get_socket_uid), FN(set_hash), FN(setsockopt), FN(skb_adjust_room), FN(redirect_map), FN(sk_redirect_map), FN(sock_map_update), FN(xdp_adjust_meta), FN(perf_event_read_value), FN(perf_prog_read_value), FN(getsockopt), FN(override_return), FN(sock_ops_cb_flags_set), FN(msg_redirect_map), FN(msg_apply_bytes), FN(msg_cork_bytes), FN(msg_pull_data), FN(bind), FN(xdp_adjust_tail), FN(skb_get_xfrm_state), FN(get_stack), FN(skb_load_bytes_relative), FN(fib_lookup), FN(sock_hash_update), FN(msg_redirect_hash), FN(sk_redirect_hash), FN(lwt_push_encap), FN(lwt_seg6_store_bytes), FN(lwt_seg6_adjust_srh), FN(lwt_seg6_action), FN(rc_repeat), FN(rc_keydown), FN(skb_cgroup_id), FN(get_current_cgroup_id), FN(get_local_storage), FN(sk_select_reuseport), FN(skb_ancestor_cgroup_id), FN(sk_lookup_tcp), FN(sk_lookup_udp), FN(sk_release), FN(map_push_elem), FN(map_pop_elem), FN(map_peek_elem), FN(msg_push_data), FN(msg_pop_data), FN(rc_pointer_rel), FN(spin_lock), FN(spin_unlock), FN(sk_fullsock), FN(tcp_sock), FN(skb_ecn_set_ce), FN(get_listener_sock), FN(skc_lookup_tcp), FN(tcp_check_syncookie), FN(sysctl_get_name), FN(sysctl_get_current_value), FN(sysctl_get_new_value), FN(sysctl_set_new_value), FN(strtol), FN(strtoul), FN(sk_storage_get), FN(sk_storage_delete), FN(send_signal), FN(tcp_gen_syncookie), FN(skb_output), FN(probe_read_user), FN(probe_read_kernel), FN(probe_read_user_str), FN(probe_read_kernel_str), FN(tcp_send_ack), FN(send_signal_thread), FN(jiffies64), #define __BPF_ENUM_FN(x) BPF_FUNC_ ##x enum bpf_func_id { __BPF_FUNC_MAPPER(__BPF_ENUM_FN) __BPF_FUNC_MAX_ID, @@ -601,7 +621,7 @@ struct bpf_map_info { __u32 map_flags; char name[BPF_OBJ_NAME_LEN]; __u32 ifindex; - __u32 : 32; + __u32 btf_vmlinux_value_type_id; __u64 netns_dev; __u64 netns_ino; __u32 btf_id; diff --git a/libc/kernel/uapi/linux/btf.h b/libc/kernel/uapi/linux/btf.h index 21e7596c1..f22d637d4 100644 --- a/libc/kernel/uapi/linux/btf.h +++ b/libc/kernel/uapi/linux/btf.h @@ -91,7 +91,13 @@ struct btf_param { }; enum { BTF_VAR_STATIC = 0, - BTF_VAR_GLOBAL_ALLOCATED, + BTF_VAR_GLOBAL_ALLOCATED = 1, + BTF_VAR_GLOBAL_EXTERN = 2, +}; +enum btf_func_linkage { + BTF_FUNC_STATIC = 0, + BTF_FUNC_GLOBAL = 1, + BTF_FUNC_EXTERN = 2, }; struct btf_var { __u32 linkage; diff --git a/libc/kernel/uapi/linux/dm-ioctl.h b/libc/kernel/uapi/linux/dm-ioctl.h index 51e997ff1..130c4c787 100644 --- a/libc/kernel/uapi/linux/dm-ioctl.h +++ b/libc/kernel/uapi/linux/dm-ioctl.h @@ -104,9 +104,9 @@ enum { #define DM_TARGET_MSG _IOWR(DM_IOCTL, DM_TARGET_MSG_CMD, struct dm_ioctl) #define DM_DEV_SET_GEOMETRY _IOWR(DM_IOCTL, DM_DEV_SET_GEOMETRY_CMD, struct dm_ioctl) #define DM_VERSION_MAJOR 4 -#define DM_VERSION_MINOR 41 +#define DM_VERSION_MINOR 42 #define DM_VERSION_PATCHLEVEL 0 -#define DM_VERSION_EXTRA "-ioctl(2019-09-16)" +#define DM_VERSION_EXTRA "-ioctl(2020-02-27)" #define DM_READONLY_FLAG (1 << 0) #define DM_SUSPEND_FLAG (1 << 1) #define DM_PERSISTENT_DEV_FLAG (1 << 3) diff --git a/libc/kernel/uapi/linux/gigaset_dev.h b/libc/kernel/uapi/linux/dma-heap.h index 5741d7d51..a2746e3f0 100644 --- a/libc/kernel/uapi/linux/gigaset_dev.h +++ b/libc/kernel/uapi/linux/dma-heap.h @@ -16,15 +16,18 @@ *** **************************************************************************** ****************************************************************************/ -#ifndef GIGASET_INTERFACE_H -#define GIGASET_INTERFACE_H +#ifndef _UAPI_LINUX_DMABUF_POOL_H +#define _UAPI_LINUX_DMABUF_POOL_H #include <linux/ioctl.h> -#define GIGASET_IOCTL 0x47 -#define GIGASET_REDIR _IOWR(GIGASET_IOCTL, 0, int) -#define GIGASET_CONFIG _IOWR(GIGASET_IOCTL, 1, int) -#define GIGASET_BRKCHARS _IOW(GIGASET_IOCTL, 2, unsigned char[6]) -#define GIGASET_VERSION _IOWR(GIGASET_IOCTL, 3, unsigned[4]) -#define GIGVER_DRIVER 0 -#define GIGVER_COMPAT 1 -#define GIGVER_FWBASE 2 +#include <linux/types.h> +#define DMA_HEAP_VALID_FD_FLAGS (O_CLOEXEC | O_ACCMODE) +#define DMA_HEAP_VALID_HEAP_FLAGS (0) +struct dma_heap_allocation_data { + __u64 len; + __u32 fd; + __u32 fd_flags; + __u64 heap_flags; +}; +#define DMA_HEAP_IOC_MAGIC 'H' +#define DMA_HEAP_IOCTL_ALLOC _IOWR(DMA_HEAP_IOC_MAGIC, 0x0, struct dma_heap_allocation_data) #endif diff --git a/libc/kernel/uapi/linux/ethtool.h b/libc/kernel/uapi/linux/ethtool.h index cc951d1da..93ff2a959 100644 --- a/libc/kernel/uapi/linux/ethtool.h +++ b/libc/kernel/uapi/linux/ethtool.h @@ -207,6 +207,10 @@ enum ethtool_stringset { ETH_SS_TUNABLES, ETH_SS_PHY_STATS, ETH_SS_PHY_TUNABLES, + ETH_SS_LINK_MODES, + ETH_SS_MSG_CLASSES, + ETH_SS_WOL_MODES, + ETH_SS_COUNT }; struct ethtool_gstrings { __u32 cmd; @@ -726,6 +730,7 @@ enum ethtool_link_mode_bit_indices { #define WAKE_MAGIC (1 << 5) #define WAKE_MAGICSECURE (1 << 6) #define WAKE_FILTER (1 << 7) +#define WOL_MODE_COUNT 8 #define TCP_V4_FLOW 0x01 #define UDP_V4_FLOW 0x02 #define SCTP_V4_FLOW 0x03 diff --git a/libc/kernel/uapi/linux/ethtool_netlink.h b/libc/kernel/uapi/linux/ethtool_netlink.h new file mode 100644 index 000000000..e0f2fc763 --- /dev/null +++ b/libc/kernel/uapi/linux/ethtool_netlink.h @@ -0,0 +1,169 @@ +/**************************************************************************** + **************************************************************************** + *** + *** This header was automatically generated from a Linux kernel header + *** of the same name, to make information necessary for userspace to + *** call into the kernel available to libc. It contains only constants, + *** structures, and macros generated from the original header, and thus, + *** contains no copyrightable information. + *** + *** To edit the content of this header, modify the corresponding + *** source file (e.g. under external/kernel-headers/original/) then + *** run bionic/libc/kernel/tools/update_all.py + *** + *** Any manual change here will be lost the next time this script will + *** be run. You've been warned! + *** + **************************************************************************** + ****************************************************************************/ +#ifndef _UAPI_LINUX_ETHTOOL_NETLINK_H_ +#define _UAPI_LINUX_ETHTOOL_NETLINK_H_ +#include <linux/ethtool.h> +enum { + ETHTOOL_MSG_USER_NONE, + ETHTOOL_MSG_STRSET_GET, + ETHTOOL_MSG_LINKINFO_GET, + ETHTOOL_MSG_LINKINFO_SET, + ETHTOOL_MSG_LINKMODES_GET, + ETHTOOL_MSG_LINKMODES_SET, + ETHTOOL_MSG_LINKSTATE_GET, + ETHTOOL_MSG_DEBUG_GET, + ETHTOOL_MSG_DEBUG_SET, + ETHTOOL_MSG_WOL_GET, + ETHTOOL_MSG_WOL_SET, + __ETHTOOL_MSG_USER_CNT, + ETHTOOL_MSG_USER_MAX = __ETHTOOL_MSG_USER_CNT - 1 +}; +enum { + ETHTOOL_MSG_KERNEL_NONE, + ETHTOOL_MSG_STRSET_GET_REPLY, + ETHTOOL_MSG_LINKINFO_GET_REPLY, + ETHTOOL_MSG_LINKINFO_NTF, + ETHTOOL_MSG_LINKMODES_GET_REPLY, + ETHTOOL_MSG_LINKMODES_NTF, + ETHTOOL_MSG_LINKSTATE_GET_REPLY, + ETHTOOL_MSG_DEBUG_GET_REPLY, + ETHTOOL_MSG_DEBUG_NTF, + ETHTOOL_MSG_WOL_GET_REPLY, + ETHTOOL_MSG_WOL_NTF, + __ETHTOOL_MSG_KERNEL_CNT, + ETHTOOL_MSG_KERNEL_MAX = __ETHTOOL_MSG_KERNEL_CNT - 1 +}; +#define ETHTOOL_FLAG_COMPACT_BITSETS (1 << 0) +#define ETHTOOL_FLAG_OMIT_REPLY (1 << 1) +#define ETHTOOL_FLAG_ALL (ETHTOOL_FLAG_COMPACT_BITSETS | ETHTOOL_FLAG_OMIT_REPLY) +enum { + ETHTOOL_A_HEADER_UNSPEC, + ETHTOOL_A_HEADER_DEV_INDEX, + ETHTOOL_A_HEADER_DEV_NAME, + ETHTOOL_A_HEADER_FLAGS, + __ETHTOOL_A_HEADER_CNT, + ETHTOOL_A_HEADER_MAX = __ETHTOOL_A_HEADER_CNT - 1 +}; +enum { + ETHTOOL_A_BITSET_BIT_UNSPEC, + ETHTOOL_A_BITSET_BIT_INDEX, + ETHTOOL_A_BITSET_BIT_NAME, + ETHTOOL_A_BITSET_BIT_VALUE, + __ETHTOOL_A_BITSET_BIT_CNT, + ETHTOOL_A_BITSET_BIT_MAX = __ETHTOOL_A_BITSET_BIT_CNT - 1 +}; +enum { + ETHTOOL_A_BITSET_BITS_UNSPEC, + ETHTOOL_A_BITSET_BITS_BIT, + __ETHTOOL_A_BITSET_BITS_CNT, + ETHTOOL_A_BITSET_BITS_MAX = __ETHTOOL_A_BITSET_BITS_CNT - 1 +}; +enum { + ETHTOOL_A_BITSET_UNSPEC, + ETHTOOL_A_BITSET_NOMASK, + ETHTOOL_A_BITSET_SIZE, + ETHTOOL_A_BITSET_BITS, + ETHTOOL_A_BITSET_VALUE, + ETHTOOL_A_BITSET_MASK, + __ETHTOOL_A_BITSET_CNT, + ETHTOOL_A_BITSET_MAX = __ETHTOOL_A_BITSET_CNT - 1 +}; +enum { + ETHTOOL_A_STRING_UNSPEC, + ETHTOOL_A_STRING_INDEX, + ETHTOOL_A_STRING_VALUE, + __ETHTOOL_A_STRING_CNT, + ETHTOOL_A_STRING_MAX = __ETHTOOL_A_STRING_CNT - 1 +}; +enum { + ETHTOOL_A_STRINGS_UNSPEC, + ETHTOOL_A_STRINGS_STRING, + __ETHTOOL_A_STRINGS_CNT, + ETHTOOL_A_STRINGS_MAX = __ETHTOOL_A_STRINGS_CNT - 1 +}; +enum { + ETHTOOL_A_STRINGSET_UNSPEC, + ETHTOOL_A_STRINGSET_ID, + ETHTOOL_A_STRINGSET_COUNT, + ETHTOOL_A_STRINGSET_STRINGS, + __ETHTOOL_A_STRINGSET_CNT, + ETHTOOL_A_STRINGSET_MAX = __ETHTOOL_A_STRINGSET_CNT - 1 +}; +enum { + ETHTOOL_A_STRINGSETS_UNSPEC, + ETHTOOL_A_STRINGSETS_STRINGSET, + __ETHTOOL_A_STRINGSETS_CNT, + ETHTOOL_A_STRINGSETS_MAX = __ETHTOOL_A_STRINGSETS_CNT - 1 +}; +enum { + ETHTOOL_A_STRSET_UNSPEC, + ETHTOOL_A_STRSET_HEADER, + ETHTOOL_A_STRSET_STRINGSETS, + ETHTOOL_A_STRSET_COUNTS_ONLY, + __ETHTOOL_A_STRSET_CNT, + ETHTOOL_A_STRSET_MAX = __ETHTOOL_A_STRSET_CNT - 1 +}; +enum { + ETHTOOL_A_LINKINFO_UNSPEC, + ETHTOOL_A_LINKINFO_HEADER, + ETHTOOL_A_LINKINFO_PORT, + ETHTOOL_A_LINKINFO_PHYADDR, + ETHTOOL_A_LINKINFO_TP_MDIX, + ETHTOOL_A_LINKINFO_TP_MDIX_CTRL, + ETHTOOL_A_LINKINFO_TRANSCEIVER, + __ETHTOOL_A_LINKINFO_CNT, + ETHTOOL_A_LINKINFO_MAX = __ETHTOOL_A_LINKINFO_CNT - 1 +}; +enum { + ETHTOOL_A_LINKMODES_UNSPEC, + ETHTOOL_A_LINKMODES_HEADER, + ETHTOOL_A_LINKMODES_AUTONEG, + ETHTOOL_A_LINKMODES_OURS, + ETHTOOL_A_LINKMODES_PEER, + ETHTOOL_A_LINKMODES_SPEED, + ETHTOOL_A_LINKMODES_DUPLEX, + __ETHTOOL_A_LINKMODES_CNT, + ETHTOOL_A_LINKMODES_MAX = __ETHTOOL_A_LINKMODES_CNT - 1 +}; +enum { + ETHTOOL_A_LINKSTATE_UNSPEC, + ETHTOOL_A_LINKSTATE_HEADER, + ETHTOOL_A_LINKSTATE_LINK, + __ETHTOOL_A_LINKSTATE_CNT, + ETHTOOL_A_LINKSTATE_MAX = __ETHTOOL_A_LINKSTATE_CNT - 1 +}; +enum { + ETHTOOL_A_DEBUG_UNSPEC, + ETHTOOL_A_DEBUG_HEADER, + ETHTOOL_A_DEBUG_MSGMASK, + __ETHTOOL_A_DEBUG_CNT, + ETHTOOL_A_DEBUG_MAX = __ETHTOOL_A_DEBUG_CNT - 1 +}; +enum { + ETHTOOL_A_WOL_UNSPEC, + ETHTOOL_A_WOL_HEADER, + ETHTOOL_A_WOL_MODES, + ETHTOOL_A_WOL_SOPASS, + __ETHTOOL_A_WOL_CNT, + ETHTOOL_A_WOL_MAX = __ETHTOOL_A_WOL_CNT - 1 +}; +#define ETHTOOL_GENL_NAME "ethtool" +#define ETHTOOL_GENL_VERSION 1 +#define ETHTOOL_MCGRP_MONITOR_NAME "monitor" +#endif diff --git a/libc/kernel/uapi/linux/fcntl.h b/libc/kernel/uapi/linux/fcntl.h index d0f19c856..84f0095b2 100644 --- a/libc/kernel/uapi/linux/fcntl.h +++ b/libc/kernel/uapi/linux/fcntl.h @@ -19,6 +19,7 @@ #ifndef _UAPI_LINUX_FCNTL_H #define _UAPI_LINUX_FCNTL_H #include <asm/fcntl.h> +#include <linux/openat2.h> #define F_SETLEASE (F_LINUX_SPECIFIC_BASE + 0) #define F_GETLEASE (F_LINUX_SPECIFIC_BASE + 1) #define F_CANCELLK (F_LINUX_SPECIFIC_BASE + 5) diff --git a/libc/kernel/uapi/linux/fscrypt.h b/libc/kernel/uapi/linux/fscrypt.h index f91ce85e8..b4361ecd9 100644 --- a/libc/kernel/uapi/linux/fscrypt.h +++ b/libc/kernel/uapi/linux/fscrypt.h @@ -18,6 +18,7 @@ ****************************************************************************/ #ifndef _UAPI_LINUX_FSCRYPT_H #define _UAPI_LINUX_FSCRYPT_H +#include <linux/ioctl.h> #include <linux/types.h> #define FSCRYPT_POLICY_FLAGS_PAD_4 0x00 #define FSCRYPT_POLICY_FLAGS_PAD_8 0x01 @@ -80,10 +81,16 @@ struct fscrypt_key_specifier { __u8 identifier[FSCRYPT_KEY_IDENTIFIER_SIZE]; } u; }; +struct fscrypt_provisioning_key_payload { + __u32 type; + __u32 __reserved; + __u8 raw[]; +}; struct fscrypt_add_key_arg { struct fscrypt_key_specifier key_spec; __u32 raw_size; - __u32 __reserved[8]; + __u32 key_id; + __u32 __reserved[7]; #define __FSCRYPT_ADD_KEY_FLAG_HW_WRAPPED 0x00000001 __u32 __flags; __u8 raw[]; @@ -115,6 +122,7 @@ struct fscrypt_get_key_status_arg { #define FS_IOC_REMOVE_ENCRYPTION_KEY _IOWR('f', 24, struct fscrypt_remove_key_arg) #define FS_IOC_REMOVE_ENCRYPTION_KEY_ALL_USERS _IOWR('f', 25, struct fscrypt_remove_key_arg) #define FS_IOC_GET_ENCRYPTION_KEY_STATUS _IOWR('f', 26, struct fscrypt_get_key_status_arg) +#define FS_IOC_GET_ENCRYPTION_NONCE _IOR('f', 27, __u8[16]) #define FS_KEY_DESCRIPTOR_SIZE FSCRYPT_KEY_DESCRIPTOR_SIZE #define FS_POLICY_FLAGS_PAD_4 FSCRYPT_POLICY_FLAGS_PAD_4 #define FS_POLICY_FLAGS_PAD_8 FSCRYPT_POLICY_FLAGS_PAD_8 diff --git a/libc/kernel/uapi/linux/hdlc/ioctl.h b/libc/kernel/uapi/linux/hdlc/ioctl.h index 67b4d139b..3c727c5e9 100644 --- a/libc/kernel/uapi/linux/hdlc/ioctl.h +++ b/libc/kernel/uapi/linux/hdlc/ioctl.h @@ -79,5 +79,13 @@ typedef struct { unsigned int interval; unsigned int timeout; } cisco_proto; +typedef struct { + unsigned short dce; + unsigned int modulo; + unsigned int window; + unsigned int t1; + unsigned int t2; + unsigned int n2; +} x25_hdlc_proto; #endif #endif diff --git a/libc/kernel/uapi/linux/hidraw.h b/libc/kernel/uapi/linux/hidraw.h index 3ce49e185..ab7ed1c5a 100644 --- a/libc/kernel/uapi/linux/hidraw.h +++ b/libc/kernel/uapi/linux/hidraw.h @@ -36,6 +36,7 @@ struct hidraw_devinfo { #define HIDIOCGRAWPHYS(len) _IOC(_IOC_READ, 'H', 0x05, len) #define HIDIOCSFEATURE(len) _IOC(_IOC_WRITE | _IOC_READ, 'H', 0x06, len) #define HIDIOCGFEATURE(len) _IOC(_IOC_WRITE | _IOC_READ, 'H', 0x07, len) +#define HIDIOCGRAWUNIQ(len) _IOC(_IOC_READ, 'H', 0x08, len) #define HIDRAW_FIRST_MINOR 0 #define HIDRAW_MAX_DEVICES 64 #define HIDRAW_BUFFER_SIZE 64 diff --git a/libc/kernel/uapi/linux/idxd.h b/libc/kernel/uapi/linux/idxd.h new file mode 100644 index 000000000..9c96af8ed --- /dev/null +++ b/libc/kernel/uapi/linux/idxd.h @@ -0,0 +1,210 @@ +/**************************************************************************** + **************************************************************************** + *** + *** This header was automatically generated from a Linux kernel header + *** of the same name, to make information necessary for userspace to + *** call into the kernel available to libc. It contains only constants, + *** structures, and macros generated from the original header, and thus, + *** contains no copyrightable information. + *** + *** To edit the content of this header, modify the corresponding + *** source file (e.g. under external/kernel-headers/original/) then + *** run bionic/libc/kernel/tools/update_all.py + *** + *** Any manual change here will be lost the next time this script will + *** be run. You've been warned! + *** + **************************************************************************** + ****************************************************************************/ +#ifndef _USR_IDXD_H_ +#define _USR_IDXD_H_ +#include <stdint.h> +#define IDXD_OP_FLAG_FENCE 0x0001 +#define IDXD_OP_FLAG_BOF 0x0002 +#define IDXD_OP_FLAG_CRAV 0x0004 +#define IDXD_OP_FLAG_RCR 0x0008 +#define IDXD_OP_FLAG_RCI 0x0010 +#define IDXD_OP_FLAG_CRSTS 0x0020 +#define IDXD_OP_FLAG_CR 0x0080 +#define IDXD_OP_FLAG_CC 0x0100 +#define IDXD_OP_FLAG_ADDR1_TCS 0x0200 +#define IDXD_OP_FLAG_ADDR2_TCS 0x0400 +#define IDXD_OP_FLAG_ADDR3_TCS 0x0800 +#define IDXD_OP_FLAG_CR_TCS 0x1000 +#define IDXD_OP_FLAG_STORD 0x2000 +#define IDXD_OP_FLAG_DRDBK 0x4000 +#define IDXD_OP_FLAG_DSTS 0x8000 +enum dsa_opcode { + DSA_OPCODE_NOOP = 0, + DSA_OPCODE_BATCH, + DSA_OPCODE_DRAIN, + DSA_OPCODE_MEMMOVE, + DSA_OPCODE_MEMFILL, + DSA_OPCODE_COMPARE, + DSA_OPCODE_COMPVAL, + DSA_OPCODE_CR_DELTA, + DSA_OPCODE_AP_DELTA, + DSA_OPCODE_DUALCAST, + DSA_OPCODE_CRCGEN = 0x10, + DSA_OPCODE_COPY_CRC, + DSA_OPCODE_DIF_CHECK, + DSA_OPCODE_DIF_INS, + DSA_OPCODE_DIF_STRP, + DSA_OPCODE_DIF_UPDT, + DSA_OPCODE_CFLUSH = 0x20, +}; +enum dsa_completion_status { + DSA_COMP_NONE = 0, + DSA_COMP_SUCCESS, + DSA_COMP_SUCCESS_PRED, + DSA_COMP_PAGE_FAULT_NOBOF, + DSA_COMP_PAGE_FAULT_IR, + DSA_COMP_BATCH_FAIL, + DSA_COMP_BATCH_PAGE_FAULT, + DSA_COMP_DR_OFFSET_NOINC, + DSA_COMP_DR_OFFSET_ERANGE, + DSA_COMP_DIF_ERR, + DSA_COMP_BAD_OPCODE = 0x10, + DSA_COMP_INVALID_FLAGS, + DSA_COMP_NOZERO_RESERVE, + DSA_COMP_XFER_ERANGE, + DSA_COMP_DESC_CNT_ERANGE, + DSA_COMP_DR_ERANGE, + DSA_COMP_OVERLAP_BUFFERS, + DSA_COMP_DCAST_ERR, + DSA_COMP_DESCLIST_ALIGN, + DSA_COMP_INT_HANDLE_INVAL, + DSA_COMP_CRA_XLAT, + DSA_COMP_CRA_ALIGN, + DSA_COMP_ADDR_ALIGN, + DSA_COMP_PRIV_BAD, + DSA_COMP_TRAFFIC_CLASS_CONF, + DSA_COMP_PFAULT_RDBA, + DSA_COMP_HW_ERR1, + DSA_COMP_HW_ERR_DRB, + DSA_COMP_TRANSLATION_FAIL, +}; +#define DSA_COMP_STATUS_MASK 0x7f +#define DSA_COMP_STATUS_WRITE 0x80 +struct dsa_batch_desc { + uint32_t pasid : 20; + uint32_t rsvd : 11; + uint32_t priv : 1; + uint32_t flags : 24; + uint32_t opcode : 8; + uint64_t completion_addr; + uint64_t desc_list_addr; + uint64_t rsvd1; + uint32_t desc_count; + uint16_t interrupt_handle; + uint16_t rsvd2; + uint8_t rsvd3[24]; +} __attribute__((packed)); +struct dsa_hw_desc { + uint32_t pasid : 20; + uint32_t rsvd : 11; + uint32_t priv : 1; + uint32_t flags : 24; + uint32_t opcode : 8; + uint64_t completion_addr; + union { + uint64_t src_addr; + uint64_t rdback_addr; + uint64_t pattern; + }; + union { + uint64_t dst_addr; + uint64_t rdback_addr2; + uint64_t src2_addr; + uint64_t comp_pattern; + }; + uint32_t xfer_size; + uint16_t int_handle; + uint16_t rsvd1; + union { + uint8_t expected_res; + struct { + uint64_t delta_addr; + uint32_t max_delta_size; + }; + uint32_t delta_rec_size; + uint64_t dest2; + struct { + uint32_t crc_seed; + uint32_t crc_rsvd; + uint64_t seed_addr; + }; + struct { + uint8_t src_dif_flags; + uint8_t dif_chk_res; + uint8_t dif_chk_flags; + uint8_t dif_chk_res2[5]; + uint32_t chk_ref_tag_seed; + uint16_t chk_app_tag_mask; + uint16_t chk_app_tag_seed; + }; + struct { + uint8_t dif_ins_res; + uint8_t dest_dif_flag; + uint8_t dif_ins_flags; + uint8_t dif_ins_res2[13]; + uint32_t ins_ref_tag_seed; + uint16_t ins_app_tag_mask; + uint16_t ins_app_tag_seed; + }; + struct { + uint8_t src_upd_flags; + uint8_t upd_dest_flags; + uint8_t dif_upd_flags; + uint8_t dif_upd_res[5]; + uint32_t src_ref_tag_seed; + uint16_t src_app_tag_mask; + uint16_t src_app_tag_seed; + uint32_t dest_ref_tag_seed; + uint16_t dest_app_tag_mask; + uint16_t dest_app_tag_seed; + }; + uint8_t op_specific[24]; + }; +} __attribute__((packed)); +struct dsa_raw_desc { + uint64_t field[8]; +} __attribute__((packed)); +struct dsa_completion_record { + volatile uint8_t status; + union { + uint8_t result; + uint8_t dif_status; + }; + uint16_t rsvd; + uint32_t bytes_completed; + uint64_t fault_addr; + union { + uint16_t delta_rec_size; + uint16_t crc_val; + struct { + uint32_t dif_chk_ref_tag; + uint16_t dif_chk_app_tag_mask; + uint16_t dif_chk_app_tag; + }; + struct { + uint64_t dif_ins_res; + uint32_t dif_ins_ref_tag; + uint16_t dif_ins_app_tag_mask; + uint16_t dif_ins_app_tag; + }; + struct { + uint32_t dif_upd_src_ref_tag; + uint16_t dif_upd_src_app_tag_mask; + uint16_t dif_upd_src_app_tag; + uint32_t dif_upd_dest_ref_tag; + uint16_t dif_upd_dest_app_tag_mask; + uint16_t dif_upd_dest_app_tag; + }; + uint8_t op_specific[16]; + }; +} __attribute__((packed)); +struct dsa_raw_completion_record { + uint64_t field[4]; +} __attribute__((packed)); +#endif diff --git a/libc/kernel/uapi/linux/if.h b/libc/kernel/uapi/linux/if.h index 12967f791..0821f2bbf 100644 --- a/libc/kernel/uapi/linux/if.h +++ b/libc/kernel/uapi/linux/if.h @@ -134,6 +134,7 @@ struct if_settings { fr_proto __user * fr; fr_proto_pvc __user * fr_pvc; fr_proto_pvc_info __user * fr_pvc_info; + x25_hdlc_proto __user * x25; sync_serial_settings __user * sync; te1_settings __user * te1; } ifs_ifsu; diff --git a/libc/kernel/uapi/linux/if_bonding.h b/libc/kernel/uapi/linux/if_bonding.h index a1fa959e6..0079f30f1 100644 --- a/libc/kernel/uapi/linux/if_bonding.h +++ b/libc/kernel/uapi/linux/if_bonding.h @@ -50,6 +50,14 @@ #define BOND_XMIT_POLICY_LAYER23 2 #define BOND_XMIT_POLICY_ENCAP23 3 #define BOND_XMIT_POLICY_ENCAP34 4 +#define LACP_STATE_LACP_ACTIVITY 0x1 +#define LACP_STATE_LACP_TIMEOUT 0x2 +#define LACP_STATE_AGGREGATION 0x4 +#define LACP_STATE_SYNCHRONIZATION 0x8 +#define LACP_STATE_COLLECTING 0x10 +#define LACP_STATE_DISTRIBUTING 0x20 +#define LACP_STATE_DEFAULTED 0x40 +#define LACP_STATE_EXPIRED 0x80 typedef struct ifbond { __s32 bond_mode; __s32 num_slaves; diff --git a/libc/kernel/uapi/linux/if_bridge.h b/libc/kernel/uapi/linux/if_bridge.h index 03cc1c45d..b644ad010 100644 --- a/libc/kernel/uapi/linux/if_bridge.h +++ b/libc/kernel/uapi/linux/if_bridge.h @@ -115,6 +115,7 @@ enum { #define BRIDGE_VLAN_INFO_RANGE_BEGIN (1 << 3) #define BRIDGE_VLAN_INFO_RANGE_END (1 << 4) #define BRIDGE_VLAN_INFO_BRENTRY (1 << 5) +#define BRIDGE_VLAN_INFO_ONLY_OPTS (1 << 6) struct bridge_vlan_info { __u16 flags; __u16 vid; @@ -136,6 +137,34 @@ struct bridge_vlan_xstats { __u16 flags; __u32 pad2; }; +struct bridge_stp_xstats { + __u64 transition_blk; + __u64 transition_fwd; + __u64 rx_bpdu; + __u64 tx_bpdu; + __u64 rx_tcn; + __u64 tx_tcn; +}; +struct br_vlan_msg { + __u8 family; + __u8 reserved1; + __u16 reserved2; + __u32 ifindex; +}; +enum { + BRIDGE_VLANDB_UNSPEC, + BRIDGE_VLANDB_ENTRY, + __BRIDGE_VLANDB_MAX, +}; +#define BRIDGE_VLANDB_MAX (__BRIDGE_VLANDB_MAX - 1) +enum { + BRIDGE_VLANDB_ENTRY_UNSPEC, + BRIDGE_VLANDB_ENTRY_INFO, + BRIDGE_VLANDB_ENTRY_RANGE, + BRIDGE_VLANDB_ENTRY_STATE, + __BRIDGE_VLANDB_ENTRY_MAX, +}; +#define BRIDGE_VLANDB_ENTRY_MAX (__BRIDGE_VLANDB_ENTRY_MAX - 1) enum { MDBA_UNSPEC, MDBA_MDB, @@ -212,6 +241,7 @@ enum { BRIDGE_XSTATS_VLAN, BRIDGE_XSTATS_MCAST, BRIDGE_XSTATS_PAD, + BRIDGE_XSTATS_STP, __BRIDGE_XSTATS_MAX }; #define BRIDGE_XSTATS_MAX (__BRIDGE_XSTATS_MAX - 1) diff --git a/libc/kernel/uapi/linux/if_link.h b/libc/kernel/uapi/linux/if_link.h index 7843fb52e..52a18afc7 100644 --- a/libc/kernel/uapi/linux/if_link.h +++ b/libc/kernel/uapi/linux/if_link.h @@ -146,6 +146,7 @@ enum { IFLA_MAX_MTU, IFLA_PROP_LIST, IFLA_ALT_IFNAME, + IFLA_PERM_ADDRESS, __IFLA_MAX }; #define IFLA_MAX (__IFLA_MAX - 1) @@ -384,6 +385,12 @@ enum macsec_validation_type { __MACSEC_VALIDATE_END, MACSEC_VALIDATE_MAX = __MACSEC_VALIDATE_END - 1, }; +enum macsec_offload { + MACSEC_OFFLOAD_OFF = 0, + MACSEC_OFFLOAD_PHY = 1, + __MACSEC_OFFLOAD_END, + MACSEC_OFFLOAD_MAX = __MACSEC_OFFLOAD_END - 1, +}; enum { IFLA_IPVLAN_UNSPEC, IFLA_IPVLAN_MODE, diff --git a/libc/kernel/uapi/linux/if_macsec.h b/libc/kernel/uapi/linux/if_macsec.h index a58f5316e..d77bf21c3 100644 --- a/libc/kernel/uapi/linux/if_macsec.h +++ b/libc/kernel/uapi/linux/if_macsec.h @@ -40,6 +40,7 @@ enum macsec_attrs { MACSEC_ATTR_RXSC_LIST, MACSEC_ATTR_TXSC_STATS, MACSEC_ATTR_SECY_STATS, + MACSEC_ATTR_OFFLOAD, __MACSEC_ATTR_END, NUM_MACSEC_ATTR = __MACSEC_ATTR_END, MACSEC_ATTR_MAX = __MACSEC_ATTR_END - 1, @@ -88,6 +89,14 @@ enum macsec_sa_attrs { NUM_MACSEC_SA_ATTR = __MACSEC_SA_ATTR_END, MACSEC_SA_ATTR_MAX = __MACSEC_SA_ATTR_END - 1, }; +enum macsec_offload_attrs { + MACSEC_OFFLOAD_ATTR_UNSPEC, + MACSEC_OFFLOAD_ATTR_TYPE, + MACSEC_OFFLOAD_ATTR_PAD, + __MACSEC_OFFLOAD_ATTR_END, + NUM_MACSEC_OFFLOAD_ATTR = __MACSEC_OFFLOAD_ATTR_END, + MACSEC_OFFLOAD_ATTR_MAX = __MACSEC_OFFLOAD_ATTR_END - 1, +}; enum macsec_nl_commands { MACSEC_CMD_GET_TXSC, MACSEC_CMD_ADD_RXSC, @@ -99,6 +108,7 @@ enum macsec_nl_commands { MACSEC_CMD_ADD_RXSA, MACSEC_CMD_DEL_RXSA, MACSEC_CMD_UPD_RXSA, + MACSEC_CMD_UPD_OFFLOAD, }; enum macsec_rxsc_stats_attr { MACSEC_RXSC_STATS_ATTR_UNSPEC, diff --git a/libc/kernel/uapi/linux/in.h b/libc/kernel/uapi/linux/in.h index f1dab00eb..99b54cc3c 100644 --- a/libc/kernel/uapi/linux/in.h +++ b/libc/kernel/uapi/linux/in.h @@ -74,8 +74,12 @@ enum { #define IPPROTO_UDPLITE IPPROTO_UDPLITE IPPROTO_MPLS = 137, #define IPPROTO_MPLS IPPROTO_MPLS + IPPROTO_ETHERNET = 143, +#define IPPROTO_ETHERNET IPPROTO_ETHERNET IPPROTO_RAW = 255, #define IPPROTO_RAW IPPROTO_RAW + IPPROTO_MPTCP = 262, +#define IPPROTO_MPTCP IPPROTO_MPTCP IPPROTO_MAX }; #endif diff --git a/libc/kernel/uapi/linux/incrementalfs.h b/libc/kernel/uapi/linux/incrementalfs.h new file mode 100644 index 000000000..531760d8c --- /dev/null +++ b/libc/kernel/uapi/linux/incrementalfs.h @@ -0,0 +1,116 @@ +/**************************************************************************** + **************************************************************************** + *** + *** This header was automatically generated from a Linux kernel header + *** of the same name, to make information necessary for userspace to + *** call into the kernel available to libc. It contains only constants, + *** structures, and macros generated from the original header, and thus, + *** contains no copyrightable information. + *** + *** To edit the content of this header, modify the corresponding + *** source file (e.g. under external/kernel-headers/original/) then + *** run bionic/libc/kernel/tools/update_all.py + *** + *** Any manual change here will be lost the next time this script will + *** be run. You've been warned! + *** + **************************************************************************** + ****************************************************************************/ +#ifndef _UAPI_LINUX_INCREMENTALFS_H +#define _UAPI_LINUX_INCREMENTALFS_H +#include <linux/limits.h> +#include <linux/ioctl.h> +#include <linux/types.h> +#include <linux/xattr.h> +#define INCFS_NAME "incremental-fs" +#define INCFS_MAGIC_NUMBER (0x5346434e49ul) +#define INCFS_DATA_FILE_BLOCK_SIZE 4096 +#define INCFS_HEADER_VER 1 +#define INCFS_MAX_HASH_SIZE 32 +#define INCFS_MAX_FILE_ATTR_SIZE 512 +#define INCFS_PENDING_READS_FILENAME ".pending_reads" +#define INCFS_LOG_FILENAME ".log" +#define INCFS_XATTR_ID_NAME (XATTR_USER_PREFIX "incfs.id") +#define INCFS_XATTR_SIZE_NAME (XATTR_USER_PREFIX "incfs.size") +#define INCFS_XATTR_METADATA_NAME (XATTR_USER_PREFIX "incfs.metadata") +#define INCFS_MAX_SIGNATURE_SIZE 8096 +#define INCFS_SIGNATURE_VERSION 2 +#define INCFS_SIGNATURE_SECTIONS 2 +#define INCFS_IOCTL_BASE_CODE 'g' +#define INCFS_IOC_CREATE_FILE _IOWR(INCFS_IOCTL_BASE_CODE, 30, struct incfs_new_file_args) +#define INCFS_IOC_READ_FILE_SIGNATURE _IOR(INCFS_IOCTL_BASE_CODE, 31, struct incfs_get_file_sig_args) +#define INCFS_IOC_FILL_BLOCKS _IOR(INCFS_IOCTL_BASE_CODE, 32, struct incfs_fill_blocks) +#define INCFS_IOC_PERMIT_FILL _IOW(INCFS_IOCTL_BASE_CODE, 33, struct incfs_permit_fill) +#define INCFS_IOC_GET_FILLED_BLOCKS _IOR(INCFS_IOCTL_BASE_CODE, 34, struct incfs_get_filled_blocks_args) +enum incfs_compression_alg { + COMPRESSION_NONE = 0, + COMPRESSION_LZ4 = 1 +}; +enum incfs_block_flags { + INCFS_BLOCK_FLAGS_NONE = 0, + INCFS_BLOCK_FLAGS_HASH = 1, +}; +typedef struct { + __u8 bytes[16]; +} incfs_uuid_t __attribute__((aligned(8))); +struct incfs_pending_read_info { + incfs_uuid_t file_id; + __aligned_u64 timestamp_us; + __u32 block_index; + __u32 serial_number; +}; +struct incfs_fill_block { + __u32 block_index; + __u32 data_len; + __aligned_u64 data; + __u8 compression; + __u8 flags; + __u16 reserved1; + __u32 reserved2; + __aligned_u64 reserved3; +}; +struct incfs_fill_blocks { + __u64 count; + __aligned_u64 fill_blocks; +}; +struct incfs_permit_fill { + __u32 file_descriptor; +}; +enum incfs_hash_tree_algorithm { + INCFS_HASH_TREE_NONE = 0, + INCFS_HASH_TREE_SHA256 = 1 +}; +struct incfs_new_file_args { + incfs_uuid_t file_id; + __aligned_u64 size; + __u16 mode; + __u16 reserved1; + __u32 reserved2; + __aligned_u64 directory_path; + __aligned_u64 file_name; + __aligned_u64 file_attr; + __u32 file_attr_len; + __u32 reserved4; + __aligned_u64 signature_info; + __aligned_u64 signature_size; + __aligned_u64 reserved6; +}; +struct incfs_get_file_sig_args { + __aligned_u64 file_signature; + __u32 file_signature_buf_size; + __u32 file_signature_len_out; +}; +struct incfs_filled_range { + __u32 begin; + __u32 end; +}; +struct incfs_get_filled_blocks_args { + __aligned_u64 range_buffer; + __u32 range_buffer_size; + __u32 start_index; + __u32 end_index; + __u32 total_blocks_out; + __u32 range_buffer_size_out; + __u32 index_out; +}; +#endif diff --git a/libc/kernel/uapi/linux/input-event-codes.h b/libc/kernel/uapi/linux/input-event-codes.h index ee0e92f2e..46cc7f071 100644 --- a/libc/kernel/uapi/linux/input-event-codes.h +++ b/libc/kernel/uapi/linux/input-event-codes.h @@ -572,6 +572,7 @@ #define KEY_DATA 0x277 #define KEY_ONSCREEN_KEYBOARD 0x278 #define KEY_PRIVACY_SCREEN_TOGGLE 0x279 +#define KEY_SELECTIVE_SCREENSHOT 0x27a #define KEY_MACRO1 0x290 #define KEY_MACRO2 0x291 #define KEY_MACRO3 0x292 diff --git a/libc/kernel/uapi/linux/io_uring.h b/libc/kernel/uapi/linux/io_uring.h index 0639a8003..588531273 100644 --- a/libc/kernel/uapi/linux/io_uring.h +++ b/libc/kernel/uapi/linux/io_uring.h @@ -40,21 +40,37 @@ struct io_uring_sqe { __u32 timeout_flags; __u32 accept_flags; __u32 cancel_flags; + __u32 open_flags; + __u32 statx_flags; + __u32 fadvise_advice; }; __u64 user_data; union { - __u16 buf_index; + struct { + __u16 buf_index; + __u16 personality; + }; __u64 __pad2[3]; }; }; -#define IOSQE_FIXED_FILE (1U << 0) -#define IOSQE_IO_DRAIN (1U << 1) -#define IOSQE_IO_LINK (1U << 2) -#define IOSQE_IO_HARDLINK (1U << 3) +enum { + IOSQE_FIXED_FILE_BIT, + IOSQE_IO_DRAIN_BIT, + IOSQE_IO_LINK_BIT, + IOSQE_IO_HARDLINK_BIT, + IOSQE_ASYNC_BIT, +}; +#define IOSQE_FIXED_FILE (1U << IOSQE_FIXED_FILE_BIT) +#define IOSQE_IO_DRAIN (1U << IOSQE_IO_DRAIN_BIT) +#define IOSQE_IO_LINK (1U << IOSQE_IO_LINK_BIT) +#define IOSQE_IO_HARDLINK (1U << IOSQE_IO_HARDLINK_BIT) +#define IOSQE_ASYNC (1U << IOSQE_ASYNC_BIT) #define IORING_SETUP_IOPOLL (1U << 0) #define IORING_SETUP_SQPOLL (1U << 1) #define IORING_SETUP_SQ_AFF (1U << 2) #define IORING_SETUP_CQSIZE (1U << 3) +#define IORING_SETUP_CLAMP (1U << 4) +#define IORING_SETUP_ATTACH_WQ (1U << 5) enum { IORING_OP_NOP, IORING_OP_READV, @@ -73,6 +89,19 @@ enum { IORING_OP_ASYNC_CANCEL, IORING_OP_LINK_TIMEOUT, IORING_OP_CONNECT, + IORING_OP_FALLOCATE, + IORING_OP_OPENAT, + IORING_OP_CLOSE, + IORING_OP_FILES_UPDATE, + IORING_OP_STATX, + IORING_OP_READ, + IORING_OP_WRITE, + IORING_OP_FADVISE, + IORING_OP_MADVISE, + IORING_OP_SEND, + IORING_OP_RECV, + IORING_OP_OPENAT2, + IORING_OP_EPOLL_CTL, IORING_OP_LAST, }; #define IORING_FSYNC_DATASYNC (1U << 0) @@ -115,13 +144,16 @@ struct io_uring_params { __u32 sq_thread_cpu; __u32 sq_thread_idle; __u32 features; - __u32 resv[4]; + __u32 wq_fd; + __u32 resv[3]; struct io_sqring_offsets sq_off; struct io_cqring_offsets cq_off; }; #define IORING_FEAT_SINGLE_MMAP (1U << 0) #define IORING_FEAT_NODROP (1U << 1) #define IORING_FEAT_SUBMIT_STABLE (1U << 2) +#define IORING_FEAT_RW_CUR_POS (1U << 3) +#define IORING_FEAT_CUR_PERSONALITY (1U << 4) #define IORING_REGISTER_BUFFERS 0 #define IORING_UNREGISTER_BUFFERS 1 #define IORING_REGISTER_FILES 2 @@ -129,9 +161,27 @@ struct io_uring_params { #define IORING_REGISTER_EVENTFD 4 #define IORING_UNREGISTER_EVENTFD 5 #define IORING_REGISTER_FILES_UPDATE 6 +#define IORING_REGISTER_EVENTFD_ASYNC 7 +#define IORING_REGISTER_PROBE 8 +#define IORING_REGISTER_PERSONALITY 9 +#define IORING_UNREGISTER_PERSONALITY 10 struct io_uring_files_update { __u32 offset; __u32 resv; __aligned_u64 fds; }; +#define IO_URING_OP_SUPPORTED (1U << 0) +struct io_uring_probe_op { + __u8 op; + __u8 resv; + __u16 flags; + __u32 resv2; +}; +struct io_uring_probe { + __u8 last_op; + __u8 ops_len; + __u16 resv; + __u32 resv2[3]; + struct io_uring_probe_op ops[0]; +}; #endif diff --git a/libc/kernel/uapi/linux/kvm.h b/libc/kernel/uapi/linux/kvm.h index b865936d1..4f40b7a66 100644 --- a/libc/kernel/uapi/linux/kvm.h +++ b/libc/kernel/uapi/linux/kvm.h @@ -788,6 +788,7 @@ struct kvm_ppc_resize_hpt { #define KVM_CAP_PPC_GUEST_DEBUG_SSTEP 176 #define KVM_CAP_ARM_NISV_TO_USER 177 #define KVM_CAP_ARM_INJECT_EXT_DABT 178 +#define KVM_CAP_S390_VCPU_RESETS 179 #ifdef KVM_CAP_IRQ_ROUTING struct kvm_irq_routing_irqchip { __u32 irqchip; @@ -1110,6 +1111,8 @@ struct kvm_enc_region { #define KVM_CLEAR_DIRTY_LOG _IOWR(KVMIO, 0xc0, struct kvm_clear_dirty_log) #define KVM_GET_SUPPORTED_HV_CPUID _IOWR(KVMIO, 0xc1, struct kvm_cpuid2) #define KVM_ARM_VCPU_FINALIZE _IOW(KVMIO, 0xc2, int) +#define KVM_S390_NORMAL_RESET _IO(KVMIO, 0xc3) +#define KVM_S390_CLEAR_RESET _IO(KVMIO, 0xc4) enum sev_cmd_id { KVM_SEV_INIT = 0, KVM_SEV_ES_INIT, diff --git a/libc/kernel/uapi/linux/magic.h b/libc/kernel/uapi/linux/magic.h index ca1daea20..439c0ac7b 100644 --- a/libc/kernel/uapi/linux/magic.h +++ b/libc/kernel/uapi/linux/magic.h @@ -93,6 +93,7 @@ #define NSFS_MAGIC 0x6e736673 #define BPF_FS_MAGIC 0xcafe4a11 #define AAFS_MAGIC 0x5a3c69f0 +#define ZONEFS_MAGIC 0x5a4f4653 #define UDF_SUPER_MAGIC 0x15013346 #define BALLOON_KVM_MAGIC 0x13661366 #define ZSMALLOC_MAGIC 0x58295829 diff --git a/libc/kernel/uapi/linux/mii.h b/libc/kernel/uapi/linux/mii.h index 3c6c56470..4ee44486f 100644 --- a/libc/kernel/uapi/linux/mii.h +++ b/libc/kernel/uapi/linux/mii.h @@ -120,6 +120,16 @@ #define NWAYTEST_RESV1 0x00ff #define NWAYTEST_LOOPBACK 0x0100 #define NWAYTEST_RESV2 0xfe00 +#define ADVERTISE_SGMII 0x0001 +#define LPA_SGMII 0x0001 +#define LPA_SGMII_DPX_SPD_MASK 0x1C00 +#define LPA_SGMII_10HALF 0x0000 +#define LPA_SGMII_10FULL 0x1000 +#define LPA_SGMII_100HALF 0x0400 +#define LPA_SGMII_100FULL 0x1400 +#define LPA_SGMII_1000HALF 0x0800 +#define LPA_SGMII_1000FULL 0x1800 +#define LPA_SGMII_LINK 0x8000 #define ADVERTISE_1000FULL 0x0200 #define ADVERTISE_1000HALF 0x0100 #define CTL1000_AS_MASTER 0x0800 diff --git a/libc/kernel/uapi/linux/net_tstamp.h b/libc/kernel/uapi/linux/net_tstamp.h index 375906ae9..4e1508a10 100644 --- a/libc/kernel/uapi/linux/net_tstamp.h +++ b/libc/kernel/uapi/linux/net_tstamp.h @@ -49,6 +49,7 @@ enum hwtstamp_tx_types { HWTSTAMP_TX_OFF, HWTSTAMP_TX_ON, HWTSTAMP_TX_ONESTEP_SYNC, + HWTSTAMP_TX_ONESTEP_P2P, }; enum hwtstamp_rx_filters { HWTSTAMP_FILTER_NONE, diff --git a/libc/kernel/uapi/linux/netfilter/nf_conntrack_common.h b/libc/kernel/uapi/linux/netfilter/nf_conntrack_common.h index 43d60ca26..152584a2e 100644 --- a/libc/kernel/uapi/linux/netfilter/nf_conntrack_common.h +++ b/libc/kernel/uapi/linux/netfilter/nf_conntrack_common.h @@ -64,7 +64,7 @@ enum ip_conntrack_status { IPS_HELPER = (1 << IPS_HELPER_BIT), IPS_OFFLOAD_BIT = 14, IPS_OFFLOAD = (1 << IPS_OFFLOAD_BIT), - IPS_UNCHANGEABLE_MASK = (IPS_NAT_DONE_MASK | IPS_NAT_MASK | IPS_EXPECTED | IPS_CONFIRMED | IPS_DYING | IPS_SEQ_ADJUST | IPS_TEMPLATE | IPS_OFFLOAD), + IPS_UNCHANGEABLE_MASK = (IPS_NAT_DONE_MASK | IPS_NAT_MASK | IPS_EXPECTED | IPS_CONFIRMED | IPS_DYING | IPS_SEQ_ADJUST | IPS_TEMPLATE | IPS_UNTRACKED | IPS_OFFLOAD), __IPS_MAX_BIT = 15, }; enum ip_conntrack_events { diff --git a/libc/kernel/uapi/linux/netfilter/nf_tables.h b/libc/kernel/uapi/linux/netfilter/nf_tables.h index 2fe11b0af..26a7b3996 100644 --- a/libc/kernel/uapi/linux/netfilter/nf_tables.h +++ b/libc/kernel/uapi/linux/netfilter/nf_tables.h @@ -52,6 +52,7 @@ enum nft_registers { #define NFT_REG_MAX (__NFT_REG_MAX - 1) #define NFT_REG_SIZE 16 #define NFT_REG32_SIZE 4 +#define NFT_REG32_COUNT (NFT_REG32_15 - NFT_REG32_00 + 1) enum nft_verdicts { NFT_CONTINUE = - 1, NFT_BREAK = - 2, @@ -172,9 +173,16 @@ enum nft_set_policies { enum nft_set_desc_attributes { NFTA_SET_DESC_UNSPEC, NFTA_SET_DESC_SIZE, + NFTA_SET_DESC_CONCAT, __NFTA_SET_DESC_MAX }; #define NFTA_SET_DESC_MAX (__NFTA_SET_DESC_MAX - 1) +enum nft_set_field_attributes { + NFTA_SET_FIELD_UNSPEC, + NFTA_SET_FIELD_LEN, + __NFTA_SET_FIELD_MAX +}; +#define NFTA_SET_FIELD_MAX (__NFTA_SET_FIELD_MAX - 1) enum nft_set_attributes { NFTA_SET_UNSPEC, NFTA_SET_TABLE, @@ -210,6 +218,7 @@ enum nft_set_elem_attributes { NFTA_SET_ELEM_EXPR, NFTA_SET_ELEM_PAD, NFTA_SET_ELEM_OBJREF, + NFTA_SET_ELEM_KEY_END, __NFTA_SET_ELEM_MAX }; #define NFTA_SET_ELEM_MAX (__NFTA_SET_ELEM_MAX - 1) @@ -256,6 +265,11 @@ enum nft_immediate_attributes { __NFTA_IMMEDIATE_MAX }; #define NFTA_IMMEDIATE_MAX (__NFTA_IMMEDIATE_MAX - 1) +enum nft_bitwise_ops { + NFT_BITWISE_BOOL, + NFT_BITWISE_LSHIFT, + NFT_BITWISE_RSHIFT, +}; enum nft_bitwise_attributes { NFTA_BITWISE_UNSPEC, NFTA_BITWISE_SREG, @@ -263,6 +277,8 @@ enum nft_bitwise_attributes { NFTA_BITWISE_LEN, NFTA_BITWISE_MASK, NFTA_BITWISE_XOR, + NFTA_BITWISE_OP, + NFTA_BITWISE_DATA, __NFTA_BITWISE_MAX }; #define NFTA_BITWISE_MAX (__NFTA_BITWISE_MAX - 1) @@ -425,6 +441,8 @@ enum nft_meta_keys { NFT_META_TIME_NS, NFT_META_TIME_DAY, NFT_META_TIME_HOUR, + NFT_META_SDIF, + NFT_META_SDIFNAME, }; enum nft_rt_keys { NFT_RT_CLASSID, diff --git a/libc/kernel/uapi/linux/hysdn_if.h b/libc/kernel/uapi/linux/openat2.h index 2aac1d0da..27136af2b 100644 --- a/libc/kernel/uapi/linux/hysdn_if.h +++ b/libc/kernel/uapi/linux/openat2.h @@ -16,16 +16,17 @@ *** **************************************************************************** ****************************************************************************/ -#define ERR_NONE 0 -#define ERR_ALREADY_BOOT 1000 -#define EPOF_BAD_MAGIC 1001 -#define ERR_BOARD_DPRAM 1002 -#define EPOF_INTERNAL 1003 -#define EPOF_BAD_IMG_SIZE 1004 -#define ERR_BOOTIMG_FAIL 1005 -#define ERR_BOOTSEQ_FAIL 1006 -#define ERR_POF_TIMEOUT 1007 -#define ERR_NOT_BOOTED 1008 -#define ERR_CONF_LONG 1009 -#define ERR_INV_CHAN 1010 -#define ERR_ASYNC_TIME 1011 +#ifndef _UAPI_LINUX_OPENAT2_H +#define _UAPI_LINUX_OPENAT2_H +#include <linux/types.h> +struct open_how { + __u64 flags; + __u64 mode; + __u64 resolve; +}; +#define RESOLVE_NO_XDEV 0x01 +#define RESOLVE_NO_MAGICLINKS 0x02 +#define RESOLVE_NO_SYMLINKS 0x04 +#define RESOLVE_BENEATH 0x08 +#define RESOLVE_IN_ROOT 0x10 +#endif diff --git a/libc/kernel/uapi/linux/openvswitch.h b/libc/kernel/uapi/linux/openvswitch.h index 99a987df4..05d750ac1 100644 --- a/libc/kernel/uapi/linux/openvswitch.h +++ b/libc/kernel/uapi/linux/openvswitch.h @@ -366,6 +366,12 @@ struct ovs_action_push_mpls { __be32 mpls_lse; __be16 mpls_ethertype; }; +struct ovs_action_add_mpls { + __be32 mpls_lse; + __be16 mpls_ethertype; + __u16 tun_flags; +}; +#define OVS_MPLS_L3_TUNNEL_FLAG_MASK (1 << 0) struct ovs_action_push_vlan { __be16 vlan_tpid; __be16 vlan_tci; @@ -439,6 +445,7 @@ enum ovs_action_attr { OVS_ACTION_ATTR_METER, OVS_ACTION_ATTR_CLONE, OVS_ACTION_ATTR_CHECK_PKT_LEN, + OVS_ACTION_ATTR_ADD_MPLS, __OVS_ACTION_ATTR_MAX, }; #define OVS_ACTION_ATTR_MAX (__OVS_ACTION_ATTR_MAX - 1) diff --git a/libc/kernel/uapi/linux/pci_regs.h b/libc/kernel/uapi/linux/pci_regs.h index 5501de074..c3f28598a 100644 --- a/libc/kernel/uapi/linux/pci_regs.h +++ b/libc/kernel/uapi/linux/pci_regs.h @@ -577,6 +577,7 @@ #define PCI_EXP_LNKCTL2_TLS_32_0GT 0x0005 #define PCI_EXP_LNKCTL2_ENTER_COMP 0x0010 #define PCI_EXP_LNKCTL2_TX_MARGIN 0x0380 +#define PCI_EXP_LNKCTL2_HASD 0x0020 #define PCI_EXP_LNKSTA2 50 #define PCI_CAP_EXP_ENDPOINT_SIZEOF_V2 52 #define PCI_EXP_SLTCAP2 52 diff --git a/libc/kernel/uapi/linux/pkt_sched.h b/libc/kernel/uapi/linux/pkt_sched.h index c965928df..f0bb319c1 100644 --- a/libc/kernel/uapi/linux/pkt_sched.h +++ b/libc/kernel/uapi/linux/pkt_sched.h @@ -725,6 +725,34 @@ struct tc_pie_xstats { __u32 maxq; __u32 ecn_mark; }; +enum { + TCA_FQ_PIE_UNSPEC, + TCA_FQ_PIE_LIMIT, + TCA_FQ_PIE_FLOWS, + TCA_FQ_PIE_TARGET, + TCA_FQ_PIE_TUPDATE, + TCA_FQ_PIE_ALPHA, + TCA_FQ_PIE_BETA, + TCA_FQ_PIE_QUANTUM, + TCA_FQ_PIE_MEMORY_LIMIT, + TCA_FQ_PIE_ECN_PROB, + TCA_FQ_PIE_ECN, + TCA_FQ_PIE_BYTEMODE, + TCA_FQ_PIE_DQ_RATE_ESTIMATOR, + __TCA_FQ_PIE_MAX +}; +#define TCA_FQ_PIE_MAX (__TCA_FQ_PIE_MAX - 1) +struct tc_fq_pie_xstats { + __u32 packets_in; + __u32 dropped; + __u32 overlimit; + __u32 overmemory; + __u32 ecn_mark; + __u32 new_flow_count; + __u32 new_flows_len; + __u32 old_flows_len; + __u32 memory_usage; +}; struct tc_cbs_qopt { __u8 offload; __u8 _pad[3]; @@ -897,4 +925,16 @@ enum { __TCA_TAPRIO_ATTR_MAX, }; #define TCA_TAPRIO_ATTR_MAX (__TCA_TAPRIO_ATTR_MAX - 1) +#define TCQ_ETS_MAX_BANDS 16 +enum { + TCA_ETS_UNSPEC, + TCA_ETS_NBANDS, + TCA_ETS_NSTRICT, + TCA_ETS_QUANTA, + TCA_ETS_QUANTA_BAND, + TCA_ETS_PRIOMAP, + TCA_ETS_PRIOMAP_BAND, + __TCA_ETS_MAX, +}; +#define TCA_ETS_MAX (__TCA_ETS_MAX - 1) #endif diff --git a/libc/kernel/uapi/linux/prctl.h b/libc/kernel/uapi/linux/prctl.h index 6e3426ce6..c8118da40 100644 --- a/libc/kernel/uapi/linux/prctl.h +++ b/libc/kernel/uapi/linux/prctl.h @@ -153,6 +153,8 @@ struct prctl_mm_map { #define PR_SET_TAGGED_ADDR_CTRL 55 #define PR_GET_TAGGED_ADDR_CTRL 56 #define PR_TAGGED_ADDR_ENABLE (1UL << 0) +#define PR_SET_IO_FLUSHER 57 +#define PR_GET_IO_FLUSHER 58 #define PR_SET_VMA 0x53564d41 #define PR_SET_VMA_ANON_NAME 0 #endif diff --git a/libc/kernel/uapi/linux/random.h b/libc/kernel/uapi/linux/random.h index 3a5fbfdc9..2d3cfeff2 100644 --- a/libc/kernel/uapi/linux/random.h +++ b/libc/kernel/uapi/linux/random.h @@ -35,4 +35,5 @@ struct rand_pool_info { }; #define GRND_NONBLOCK 0x0001 #define GRND_RANDOM 0x0002 +#define GRND_INSECURE 0x0004 #endif diff --git a/libc/kernel/uapi/linux/rtc.h b/libc/kernel/uapi/linux/rtc.h index a0472935a..6536fff61 100644 --- a/libc/kernel/uapi/linux/rtc.h +++ b/libc/kernel/uapi/linux/rtc.h @@ -63,7 +63,11 @@ struct rtc_pll_info { #define RTC_WKALM_RD _IOR('p', 0x10, struct rtc_wkalrm) #define RTC_PLL_GET _IOR('p', 0x11, struct rtc_pll_info) #define RTC_PLL_SET _IOW('p', 0x12, struct rtc_pll_info) -#define RTC_VL_READ _IOR('p', 0x13, int) +#define RTC_VL_DATA_INVALID BIT(0) +#define RTC_VL_BACKUP_LOW BIT(1) +#define RTC_VL_BACKUP_EMPTY BIT(2) +#define RTC_VL_ACCURACY_LOW BIT(3) +#define RTC_VL_READ _IOR('p', 0x13, unsigned int) #define RTC_VL_CLR _IO('p', 0x14) #define RTC_IRQF 0x80 #define RTC_PF 0x40 diff --git a/libc/kernel/uapi/linux/rtnetlink.h b/libc/kernel/uapi/linux/rtnetlink.h index 14366de38..295fbedf1 100644 --- a/libc/kernel/uapi/linux/rtnetlink.h +++ b/libc/kernel/uapi/linux/rtnetlink.h @@ -151,6 +151,12 @@ enum { #define RTM_DELLINKPROP RTM_DELLINKPROP RTM_GETLINKPROP, #define RTM_GETLINKPROP RTM_GETLINKPROP + RTM_NEWVLAN = 112, +#define RTM_NEWNVLAN RTM_NEWVLAN + RTM_DELVLAN, +#define RTM_DELVLAN RTM_DELVLAN + RTM_GETVLAN, +#define RTM_GETVLAN RTM_GETVLAN __RTM_MAX, #define RTM_MAX (((__RTM_MAX + 3) & ~3) - 1) }; @@ -230,6 +236,8 @@ enum rt_scope_t { #define RTM_F_PREFIX 0x800 #define RTM_F_LOOKUP_TABLE 0x1000 #define RTM_F_FIB_MATCH 0x2000 +#define RTM_F_OFFLOAD 0x4000 +#define RTM_F_TRAP 0x8000 enum rt_class_t { RT_TABLE_UNSPEC = 0, RT_TABLE_COMPAT = 252, @@ -537,6 +545,8 @@ enum rtnetlink_groups { #define RTNLGRP_IPV6_MROUTE_R RTNLGRP_IPV6_MROUTE_R RTNLGRP_NEXTHOP, #define RTNLGRP_NEXTHOP RTNLGRP_NEXTHOP + RTNLGRP_BRVLAN, +#define RTNLGRP_BRVLAN RTNLGRP_BRVLAN __RTNLGRP_MAX }; #define RTNLGRP_MAX (__RTNLGRP_MAX - 1) diff --git a/libc/kernel/uapi/linux/sched.h b/libc/kernel/uapi/linux/sched.h index b8f39ddd0..2afbf6178 100644 --- a/libc/kernel/uapi/linux/sched.h +++ b/libc/kernel/uapi/linux/sched.h @@ -45,6 +45,7 @@ #define CLONE_NEWNET 0x40000000 #define CLONE_IO 0x80000000 #define CLONE_CLEAR_SIGHAND 0x100000000ULL +#define CLONE_NEWTIME 0x00000080 #ifndef __ASSEMBLY__ struct clone_args { __aligned_u64 flags; diff --git a/libc/kernel/uapi/linux/serio.h b/libc/kernel/uapi/linux/serio.h index 5ef9de4b4..605a4e450 100644 --- a/libc/kernel/uapi/linux/serio.h +++ b/libc/kernel/uapi/linux/serio.h @@ -18,12 +18,13 @@ ****************************************************************************/ #ifndef _UAPI_SERIO_H #define _UAPI_SERIO_H +#include <linux/const.h> #include <linux/ioctl.h> #define SPIOCSTYPE _IOW('q', 0x01, unsigned long) -#define SERIO_TIMEOUT BIT(0) -#define SERIO_PARITY BIT(1) -#define SERIO_FRAME BIT(2) -#define SERIO_OOB_DATA BIT(3) +#define SERIO_TIMEOUT _BITUL(0) +#define SERIO_PARITY _BITUL(1) +#define SERIO_FRAME _BITUL(2) +#define SERIO_OOB_DATA _BITUL(3) #define SERIO_XT 0x00 #define SERIO_8042 0x01 #define SERIO_RS232 0x02 diff --git a/libc/kernel/uapi/linux/snmp.h b/libc/kernel/uapi/linux/snmp.h index 3ec299af3..c114544b6 100644 --- a/libc/kernel/uapi/linux/snmp.h +++ b/libc/kernel/uapi/linux/snmp.h @@ -252,6 +252,8 @@ enum { LINUX_MIB_TCPRCVQDROP, LINUX_MIB_TCPWQUEUETOOBIG, LINUX_MIB_TCPFASTOPENPASSIVEALTKEY, + LINUX_MIB_TCPTIMEOUTREHASH, + LINUX_MIB_TCPDUPLICATEDATAREHASH, __LINUX_MIB_MAX }; enum { diff --git a/libc/kernel/uapi/linux/swab.h b/libc/kernel/uapi/linux/swab.h index da949db61..e96085e4e 100644 --- a/libc/kernel/uapi/linux/swab.h +++ b/libc/kernel/uapi/linux/swab.h @@ -20,6 +20,7 @@ #define _UAPI_LINUX_SWAB_H #include <linux/types.h> #include <linux/compiler.h> +#include <asm/bitsperlong.h> #include <asm/swab.h> #define ___constant_swab16(x) ((__u16) ((((__u16) (x) & (__u16) 0x00ffU) << 8) | (((__u16) (x) & (__u16) 0xff00U) >> 8))) #define ___constant_swab32(x) ((__u32) ((((__u32) (x) & (__u32) 0x000000ffUL) << 24) | (((__u32) (x) & (__u32) 0x0000ff00UL) << 8) | (((__u32) (x) & (__u32) 0x00ff0000UL) >> 8) | (((__u32) (x) & (__u32) 0xff000000UL) >> 24))) @@ -53,6 +54,9 @@ static inline __attribute__((__const__)) __u32 __fswahb32(__u32 val) { #define __swab16(x) (__u16) __builtin_bswap16((__u16) (x)) #define __swab32(x) (__u32) __builtin_bswap32((__u32) (x)) #define __swab64(x) (__u64) __builtin_bswap64((__u64) (x)) +#if __BITS_PER_LONG == 64 +#else +#endif #define __swahw32(x) (__builtin_constant_p((__u32) (x)) ? ___constant_swahw32(x) : __fswahw32(x)) #define __swahb32(x) (__builtin_constant_p((__u32) (x)) ? ___constant_swahb32(x) : __fswahb32(x)) static __always_inline __u16 __swab16p(const __u16 * p) { diff --git a/libc/kernel/uapi/linux/switchtec_ioctl.h b/libc/kernel/uapi/linux/switchtec_ioctl.h index 2143148e6..204839dbe 100644 --- a/libc/kernel/uapi/linux/switchtec_ioctl.h +++ b/libc/kernel/uapi/linux/switchtec_ioctl.h @@ -32,7 +32,15 @@ #define SWITCHTEC_IOCTL_PART_VENDOR5 10 #define SWITCHTEC_IOCTL_PART_VENDOR6 11 #define SWITCHTEC_IOCTL_PART_VENDOR7 12 -#define SWITCHTEC_IOCTL_NUM_PARTITIONS 13 +#define SWITCHTEC_IOCTL_PART_BL2_0 13 +#define SWITCHTEC_IOCTL_PART_BL2_1 14 +#define SWITCHTEC_IOCTL_PART_MAP_0 15 +#define SWITCHTEC_IOCTL_PART_MAP_1 16 +#define SWITCHTEC_IOCTL_PART_KEY_0 17 +#define SWITCHTEC_IOCTL_PART_KEY_1 18 +#define SWITCHTEC_NUM_PARTITIONS_GEN3 13 +#define SWITCHTEC_NUM_PARTITIONS_GEN4 19 +#define SWITCHTEC_IOCTL_NUM_PARTITIONS SWITCHTEC_NUM_PARTITIONS_GEN3 struct switchtec_ioctl_flash_info { __u64 flash_length; __u32 num_partitions; @@ -92,7 +100,9 @@ struct switchtec_ioctl_event_summary { #define SWITCHTEC_IOCTL_EVENT_CREDIT_TIMEOUT 27 #define SWITCHTEC_IOCTL_EVENT_LINK_STATE 28 #define SWITCHTEC_IOCTL_EVENT_GFMS 29 -#define SWITCHTEC_IOCTL_MAX_EVENTS 30 +#define SWITCHTEC_IOCTL_EVENT_INTERCOMM_REQ_NOTIFY 30 +#define SWITCHTEC_IOCTL_EVENT_UEC 31 +#define SWITCHTEC_IOCTL_MAX_EVENTS 32 #define SWITCHTEC_IOCTL_EVENT_LOCAL_PART_IDX - 1 #define SWITCHTEC_IOCTL_EVENT_IDX_ALL - 2 #define SWITCHTEC_IOCTL_EVENT_FLAG_CLEAR (1 << 0) diff --git a/libc/kernel/uapi/linux/taskstats.h b/libc/kernel/uapi/linux/taskstats.h index dc7791ddf..5f9d0cc48 100644 --- a/libc/kernel/uapi/linux/taskstats.h +++ b/libc/kernel/uapi/linux/taskstats.h @@ -19,7 +19,7 @@ #ifndef _LINUX_TASKSTATS_H #define _LINUX_TASKSTATS_H #include <linux/types.h> -#define TASKSTATS_VERSION 9 +#define TASKSTATS_VERSION 10 #define TS_COMM_LEN 32 struct taskstats { __u16 version; @@ -68,6 +68,7 @@ struct taskstats { __u64 freepages_delay_total; __u64 thrashing_count; __u64 thrashing_delay_total; + __u64 ac_btime64; }; enum { TASKSTATS_CMD_UNSPEC = 0, diff --git a/libc/kernel/uapi/linux/tcp.h b/libc/kernel/uapi/linux/tcp.h index 823583dc8..4dbb76486 100644 --- a/libc/kernel/uapi/linux/tcp.h +++ b/libc/kernel/uapi/linux/tcp.h @@ -217,15 +217,17 @@ enum { TCP_NLA_DSACK_DUPS, TCP_NLA_REORD_SEEN, TCP_NLA_SRTT, + TCP_NLA_TIMEOUT_REHASH, }; #define TCP_MD5SIG_MAXKEYLEN 80 -#define TCP_MD5SIG_FLAG_PREFIX 1 +#define TCP_MD5SIG_FLAG_PREFIX 0x1 +#define TCP_MD5SIG_FLAG_IFINDEX 0x2 struct tcp_md5sig { struct sockaddr_storage tcpm_addr; __u8 tcpm_flags; __u8 tcpm_prefixlen; __u16 tcpm_keylen; - __u32 __tcpm_pad; + int tcpm_ifindex; __u8 tcpm_key[TCP_MD5SIG_MAXKEYLEN]; }; struct tcp_diag_md5sig { diff --git a/libc/kernel/uapi/linux/tee.h b/libc/kernel/uapi/linux/tee.h index e13c2313f..9ddcf1925 100644 --- a/libc/kernel/uapi/linux/tee.h +++ b/libc/kernel/uapi/linux/tee.h @@ -29,6 +29,7 @@ #define TEE_GEN_CAP_PRIVILEGED (1 << 1) #define TEE_GEN_CAP_REG_MEM (1 << 2) #define TEE_IMPL_ID_OPTEE 1 +#define TEE_IMPL_ID_AMDTEE 2 #define TEE_OPTEE_CAP_TZ (1 << 0) struct tee_ioctl_version_data { __u32 impl_id; diff --git a/libc/kernel/uapi/linux/time.h b/libc/kernel/uapi/linux/time.h index eed430b5f..df52295db 100644 --- a/libc/kernel/uapi/linux/time.h +++ b/libc/kernel/uapi/linux/time.h @@ -31,13 +31,6 @@ struct timeval { __kernel_old_time_t tv_sec; __kernel_suseconds_t tv_usec; }; -struct timezone { - int tz_minuteswest; - int tz_dsttime; -}; -#define ITIMER_REAL 0 -#define ITIMER_VIRTUAL 1 -#define ITIMER_PROF 2 struct itimerspec { struct timespec it_interval; struct timespec it_value; @@ -46,6 +39,13 @@ struct itimerval { struct timeval it_interval; struct timeval it_value; }; +struct timezone { + int tz_minuteswest; + int tz_dsttime; +}; +#define ITIMER_REAL 0 +#define ITIMER_VIRTUAL 1 +#define ITIMER_PROF 2 #define CLOCK_REALTIME 0 #define CLOCK_MONOTONIC 1 #define CLOCK_PROCESS_CPUTIME_ID 2 diff --git a/libc/kernel/uapi/linux/tipc_netlink.h b/libc/kernel/uapi/linux/tipc_netlink.h index 61577fad9..10fdf5e2e 100644 --- a/libc/kernel/uapi/linux/tipc_netlink.h +++ b/libc/kernel/uapi/linux/tipc_netlink.h @@ -46,6 +46,7 @@ enum { TIPC_NL_UDP_GET_REMOTEIP, TIPC_NL_KEY_SET, TIPC_NL_KEY_FLUSH, + TIPC_NL_ADDR_LEGACY_GET, __TIPC_NL_CMD_MAX, TIPC_NL_CMD_MAX = __TIPC_NL_CMD_MAX - 1 }; @@ -135,6 +136,7 @@ enum { TIPC_NLA_NET_ADDR, TIPC_NLA_NET_NODEID, TIPC_NLA_NET_NODEID_W1, + TIPC_NLA_NET_ADDR_LEGACY, __TIPC_NLA_NET_MAX, TIPC_NLA_NET_MAX = __TIPC_NLA_NET_MAX - 1 }; diff --git a/libc/kernel/uapi/linux/udp.h b/libc/kernel/uapi/linux/udp.h index 278cf6c11..802c686c4 100644 --- a/libc/kernel/uapi/linux/udp.h +++ b/libc/kernel/uapi/linux/udp.h @@ -37,4 +37,5 @@ struct __kernel_udphdr { #define UDP_ENCAP_GTP0 4 #define UDP_ENCAP_GTP1U 5 #define UDP_ENCAP_RXRPC 6 +#define TCP_ENCAP_ESPINTCP 7 #endif diff --git a/libc/kernel/uapi/linux/usb/charger.h b/libc/kernel/uapi/linux/usb/charger.h index 0810aab1a..e53f7d62f 100644 --- a/libc/kernel/uapi/linux/usb/charger.h +++ b/libc/kernel/uapi/linux/usb/charger.h @@ -19,15 +19,15 @@ #ifndef _UAPI__LINUX_USB_CHARGER_H #define _UAPI__LINUX_USB_CHARGER_H enum usb_charger_type { - UNKNOWN_TYPE, - SDP_TYPE, - DCP_TYPE, - CDP_TYPE, - ACA_TYPE, + UNKNOWN_TYPE = 0, + SDP_TYPE = 1, + DCP_TYPE = 2, + CDP_TYPE = 3, + ACA_TYPE = 4, }; enum usb_charger_state { - USB_CHARGER_DEFAULT, - USB_CHARGER_PRESENT, - USB_CHARGER_ABSENT, + USB_CHARGER_DEFAULT = 0, + USB_CHARGER_PRESENT = 1, + USB_CHARGER_ABSENT = 2, }; #endif diff --git a/libc/kernel/uapi/linux/version.h b/libc/kernel/uapi/linux/version.h index 471dcd7ba..e63a1afb4 100644 --- a/libc/kernel/uapi/linux/version.h +++ b/libc/kernel/uapi/linux/version.h @@ -16,5 +16,5 @@ *** **************************************************************************** ****************************************************************************/ -#define LINUX_VERSION_CODE 328960 +#define LINUX_VERSION_CODE 329216 #define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c)) diff --git a/libc/kernel/uapi/linux/vm_sockets.h b/libc/kernel/uapi/linux/vm_sockets.h index 87e4ba023..3dc4bcf47 100644 --- a/libc/kernel/uapi/linux/vm_sockets.h +++ b/libc/kernel/uapi/linux/vm_sockets.h @@ -29,7 +29,7 @@ #define VMADDR_CID_ANY - 1U #define VMADDR_PORT_ANY - 1U #define VMADDR_CID_HYPERVISOR 0 -#define VMADDR_CID_RESERVED 1 +#define VMADDR_CID_LOCAL 1 #define VMADDR_CID_HOST 2 #define VM_SOCKETS_INVALID_VERSION - 1U #define VM_SOCKETS_VERSION_EPOCH(_v) (((_v) & 0xFF000000) >> 24) diff --git a/libc/kernel/uapi/linux/vsoc_shm.h b/libc/kernel/uapi/linux/vsoc_shm.h deleted file mode 100644 index 467b89bba..000000000 --- a/libc/kernel/uapi/linux/vsoc_shm.h +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************** - **************************************************************************** - *** - *** This header was automatically generated from a Linux kernel header - *** of the same name, to make information necessary for userspace to - *** call into the kernel available to libc. It contains only constants, - *** structures, and macros generated from the original header, and thus, - *** contains no copyrightable information. - *** - *** To edit the content of this header, modify the corresponding - *** source file (e.g. under external/kernel-headers/original/) then - *** run bionic/libc/kernel/tools/update_all.py - *** - *** Any manual change here will be lost the next time this script will - *** be run. You've been warned! - *** - **************************************************************************** - ****************************************************************************/ -#ifndef _UAPI_LINUX_VSOC_SHM_H -#define _UAPI_LINUX_VSOC_SHM_H -#include <linux/types.h> -struct fd_scoped_permission { - __u32 begin_offset; - __u32 end_offset; - __u32 owner_offset; - __u32 owned_value; -}; -#define VSOC_REGION_FREE ((__u32) 0) -struct fd_scoped_permission_arg { - struct fd_scoped_permission perm; - __s32 managed_region_fd; -}; -#define VSOC_NODE_FREE ((__u32) 0) -struct vsoc_signal_table_layout { - __u32 num_nodes_lg2; - __u32 futex_uaddr_table_offset; - __u32 interrupt_signalled_offset; -}; -#define VSOC_REGION_WHOLE ((__s32) 0) -#define VSOC_DEVICE_NAME_SZ 16 -struct vsoc_device_region { - __u16 current_version; - __u16 min_compatible_version; - __u32 region_begin_offset; - __u32 region_end_offset; - __u32 offset_of_region_data; - struct vsoc_signal_table_layout guest_to_host_signal_table; - struct vsoc_signal_table_layout host_to_guest_signal_table; - char device_name[VSOC_DEVICE_NAME_SZ]; - __u32 managed_by; -}; -struct vsoc_shm_layout_descriptor { - __u16 major_version; - __u16 minor_version; - __u32 size; - __u32 region_count; - __u32 vsoc_region_desc_offset; -}; -#define CURRENT_VSOC_LAYOUT_MAJOR_VERSION 2 -#define CURRENT_VSOC_LAYOUT_MINOR_VERSION 0 -#define VSOC_CREATE_FD_SCOPED_PERMISSION _IOW(0xF5, 0, struct fd_scoped_permission) -#define VSOC_GET_FD_SCOPED_PERMISSION _IOR(0xF5, 1, struct fd_scoped_permission) -#define VSOC_MAYBE_SEND_INTERRUPT_TO_HOST _IO(0xF5, 2) -#define VSOC_WAIT_FOR_INCOMING_INTERRUPT _IO(0xF5, 3) -#define VSOC_DESCRIBE_REGION _IOR(0xF5, 4, struct vsoc_device_region) -#define VSOC_SELF_INTERRUPT _IO(0xF5, 5) -#define VSOC_SEND_INTERRUPT_TO_HOST _IO(0xF5, 6) -enum wait_types { - VSOC_WAIT_UNDEFINED = 0, - VSOC_WAIT_IF_EQUAL = 1, - VSOC_WAIT_IF_EQUAL_TIMEOUT = 2 -}; -struct vsoc_cond_wait { - __u32 offset; - __u32 value; - __u64 wake_time_sec; - __u32 wake_time_nsec; - __u32 wait_type; - __u32 wakes; - __u32 reserved_1; -}; -#define VSOC_COND_WAIT _IOWR(0xF5, 7, struct vsoc_cond_wait) -#define VSOC_COND_WAKE _IO(0xF5, 8) -#endif diff --git a/libc/kernel/uapi/linux/wireguard.h b/libc/kernel/uapi/linux/wireguard.h new file mode 100644 index 000000000..6a4128baa --- /dev/null +++ b/libc/kernel/uapi/linux/wireguard.h @@ -0,0 +1,76 @@ +/**************************************************************************** + **************************************************************************** + *** + *** This header was automatically generated from a Linux kernel header + *** of the same name, to make information necessary for userspace to + *** call into the kernel available to libc. It contains only constants, + *** structures, and macros generated from the original header, and thus, + *** contains no copyrightable information. + *** + *** To edit the content of this header, modify the corresponding + *** source file (e.g. under external/kernel-headers/original/) then + *** run bionic/libc/kernel/tools/update_all.py + *** + *** Any manual change here will be lost the next time this script will + *** be run. You've been warned! + *** + **************************************************************************** + ****************************************************************************/ +#ifndef _WG_UAPI_WIREGUARD_H +#define _WG_UAPI_WIREGUARD_H +#define WG_GENL_NAME "wireguard" +#define WG_GENL_VERSION 1 +#define WG_KEY_LEN 32 +enum wg_cmd { + WG_CMD_GET_DEVICE, + WG_CMD_SET_DEVICE, + __WG_CMD_MAX +}; +#define WG_CMD_MAX (__WG_CMD_MAX - 1) +enum wgdevice_flag { + WGDEVICE_F_REPLACE_PEERS = 1U << 0, + __WGDEVICE_F_ALL = WGDEVICE_F_REPLACE_PEERS +}; +enum wgdevice_attribute { + WGDEVICE_A_UNSPEC, + WGDEVICE_A_IFINDEX, + WGDEVICE_A_IFNAME, + WGDEVICE_A_PRIVATE_KEY, + WGDEVICE_A_PUBLIC_KEY, + WGDEVICE_A_FLAGS, + WGDEVICE_A_LISTEN_PORT, + WGDEVICE_A_FWMARK, + WGDEVICE_A_PEERS, + __WGDEVICE_A_LAST +}; +#define WGDEVICE_A_MAX (__WGDEVICE_A_LAST - 1) +enum wgpeer_flag { + WGPEER_F_REMOVE_ME = 1U << 0, + WGPEER_F_REPLACE_ALLOWEDIPS = 1U << 1, + WGPEER_F_UPDATE_ONLY = 1U << 2, + __WGPEER_F_ALL = WGPEER_F_REMOVE_ME | WGPEER_F_REPLACE_ALLOWEDIPS | WGPEER_F_UPDATE_ONLY +}; +enum wgpeer_attribute { + WGPEER_A_UNSPEC, + WGPEER_A_PUBLIC_KEY, + WGPEER_A_PRESHARED_KEY, + WGPEER_A_FLAGS, + WGPEER_A_ENDPOINT, + WGPEER_A_PERSISTENT_KEEPALIVE_INTERVAL, + WGPEER_A_LAST_HANDSHAKE_TIME, + WGPEER_A_RX_BYTES, + WGPEER_A_TX_BYTES, + WGPEER_A_ALLOWEDIPS, + WGPEER_A_PROTOCOL_VERSION, + __WGPEER_A_LAST +}; +#define WGPEER_A_MAX (__WGPEER_A_LAST - 1) +enum wgallowedip_attribute { + WGALLOWEDIP_A_UNSPEC, + WGALLOWEDIP_A_FAMILY, + WGALLOWEDIP_A_IPADDR, + WGALLOWEDIP_A_CIDR_MASK, + __WGALLOWEDIP_A_LAST +}; +#define WGALLOWEDIP_A_MAX (__WGALLOWEDIP_A_LAST - 1) +#endif diff --git a/libc/kernel/uapi/misc/pvpanic.h b/libc/kernel/uapi/misc/pvpanic.h new file mode 100644 index 000000000..18edcd8eb --- /dev/null +++ b/libc/kernel/uapi/misc/pvpanic.h @@ -0,0 +1,23 @@ +/**************************************************************************** + **************************************************************************** + *** + *** This header was automatically generated from a Linux kernel header + *** of the same name, to make information necessary for userspace to + *** call into the kernel available to libc. It contains only constants, + *** structures, and macros generated from the original header, and thus, + *** contains no copyrightable information. + *** + *** To edit the content of this header, modify the corresponding + *** source file (e.g. under external/kernel-headers/original/) then + *** run bionic/libc/kernel/tools/update_all.py + *** + *** Any manual change here will be lost the next time this script will + *** be run. You've been warned! + *** + **************************************************************************** + ****************************************************************************/ +#ifndef __PVPANIC_H__ +#define __PVPANIC_H__ +#define PVPANIC_PANICKED (1 << 0) +#define PVPANIC_CRASH_LOADED (1 << 1) +#endif diff --git a/libc/kernel/uapi/rdma/ib_user_ioctl_cmds.h b/libc/kernel/uapi/rdma/ib_user_ioctl_cmds.h index ebf8b7c8d..39338414e 100644 --- a/libc/kernel/uapi/rdma/ib_user_ioctl_cmds.h +++ b/libc/kernel/uapi/rdma/ib_user_ioctl_cmds.h @@ -39,6 +39,7 @@ enum uverbs_default_objects { UVERBS_OBJECT_FLOW_ACTION, UVERBS_OBJECT_DM, UVERBS_OBJECT_COUNTERS, + UVERBS_OBJECT_ASYNC_EVENT, }; enum { UVERBS_ATTR_UHW_IN = UVERBS_UDATA_DRIVER_DATA_FLAG, @@ -48,6 +49,7 @@ enum uverbs_methods_device { UVERBS_METHOD_INVOKE_WRITE, UVERBS_METHOD_INFO_HANDLES, UVERBS_METHOD_QUERY_PORT, + UVERBS_METHOD_GET_CONTEXT, }; enum uverbs_attrs_invoke_write_cmd_attr_ids { UVERBS_ATTR_CORE_IN, @@ -58,6 +60,10 @@ enum uverbs_attrs_query_port_cmd_attr_ids { UVERBS_ATTR_QUERY_PORT_PORT_NUM, UVERBS_ATTR_QUERY_PORT_RESP, }; +enum uverbs_attrs_get_context_attr_ids { + UVERBS_ATTR_GET_CONTEXT_NUM_COMP_VECTORS, + UVERBS_ATTR_GET_CONTEXT_CORE_SUPPORT, +}; enum uverbs_attrs_create_cq_cmd_attr_ids { UVERBS_ATTR_CREATE_CQ_HANDLE, UVERBS_ATTR_CREATE_CQ_CQE, @@ -187,4 +193,10 @@ enum uverbs_methods_flow { enum uverbs_attrs_flow_destroy_ids { UVERBS_ATTR_DESTROY_FLOW_HANDLE, }; +enum uverbs_method_async_event { + UVERBS_METHOD_ASYNC_EVENT_ALLOC, +}; +enum uverbs_attrs_async_event_create { + UVERBS_ATTR_ASYNC_EVENT_ALLOC_FD_HANDLE, +}; #endif diff --git a/libc/kernel/uapi/rdma/ib_user_ioctl_verbs.h b/libc/kernel/uapi/rdma/ib_user_ioctl_verbs.h index 1394ed7a0..ddf2abd06 100644 --- a/libc/kernel/uapi/rdma/ib_user_ioctl_verbs.h +++ b/libc/kernel/uapi/rdma/ib_user_ioctl_verbs.h @@ -23,6 +23,11 @@ #ifndef RDMA_UAPI_PTR #define RDMA_UAPI_PTR(_type,_name) __aligned_u64 _name #endif +#define IB_UVERBS_ACCESS_OPTIONAL_FIRST (1 << 20) +#define IB_UVERBS_ACCESS_OPTIONAL_LAST (1 << 29) +enum ib_uverbs_core_support { + IB_UVERBS_CORE_SUPPORT_OPTIONAL_MR_ACCESS = 1 << 0, +}; enum ib_uverbs_access_flags { IB_UVERBS_ACCESS_LOCAL_WRITE = 1 << 0, IB_UVERBS_ACCESS_REMOTE_WRITE = 1 << 1, @@ -32,6 +37,8 @@ enum ib_uverbs_access_flags { IB_UVERBS_ACCESS_ZERO_BASED = 1 << 5, IB_UVERBS_ACCESS_ON_DEMAND = 1 << 6, IB_UVERBS_ACCESS_HUGETLB = 1 << 7, + IB_UVERBS_ACCESS_RELAXED_ORDERING = IB_UVERBS_ACCESS_OPTIONAL_FIRST, + IB_UVERBS_ACCESS_OPTIONAL_RANGE = ((IB_UVERBS_ACCESS_OPTIONAL_LAST << 1) - 1) & ~(IB_UVERBS_ACCESS_OPTIONAL_FIRST - 1) }; enum ib_uverbs_query_port_cap_flags { IB_UVERBS_PCF_SM = 1 << 1, diff --git a/libc/kernel/uapi/rdma/mlx5_user_ioctl_cmds.h b/libc/kernel/uapi/rdma/mlx5_user_ioctl_cmds.h index 1cd333959..b017e7335 100644 --- a/libc/kernel/uapi/rdma/mlx5_user_ioctl_cmds.h +++ b/libc/kernel/uapi/rdma/mlx5_user_ioctl_cmds.h @@ -85,6 +85,19 @@ enum mlx5_ib_devx_obj_methods { MLX5_IB_METHOD_DEVX_OBJ_QUERY, MLX5_IB_METHOD_DEVX_OBJ_ASYNC_QUERY, }; +enum mlx5_ib_var_alloc_attrs { + MLX5_IB_ATTR_VAR_OBJ_ALLOC_HANDLE = (1U << UVERBS_ID_NS_SHIFT), + MLX5_IB_ATTR_VAR_OBJ_ALLOC_MMAP_OFFSET, + MLX5_IB_ATTR_VAR_OBJ_ALLOC_MMAP_LENGTH, + MLX5_IB_ATTR_VAR_OBJ_ALLOC_PAGE_ID, +}; +enum mlx5_ib_var_obj_destroy_attrs { + MLX5_IB_ATTR_VAR_OBJ_DESTROY_HANDLE = (1U << UVERBS_ID_NS_SHIFT), +}; +enum mlx5_ib_var_obj_methods { + MLX5_IB_METHOD_VAR_OBJ_ALLOC = (1U << UVERBS_ID_NS_SHIFT), + MLX5_IB_METHOD_VAR_OBJ_DESTROY, +}; enum mlx5_ib_devx_umem_reg_attrs { MLX5_IB_ATTR_DEVX_UMEM_REG_HANDLE = (1U << UVERBS_ID_NS_SHIFT), MLX5_IB_ATTR_DEVX_UMEM_REG_ADDR, @@ -119,6 +132,7 @@ enum mlx5_ib_objects { MLX5_IB_OBJECT_FLOW_MATCHER, MLX5_IB_OBJECT_DEVX_ASYNC_CMD_FD, MLX5_IB_OBJECT_DEVX_ASYNC_EVENT_FD, + MLX5_IB_OBJECT_VAR, }; enum mlx5_ib_flow_matcher_create_attrs { MLX5_IB_ATTR_FLOW_MATCHER_CREATE_HANDLE = (1U << UVERBS_ID_NS_SHIFT), diff --git a/libc/kernel/uapi/rdma/qedr-abi.h b/libc/kernel/uapi/rdma/qedr-abi.h index fd963097f..2e666f3bb 100644 --- a/libc/kernel/uapi/rdma/qedr-abi.h +++ b/libc/kernel/uapi/rdma/qedr-abi.h @@ -28,6 +28,16 @@ struct qedr_alloc_ucontext_req { __u32 context_flags; __u32 reserved; }; +#define QEDR_LDPM_MAX_SIZE (8192) +#define QEDR_EDPM_TRANS_SIZE (64) +enum qedr_rdma_dpm_type { + QEDR_DPM_TYPE_NONE = 0, + QEDR_DPM_TYPE_ROCE_ENHANCED = 1 << 0, + QEDR_DPM_TYPE_ROCE_LEGACY = 1 << 1, + QEDR_DPM_TYPE_IWARP_LEGACY = 1 << 2, + QEDR_DPM_TYPE_RESERVED = 1 << 3, + QEDR_DPM_SIZES_SET = 1 << 4, +}; struct qedr_alloc_ucontext_resp { __aligned_u64 db_pa; __u32 db_size; @@ -38,10 +48,12 @@ struct qedr_alloc_ucontext_resp { __u32 sges_per_recv_wr; __u32 sges_per_srq_wr; __u32 max_cqes; - __u8 dpm_enabled; + __u8 dpm_flags; __u8 wids_enabled; __u16 wid_count; - __u32 reserved; + __u16 ldpm_limit_size; + __u8 edpm_trans_size; + __u8 reserved; }; struct qedr_alloc_pd_ureq { __aligned_u64 rsvd1; diff --git a/libc/kernel/uapi/scsi/scsi_bsg_ufs.h b/libc/kernel/uapi/scsi/scsi_bsg_ufs.h index 177cae984..ae5c757b1 100644 --- a/libc/kernel/uapi/scsi/scsi_bsg_ufs.h +++ b/libc/kernel/uapi/scsi/scsi_bsg_ufs.h @@ -46,7 +46,6 @@ struct utp_upiu_req { union { struct utp_upiu_cmd sc; struct utp_upiu_query qr; - struct utp_upiu_query tr; struct utp_upiu_query uc; }; }; diff --git a/libc/kernel/uapi/sound/asoc.h b/libc/kernel/uapi/sound/asoc.h index e46c4b5ec..706fddc12 100644 --- a/libc/kernel/uapi/sound/asoc.h +++ b/libc/kernel/uapi/sound/asoc.h @@ -19,7 +19,6 @@ #ifndef __LINUX_UAPI_SND_ASOC_H #define __LINUX_UAPI_SND_ASOC_H #include <linux/types.h> -#include <sound/asound.h> #define SND_SOC_TPLG_MAX_CHAN 8 #define SND_SOC_TPLG_MAX_FORMATS 16 #define SND_SOC_TPLG_STREAM_CONFIG_MAX 8 diff --git a/libc/kernel/uapi/sound/asound.h b/libc/kernel/uapi/sound/asound.h index abc81dde2..397cccce8 100644 --- a/libc/kernel/uapi/sound/asound.h +++ b/libc/kernel/uapi/sound/asound.h @@ -20,7 +20,9 @@ #define _UAPI__SOUND_ASOUND_H #ifdef __linux__ #include <linux/types.h> +#include <asm/byteorder.h> #else +#include <endian.h> #include <sys/ioctl.h> #endif #include <stdlib.h> @@ -101,7 +103,7 @@ struct snd_hwdep_dsp_image { #define SNDRV_HWDEP_IOCTL_INFO _IOR('H', 0x01, struct snd_hwdep_info) #define SNDRV_HWDEP_IOCTL_DSP_STATUS _IOR('H', 0x02, struct snd_hwdep_dsp_status) #define SNDRV_HWDEP_IOCTL_DSP_LOAD _IOW('H', 0x03, struct snd_hwdep_dsp_image) -#define SNDRV_PCM_VERSION SNDRV_PROTOCOL_VERSION(2, 0, 14) +#define SNDRV_PCM_VERSION SNDRV_PROTOCOL_VERSION(2, 0, 15) typedef unsigned long snd_pcm_uframes_t; typedef signed long snd_pcm_sframes_t; enum { @@ -234,6 +236,9 @@ typedef int __bitwise snd_pcm_subformat_t; #define SNDRV_PCM_INFO_HAS_LINK_SYNCHRONIZED_ATIME 0x08000000 #define SNDRV_PCM_INFO_DRAIN_TRIGGER 0x40000000 #define SNDRV_PCM_INFO_FIFO_IN_FRAMES 0x80000000 +#if __BITS_PER_LONG == 32 && defined(__USE_TIME_BITS64) +#define __SND_STRUCT_TIME64 +#endif typedef int __bitwise snd_pcm_state_t; #define SNDRV_PCM_STATE_OPEN ((__force snd_pcm_state_t) 0) #define SNDRV_PCM_STATE_SETUP ((__force snd_pcm_state_t) 1) @@ -247,8 +252,17 @@ typedef int __bitwise snd_pcm_state_t; #define SNDRV_PCM_STATE_LAST SNDRV_PCM_STATE_DISCONNECTED enum { SNDRV_PCM_MMAP_OFFSET_DATA = 0x00000000, - SNDRV_PCM_MMAP_OFFSET_STATUS = 0x80000000, - SNDRV_PCM_MMAP_OFFSET_CONTROL = 0x81000000, + SNDRV_PCM_MMAP_OFFSET_STATUS_OLD = 0x80000000, + SNDRV_PCM_MMAP_OFFSET_CONTROL_OLD = 0x81000000, + SNDRV_PCM_MMAP_OFFSET_STATUS_NEW = 0x82000000, + SNDRV_PCM_MMAP_OFFSET_CONTROL_NEW = 0x83000000, +#ifdef __SND_STRUCT_TIME64 + SNDRV_PCM_MMAP_OFFSET_STATUS = SNDRV_PCM_MMAP_OFFSET_STATUS_NEW, + SNDRV_PCM_MMAP_OFFSET_CONTROL = SNDRV_PCM_MMAP_OFFSET_CONTROL_NEW, +#else + SNDRV_PCM_MMAP_OFFSET_STATUS = SNDRV_PCM_MMAP_OFFSET_STATUS_OLD, + SNDRV_PCM_MMAP_OFFSET_CONTROL = SNDRV_PCM_MMAP_OFFSET_CONTROL_OLD, +#endif }; union snd_pcm_sync_id { unsigned char id[16]; @@ -351,8 +365,12 @@ enum { SNDRV_PCM_AUDIO_TSTAMP_TYPE_LINK_SYNCHRONIZED = 5, SNDRV_PCM_AUDIO_TSTAMP_TYPE_LAST = SNDRV_PCM_AUDIO_TSTAMP_TYPE_LINK_SYNCHRONIZED }; +typedef struct { + unsigned char pad[sizeof(time_t) - sizeof(int)]; +} __time_pad; struct snd_pcm_status { snd_pcm_state_t state; + __time_pad pad1; struct timespec trigger_tstamp; struct timespec tstamp; snd_pcm_uframes_t appl_ptr; @@ -368,29 +386,87 @@ struct snd_pcm_status { __u32 audio_tstamp_accuracy; unsigned char reserved[52 - 2 * sizeof(struct timespec)]; }; -struct snd_pcm_mmap_status { +#ifdef __SND_STRUCT_TIME64 +#define __snd_pcm_mmap_status64 snd_pcm_mmap_status +#define __snd_pcm_mmap_control64 snd_pcm_mmap_control +#define __snd_pcm_sync_ptr64 snd_pcm_sync_ptr +#define __snd_timespec64 timespec +struct __snd_timespec { + __s32 tv_sec; + __s32 tv_nsec; +}; +#else +#define __snd_pcm_mmap_status snd_pcm_mmap_status +#define __snd_pcm_mmap_control snd_pcm_mmap_control +#define __snd_pcm_sync_ptr snd_pcm_sync_ptr +#define __snd_timespec timespec +struct __snd_timespec64 { + __s64 tv_sec; + __s64 tv_nsec; +}; +#endif +struct __snd_pcm_mmap_status { snd_pcm_state_t state; int pad1; snd_pcm_uframes_t hw_ptr; - struct timespec tstamp; + struct __snd_timespec tstamp; snd_pcm_state_t suspended_state; - struct timespec audio_tstamp; + struct __snd_timespec audio_tstamp; }; -struct snd_pcm_mmap_control { +struct __snd_pcm_mmap_control { snd_pcm_uframes_t appl_ptr; snd_pcm_uframes_t avail_min; }; #define SNDRV_PCM_SYNC_PTR_HWSYNC (1 << 0) #define SNDRV_PCM_SYNC_PTR_APPL (1 << 1) #define SNDRV_PCM_SYNC_PTR_AVAIL_MIN (1 << 2) -struct snd_pcm_sync_ptr { +struct __snd_pcm_sync_ptr { unsigned int flags; union { - struct snd_pcm_mmap_status status; + struct __snd_pcm_mmap_status status; + unsigned char reserved[64]; + } s; + union { + struct __snd_pcm_mmap_control control; + unsigned char reserved[64]; + } c; +}; +#if defined(__BYTE_ORDER) ? __BYTE_ORDER == __BIG_ENDIAN : defined(__BIG_ENDIAN) +typedef char __pad_before_uframe[sizeof(__u64) - sizeof(snd_pcm_uframes_t)]; +typedef char __pad_after_uframe[0]; +#endif +#if defined(__BYTE_ORDER) ? __BYTE_ORDER == __LITTLE_ENDIAN : defined(__LITTLE_ENDIAN) +typedef char __pad_before_uframe[0]; +typedef char __pad_after_uframe[sizeof(__u64) - sizeof(snd_pcm_uframes_t)]; +#endif +struct __snd_pcm_mmap_status64 { + snd_pcm_state_t state; + __u32 pad1; + __pad_before_uframe __pad1; + snd_pcm_uframes_t hw_ptr; + __pad_after_uframe __pad2; + struct __snd_timespec64 tstamp; + snd_pcm_state_t suspended_state; + __u32 pad3; + struct __snd_timespec64 audio_tstamp; +}; +struct __snd_pcm_mmap_control64 { + __pad_before_uframe __pad1; + snd_pcm_uframes_t appl_ptr; + __pad_before_uframe __pad2; + __pad_before_uframe __pad3; + snd_pcm_uframes_t avail_min; + __pad_after_uframe __pad4; +}; +struct __snd_pcm_sync_ptr64 { + __u32 flags; + __u32 pad1; + union { + struct __snd_pcm_mmap_status64 status; unsigned char reserved[64]; } s; union { - struct snd_pcm_mmap_control control; + struct __snd_pcm_mmap_control64 control; unsigned char reserved[64]; } c; }; @@ -465,6 +541,8 @@ enum { #define SNDRV_PCM_IOCTL_STATUS _IOR('A', 0x20, struct snd_pcm_status) #define SNDRV_PCM_IOCTL_DELAY _IOR('A', 0x21, snd_pcm_sframes_t) #define SNDRV_PCM_IOCTL_HWSYNC _IO('A', 0x22) +#define __SNDRV_PCM_IOCTL_SYNC_PTR _IOWR('A', 0x23, struct __snd_pcm_sync_ptr) +#define __SNDRV_PCM_IOCTL_SYNC_PTR64 _IOWR('A', 0x23, struct __snd_pcm_sync_ptr64) #define SNDRV_PCM_IOCTL_SYNC_PTR _IOWR('A', 0x23, struct snd_pcm_sync_ptr) #define SNDRV_PCM_IOCTL_STATUS_EXT _IOWR('A', 0x24, struct snd_pcm_status) #define SNDRV_PCM_IOCTL_CHANNEL_INFO _IOR('A', 0x32, struct snd_pcm_channel_info) @@ -484,7 +562,7 @@ enum { #define SNDRV_PCM_IOCTL_READN_FRAMES _IOR('A', 0x53, struct snd_xfern) #define SNDRV_PCM_IOCTL_LINK _IOW('A', 0x60, int) #define SNDRV_PCM_IOCTL_UNLINK _IO('A', 0x61) -#define SNDRV_RAWMIDI_VERSION SNDRV_PROTOCOL_VERSION(2, 0, 0) +#define SNDRV_RAWMIDI_VERSION SNDRV_PROTOCOL_VERSION(2, 0, 1) enum { SNDRV_RAWMIDI_STREAM_OUTPUT = 0, SNDRV_RAWMIDI_STREAM_INPUT, @@ -515,6 +593,7 @@ struct snd_rawmidi_params { }; struct snd_rawmidi_status { int stream; + __time_pad pad1; struct timespec tstamp; size_t avail; size_t xruns; @@ -526,7 +605,7 @@ struct snd_rawmidi_status { #define SNDRV_RAWMIDI_IOCTL_STATUS _IOWR('W', 0x20, struct snd_rawmidi_status) #define SNDRV_RAWMIDI_IOCTL_DROP _IOW('W', 0x30, int) #define SNDRV_RAWMIDI_IOCTL_DRAIN _IOW('W', 0x31, int) -#define SNDRV_TIMER_VERSION SNDRV_PROTOCOL_VERSION(2, 0, 6) +#define SNDRV_TIMER_VERSION SNDRV_PROTOCOL_VERSION(2, 0, 7) enum { SNDRV_TIMER_CLASS_NONE = - 1, SNDRV_TIMER_CLASS_SLAVE = 0, @@ -614,7 +693,7 @@ struct snd_timer_status { }; #define SNDRV_TIMER_IOCTL_PVERSION _IOR('T', 0x00, int) #define SNDRV_TIMER_IOCTL_NEXT_DEVICE _IOWR('T', 0x01, struct snd_timer_id) -#define SNDRV_TIMER_IOCTL_TREAD _IOW('T', 0x02, int) +#define SNDRV_TIMER_IOCTL_TREAD_OLD _IOW('T', 0x02, int) #define SNDRV_TIMER_IOCTL_GINFO _IOWR('T', 0x03, struct snd_timer_ginfo) #define SNDRV_TIMER_IOCTL_GPARAMS _IOW('T', 0x04, struct snd_timer_gparams) #define SNDRV_TIMER_IOCTL_GSTATUS _IOWR('T', 0x05, struct snd_timer_gstatus) @@ -626,6 +705,12 @@ struct snd_timer_status { #define SNDRV_TIMER_IOCTL_STOP _IO('T', 0xa1) #define SNDRV_TIMER_IOCTL_CONTINUE _IO('T', 0xa2) #define SNDRV_TIMER_IOCTL_PAUSE _IO('T', 0xa3) +#define SNDRV_TIMER_IOCTL_TREAD64 _IOW('T', 0xa4, int) +#if __BITS_PER_LONG == 64 +#define SNDRV_TIMER_IOCTL_TREAD SNDRV_TIMER_IOCTL_TREAD_OLD +#else +#define SNDRV_TIMER_IOCTL_TREAD ((sizeof(__kernel_long_t) >= sizeof(time_t)) ? SNDRV_TIMER_IOCTL_TREAD_OLD : SNDRV_TIMER_IOCTL_TREAD64) +#endif struct snd_timer_read { unsigned int resolution; unsigned int ticks; @@ -649,10 +734,12 @@ enum { }; struct snd_timer_tread { int event; + __time_pad pad1; struct timespec tstamp; unsigned int val; + __time_pad pad2; }; -#define SNDRV_CTL_VERSION SNDRV_PROTOCOL_VERSION(2, 0, 7) +#define SNDRV_CTL_VERSION SNDRV_PROTOCOL_VERSION(2, 0, 8) struct snd_ctl_card_info { int card; int pad; @@ -686,7 +773,6 @@ typedef int __bitwise snd_ctl_elem_iface_t; #define SNDRV_CTL_ELEM_ACCESS_WRITE (1 << 1) #define SNDRV_CTL_ELEM_ACCESS_READWRITE (SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_WRITE) #define SNDRV_CTL_ELEM_ACCESS_VOLATILE (1 << 2) -#define SNDRV_CTL_ELEM_ACCESS_TIMESTAMP (1 << 3) #define SNDRV_CTL_ELEM_ACCESS_TLV_READ (1 << 4) #define SNDRV_CTL_ELEM_ACCESS_TLV_WRITE (1 << 5) #define SNDRV_CTL_ELEM_ACCESS_TLV_READWRITE (SNDRV_CTL_ELEM_ACCESS_TLV_READ | SNDRV_CTL_ELEM_ACCESS_TLV_WRITE) @@ -745,11 +831,7 @@ struct snd_ctl_elem_info { } enumerated; unsigned char reserved[128]; } value; - union { - unsigned short d[4]; - unsigned short * d_ptr; - } dimen; - unsigned char reserved[64 - 4 * sizeof(unsigned short)]; + unsigned char reserved[64]; }; struct snd_ctl_elem_value { struct snd_ctl_elem_id id; @@ -773,8 +855,7 @@ struct snd_ctl_elem_value { } bytes; struct snd_aes_iec958 iec958; } value; - struct timespec tstamp; - unsigned char reserved[128 - sizeof(struct timespec)]; + unsigned char reserved[128]; }; struct snd_ctl_tlv { unsigned int numid; diff --git a/libc/kernel/uapi/sound/emu10k1.h b/libc/kernel/uapi/sound/emu10k1.h index 4ad00024a..483309e7d 100644 --- a/libc/kernel/uapi/sound/emu10k1.h +++ b/libc/kernel/uapi/sound/emu10k1.h @@ -18,8 +18,9 @@ ****************************************************************************/ #ifndef _UAPI__SOUND_EMU10K1_H #define _UAPI__SOUND_EMU10K1_H +#ifdef __linux__ #include <linux/types.h> -#include <sound/asound.h> +#endif #define EMU10K1_CARD_CREATIVE 0x00000000 #define EMU10K1_CARD_EMUAPS 0x00000001 #define EMU10K1_FX8010_PCM_COUNT 8 @@ -233,8 +234,20 @@ struct snd_emu10k1_fx8010_info { #define EMU10K1_GPR_TRANSLATION_BASS 2 #define EMU10K1_GPR_TRANSLATION_TREBLE 3 #define EMU10K1_GPR_TRANSLATION_ONOFF 4 +enum emu10k1_ctl_elem_iface { + EMU10K1_CTL_ELEM_IFACE_MIXER = 2, + EMU10K1_CTL_ELEM_IFACE_PCM = 3, +}; +struct emu10k1_ctl_elem_id { + unsigned int pad; + int iface; + unsigned int device; + unsigned int subdevice; + unsigned char name[44]; + unsigned int index; +}; struct snd_emu10k1_fx8010_control_gpr { - struct snd_ctl_elem_id id; + struct emu10k1_ctl_elem_id id; unsigned int vcount; unsigned int count; unsigned short gpr[32]; @@ -245,7 +258,7 @@ struct snd_emu10k1_fx8010_control_gpr { const unsigned int * tlv; }; struct snd_emu10k1_fx8010_control_old_gpr { - struct snd_ctl_elem_id id; + struct emu10k1_ctl_elem_id id; unsigned int vcount; unsigned int count; unsigned short gpr[32]; @@ -257,19 +270,19 @@ struct snd_emu10k1_fx8010_control_old_gpr { struct snd_emu10k1_fx8010_code { char name[128]; __EMU10K1_DECLARE_BITMAP(gpr_valid, 0x200); - __u32 __user * gpr_map; + __u32 * gpr_map; unsigned int gpr_add_control_count; - struct snd_emu10k1_fx8010_control_gpr __user * gpr_add_controls; + struct snd_emu10k1_fx8010_control_gpr * gpr_add_controls; unsigned int gpr_del_control_count; - struct snd_ctl_elem_id __user * gpr_del_controls; + struct emu10k1_ctl_elem_id * gpr_del_controls; unsigned int gpr_list_control_count; unsigned int gpr_list_control_total; - struct snd_emu10k1_fx8010_control_gpr __user * gpr_list_controls; + struct snd_emu10k1_fx8010_control_gpr * gpr_list_controls; __EMU10K1_DECLARE_BITMAP(tram_valid, 0x100); - __u32 __user * tram_data_map; - __u32 __user * tram_addr_map; + __u32 * tram_data_map; + __u32 * tram_addr_map; __EMU10K1_DECLARE_BITMAP(code_valid, 1024); - __u32 __user * code; + __u32 * code; }; struct snd_emu10k1_fx8010_tram { unsigned int address; @@ -307,9 +320,4 @@ struct snd_emu10k1_fx8010_pcm_rec { #define SNDRV_EMU10K1_IOCTL_ZERO_TRAM_COUNTER _IO('H', 0x82) #define SNDRV_EMU10K1_IOCTL_SINGLE_STEP _IOW('H', 0x83, int) #define SNDRV_EMU10K1_IOCTL_DBG_READ _IOR('H', 0x84, int) -typedef struct snd_emu10k1_fx8010_info emu10k1_fx8010_info_t; -typedef struct snd_emu10k1_fx8010_control_gpr emu10k1_fx8010_control_gpr_t; -typedef struct snd_emu10k1_fx8010_code emu10k1_fx8010_code_t; -typedef struct snd_emu10k1_fx8010_tram emu10k1_fx8010_tram_t; -typedef struct snd_emu10k1_fx8010_pcm_rec emu10k1_fx8010_pcm_t; #endif diff --git a/libc/kernel/uapi/sound/hdsp.h b/libc/kernel/uapi/sound/hdsp.h index 02e7f2da3..2fec3714a 100644 --- a/libc/kernel/uapi/sound/hdsp.h +++ b/libc/kernel/uapi/sound/hdsp.h @@ -18,7 +18,9 @@ ****************************************************************************/ #ifndef __SOUND_HDSP_H #define __SOUND_HDSP_H +#ifdef __linux__ #include <linux/types.h> +#endif #define HDSP_MATRIX_MIXER_SIZE 2048 enum HDSP_IO_Type { Digiface, @@ -64,7 +66,7 @@ struct hdsp_config_info { }; #define SNDRV_HDSP_IOCTL_GET_CONFIG_INFO _IOR('H', 0x41, struct hdsp_config_info) struct hdsp_firmware { - void __user * firmware_data; + void * firmware_data; }; #define SNDRV_HDSP_IOCTL_UPLOAD_FIRMWARE _IOW('H', 0x42, struct hdsp_firmware) struct hdsp_version { @@ -81,11 +83,4 @@ struct hdsp_9632_aeb { int aebo; }; #define SNDRV_HDSP_IOCTL_GET_9632_AEB _IOR('H', 0x45, struct hdsp_9632_aeb) -typedef enum HDSP_IO_Type HDSP_IO_Type; -typedef struct hdsp_peak_rms hdsp_peak_rms_t; -typedef struct hdsp_config_info hdsp_config_info_t; -typedef struct hdsp_firmware hdsp_firmware_t; -typedef struct hdsp_version hdsp_version_t; -typedef struct hdsp_mixer hdsp_mixer_t; -typedef struct hdsp_9632_aeb hdsp_9632_aeb_t; #endif diff --git a/libc/kernel/uapi/sound/hdspm.h b/libc/kernel/uapi/sound/hdspm.h index dc3192d4e..bd28e8caf 100644 --- a/libc/kernel/uapi/sound/hdspm.h +++ b/libc/kernel/uapi/sound/hdspm.h @@ -18,7 +18,9 @@ ****************************************************************************/ #ifndef __SOUND_HDSPM_H #define __SOUND_HDSPM_H +#ifdef __linux__ #include <linux/types.h> +#endif #define HDSPM_MAX_CHANNELS 64 enum hdspm_io_type { MADI, @@ -144,9 +146,4 @@ struct hdspm_mixer_ioctl { struct hdspm_mixer * mixer; }; #define SNDRV_HDSPM_IOCTL_GET_MIXER _IOR('H', 0x44, struct hdspm_mixer_ioctl) -typedef struct hdspm_peak_rms hdspm_peak_rms_t; -typedef struct hdspm_config_info hdspm_config_info_t; -typedef struct hdspm_version hdspm_version_t; -typedef struct hdspm_channelfader snd_hdspm_channelfader_t; -typedef struct hdspm_mixer hdspm_mixer_t; #endif diff --git a/libc/kernel/uapi/sound/sof/abi.h b/libc/kernel/uapi/sound/sof/abi.h index f19e4e969..c385f5a7d 100644 --- a/libc/kernel/uapi/sound/sof/abi.h +++ b/libc/kernel/uapi/sound/sof/abi.h @@ -19,7 +19,7 @@ #ifndef __INCLUDE_UAPI_SOUND_SOF_ABI_H__ #define __INCLUDE_UAPI_SOUND_SOF_ABI_H__ #define SOF_ABI_MAJOR 3 -#define SOF_ABI_MINOR 11 +#define SOF_ABI_MINOR 12 #define SOF_ABI_PATCH 0 #define SOF_ABI_MAJOR_SHIFT 24 #define SOF_ABI_MAJOR_MASK 0xff diff --git a/libc/kernel/uapi/sound/sof/tokens.h b/libc/kernel/uapi/sound/sof/tokens.h index 6d8561f6a..7ce5ddc83 100644 --- a/libc/kernel/uapi/sound/sof/tokens.h +++ b/libc/kernel/uapi/sound/sof/tokens.h @@ -37,6 +37,10 @@ #define SOF_TKN_VOLUME_RAMP_STEP_MS 251 #define SOF_TKN_SRC_RATE_IN 300 #define SOF_TKN_SRC_RATE_OUT 301 +#define SOF_TKN_ASRC_RATE_IN 320 +#define SOF_TKN_ASRC_RATE_OUT 321 +#define SOF_TKN_ASRC_ASYNCHRONOUS_MODE 322 +#define SOF_TKN_ASRC_OPERATION_MODE 323 #define SOF_TKN_PCM_DMAC_CONFIG 353 #define SOF_TKN_COMP_PERIOD_SINK_COUNT 400 #define SOF_TKN_COMP_PERIOD_SOURCE_COUNT 401 @@ -67,7 +71,7 @@ #define SOF_TKN_TONE_SAMPLE_RATE 800 #define SOF_TKN_PROCESS_TYPE 900 #define SOF_TKN_EFFECT_TYPE SOF_TKN_PROCESS_TYPE -#define SOF_TKN_IMX_SAI_FIRST_TOKEN 1000 +#define SOF_TKN_IMX_SAI_MCLK_ID 1000 #define SOF_TKN_IMX_ESAI_MCLK_ID 1100 #define SOF_TKN_STREAM_PLAYBACK_COMPATIBLE_D0I3 1200 #define SOF_TKN_STREAM_CAPTURE_COMPATIBLE_D0I3 1201 diff --git a/libc/libc.map.txt b/libc/libc.map.txt index 4bfb8a232..228477588 100644 --- a/libc/libc.map.txt +++ b/libc/libc.map.txt @@ -1550,6 +1550,12 @@ LIBC_R { # introduced=R _Unwind_VRS_Set; # apex llndk arm } LIBC_Q; +LIBC_S { # introduced=31 + global: + ffsl; + ffsll; +} LIBC_R; + LIBC_PRIVATE { global: __accept4; # arm x86 diff --git a/libc/malloc_debug/tests/malloc_debug_system_tests.cpp b/libc/malloc_debug/tests/malloc_debug_system_tests.cpp index 9e612f03b..ac19cf99c 100644 --- a/libc/malloc_debug/tests/malloc_debug_system_tests.cpp +++ b/libc/malloc_debug/tests/malloc_debug_system_tests.cpp @@ -40,7 +40,7 @@ #include <android-base/file.h> #include <android-base/stringprintf.h> #include <gtest/gtest.h> -#include <log/log.h> +#include <log/log_read.h> #include <string> #include <thread> @@ -150,7 +150,7 @@ static void GetLogStr(pid_t pid, std::string* log_str, log_id log = LOG_ID_MAIN) log_str->clear(); logger_list* list; - list = android_logger_list_open(log, ANDROID_LOG_RDONLY | ANDROID_LOG_NONBLOCK, 1000, pid); + list = android_logger_list_open(log, ANDROID_LOG_NONBLOCK, 1000, pid); ASSERT_TRUE(list != nullptr); while (true) { diff --git a/libc/malloc_hooks/README.md b/libc/malloc_hooks/README.md index b418e1ef4..1747e8d41 100644 --- a/libc/malloc_hooks/README.md +++ b/libc/malloc_hooks/README.md @@ -74,11 +74,11 @@ Example Implementation ====================== Below is a simple implementation intercepting only malloc/calloc calls. - void* new_malloc_hook(size_t bytes, const char* arg) { + void* new_malloc_hook(size_t bytes, const void* arg) { return orig_malloc_hook(bytes, arg); } - void orig_malloc_hook = __malloc_hook; + auto orig_malloc_hook = __malloc_hook; __malloc_hook = new_malloc_hook; Enabling Examples diff --git a/libc/platform/bionic/macros.h b/libc/platform/bionic/macros.h index 28a69e6d7..076cff116 100644 --- a/libc/platform/bionic/macros.h +++ b/libc/platform/bionic/macros.h @@ -83,11 +83,15 @@ char (&ArraySizeHelper(T (&array)[N]))[N]; // NOLINT(readability/casting) #define __BIONIC_FALLTHROUGH #endif -template <typename T> -static inline T* untag_address(T* p) { +static inline uintptr_t untag_address(uintptr_t p) { #if defined(__aarch64__) - return reinterpret_cast<T*>(reinterpret_cast<uintptr_t>(p) & ((1ULL << 56) - 1)); + return p & ((1ULL << 56) - 1); #else return p; #endif } + +template <typename T> +static inline T* untag_address(T* p) { + return reinterpret_cast<T*>(untag_address(reinterpret_cast<uintptr_t>(p))); +} diff --git a/libc/platform/bionic/mte_kernel.h b/libc/platform/bionic/mte_kernel.h index 2c777c949..e8ef2a562 100644 --- a/libc/platform/bionic/mte_kernel.h +++ b/libc/platform/bionic/mte_kernel.h @@ -37,7 +37,7 @@ #ifdef ANDROID_EXPERIMENTAL_MTE -#define HWCAP2_MTE (1 << 10) +#define HWCAP2_MTE (1 << 18) #define PROT_MTE 0x20 #define PR_MTE_TCF_SHIFT 1 @@ -45,10 +45,13 @@ #define PR_MTE_TCF_SYNC (1UL << PR_MTE_TCF_SHIFT) #define PR_MTE_TCF_ASYNC (2UL << PR_MTE_TCF_SHIFT) #define PR_MTE_TCF_MASK (3UL << PR_MTE_TCF_SHIFT) -#define PR_MTE_EXCL_SHIFT 3 -#define PR_MTE_EXCL_MASK (0xffffUL << PR_MTE_EXCL_SHIFT) +#define PR_MTE_TAG_SHIFT 3 +#define PR_MTE_TAG_MASK (0xffffUL << PR_MTE_TAG_SHIFT) -#define SEGV_MTEAERR 6 -#define SEGV_MTESERR 7 +#define SEGV_MTEAERR 8 +#define SEGV_MTESERR 9 + +#define PTRACE_PEEKMTETAGS 33 +#define PTRACE_POKEMTETAGS 34 #endif diff --git a/libc/private/bionic_globals.h b/libc/private/bionic_globals.h index 6e7eb76e4..54605dbf3 100644 --- a/libc/private/bionic_globals.h +++ b/libc/private/bionic_globals.h @@ -101,8 +101,8 @@ struct libc_shared_globals { const char* init_progname = nullptr; char** init_environ = nullptr; - const gwp_asan::AllocatorState *gwp_asan_state = nullptr; - const gwp_asan::AllocationMetadata *gwp_asan_metadata = nullptr; + const gwp_asan::AllocatorState* gwp_asan_state = nullptr; + const gwp_asan::AllocationMetadata* gwp_asan_metadata = nullptr; }; __LIBC_HIDDEN__ libc_shared_globals* __libc_shared_globals(); diff --git a/libc/system_properties/contexts_split.cpp b/libc/system_properties/contexts_split.cpp index 11db7ec68..96b01a47c 100644 --- a/libc/system_properties/contexts_split.cpp +++ b/libc/system_properties/contexts_split.cpp @@ -114,8 +114,6 @@ static void ListFree(List** list) { } // The below two functions are duplicated from label_support.c in libselinux. -// TODO: Find a location suitable for these functions such that both libc and -// libselinux can share a common source file. // The read_spec_entries and read_spec_entry functions may be used to // replace sscanf to read entries from spec files. The file and diff --git a/libc/upstream-openbsd/android/include/arc4random.h b/libc/upstream-openbsd/android/include/arc4random.h index 5f0b15e0f..96f94be03 100644 --- a/libc/upstream-openbsd/android/include/arc4random.h +++ b/libc/upstream-openbsd/android/include/arc4random.h @@ -36,14 +36,6 @@ //#define _ARC4_LOCK() pthread_mutex_lock(&arc4random_mtx) //#define _ARC4_UNLOCK() pthread_mutex_unlock(&arc4random_mtx) -#ifdef __GLIBC__ -extern void *__dso_handle; -extern int __register_atfork(void (*)(void), void(*)(void), void (*)(void), void *); -#define _ARC4_ATFORK(f) __register_atfork(NULL, NULL, (f), __dso_handle) -#else -#define _ARC4_ATFORK(f) pthread_atfork(NULL, NULL, (f)) -#endif - static inline void _getentropy_fail(void) { async_safe_fatal("getentropy failed: %s", strerror(errno)); } |