Merge "Add scsi directory"
diff --git a/CleanSpec.mk b/CleanSpec.mk
index 8865723..e8dd26c 100644
--- a/CleanSpec.mk
+++ b/CleanSpec.mk
@@ -57,6 +57,11 @@
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/root/bionic)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/recovery/root/bionic)
+# Ensure libdl_android.so is (only) in the correct locations after the move into
+# the Runtime APEX.
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/apex/com.android.runtime/lib{,64})
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib{,64})
+
# ************************************************
# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
# ************************************************
diff --git a/TEST_MAPPING b/TEST_MAPPING
index e4d3d5e..1d652f7 100644
--- a/TEST_MAPPING
+++ b/TEST_MAPPING
@@ -2,6 +2,12 @@
"presubmit": [
{
"name": "CtsBionicTestCases"
+ },
+ {
+ "name": "malloc_debug_system_tests"
+ },
+ {
+ "name": "malloc_hooks_system_tests"
}
]
}
diff --git a/benchmarks/Android.bp b/benchmarks/Android.bp
index a7be965..b4176de 100644
--- a/benchmarks/Android.bp
+++ b/benchmarks/Android.bp
@@ -33,6 +33,7 @@
"get_heap_size_benchmark.cpp",
"inttypes_benchmark.cpp",
"malloc_benchmark.cpp",
+ "malloc_sql_benchmark.cpp",
"math_benchmark.cpp",
"property_benchmark.cpp",
"pthread_benchmark.cpp",
diff --git a/benchmarks/malloc_benchmark.cpp b/benchmarks/malloc_benchmark.cpp
index ca54f11..18ba523 100644
--- a/benchmarks/malloc_benchmark.cpp
+++ b/benchmarks/malloc_benchmark.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2018 The Android Open Source Project
+ * Copyright (C) 2019 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -27,102 +27,46 @@
*/
#include <malloc.h>
-#include <stdlib.h>
+#include <unistd.h>
+
+#include <vector>
#include <benchmark/benchmark.h>
#include "util.h"
#if defined(__BIONIC__)
-enum AllocEnum : uint8_t {
- MALLOC = 0,
- CALLOC,
- MEMALIGN,
- REALLOC,
- FREE,
-};
-
-struct MallocEntry {
- AllocEnum type;
- size_t idx;
- size_t size;
- size_t arg2;
-};
-
-void BenchmarkMalloc(MallocEntry entries[], size_t total_entries, size_t max_allocs) {
- void* ptrs[max_allocs];
-
- for (size_t i = 0; i < total_entries; i++) {
- switch (entries[i].type) {
- case MALLOC:
- ptrs[entries[i].idx] = malloc(entries[i].size);
- // Touch at least one byte of the allocation to make sure that
- // PSS for this allocation is counted.
- reinterpret_cast<uint8_t*>(ptrs[entries[i].idx])[0] = 10;
- break;
- case CALLOC:
- ptrs[entries[i].idx] = calloc(entries[i].arg2, entries[i].size);
- // Touch at least one byte of the allocation to make sure that
- // PSS for this allocation is counted.
- reinterpret_cast<uint8_t*>(ptrs[entries[i].idx])[0] = 20;
- break;
- case MEMALIGN:
- ptrs[entries[i].idx] = memalign(entries[i].arg2, entries[i].size);
- // Touch at least one byte of the allocation to make sure that
- // PSS for this allocation is counted.
- reinterpret_cast<uint8_t*>(ptrs[entries[i].idx])[0] = 30;
- break;
- case REALLOC:
- if (entries[i].arg2 == 0) {
- ptrs[entries[i].idx] = realloc(nullptr, entries[i].size);
- } else {
- ptrs[entries[i].idx] = realloc(ptrs[entries[i].arg2 - 1], entries[i].size);
- }
- // Touch at least one byte of the allocation to make sure that
- // PSS for this allocation is counted.
- reinterpret_cast<uint8_t*>(ptrs[entries[i].idx])[0] = 40;
- break;
- case FREE:
- free(ptrs[entries[i].idx]);
- break;
- }
- }
-}
-
-// This codifies playing back a single threaded trace of the allocations
-// when running the SQLite BenchMark app.
-// Instructions for recreating:
-// - Enable malloc debug
-// setprop wrap.com.wtsang02.sqliteutil "LIBC_DEBUG_MALLOC_OPTIONS=record_allocs logwrapper"
-// - Start the SQLite BenchMark app
-// - Dump allocs using the signal to get rid of non sql allocs(kill -47 <SQLITE_PID>)
-// - Run the benchmark.
-// - Dump allocs using the signal again.
-// - Find the thread that has the most allocs and run the helper script
-// bionic/libc/malloc_debug/tools/gen_malloc.pl -i <THREAD_ID> g_sql_entries kMaxSqlAllocSlots < <ALLOC_FILE> > malloc_sql.h
-#include "malloc_sql.h"
-
-static void BM_malloc_sql_trace_default(benchmark::State& state) {
- // The default is expected to be a zero decay time.
- mallopt(M_DECAY_TIME, 0);
-
- for (auto _ : state) {
- BenchmarkMalloc(g_sql_entries, sizeof(g_sql_entries) / sizeof(MallocEntry),
- kMaxSqlAllocSlots);
- }
-}
-BIONIC_BENCHMARK(BM_malloc_sql_trace_default);
-
-static void BM_malloc_sql_trace_decay1(benchmark::State& state) {
+static void BM_mallopt_purge(benchmark::State& state) {
+ static size_t sizes[] = {8, 16, 32, 64, 128, 1024, 4096, 16384, 65536, 131072, 1048576};
+ static int pagesize = getpagesize();
mallopt(M_DECAY_TIME, 1);
-
+ mallopt(M_PURGE, 0);
for (auto _ : state) {
- BenchmarkMalloc(g_sql_entries, sizeof(g_sql_entries) / sizeof(MallocEntry),
- kMaxSqlAllocSlots);
- }
+ state.PauseTiming();
+ std::vector<void*> ptrs;
+ for (auto size : sizes) {
+ // Allocate at least two pages worth of the allocations.
+ for (size_t allocated = 0; allocated < 2 * static_cast<size_t>(pagesize); allocated += size) {
+ void* ptr = malloc(size);
+ if (ptr == nullptr) {
+ state.SkipWithError("Failed to allocate memory");
+ }
+ MakeAllocationResident(ptr, size, pagesize);
+ ptrs.push_back(ptr);
+ }
+ }
+ // Free the memory, which should leave many of the pages resident until
+ // the purge call.
+ for (auto ptr : ptrs) {
+ free(ptr);
+ }
+ ptrs.clear();
+ state.ResumeTiming();
+ mallopt(M_PURGE, 0);
+ }
mallopt(M_DECAY_TIME, 0);
}
-BIONIC_BENCHMARK(BM_malloc_sql_trace_decay1);
+BIONIC_BENCHMARK(BM_mallopt_purge);
#endif
diff --git a/benchmarks/malloc_sql_benchmark.cpp b/benchmarks/malloc_sql_benchmark.cpp
new file mode 100644
index 0000000..383325c
--- /dev/null
+++ b/benchmarks/malloc_sql_benchmark.cpp
@@ -0,0 +1,129 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ * 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.
+ *
+ * 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 OWNER 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.
+ */
+
+#include <malloc.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include <benchmark/benchmark.h>
+#include "util.h"
+
+#if defined(__BIONIC__)
+
+enum AllocEnum : uint8_t {
+ MALLOC = 0,
+ CALLOC,
+ MEMALIGN,
+ REALLOC,
+ FREE,
+};
+
+struct MallocEntry {
+ AllocEnum type;
+ size_t idx;
+ size_t size;
+ size_t arg2;
+};
+
+void BenchmarkMalloc(MallocEntry entries[], size_t total_entries, size_t max_allocs) {
+ void* ptrs[max_allocs];
+
+ for (size_t i = 0; i < total_entries; i++) {
+ switch (entries[i].type) {
+ case MALLOC:
+ ptrs[entries[i].idx] = malloc(entries[i].size);
+ // Touch at least one byte of the allocation to make sure that
+ // PSS for this allocation is counted.
+ reinterpret_cast<uint8_t*>(ptrs[entries[i].idx])[0] = 10;
+ break;
+ case CALLOC:
+ ptrs[entries[i].idx] = calloc(entries[i].arg2, entries[i].size);
+ // Touch at least one byte of the allocation to make sure that
+ // PSS for this allocation is counted.
+ reinterpret_cast<uint8_t*>(ptrs[entries[i].idx])[0] = 20;
+ break;
+ case MEMALIGN:
+ ptrs[entries[i].idx] = memalign(entries[i].arg2, entries[i].size);
+ // Touch at least one byte of the allocation to make sure that
+ // PSS for this allocation is counted.
+ reinterpret_cast<uint8_t*>(ptrs[entries[i].idx])[0] = 30;
+ break;
+ case REALLOC:
+ if (entries[i].arg2 == 0) {
+ ptrs[entries[i].idx] = realloc(nullptr, entries[i].size);
+ } else {
+ ptrs[entries[i].idx] = realloc(ptrs[entries[i].arg2 - 1], entries[i].size);
+ }
+ // Touch at least one byte of the allocation to make sure that
+ // PSS for this allocation is counted.
+ reinterpret_cast<uint8_t*>(ptrs[entries[i].idx])[0] = 40;
+ break;
+ case FREE:
+ free(ptrs[entries[i].idx]);
+ break;
+ }
+ }
+}
+
+// This codifies playing back a single threaded trace of the allocations
+// when running the SQLite BenchMark app.
+// Instructions for recreating:
+// - Enable malloc debug
+// setprop wrap.com.wtsang02.sqliteutil "LIBC_DEBUG_MALLOC_OPTIONS=record_allocs logwrapper"
+// - Start the SQLite BenchMark app
+// - Dump allocs using the signal to get rid of non sql allocs(kill -47 <SQLITE_PID>)
+// - Run the benchmark.
+// - Dump allocs using the signal again.
+// - Find the thread that has the most allocs and run the helper script
+// bionic/libc/malloc_debug/tools/gen_malloc.pl -i <THREAD_ID> g_sql_entries kMaxSqlAllocSlots < <ALLOC_FILE> > malloc_sql.h
+#include "malloc_sql.h"
+
+static void BM_malloc_sql_trace_default(benchmark::State& state) {
+ // The default is expected to be a zero decay time.
+ mallopt(M_DECAY_TIME, 0);
+
+ for (auto _ : state) {
+ BenchmarkMalloc(g_sql_entries, sizeof(g_sql_entries) / sizeof(MallocEntry),
+ kMaxSqlAllocSlots);
+ }
+}
+BIONIC_BENCHMARK(BM_malloc_sql_trace_default);
+
+static void BM_malloc_sql_trace_decay1(benchmark::State& state) {
+ mallopt(M_DECAY_TIME, 1);
+
+ for (auto _ : state) {
+ BenchmarkMalloc(g_sql_entries, sizeof(g_sql_entries) / sizeof(MallocEntry),
+ kMaxSqlAllocSlots);
+ }
+
+ mallopt(M_DECAY_TIME, 0);
+}
+BIONIC_BENCHMARK(BM_malloc_sql_trace_decay1);
+
+#endif
diff --git a/benchmarks/property_benchmark.cpp b/benchmarks/property_benchmark.cpp
index 77814bf..ba54ed1 100644
--- a/benchmarks/property_benchmark.cpp
+++ b/benchmarks/property_benchmark.cpp
@@ -184,7 +184,7 @@
size_t i = 0;
while (state.KeepRunning()) {
- pa.system_properties().Serial(pinfo[i]);
+ __system_property_serial(pinfo[i]);
i = (i + 1) % nprops;
}
diff --git a/benchmarks/stdlib_benchmark.cpp b/benchmarks/stdlib_benchmark.cpp
index ec3f6f2..61b51fa 100644
--- a/benchmarks/stdlib_benchmark.cpp
+++ b/benchmarks/stdlib_benchmark.cpp
@@ -24,18 +24,6 @@
#include <benchmark/benchmark.h>
#include "util.h"
-#if defined(__BIONIC__)
-
-#else
-#endif
-
-static __always_inline void MakeAllocationResident(void* ptr, size_t nbytes, int pagesize) {
- uint8_t* data = reinterpret_cast<uint8_t*>(ptr);
- for (size_t i = 0; i < nbytes; i += pagesize) {
- data[i] = 1;
- }
-}
-
static void MallocFree(benchmark::State& state) {
const size_t nbytes = state.range(0);
int pagesize = getpagesize();
diff --git a/benchmarks/util.h b/benchmarks/util.h
index ef4892d..99eed5f 100644
--- a/benchmarks/util.h
+++ b/benchmarks/util.h
@@ -16,6 +16,8 @@
#pragma once
+#include <stdint.h>
+
#include <map>
#include <mutex>
#include <string>
@@ -68,3 +70,11 @@
char* GetAlignedPtrFilled(std::vector<char>* buf, size_t alignment, size_t nbytes, char fill_byte);
bool LockToCPU(int cpu_to_lock);
+
+static __inline __attribute__ ((__always_inline__)) void MakeAllocationResident(
+ void* ptr, size_t nbytes, int pagesize) {
+ uint8_t* data = reinterpret_cast<uint8_t*>(ptr);
+ for (size_t i = 0; i < nbytes; i += pagesize) {
+ data[i] = 1;
+ }
+}
diff --git a/docs/native_allocator.md b/docs/native_allocator.md
index adfa6ef..139d664 100644
--- a/docs/native_allocator.md
+++ b/docs/native_allocator.md
@@ -144,6 +144,32 @@
These benchmarks are only used to verify the speed of the allocator and
ignore anything related to RSS and virtual address space consumed.
+For all of these benchmark runs, it can be useful to add these two options:
+
+ --benchmark_repetitions=XX
+ --benchmark_report_aggregates_only=true
+
+This will run the benchmark XX times and then give a mean, median, and stddev
+and helps to get a number that can be compared to the new allocator.
+
+In addition, there is another option:
+
+ --bionic_cpu=XX
+
+Which will lock the benchmark to only run on core XX. This also avoids
+any issue related to the code migrating from one core to another
+with different characteristics. For example, on a big-little cpu, if the
+benchmark moves from big to little or vice-versa, this can cause scores
+to fluctuate in indeterminate ways.
+
+For most runs, the best set of options to add is:
+
+ --benchmark_repetitions=10 --benchmark_report_aggregates_only=true --bionic_cpu=3
+
+On most phones with a big-little cpu, the third core is the little core.
+Choosing to run on the little core can tend to highlight any performance
+differences.
+
#### Allocate/Free Benchmarks
These are the benchmarks to verify the allocation speed of a loop doing a
single allocation, touching every page in the allocation to make it resident
@@ -240,6 +266,30 @@
These numbers should be as performant as the current allocator.
+#### mallinfo Benchmark
+This benchmark only verifies that mallinfo is still close to the performance
+of the current allocator.
+
+To run the benchmark, use these commands:
+
+ adb shell /data/benchmarktest64/bionic-benchmarks/bionic-benchmarks --benchmark_filter=BM_mallinfo
+ adb shell /data/benchmarktest/bionic-benchmarks/bionic-benchmarks --benchmark_filter=BM_mallinfo
+
+Calls to mallinfo are used in ART so a new allocator is required to be
+nearly as performant as the current allocator.
+
+#### mallopt M\_PURGE Benchmark
+This benchmark tracks the cost of calling `mallopt(M_PURGE, 0)`. As with the
+mallinfo benchmark, it's not necessary for this to be better than the previous
+allocator, only that the performance be in the same order of magnitude.
+
+To run the benchmark, use these commands:
+
+ adb shell /data/benchmarktest64/bionic-benchmarks/bionic-benchmarks --benchmark_filter=BM_mallopt_purge
+ adb shell /data/benchmarktest/bionic-benchmarks/bionic-benchmarks --benchmark_filter=BM_mallopt_purge
+
+These calls are used to free unused memory pages back to the kernel.
+
### Memory Trace Benchmarks
These benchmarks measure all three axes of a native allocator, RSS, virtual
address space consumed, speed of allocation. They are designed to
diff --git a/docs/status.md b/docs/status.md
index 6968a18..a1d5332 100644
--- a/docs/status.md
+++ b/docs/status.md
@@ -213,18 +213,31 @@
* all of <sys/xattr.h>.
libc function count over time:
- G 803, H 825, I 826, J 846, J-MR1 873, J-MR2 881, K 896, L 1116, M 1181, N 1226, O 1278
+| OS | API level | Function count |
+|-------|-----------|----------------|
+| J | 16 | 842 |
+| J MR1 | 17 | 870 |
+| J MR2 | 18 | 878 |
+| K | 19 | 893 |
+| L | 21 | 1118 |
+| M | 23 | 1183 |
+| N | 24 | 1228 |
+| O | 26 | 1280 |
+| P | 28 | 1378 |
+| Q | 29 | 1394 |
+
+Data collected by:
```
-ndk-r17$ for i in `ls -1v platforms/android-*/arch-arm/usr/lib/libc.so` ; do \
- echo $i; nm $i | grep -vw [AbdNnt] | grep -vw B | wc -l ; done
+ndk-r21$ for i in `ls -1v platforms/android-*/arch-arm/usr/lib/libc.so` ; do \
+ echo $i; nm $i | grep -w T | wc -l ; done
```
### libm
Current libm symbols: https://android.googlesource.com/platform/bionic/+/master/libm/libm.map.txt
-0 remaining missing POSIX libm functions.
+0 remaining missing C11/POSIX libm functions.
New libm functions in O (API level 26):
* <complex.h> `clog`/`clogf`, `cpow`/`cpowf` functions.
@@ -240,10 +253,6 @@
New libm functions in J-MR2 (API level 18):
* <math.h> `log2`, `log2f`.
-libm function count over time:
- G 158, J-MR2 164, L 220, M 265, O 284
-
-
## Target API level behavioral differences
diff --git a/libc/Android.bp b/libc/Android.bp
index d002e50..d418012 100644
--- a/libc/Android.bp
+++ b/libc/Android.bp
@@ -20,13 +20,8 @@
"stdlib/exit.c",
]
-// Various kinds of cruft.
+// off64_t/time64_t support on LP32.
// ========================================================
-libc_common_src_files += [
- "bionic/ndk_cruft.cpp",
- "bionic/ndk_cruft_data.cpp",
-]
-
libc_common_src_files_32 = [
"bionic/legacy_32_bit_support.cpp",
"bionic/time64.c",
@@ -42,7 +37,6 @@
"-Wno-deprecated-declarations",
"-Wno-gcc-compat",
"-Wframe-larger-than=2048",
- "-Wimplicit-fallthrough",
// Try to catch typical 32-bit assumptions that break with 64-bit pointers.
"-Werror=pointer-to-int-cast",
@@ -133,9 +127,18 @@
name: "libc_scudo_defaults",
cflags: [
- "-DUSE_SCUDO",
+ "-DUSE_SCUDO_SVELTE",
],
+ product_variables: {
+ malloc_not_svelte: {
+ cflags: [
+ "-UUSE_SCUDO_SVELTE",
+ "-DUSE_SCUDO",
+ ],
+ },
+ },
+
whole_static_libs: [
"libscudo",
],
@@ -537,7 +540,6 @@
"upstream-openbsd/lib/libc/string/strpbrk.c",
"upstream-openbsd/lib/libc/string/strsep.c",
"upstream-openbsd/lib/libc/string/strspn.c",
- "upstream-openbsd/lib/libc/string/strstr.c",
"upstream-openbsd/lib/libc/string/strtok.c",
"upstream-openbsd/lib/libc/string/strxfrm.c",
"upstream-openbsd/lib/libc/string/wcslcpy.c",
@@ -565,6 +567,7 @@
srcs: [
"stdio/vfprintf.cpp",
"stdio/vfwprintf.cpp",
+ "upstream-openbsd/lib/libc/string/strstr.c",
],
cflags: [
"-include openbsd-compat.h",
@@ -1610,6 +1613,8 @@
"bionic/malloc_common_dynamic.cpp",
"bionic/malloc_heapprofd.cpp",
"bionic/malloc_limit.cpp",
+ "bionic/ndk_cruft.cpp",
+ "bionic/ndk_cruft_data.cpp",
"bionic/NetdClient.cpp",
"arch-common/bionic/crtend_so.S",
],
@@ -1711,6 +1716,8 @@
strip: {
keep_symbols_and_debug_frame: true,
},
+
+ whole_static_libs: [ "libgcc_stripped" ],
},
arm64: {
version_script: ":libc.arm64.map",
diff --git a/libc/NOTICE b/libc/NOTICE
index d9ac638..e2afdbf 100644
--- a/libc/NOTICE
+++ b/libc/NOTICE
@@ -1030,7 +1030,7 @@
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
-http://www.apache.org/licenses/LICENSE-2.0
+ http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
@@ -3113,7 +3113,7 @@
-------------------------------------------------------------------
-Copyright (c) 1997 Todd C. Miller <Todd.Miller@courtesan.com>
+Copyright (c) 1997 Todd C. Miller <millert@openbsd.org>
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -3353,7 +3353,7 @@
-------------------------------------------------------------------
-Copyright (c) 1998, 2015 Todd C. Miller <Todd.Miller@courtesan.com>
+Copyright (c) 1998, 2015 Todd C. Miller <millert@openbsd.org>
Permission to use, copy, modify, and distribute this software for any
purpose with or without fee is hereby granted, provided that the above
@@ -4418,6 +4418,29 @@
-------------------------------------------------------------------
+Copyright (c) 2005-2014 Rich Felker
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+-------------------------------------------------------------------
+
Copyright (c) 2007 David Schultz
All rights reserved.
@@ -4560,7 +4583,7 @@
-------------------------------------------------------------------
-Copyright (c) 2007 Todd C. Miller <Todd.Miller@courtesan.com>
+Copyright (c) 2007 Todd C. Miller <millert@openbsd.org>
Permission to use, copy, modify, and distribute this software for any
purpose with or without fee is hereby granted, provided that the above
@@ -4923,7 +4946,7 @@
-------------------------------------------------------------------
-Copyright (c) 2010 Todd C. Miller <Todd.Miller@courtesan.com>
+Copyright (c) 2010 Todd C. Miller <millert@openbsd.org>
Permission to use, copy, modify, and distribute this software for any
purpose with or without fee is hereby granted, provided that the above
diff --git a/libc/arch-x86/generic/string/wmemset.c b/libc/arch-x86/generic/string/wmemset.c
index eff533c..35d489f 100644
--- a/libc/arch-x86/generic/string/wmemset.c
+++ b/libc/arch-x86/generic/string/wmemset.c
@@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/libc/arch-x86_64/string/cache.h b/libc/arch-x86_64/string/cache.h
index 38acc6e..4131509 100644
--- a/libc/arch-x86_64/string/cache.h
+++ b/libc/arch-x86_64/string/cache.h
@@ -28,9 +28,9 @@
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-/* Values are optimized for Silvermont */
-#define SHARED_CACHE_SIZE (1024*1024) /* Silvermont L2 Cache */
-#define DATA_CACHE_SIZE (24*1024) /* Silvermont L1 Data Cache */
+/* Values are optimized for Core Architecture */
+#define SHARED_CACHE_SIZE (4096*1024) /* Core Architecture L2 Cache */
+#define DATA_CACHE_SIZE (24*1024) /* Core Architecture L1 Data Cache */
-#define SHARED_CACHE_SIZE_HALF (SHARED_CACHE_SIZE / 2)
-#define DATA_CACHE_SIZE_HALF (DATA_CACHE_SIZE / 2)
+#define SHARED_CACHE_SIZE_HALF (SHARED_CACHE_SIZE / 2)
+#define DATA_CACHE_SIZE_HALF (DATA_CACHE_SIZE / 2)
diff --git a/libc/bionic/bionic_allocator.cpp b/libc/bionic/bionic_allocator.cpp
index 168d6ba..7fd7067 100644
--- a/libc/bionic/bionic_allocator.cpp
+++ b/libc/bionic/bionic_allocator.cpp
@@ -40,8 +40,8 @@
#include <async_safe/log.h>
#include <async_safe/CHECK.h>
+#include "platform/bionic/page.h"
#include "private/bionic_macros.h"
-#include "private/bionic_page.h"
//
// BionicAllocator is a general purpose allocator designed to provide the same
diff --git a/libc/bionic/jemalloc.h b/libc/bionic/jemalloc.h
index ef77c9c..4ce51c0 100644
--- a/libc/bionic/jemalloc.h
+++ b/libc/bionic/jemalloc.h
@@ -29,7 +29,7 @@
__BEGIN_DECLS
void* je_aligned_alloc_wrapper(size_t, size_t);
-int je_iterate(uintptr_t, size_t, void (*)(uintptr_t, size_t, void*), void*);
+int je_malloc_iterate(uintptr_t, size_t, void (*)(uintptr_t, size_t, void*), void*);
int je_mallctl(const char *name, void *oldp, size_t *oldlenp, void *newp, size_t newlen) __attribute__((nothrow));
struct mallinfo je_mallinfo();
void je_malloc_disable();
diff --git a/libc/bionic/libc_init_common.cpp b/libc/bionic/libc_init_common.cpp
index 1f099cf..d64a6bd 100644
--- a/libc/bionic/libc_init_common.cpp
+++ b/libc/bionic/libc_init_common.cpp
@@ -42,6 +42,7 @@
#include <unistd.h>
#include <async_safe/log.h>
+#include <platform/bionic/mte_kernel.h>
#include "private/WriteProtected.h"
#include "private/bionic_defs.h"
@@ -101,11 +102,31 @@
__libc_add_main_thread();
- // Register atfork handlers to take and release the arc4random lock.
- pthread_atfork(arc4random_fork_handler, _thread_arc4_unlock, _thread_arc4_unlock);
-
__system_properties_init(); // Requires 'environ'.
__libc_init_fdsan(); // Requires system properties (for debug.fdsan).
+
+ // Allow the kernel to accept tagged pointers in syscall arguments. This is a no-op (kernel
+ // returns -EINVAL) if the kernel doesn't understand the prctl.
+#if defined(__aarch64__)
+#define PR_SET_TAGGED_ADDR_CTRL 55
+#define PR_TAGGED_ADDR_ENABLE (1UL << 0)
+#ifdef ANDROID_EXPERIMENTAL_MTE
+ // First, try enabling MTE in asynchronous mode, with tag 0 excluded. This will fail if the kernel
+ // 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)) {
+ prctl(PR_SET_TAGGED_ADDR_CTRL, PR_TAGGED_ADDR_ENABLE, 0, 0, 0);
+ }
+#else
+ prctl(PR_SET_TAGGED_ADDR_CTRL, PR_TAGGED_ADDR_ENABLE, 0, 0, 0);
+#endif
+#endif
+}
+
+void __libc_init_fork_handler() {
+ // Register atfork handlers to take and release the arc4random lock.
+ pthread_atfork(arc4random_fork_handler, _thread_arc4_unlock, _thread_arc4_unlock);
}
__noreturn static void __early_abort(int line) {
diff --git a/libc/bionic/libc_init_common.h b/libc/bionic/libc_init_common.h
index 73f5817..0c2e78a 100644
--- a/libc/bionic/libc_init_common.h
+++ b/libc/bionic/libc_init_common.h
@@ -56,4 +56,8 @@
__LIBC_HIDDEN__ void __libc_init_AT_SECURE(char** envp);
+// The fork handler must be initialised after __libc_init_malloc, as
+// pthread_atfork may call malloc() during its once-init.
+__LIBC_HIDDEN__ void __libc_init_fork_handler();
+
#endif
diff --git a/libc/bionic/libc_init_dynamic.cpp b/libc/bionic/libc_init_dynamic.cpp
index d6d5552..ca94652 100644
--- a/libc/bionic/libc_init_dynamic.cpp
+++ b/libc/bionic/libc_init_dynamic.cpp
@@ -99,6 +99,8 @@
// Hooks for various libraries to let them know that we're starting up.
__libc_globals.mutate(__libc_init_malloc);
+ __libc_init_fork_handler();
+
#if __has_feature(hwaddress_sanitizer)
// Notify the HWASan runtime library whenever a library is loaded or unloaded
// so that it can update its shadow memory.
diff --git a/libc/bionic/libc_init_static.cpp b/libc/bionic/libc_init_static.cpp
index 28c0b0c..d2a5334 100644
--- a/libc/bionic/libc_init_static.cpp
+++ b/libc/bionic/libc_init_static.cpp
@@ -39,11 +39,11 @@
#include "libc_init_common.h"
#include "pthread_internal.h"
+#include "platform/bionic/page.h"
#include "private/bionic_call_ifunc_resolver.h"
#include "private/bionic_elf_tls.h"
#include "private/bionic_globals.h"
#include "private/bionic_macros.h"
-#include "private/bionic_page.h"
#include "private/bionic_tls.h"
#include "private/KernelArgumentBlock.h"
@@ -181,6 +181,7 @@
layout_static_tls(args);
__libc_init_main_thread_final();
__libc_init_common();
+ __libc_init_fork_handler();
call_ifunc_resolvers();
apply_gnu_relro();
diff --git a/libc/bionic/malloc_common.cpp b/libc/bionic/malloc_common.cpp
index 96e6140..a0da3db 100644
--- a/libc/bionic/malloc_common.cpp
+++ b/libc/bionic/malloc_common.cpp
@@ -215,9 +215,9 @@
void (*callback)(uintptr_t base, size_t size, void* arg), void* arg) {
auto dispatch_table = GetDispatchTable();
if (__predict_false(dispatch_table != nullptr)) {
- return dispatch_table->iterate(base, size, callback, arg);
+ return dispatch_table->malloc_iterate(base, size, callback, arg);
}
- return Malloc(iterate)(base, size, callback, arg);
+ return Malloc(malloc_iterate)(base, size, callback, arg);
}
// Disable calls to malloc so malloc_iterate gets a consistent view of
@@ -247,9 +247,10 @@
#if __has_feature(hwaddress_sanitizer)
// FIXME: implement these in HWASan allocator.
-extern "C" int __sanitizer_iterate(uintptr_t base __unused, size_t size __unused,
- void (*callback)(uintptr_t base, size_t size, void* arg) __unused,
- void* arg __unused) {
+extern "C" int __sanitizer_malloc_iterate(uintptr_t base __unused, size_t size __unused,
+ void (*callback)(uintptr_t base, size_t size, void* arg)
+ __unused,
+ void* arg __unused) {
return 0;
}
diff --git a/libc/bionic/malloc_common.h b/libc/bionic/malloc_common.h
index 2176e63..4a726db 100644
--- a/libc/bionic/malloc_common.h
+++ b/libc/bionic/malloc_common.h
@@ -42,9 +42,9 @@
__BEGIN_DECLS
// FIXME: implement these in HWASan allocator.
-int __sanitizer_iterate(uintptr_t base, size_t size,
- void (*callback)(uintptr_t base, size_t size, void* arg),
- void* arg);
+int __sanitizer_malloc_iterate(uintptr_t base, size_t size,
+ void (*callback)(uintptr_t base, size_t size, void* arg),
+ void* arg);
void __sanitizer_malloc_disable();
void __sanitizer_malloc_enable();
int __sanitizer_malloc_info(int options, FILE* fp);
@@ -60,6 +60,11 @@
#include "scudo.h"
#define Malloc(function) scudo_ ## function
+#elif defined(USE_SCUDO_SVELTE)
+
+#include "scudo.h"
+#define Malloc(function) scudo_svelte_ ## function
+
#else
#include "jemalloc.h"
diff --git a/libc/bionic/malloc_common_dynamic.cpp b/libc/bionic/malloc_common_dynamic.cpp
index 9ad79a0..eec49a4 100644
--- a/libc/bionic/malloc_common_dynamic.cpp
+++ b/libc/bionic/malloc_common_dynamic.cpp
@@ -95,7 +95,7 @@
#if defined(HAVE_DEPRECATED_MALLOC_FUNCS)
Malloc(valloc),
#endif
- Malloc(iterate),
+ Malloc(malloc_iterate),
Malloc(malloc_disable),
Malloc(malloc_enable),
Malloc(mallopt),
@@ -184,7 +184,8 @@
if (!InitMallocFunction<MallocRealloc>(impl_handler, &table->realloc, prefix, "realloc")) {
return false;
}
- if (!InitMallocFunction<MallocIterate>(impl_handler, &table->iterate, prefix, "iterate")) {
+ if (!InitMallocFunction<MallocIterate>(impl_handler, &table->malloc_iterate, prefix,
+ "malloc_iterate")) {
return false;
}
if (!InitMallocFunction<MallocMallocDisable>(impl_handler, &table->malloc_disable, prefix,
@@ -464,6 +465,7 @@
// =============================================================================
// Platform-internal mallopt variant.
// =============================================================================
+__BIONIC_WEAK_FOR_NATIVE_BRIDGE
extern "C" bool android_mallopt(int opcode, void* arg, size_t arg_size) {
if (opcode == M_SET_ZYGOTE_CHILD) {
if (arg != nullptr || arg_size != 0) {
diff --git a/libc/bionic/malloc_heapprofd.cpp b/libc/bionic/malloc_heapprofd.cpp
index 62249fb..5860222 100644
--- a/libc/bionic/malloc_heapprofd.cpp
+++ b/libc/bionic/malloc_heapprofd.cpp
@@ -104,7 +104,7 @@
#if defined(HAVE_DEPRECATED_MALLOC_FUNCS)
Malloc(valloc),
#endif
- Malloc(iterate),
+ Malloc(malloc_iterate),
Malloc(malloc_disable),
Malloc(malloc_enable),
Malloc(mallopt),
diff --git a/libc/bionic/malloc_limit.cpp b/libc/bionic/malloc_limit.cpp
index 6a67cae..d8c0ebe 100644
--- a/libc/bionic/malloc_limit.cpp
+++ b/libc/bionic/malloc_limit.cpp
@@ -350,9 +350,9 @@
static int LimitIterate(uintptr_t base, size_t size, void (*callback)(uintptr_t, size_t, void*), void* arg) {
auto dispatch_table = GetDefaultDispatchTable();
if (__predict_false(dispatch_table != nullptr)) {
- return dispatch_table->iterate(base, size, callback, arg);
+ return dispatch_table->malloc_iterate(base, size, callback, arg);
}
- return Malloc(iterate)(base, size, callback, arg);
+ return Malloc(malloc_iterate)(base, size, callback, arg);
}
static void LimitMallocDisable() {
diff --git a/libc/bionic/scudo.h b/libc/bionic/scudo.h
index d9933c4..946a497 100644
--- a/libc/bionic/scudo.h
+++ b/libc/bionic/scudo.h
@@ -52,8 +52,28 @@
void* scudo_valloc(size_t);
#endif
-int scudo_iterate(uintptr_t, size_t, void (*)(uintptr_t, size_t, void*), void*);
+int scudo_malloc_iterate(uintptr_t, size_t, void (*)(uintptr_t, size_t, void*), void*);
void scudo_malloc_disable();
void scudo_malloc_enable();
+void* scudo_svelte_aligned_alloc(size_t, size_t);
+void* scudo_svelte_calloc(size_t, size_t);
+void scudo_svelte_free(void*);
+struct mallinfo scudo_svelte_mallinfo();
+void* scudo_svelte_malloc(size_t);
+int scudo_svelte_malloc_info(int, FILE*);
+size_t scudo_svelte_malloc_usable_size(const void*);
+int scudo_svelte_mallopt(int, int);
+void* scudo_svelte_memalign(size_t, size_t);
+void* scudo_svelte_realloc(void*, size_t);
+int scudo_svelte_posix_memalign(void**, size_t, size_t);
+#if defined(HAVE_DEPRECATED_MALLOC_FUNCS)
+void* scudo_svelte_pvalloc(size_t);
+void* scudo_svelte_valloc(size_t);
+#endif
+
+int scudo_svelte_malloc_iterate(uintptr_t, size_t, void (*)(uintptr_t, size_t, void*), void*);
+void scudo_svelte_malloc_disable();
+void scudo_svelte_malloc_enable();
+
__END_DECLS
diff --git a/libc/bionic/scudo_wrapper.cpp b/libc/bionic/scudo_wrapper.cpp
index e17f20b..de6969fd 100644
--- a/libc/bionic/scudo_wrapper.cpp
+++ b/libc/bionic/scudo_wrapper.cpp
@@ -35,6 +35,11 @@
__LIBC_HIDDEN__ WriteProtected<libc_globals> __libc_globals;
+// Call the libc malloc initialisers.
+__attribute__((constructor(1))) static void __scudo_preinit() {
+ __libc_globals.mutate(__libc_init_malloc);
+}
+
#if defined(__i386__)
__LIBC_HIDDEN__ void* __libc_sysinfo = reinterpret_cast<void*>(__libc_int0x80);
#endif
@@ -48,7 +53,7 @@
return -1;
}
-int scudo_iterate(uintptr_t, size_t, void (*)(uintptr_t, size_t, void*), void*) {
+int scudo_malloc_iterate(uintptr_t, size_t, void (*)(uintptr_t, size_t, void*), void*) {
return 0;
}
diff --git a/libc/bionic/sysconf.cpp b/libc/bionic/sysconf.cpp
index 2b3200c..dd6b129 100644
--- a/libc/bionic/sysconf.cpp
+++ b/libc/bionic/sysconf.cpp
@@ -52,16 +52,31 @@
// Things we actually have to calculate...
//
case _SC_ARG_MAX:
- // https://lkml.org/lkml/2017/11/15/813...
+ // You might think that just returning a constant 128KiB (ARG_MAX) would
+ // make sense, as this guy did:
//
- // I suspect a 128kB sysconf(_SC_ARG_MAX) is the sanest bet, simply
- // because of that "conservative is better than aggressive".
+ // https://lkml.org/lkml/2017/11/15/813...
//
- // Especially since _technically_ we're still limiting things to that
- // 128kB due to the single-string limit.
+ // I suspect a 128kB sysconf(_SC_ARG_MAX) is the sanest bet, simply
+ // because of that "conservative is better than aggressive".
//
- // Linus
- return ARG_MAX;
+ // Especially since _technically_ we're still limiting things to that
+ // 128kB due to the single-string limit.
+ //
+ // Linus
+ //
+ // In practice that caused us trouble with toybox tests for xargs edge
+ // cases. The tests assume that they can at least reach the kernel's
+ // "minimum maximum" of 128KiB, but if we report 128KiB for _SC_ARG_MAX
+ // and xargs starts subtracting the environment space and so on from that,
+ // then xargs will think it's run out of space when given 128KiB of data,
+ // which should always work. See this thread for more:
+ //
+ // http://lists.landley.net/pipermail/toybox-landley.net/2019-November/011229.html
+ //
+ // So let's resign ourselves to tracking what the kernel actually does.
+ // Right now (2019, Linux 5.3) that amounts to:
+ return MAX(MIN(__sysconf_rlimit(RLIMIT_STACK) / 4, 3 * _STK_LIM / 4), ARG_MAX);
case _SC_AVPHYS_PAGES: return get_avphys_pages();
case _SC_CHILD_MAX: return __sysconf_rlimit(RLIMIT_NPROC);
diff --git a/libc/bionic/system_property_api.cpp b/libc/bionic/system_property_api.cpp
index 051bc4c..a641f12 100644
--- a/libc/bionic/system_property_api.cpp
+++ b/libc/bionic/system_property_api.cpp
@@ -100,7 +100,13 @@
__BIONIC_WEAK_FOR_NATIVE_BRIDGE
uint32_t __system_property_serial(const prop_info* pi) {
- return system_properties.Serial(pi);
+ // N.B. a previous version of this function was much heavier-weight
+ // and enforced acquire semantics, so give our load here acquire
+ // semantics just in case somebody depends on
+ // __system_property_serial enforcing memory order, e.g., in case
+ // someone spins on the result of this function changing before
+ // loading some value.
+ return atomic_load_explicit(&pi->serial, memory_order_acquire);
}
__BIONIC_WEAK_FOR_NATIVE_BRIDGE
diff --git a/libc/include/bits/fortify/fcntl.h b/libc/include/bits/fortify/fcntl.h
index ded62ee..3c5a037 100644
--- a/libc/include/bits/fortify/fcntl.h
+++ b/libc/include/bits/fortify/fcntl.h
@@ -59,11 +59,11 @@
int open(const char* const __pass_object_size pathname, int flags)
__overloadable
__clang_error_if(__open_modes_useful(flags), "'open' " __open_too_few_args_error) {
-#if __ANDROID_API__ >= __ANDROID_API_J_MR1__
+#if __ANDROID_API__ >= __ANDROID_API_J_MR1__ && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED
return __open_2(pathname, flags);
#else
return __open_real(pathname, flags);
-#endif /* __ANDROID_API__ >= __ANDROID_API_J_MR1__ */
+#endif
}
__BIONIC_FORTIFY_INLINE
@@ -83,11 +83,11 @@
int openat(int dirfd, const char* const __pass_object_size pathname, int flags)
__overloadable
__clang_error_if(__open_modes_useful(flags), "'openat' " __open_too_few_args_error) {
-#if __ANDROID_API__ >= __ANDROID_API_J_MR1__
+#if __ANDROID_API__ >= __ANDROID_API_J_MR1__ && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED
return __openat_2(dirfd, pathname, flags);
#else
return __openat_real(dirfd, pathname, flags);
-#endif /* __ANDROID_API__ >= __ANDROID_API_J_MR1__ */
+#endif
}
__BIONIC_FORTIFY_INLINE
@@ -109,7 +109,7 @@
int open64(const char* const __pass_object_size pathname, int flags)
__overloadable
__clang_error_if(__open_modes_useful(flags), "'open64' " __open_too_few_args_error) {
- return __open_2(pathname, flags);
+ return open(pathname, flags);
}
__BIONIC_FORTIFY_INLINE
@@ -117,7 +117,7 @@
__overloadable
__clang_warning_if(!__open_modes_useful(flags) && modes,
"'open64' " __open_useless_modes_warning) {
- return __open_real(pathname, flags, modes);
+ return open(pathname, flags, modes);
}
__BIONIC_ERROR_FUNCTION_VISIBILITY
@@ -129,7 +129,7 @@
int openat64(int dirfd, const char* const __pass_object_size pathname, int flags)
__overloadable
__clang_error_if(__open_modes_useful(flags), "'openat64' " __open_too_few_args_error) {
- return __openat_2(dirfd, pathname, flags);
+ return openat(dirfd, pathname, flags);
}
__BIONIC_FORTIFY_INLINE
@@ -137,7 +137,7 @@
__overloadable
__clang_warning_if(!__open_modes_useful(flags) && modes,
"'openat64' " __open_useless_modes_warning) {
- return __openat_real(dirfd, pathname, flags, modes);
+ return openat(dirfd, pathname, flags, modes);
}
#endif /* __ANDROID_API__ >= __ANDROID_API_L__ */
diff --git a/libc/include/bits/fortify/poll.h b/libc/include/bits/fortify/poll.h
index 7a727a4..30fdce4 100644
--- a/libc/include/bits/fortify/poll.h
+++ b/libc/include/bits/fortify/poll.h
@@ -44,13 +44,13 @@
__overloadable
__clang_error_if(__bos_unevaluated_lt(__bos(fds), sizeof(*fds) * fd_count),
"in call to 'poll', fd_count is larger than the given buffer") {
-#if __ANDROID_API__ >= __ANDROID_API_M__
+#if __ANDROID_API__ >= __ANDROID_API_M__ && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED
size_t bos_fds = __bos(fds);
if (!__bos_fd_count_trivially_safe(bos_fds, fds, fd_count)) {
return __poll_chk(fds, fd_count, timeout, bos_fds);
}
-#endif /* __ANDROID_API__ >= __ANDROID_API_M__ */
+#endif
return __call_bypassing_fortify(poll)(fds, fd_count, timeout);
}
@@ -60,13 +60,13 @@
__overloadable
__clang_error_if(__bos_unevaluated_lt(__bos(fds), sizeof(*fds) * fd_count),
"in call to 'ppoll', fd_count is larger than the given buffer") {
-#if __ANDROID_API__ >= __ANDROID_API_M__
+#if __ANDROID_API__ >= __ANDROID_API_M__ && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED
size_t bos_fds = __bos(fds);
if (!__bos_fd_count_trivially_safe(bos_fds, fds, fd_count)) {
return __ppoll_chk(fds, fd_count, timeout, mask, bos_fds);
}
-#endif /* __ANDROID_API__ >= __ANDROID_API_M__ */
+#endif
return __call_bypassing_fortify(ppoll)(fds, fd_count, timeout, mask);
}
#endif /* __ANDROID_API__ >= __ANDROID_API_L__ */
@@ -77,11 +77,13 @@
__overloadable
__clang_error_if(__bos_unevaluated_lt(__bos(fds), sizeof(*fds) * fd_count),
"in call to 'ppoll64', fd_count is larger than the given buffer") {
+#if __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED
size_t bos_fds = __bos(fds);
if (!__bos_fd_count_trivially_safe(bos_fds, fds, fd_count)) {
return __ppoll64_chk(fds, fd_count, timeout, mask, bos_fds);
}
+#endif
return __call_bypassing_fortify(ppoll64)(fds, fd_count, timeout, mask);
}
#endif /* __ANDROID_API__ >= __ANDROID_API_P__ */
diff --git a/libc/include/bits/fortify/socket.h b/libc/include/bits/fortify/socket.h
index cf5f189..30fe0d7 100644
--- a/libc/include/bits/fortify/socket.h
+++ b/libc/include/bits/fortify/socket.h
@@ -42,13 +42,13 @@
__overloadable
__clang_error_if(__bos_unevaluated_lt(__bos0(buf), len),
"'recvfrom' called with size bigger than buffer") {
-#if __ANDROID_API__ >= __ANDROID_API_N__
+#if __ANDROID_API__ >= __ANDROID_API_N__ && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED
size_t bos = __bos0(buf);
if (!__bos_trivially_ge(bos, len)) {
return __recvfrom_chk(fd, buf, len, bos, flags, src_addr, addr_len);
}
-#endif /* __ANDROID_API__ >= __ANDROID_API_N__ */
+#endif
return __call_bypassing_fortify(recvfrom)(fd, buf, len, flags, src_addr, addr_len);
}
@@ -57,13 +57,13 @@
__overloadable
__clang_error_if(__bos_unevaluated_lt(__bos0(buf), len),
"'sendto' called with size bigger than buffer") {
-#if __ANDROID_API__ >= __ANDROID_API_N_MR1__
+#if __ANDROID_API__ >= __ANDROID_API_N_MR1__ && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED
size_t bos = __bos0(buf);
if (!__bos_trivially_ge(bos, len)) {
return __sendto_chk(fd, buf, len, bos, flags, dest_addr, addr_len);
}
-#endif /* __ANDROID_API__ >= __ANDROID_API_N_MR1__ */
+#endif
return __call_bypassing_fortify(sendto)(fd, buf, len, flags, dest_addr, addr_len);
}
diff --git a/libc/include/bits/fortify/stat.h b/libc/include/bits/fortify/stat.h
index 6a2e822..43fc69c 100644
--- a/libc/include/bits/fortify/stat.h
+++ b/libc/include/bits/fortify/stat.h
@@ -41,11 +41,11 @@
__overloadable
__enable_if(1, "")
__clang_error_if(mode & ~0777, "'umask' called with invalid mode") {
-#if __ANDROID_API__ >= __ANDROID_API_J_MR2__
+#if __ANDROID_API__ >= __ANDROID_API_J_MR2__ && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED
return __umask_chk(mode);
#else
return __umask_real(mode);
-#endif /* __ANDROID_API__ >= __ANDROID_API_J_MR2__ */
+#endif
}
#endif /* defined(__BIONIC_FORTIFY) */
diff --git a/libc/include/bits/fortify/stdio.h b/libc/include/bits/fortify/stdio.h
index 528d5fb..fb503c3 100644
--- a/libc/include/bits/fortify/stdio.h
+++ b/libc/include/bits/fortify/stdio.h
@@ -36,7 +36,7 @@
#if defined(__BIONIC_FORTIFY) && !defined(__BIONIC_NO_STDIO_FORTIFY)
-#if __ANDROID_API__ >= __ANDROID_API_J_MR1__
+#if __ANDROID_API__ >= __ANDROID_API_J_MR1__ && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED
/* No diag -- clang diagnoses misuses of this on its own. */
__BIONIC_FORTIFY_INLINE __printflike(3, 0)
int vsnprintf(char* const __pass_object_size dest, size_t size, const char* format, va_list ap)
@@ -48,7 +48,7 @@
int vsprintf(char* const __pass_object_size dest, const char* format, va_list ap) __overloadable {
return __builtin___vsprintf_chk(dest, 0, __bos(dest), format, ap);
}
-#endif /* __ANDROID_API__ >= __ANDROID_API_J_MR1__ */
+#endif
__BIONIC_ERROR_FUNCTION_VISIBILITY
int sprintf(char* dest, const char* format)
@@ -57,7 +57,7 @@
"format string will always overflow destination buffer")
__errorattr("format string will always overflow destination buffer");
-#if __ANDROID_API__ >= __ANDROID_API_J_MR1__
+#if __ANDROID_API__ >= __ANDROID_API_J_MR1__ && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED
__BIONIC_FORTIFY_VARIADIC __printflike(2, 3)
int sprintf(char* const __pass_object_size dest, const char* format, ...) __overloadable {
va_list va;
@@ -77,7 +77,7 @@
va_end(va);
return result;
}
-#endif /* __ANDROID_API__ >= __ANDROID_API_J_MR1__ */
+#endif
#define __bos_trivially_ge_mul(bos_val, size, count) \
__bos_dynamic_check_impl_and(bos_val, >=, (size) * (count), \
@@ -90,13 +90,13 @@
"in call to 'fread', size * count overflows")
__clang_error_if(__bos_unevaluated_lt(__bos0(buf), size * count),
"in call to 'fread', size * count is too large for the given buffer") {
-#if __ANDROID_API__ >= __ANDROID_API_N__
+#if __ANDROID_API__ >= __ANDROID_API_N__ && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED
size_t bos = __bos0(buf);
if (!__bos_trivially_ge_mul(bos, size, count)) {
return __fread_chk(buf, size, count, stream, bos);
}
-#endif /* __ANDROID_API__ >= __ANDROID_API_N__ */
+#endif
return __call_bypassing_fortify(fread)(buf, size, count, stream);
}
@@ -107,13 +107,13 @@
"in call to 'fwrite', size * count overflows")
__clang_error_if(__bos_unevaluated_lt(__bos0(buf), size * count),
"in call to 'fwrite', size * count is too large for the given buffer") {
-#if __ANDROID_API__ >= __ANDROID_API_N__
+#if __ANDROID_API__ >= __ANDROID_API_N__ && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED
size_t bos = __bos0(buf);
if (!__bos_trivially_ge_mul(bos, size, count)) {
return __fwrite_chk(buf, size, count, stream, bos);
}
-#endif /* __ANDROID_API__ >= __ANDROID_API_N__ */
+#endif
return __call_bypassing_fortify(fwrite)(buf, size, count, stream);
}
#undef __bos_trivially_ge_mul
@@ -124,13 +124,13 @@
__clang_error_if(size < 0, "in call to 'fgets', size should not be negative")
__clang_error_if(__bos_unevaluated_lt(__bos(dest), size),
"in call to 'fgets', size is larger than the destination buffer") {
-#if __ANDROID_API__ >= __ANDROID_API_J_MR1__
+#if __ANDROID_API__ >= __ANDROID_API_J_MR1__ && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED
size_t bos = __bos(dest);
if (!__bos_dynamic_check_impl_and(bos, >=, (size_t)size, size >= 0)) {
return __fgets_chk(dest, size, stream, bos);
}
-#endif /* __ANDROID_API__ >= __ANDROID_API_J_MR1__ */
+#endif
return __call_bypassing_fortify(fgets)(dest, size, stream);
}
diff --git a/libc/include/bits/fortify/string.h b/libc/include/bits/fortify/string.h
index bd36483..7dc60f2 100644
--- a/libc/include/bits/fortify/string.h
+++ b/libc/include/bits/fortify/string.h
@@ -40,7 +40,7 @@
#if defined(__BIONIC_FORTIFY)
extern void* __memrchr_real(const void*, int, size_t) __RENAME(memrchr);
-#if __ANDROID_API__ >= __ANDROID_API_J_MR1__
+#if __ANDROID_API__ >= __ANDROID_API_J_MR1__ && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED
/* No diag -- clang diagnoses misuses of this on its own. */
__BIONIC_FORTIFY_INLINE
void* memcpy(void* const dst __pass_object_size0, const void* src, size_t copy_amount)
@@ -61,7 +61,7 @@
}
return __builtin___memmove_chk(dst, src, len, bos_dst);
}
-#endif /* __ANDROID_API__ >= __ANDROID_API_J_MR1__ */
+#endif
#if defined(__USE_GNU)
#if __ANDROID_API__ >= __ANDROID_API_R__
@@ -70,11 +70,13 @@
__overloadable
__clang_error_if(__bos_unevaluated_lt(__bos0(dst), copy_amount),
"'mempcpy' called with size bigger than buffer") {
+#if __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED
size_t bos_dst = __bos0(dst);
- if (__bos_trivially_ge(bos_dst, copy_amount)) {
- return __builtin_mempcpy(dst, src, copy_amount);
+ if (!__bos_trivially_ge(bos_dst, copy_amount)) {
+ return __builtin___mempcpy_chk(dst, src, copy_amount, bos_dst);
}
- return __builtin___mempcpy_chk(dst, src, copy_amount, bos_dst);
+#endif
+ return __builtin_mempcpy(dst, src, copy_amount);
}
#endif /* __ANDROID_API__ >= __ANDROID_API_R__ */
#endif /* __USE_GNU */
@@ -84,12 +86,12 @@
__overloadable
__clang_error_if(__bos_unevaluated_le(__bos(dst), __builtin_strlen(src)),
"'stpcpy' called with string bigger than buffer") {
-#if __ANDROID_API__ >= __ANDROID_API_L__
+#if __ANDROID_API__ >= __ANDROID_API_L__ && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED
size_t bos_dst = __bos(dst);
if (!__bos_trivially_gt(bos_dst, __builtin_strlen(src))) {
return __builtin___stpcpy_chk(dst, src, bos_dst);
}
-#endif /* __ANDROID_API__ >= __ANDROID_API_L__ */
+#endif
return __builtin_stpcpy(dst, src);
}
@@ -98,12 +100,12 @@
__overloadable
__clang_error_if(__bos_unevaluated_le(__bos(dst), __builtin_strlen(src)),
"'strcpy' called with string bigger than buffer") {
-#if __ANDROID_API__ >= __ANDROID_API_J_MR1__
+#if __ANDROID_API__ >= __ANDROID_API_J_MR1__ && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED
size_t bos_dst = __bos(dst);
if (!__bos_trivially_gt(bos_dst, __builtin_strlen(src))) {
return __builtin___strcpy_chk(dst, src, bos_dst);
}
-#endif /* __ANDROID_API__ >= __ANDROID_API_J_MR1__ */
+#endif
return __builtin_strcpy(dst, src);
}
@@ -112,36 +114,36 @@
__overloadable
__clang_error_if(__bos_unevaluated_le(__bos(dst), __builtin_strlen(src)),
"'strcat' called with string bigger than buffer") {
-#if __ANDROID_API__ >= __ANDROID_API_J_MR1__
+#if __ANDROID_API__ >= __ANDROID_API_J_MR1__ && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED
return __builtin___strcat_chk(dst, src, __bos(dst));
#else
return __builtin_strcat(dst, src);
-#endif /* __ANDROID_API__ >= __ANDROID_API_J_MR1__ */
+#endif
}
-#if __ANDROID_API__ >= __ANDROID_API_J_MR1__
+#if __ANDROID_API__ >= __ANDROID_API_J_MR1__ && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED
/* No diag -- clang diagnoses misuses of this on its own. */
__BIONIC_FORTIFY_INLINE
char* strncat(char* const dst __pass_object_size, const char* src, size_t n) __overloadable {
return __builtin___strncat_chk(dst, src, n, __bos(dst));
}
-#endif /* __ANDROID_API__ >= __ANDROID_API_J_MR1__ */
+#endif
/* No diag -- clang diagnoses misuses of this on its own. */
__BIONIC_FORTIFY_INLINE
void* memset(void* const s __pass_object_size0, int c, size_t n) __overloadable
/* If you're a user who wants this warning to go away: use `(&memset)(foo, bar, baz)`. */
__clang_warning_if(c && !n, "'memset' will set 0 bytes; maybe the arguments got flipped?") {
-#if __ANDROID_API__ >= __ANDROID_API_J_MR1__
+#if __ANDROID_API__ >= __ANDROID_API_J_MR1__ && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED
size_t bos = __bos0(s);
if (!__bos_trivially_ge(bos, n)) {
return __builtin___memset_chk(s, c, n, bos);
}
-#endif /* __ANDROID_API__ >= __ANDROID_API_J_MR1__ */
+#endif
return __builtin_memset(s, c, n);
}
-#if __ANDROID_API__ >= __ANDROID_API_M__
+#if __ANDROID_API__ >= __ANDROID_API_M__ && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED
__BIONIC_FORTIFY_INLINE
void* memchr(const void* const s __pass_object_size, int c, size_t n) __overloadable {
size_t bos = __bos(s);
@@ -163,9 +165,9 @@
return __memrchr_chk(s, c, n, bos);
}
-#endif /* __ANDROID_API__ >= __ANDROID_API_M__ */
+#endif
-#if __ANDROID_API__ >= __ANDROID_API_L__
+#if __ANDROID_API__ >= __ANDROID_API_L__ && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED
/* No diag -- clang diagnoses misuses of this on its own. */
__BIONIC_FORTIFY_INLINE
char* stpncpy(char* const dst __pass_object_size, const char* const src __pass_object_size, size_t n)
@@ -195,20 +197,20 @@
return __strncpy_chk2(dst, src, n, bos_dst, bos_src);
}
-#endif /* __ANDROID_API__ >= __ANDROID_API_L__ */
+#endif
__BIONIC_FORTIFY_INLINE
size_t strlcpy(char* const dst __pass_object_size, const char* src, size_t size)
__overloadable
__clang_error_if(__bos_unevaluated_lt(__bos(dst), size),
"'strlcpy' called with size bigger than buffer") {
-#if __ANDROID_API__ >= __ANDROID_API_J_MR1__
+#if __ANDROID_API__ >= __ANDROID_API_J_MR1__ && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED
size_t bos = __bos(dst);
if (bos != __BIONIC_FORTIFY_UNKNOWN_SIZE) {
return __strlcpy_chk(dst, src, size, bos);
}
-#endif /* __ANDROID_API__ >= __ANDROID_API_J_MR1__ */
+#endif
return __call_bypassing_fortify(strlcpy)(dst, src, size);
}
@@ -217,53 +219,53 @@
__overloadable
__clang_error_if(__bos_unevaluated_lt(__bos(dst), size),
"'strlcat' called with size bigger than buffer") {
-#if __ANDROID_API__ >= __ANDROID_API_J_MR1__
+#if __ANDROID_API__ >= __ANDROID_API_J_MR1__ && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED
size_t bos = __bos(dst);
if (bos != __BIONIC_FORTIFY_UNKNOWN_SIZE) {
return __strlcat_chk(dst, src, size, bos);
}
-#endif /* __ANDROID_API__ >= __ANDROID_API_J_MR1__ */
+#endif
return __call_bypassing_fortify(strlcat)(dst, src, size);
}
__BIONIC_FORTIFY_INLINE
size_t strlen(const char* const s __pass_object_size0) __overloadable {
+#if __ANDROID_API__ >= __ANDROID_API_J_MR1__ && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED
size_t bos = __bos0(s);
-#if __ANDROID_API__ >= __ANDROID_API_J_MR1__
if (!__bos_trivially_gt(bos, __builtin_strlen(s))) {
return __strlen_chk(s, bos);
}
-#endif /* __ANDROID_API__ >= __ANDROID_API_J_MR1__ */
+#endif
return __builtin_strlen(s);
}
__BIONIC_FORTIFY_INLINE
char* strchr(const char* const s __pass_object_size, int c) __overloadable {
-#if __ANDROID_API__ >= __ANDROID_API_J_MR2__
+#if __ANDROID_API__ >= __ANDROID_API_J_MR2__ && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED
size_t bos = __bos(s);
if (bos != __BIONIC_FORTIFY_UNKNOWN_SIZE) {
return __strchr_chk(s, c, bos);
}
-#endif /* __ANDROID_API__ >= __ANDROID_API_J_MR2__ */
+#endif
return __builtin_strchr(s, c);
}
__BIONIC_FORTIFY_INLINE
char* strrchr(const char* const s __pass_object_size, int c) __overloadable {
-#if __ANDROID_API__ >= __ANDROID_API_J_MR2__
+#if __ANDROID_API__ >= __ANDROID_API_J_MR2__ && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED
size_t bos = __bos(s);
if (bos != __BIONIC_FORTIFY_UNKNOWN_SIZE) {
return __strrchr_chk(s, c, bos);
}
-#endif /* __ANDROID_API__ >= __ANDROID_API_J_MR2__ */
+#endif
return __builtin_strrchr(s, c);
}
-#if __ANDROID_API__ >= __ANDROID_API_M__
+#if __ANDROID_API__ >= __ANDROID_API_M__ && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED
#if defined(__cplusplus)
extern "C++" {
__BIONIC_FORTIFY_INLINE
diff --git a/libc/include/bits/fortify/strings.h b/libc/include/bits/fortify/strings.h
index cc268db..1ebaf39 100644
--- a/libc/include/bits/fortify/strings.h
+++ b/libc/include/bits/fortify/strings.h
@@ -33,13 +33,13 @@
__overloadable
__clang_error_if(__bos_unevaluated_lt(__bos0(dst), len),
"'bcopy' called with size bigger than buffer") {
-#if __ANDROID_API__ >= __ANDROID_API_J_MR1__
+#if __ANDROID_API__ >= __ANDROID_API_J_MR1__ && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED
size_t bos = __bos0(dst);
if (!__bos_trivially_ge(bos, len)) {
__builtin___memmove_chk(dst, src, len, bos);
return;
}
-#endif /* __ANDROID_API__ >= __ANDROID_API_J_MR1__ */
+#endif
__builtin_memmove(dst, src, len);
}
@@ -48,13 +48,13 @@
__overloadable
__clang_error_if(__bos_unevaluated_lt(__bos0(b), len),
"'bzero' called with size bigger than buffer") {
-#if __ANDROID_API__ >= __ANDROID_API_J_MR1__
+#if __ANDROID_API__ >= __ANDROID_API_J_MR1__ && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED
size_t bos = __bos0(b);
if (!__bos_trivially_ge(bos, len)) {
__builtin___memset_chk(b, 0, len, bos);
return;
}
-#endif /* __ANDROID_API__ >= __ANDROID_API_J_MR1__ */
+#endif
__builtin_memset(b, 0, len);
}
diff --git a/libc/include/bits/fortify/unistd.h b/libc/include/bits/fortify/unistd.h
index 45ed2cf..f1580ce 100644
--- a/libc/include/bits/fortify/unistd.h
+++ b/libc/include/bits/fortify/unistd.h
@@ -73,13 +73,13 @@
char* getcwd(char* const __pass_object_size buf, size_t size)
__overloadable
__error_if_overflows_objectsize(size, __bos(buf), getcwd) {
-#if __ANDROID_API__ >= __ANDROID_API_N__
+#if __ANDROID_API__ >= __ANDROID_API_N__ && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED
size_t bos = __bos(buf);
if (!__bos_trivially_ge(bos, size)) {
return __getcwd_chk(buf, size, bos);
}
-#endif /* __ANDROID_API__ >= __ANDROID_API_N__ */
+#endif
return __call_bypassing_fortify(getcwd)(buf, size);
}
@@ -89,13 +89,13 @@
__overloadable
__error_if_overflows_ssizet(count, pread)
__error_if_overflows_objectsize(count, __bos0(buf), pread) {
-#if __ANDROID_API__ >= __ANDROID_API_M__
+#if __ANDROID_API__ >= __ANDROID_API_M__ && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED
size_t bos = __bos0(buf);
if (!__bos_trivially_ge_no_overflow(bos, count)) {
return __PREAD_PREFIX(chk)(fd, buf, count, offset, bos);
}
-#endif /* __ANDROID_API__ >= __ANDROID_API_M__ */
+#endif
return __PREAD_PREFIX(real)(fd, buf, count, offset);
}
#endif /* !defined(__USE_FILE_OFFSET64) */
@@ -105,13 +105,13 @@
__overloadable
__error_if_overflows_ssizet(count, pread64)
__error_if_overflows_objectsize(count, __bos0(buf), pread64) {
-#if __ANDROID_API__ >= __ANDROID_API_M__
+#if __ANDROID_API__ >= __ANDROID_API_M__ && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED
size_t bos = __bos0(buf);
if (!__bos_trivially_ge_no_overflow(bos, count)) {
return __pread64_chk(fd, buf, count, offset, bos);
}
-#endif /* __ANDROID_API__ >= __ANDROID_API_M__ */
+#endif
return __pread64_real(fd, buf, count, offset);
}
@@ -121,13 +121,13 @@
__overloadable
__error_if_overflows_ssizet(count, pwrite)
__error_if_overflows_objectsize(count, __bos0(buf), pwrite) {
-#if __ANDROID_API__ >= __ANDROID_API_N__
+#if __ANDROID_API__ >= __ANDROID_API_N__ && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED
size_t bos = __bos0(buf);
if (!__bos_trivially_ge_no_overflow(bos, count)) {
return __PWRITE_PREFIX(chk)(fd, buf, count, offset, bos);
}
-#endif /* __ANDROID_API__ >= __ANDROID_API_N__ */
+#endif
return __PWRITE_PREFIX(real)(fd, buf, count, offset);
}
#endif /* !defined(__USE_FILE_OFFSET64) */
@@ -137,13 +137,13 @@
__overloadable
__error_if_overflows_ssizet(count, pwrite64)
__error_if_overflows_objectsize(count, __bos0(buf), pwrite64) {
-#if __ANDROID_API__ >= __ANDROID_API_N__
+#if __ANDROID_API__ >= __ANDROID_API_N__ && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED
size_t bos = __bos0(buf);
if (!__bos_trivially_ge_no_overflow(bos, count)) {
return __pwrite64_chk(fd, buf, count, offset, bos);
}
-#endif /* __ANDROID_API__ >= __ANDROID_API_N__ */
+#endif
return __pwrite64_real(fd, buf, count, offset);
}
@@ -152,13 +152,13 @@
__overloadable
__error_if_overflows_ssizet(count, read)
__error_if_overflows_objectsize(count, __bos0(buf), read) {
-#if __ANDROID_API__ >= __ANDROID_API_L__
+#if __ANDROID_API__ >= __ANDROID_API_L__ && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED
size_t bos = __bos0(buf);
if (!__bos_trivially_ge_no_overflow(bos, count)) {
return __read_chk(fd, buf, count, bos);
}
-#endif /* __ANDROID_API__ >= __ANDROID_API_L__ */
+#endif
return __call_bypassing_fortify(read)(fd, buf, count);
}
@@ -167,13 +167,13 @@
__overloadable
__error_if_overflows_ssizet(count, write)
__error_if_overflows_objectsize(count, __bos0(buf), write) {
-#if __ANDROID_API__ >= __ANDROID_API_N__
+#if __ANDROID_API__ >= __ANDROID_API_N__ && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED
size_t bos = __bos0(buf);
if (!__bos_trivially_ge_no_overflow(bos, count)) {
return __write_chk(fd, buf, count, bos);
}
-#endif /* __ANDROID_API__ >= __ANDROID_API_N__ */
+#endif
return __call_bypassing_fortify(write)(fd, buf, count);
}
@@ -182,13 +182,13 @@
__overloadable
__error_if_overflows_ssizet(size, readlink)
__error_if_overflows_objectsize(size, __bos(buf), readlink) {
-#if __ANDROID_API__ >= __ANDROID_API_M__
+#if __ANDROID_API__ >= __ANDROID_API_M__ && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED
size_t bos = __bos(buf);
if (!__bos_trivially_ge_no_overflow(bos, size)) {
return __readlink_chk(path, buf, size, bos);
}
-#endif /* __ANDROID_API__ >= __ANDROID_API_M__ */
+#endif
return __call_bypassing_fortify(readlink)(path, buf, size);
}
@@ -198,13 +198,13 @@
__overloadable
__error_if_overflows_ssizet(size, readlinkat)
__error_if_overflows_objectsize(size, __bos(buf), readlinkat) {
-#if __ANDROID_API__ >= __ANDROID_API_M__
+#if __ANDROID_API__ >= __ANDROID_API_M__ && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED
size_t bos = __bos(buf);
if (!__bos_trivially_ge_no_overflow(bos, size)) {
return __readlinkat_chk(dirfd, path, buf, size, bos);
}
-#endif /* __ANDROID_API__ >= __ANDROID_API_M__ */
+#endif
return __call_bypassing_fortify(readlinkat)(dirfd, path, buf, size);
}
#endif /* __ANDROID_API__ >= __ANDROID_API_L__ */
diff --git a/libc/include/bits/sys_statvfs_inlines.h b/libc/include/bits/sys_statvfs_inlines.h
index fd4578c..991fac7 100644
--- a/libc/include/bits/sys_statvfs_inlines.h
+++ b/libc/include/bits/sys_statvfs_inlines.h
@@ -38,20 +38,20 @@
#if defined(__BIONIC_NEED_STATVFS_INLINES)
-static __inline void __bionic_statfs_to_statvfs(const struct statfs* __in,
- struct statvfs* __out) {
- __out->f_bsize = __in->f_bsize;
- __out->f_frsize = __in->f_frsize;
- __out->f_blocks = __in->f_blocks;
- __out->f_bfree = __in->f_bfree;
- __out->f_bavail = __in->f_bavail;
- __out->f_files = __in->f_files;
- __out->f_ffree = __in->f_ffree;
- __out->f_favail = __in->f_ffree;
- __out->f_fsid = __in->f_fsid.__val[0] |
- __BIONIC_CAST(static_cast, uint64_t, __in->f_fsid.__val[1]) << 32;
- __out->f_flag = __in->f_flags;
- __out->f_namemax = __in->f_namelen;
+static __inline void __bionic_statfs_to_statvfs(const struct statfs* __src,
+ struct statvfs* __dst) {
+ __dst->f_bsize = __src->f_bsize;
+ __dst->f_frsize = __src->f_frsize;
+ __dst->f_blocks = __src->f_blocks;
+ __dst->f_bfree = __src->f_bfree;
+ __dst->f_bavail = __src->f_bavail;
+ __dst->f_files = __src->f_files;
+ __dst->f_ffree = __src->f_ffree;
+ __dst->f_favail = __src->f_ffree;
+ __dst->f_fsid = __src->f_fsid.__val[0] |
+ __BIONIC_CAST(static_cast, uint64_t, __src->f_fsid.__val[1]) << 32;
+ __dst->f_flag = __src->f_flags;
+ __dst->f_namemax = __src->f_namelen;
}
__BIONIC_SYS_STATVFS_INLINE int statvfs(const char* __path,
diff --git a/libc/include/sys/cdefs.h b/libc/include/sys/cdefs.h
index 8078bda..eb30690 100644
--- a/libc/include/sys/cdefs.h
+++ b/libc/include/sys/cdefs.h
@@ -237,14 +237,15 @@
#define __BIONIC_FORTIFY_UNKNOWN_SIZE ((size_t) -1)
#if defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0
-/*
- * FORTIFY's _chk functions effectively disable ASAN's stdlib interceptors.
- * Additionally, the static analyzer/clang-tidy try to pattern match some
- * standard library functions, and FORTIFY sometimes interferes with this. So,
- * we turn FORTIFY off in both cases.
- */
-# if !__has_feature(address_sanitizer) && !defined(__clang_analyzer__)
+/* FORTIFY can interfere with pattern-matching of clang-tidy/the static analyzer. */
+# if !defined(__clang_analyzer__)
# define __BIONIC_FORTIFY 1
+/* ASAN has interceptors that FORTIFY's _chk functions can break. */
+# if __has_feature(address_sanitizer)
+# define __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED 0
+# else
+# define __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED 1
+# endif
# endif
#endif
diff --git a/libc/include/sys/prctl.h b/libc/include/sys/prctl.h
index bd42411..ff03c33 100644
--- a/libc/include/sys/prctl.h
+++ b/libc/include/sys/prctl.h
@@ -37,21 +37,6 @@
#include <linux/prctl.h>
-/**
- * Names a VMA (mmap'ed region). The second argument must be `PR_SET_VMA_ANON_NAME`,
- * the third and fourth are a `void*` pointer to the VMA and its `size_t` length in
- * bytes, and the final argument is a `const char*` pointer to the name.
- *
- * Note that the kernel keeps the pointer to the name rather than copying the name,
- * so the lifetime of the string should be at least as long as that of the VMA.
- */
-#define PR_SET_VMA 0x53564d41
-
-/**
- * For use with `PR_SET_VMA`.
- */
-#define PR_SET_VMA_ANON_NAME 0
-
__BEGIN_DECLS
/**
diff --git a/libc/kernel/README.md b/libc/kernel/README.md
index 9036b9f..6db08d6 100644
--- a/libc/kernel/README.md
+++ b/libc/kernel/README.md
@@ -53,14 +53,16 @@
NOT BREAK THE KERNEL <-> USER ABI, FOR EXAMPLE BY CHANGING THE SIZE
OF A GIVEN TYPE. THIS TASK CANNOT BE EASILY AUTOMATED AT THE MOMENT.
-Download the Linux kernel source code:
+Download the Android mainline kernel source code:
```
> mkdir kernel_src
> cd kernel_src
- kernel_src> git clone git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
+ kernel_src> git clone https://android.googlesource.com/kernel/common/ -b android-mainline
```
-Then checkout the stable tag for the new kernel headers to import:
+For now, there are no tags, take the top of tree version. To find the
+version of the linux stable kernel headers the mainline source code is
+tracking, read the uapi/linux/version.h that is generated.
```
kernel_src> cd linux-stable
kernel_src/linux-stable> git checkout tags/vXXX
@@ -71,11 +73,17 @@
to determine which directory to use as the destination directory.
After running lunch, run this command to import the headers into the android
-source tree:
+source tree if there is a kernel source tree already checked out:
```
bionic/libc/kernel/tools/generate_uapi_headers.sh --use-kernel-dir kernel_src
```
+Run this command to automatically download the latest version of the headers
+and import them if there is no checked out kernel source tree:
+```
+ bionic/libc/kernel/tools/generate_uapi_headers.sh --download-kernel
+```
+
Next, run this command to copy the parsed files to bionic/libc/kernel/uapi:
```
bionic/libc/kernel/tools/update_all.py
diff --git a/libc/kernel/android/uapi/linux/netfilter_ipv4/ipt_ULOG.h b/libc/kernel/android/uapi/linux/netfilter_ipv4/ipt_ULOG.h
deleted file mode 100644
index ee6a557..0000000
--- a/libc/kernel/android/uapi/linux/netfilter_ipv4/ipt_ULOG.h
+++ /dev/null
@@ -1,55 +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 _IPT_ULOG_H
-#define _IPT_ULOG_H
-#ifndef NETLINK_NFLOG
-#define NETLINK_NFLOG 5
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#endif
-#define ULOG_DEFAULT_NLGROUP 1
-#define ULOG_DEFAULT_QTHRESHOLD 1
-#define ULOG_MAC_LEN 80
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ULOG_PREFIX_LEN 32
-#define ULOG_MAX_QLEN 50
-struct ipt_ulog_info {
- unsigned int nl_group;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- size_t copy_range;
- size_t qthreshold;
- char prefix[ULOG_PREFIX_LEN];
-};
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-typedef struct ulog_packet_msg {
- unsigned long mark;
- long timestamp_sec;
- long timestamp_usec;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- unsigned int hook;
- char indev_name[IFNAMSIZ];
- char outdev_name[IFNAMSIZ];
- size_t data_len;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- char prefix[ULOG_PREFIX_LEN];
- unsigned char mac_len;
- unsigned char mac[ULOG_MAC_LEN];
- unsigned char payload[0];
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-} ulog_packet_msg_t;
-#endif
diff --git a/libc/kernel/android/uapi/linux/usb/f_mtp.h b/libc/kernel/android/uapi/linux/usb/f_mtp.h
deleted file mode 100644
index 22ec771..0000000
--- a/libc/kernel/android/uapi/linux/usb/f_mtp.h
+++ /dev/null
@@ -1,43 +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_USB_F_MTP_H
-#define _UAPI_LINUX_USB_F_MTP_H
-#include <linux/ioctl.h>
-#include <linux/types.h>
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-struct mtp_file_range {
- int fd;
- loff_t offset;
- int64_t length;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- uint16_t command;
- uint32_t transaction_id;
-};
-struct mtp_event {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- size_t length;
- void * data;
-};
-#define MTP_SEND_FILE _IOW('M', 0, struct mtp_file_range)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MTP_RECEIVE_FILE _IOW('M', 1, struct mtp_file_range)
-#define MTP_SEND_EVENT _IOW('M', 3, struct mtp_event)
-#define MTP_SEND_FILE_WITH_HEADER _IOW('M', 4, struct mtp_file_range)
-#endif
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/tools/generate_uapi_headers.sh b/libc/kernel/tools/generate_uapi_headers.sh
index 5bf1cf3..61c78ce 100755
--- a/libc/kernel/tools/generate_uapi_headers.sh
+++ b/libc/kernel/tools/generate_uapi_headers.sh
@@ -24,9 +24,9 @@
### Options:
### --skip-generation
### Skip the step that generates all of the include files.
-### --download-kernel <VERSION>
+### --download-kernel
### Automatically create a temporary git repository and check out the
-### linux kernel source code for the given version.
+### linux kernel source code at TOT.
### --use-kernel-dir <DIR>
### Do not check out the kernel source, use the kernel directory
### pointed to by <DIR>.
@@ -39,8 +39,8 @@
TMPDIR=""
ANDROID_DIR=""
-KERNEL_VERSION=""
-KERNEL_REPO="git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git"
+ANDROID_KERNEL_REPO="https://android.googlesource.com/kernel/common/"
+ANDROID_KERNEL_BRANCH="android-mainline"
KERNEL_DIR=""
KERNEL_DOWNLOAD=0
ARCH_LIST=("arm" "arm64" "mips" "x86")
@@ -143,12 +143,6 @@
SKIP_GENERATION=1
;;
"--download-kernel")
- if [[ $# -lt 2 ]]; then
- echo "--download-kernel requires an argument."
- exit 1
- fi
- shift
- KERNEL_VERSION="$1"
KERNEL_DOWNLOAD=1
;;
"--use-kernel-dir")
@@ -198,31 +192,28 @@
exit 1
fi
-src_dir="linux-stable"
-
if [[ ${KERNEL_DOWNLOAD} -eq 1 ]]; then
TMPDIR=$(mktemp -d /tmp/android_kernelXXXXXXXX)
cd "${TMPDIR}"
- echo "Fetching linux kernel source ${KERNEL_VERSION}"
- git clone ${KERNEL_REPO}
- cd ${src_dir}
- git checkout tags/"${KERNEL_VERSION}"
- KERNEL_DIR="${TMPDIR}"
+ echo "Fetching android linux kernel source..."
+ git clone ${ANDROID_KERNEL_REPO} -b ${ANDROID_KERNEL_BRANCH} --depth=1
+ cd common
+ KERNEL_DIR="${TMPDIR}/common"
elif [[ "${KERNEL_DIR}" == "" ]]; then
echo "Must specify one of --use-kernel-dir or --download-kernel."
exit 1
-elif [[ ! -d "${KERNEL_DIR}" ]] || [[ ! -d "${KERNEL_DIR}/${src_dir}" ]]; then
- echo "The kernel directory $KERNEL_DIR or $KERNEL_DIR/${src_dir} does not exist."
+elif [[ ! -d "${KERNEL_DIR}" ]] || [[ ! -d "${KERNEL_DIR}/kernel" ]]; then
+ echo "The kernel directory $KERNEL_DIR or $KERNEL_DIR/kernel does not exist."
exit 1
else
- cd "${KERNEL_DIR}/${src_dir}"
+ cd "${KERNEL_DIR}"
fi
if [[ ${VERIFY_HEADERS_ONLY} -eq 1 ]]; then
# Verify if modified headers have changed.
- verify_modified_hdrs "${KERNEL_DIR}/${src_dir}/include/scsi" \
+ verify_modified_hdrs "${KERNEL_DIR}/include/scsi" \
"${ANDROID_KERNEL_DIR}/scsi" \
- "${KERNEL_DIR}/${src_dir}"
+ "${KERNEL_DIR}"
exit 0
fi
@@ -245,41 +236,41 @@
cd ${ANDROID_BUILD_TOP}
# Copy all of the include/uapi files to the kernel headers uapi directory.
-copy_hdrs "${KERNEL_DIR}/${src_dir}/include/uapi" "${ANDROID_KERNEL_DIR}/uapi"
+copy_hdrs "${KERNEL_DIR}/include/uapi" "${ANDROID_KERNEL_DIR}/uapi"
# Copy the staging files to uapi/linux.
-copy_hdrs "${KERNEL_DIR}/${src_dir}/drivers/staging/android/uapi" \
+copy_hdrs "${KERNEL_DIR}/drivers/staging/android/uapi" \
"${ANDROID_KERNEL_DIR}/uapi/linux" "no-copy-dirs"
# Remove ion.h, it's not fully supported by the upstream kernel (see b/77976082).
rm -f "${ANDROID_KERNEL_DIR}/uapi/linux/ion.h"
# Copy the generated headers.
-copy_hdrs "${KERNEL_DIR}/${src_dir}/include/generated/uapi" \
+copy_hdrs "${KERNEL_DIR}/include/generated/uapi" \
"${ANDROID_KERNEL_DIR}/uapi"
for arch in "${ARCH_LIST[@]}"; do
# Copy arch headers.
- copy_hdrs "${KERNEL_DIR}/${src_dir}/arch/${arch}/include/uapi" \
+ copy_hdrs "${KERNEL_DIR}/arch/${arch}/include/uapi" \
"${ANDROID_KERNEL_DIR}/uapi/asm-${arch}"
# Copy the generated arch headers.
- copy_hdrs "${KERNEL_DIR}/${src_dir}/arch/${arch}/include/generated/uapi" \
+ copy_hdrs "${KERNEL_DIR}/arch/${arch}/include/generated/uapi" \
"${ANDROID_KERNEL_DIR}/uapi/asm-${arch}"
# Special copy of generated header files from arch/<ARCH>/generated/asm that
# also exist in uapi/asm-generic.
- copy_if_exists "${KERNEL_DIR}/${src_dir}/include/uapi/asm-generic" \
- "${KERNEL_DIR}/${src_dir}/arch/${arch}/include/generated/asm" \
+ copy_if_exists "${KERNEL_DIR}/include/uapi/asm-generic" \
+ "${KERNEL_DIR}/arch/${arch}/include/generated/asm" \
"${ANDROID_KERNEL_DIR}/uapi/asm-${arch}/asm"
done
# The arm types.h uapi header is not properly being generated, so copy it
# directly.
-cp "${KERNEL_DIR}/${src_dir}/include/uapi/asm-generic/types.h" \
+cp "${KERNEL_DIR}/include/uapi/asm-generic/types.h" \
"${ANDROID_KERNEL_DIR}/uapi/asm-arm/asm"
# Verify if modified headers have changed.
-verify_modified_hdrs "${KERNEL_DIR}/${src_dir}/include/scsi" \
+verify_modified_hdrs "${KERNEL_DIR}/include/scsi" \
"${ANDROID_KERNEL_DIR}/scsi" \
- "${KERNEL_DIR}/${src_dir}"
+ "${KERNEL_DIR}"
echo "Headers updated."
diff --git a/libc/kernel/uapi/asm-arm/asm/kvm.h b/libc/kernel/uapi/asm-arm/asm/kvm.h
index 72bcb03..6fdb46c 100644
--- a/libc/kernel/uapi/asm-arm/asm/kvm.h
+++ b/libc/kernel/uapi/asm-arm/asm/kvm.h
@@ -187,8 +187,10 @@
#define KVM_DEV_ARM_ITS_RESTORE_TABLES 2
#define KVM_DEV_ARM_VGIC_SAVE_PENDING_TABLES 3
#define KVM_DEV_ARM_ITS_CTRL_RESET 4
+#define KVM_ARM_IRQ_VCPU2_SHIFT 28
+#define KVM_ARM_IRQ_VCPU2_MASK 0xf
#define KVM_ARM_IRQ_TYPE_SHIFT 24
-#define KVM_ARM_IRQ_TYPE_MASK 0xff
+#define KVM_ARM_IRQ_TYPE_MASK 0xf
#define KVM_ARM_IRQ_VCPU_SHIFT 16
#define KVM_ARM_IRQ_VCPU_MASK 0xff
#define KVM_ARM_IRQ_NUM_SHIFT 0
diff --git a/libc/kernel/uapi/asm-arm64/asm/kvm.h b/libc/kernel/uapi/asm-arm64/asm/kvm.h
index e345744..1c7ee65 100644
--- a/libc/kernel/uapi/asm-arm64/asm/kvm.h
+++ b/libc/kernel/uapi/asm-arm64/asm/kvm.h
@@ -196,8 +196,10 @@
#define KVM_ARM_VCPU_TIMER_CTRL 1
#define KVM_ARM_VCPU_TIMER_IRQ_VTIMER 0
#define KVM_ARM_VCPU_TIMER_IRQ_PTIMER 1
+#define KVM_ARM_IRQ_VCPU2_SHIFT 28
+#define KVM_ARM_IRQ_VCPU2_MASK 0xf
#define KVM_ARM_IRQ_TYPE_SHIFT 24
-#define KVM_ARM_IRQ_TYPE_MASK 0xff
+#define KVM_ARM_IRQ_TYPE_MASK 0xf
#define KVM_ARM_IRQ_VCPU_SHIFT 16
#define KVM_ARM_IRQ_VCPU_MASK 0xff
#define KVM_ARM_IRQ_NUM_SHIFT 0
diff --git a/libc/kernel/uapi/asm-generic/mman-common.h b/libc/kernel/uapi/asm-generic/mman-common.h
index 21d0356..a088ce5 100644
--- a/libc/kernel/uapi/asm-generic/mman-common.h
+++ b/libc/kernel/uapi/asm-generic/mman-common.h
@@ -58,6 +58,8 @@
#define MADV_DODUMP 17
#define MADV_WIPEONFORK 18
#define MADV_KEEPONFORK 19
+#define MADV_COLD 20
+#define MADV_PAGEOUT 21
#define MAP_FILE 0
#define PKEY_DISABLE_ACCESS 0x1
#define PKEY_DISABLE_WRITE 0x2
diff --git a/libc/kernel/uapi/asm-mips/asm/hwcap.h b/libc/kernel/uapi/asm-mips/asm/hwcap.h
index 6151555..702b6f6 100644
--- a/libc/kernel/uapi/asm-mips/asm/hwcap.h
+++ b/libc/kernel/uapi/asm-mips/asm/hwcap.h
@@ -21,4 +21,15 @@
#define HWCAP_MIPS_R6 (1 << 0)
#define HWCAP_MIPS_MSA (1 << 1)
#define HWCAP_MIPS_CRC32 (1 << 2)
+#define HWCAP_MIPS_MIPS16 (1 << 3)
+#define HWCAP_MIPS_MDMX (1 << 4)
+#define HWCAP_MIPS_MIPS3D (1 << 5)
+#define HWCAP_MIPS_SMARTMIPS (1 << 6)
+#define HWCAP_MIPS_DSP (1 << 7)
+#define HWCAP_MIPS_DSP2 (1 << 8)
+#define HWCAP_MIPS_DSP3 (1 << 9)
+#define HWCAP_MIPS_MIPS16E2 (1 << 10)
+#define HWCAP_LOONGSON_MMI (1 << 11)
+#define HWCAP_LOONGSON_EXT (1 << 12)
+#define HWCAP_LOONGSON_EXT2 (1 << 13)
#endif
diff --git a/libc/kernel/uapi/asm-mips/asm/mman.h b/libc/kernel/uapi/asm-mips/asm/mman.h
index 8664a81..86df482 100644
--- a/libc/kernel/uapi/asm-mips/asm/mman.h
+++ b/libc/kernel/uapi/asm-mips/asm/mman.h
@@ -67,6 +67,8 @@
#define MADV_DODUMP 17
#define MADV_WIPEONFORK 18
#define MADV_KEEPONFORK 19
+#define MADV_COLD 20
+#define MADV_PAGEOUT 21
#define MAP_FILE 0
#define PKEY_DISABLE_ACCESS 0x1
#define PKEY_DISABLE_WRITE 0x2
diff --git a/libc/kernel/uapi/asm-mips/asm/unistd_n32.h b/libc/kernel/uapi/asm-mips/asm/unistd_n32.h
index 285b1f0..974fb54 100644
--- a/libc/kernel/uapi/asm-mips/asm/unistd_n32.h
+++ b/libc/kernel/uapi/asm-mips/asm/unistd_n32.h
@@ -381,4 +381,5 @@
#define __NR_fsmount (__NR_Linux + 432)
#define __NR_fspick (__NR_Linux + 433)
#define __NR_pidfd_open (__NR_Linux + 434)
+#define __NR_clone3 (__NR_Linux + 435)
#endif
diff --git a/libc/kernel/uapi/asm-mips/asm/unistd_n64.h b/libc/kernel/uapi/asm-mips/asm/unistd_n64.h
index 9b2650f..e71caf2 100644
--- a/libc/kernel/uapi/asm-mips/asm/unistd_n64.h
+++ b/libc/kernel/uapi/asm-mips/asm/unistd_n64.h
@@ -357,4 +357,5 @@
#define __NR_fsmount (__NR_Linux + 432)
#define __NR_fspick (__NR_Linux + 433)
#define __NR_pidfd_open (__NR_Linux + 434)
+#define __NR_clone3 (__NR_Linux + 435)
#endif
diff --git a/libc/kernel/uapi/asm-mips/asm/unistd_nr_n32.h b/libc/kernel/uapi/asm-mips/asm/unistd_nr_n32.h
index a335768..4a98139 100644
--- a/libc/kernel/uapi/asm-mips/asm/unistd_nr_n32.h
+++ b/libc/kernel/uapi/asm-mips/asm/unistd_nr_n32.h
@@ -19,5 +19,5 @@
#ifndef _UAPI_ASM_MIPS_UNISTD_NR_N32_H
#define _UAPI_ASM_MIPS_UNISTD_NR_N32_H
#define __NR_N32_Linux 6000
-#define __NR_N32_Linux_syscalls 435
+#define __NR_N32_Linux_syscalls 436
#endif
diff --git a/libc/kernel/uapi/asm-mips/asm/unistd_nr_n64.h b/libc/kernel/uapi/asm-mips/asm/unistd_nr_n64.h
index c4812a5..f5b5982 100644
--- a/libc/kernel/uapi/asm-mips/asm/unistd_nr_n64.h
+++ b/libc/kernel/uapi/asm-mips/asm/unistd_nr_n64.h
@@ -19,5 +19,5 @@
#ifndef _UAPI_ASM_MIPS_UNISTD_NR_N64_H
#define _UAPI_ASM_MIPS_UNISTD_NR_N64_H
#define __NR_64_Linux 5000
-#define __NR_64_Linux_syscalls 435
+#define __NR_64_Linux_syscalls 436
#endif
diff --git a/libc/kernel/uapi/asm-mips/asm/unistd_nr_o32.h b/libc/kernel/uapi/asm-mips/asm/unistd_nr_o32.h
index 041051a..72a6c59 100644
--- a/libc/kernel/uapi/asm-mips/asm/unistd_nr_o32.h
+++ b/libc/kernel/uapi/asm-mips/asm/unistd_nr_o32.h
@@ -19,5 +19,5 @@
#ifndef _UAPI_ASM_MIPS_UNISTD_NR_O32_H
#define _UAPI_ASM_MIPS_UNISTD_NR_O32_H
#define __NR_O32_Linux 4000
-#define __NR_O32_Linux_syscalls 435
+#define __NR_O32_Linux_syscalls 436
#endif
diff --git a/libc/kernel/uapi/asm-mips/asm/unistd_o32.h b/libc/kernel/uapi/asm-mips/asm/unistd_o32.h
index acbfa6b..0ed3ba2 100644
--- a/libc/kernel/uapi/asm-mips/asm/unistd_o32.h
+++ b/libc/kernel/uapi/asm-mips/asm/unistd_o32.h
@@ -427,4 +427,5 @@
#define __NR_fsmount (__NR_Linux + 432)
#define __NR_fspick (__NR_Linux + 433)
#define __NR_pidfd_open (__NR_Linux + 434)
+#define __NR_clone3 (__NR_Linux + 435)
#endif
diff --git a/libc/kernel/uapi/asm-x86/asm/svm.h b/libc/kernel/uapi/asm-x86/asm/svm.h
index 76fb985..4929c13 100644
--- a/libc/kernel/uapi/asm-x86/asm/svm.h
+++ b/libc/kernel/uapi/asm-x86/asm/svm.h
@@ -91,6 +91,7 @@
#define SVM_EXIT_MWAIT 0x08b
#define SVM_EXIT_MWAIT_COND 0x08c
#define SVM_EXIT_XSETBV 0x08d
+#define SVM_EXIT_RDPRU 0x08e
#define SVM_EXIT_NPF 0x400
#define SVM_EXIT_AVIC_INCOMPLETE_IPI 0x401
#define SVM_EXIT_AVIC_UNACCELERATED_ACCESS 0x402
diff --git a/libc/kernel/uapi/asm-x86/asm/types.h b/libc/kernel/uapi/asm-x86/asm/types.h
index 5126b84..8250f43 100644
--- a/libc/kernel/uapi/asm-x86/asm/types.h
+++ b/libc/kernel/uapi/asm-x86/asm/types.h
@@ -16,7 +16,4 @@
***
****************************************************************************
****************************************************************************/
-#ifndef _ASM_X86_TYPES_H
-#define _ASM_X86_TYPES_H
#include <asm-generic/types.h>
-#endif
diff --git a/libc/kernel/uapi/asm-x86/asm/unistd.h b/libc/kernel/uapi/asm-x86/asm/unistd.h
index 8cab383..4bb90cf 100644
--- a/libc/kernel/uapi/asm-x86/asm/unistd.h
+++ b/libc/kernel/uapi/asm-x86/asm/unistd.h
@@ -18,7 +18,7 @@
****************************************************************************/
#ifndef _UAPI_ASM_X86_UNISTD_H
#define _UAPI_ASM_X86_UNISTD_H
-#define __X32_SYSCALL_BIT 0x40000000
+#define __X32_SYSCALL_BIT 0x40000000UL
#ifdef __i386__
#include <asm/unistd_32.h>
#elif defined(__ILP32__)
diff --git a/libc/kernel/uapi/asm-x86/asm/vmx.h b/libc/kernel/uapi/asm-x86/asm/vmx.h
index 83365f8..e218d0d 100644
--- a/libc/kernel/uapi/asm-x86/asm/vmx.h
+++ b/libc/kernel/uapi/asm-x86/asm/vmx.h
@@ -22,6 +22,7 @@
#define EXIT_REASON_EXCEPTION_NMI 0
#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_NMI_WINDOW 8
#define EXIT_REASON_TASK_SWITCH 9
@@ -75,7 +76,9 @@
#define EXIT_REASON_PML_FULL 62
#define EXIT_REASON_XSAVES 63
#define EXIT_REASON_XRSTORS 64
-#define VMX_EXIT_REASONS { EXIT_REASON_EXCEPTION_NMI, "EXCEPTION_NMI" }, { EXIT_REASON_EXTERNAL_INTERRUPT, "EXTERNAL_INTERRUPT" }, { EXIT_REASON_TRIPLE_FAULT, "TRIPLE_FAULT" }, { 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" }
+#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_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 dda9ced..1d95379 100644
--- a/libc/kernel/uapi/drm/amdgpu_drm.h
+++ b/libc/kernel/uapi/drm/amdgpu_drm.h
@@ -70,6 +70,7 @@
#define AMDGPU_GEM_CREATE_VM_ALWAYS_VALID (1 << 6)
#define AMDGPU_GEM_CREATE_EXPLICIT_SYNC (1 << 7)
#define AMDGPU_GEM_CREATE_MQD_GFX9 (1 << 8)
+#define AMDGPU_GEM_CREATE_VRAM_WIPE_ON_RELEASE (1 << 9)
struct drm_amdgpu_gem_create_in {
__u64 bo_size;
__u64 alignment;
@@ -596,6 +597,7 @@
__u64 high_va_offset;
__u64 high_va_max;
__u32 pa_sc_tile_steering_override;
+ __u64 tcc_disabled_mask;
};
struct drm_amdgpu_info_hw_ip {
__u32 hw_ip_version_major;
diff --git a/libc/kernel/uapi/drm/drm_fourcc.h b/libc/kernel/uapi/drm/drm_fourcc.h
index 593d87c..dec9cfa 100644
--- a/libc/kernel/uapi/drm/drm_fourcc.h
+++ b/libc/kernel/uapi/drm/drm_fourcc.h
@@ -148,6 +148,9 @@
#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)
+#define DRM_FORMAT_MOD_QCOM_DX fourcc_mod_code(QCOM, 0x2)
+#define DRM_FORMAT_MOD_QCOM_TIGHT fourcc_mod_code(QCOM, 0x4)
+#define DRM_FORMAT_MOD_QCOM_TILE fourcc_mod_code(QCOM, 0x8)
#define DRM_FORMAT_MOD_VIVANTE_TILED fourcc_mod_code(VIVANTE, 1)
#define DRM_FORMAT_MOD_VIVANTE_SUPER_TILED fourcc_mod_code(VIVANTE, 2)
#define DRM_FORMAT_MOD_VIVANTE_SPLIT_TILED fourcc_mod_code(VIVANTE, 3)
diff --git a/libc/kernel/uapi/drm/drm_mode.h b/libc/kernel/uapi/drm/drm_mode.h
index 403c787..be5cbad 100644
--- a/libc/kernel/uapi/drm/drm_mode.h
+++ b/libc/kernel/uapi/drm/drm_mode.h
@@ -73,7 +73,12 @@
#define DRM_MODE_FLAG_PIC_AR_16_9 (DRM_MODE_PICTURE_ASPECT_16_9 << 19)
#define DRM_MODE_FLAG_PIC_AR_64_27 (DRM_MODE_PICTURE_ASPECT_64_27 << 19)
#define DRM_MODE_FLAG_PIC_AR_256_135 (DRM_MODE_PICTURE_ASPECT_256_135 << 19)
-#define DRM_MODE_FLAG_ALL (DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC | DRM_MODE_FLAG_NVSYNC | DRM_MODE_FLAG_INTERLACE | DRM_MODE_FLAG_DBLSCAN | DRM_MODE_FLAG_CSYNC | DRM_MODE_FLAG_PCSYNC | DRM_MODE_FLAG_NCSYNC | DRM_MODE_FLAG_HSKEW | DRM_MODE_FLAG_DBLCLK | DRM_MODE_FLAG_CLKDIV2 | DRM_MODE_FLAG_3D_MASK)
+#define DRM_MODE_FLAG_SUPPORTS_RGB (1 << 27)
+#define DRM_MODE_FLAG_SUPPORTS_YUV (1 << 28)
+#define DRM_MODE_FLAG_VID_MODE_PANEL (1 << 29)
+#define DRM_MODE_FLAG_CMD_MODE_PANEL (1 << 30)
+#define DRM_MODE_FLAG_SEAMLESS (1 << 31)
+#define DRM_MODE_FLAG_ALL (DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC | DRM_MODE_FLAG_NVSYNC | DRM_MODE_FLAG_INTERLACE | DRM_MODE_FLAG_DBLSCAN | DRM_MODE_FLAG_CSYNC | DRM_MODE_FLAG_PCSYNC | DRM_MODE_FLAG_NCSYNC | DRM_MODE_FLAG_HSKEW | DRM_MODE_FLAG_DBLCLK | DRM_MODE_FLAG_CLKDIV2 | DRM_MODE_FLAG_SUPPORTS_RGB | DRM_MODE_FLAG_SUPPORTS_YUV | DRM_MODE_FLAG_VID_MODE_PANEL | DRM_MODE_FLAG_CMD_MODE_PANEL | DRM_MODE_FLAG_3D_MASK)
#define DRM_MODE_DPMS_ON 0
#define DRM_MODE_DPMS_STANDBY 1
#define DRM_MODE_DPMS_SUSPEND 2
@@ -217,6 +222,7 @@
#define DRM_MODE_CONNECTOR_DSI 16
#define DRM_MODE_CONNECTOR_DPI 17
#define DRM_MODE_CONNECTOR_WRITEBACK 18
+#define DRM_MODE_CONNECTOR_SPI 19
struct drm_mode_get_connector {
__u64 encoders_ptr;
__u64 modes_ptr;
@@ -303,6 +309,7 @@
};
#define DRM_MODE_FB_INTERLACED (1 << 0)
#define DRM_MODE_FB_MODIFIERS (1 << 1)
+#define DRM_MODE_FB_SECURE (1 << 2)
struct drm_mode_fb_cmd2 {
__u32 fb_id;
__u32 width;
diff --git a/libc/kernel/uapi/drm/etnaviv_drm.h b/libc/kernel/uapi/drm/etnaviv_drm.h
index 4c09e6c..c92d110 100644
--- a/libc/kernel/uapi/drm/etnaviv_drm.h
+++ b/libc/kernel/uapi/drm/etnaviv_drm.h
@@ -52,6 +52,7 @@
#define ETNAVIV_PARAM_GPU_INSTRUCTION_COUNT 0x18
#define ETNAVIV_PARAM_GPU_NUM_CONSTANTS 0x19
#define ETNAVIV_PARAM_GPU_NUM_VARYINGS 0x1a
+#define ETNAVIV_PARAM_SOFTPIN_START_ADDR 0x1b
#define ETNA_MAX_PIPES 4
struct drm_etnaviv_param {
__u32 pipe;
@@ -112,7 +113,8 @@
#define ETNA_SUBMIT_NO_IMPLICIT 0x0001
#define ETNA_SUBMIT_FENCE_FD_IN 0x0002
#define ETNA_SUBMIT_FENCE_FD_OUT 0x0004
-#define ETNA_SUBMIT_FLAGS (ETNA_SUBMIT_NO_IMPLICIT | ETNA_SUBMIT_FENCE_FD_IN | ETNA_SUBMIT_FENCE_FD_OUT)
+#define ETNA_SUBMIT_SOFTPIN 0x0008
+#define ETNA_SUBMIT_FLAGS (ETNA_SUBMIT_NO_IMPLICIT | ETNA_SUBMIT_FENCE_FD_IN | ETNA_SUBMIT_FENCE_FD_OUT | ETNA_SUBMIT_SOFTPIN)
#define ETNA_PIPE_3D 0x00
#define ETNA_PIPE_2D 0x01
#define ETNA_PIPE_VG 0x02
diff --git a/libc/kernel/uapi/drm/i915_drm.h b/libc/kernel/uapi/drm/i915_drm.h
index 8965f01..09480c3 100644
--- a/libc/kernel/uapi/drm/i915_drm.h
+++ b/libc/kernel/uapi/drm/i915_drm.h
@@ -346,6 +346,7 @@
#define I915_SCHEDULER_CAP_PRIORITY (1ul << 1)
#define I915_SCHEDULER_CAP_PREEMPTION (1ul << 2)
#define I915_SCHEDULER_CAP_SEMAPHORES (1ul << 3)
+#define I915_SCHEDULER_CAP_ENGINE_BUSY_STATS (1ul << 4)
#define I915_PARAM_HUC_STATUS 42
#define I915_PARAM_HAS_EXEC_ASYNC 43
#define I915_PARAM_HAS_EXEC_FENCE 44
diff --git a/libc/kernel/uapi/drm/panfrost_drm.h b/libc/kernel/uapi/drm/panfrost_drm.h
index 4da1447..f8b8aa1 100644
--- a/libc/kernel/uapi/drm/panfrost_drm.h
+++ b/libc/kernel/uapi/drm/panfrost_drm.h
@@ -30,12 +30,14 @@
#define DRM_PANFROST_GET_BO_OFFSET 0x05
#define DRM_PANFROST_PERFCNT_ENABLE 0x06
#define DRM_PANFROST_PERFCNT_DUMP 0x07
+#define DRM_PANFROST_MADVISE 0x08
#define DRM_IOCTL_PANFROST_SUBMIT DRM_IOW(DRM_COMMAND_BASE + DRM_PANFROST_SUBMIT, struct drm_panfrost_submit)
#define DRM_IOCTL_PANFROST_WAIT_BO DRM_IOW(DRM_COMMAND_BASE + DRM_PANFROST_WAIT_BO, struct drm_panfrost_wait_bo)
#define DRM_IOCTL_PANFROST_CREATE_BO DRM_IOWR(DRM_COMMAND_BASE + DRM_PANFROST_CREATE_BO, struct drm_panfrost_create_bo)
#define DRM_IOCTL_PANFROST_MMAP_BO DRM_IOWR(DRM_COMMAND_BASE + DRM_PANFROST_MMAP_BO, struct drm_panfrost_mmap_bo)
#define DRM_IOCTL_PANFROST_GET_PARAM DRM_IOWR(DRM_COMMAND_BASE + DRM_PANFROST_GET_PARAM, struct drm_panfrost_get_param)
#define DRM_IOCTL_PANFROST_GET_BO_OFFSET DRM_IOWR(DRM_COMMAND_BASE + DRM_PANFROST_GET_BO_OFFSET, struct drm_panfrost_get_bo_offset)
+#define DRM_IOCTL_PANFROST_MADVISE DRM_IOWR(DRM_COMMAND_BASE + DRM_PANFROST_MADVISE, struct drm_panfrost_madvise)
#define DRM_IOCTL_PANFROST_PERFCNT_ENABLE DRM_IOW(DRM_COMMAND_BASE + DRM_PANFROST_PERFCNT_ENABLE, struct drm_panfrost_perfcnt_enable)
#define DRM_IOCTL_PANFROST_PERFCNT_DUMP DRM_IOW(DRM_COMMAND_BASE + DRM_PANFROST_PERFCNT_DUMP, struct drm_panfrost_perfcnt_dump)
#define PANFROST_JD_REQ_FS (1 << 0)
@@ -53,6 +55,8 @@
__u32 pad;
__s64 timeout_ns;
};
+#define PANFROST_BO_NOEXEC 1
+#define PANFROST_BO_HEAP 2
struct drm_panfrost_create_bo {
__u32 size;
__u32 flags;
@@ -67,6 +71,45 @@
};
enum drm_panfrost_param {
DRM_PANFROST_PARAM_GPU_PROD_ID,
+ DRM_PANFROST_PARAM_GPU_REVISION,
+ DRM_PANFROST_PARAM_SHADER_PRESENT,
+ DRM_PANFROST_PARAM_TILER_PRESENT,
+ DRM_PANFROST_PARAM_L2_PRESENT,
+ DRM_PANFROST_PARAM_STACK_PRESENT,
+ DRM_PANFROST_PARAM_AS_PRESENT,
+ DRM_PANFROST_PARAM_JS_PRESENT,
+ DRM_PANFROST_PARAM_L2_FEATURES,
+ DRM_PANFROST_PARAM_CORE_FEATURES,
+ DRM_PANFROST_PARAM_TILER_FEATURES,
+ DRM_PANFROST_PARAM_MEM_FEATURES,
+ DRM_PANFROST_PARAM_MMU_FEATURES,
+ DRM_PANFROST_PARAM_THREAD_FEATURES,
+ DRM_PANFROST_PARAM_MAX_THREADS,
+ DRM_PANFROST_PARAM_THREAD_MAX_WORKGROUP_SZ,
+ DRM_PANFROST_PARAM_THREAD_MAX_BARRIER_SZ,
+ DRM_PANFROST_PARAM_COHERENCY_FEATURES,
+ DRM_PANFROST_PARAM_TEXTURE_FEATURES0,
+ DRM_PANFROST_PARAM_TEXTURE_FEATURES1,
+ DRM_PANFROST_PARAM_TEXTURE_FEATURES2,
+ DRM_PANFROST_PARAM_TEXTURE_FEATURES3,
+ DRM_PANFROST_PARAM_JS_FEATURES0,
+ DRM_PANFROST_PARAM_JS_FEATURES1,
+ DRM_PANFROST_PARAM_JS_FEATURES2,
+ DRM_PANFROST_PARAM_JS_FEATURES3,
+ DRM_PANFROST_PARAM_JS_FEATURES4,
+ DRM_PANFROST_PARAM_JS_FEATURES5,
+ DRM_PANFROST_PARAM_JS_FEATURES6,
+ DRM_PANFROST_PARAM_JS_FEATURES7,
+ DRM_PANFROST_PARAM_JS_FEATURES8,
+ DRM_PANFROST_PARAM_JS_FEATURES9,
+ DRM_PANFROST_PARAM_JS_FEATURES10,
+ DRM_PANFROST_PARAM_JS_FEATURES11,
+ DRM_PANFROST_PARAM_JS_FEATURES12,
+ DRM_PANFROST_PARAM_JS_FEATURES13,
+ DRM_PANFROST_PARAM_JS_FEATURES14,
+ DRM_PANFROST_PARAM_JS_FEATURES15,
+ DRM_PANFROST_PARAM_NR_CORE_GROUPS,
+ DRM_PANFROST_PARAM_THREAD_TLS_ALLOC,
};
struct drm_panfrost_get_param {
__u32 param;
@@ -85,6 +128,13 @@
struct drm_panfrost_perfcnt_dump {
__u64 buf_ptr;
};
+#define PANFROST_MADV_WILLNEED 0
+#define PANFROST_MADV_DONTNEED 1
+struct drm_panfrost_madvise {
+ __u32 handle;
+ __u32 madv;
+ __u32 retained;
+};
#ifdef __cplusplus
}
#endif
diff --git a/libc/kernel/uapi/linux/android/binder.h b/libc/kernel/uapi/linux/android/binder.h
index 542cf1c..0674008 100644
--- a/libc/kernel/uapi/linux/android/binder.h
+++ b/libc/kernel/uapi/linux/android/binder.h
@@ -31,9 +31,14 @@
BINDER_TYPE_FDA = B_PACK_CHARS('f', 'd', 'a', B_TYPE_LARGE),
BINDER_TYPE_PTR = B_PACK_CHARS('p', 't', '*', B_TYPE_LARGE),
};
-enum {
+enum flat_binder_object_shifts {
+ FLAT_BINDER_FLAG_SCHED_POLICY_SHIFT = 9,
+};
+enum flat_binder_object_flags {
FLAT_BINDER_FLAG_PRIORITY_MASK = 0xff,
FLAT_BINDER_FLAG_ACCEPTS_FDS = 0x100,
+ FLAT_BINDER_FLAG_SCHED_POLICY_MASK = 3U << FLAT_BINDER_FLAG_SCHED_POLICY_SHIFT,
+ FLAT_BINDER_FLAG_INHERIT_RT = 0x800,
FLAT_BINDER_FLAG_TXN_SECURITY_CTX = 0x1000,
};
#ifdef BINDER_IPC_32BIT
diff --git a/libc/kernel/uapi/linux/bpf.h b/libc/kernel/uapi/linux/bpf.h
index 7e78758..39a9ea6 100644
--- a/libc/kernel/uapi/linux/bpf.h
+++ b/libc/kernel/uapi/linux/bpf.h
@@ -94,6 +94,7 @@
BPF_TASK_FD_QUERY,
BPF_MAP_LOOKUP_AND_DELETE_ELEM,
BPF_MAP_FREEZE,
+ BPF_BTF_GET_NEXT_ID,
};
enum bpf_map_type {
BPF_MAP_TYPE_UNSPEC,
@@ -121,6 +122,7 @@
BPF_MAP_TYPE_QUEUE,
BPF_MAP_TYPE_STACK,
BPF_MAP_TYPE_SK_STORAGE,
+ BPF_MAP_TYPE_DEVMAP_HASH,
};
enum bpf_prog_type {
BPF_PROG_TYPE_UNSPEC,
@@ -182,6 +184,7 @@
#define BPF_F_STRICT_ALIGNMENT (1U << 0)
#define BPF_F_ANY_ALIGNMENT (1U << 1)
#define BPF_F_TEST_RND_HI32 (1U << 2)
+#define BPF_F_TEST_STATE_FREQ (1U << 3)
#define BPF_PSEUDO_MAP_FD 1
#define BPF_PSEUDO_MAP_VALUE 2
#define BPF_PSEUDO_CALL 1
@@ -199,6 +202,7 @@
#define BPF_F_ZERO_SEED (1U << 6)
#define BPF_F_RDONLY_PROG (1U << 7)
#define BPF_F_WRONLY_PROG (1U << 8)
+#define BPF_F_CLONE (1U << 9)
#define BPF_F_QUERY_EFFECTIVE (1U << 0)
enum bpf_stack_build_id_status {
BPF_STACK_BUILD_ID_EMPTY = 0,
@@ -330,7 +334,7 @@
__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),
+#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),
#define __BPF_ENUM_FN(x) BPF_FUNC_ ##x
enum bpf_func_id {
__BPF_FUNC_MAPPER(__BPF_ENUM_FN) __BPF_FUNC_MAX_ID,
@@ -757,6 +761,9 @@
BPF_FD_TYPE_UPROBE,
BPF_FD_TYPE_URETPROBE,
};
+#define BPF_FLOW_DISSECTOR_F_PARSE_1ST_FRAG (1U << 0)
+#define BPF_FLOW_DISSECTOR_F_STOP_AT_FLOW_LABEL (1U << 1)
+#define BPF_FLOW_DISSECTOR_F_STOP_AT_ENCAP (1U << 2)
struct bpf_flow_keys {
__u16 nhoff;
__u16 thoff;
@@ -778,6 +785,8 @@
__u32 ipv6_dst[4];
};
};
+ __u32 flags;
+ __be32 flow_label;
};
struct bpf_func_info {
__u32 insn_off;
diff --git a/libc/kernel/uapi/linux/btf.h b/libc/kernel/uapi/linux/btf.h
index 475e2eb..21e7596 100644
--- a/libc/kernel/uapi/linux/btf.h
+++ b/libc/kernel/uapi/linux/btf.h
@@ -31,8 +31,8 @@
__u32 str_off;
__u32 str_len;
};
-#define BTF_MAX_TYPE 0x0000ffff
-#define BTF_MAX_NAME_OFFSET 0x0000ffff
+#define BTF_MAX_TYPE 0x000fffff
+#define BTF_MAX_NAME_OFFSET 0x00ffffff
#define BTF_MAX_VLEN 0xffff
struct btf_type {
__u32 name_off;
diff --git a/libc/kernel/uapi/linux/btrfs.h b/libc/kernel/uapi/linux/btrfs.h
index 14cd6e8..a69e089 100644
--- a/libc/kernel/uapi/linux/btrfs.h
+++ b/libc/kernel/uapi/linux/btrfs.h
@@ -501,8 +501,8 @@
#define BTRFS_IOC_QUOTA_RESCAN _IOW(BTRFS_IOCTL_MAGIC, 44, struct btrfs_ioctl_quota_rescan_args)
#define BTRFS_IOC_QUOTA_RESCAN_STATUS _IOR(BTRFS_IOCTL_MAGIC, 45, struct btrfs_ioctl_quota_rescan_args)
#define BTRFS_IOC_QUOTA_RESCAN_WAIT _IO(BTRFS_IOCTL_MAGIC, 46)
-#define BTRFS_IOC_GET_FSLABEL _IOR(BTRFS_IOCTL_MAGIC, 49, char[BTRFS_LABEL_SIZE])
-#define BTRFS_IOC_SET_FSLABEL _IOW(BTRFS_IOCTL_MAGIC, 50, char[BTRFS_LABEL_SIZE])
+#define BTRFS_IOC_GET_FSLABEL FS_IOC_GETFSLABEL
+#define BTRFS_IOC_SET_FSLABEL FS_IOC_SETFSLABEL
#define BTRFS_IOC_GET_DEV_STATS _IOWR(BTRFS_IOCTL_MAGIC, 52, struct btrfs_ioctl_get_dev_stats)
#define BTRFS_IOC_DEV_REPLACE _IOWR(BTRFS_IOCTL_MAGIC, 53, struct btrfs_ioctl_dev_replace_args)
#define BTRFS_IOC_FILE_EXTENT_SAME _IOWR(BTRFS_IOCTL_MAGIC, 54, struct btrfs_ioctl_same_args)
diff --git a/libc/kernel/uapi/linux/btrfs_tree.h b/libc/kernel/uapi/linux/btrfs_tree.h
index be0c8b0..5f58100 100644
--- a/libc/kernel/uapi/linux/btrfs_tree.h
+++ b/libc/kernel/uapi/linux/btrfs_tree.h
@@ -92,7 +92,9 @@
#define BTRFS_UUID_KEY_RECEIVED_SUBVOL 252
#define BTRFS_STRING_ITEM_KEY 253
#define BTRFS_CSUM_SIZE 32
-#define BTRFS_CSUM_TYPE_CRC32 0
+enum btrfs_csum_type {
+ BTRFS_CSUM_TYPE_CRC32 = 0,
+};
#define BTRFS_FT_UNKNOWN 0
#define BTRFS_FT_REG_FILE 1
#define BTRFS_FT_DIR 2
@@ -344,11 +346,6 @@
} __attribute__((__packed__));
#define BTRFS_DEV_REPLACE_ITEM_CONT_READING_FROM_SRCDEV_MODE_ALWAYS 0
#define BTRFS_DEV_REPLACE_ITEM_CONT_READING_FROM_SRCDEV_MODE_AVOID 1
-#define BTRFS_DEV_REPLACE_ITEM_STATE_NEVER_STARTED 0
-#define BTRFS_DEV_REPLACE_ITEM_STATE_STARTED 1
-#define BTRFS_DEV_REPLACE_ITEM_STATE_SUSPENDED 2
-#define BTRFS_DEV_REPLACE_ITEM_STATE_FINISHED 3
-#define BTRFS_DEV_REPLACE_ITEM_STATE_CANCELED 4
struct btrfs_dev_replace_item {
__le64 src_devid;
__le64 cursor_left;
diff --git a/libc/kernel/uapi/linux/can.h b/libc/kernel/uapi/linux/can.h
index 122d545..3933614 100644
--- a/libc/kernel/uapi/linux/can.h
+++ b/libc/kernel/uapi/linux/can.h
@@ -60,7 +60,8 @@
#define CAN_TP20 4
#define CAN_MCNET 5
#define CAN_ISOTP 6
-#define CAN_NPROTO 7
+#define CAN_J1939 7
+#define CAN_NPROTO 8
#define SOL_CAN_BASE 100
struct sockaddr_can {
__kernel_sa_family_t can_family;
@@ -69,6 +70,11 @@
struct {
canid_t rx_id, tx_id;
} tp;
+ struct {
+ __u64 name;
+ __u32 pgn;
+ __u8 addr;
+ } j1939;
} can_addr;
};
struct can_filter {
diff --git a/libc/kernel/uapi/linux/can/gw.h b/libc/kernel/uapi/linux/can/gw.h
index 9be6107..f76bafb 100644
--- a/libc/kernel/uapi/linux/can/gw.h
+++ b/libc/kernel/uapi/linux/can/gw.h
@@ -47,23 +47,35 @@
CGW_DELETED,
CGW_LIM_HOPS,
CGW_MOD_UID,
+ CGW_FDMOD_AND,
+ CGW_FDMOD_OR,
+ CGW_FDMOD_XOR,
+ CGW_FDMOD_SET,
__CGW_MAX
};
#define CGW_MAX (__CGW_MAX - 1)
#define CGW_FLAGS_CAN_ECHO 0x01
#define CGW_FLAGS_CAN_SRC_TSTAMP 0x02
#define CGW_FLAGS_CAN_IIF_TX_OK 0x04
+#define CGW_FLAGS_CAN_FD 0x08
#define CGW_MOD_FUNCS 4
#define CGW_MOD_ID 0x01
#define CGW_MOD_DLC 0x02
+#define CGW_MOD_LEN CGW_MOD_DLC
#define CGW_MOD_DATA 0x04
-#define CGW_FRAME_MODS 3
+#define CGW_MOD_FLAGS 0x08
+#define CGW_FRAME_MODS 4
#define MAX_MODFUNCTIONS (CGW_MOD_FUNCS * CGW_FRAME_MODS)
struct cgw_frame_mod {
struct can_frame cf;
__u8 modtype;
} __attribute__((packed));
+struct cgw_fdframe_mod {
+ struct canfd_frame cf;
+ __u8 modtype;
+} __attribute__((packed));
#define CGW_MODATTR_LEN sizeof(struct cgw_frame_mod)
+#define CGW_FDMODATTR_LEN sizeof(struct cgw_fdframe_mod)
struct cgw_csum_xor {
__s8 from_idx;
__s8 to_idx;
diff --git a/libc/kernel/uapi/linux/can/j1939.h b/libc/kernel/uapi/linux/can/j1939.h
new file mode 100644
index 0000000..531a222
--- /dev/null
+++ b/libc/kernel/uapi/linux/can/j1939.h
@@ -0,0 +1,67 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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_CAN_J1939_H_
+#define _UAPI_CAN_J1939_H_
+#include <linux/types.h>
+#include <linux/socket.h>
+#include <linux/can.h>
+#define J1939_MAX_UNICAST_ADDR 0xfd
+#define J1939_IDLE_ADDR 0xfe
+#define J1939_NO_ADDR 0xff
+#define J1939_NO_NAME 0
+#define J1939_PGN_REQUEST 0x0ea00
+#define J1939_PGN_ADDRESS_CLAIMED 0x0ee00
+#define J1939_PGN_ADDRESS_COMMANDED 0x0fed8
+#define J1939_PGN_PDU1_MAX 0x3ff00
+#define J1939_PGN_MAX 0x3ffff
+#define J1939_NO_PGN 0x40000
+typedef __u32 pgn_t;
+typedef __u8 priority_t;
+typedef __u64 name_t;
+#define SOL_CAN_J1939 (SOL_CAN_BASE + CAN_J1939)
+enum {
+ SO_J1939_FILTER = 1,
+ SO_J1939_PROMISC = 2,
+ SO_J1939_SEND_PRIO = 3,
+ SO_J1939_ERRQUEUE = 4,
+};
+enum {
+ SCM_J1939_DEST_ADDR = 1,
+ SCM_J1939_DEST_NAME = 2,
+ SCM_J1939_PRIO = 3,
+ SCM_J1939_ERRQUEUE = 4,
+};
+enum {
+ J1939_NLA_PAD,
+ J1939_NLA_BYTES_ACKED,
+};
+enum {
+ J1939_EE_INFO_NONE,
+ J1939_EE_INFO_TX_ABORT,
+};
+struct j1939_filter {
+ name_t name;
+ name_t name_mask;
+ pgn_t pgn;
+ pgn_t pgn_mask;
+ __u8 addr;
+ __u8 addr_mask;
+};
+#define J1939_FILTER_MAX 512
+#endif
diff --git a/libc/kernel/uapi/linux/coff.h b/libc/kernel/uapi/linux/coff.h
index be2db26..8f93b61 100644
--- a/libc/kernel/uapi/linux/coff.h
+++ b/libc/kernel/uapi/linux/coff.h
@@ -16,6 +16,8 @@
***
****************************************************************************
****************************************************************************/
+#ifndef _UAPI_LINUX_COFF_H
+#define _UAPI_LINUX_COFF_H
#define E_SYMNMLEN 8
#define E_FILNMLEN 14
#define E_DIMNUM 4
@@ -193,3 +195,4 @@
#define COFF_DEF_BSS_SECTION_ALIGNMENT 4
#define COFF_DEF_TEXT_SECTION_ALIGNMENT 4
#define COFF_DEF_SECTION_ALIGNMENT 4
+#endif
diff --git a/libc/kernel/uapi/linux/cryptouser.h b/libc/kernel/uapi/linux/cryptouser.h
index b32db64..1d145bd 100644
--- a/libc/kernel/uapi/linux/cryptouser.h
+++ b/libc/kernel/uapi/linux/cryptouser.h
@@ -16,6 +16,8 @@
***
****************************************************************************
****************************************************************************/
+#ifndef _UAPI_LINUX_CRYPTOUSER_H
+#define _UAPI_LINUX_CRYPTOUSER_H
#include <linux/types.h>
enum {
CRYPTO_MSG_BASE = 0x10,
@@ -168,3 +170,4 @@
char type[CRYPTO_MAX_NAME];
};
#define CRYPTO_REPORT_MAXSIZE (sizeof(struct crypto_user_alg) + sizeof(struct crypto_report_blkcipher))
+#endif
diff --git a/libc/kernel/uapi/linux/devlink.h b/libc/kernel/uapi/linux/devlink.h
index 1cf9d95..beab9fd 100644
--- a/libc/kernel/uapi/linux/devlink.h
+++ b/libc/kernel/uapi/linux/devlink.h
@@ -85,6 +85,14 @@
DEVLINK_CMD_FLASH_UPDATE,
DEVLINK_CMD_FLASH_UPDATE_END,
DEVLINK_CMD_FLASH_UPDATE_STATUS,
+ DEVLINK_CMD_TRAP_GET,
+ DEVLINK_CMD_TRAP_SET,
+ DEVLINK_CMD_TRAP_NEW,
+ DEVLINK_CMD_TRAP_DEL,
+ DEVLINK_CMD_TRAP_GROUP_GET,
+ DEVLINK_CMD_TRAP_GROUP_SET,
+ DEVLINK_CMD_TRAP_GROUP_NEW,
+ DEVLINK_CMD_TRAP_GROUP_DEL,
__DEVLINK_CMD_MAX,
DEVLINK_CMD_MAX = __DEVLINK_CMD_MAX - 1
};
@@ -134,6 +142,31 @@
enum devlink_param_fw_load_policy_value {
DEVLINK_PARAM_FW_LOAD_POLICY_VALUE_DRIVER,
DEVLINK_PARAM_FW_LOAD_POLICY_VALUE_FLASH,
+ DEVLINK_PARAM_FW_LOAD_POLICY_VALUE_DISK,
+ DEVLINK_PARAM_FW_LOAD_POLICY_VALUE_UNKNOWN,
+};
+enum devlink_param_reset_dev_on_drv_probe_value {
+ DEVLINK_PARAM_RESET_DEV_ON_DRV_PROBE_VALUE_UNKNOWN,
+ DEVLINK_PARAM_RESET_DEV_ON_DRV_PROBE_VALUE_ALWAYS,
+ DEVLINK_PARAM_RESET_DEV_ON_DRV_PROBE_VALUE_NEVER,
+ DEVLINK_PARAM_RESET_DEV_ON_DRV_PROBE_VALUE_DISK,
+};
+enum {
+ DEVLINK_ATTR_STATS_RX_PACKETS,
+ DEVLINK_ATTR_STATS_RX_BYTES,
+ __DEVLINK_ATTR_STATS_MAX,
+ DEVLINK_ATTR_STATS_MAX = __DEVLINK_ATTR_STATS_MAX - 1
+};
+enum devlink_trap_action {
+ DEVLINK_TRAP_ACTION_DROP,
+ DEVLINK_TRAP_ACTION_TRAP,
+};
+enum devlink_trap_type {
+ DEVLINK_TRAP_TYPE_DROP,
+ DEVLINK_TRAP_TYPE_EXCEPTION,
+};
+enum {
+ DEVLINK_ATTR_TRAP_METADATA_TYPE_IN_PORT,
};
enum devlink_attr {
DEVLINK_ATTR_UNSPEC,
@@ -265,6 +298,15 @@
DEVLINK_ATTR_FLASH_UPDATE_STATUS_TOTAL,
DEVLINK_ATTR_PORT_PCI_PF_NUMBER,
DEVLINK_ATTR_PORT_PCI_VF_NUMBER,
+ DEVLINK_ATTR_STATS,
+ DEVLINK_ATTR_TRAP_NAME,
+ DEVLINK_ATTR_TRAP_ACTION,
+ DEVLINK_ATTR_TRAP_TYPE,
+ DEVLINK_ATTR_TRAP_GENERIC,
+ DEVLINK_ATTR_TRAP_METADATA,
+ DEVLINK_ATTR_TRAP_GROUP_NAME,
+ DEVLINK_ATTR_RELOAD_FAILED,
+ DEVLINK_ATTR_HEALTH_REPORTER_DUMP_TS_NS,
__DEVLINK_ATTR_MAX,
DEVLINK_ATTR_MAX = __DEVLINK_ATTR_MAX - 1
};
diff --git a/libc/kernel/uapi/linux/dm-ioctl.h b/libc/kernel/uapi/linux/dm-ioctl.h
index 3aa627d..51e997f 100644
--- a/libc/kernel/uapi/linux/dm-ioctl.h
+++ b/libc/kernel/uapi/linux/dm-ioctl.h
@@ -82,6 +82,7 @@
DM_TARGET_MSG_CMD,
DM_DEV_SET_GEOMETRY_CMD,
DM_DEV_ARM_POLL_CMD,
+ DM_GET_TARGET_VERSION_CMD,
};
#define DM_IOCTL 0xfd
#define DM_VERSION _IOWR(DM_IOCTL, DM_VERSION_CMD, struct dm_ioctl)
@@ -99,12 +100,13 @@
#define DM_TABLE_DEPS _IOWR(DM_IOCTL, DM_TABLE_DEPS_CMD, struct dm_ioctl)
#define DM_TABLE_STATUS _IOWR(DM_IOCTL, DM_TABLE_STATUS_CMD, struct dm_ioctl)
#define DM_LIST_VERSIONS _IOWR(DM_IOCTL, DM_LIST_VERSIONS_CMD, struct dm_ioctl)
+#define DM_GET_TARGET_VERSION _IOWR(DM_IOCTL, DM_GET_TARGET_VERSION_CMD, struct dm_ioctl)
#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 40
+#define DM_VERSION_MINOR 41
#define DM_VERSION_PATCHLEVEL 0
-#define DM_VERSION_EXTRA "-ioctl(2019-01-18)"
+#define DM_VERSION_EXTRA "-ioctl(2019-09-16)"
#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/ethtool.h b/libc/kernel/uapi/linux/ethtool.h
index 6b2b8d5..28209e3 100644
--- a/libc/kernel/uapi/linux/ethtool.h
+++ b/libc/kernel/uapi/linux/ethtool.h
@@ -103,10 +103,14 @@
#define DOWNSHIFT_DEV_DISABLE 0
#define ETHTOOL_PHY_FAST_LINK_DOWN_ON 0
#define ETHTOOL_PHY_FAST_LINK_DOWN_OFF 0xff
+#define ETHTOOL_PHY_EDPD_DFLT_TX_MSECS 0xffff
+#define ETHTOOL_PHY_EDPD_NO_TX 0xfffe
+#define ETHTOOL_PHY_EDPD_DISABLE 0
enum phy_tunable_id {
ETHTOOL_PHY_ID_UNSPEC,
ETHTOOL_PHY_DOWNSHIFT,
ETHTOOL_PHY_FAST_LINK_DOWN,
+ ETHTOOL_PHY_EDPD,
__ETHTOOL_PHY_TUNABLE_COUNT,
};
struct ethtool_regs {
diff --git a/libc/kernel/uapi/linux/fpga-dfl.h b/libc/kernel/uapi/linux/fpga-dfl.h
index bf9a7c7..8712e4c 100644
--- a/libc/kernel/uapi/linux/fpga-dfl.h
+++ b/libc/kernel/uapi/linux/fpga-dfl.h
@@ -71,4 +71,6 @@
__u64 buffer_address;
};
#define DFL_FPGA_FME_PORT_PR _IO(DFL_FPGA_MAGIC, DFL_FME_BASE + 0)
+#define DFL_FPGA_FME_PORT_RELEASE _IOW(DFL_FPGA_MAGIC, DFL_FME_BASE + 1, int)
+#define DFL_FPGA_FME_PORT_ASSIGN _IOW(DFL_FPGA_MAGIC, DFL_FME_BASE + 2, int)
#endif
diff --git a/libc/kernel/uapi/linux/fs.h b/libc/kernel/uapi/linux/fs.h
index 5edd66b..1dd1602 100644
--- a/libc/kernel/uapi/linux/fs.h
+++ b/libc/kernel/uapi/linux/fs.h
@@ -21,6 +21,7 @@
#include <linux/limits.h>
#include <linux/ioctl.h>
#include <linux/types.h>
+#include <linux/fscrypt.h>
#include <linux/mount.h>
#undef NR_OPEN
#define INR_OPEN_CUR 1024
@@ -151,42 +152,6 @@
#define FS_IOC_FSSETXATTR _IOW('X', 32, struct fsxattr)
#define FS_IOC_GETFSLABEL _IOR(0x94, 49, char[FSLABEL_MAX])
#define FS_IOC_SETFSLABEL _IOW(0x94, 50, char[FSLABEL_MAX])
-#define FS_KEY_DESCRIPTOR_SIZE 8
-#define FS_POLICY_FLAGS_PAD_4 0x00
-#define FS_POLICY_FLAGS_PAD_8 0x01
-#define FS_POLICY_FLAGS_PAD_16 0x02
-#define FS_POLICY_FLAGS_PAD_32 0x03
-#define FS_POLICY_FLAGS_PAD_MASK 0x03
-#define FS_POLICY_FLAG_DIRECT_KEY 0x04
-#define FS_POLICY_FLAGS_VALID 0x07
-#define FS_ENCRYPTION_MODE_INVALID 0
-#define FS_ENCRYPTION_MODE_AES_256_XTS 1
-#define FS_ENCRYPTION_MODE_AES_256_GCM 2
-#define FS_ENCRYPTION_MODE_AES_256_CBC 3
-#define FS_ENCRYPTION_MODE_AES_256_CTS 4
-#define FS_ENCRYPTION_MODE_AES_128_CBC 5
-#define FS_ENCRYPTION_MODE_AES_128_CTS 6
-#define FS_ENCRYPTION_MODE_SPECK128_256_XTS 7
-#define FS_ENCRYPTION_MODE_SPECK128_256_CTS 8
-#define FS_ENCRYPTION_MODE_ADIANTUM 9
-struct fscrypt_policy {
- __u8 version;
- __u8 contents_encryption_mode;
- __u8 filenames_encryption_mode;
- __u8 flags;
- __u8 master_key_descriptor[FS_KEY_DESCRIPTOR_SIZE];
-};
-#define FS_IOC_SET_ENCRYPTION_POLICY _IOR('f', 19, struct fscrypt_policy)
-#define FS_IOC_GET_ENCRYPTION_PWSALT _IOW('f', 20, __u8[16])
-#define FS_IOC_GET_ENCRYPTION_POLICY _IOW('f', 21, struct fscrypt_policy)
-#define FS_KEY_DESC_PREFIX "fscrypt:"
-#define FS_KEY_DESC_PREFIX_SIZE 8
-#define FS_MAX_KEY_SIZE 64
-struct fscrypt_key {
- __u32 mode;
- __u8 raw[FS_MAX_KEY_SIZE];
- __u32 size;
-};
#define FS_SECRM_FL 0x00000001
#define FS_UNRM_FL 0x00000002
#define FS_COMPR_FL 0x00000004
@@ -208,11 +173,13 @@
#define FS_TOPDIR_FL 0x00020000
#define FS_HUGE_FILE_FL 0x00040000
#define FS_EXTENT_FL 0x00080000
+#define FS_VERITY_FL 0x00100000
#define FS_EA_INODE_FL 0x00200000
#define FS_EOFBLOCKS_FL 0x00400000
#define FS_NOCOW_FL 0x00800000
#define FS_INLINE_DATA_FL 0x10000000
#define FS_PROJINHERIT_FL 0x20000000
+#define FS_CASEFOLD_FL 0x40000000
#define FS_RESERVED_FL 0x80000000
#define FS_FL_USER_VISIBLE 0x0003DFFF
#define FS_FL_USER_MODIFIABLE 0x000380FF
diff --git a/libc/kernel/uapi/linux/fscrypt.h b/libc/kernel/uapi/linux/fscrypt.h
new file mode 100644
index 0000000..75a554e
--- /dev/null
+++ b/libc/kernel/uapi/linux/fscrypt.h
@@ -0,0 +1,137 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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_FSCRYPT_H
+#define _UAPI_LINUX_FSCRYPT_H
+#include <linux/types.h>
+#define FSCRYPT_POLICY_FLAGS_PAD_4 0x00
+#define FSCRYPT_POLICY_FLAGS_PAD_8 0x01
+#define FSCRYPT_POLICY_FLAGS_PAD_16 0x02
+#define FSCRYPT_POLICY_FLAGS_PAD_32 0x03
+#define FSCRYPT_POLICY_FLAGS_PAD_MASK 0x03
+#define FSCRYPT_POLICY_FLAG_DIRECT_KEY 0x04
+#define FSCRYPT_POLICY_FLAG_IV_INO_LBLK_64 0x08
+#define FSCRYPT_POLICY_FLAGS_VALID 0x0F
+#define FSCRYPT_MODE_AES_256_XTS 1
+#define FSCRYPT_MODE_AES_256_CTS 4
+#define FSCRYPT_MODE_AES_128_CBC 5
+#define FSCRYPT_MODE_AES_128_CTS 6
+#define FSCRYPT_MODE_ADIANTUM 9
+#define __FSCRYPT_MODE_MAX 9
+#define FSCRYPT_POLICY_V1 0
+#define FSCRYPT_KEY_DESCRIPTOR_SIZE 8
+struct fscrypt_policy_v1 {
+ __u8 version;
+ __u8 contents_encryption_mode;
+ __u8 filenames_encryption_mode;
+ __u8 flags;
+ __u8 master_key_descriptor[FSCRYPT_KEY_DESCRIPTOR_SIZE];
+};
+#define fscrypt_policy fscrypt_policy_v1
+#define FSCRYPT_KEY_DESC_PREFIX "fscrypt:"
+#define FSCRYPT_KEY_DESC_PREFIX_SIZE 8
+#define FSCRYPT_MAX_KEY_SIZE 64
+struct fscrypt_key {
+ __u32 mode;
+ __u8 raw[FSCRYPT_MAX_KEY_SIZE];
+ __u32 size;
+};
+#define FSCRYPT_POLICY_V2 2
+#define FSCRYPT_KEY_IDENTIFIER_SIZE 16
+struct fscrypt_policy_v2 {
+ __u8 version;
+ __u8 contents_encryption_mode;
+ __u8 filenames_encryption_mode;
+ __u8 flags;
+ __u8 __reserved[4];
+ __u8 master_key_identifier[FSCRYPT_KEY_IDENTIFIER_SIZE];
+};
+struct fscrypt_get_policy_ex_arg {
+ __u64 policy_size;
+ union {
+ __u8 version;
+ struct fscrypt_policy_v1 v1;
+ struct fscrypt_policy_v2 v2;
+ } policy;
+};
+#define FSCRYPT_KEY_SPEC_TYPE_DESCRIPTOR 1
+#define FSCRYPT_KEY_SPEC_TYPE_IDENTIFIER 2
+struct fscrypt_key_specifier {
+ __u32 type;
+ __u32 __reserved;
+ union {
+ __u8 __reserved[32];
+ __u8 descriptor[FSCRYPT_KEY_DESCRIPTOR_SIZE];
+ __u8 identifier[FSCRYPT_KEY_IDENTIFIER_SIZE];
+ } u;
+};
+struct fscrypt_add_key_arg {
+ struct fscrypt_key_specifier key_spec;
+ __u32 raw_size;
+ __u32 __reserved[9];
+ __u8 raw[];
+};
+struct fscrypt_remove_key_arg {
+ struct fscrypt_key_specifier key_spec;
+#define FSCRYPT_KEY_REMOVAL_STATUS_FLAG_FILES_BUSY 0x00000001
+#define FSCRYPT_KEY_REMOVAL_STATUS_FLAG_OTHER_USERS 0x00000002
+ __u32 removal_status_flags;
+ __u32 __reserved[5];
+};
+struct fscrypt_get_key_status_arg {
+ struct fscrypt_key_specifier key_spec;
+ __u32 __reserved[6];
+#define FSCRYPT_KEY_STATUS_ABSENT 1
+#define FSCRYPT_KEY_STATUS_PRESENT 2
+#define FSCRYPT_KEY_STATUS_INCOMPLETELY_REMOVED 3
+ __u32 status;
+#define FSCRYPT_KEY_STATUS_FLAG_ADDED_BY_SELF 0x00000001
+ __u32 status_flags;
+ __u32 user_count;
+ __u32 __out_reserved[13];
+};
+#define FS_IOC_SET_ENCRYPTION_POLICY _IOR('f', 19, struct fscrypt_policy)
+#define FS_IOC_GET_ENCRYPTION_PWSALT _IOW('f', 20, __u8[16])
+#define FS_IOC_GET_ENCRYPTION_POLICY _IOW('f', 21, struct fscrypt_policy)
+#define FS_IOC_GET_ENCRYPTION_POLICY_EX _IOWR('f', 22, __u8[9])
+#define FS_IOC_ADD_ENCRYPTION_KEY _IOWR('f', 23, struct fscrypt_add_key_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_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
+#define FS_POLICY_FLAGS_PAD_16 FSCRYPT_POLICY_FLAGS_PAD_16
+#define FS_POLICY_FLAGS_PAD_32 FSCRYPT_POLICY_FLAGS_PAD_32
+#define FS_POLICY_FLAGS_PAD_MASK FSCRYPT_POLICY_FLAGS_PAD_MASK
+#define FS_POLICY_FLAG_DIRECT_KEY FSCRYPT_POLICY_FLAG_DIRECT_KEY
+#define FS_POLICY_FLAGS_VALID FSCRYPT_POLICY_FLAGS_VALID
+#define FS_ENCRYPTION_MODE_INVALID 0
+#define FS_ENCRYPTION_MODE_AES_256_XTS FSCRYPT_MODE_AES_256_XTS
+#define FS_ENCRYPTION_MODE_AES_256_GCM 2
+#define FS_ENCRYPTION_MODE_AES_256_CBC 3
+#define FS_ENCRYPTION_MODE_AES_256_CTS FSCRYPT_MODE_AES_256_CTS
+#define FS_ENCRYPTION_MODE_AES_128_CBC FSCRYPT_MODE_AES_128_CBC
+#define FS_ENCRYPTION_MODE_AES_128_CTS FSCRYPT_MODE_AES_128_CTS
+#define FS_ENCRYPTION_MODE_SPECK128_256_XTS 7
+#define FS_ENCRYPTION_MODE_SPECK128_256_CTS 8
+#define FS_ENCRYPTION_MODE_ADIANTUM FSCRYPT_MODE_ADIANTUM
+#define FS_KEY_DESC_PREFIX FSCRYPT_KEY_DESC_PREFIX
+#define FS_KEY_DESC_PREFIX_SIZE FSCRYPT_KEY_DESC_PREFIX_SIZE
+#define FS_MAX_KEY_SIZE FSCRYPT_MAX_KEY_SIZE
+#endif
diff --git a/libc/kernel/android/uapi/linux/keychord.h b/libc/kernel/uapi/linux/fsverity.h
similarity index 60%
copy from libc/kernel/android/uapi/linux/keychord.h
copy to libc/kernel/uapi/linux/fsverity.h
index 5fd3912..5013567 100644
--- a/libc/kernel/android/uapi/linux/keychord.h
+++ b/libc/kernel/uapi/linux/fsverity.h
@@ -16,16 +16,28 @@
***
****************************************************************************
****************************************************************************/
-#ifndef _UAPI_LINUX_KEYCHORD_H_
-#define _UAPI_LINUX_KEYCHORD_H_
-#include <linux/input.h>
-#define KEYCHORD_VERSION 1
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-struct input_keychord {
- __u16 version;
- __u16 id;
- __u16 count;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- __u16 keycodes[];
+#ifndef _UAPI_LINUX_FSVERITY_H
+#define _UAPI_LINUX_FSVERITY_H
+#include <linux/ioctl.h>
+#include <linux/types.h>
+#define FS_VERITY_HASH_ALG_SHA256 1
+#define FS_VERITY_HASH_ALG_SHA512 2
+struct fsverity_enable_arg {
+ __u32 version;
+ __u32 hash_algorithm;
+ __u32 block_size;
+ __u32 salt_size;
+ __u64 salt_ptr;
+ __u32 sig_size;
+ __u32 __reserved1;
+ __u64 sig_ptr;
+ __u64 __reserved2[11];
};
+struct fsverity_digest {
+ __u16 digest_algorithm;
+ __u16 digest_size;
+ __u8 digest[];
+};
+#define FS_IOC_ENABLE_VERITY _IOW('f', 133, struct fsverity_enable_arg)
+#define FS_IOC_MEASURE_VERITY _IOWR('f', 134, struct fsverity_digest)
#endif
diff --git a/libc/kernel/uapi/linux/fuse.h b/libc/kernel/uapi/linux/fuse.h
index 86b01f0..7a7ff9d 100644
--- a/libc/kernel/uapi/linux/fuse.h
+++ b/libc/kernel/uapi/linux/fuse.h
@@ -100,6 +100,7 @@
#define FUSE_CACHE_SYMLINKS (1 << 23)
#define FUSE_NO_OPENDIR_SUPPORT (1 << 24)
#define FUSE_EXPLICIT_INVAL_DATA (1 << 25)
+#define FUSE_MAP_ALIGNMENT (1 << 26)
#define CUSE_UNRESTRICTED_IOCTL (1 << 0)
#define FUSE_RELEASE_FLUSH (1 << 0)
#define FUSE_RELEASE_FLOCK_UNLOCK (1 << 1)
@@ -164,7 +165,11 @@
FUSE_RENAME2 = 45,
FUSE_LSEEK = 46,
FUSE_COPY_FILE_RANGE = 47,
+ FUSE_SETUPMAPPING = 48,
+ FUSE_REMOVEMAPPING = 49,
CUSE_INIT = 4096,
+ CUSE_INIT_BSWAP_RESERVED = 1048576,
+ FUSE_INIT_BSWAP_RESERVED = 436207616,
};
enum fuse_notify_code {
FUSE_NOTIFY_POLL = 1,
@@ -352,7 +357,7 @@
uint32_t max_write;
uint32_t time_gran;
uint16_t max_pages;
- uint16_t padding;
+ uint16_t map_alignment;
uint32_t unused[8];
};
#define CUSE_INIT_INFO_MAX 4096
diff --git a/libc/kernel/uapi/linux/gsmmux.h b/libc/kernel/uapi/linux/gsmmux.h
index 2757b05..4e6920a 100644
--- a/libc/kernel/uapi/linux/gsmmux.h
+++ b/libc/kernel/uapi/linux/gsmmux.h
@@ -46,4 +46,5 @@
};
#define GSMIOC_ENABLE_NET _IOW('G', 2, struct gsm_netconfig)
#define GSMIOC_DISABLE_NET _IO('G', 3)
+#define GSMIOC_GETFIRST _IOR('G', 4, __u32)
#endif
diff --git a/libc/kernel/uapi/linux/if_bridge.h b/libc/kernel/uapi/linux/if_bridge.h
index 31683c1..03cc1c4 100644
--- a/libc/kernel/uapi/linux/if_bridge.h
+++ b/libc/kernel/uapi/linux/if_bridge.h
@@ -190,6 +190,7 @@
#define MDB_PERMANENT 1
__u8 state;
#define MDB_FLAGS_OFFLOAD (1 << 0)
+#define MDB_FLAGS_FAST_LEAVE (1 << 1)
__u8 flags;
__u16 vid;
struct {
diff --git a/libc/kernel/uapi/linux/if_xdp.h b/libc/kernel/uapi/linux/if_xdp.h
index 2c2596c..3615edb 100644
--- a/libc/kernel/uapi/linux/if_xdp.h
+++ b/libc/kernel/uapi/linux/if_xdp.h
@@ -22,6 +22,8 @@
#define XDP_SHARED_UMEM (1 << 0)
#define XDP_COPY (1 << 1)
#define XDP_ZEROCOPY (1 << 2)
+#define XDP_USE_NEED_WAKEUP (1 << 3)
+#define XDP_UMEM_UNALIGNED_CHUNK_FLAG (1 << 0)
struct sockaddr_xdp {
__u16 sxdp_family;
__u16 sxdp_flags;
@@ -29,10 +31,12 @@
__u32 sxdp_queue_id;
__u32 sxdp_shared_umem_fd;
};
+#define XDP_RING_NEED_WAKEUP (1 << 0)
struct xdp_ring_offset {
__u64 producer;
__u64 consumer;
__u64 desc;
+ __u64 flags;
};
struct xdp_mmap_offsets {
struct xdp_ring_offset rx;
@@ -53,6 +57,7 @@
__u64 len;
__u32 chunk_size;
__u32 headroom;
+ __u32 flags;
};
struct xdp_statistics {
__u64 rx_dropped;
@@ -67,6 +72,8 @@
#define XDP_PGOFF_TX_RING 0x80000000
#define XDP_UMEM_PGOFF_FILL_RING 0x100000000ULL
#define XDP_UMEM_PGOFF_COMPLETION_RING 0x180000000ULL
+#define XSK_UNALIGNED_BUF_OFFSET_SHIFT 48
+#define XSK_UNALIGNED_BUF_ADDR_MASK ((1ULL << XSK_UNALIGNED_BUF_OFFSET_SHIFT) - 1)
struct xdp_desc {
__u64 addr;
__u32 len;
diff --git a/libc/kernel/uapi/linux/inet_diag.h b/libc/kernel/uapi/linux/inet_diag.h
index eb9b712..5df55ef 100644
--- a/libc/kernel/uapi/linux/inet_diag.h
+++ b/libc/kernel/uapi/linux/inet_diag.h
@@ -123,9 +123,17 @@
INET_DIAG_BBRINFO,
INET_DIAG_CLASS_ID,
INET_DIAG_MD5SIG,
+ INET_DIAG_ULP_INFO,
__INET_DIAG_MAX,
};
#define INET_DIAG_MAX (__INET_DIAG_MAX - 1)
+enum {
+ INET_ULP_INFO_UNSPEC,
+ INET_ULP_INFO_NAME,
+ INET_ULP_INFO_TLS,
+ __INET_ULP_INFO_MAX,
+};
+#define INET_ULP_INFO_MAX (__INET_ULP_INFO_MAX - 1)
struct inet_diag_meminfo {
__u32 idiag_rmem;
__u32 idiag_wmem;
diff --git a/libc/kernel/uapi/linux/input-event-codes.h b/libc/kernel/uapi/linux/input-event-codes.h
index 5d20c24..0230c11 100644
--- a/libc/kernel/uapi/linux/input-event-codes.h
+++ b/libc/kernel/uapi/linux/input-event-codes.h
@@ -691,7 +691,10 @@
#define SW_LINEIN_INSERT 0x0d
#define SW_MUTE_DEVICE 0x0e
#define SW_PEN_INSERTED 0x0f
-#define SW_MAX 0x0f
+#define SW_HPHL_OVERCURRENT 0x10
+#define SW_HPHR_OVERCURRENT 0x11
+#define SW_UNSUPPORT_INSERT 0x12
+#define SW_MAX 0x20
#define SW_CNT (SW_MAX + 1)
#define MSC_SERIAL 0x00
#define MSC_PULSELED 0x01
diff --git a/libc/kernel/uapi/linux/io_uring.h b/libc/kernel/uapi/linux/io_uring.h
index c5055ba..7ae31df 100644
--- a/libc/kernel/uapi/linux/io_uring.h
+++ b/libc/kernel/uapi/linux/io_uring.h
@@ -34,6 +34,7 @@
__u16 poll_events;
__u32 sync_range_flags;
__u32 msg_flags;
+ __u32 timeout_flags;
};
__u64 user_data;
union {
@@ -58,6 +59,7 @@
#define IORING_OP_SYNC_FILE_RANGE 8
#define IORING_OP_SENDMSG 9
#define IORING_OP_RECVMSG 10
+#define IORING_OP_TIMEOUT 11
#define IORING_FSYNC_DATASYNC (1U << 0)
struct io_uring_cqe {
__u64 user_data;
@@ -96,10 +98,12 @@
__u32 flags;
__u32 sq_thread_cpu;
__u32 sq_thread_idle;
- __u32 resv[5];
+ __u32 features;
+ __u32 resv[4];
struct io_sqring_offsets sq_off;
struct io_cqring_offsets cq_off;
};
+#define IORING_FEAT_SINGLE_MMAP (1U << 0)
#define IORING_REGISTER_BUFFERS 0
#define IORING_UNREGISTER_BUFFERS 1
#define IORING_REGISTER_FILES 2
diff --git a/libc/kernel/uapi/linux/kexec.h b/libc/kernel/uapi/linux/kexec.h
index 5100404..b2dc88f 100644
--- a/libc/kernel/uapi/linux/kexec.h
+++ b/libc/kernel/uapi/linux/kexec.h
@@ -28,6 +28,7 @@
#define KEXEC_ARCH_DEFAULT (0 << 16)
#define KEXEC_ARCH_386 (3 << 16)
#define KEXEC_ARCH_68K (4 << 16)
+#define KEXEC_ARCH_PARISC (15 << 16)
#define KEXEC_ARCH_X86_64 (62 << 16)
#define KEXEC_ARCH_PPC (20 << 16)
#define KEXEC_ARCH_PPC64 (21 << 16)
diff --git a/libc/kernel/uapi/linux/kvm.h b/libc/kernel/uapi/linux/kvm.h
index 7b8fb1b..358a168 100644
--- a/libc/kernel/uapi/linux/kvm.h
+++ b/libc/kernel/uapi/linux/kvm.h
@@ -185,6 +185,7 @@
#define KVM_INTERNAL_ERROR_EMULATION 1
#define KVM_INTERNAL_ERROR_SIMUL_EX 2
#define KVM_INTERNAL_ERROR_DELIVERY_EV 3
+#define KVM_INTERNAL_ERROR_UNEXPECTED_EXIT_REASON 4
struct kvm_run {
__u8 request_interrupt_window;
__u8 immediate_exit;
@@ -777,6 +778,8 @@
#define KVM_CAP_ARM_PTRAUTH_ADDRESS 171
#define KVM_CAP_ARM_PTRAUTH_GENERIC 172
#define KVM_CAP_PMU_EVENT_FILTER 173
+#define KVM_CAP_ARM_IRQ_LINE_LAYOUT_2 174
+#define KVM_CAP_HYPERV_DIRECT_TLBFLUSH 175
#ifdef KVM_CAP_IRQ_ROUTING
struct kvm_irq_routing_irqchip {
__u32 irqchip;
@@ -883,6 +886,7 @@
#define KVM_REG_S390 0x5000000000000000ULL
#define KVM_REG_ARM64 0x6000000000000000ULL
#define KVM_REG_MIPS 0x7000000000000000ULL
+#define KVM_REG_RISCV 0x8000000000000000ULL
#define KVM_REG_SIZE_SHIFT 52
#define KVM_REG_SIZE_MASK 0x00f0000000000000ULL
#define KVM_REG_SIZE_U8 0x0000000000000000ULL
diff --git a/libc/kernel/uapi/linux/magic.h b/libc/kernel/uapi/linux/magic.h
index 38b5c85..ebbb58c 100644
--- a/libc/kernel/uapi/linux/magic.h
+++ b/libc/kernel/uapi/linux/magic.h
@@ -35,6 +35,7 @@
#define SQUASHFS_MAGIC 0x73717368
#define ECRYPTFS_SUPER_MAGIC 0xf15f
#define EFS_SUPER_MAGIC 0x414A53
+#define EROFS_SUPER_MAGIC_V1 0xE0F5E1E2
#define EXT2_SUPER_MAGIC 0xEF53
#define EXT3_SUPER_MAGIC 0xEF53
#define XENFS_SUPER_MAGIC 0xabba1974
@@ -67,6 +68,7 @@
#define REISERFS_SUPER_MAGIC_STRING "ReIsErFs"
#define REISER2FS_SUPER_MAGIC_STRING "ReIsEr2Fs"
#define REISER2FS_JR_SUPER_MAGIC_STRING "ReIsEr3Fs"
+#define SDCARDFS_SUPER_MAGIC 0x5dca2df5
#define SMB_SUPER_MAGIC 0x517B
#define CGROUP_SUPER_MAGIC 0x27e0eb
#define CGROUP2_SUPER_MAGIC 0x63677270
diff --git a/libc/kernel/uapi/linux/mdio.h b/libc/kernel/uapi/linux/mdio.h
index 14f1e77..3bbe433 100644
--- a/libc/kernel/uapi/linux/mdio.h
+++ b/libc/kernel/uapi/linux/mdio.h
@@ -47,11 +47,14 @@
#define MDIO_AN_ADVERTISE 16
#define MDIO_AN_LPA 19
#define MDIO_PCS_EEE_ABLE 20
+#define MDIO_PCS_EEE_ABLE2 21
#define MDIO_PMA_NG_EXTABLE 21
#define MDIO_PCS_EEE_WK_ERR 22
#define MDIO_PHYXS_LNSTAT 24
#define MDIO_AN_EEE_ADV 60
#define MDIO_AN_EEE_LPABLE 61
+#define MDIO_AN_EEE_ADV2 62
+#define MDIO_AN_EEE_LPABLE2 63
#define MDIO_PMA_10GBT_SWAPPOL 130
#define MDIO_PMA_10GBT_TXPWR 131
#define MDIO_PMA_10GBT_SNR 133
@@ -217,6 +220,12 @@
#define MDIO_EEE_1000KX 0x0010
#define MDIO_EEE_10GKX4 0x0020
#define MDIO_EEE_10GKR 0x0040
+#define MDIO_EEE_40GR_FW 0x0100
+#define MDIO_EEE_40GR_DS 0x0200
+#define MDIO_EEE_100GR_FW 0x1000
+#define MDIO_EEE_100GR_DS 0x2000
+#define MDIO_EEE_2_5GT 0x0001
+#define MDIO_EEE_5GT 0x0002
#define MDIO_PMA_NG_EXTABLE_2_5GBT 0x0001
#define MDIO_PMA_NG_EXTABLE_5GBT 0x0002
#define MDIO_PMA_LASI_RX_PHYXSLFLT 0x0001
diff --git a/libc/kernel/uapi/linux/media-bus-format.h b/libc/kernel/uapi/linux/media-bus-format.h
index 1b13002..f0d81d0 100644
--- a/libc/kernel/uapi/linux/media-bus-format.h
+++ b/libc/kernel/uapi/linux/media-bus-format.h
@@ -39,6 +39,7 @@
#define MEDIA_BUS_FMT_RGB888_1X24 0x100a
#define MEDIA_BUS_FMT_RGB888_2X12_BE 0x100b
#define MEDIA_BUS_FMT_RGB888_2X12_LE 0x100c
+#define MEDIA_BUS_FMT_RGB888_3X8 0x101c
#define MEDIA_BUS_FMT_RGB888_1X7X4_SPWG 0x1011
#define MEDIA_BUS_FMT_RGB888_1X7X4_JEIDA 0x1012
#define MEDIA_BUS_FMT_ARGB8888_1X32 0x100d
diff --git a/libc/kernel/uapi/linux/net_dropmon.h b/libc/kernel/uapi/linux/net_dropmon.h
index ec7f4ec..a3d9119 100644
--- a/libc/kernel/uapi/linux/net_dropmon.h
+++ b/libc/kernel/uapi/linux/net_dropmon.h
@@ -54,8 +54,58 @@
NET_DM_CMD_CONFIG,
NET_DM_CMD_START,
NET_DM_CMD_STOP,
+ NET_DM_CMD_PACKET_ALERT,
+ NET_DM_CMD_CONFIG_GET,
+ NET_DM_CMD_CONFIG_NEW,
+ NET_DM_CMD_STATS_GET,
+ NET_DM_CMD_STATS_NEW,
_NET_DM_CMD_MAX,
};
#define NET_DM_CMD_MAX (_NET_DM_CMD_MAX - 1)
#define NET_DM_GRP_ALERT 1
+enum net_dm_attr {
+ NET_DM_ATTR_UNSPEC,
+ NET_DM_ATTR_ALERT_MODE,
+ NET_DM_ATTR_PC,
+ NET_DM_ATTR_SYMBOL,
+ NET_DM_ATTR_IN_PORT,
+ NET_DM_ATTR_TIMESTAMP,
+ NET_DM_ATTR_PROTO,
+ NET_DM_ATTR_PAYLOAD,
+ NET_DM_ATTR_PAD,
+ NET_DM_ATTR_TRUNC_LEN,
+ NET_DM_ATTR_ORIG_LEN,
+ NET_DM_ATTR_QUEUE_LEN,
+ NET_DM_ATTR_STATS,
+ NET_DM_ATTR_HW_STATS,
+ NET_DM_ATTR_ORIGIN,
+ NET_DM_ATTR_HW_TRAP_GROUP_NAME,
+ NET_DM_ATTR_HW_TRAP_NAME,
+ NET_DM_ATTR_HW_ENTRIES,
+ NET_DM_ATTR_HW_ENTRY,
+ NET_DM_ATTR_HW_TRAP_COUNT,
+ NET_DM_ATTR_SW_DROPS,
+ NET_DM_ATTR_HW_DROPS,
+ __NET_DM_ATTR_MAX,
+ NET_DM_ATTR_MAX = __NET_DM_ATTR_MAX - 1
+};
+enum net_dm_alert_mode {
+ NET_DM_ALERT_MODE_SUMMARY,
+ NET_DM_ALERT_MODE_PACKET,
+};
+enum {
+ NET_DM_ATTR_PORT_NETDEV_IFINDEX,
+ NET_DM_ATTR_PORT_NETDEV_NAME,
+ __NET_DM_ATTR_PORT_MAX,
+ NET_DM_ATTR_PORT_MAX = __NET_DM_ATTR_PORT_MAX - 1
+};
+enum {
+ NET_DM_ATTR_STATS_DROPPED,
+ __NET_DM_ATTR_STATS_MAX,
+ NET_DM_ATTR_STATS_MAX = __NET_DM_ATTR_STATS_MAX - 1
+};
+enum net_dm_origin {
+ NET_DM_ORIGIN_SW,
+ NET_DM_ORIGIN_HW,
+};
#endif
diff --git a/libc/kernel/uapi/linux/netfilter/nf_tables.h b/libc/kernel/uapi/linux/netfilter/nf_tables.h
index ec6ac82..a0b1a08 100644
--- a/libc/kernel/uapi/linux/netfilter/nf_tables.h
+++ b/libc/kernel/uapi/linux/netfilter/nf_tables.h
@@ -324,6 +324,7 @@
enum nft_dynset_ops {
NFT_DYNSET_OP_ADD,
NFT_DYNSET_OP_UPDATE,
+ NFT_DYNSET_OP_DELETE,
};
enum nft_dynset_flags {
NFT_DYNSET_F_INV = (1 << 0),
@@ -420,6 +421,9 @@
NFT_META_OIFKIND,
NFT_META_BRI_IIFPVID,
NFT_META_BRI_IIFVPROTO,
+ NFT_META_TIME_NS,
+ NFT_META_TIME_DAY,
+ NFT_META_TIME_HOUR,
};
enum nft_rt_keys {
NFT_RT_CLASSID,
@@ -764,7 +768,8 @@
#define NFT_OBJECT_CT_TIMEOUT 7
#define NFT_OBJECT_SECMARK 8
#define NFT_OBJECT_CT_EXPECT 9
-#define __NFT_OBJECT_MAX 10
+#define NFT_OBJECT_SYNPROXY 10
+#define __NFT_OBJECT_MAX 11
#define NFT_OBJECT_MAX (__NFT_OBJECT_MAX - 1)
enum nft_object_attributes {
NFTA_OBJ_UNSPEC,
diff --git a/libc/kernel/uapi/linux/netfilter/nfnetlink_log.h b/libc/kernel/uapi/linux/netfilter/nfnetlink_log.h
index d3ed3bc..f6a2708 100644
--- a/libc/kernel/uapi/linux/netfilter/nfnetlink_log.h
+++ b/libc/kernel/uapi/linux/netfilter/nfnetlink_log.h
@@ -39,6 +39,13 @@
__aligned_be64 sec;
__aligned_be64 usec;
};
+enum nfulnl_vlan_attr {
+ NFULA_VLAN_UNSPEC,
+ NFULA_VLAN_PROTO,
+ NFULA_VLAN_TCI,
+ __NFULA_VLAN_MAX,
+};
+#define NFULA_VLAN_MAX (__NFULA_VLAN_MAX + 1)
enum nfulnl_attr_type {
NFULA_UNSPEC,
NFULA_PACKET_HDR,
@@ -60,6 +67,8 @@
NFULA_HWLEN,
NFULA_CT,
NFULA_CT_INFO,
+ NFULA_VLAN,
+ NFULA_L2HDR,
__NFULA_MAX
};
#define NFULA_MAX (__NFULA_MAX - 1)
diff --git a/libc/kernel/uapi/linux/netfilter/xt_IDLETIMER.h b/libc/kernel/uapi/linux/netfilter/xt_IDLETIMER.h
index 689da03..e1f0e33 100644
--- a/libc/kernel/uapi/linux/netfilter/xt_IDLETIMER.h
+++ b/libc/kernel/uapi/linux/netfilter/xt_IDLETIMER.h
@@ -20,9 +20,13 @@
#define _XT_IDLETIMER_H
#include <linux/types.h>
#define MAX_IDLETIMER_LABEL_SIZE 28
+#define NLMSG_MAX_SIZE 64
+#define NL_EVENT_TYPE_INACTIVE 0
+#define NL_EVENT_TYPE_ACTIVE 1
struct idletimer_tg_info {
__u32 timeout;
char label[MAX_IDLETIMER_LABEL_SIZE];
+ __u8 send_nl_msg;
struct idletimer_tg * timer __attribute__((aligned(8)));
};
#endif
diff --git a/libc/kernel/uapi/linux/netfilter/xt_policy.h b/libc/kernel/uapi/linux/netfilter/xt_policy.h
index c59959c..495aeb0 100644
--- a/libc/kernel/uapi/linux/netfilter/xt_policy.h
+++ b/libc/kernel/uapi/linux/netfilter/xt_policy.h
@@ -18,6 +18,7 @@
****************************************************************************/
#ifndef _XT_POLICY_H
#define _XT_POLICY_H
+#include <linux/netfilter.h>
#include <linux/types.h>
#include <linux/in.h>
#include <linux/in6.h>
diff --git a/libc/kernel/uapi/linux/netfilter_bridge/ebtables.h b/libc/kernel/uapi/linux/netfilter_bridge/ebtables.h
index e102756..7c8f435 100644
--- a/libc/kernel/uapi/linux/netfilter_bridge/ebtables.h
+++ b/libc/kernel/uapi/linux/netfilter_bridge/ebtables.h
@@ -83,7 +83,7 @@
union {
struct {
char name[EBT_EXTENSION_MAXNAMELEN];
- uint8_t revision;
+ __u8 revision;
};
struct xt_match * match;
} u;
@@ -94,7 +94,7 @@
union {
struct {
char name[EBT_EXTENSION_MAXNAMELEN];
- uint8_t revision;
+ __u8 revision;
};
struct xt_target * watcher;
} u;
@@ -105,7 +105,7 @@
union {
struct {
char name[EBT_EXTENSION_MAXNAMELEN];
- uint8_t revision;
+ __u8 revision;
};
struct xt_target * target;
} u;
diff --git a/libc/kernel/uapi/linux/netfilter_ipv4/ipt_LOG.h b/libc/kernel/uapi/linux/netfilter_ipv4/ipt_LOG.h
index a13ac94..c049244 100644
--- a/libc/kernel/uapi/linux/netfilter_ipv4/ipt_LOG.h
+++ b/libc/kernel/uapi/linux/netfilter_ipv4/ipt_LOG.h
@@ -18,7 +18,6 @@
****************************************************************************/
#ifndef _IPT_LOG_H
#define _IPT_LOG_H
-#warning "Please update iptables, this file will be removed soon!"
#define IPT_LOG_TCPSEQ 0x01
#define IPT_LOG_TCPOPT 0x02
#define IPT_LOG_IPOPT 0x04
diff --git a/libc/kernel/uapi/linux/netfilter_ipv6/ip6t_LOG.h b/libc/kernel/uapi/linux/netfilter_ipv6/ip6t_LOG.h
index e621e27..eb3f26a 100644
--- a/libc/kernel/uapi/linux/netfilter_ipv6/ip6t_LOG.h
+++ b/libc/kernel/uapi/linux/netfilter_ipv6/ip6t_LOG.h
@@ -18,7 +18,6 @@
****************************************************************************/
#ifndef _IP6T_LOG_H
#define _IP6T_LOG_H
-#warning "Please update iptables, this file will be removed soon!"
#define IP6T_LOG_TCPSEQ 0x01
#define IP6T_LOG_TCPOPT 0x02
#define IP6T_LOG_IPOPT 0x04
diff --git a/libc/kernel/uapi/linux/nfsd/cld.h b/libc/kernel/uapi/linux/nfsd/cld.h
index ed99e73..92b89c0 100644
--- a/libc/kernel/uapi/linux/nfsd/cld.h
+++ b/libc/kernel/uapi/linux/nfsd/cld.h
@@ -19,19 +19,31 @@
#ifndef _NFSD_CLD_H
#define _NFSD_CLD_H
#include <linux/types.h>
-#define CLD_UPCALL_VERSION 1
+#define CLD_UPCALL_VERSION 2
#define NFS4_OPAQUE_LIMIT 1024
+#ifndef SHA256_DIGEST_SIZE
+#define SHA256_DIGEST_SIZE 32
+#endif
enum cld_command {
Cld_Create,
Cld_Remove,
Cld_Check,
Cld_GraceDone,
Cld_GraceStart,
+ Cld_GetVersion,
};
struct cld_name {
__u16 cn_len;
unsigned char cn_id[NFS4_OPAQUE_LIMIT];
} __attribute__((packed));
+struct cld_princhash {
+ __u8 cp_len;
+ unsigned char cp_data[SHA256_DIGEST_SIZE];
+} __attribute__((packed));
+struct cld_clntinfo {
+ struct cld_name cc_name;
+ struct cld_princhash cc_princhash;
+} __attribute__((packed));
struct cld_msg {
__u8 cm_vers;
__u8 cm_cmd;
@@ -40,6 +52,24 @@
union {
__s64 cm_gracetime;
struct cld_name cm_name;
+ __u8 cm_version;
} __attribute__((packed)) cm_u;
} __attribute__((packed));
+struct cld_msg_v2 {
+ __u8 cm_vers;
+ __u8 cm_cmd;
+ __s16 cm_status;
+ __u32 cm_xid;
+ union {
+ struct cld_name cm_name;
+ __u8 cm_version;
+ struct cld_clntinfo cm_clntinfo;
+ } __attribute__((packed)) cm_u;
+} __attribute__((packed));
+struct cld_msg_hdr {
+ __u8 cm_vers;
+ __u8 cm_cmd;
+ __s16 cm_status;
+ __u32 cm_xid;
+} __attribute__((packed));
#endif
diff --git a/libc/kernel/uapi/linux/nl80211.h b/libc/kernel/uapi/linux/nl80211.h
index 082601d..fa2c035 100644
--- a/libc/kernel/uapi/linux/nl80211.h
+++ b/libc/kernel/uapi/linux/nl80211.h
@@ -27,6 +27,10 @@
#define NL80211_MULTICAST_GROUP_VENDOR "vendor"
#define NL80211_MULTICAST_GROUP_NAN "nan"
#define NL80211_MULTICAST_GROUP_TESTMODE "testmode"
+#define NL80211_EDMG_BW_CONFIG_MIN 4
+#define NL80211_EDMG_BW_CONFIG_MAX 15
+#define NL80211_EDMG_CHANNELS_MIN 1
+#define NL80211_EDMG_CHANNELS_MAX 0x3c
enum nl80211_commands {
NL80211_CMD_UNSPEC,
NL80211_CMD_GET_WIPHY,
@@ -465,6 +469,9 @@
NL80211_ATTR_STA_TX_POWER,
NL80211_ATTR_SAE_PASSWORD,
NL80211_ATTR_TWT_RESPONDER,
+ NL80211_ATTR_HE_OBSS_PD,
+ NL80211_ATTR_WIPHY_EDMG_CHANNELS,
+ NL80211_ATTR_WIPHY_EDMG_BW_CONFIG,
__NL80211_ATTR_AFTER_LAST,
NUM_NL80211_ATTR = __NL80211_ATTR_AFTER_LAST,
NL80211_ATTR_MAX = __NL80211_ATTR_AFTER_LAST - 1
@@ -638,6 +645,7 @@
NL80211_STA_INFO_TX_DURATION,
NL80211_STA_INFO_AIRTIME_WEIGHT,
NL80211_STA_INFO_AIRTIME_LINK_METRIC,
+ NL80211_STA_INFO_ASSOC_AT_BOOTTIME,
__NL80211_STA_INFO_AFTER_LAST,
NL80211_STA_INFO_MAX = __NL80211_STA_INFO_AFTER_LAST - 1
};
@@ -711,6 +719,8 @@
NL80211_BAND_ATTR_VHT_MCS_SET,
NL80211_BAND_ATTR_VHT_CAPA,
NL80211_BAND_ATTR_IFTYPE_DATA,
+ NL80211_BAND_ATTR_EDMG_CHANNELS,
+ NL80211_BAND_ATTR_EDMG_BW_CONFIG,
__NL80211_BAND_ATTR_AFTER_LAST,
NL80211_BAND_ATTR_MAX = __NL80211_BAND_ATTR_AFTER_LAST - 1
};
@@ -841,6 +851,7 @@
NL80211_SURVEY_INFO_TIME_TX,
NL80211_SURVEY_INFO_TIME_SCAN,
NL80211_SURVEY_INFO_PAD,
+ NL80211_SURVEY_INFO_TIME_BSS_RX,
__NL80211_SURVEY_INFO_AFTER_LAST,
NL80211_SURVEY_INFO_MAX = __NL80211_SURVEY_INFO_AFTER_LAST - 1
};
@@ -1064,6 +1075,7 @@
NL80211_BAND_2GHZ,
NL80211_BAND_5GHZ,
NL80211_BAND_60GHZ,
+ NL80211_BAND_6GHZ,
NUM_NL80211_BANDS,
};
enum nl80211_ps_state {
@@ -1633,4 +1645,11 @@
NUM_NL80211_PMSR_FTM_RESP_ATTR,
NL80211_PMSR_FTM_RESP_ATTR_MAX = NUM_NL80211_PMSR_FTM_RESP_ATTR - 1
};
+enum nl80211_obss_pd_attributes {
+ __NL80211_HE_OBSS_PD_ATTR_INVALID,
+ NL80211_HE_OBSS_PD_ATTR_MIN_OFFSET,
+ NL80211_HE_OBSS_PD_ATTR_MAX_OFFSET,
+ __NL80211_HE_OBSS_PD_ATTR_LAST,
+ NL80211_HE_OBSS_PD_ATTR_MAX = __NL80211_HE_OBSS_PD_ATTR_LAST - 1,
+};
#endif
diff --git a/libc/kernel/uapi/linux/nvme_ioctl.h b/libc/kernel/uapi/linux/nvme_ioctl.h
index 10d8b8f..f2a328e 100644
--- a/libc/kernel/uapi/linux/nvme_ioctl.h
+++ b/libc/kernel/uapi/linux/nvme_ioctl.h
@@ -53,6 +53,27 @@
__u32 timeout_ms;
__u32 result;
};
+struct nvme_passthru_cmd64 {
+ __u8 opcode;
+ __u8 flags;
+ __u16 rsvd1;
+ __u32 nsid;
+ __u32 cdw2;
+ __u32 cdw3;
+ __u64 metadata;
+ __u64 addr;
+ __u32 metadata_len;
+ __u32 data_len;
+ __u32 cdw10;
+ __u32 cdw11;
+ __u32 cdw12;
+ __u32 cdw13;
+ __u32 cdw14;
+ __u32 cdw15;
+ __u32 timeout_ms;
+ __u32 rsvd2;
+ __u64 result;
+};
#define nvme_admin_cmd nvme_passthru_cmd
#define NVME_IOCTL_ID _IO('N', 0x40)
#define NVME_IOCTL_ADMIN_CMD _IOWR('N', 0x41, struct nvme_admin_cmd)
@@ -61,4 +82,6 @@
#define NVME_IOCTL_RESET _IO('N', 0x44)
#define NVME_IOCTL_SUBSYS_RESET _IO('N', 0x45)
#define NVME_IOCTL_RESCAN _IO('N', 0x46)
+#define NVME_IOCTL_ADMIN64_CMD _IOWR('N', 0x47, struct nvme_passthru_cmd64)
+#define NVME_IOCTL_IO64_CMD _IOWR('N', 0x48, struct nvme_passthru_cmd64)
#endif
diff --git a/libc/kernel/uapi/linux/openvswitch.h b/libc/kernel/uapi/linux/openvswitch.h
index 2344ab1..581a371 100644
--- a/libc/kernel/uapi/linux/openvswitch.h
+++ b/libc/kernel/uapi/linux/openvswitch.h
@@ -70,6 +70,7 @@
};
#define OVS_DP_F_UNALIGNED (1 << 0)
#define OVS_DP_F_VPORT_PIDS (1 << 1)
+#define OVS_DP_F_TC_RECIRC_SHARING (1 << 2)
#define OVSP_LOCAL ((__u32) 0)
#define OVS_PACKET_FAMILY "ovs_packet"
#define OVS_PACKET_VERSION 0x1
diff --git a/libc/kernel/uapi/linux/pci_regs.h b/libc/kernel/uapi/linux/pci_regs.h
index bd4d98f..a3db220 100644
--- a/libc/kernel/uapi/linux/pci_regs.h
+++ b/libc/kernel/uapi/linux/pci_regs.h
@@ -500,6 +500,7 @@
#define PCI_EXP_SLTCTL_CCIE 0x0010
#define PCI_EXP_SLTCTL_HPIE 0x0020
#define PCI_EXP_SLTCTL_AIC 0x00c0
+#define PCI_EXP_SLTCTL_ATTN_IND_SHIFT 6
#define PCI_EXP_SLTCTL_ATTN_IND_ON 0x0040
#define PCI_EXP_SLTCTL_ATTN_IND_BLINK 0x0080
#define PCI_EXP_SLTCTL_ATTN_IND_OFF 0x00c0
@@ -611,7 +612,9 @@
#define PCI_EXT_CAP_ID_DPC 0x1D
#define PCI_EXT_CAP_ID_L1SS 0x1E
#define PCI_EXT_CAP_ID_PTM 0x1F
-#define PCI_EXT_CAP_ID_MAX PCI_EXT_CAP_ID_PTM
+#define PCI_EXT_CAP_ID_DLF 0x25
+#define PCI_EXT_CAP_ID_PL_16GT 0x26
+#define PCI_EXT_CAP_ID_MAX PCI_EXT_CAP_ID_PL_16GT
#define PCI_EXT_CAP_DSN_SIZEOF 12
#define PCI_EXT_CAP_MCAST_ENDPOINT_SIZEOF 40
#define PCI_ERR_UNCOR_STATUS 4
@@ -896,4 +899,10 @@
#define PCI_L1SS_CTL1_LTR_L12_TH_VALUE 0x03ff0000
#define PCI_L1SS_CTL1_LTR_L12_TH_SCALE 0xe0000000
#define PCI_L1SS_CTL2 0x0c
+#define PCI_DLF_CAP 0x04
+#define PCI_DLF_EXCHANGE_ENABLE 0x80000000
+#define PCI_PL_16GT_LE_CTRL 0x20
+#define PCI_PL_16GT_LE_CTRL_DSP_TX_PRESET_MASK 0x0000000F
+#define PCI_PL_16GT_LE_CTRL_USP_TX_PRESET_MASK 0x000000F0
+#define PCI_PL_16GT_LE_CTRL_USP_TX_PRESET_SHIFT 4
#endif
diff --git a/libc/kernel/uapi/linux/perf_event.h b/libc/kernel/uapi/linux/perf_event.h
index 9048588..229184f 100644
--- a/libc/kernel/uapi/linux/perf_event.h
+++ b/libc/kernel/uapi/linux/perf_event.h
@@ -198,7 +198,7 @@
};
__u64 sample_type;
__u64 read_format;
- __u64 disabled : 1, inherit : 1, pinned : 1, exclusive : 1, exclude_user : 1, exclude_kernel : 1, exclude_hv : 1, exclude_idle : 1, mmap : 1, comm : 1, freq : 1, inherit_stat : 1, enable_on_exec : 1, task : 1, watermark : 1, precise_ip : 2, mmap_data : 1, sample_id_all : 1, exclude_host : 1, exclude_guest : 1, exclude_callchain_kernel : 1, exclude_callchain_user : 1, mmap2 : 1, comm_exec : 1, use_clockid : 1, context_switch : 1, write_backward : 1, namespaces : 1, ksymbol : 1, bpf_event : 1, __reserved_1 : 33;
+ __u64 disabled : 1, inherit : 1, pinned : 1, exclusive : 1, exclude_user : 1, exclude_kernel : 1, exclude_hv : 1, exclude_idle : 1, mmap : 1, comm : 1, freq : 1, inherit_stat : 1, enable_on_exec : 1, task : 1, watermark : 1, precise_ip : 2, mmap_data : 1, sample_id_all : 1, exclude_host : 1, exclude_guest : 1, exclude_callchain_kernel : 1, exclude_callchain_user : 1, mmap2 : 1, comm_exec : 1, use_clockid : 1, context_switch : 1, write_backward : 1, namespaces : 1, ksymbol : 1, bpf_event : 1, aux_output : 1, __reserved_1 : 32;
union {
__u32 wakeup_events;
__u32 wakeup_watermark;
diff --git a/libc/kernel/uapi/linux/pg.h b/libc/kernel/uapi/linux/pg.h
index d837336..dd52282 100644
--- a/libc/kernel/uapi/linux/pg.h
+++ b/libc/kernel/uapi/linux/pg.h
@@ -16,6 +16,8 @@
***
****************************************************************************
****************************************************************************/
+#ifndef _UAPI_LINUX_PG_H
+#define _UAPI_LINUX_PG_H
#define PG_MAGIC 'P'
#define PG_RESET 'Z'
#define PG_COMMAND 'C'
@@ -34,3 +36,4 @@
int duration;
char pad[12];
};
+#endif
diff --git a/libc/kernel/uapi/linux/pkt_cls.h b/libc/kernel/uapi/linux/pkt_cls.h
index 0727916..cc5518c 100644
--- a/libc/kernel/uapi/linux/pkt_cls.h
+++ b/libc/kernel/uapi/linux/pkt_cls.h
@@ -137,6 +137,8 @@
TCA_POLICE_RESULT,
TCA_POLICE_TM,
TCA_POLICE_PAD,
+ TCA_POLICE_RATE64,
+ TCA_POLICE_PEAKRATE64,
__TCA_POLICE_MAX
#define TCA_POLICE_RESULT TCA_POLICE_RESULT
};
diff --git a/libc/kernel/uapi/linux/pkt_sched.h b/libc/kernel/uapi/linux/pkt_sched.h
index 15ee3b0..c287e8c 100644
--- a/libc/kernel/uapi/linux/pkt_sched.h
+++ b/libc/kernel/uapi/linux/pkt_sched.h
@@ -877,7 +877,8 @@
__TCA_TAPRIO_SCHED_MAX,
};
#define TCA_TAPRIO_SCHED_MAX (__TCA_TAPRIO_SCHED_MAX - 1)
-#define TCA_TAPRIO_ATTR_FLAG_TXTIME_ASSIST 0x1
+#define TCA_TAPRIO_ATTR_FLAG_TXTIME_ASSIST BIT(0)
+#define TCA_TAPRIO_ATTR_FLAG_FULL_OFFLOAD BIT(1)
enum {
TCA_TAPRIO_ATTR_UNSPEC,
TCA_TAPRIO_ATTR_PRIOMAP,
diff --git a/libc/kernel/uapi/linux/ppdev.h b/libc/kernel/uapi/linux/ppdev.h
index 8a891db..450d6fd 100644
--- a/libc/kernel/uapi/linux/ppdev.h
+++ b/libc/kernel/uapi/linux/ppdev.h
@@ -16,6 +16,8 @@
***
****************************************************************************
****************************************************************************/
+#ifndef _UAPI_LINUX_PPDEV_H
+#define _UAPI_LINUX_PPDEV_H
#define PP_IOCTL 'p'
#define PPSETMODE _IOW(PP_IOCTL, 0x80, int)
#define PPRSTATUS _IOR(PP_IOCTL, 0x81, unsigned char)
@@ -53,3 +55,4 @@
#define PP_FASTREAD (1 << 3)
#define PP_W91284PIC (1 << 4)
#define PP_FLAGMASK (PP_FASTWRITE | PP_FASTREAD | PP_W91284PIC)
+#endif
diff --git a/libc/kernel/uapi/linux/prctl.h b/libc/kernel/uapi/linux/prctl.h
index 9015e29..6e3426c 100644
--- a/libc/kernel/uapi/linux/prctl.h
+++ b/libc/kernel/uapi/linux/prctl.h
@@ -150,4 +150,9 @@
#define PR_PAC_APDAKEY (1UL << 2)
#define PR_PAC_APDBKEY (1UL << 3)
#define PR_PAC_APGAKEY (1UL << 4)
+#define PR_SET_TAGGED_ADDR_CTRL 55
+#define PR_GET_TAGGED_ADDR_CTRL 56
+#define PR_TAGGED_ADDR_ENABLE (1UL << 0)
+#define PR_SET_VMA 0x53564d41
+#define PR_SET_VMA_ANON_NAME 0
#endif
diff --git a/libc/kernel/uapi/linux/ptp_clock.h b/libc/kernel/uapi/linux/ptp_clock.h
index bef3fe2..8618101 100644
--- a/libc/kernel/uapi/linux/ptp_clock.h
+++ b/libc/kernel/uapi/linux/ptp_clock.h
@@ -23,6 +23,13 @@
#define PTP_ENABLE_FEATURE (1 << 0)
#define PTP_RISING_EDGE (1 << 1)
#define PTP_FALLING_EDGE (1 << 2)
+#define PTP_STRICT_FLAGS (1 << 3)
+#define PTP_EXTTS_EDGES (PTP_RISING_EDGE | PTP_FALLING_EDGE)
+#define PTP_EXTTS_VALID_FLAGS (PTP_ENABLE_FEATURE | PTP_RISING_EDGE | PTP_FALLING_EDGE | PTP_STRICT_FLAGS)
+#define PTP_EXTTS_V1_VALID_FLAGS (PTP_ENABLE_FEATURE | PTP_RISING_EDGE | PTP_FALLING_EDGE)
+#define PTP_PEROUT_ONE_SHOT (1 << 0)
+#define PTP_PEROUT_VALID_FLAGS (PTP_PEROUT_ONE_SHOT)
+#define PTP_PEROUT_V1_VALID_FLAGS (0)
struct ptp_clock_time {
__s64 sec;
__u32 nsec;
@@ -90,6 +97,15 @@
#define PTP_PIN_SETFUNC _IOW(PTP_CLK_MAGIC, 7, struct ptp_pin_desc)
#define PTP_SYS_OFFSET_PRECISE _IOWR(PTP_CLK_MAGIC, 8, struct ptp_sys_offset_precise)
#define PTP_SYS_OFFSET_EXTENDED _IOWR(PTP_CLK_MAGIC, 9, struct ptp_sys_offset_extended)
+#define PTP_CLOCK_GETCAPS2 _IOR(PTP_CLK_MAGIC, 10, struct ptp_clock_caps)
+#define PTP_EXTTS_REQUEST2 _IOW(PTP_CLK_MAGIC, 11, struct ptp_extts_request)
+#define PTP_PEROUT_REQUEST2 _IOW(PTP_CLK_MAGIC, 12, struct ptp_perout_request)
+#define PTP_ENABLE_PPS2 _IOW(PTP_CLK_MAGIC, 13, int)
+#define PTP_SYS_OFFSET2 _IOW(PTP_CLK_MAGIC, 14, struct ptp_sys_offset)
+#define PTP_PIN_GETFUNC2 _IOWR(PTP_CLK_MAGIC, 15, struct ptp_pin_desc)
+#define PTP_PIN_SETFUNC2 _IOW(PTP_CLK_MAGIC, 16, struct ptp_pin_desc)
+#define PTP_SYS_OFFSET_PRECISE2 _IOWR(PTP_CLK_MAGIC, 17, struct ptp_sys_offset_precise)
+#define PTP_SYS_OFFSET_EXTENDED2 _IOWR(PTP_CLK_MAGIC, 18, struct ptp_sys_offset_extended)
struct ptp_extts_event {
struct ptp_clock_time t;
unsigned int index;
diff --git a/libc/kernel/uapi/linux/raid/md_p.h b/libc/kernel/uapi/linux/raid/md_p.h
index 0bc6756..4ad444a 100644
--- a/libc/kernel/uapi/linux/raid/md_p.h
+++ b/libc/kernel/uapi/linux/raid/md_p.h
@@ -182,7 +182,8 @@
#define MD_FEATURE_JOURNAL 512
#define MD_FEATURE_PPL 1024
#define MD_FEATURE_MULTIPLE_PPLS 2048
-#define MD_FEATURE_ALL (MD_FEATURE_BITMAP_OFFSET | MD_FEATURE_RECOVERY_OFFSET | MD_FEATURE_RESHAPE_ACTIVE | MD_FEATURE_BAD_BLOCKS | MD_FEATURE_REPLACEMENT | MD_FEATURE_RESHAPE_BACKWARDS | MD_FEATURE_NEW_OFFSET | MD_FEATURE_RECOVERY_BITMAP | MD_FEATURE_CLUSTERED | MD_FEATURE_JOURNAL | MD_FEATURE_PPL | MD_FEATURE_MULTIPLE_PPLS)
+#define MD_FEATURE_RAID0_LAYOUT 4096
+#define MD_FEATURE_ALL (MD_FEATURE_BITMAP_OFFSET | MD_FEATURE_RECOVERY_OFFSET | MD_FEATURE_RESHAPE_ACTIVE | MD_FEATURE_BAD_BLOCKS | MD_FEATURE_REPLACEMENT | MD_FEATURE_RESHAPE_BACKWARDS | MD_FEATURE_NEW_OFFSET | MD_FEATURE_RECOVERY_BITMAP | MD_FEATURE_CLUSTERED | MD_FEATURE_JOURNAL | MD_FEATURE_PPL | MD_FEATURE_MULTIPLE_PPLS | MD_FEATURE_RAID0_LAYOUT)
struct r5l_payload_header {
__le16 type;
__le16 flags;
diff --git a/libc/kernel/uapi/linux/sched.h b/libc/kernel/uapi/linux/sched.h
index b396348..13a34ce 100644
--- a/libc/kernel/uapi/linux/sched.h
+++ b/libc/kernel/uapi/linux/sched.h
@@ -44,6 +44,7 @@
#define CLONE_NEWPID 0x20000000
#define CLONE_NEWNET 0x40000000
#define CLONE_IO 0x80000000
+#ifndef __ASSEMBLY__
struct clone_args {
__aligned_u64 flags;
__aligned_u64 pidfd;
@@ -54,6 +55,8 @@
__aligned_u64 stack_size;
__aligned_u64 tls;
};
+#endif
+#define CLONE_ARGS_SIZE_VER0 64
#define SCHED_NORMAL 0
#define SCHED_FIFO 1
#define SCHED_RR 2
diff --git a/libc/kernel/uapi/linux/sctp.h b/libc/kernel/uapi/linux/sctp.h
index 18c5d21..9a808ef 100644
--- a/libc/kernel/uapi/linux/sctp.h
+++ b/libc/kernel/uapi/linux/sctp.h
@@ -87,6 +87,9 @@
#define SCTP_INTERLEAVING_SUPPORTED 125
#define SCTP_SENDMSG_CONNECT 126
#define SCTP_EVENT 127
+#define SCTP_ASCONF_SUPPORTED 128
+#define SCTP_AUTH_SUPPORTED 129
+#define SCTP_ECN_SUPPORTED 130
#define SCTP_PR_SCTP_NONE 0x0000
#define SCTP_PR_SCTP_TTL 0x0010
#define SCTP_PR_SCTP_RTX 0x0020
diff --git a/libc/kernel/uapi/linux/serial_core.h b/libc/kernel/uapi/linux/serial_core.h
index 29fcdf4..37dfc16 100644
--- a/libc/kernel/uapi/linux/serial_core.h
+++ b/libc/kernel/uapi/linux/serial_core.h
@@ -92,7 +92,6 @@
#define PORT_S3C2412 73
#define PORT_UARTLITE 74
#define PORT_BFIN 75
-#define PORT_KS8695 76
#define PORT_SB1250_DUART 77
#define PORT_MCF 78
#define PORT_BFIN_SPORT 79
@@ -137,4 +136,6 @@
#define PORT_RDA 118
#define PORT_MLB_USIO 119
#define PORT_SIFIVE_V0 120
+#define PORT_SUNIX 121
+#define PORT_LINFLEXUART 122
#endif
diff --git a/libc/kernel/uapi/linux/serio.h b/libc/kernel/uapi/linux/serio.h
index 72149ee..5ef9de4 100644
--- a/libc/kernel/uapi/linux/serio.h
+++ b/libc/kernel/uapi/linux/serio.h
@@ -76,4 +76,5 @@
#define SERIO_EGALAX 0x3f
#define SERIO_PULSE8_CEC 0x40
#define SERIO_RAINSHADOW_CEC 0x41
+#define SERIO_FSIA6B 0x42
#endif
diff --git a/libc/kernel/uapi/linux/tcp.h b/libc/kernel/uapi/linux/tcp.h
index 1ec025f..4cae8d8 100644
--- a/libc/kernel/uapi/linux/tcp.h
+++ b/libc/kernel/uapi/linux/tcp.h
@@ -184,6 +184,8 @@
__u64 tcpi_bytes_retrans;
__u32 tcpi_dsack_dups;
__u32 tcpi_reord_seen;
+ __u32 tcpi_rcv_ooopack;
+ __u32 tcpi_snd_wnd;
};
enum {
TCP_NLA_PAD,
diff --git a/libc/kernel/uapi/linux/tls.h b/libc/kernel/uapi/linux/tls.h
index e188826..6949d65 100644
--- a/libc/kernel/uapi/linux/tls.h
+++ b/libc/kernel/uapi/linux/tls.h
@@ -75,4 +75,17 @@
unsigned char salt[TLS_CIPHER_AES_CCM_128_SALT_SIZE];
unsigned char rec_seq[TLS_CIPHER_AES_CCM_128_REC_SEQ_SIZE];
};
+enum {
+ TLS_INFO_UNSPEC,
+ TLS_INFO_VERSION,
+ TLS_INFO_CIPHER,
+ TLS_INFO_TXCONF,
+ TLS_INFO_RXCONF,
+ __TLS_INFO_MAX,
+};
+#define TLS_INFO_MAX (__TLS_INFO_MAX - 1)
+#define TLS_CONF_BASE 1
+#define TLS_CONF_SW 2
+#define TLS_CONF_HW 3
+#define TLS_CONF_HW_RECORD 4
#endif
diff --git a/libc/kernel/uapi/linux/usb/ch9.h b/libc/kernel/uapi/linux/usb/ch9.h
index 89d772a..2d69abd 100644
--- a/libc/kernel/uapi/linux/usb/ch9.h
+++ b/libc/kernel/uapi/linux/usb/ch9.h
@@ -380,6 +380,8 @@
#define USB_BESL_SUPPORT (1 << 2)
#define USB_BESL_BASELINE_VALID (1 << 3)
#define USB_BESL_DEEP_VALID (1 << 4)
+#define USB_SET_BESL_BASELINE(p) (((p) & 0xf) << 8)
+#define USB_SET_BESL_DEEP(p) (((p) & 0xf) << 12)
#define USB_GET_BESL_BASELINE(p) (((p) & (0xf << 8)) >> 8)
#define USB_GET_BESL_DEEP(p) (((p) & (0xf << 12)) >> 12)
} __attribute__((packed));
diff --git a/libc/kernel/android/uapi/linux/usb/f_accessory.h b/libc/kernel/uapi/linux/usb/f_accessory.h
similarity index 80%
rename from libc/kernel/android/uapi/linux/usb/f_accessory.h
rename to libc/kernel/uapi/linux/usb/f_accessory.h
index 75e017c..d4c5efe 100644
--- a/libc/kernel/android/uapi/linux/usb/f_accessory.h
+++ b/libc/kernel/uapi/linux/usb/f_accessory.h
@@ -20,34 +20,27 @@
#define _UAPI_LINUX_USB_F_ACCESSORY_H
#define USB_ACCESSORY_VENDOR_ID 0x18D1
#define USB_ACCESSORY_PRODUCT_ID 0x2D00
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
#define USB_ACCESSORY_ADB_PRODUCT_ID 0x2D01
#define ACCESSORY_STRING_MANUFACTURER 0
#define ACCESSORY_STRING_MODEL 1
#define ACCESSORY_STRING_DESCRIPTION 2
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
#define ACCESSORY_STRING_VERSION 3
#define ACCESSORY_STRING_URI 4
#define ACCESSORY_STRING_SERIAL 5
#define ACCESSORY_GET_PROTOCOL 51
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
#define ACCESSORY_SEND_STRING 52
#define ACCESSORY_START 53
#define ACCESSORY_REGISTER_HID 54
#define ACCESSORY_UNREGISTER_HID 55
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
#define ACCESSORY_SET_HID_REPORT_DESC 56
#define ACCESSORY_SEND_HID_EVENT 57
#define ACCESSORY_SET_AUDIO_MODE 58
#define ACCESSORY_GET_STRING_MANUFACTURER _IOW('M', 1, char[256])
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
#define ACCESSORY_GET_STRING_MODEL _IOW('M', 2, char[256])
#define ACCESSORY_GET_STRING_DESCRIPTION _IOW('M', 3, char[256])
#define ACCESSORY_GET_STRING_VERSION _IOW('M', 4, char[256])
#define ACCESSORY_GET_STRING_URI _IOW('M', 5, char[256])
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
#define ACCESSORY_GET_STRING_SERIAL _IOW('M', 6, char[256])
#define ACCESSORY_IS_START_REQUESTED _IO('M', 7)
#define ACCESSORY_GET_AUDIO_MODE _IO('M', 8)
#endif
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/uapi/linux/usbdevice_fs.h b/libc/kernel/uapi/linux/usbdevice_fs.h
index 03f3bfb..7936ad9 100644
--- a/libc/kernel/uapi/linux/usbdevice_fs.h
+++ b/libc/kernel/uapi/linux/usbdevice_fs.h
@@ -110,6 +110,7 @@
#define USBDEVFS_CAP_MMAP 0x20
#define USBDEVFS_CAP_DROP_PRIVILEGES 0x40
#define USBDEVFS_CAP_CONNINFO_EX 0x80
+#define USBDEVFS_CAP_SUSPEND 0x100
#define USBDEVFS_DISCONNECT_CLAIM_IF_DRIVER 0x01
#define USBDEVFS_DISCONNECT_CLAIM_EXCEPT_DRIVER 0x02
struct usbdevfs_disconnect_claim {
@@ -158,4 +159,7 @@
#define USBDEVFS_DROP_PRIVILEGES _IOW('U', 30, __u32)
#define USBDEVFS_GET_SPEED _IO('U', 31)
#define USBDEVFS_CONNINFO_EX(len) _IOC(_IOC_READ, 'U', 32, len)
+#define USBDEVFS_FORBID_SUSPEND _IO('U', 33)
+#define USBDEVFS_ALLOW_SUSPEND _IO('U', 34)
+#define USBDEVFS_WAIT_FOR_RESUME _IO('U', 35)
#endif
diff --git a/libc/kernel/uapi/linux/version.h b/libc/kernel/uapi/linux/version.h
index f78358d..7f3f9af 100644
--- a/libc/kernel/uapi/linux/version.h
+++ b/libc/kernel/uapi/linux/version.h
@@ -16,5 +16,5 @@
***
****************************************************************************
****************************************************************************/
-#define LINUX_VERSION_CODE 328450
+#define LINUX_VERSION_CODE 328704
#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
diff --git a/libc/kernel/uapi/linux/vfio.h b/libc/kernel/uapi/linux/vfio.h
index 62cd970..b9e7243 100644
--- a/libc/kernel/uapi/linux/vfio.h
+++ b/libc/kernel/uapi/linux/vfio.h
@@ -99,10 +99,13 @@
};
#define VFIO_REGION_TYPE_PCI_VENDOR_TYPE (1 << 31)
#define VFIO_REGION_TYPE_PCI_VENDOR_MASK (0xffff)
+#define VFIO_REGION_TYPE_GFX (1)
+#define VFIO_REGION_TYPE_CCW (2)
#define VFIO_REGION_SUBTYPE_INTEL_IGD_OPREGION (1)
#define VFIO_REGION_SUBTYPE_INTEL_IGD_HOST_CFG (2)
#define VFIO_REGION_SUBTYPE_INTEL_IGD_LPC_CFG (3)
-#define VFIO_REGION_TYPE_GFX (1)
+#define VFIO_REGION_SUBTYPE_NVIDIA_NVLINK2_RAM (1)
+#define VFIO_REGION_SUBTYPE_IBM_NVLINK2_ATSD (1)
#define VFIO_REGION_SUBTYPE_GFX_EDID (1)
struct vfio_region_gfx_edid {
__u32 edid_offset;
@@ -114,10 +117,7 @@
#define VFIO_DEVICE_GFX_LINK_STATE_UP 1
#define VFIO_DEVICE_GFX_LINK_STATE_DOWN 2
};
-#define VFIO_REGION_TYPE_CCW (2)
#define VFIO_REGION_SUBTYPE_CCW_ASYNC_CMD (1)
-#define VFIO_REGION_SUBTYPE_NVIDIA_NVLINK2_RAM (1)
-#define VFIO_REGION_SUBTYPE_IBM_NVLINK2_ATSD (1)
#define VFIO_REGION_INFO_CAP_MSIX_MAPPABLE 3
#define VFIO_REGION_INFO_CAP_NVLINK2_SSATGT 4
struct vfio_region_info_cap_nvlink2_ssatgt {
@@ -248,7 +248,20 @@
__u32 argsz;
__u32 flags;
#define VFIO_IOMMU_INFO_PGSIZES (1 << 0)
+#define VFIO_IOMMU_INFO_CAPS (1 << 1)
__u64 iova_pgsizes;
+ __u32 cap_offset;
+};
+#define VFIO_IOMMU_TYPE1_INFO_CAP_IOVA_RANGE 1
+struct vfio_iova_range {
+ __u64 start;
+ __u64 end;
+};
+struct vfio_iommu_type1_info_cap_iova_range {
+ struct vfio_info_cap_header header;
+ __u32 nr_iovas;
+ __u32 reserved;
+ struct vfio_iova_range iova_ranges[];
};
#define VFIO_IOMMU_GET_INFO _IO(VFIO_TYPE, VFIO_BASE + 12)
struct vfio_iommu_type1_dma_map {
diff --git a/libc/kernel/uapi/linux/videodev2.h b/libc/kernel/uapi/linux/videodev2.h
index e81697e..3d70691 100644
--- a/libc/kernel/uapi/linux/videodev2.h
+++ b/libc/kernel/uapi/linux/videodev2.h
@@ -24,7 +24,7 @@
#include <linux/types.h>
#include <linux/v4l2-common.h>
#include <linux/v4l2-controls.h>
-#define VIDEO_MAX_FRAME 32
+#define VIDEO_MAX_FRAME 64
#define VIDEO_MAX_PLANES 8
#define v4l2_fourcc(a,b,c,d) ((__u32) (a) | ((__u32) (b) << 8) | ((__u32) (c) << 16) | ((__u32) (d) << 24))
#define v4l2_fourcc_be(a,b,c,d) (v4l2_fourcc(a, b, c, d) | (1U << 31))
@@ -414,6 +414,8 @@
};
#define V4L2_FMT_FLAG_COMPRESSED 0x0001
#define V4L2_FMT_FLAG_EMULATED 0x0002
+#define V4L2_FMT_FLAG_CONTINUOUS_BYTESTREAM 0x0004
+#define V4L2_FMT_FLAG_DYN_RESOLUTION 0x0008
enum v4l2_frmsizetypes {
V4L2_FRMSIZE_TYPE_DISCRETE = 1,
V4L2_FRMSIZE_TYPE_CONTINUOUS = 2,
diff --git a/libc/kernel/android/uapi/linux/keychord.h b/libc/kernel/uapi/linux/virtio_fs.h
similarity index 72%
rename from libc/kernel/android/uapi/linux/keychord.h
rename to libc/kernel/uapi/linux/virtio_fs.h
index 5fd3912..41946e7 100644
--- a/libc/kernel/android/uapi/linux/keychord.h
+++ b/libc/kernel/uapi/linux/virtio_fs.h
@@ -16,16 +16,14 @@
***
****************************************************************************
****************************************************************************/
-#ifndef _UAPI_LINUX_KEYCHORD_H_
-#define _UAPI_LINUX_KEYCHORD_H_
-#include <linux/input.h>
-#define KEYCHORD_VERSION 1
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-struct input_keychord {
- __u16 version;
- __u16 id;
- __u16 count;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- __u16 keycodes[];
-};
+#ifndef _UAPI_LINUX_VIRTIO_FS_H
+#define _UAPI_LINUX_VIRTIO_FS_H
+#include <linux/types.h>
+#include <linux/virtio_ids.h>
+#include <linux/virtio_config.h>
+#include <linux/virtio_types.h>
+struct virtio_fs_config {
+ __u8 tag[36];
+ __u32 num_request_queues;
+} __attribute__((packed));
#endif
diff --git a/libc/kernel/uapi/linux/virtio_ids.h b/libc/kernel/uapi/linux/virtio_ids.h
index f7e1392..8e6712a 100644
--- a/libc/kernel/uapi/linux/virtio_ids.h
+++ b/libc/kernel/uapi/linux/virtio_ids.h
@@ -33,5 +33,6 @@
#define VIRTIO_ID_VSOCK 19
#define VIRTIO_ID_CRYPTO 20
#define VIRTIO_ID_IOMMU 23
+#define VIRTIO_ID_FS 26
#define VIRTIO_ID_PMEM 27
#endif
diff --git a/libc/kernel/uapi/linux/wait.h b/libc/kernel/uapi/linux/wait.h
index d14a597..385e882 100644
--- a/libc/kernel/uapi/linux/wait.h
+++ b/libc/kernel/uapi/linux/wait.h
@@ -30,4 +30,5 @@
#define P_ALL 0
#define P_PID 1
#define P_PGID 2
+#define P_PIDFD 3
#endif
diff --git a/libc/kernel/uapi/misc/habanalabs.h b/libc/kernel/uapi/misc/habanalabs.h
index 8fcf30f..ffc8c9f 100644
--- a/libc/kernel/uapi/misc/habanalabs.h
+++ b/libc/kernel/uapi/misc/habanalabs.h
@@ -23,20 +23,20 @@
#define GOYA_KMD_SRAM_RESERVED_SIZE_FROM_START 0x8000
enum goya_queue_id {
GOYA_QUEUE_ID_DMA_0 = 0,
- GOYA_QUEUE_ID_DMA_1,
- GOYA_QUEUE_ID_DMA_2,
- GOYA_QUEUE_ID_DMA_3,
- GOYA_QUEUE_ID_DMA_4,
- GOYA_QUEUE_ID_CPU_PQ,
- GOYA_QUEUE_ID_MME,
- GOYA_QUEUE_ID_TPC0,
- GOYA_QUEUE_ID_TPC1,
- GOYA_QUEUE_ID_TPC2,
- GOYA_QUEUE_ID_TPC3,
- GOYA_QUEUE_ID_TPC4,
- GOYA_QUEUE_ID_TPC5,
- GOYA_QUEUE_ID_TPC6,
- GOYA_QUEUE_ID_TPC7,
+ GOYA_QUEUE_ID_DMA_1 = 1,
+ GOYA_QUEUE_ID_DMA_2 = 2,
+ GOYA_QUEUE_ID_DMA_3 = 3,
+ GOYA_QUEUE_ID_DMA_4 = 4,
+ GOYA_QUEUE_ID_CPU_PQ = 5,
+ GOYA_QUEUE_ID_MME = 6,
+ GOYA_QUEUE_ID_TPC0 = 7,
+ GOYA_QUEUE_ID_TPC1 = 8,
+ GOYA_QUEUE_ID_TPC2 = 9,
+ GOYA_QUEUE_ID_TPC3 = 10,
+ GOYA_QUEUE_ID_TPC4 = 11,
+ GOYA_QUEUE_ID_TPC5 = 12,
+ GOYA_QUEUE_ID_TPC6 = 13,
+ GOYA_QUEUE_ID_TPC7 = 14,
GOYA_QUEUE_ID_SIZE
};
enum goya_engine_id {
@@ -66,6 +66,8 @@
#define HL_INFO_DRAM_USAGE 2
#define HL_INFO_HW_IDLE 3
#define HL_INFO_DEVICE_STATUS 4
+#define HL_INFO_DEVICE_UTILIZATION 6
+#define HL_INFO_HW_EVENTS_AGGREGATE 7
#define HL_INFO_VERSION_MAX_LEN 128
struct hl_info_hw_ip_info {
__u64 sram_base_address;
@@ -97,11 +99,18 @@
__u32 status;
__u32 pad;
};
+struct hl_info_device_utilization {
+ __u32 utilization;
+ __u32 pad;
+};
struct hl_info_args {
__u64 return_pointer;
__u32 return_size;
__u32 op;
- __u32 ctx_id;
+ union {
+ __u32 ctx_id;
+ __u32 period_ms;
+ };
__u32 pad;
};
#define HL_CB_OP_CREATE 0
diff --git a/libc/kernel/uapi/misc/xilinx_sdfec.h b/libc/kernel/uapi/misc/xilinx_sdfec.h
new file mode 100644
index 0000000..8dde40d
--- /dev/null
+++ b/libc/kernel/uapi/misc/xilinx_sdfec.h
@@ -0,0 +1,131 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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 __XILINX_SDFEC_H__
+#define __XILINX_SDFEC_H__
+#include <linux/types.h>
+#define XSDFEC_LDPC_SC_TABLE_ADDR_BASE (0x10000)
+#define XSDFEC_LDPC_SC_TABLE_ADDR_HIGH (0x10400)
+#define XSDFEC_LDPC_LA_TABLE_ADDR_BASE (0x18000)
+#define XSDFEC_LDPC_LA_TABLE_ADDR_HIGH (0x19000)
+#define XSDFEC_LDPC_QC_TABLE_ADDR_BASE (0x20000)
+#define XSDFEC_LDPC_QC_TABLE_ADDR_HIGH (0x28000)
+#define XSDFEC_SC_TABLE_DEPTH (XSDFEC_LDPC_SC_TABLE_ADDR_HIGH - XSDFEC_LDPC_SC_TABLE_ADDR_BASE)
+#define XSDFEC_LA_TABLE_DEPTH (XSDFEC_LDPC_LA_TABLE_ADDR_HIGH - XSDFEC_LDPC_LA_TABLE_ADDR_BASE)
+#define XSDFEC_QC_TABLE_DEPTH (XSDFEC_LDPC_QC_TABLE_ADDR_HIGH - XSDFEC_LDPC_QC_TABLE_ADDR_BASE)
+enum xsdfec_code {
+ XSDFEC_TURBO_CODE = 0,
+ XSDFEC_LDPC_CODE,
+};
+enum xsdfec_order {
+ XSDFEC_MAINTAIN_ORDER = 0,
+ XSDFEC_OUT_OF_ORDER,
+};
+enum xsdfec_turbo_alg {
+ XSDFEC_MAX_SCALE = 0,
+ XSDFEC_MAX_STAR,
+ XSDFEC_TURBO_ALG_MAX,
+};
+enum xsdfec_state {
+ XSDFEC_INIT = 0,
+ XSDFEC_STARTED,
+ XSDFEC_STOPPED,
+ XSDFEC_NEEDS_RESET,
+ XSDFEC_PL_RECONFIGURE,
+};
+enum xsdfec_axis_width {
+ XSDFEC_1x128b = 1,
+ XSDFEC_2x128b = 2,
+ XSDFEC_4x128b = 4,
+};
+enum xsdfec_axis_word_include {
+ XSDFEC_FIXED_VALUE = 0,
+ XSDFEC_IN_BLOCK,
+ XSDFEC_PER_AXI_TRANSACTION,
+ XSDFEC_AXIS_WORDS_INCLUDE_MAX,
+};
+struct xsdfec_turbo {
+ __u32 alg;
+ __u8 scale;
+};
+struct xsdfec_ldpc_params {
+ __u32 n;
+ __u32 k;
+ __u32 psize;
+ __u32 nlayers;
+ __u32 nqc;
+ __u32 nmqc;
+ __u32 nm;
+ __u32 norm_type;
+ __u32 no_packing;
+ __u32 special_qc;
+ __u32 no_final_parity;
+ __u32 max_schedule;
+ __u32 sc_off;
+ __u32 la_off;
+ __u32 qc_off;
+ __u32 * sc_table;
+ __u32 * la_table;
+ __u32 * qc_table;
+ __u16 code_id;
+};
+struct xsdfec_status {
+ __u32 state;
+ __s8 activity;
+};
+struct xsdfec_irq {
+ __s8 enable_isr;
+ __s8 enable_ecc_isr;
+};
+struct xsdfec_config {
+ __u32 code;
+ __u32 order;
+ __u32 din_width;
+ __u32 din_word_include;
+ __u32 dout_width;
+ __u32 dout_word_include;
+ struct xsdfec_irq irq;
+ __s8 bypass;
+ __s8 code_wr_protect;
+};
+struct xsdfec_stats {
+ __u32 isr_err_count;
+ __u32 cecc_count;
+ __u32 uecc_count;
+};
+struct xsdfec_ldpc_param_table_sizes {
+ __u32 sc_size;
+ __u32 la_size;
+ __u32 qc_size;
+};
+#define XSDFEC_MAGIC 'f'
+#define XSDFEC_START_DEV _IO(XSDFEC_MAGIC, 0)
+#define XSDFEC_STOP_DEV _IO(XSDFEC_MAGIC, 1)
+#define XSDFEC_GET_STATUS _IOR(XSDFEC_MAGIC, 2, struct xsdfec_status)
+#define XSDFEC_SET_IRQ _IOW(XSDFEC_MAGIC, 3, struct xsdfec_irq)
+#define XSDFEC_SET_TURBO _IOW(XSDFEC_MAGIC, 4, struct xsdfec_turbo)
+#define XSDFEC_ADD_LDPC_CODE_PARAMS _IOW(XSDFEC_MAGIC, 5, struct xsdfec_ldpc_params)
+#define XSDFEC_GET_CONFIG _IOR(XSDFEC_MAGIC, 6, struct xsdfec_config)
+#define XSDFEC_GET_TURBO _IOR(XSDFEC_MAGIC, 7, struct xsdfec_turbo)
+#define XSDFEC_SET_ORDER _IOW(XSDFEC_MAGIC, 8, unsigned long)
+#define XSDFEC_SET_BYPASS _IOW(XSDFEC_MAGIC, 9, bool)
+#define XSDFEC_IS_ACTIVE _IOR(XSDFEC_MAGIC, 10, bool)
+#define XSDFEC_CLEAR_STATS _IO(XSDFEC_MAGIC, 11)
+#define XSDFEC_GET_STATS _IOR(XSDFEC_MAGIC, 12, struct xsdfec_stats)
+#define XSDFEC_SET_DEFAULT_CONFIG _IO(XSDFEC_MAGIC, 13)
+#endif
diff --git a/libc/kernel/uapi/rdma/mlx5_user_ioctl_verbs.h b/libc/kernel/uapi/rdma/mlx5_user_ioctl_verbs.h
index 64bc843..dc2e69d 100644
--- a/libc/kernel/uapi/rdma/mlx5_user_ioctl_verbs.h
+++ b/libc/kernel/uapi/rdma/mlx5_user_ioctl_verbs.h
@@ -26,6 +26,7 @@
MLX5_IB_UAPI_FLOW_TABLE_TYPE_NIC_RX = 0x0,
MLX5_IB_UAPI_FLOW_TABLE_TYPE_NIC_TX = 0x1,
MLX5_IB_UAPI_FLOW_TABLE_TYPE_FDB = 0x2,
+ MLX5_IB_UAPI_FLOW_TABLE_TYPE_RDMA_RX = 0x3,
};
enum mlx5_ib_uapi_flow_action_packet_reformat_type {
MLX5_IB_UAPI_FLOW_ACTION_PACKET_REFORMAT_TYPE_L2_TUNNEL_TO_L2 = 0x0,
diff --git a/libc/kernel/uapi/scsi/scsi_bsg_fc.h b/libc/kernel/uapi/scsi/scsi_bsg_fc.h
index 2d76a05..8966f61 100644
--- a/libc/kernel/uapi/scsi/scsi_bsg_fc.h
+++ b/libc/kernel/uapi/scsi/scsi_bsg_fc.h
@@ -18,6 +18,7 @@
****************************************************************************/
#ifndef SCSI_BSG_FC_H
#define SCSI_BSG_FC_H
+#include <linux/types.h>
#define FC_DEFAULT_BSG_TIMEOUT (10 * HZ)
#define FC_BSG_CLS_MASK 0xF0000000
#define FC_BSG_HST_MASK 0x80000000
@@ -30,16 +31,16 @@
#define FC_BSG_RPT_ELS (FC_BSG_RPT_MASK | 0x00000001)
#define FC_BSG_RPT_CT (FC_BSG_RPT_MASK | 0x00000002)
struct fc_bsg_host_add_rport {
- uint8_t reserved;
- uint8_t port_id[3];
+ __u8 reserved;
+ __u8 port_id[3];
};
struct fc_bsg_host_del_rport {
- uint8_t reserved;
- uint8_t port_id[3];
+ __u8 reserved;
+ __u8 port_id[3];
};
struct fc_bsg_host_els {
- uint8_t command_code;
- uint8_t port_id[3];
+ __u8 command_code;
+ __u8 port_id[3];
};
#define FC_CTELS_STATUS_OK 0x00000000
#define FC_CTELS_STATUS_REJECT 0x00000001
@@ -48,38 +49,38 @@
#define FC_CTELS_STATUS_P_BSY 0x00000004
#define FC_CTELS_STATUS_F_BSY 0x00000006
struct fc_bsg_ctels_reply {
- uint32_t status;
+ __u32 status;
struct {
- uint8_t action;
- uint8_t reason_code;
- uint8_t reason_explanation;
- uint8_t vendor_unique;
+ __u8 action;
+ __u8 reason_code;
+ __u8 reason_explanation;
+ __u8 vendor_unique;
} rjt_data;
};
struct fc_bsg_host_ct {
- uint8_t reserved;
- uint8_t port_id[3];
- uint32_t preamble_word0;
- uint32_t preamble_word1;
- uint32_t preamble_word2;
+ __u8 reserved;
+ __u8 port_id[3];
+ __u32 preamble_word0;
+ __u32 preamble_word1;
+ __u32 preamble_word2;
};
struct fc_bsg_host_vendor {
- uint64_t vendor_id;
- uint32_t vendor_cmd[0];
+ __u64 vendor_id;
+ __u32 vendor_cmd[0];
};
struct fc_bsg_host_vendor_reply {
- uint32_t vendor_rsp[0];
+ __u32 vendor_rsp[0];
};
struct fc_bsg_rport_els {
- uint8_t els_code;
+ __u8 els_code;
};
struct fc_bsg_rport_ct {
- uint32_t preamble_word0;
- uint32_t preamble_word1;
- uint32_t preamble_word2;
+ __u32 preamble_word0;
+ __u32 preamble_word1;
+ __u32 preamble_word2;
};
struct fc_bsg_request {
- uint32_t msgcode;
+ __u32 msgcode;
union {
struct fc_bsg_host_add_rport h_addrport;
struct fc_bsg_host_del_rport h_delrport;
@@ -91,8 +92,8 @@
} rqst_data;
} __attribute__((packed));
struct fc_bsg_reply {
- uint32_t result;
- uint32_t reply_payload_rcv_len;
+ __u32 result;
+ __u32 reply_payload_rcv_len;
union {
struct fc_bsg_host_vendor_reply vendor_reply;
struct fc_bsg_ctels_reply ctels_reply;
diff --git a/libc/kernel/uapi/scsi/scsi_netlink.h b/libc/kernel/uapi/scsi/scsi_netlink.h
index ad6e52f..2e1b6cf 100644
--- a/libc/kernel/uapi/scsi/scsi_netlink.h
+++ b/libc/kernel/uapi/scsi/scsi_netlink.h
@@ -24,12 +24,12 @@
#define SCSI_NL_GRP_FC_EVENTS (1 << 2)
#define SCSI_NL_GRP_CNT 3
struct scsi_nl_hdr {
- uint8_t version;
- uint8_t transport;
- uint16_t magic;
- uint16_t msgtype;
- uint16_t msglen;
-} __attribute__((aligned(sizeof(uint64_t))));
+ __u8 version;
+ __u8 transport;
+ __u16 magic;
+ __u16 msgtype;
+ __u16 msglen;
+} __attribute__((aligned(sizeof(__u64))));
#define SCSI_NL_VERSION 1
#define SCSI_NL_MAGIC 0xA1B2
#define SCSI_NL_TRANSPORT 0
@@ -39,10 +39,10 @@
#define SCSI_NL_MSGALIGN(len) (((len) + 7) & ~7)
struct scsi_nl_host_vendor_msg {
struct scsi_nl_hdr snlh;
- uint64_t vendor_id;
- uint16_t host_no;
- uint16_t vmsg_datalen;
-} __attribute__((aligned(sizeof(uint64_t))));
+ __u64 vendor_id;
+ __u16 host_no;
+ __u16 vmsg_datalen;
+} __attribute__((aligned(sizeof(__u64))));
#define SCSI_NL_VID_TYPE_SHIFT 56
#define SCSI_NL_VID_TYPE_MASK ((__u64) 0xFF << SCSI_NL_VID_TYPE_SHIFT)
#define SCSI_NL_VID_TYPE_PCI ((__u64) 0x01 << SCSI_NL_VID_TYPE_SHIFT)
diff --git a/libc/kernel/uapi/scsi/scsi_netlink_fc.h b/libc/kernel/uapi/scsi/scsi_netlink_fc.h
index 9b374c7..ff92877 100644
--- a/libc/kernel/uapi/scsi/scsi_netlink_fc.h
+++ b/libc/kernel/uapi/scsi/scsi_netlink_fc.h
@@ -18,17 +18,18 @@
****************************************************************************/
#ifndef SCSI_NETLINK_FC_H
#define SCSI_NETLINK_FC_H
+#include <linux/types.h>
#include <scsi/scsi_netlink.h>
#define FC_NL_ASYNC_EVENT 0x0100
#define FC_NL_MSGALIGN(len) (((len) + 7) & ~7)
struct fc_nl_event {
struct scsi_nl_hdr snlh;
- uint64_t seconds;
- uint64_t vendor_id;
- uint16_t host_no;
- uint16_t event_datalen;
- uint32_t event_num;
- uint32_t event_code;
- uint32_t event_data;
-} __attribute__((aligned(sizeof(uint64_t))));
+ __u64 seconds;
+ __u64 vendor_id;
+ __u16 host_no;
+ __u16 event_datalen;
+ __u32 event_num;
+ __u32 event_code;
+ __u32 event_data;
+} __attribute__((aligned(sizeof(__u64))));
#endif
diff --git a/libc/kernel/uapi/sound/sof/abi.h b/libc/kernel/uapi/sound/sof/abi.h
index 0948673..f69ebae 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 8
+#define SOF_ABI_MINOR 10
#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 0f80cfa..b4af004 100644
--- a/libc/kernel/uapi/sound/sof/tokens.h
+++ b/libc/kernel/uapi/sound/sof/tokens.h
@@ -47,6 +47,7 @@
#define SOF_TKN_INTEL_SSP_FRAME_PULSE_WIDTH 503
#define SOF_TKN_INTEL_SSP_QUIRKS 504
#define SOF_TKN_INTEL_SSP_TDM_PADDING_PER_SLOT 505
+#define SOF_TKN_INTEL_SSP_BCLK_DELAY 506
#define SOF_TKN_INTEL_DMIC_DRIVER_VERSION 600
#define SOF_TKN_INTEL_DMIC_CLK_MIN 601
#define SOF_TKN_INTEL_DMIC_CLK_MAX 602
@@ -66,4 +67,6 @@
#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_ESAI_FIRST_TOKEN 1100
#endif
diff --git a/libc/libc.map.txt b/libc/libc.map.txt
index a4ab600..01c9b0c 100644
--- a/libc/libc.map.txt
+++ b/libc/libc.map.txt
@@ -1468,10 +1468,10 @@
__system_properties_init; # apex
# Used by libmemunreachable
- malloc_backtrace; # apex vndk
- malloc_disable; # apex vndk
- malloc_enable; # apex vndk
- malloc_iterate; # apex vndk
+ malloc_backtrace; # apex llndk
+ malloc_disable; # apex llndk
+ malloc_enable; # apex llndk
+ malloc_iterate; # apex llndk
# Used by libandroid_net
android_getaddrinfofornet; # apex
@@ -1521,11 +1521,6 @@
LIBC_PRIVATE {
global:
- ___Unwind_Backtrace; # arm
- ___Unwind_ForcedUnwind; # arm
- ___Unwind_RaiseException; # arm
- ___Unwind_Resume; # arm
- ___Unwind_Resume_or_Rethrow; # arm
__accept4; # arm x86 mips
__adddf3; # arm
__addsf3; # arm
@@ -1635,24 +1630,8 @@
__getdents64; # arm x86 mips
__gnu_ldivmod_helper; # arm
__gnu_uldivmod_helper; # arm
- __gnu_Unwind_Backtrace; # arm
- __gnu_unwind_execute; # arm
__gnu_Unwind_Find_exidx; # arm
- __gnu_Unwind_ForcedUnwind; # arm
__gnu_unwind_frame; # arm
- __gnu_Unwind_RaiseException; # arm
- __gnu_Unwind_Restore_VFP; # arm
- __gnu_Unwind_Restore_VFP_D; # arm
- __gnu_Unwind_Restore_VFP_D_16_to_31; # arm
- __gnu_Unwind_Restore_WMMXC; # arm
- __gnu_Unwind_Restore_WMMXD; # arm
- __gnu_Unwind_Resume; # arm
- __gnu_Unwind_Resume_or_Rethrow; # arm
- __gnu_Unwind_Save_VFP; # arm
- __gnu_Unwind_Save_VFP_D; # arm
- __gnu_Unwind_Save_VFP_D_16_to_31; # arm
- __gnu_Unwind_Save_WMMXC; # arm
- __gnu_Unwind_Save_WMMXD; # arm
__gtdf2; # arm
__gtsf2; # arm
__ledf2; # arm
@@ -1671,7 +1650,6 @@
__popcount_tab; # arm
__popcountsi2; # arm x86 mips
__pthread_gettid; # arm x86 mips
- __restore_core_regs; # arm
__sclose; # arm x86 mips
__sdidinit; # arm x86 mips
__set_errno; # arm x86 mips
@@ -1701,8 +1679,6 @@
_Unwind_Backtrace; # arm
_Unwind_Complete; # arm
_Unwind_DeleteException; # arm
- _Unwind_ForcedUnwind; # arm
- _Unwind_GetCFA; # arm
_Unwind_GetDataRelBase; # arm
_Unwind_GetLanguageSpecificData; # arm
_Unwind_GetRegionStart; # arm
@@ -1711,7 +1687,6 @@
_Unwind_Resume; # arm
_Unwind_Resume_or_Rethrow; # arm
_Unwind_VRS_Get; # arm
- _Unwind_VRS_Pop; # arm
_Unwind_VRS_Set; # arm
android_getaddrinfofornetcontext;
android_gethostbyaddrfornet;
@@ -1735,7 +1710,6 @@
memswap; # arm x86 mips
pthread_attr_getstackaddr; # arm x86 mips
pthread_attr_setstackaddr; # arm x86 mips
- restore_core_regs; # arm
SHA1Final; # arm x86 mips
SHA1Init; # arm x86 mips
SHA1Transform; # arm x86 mips
diff --git a/libc/malloc_debug/Android.bp b/libc/malloc_debug/Android.bp
index 7340f95..4256cc4 100644
--- a/libc/malloc_debug/Android.bp
+++ b/libc/malloc_debug/Android.bp
@@ -165,6 +165,7 @@
// ==============================================================
cc_test {
name: "malloc_debug_system_tests",
+ isolated: true,
include_dirs: [
"bionic/libc",
@@ -189,4 +190,5 @@
"-Werror",
"-O0",
],
+ test_suites: ["general-tests"],
}
diff --git a/libc/malloc_debug/exported32.map b/libc/malloc_debug/exported32.map
index 8ed37fa..f75d173 100644
--- a/libc/malloc_debug/exported32.map
+++ b/libc/malloc_debug/exported32.map
@@ -8,13 +8,13 @@
debug_free_malloc_leak_info;
debug_get_malloc_leak_info;
debug_initialize;
- debug_iterate;
debug_mallinfo;
debug_malloc;
debug_malloc_backtrace;
debug_malloc_disable;
debug_malloc_enable;
debug_malloc_info;
+ debug_malloc_iterate;
debug_malloc_usable_size;
debug_mallopt;
debug_memalign;
diff --git a/libc/malloc_debug/exported64.map b/libc/malloc_debug/exported64.map
index cdff88b..6dea58c 100644
--- a/libc/malloc_debug/exported64.map
+++ b/libc/malloc_debug/exported64.map
@@ -8,13 +8,13 @@
debug_free_malloc_leak_info;
debug_get_malloc_leak_info;
debug_initialize;
- debug_iterate;
debug_mallinfo;
debug_malloc;
debug_malloc_backtrace;
debug_malloc_disable;
debug_malloc_enable;
debug_malloc_info;
+ debug_malloc_iterate;
debug_malloc_usable_size;
debug_mallopt;
debug_memalign;
diff --git a/libc/malloc_debug/malloc_debug.cpp b/libc/malloc_debug/malloc_debug.cpp
index 3c0e630..c0765a9 100644
--- a/libc/malloc_debug/malloc_debug.cpp
+++ b/libc/malloc_debug/malloc_debug.cpp
@@ -91,8 +91,8 @@
int debug_mallopt(int param, int value);
int debug_malloc_info(int options, FILE* fp);
int debug_posix_memalign(void** memptr, size_t alignment, size_t size);
-int debug_iterate(uintptr_t base, size_t size,
- void (*callback)(uintptr_t base, size_t size, void* arg), void* arg);
+int debug_malloc_iterate(uintptr_t base, size_t size,
+ void (*callback)(uintptr_t base, size_t size, void* arg), void* arg);
void debug_malloc_disable();
void debug_malloc_enable();
@@ -841,7 +841,7 @@
return (*memptr != nullptr) ? 0 : ENOMEM;
}
-int debug_iterate(uintptr_t base, size_t size, void (*callback)(uintptr_t, size_t, void*),
+int debug_malloc_iterate(uintptr_t base, size_t size, void (*callback)(uintptr_t, size_t, void*),
void* arg) {
ScopedConcurrentLock lock;
if (g_debug->TrackPointers()) {
@@ -854,7 +854,7 @@
// An option that adds a header will add pointer tracking, so no need to
// check if headers are enabled.
- return g_dispatch->iterate(base, size, callback, arg);
+ return g_dispatch->malloc_iterate(base, size, callback, arg);
}
void debug_malloc_disable() {
diff --git a/libc/malloc_debug/tests/malloc_debug_system_tests.cpp b/libc/malloc_debug/tests/malloc_debug_system_tests.cpp
index 67bb8d9..9e612f0 100644
--- a/libc/malloc_debug/tests/malloc_debug_system_tests.cpp
+++ b/libc/malloc_debug/tests/malloc_debug_system_tests.cpp
@@ -50,6 +50,14 @@
static constexpr time_t kTimeoutSeconds = 10;
+extern "C" bool GetInitialArgs(const char*** args, size_t* num_args) {
+ static const char* initial_args[] = {"--slow_threshold_ms=30000",
+ "--deadline_threshold_ms=1200000"};
+ *args = initial_args;
+ *num_args = 2;
+ return true;
+}
+
static void Exec(const char* test_name, const char* debug_options, pid_t* pid, int exit_code = 0,
time_t timeout_seconds = kTimeoutSeconds) {
int fds[2];
@@ -71,6 +79,9 @@
args.push_back("--gtest_also_run_disabled_tests");
std::string filter_arg = std::string("--gtest_filter=") + test_name;
args.push_back(filter_arg.c_str());
+ // Need this because some code depends on exit codes from the test run
+ // but the isolation runner does not support that.
+ args.push_back("--no_isolate");
args.push_back(nullptr);
execv(args[0], reinterpret_cast<char* const*>(const_cast<char**>(args.data())));
exit(20);
@@ -179,14 +190,14 @@
time_t timeout_seconds = kTimeoutSeconds) {
std::string log_str;
time_t start = time(nullptr);
- bool found_all;
+ std::string missing_match;
while (true) {
GetLogStr(pid, &log_str);
- found_all = true;
+ missing_match.clear();
// Look for the expected strings.
for (auto str : match_strings) {
if (log_str.find(str) == std::string::npos) {
- found_all = false;
+ missing_match = str;
break;
}
}
@@ -195,14 +206,14 @@
for (auto str : no_match_strings) {
ASSERT_TRUE(log_str.find(str) == std::string::npos) << "Unexpectedly found '" << str << "' in log output:\n" << log_str;
}
- if (found_all) {
+ if (missing_match.empty()) {
return;
}
if ((time(nullptr) - start) > timeout_seconds) {
break;
}
}
- ASSERT_TRUE(found_all) << "Didn't find expected log output:\n" << log_str;
+ ASSERT_EQ("", missing_match) << "Didn't find expected log output:\n" << log_str;
}
TEST(MallocTests, DISABLED_smoke) {}
@@ -413,7 +424,7 @@
pid_t pid;
SCOPED_TRACE(testing::Message() << functions[i].name << " expected size " << functions[i].size);
std::string test = std::string("MallocTests.DISABLED_") + test_prefix + functions[i].name;
- EXPECT_NO_FATAL_FAILURE(Exec(test.c_str(), "verbose backtrace leak_track", &pid));
+ ASSERT_NO_FATAL_FAILURE(Exec(test.c_str(), "verbose backtrace leak_track", &pid));
std::string expected_leak = android::base::StringPrintf("leaked block of size %zu at", functions[i].size);
EXPECT_NO_FATAL_FAILURE(FindStrings(
diff --git a/libc/malloc_hooks/Android.bp b/libc/malloc_hooks/Android.bp
index 861c371..77b523e 100644
--- a/libc/malloc_hooks/Android.bp
+++ b/libc/malloc_hooks/Android.bp
@@ -47,7 +47,8 @@
// Unit Tests
// ==============================================================
cc_test {
- name: "malloc_hooks_unit_tests",
+ name: "malloc_hooks_system_tests",
+ isolated: true,
srcs: [
"tests/malloc_hooks_tests.cpp",
@@ -70,4 +71,5 @@
"-Wall",
"-Werror",
],
+ test_suites: ["general-tests"],
}
diff --git a/libc/malloc_hooks/exported32.map b/libc/malloc_hooks/exported32.map
index 293d9ac..2b02806 100644
--- a/libc/malloc_hooks/exported32.map
+++ b/libc/malloc_hooks/exported32.map
@@ -7,13 +7,13 @@
hooks_free_malloc_leak_info;
hooks_get_malloc_leak_info;
hooks_initialize;
- hooks_iterate;
hooks_mallinfo;
hooks_malloc;
hooks_malloc_backtrace;
hooks_malloc_disable;
hooks_malloc_enable;
hooks_malloc_info;
+ hooks_malloc_iterate;
hooks_malloc_usable_size;
hooks_mallopt;
hooks_memalign;
diff --git a/libc/malloc_hooks/exported64.map b/libc/malloc_hooks/exported64.map
index 340106b..59ec1f0 100644
--- a/libc/malloc_hooks/exported64.map
+++ b/libc/malloc_hooks/exported64.map
@@ -7,13 +7,13 @@
hooks_free_malloc_leak_info;
hooks_get_malloc_leak_info;
hooks_initialize;
- hooks_iterate;
hooks_mallinfo;
hooks_malloc;
hooks_malloc_backtrace;
hooks_malloc_disable;
hooks_malloc_enable;
hooks_malloc_info;
+ hooks_malloc_iterate;
hooks_malloc_usable_size;
hooks_mallopt;
hooks_memalign;
diff --git a/libc/malloc_hooks/malloc_hooks.cpp b/libc/malloc_hooks/malloc_hooks.cpp
index b1c1d50..1ba8696 100644
--- a/libc/malloc_hooks/malloc_hooks.cpp
+++ b/libc/malloc_hooks/malloc_hooks.cpp
@@ -67,7 +67,7 @@
struct mallinfo hooks_mallinfo();
int hooks_mallopt(int param, int value);
int hooks_posix_memalign(void** memptr, size_t alignment, size_t size);
-int hooks_iterate(uintptr_t base, size_t size,
+int hooks_malloc_iterate(uintptr_t base, size_t size,
void (*callback)(uintptr_t base, size_t size, void* arg), void* arg);
void hooks_malloc_disable();
void hooks_malloc_enable();
@@ -209,7 +209,7 @@
return g_dispatch->posix_memalign(memptr, alignment, size);
}
-int hooks_iterate(uintptr_t, size_t, void (*)(uintptr_t, size_t, void*), void*) {
+int hooks_malloc_iterate(uintptr_t, size_t, void (*)(uintptr_t, size_t, void*), void*) {
return 0;
}
diff --git a/libc/platform/bionic/mte_kernel.h b/libc/platform/bionic/mte_kernel.h
index 04f2bb6..804311c 100644
--- a/libc/platform/bionic/mte_kernel.h
+++ b/libc/platform/bionic/mte_kernel.h
@@ -36,6 +36,16 @@
// This interface should not be considered to be stable.
#ifdef ANDROID_EXPERIMENTAL_MTE
-#define HWCAP2_MTE (1UL << 31)
-#define PROT_MTE 0x10
+
+#define HWCAP2_MTE (1 << 10)
+#define PROT_MTE 0x20
+
+#define PR_MTE_TCF_SHIFT 1
+#define PR_MTE_TCF_NONE (0UL << PR_MTE_TCF_SHIFT)
+#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)
+
#endif
diff --git a/libc/private/bionic_page.h b/libc/platform/bionic/page.h
similarity index 92%
rename from libc/private/bionic_page.h
rename to libc/platform/bionic/page.h
index 0beb708..d063a98 100644
--- a/libc/private/bionic_page.h
+++ b/libc/platform/bionic/page.h
@@ -14,8 +14,7 @@
* limitations under the License.
*/
-#ifndef _BIONIC_PAGE_H_
-#define _BIONIC_PAGE_H_
+#pragma once
// Get PAGE_SIZE and PAGE_MASK.
#include <sys/user.h>
@@ -29,5 +28,3 @@
// Returns the address of the next page after address 'x', unless 'x' is
// itself at the start of a page.
#define PAGE_END(x) PAGE_START((x) + (PAGE_SIZE-1))
-
-#endif // _BIONIC_PAGE_H_
diff --git a/libc/private/CFIShadow.h b/libc/private/CFIShadow.h
index 1423d86..84fbea5 100644
--- a/libc/private/CFIShadow.h
+++ b/libc/private/CFIShadow.h
@@ -19,7 +19,7 @@
#include <stdint.h>
-#include "private/bionic_page.h"
+#include "platform/bionic/page.h"
#include "private/bionic_macros.h"
constexpr unsigned kLibraryAlignmentBits = 18;
diff --git a/libc/private/bionic_malloc_dispatch.h b/libc/private/bionic_malloc_dispatch.h
index aea3a1c..52d8573 100644
--- a/libc/private/bionic_malloc_dispatch.h
+++ b/libc/private/bionic_malloc_dispatch.h
@@ -70,7 +70,7 @@
#if defined(HAVE_DEPRECATED_MALLOC_FUNCS)
MallocValloc valloc;
#endif
- MallocIterate iterate;
+ MallocIterate malloc_iterate;
MallocMallocDisable malloc_disable;
MallocMallocEnable malloc_enable;
MallocMallopt mallopt;
diff --git a/libc/system_properties/include/system_properties/prop_area.h b/libc/system_properties/include/system_properties/prop_area.h
index a69f90e..53b2745 100644
--- a/libc/system_properties/include/system_properties/prop_area.h
+++ b/libc/system_properties/include/system_properties/prop_area.h
@@ -106,6 +106,20 @@
memset(reserved_, 0, sizeof(reserved_));
// Allocate enough space for the root node.
bytes_used_ = sizeof(prop_bt);
+ // To make property reads wait-free, we reserve a
+ // PROP_VALUE_MAX-sized block of memory, the "dirty backup area",
+ // just after the root node. When we're about to modify a
+ // property, we copy the old value into the dirty backup area and
+ // copy the new value into the prop_info structure. Before
+ // starting the latter copy, we mark the property's serial as
+ // being dirty. If a reader comes along while we're doing the
+ // property update and sees a dirty serial, the reader copies from
+ // the dirty backup area instead of the property value
+ // proper. After the copy, the reader checks whether the property
+ // serial is the same: if it is, the dirty backup area hasn't been
+ // reused for something else and we can complete the
+ // read immediately.
+ bytes_used_ += __BIONIC_ALIGN(PROP_VALUE_MAX, sizeof(uint_least32_t));
}
const prop_info* find(const char* name);
@@ -122,6 +136,9 @@
uint32_t version() const {
return version_;
}
+ char* dirty_backup_area() {
+ return data_ + sizeof (prop_bt);
+ }
private:
static prop_area* map_fd_ro(const int fd);
diff --git a/libc/system_properties/include/system_properties/system_properties.h b/libc/system_properties/include/system_properties/system_properties.h
index cad29cc..0666e28 100644
--- a/libc/system_properties/include/system_properties/system_properties.h
+++ b/libc/system_properties/include/system_properties/system_properties.h
@@ -66,7 +66,6 @@
int Get(const char* name, char* value);
int Update(prop_info* pi, const char* value, unsigned int len);
int Add(const char* name, unsigned int namelen, const char* value, unsigned int valuelen);
- uint32_t Serial(const prop_info* pi);
uint32_t WaitAny(uint32_t old_serial);
bool Wait(const prop_info* pi, uint32_t old_serial, uint32_t* new_serial_ptr,
const timespec* relative_timeout);
@@ -74,6 +73,8 @@
int Foreach(void (*propfn)(const prop_info* pi, void* cookie), void* cookie);
private:
+ uint32_t ReadMutablePropertyValue(const prop_info* pi, char* value);
+
// We don't want to use new or malloc in properties (b/31659220), and we don't want to waste a
// full page by using mmap(), so we set aside enough space to create any context of the three
// contexts.
diff --git a/libc/system_properties/system_properties.cpp b/libc/system_properties/system_properties.cpp
index d7c441b..8404778 100644
--- a/libc/system_properties/system_properties.cpp
+++ b/libc/system_properties/system_properties.cpp
@@ -140,42 +140,58 @@
return strncmp(name, "ro.", 3) == 0;
}
-int SystemProperties::Read(const prop_info* pi, char* name, char* value) {
- while (true) {
- uint32_t serial = Serial(pi); // acquire semantics
- size_t len = SERIAL_VALUE_LEN(serial);
- memcpy(value, pi->value, len + 1);
- // TODO: Fix the synchronization scheme here.
- // There is no fully supported way to implement this kind
- // of synchronization in C++11, since the memcpy races with
- // updates to pi, and the data being accessed is not atomic.
- // The following fence is unintuitive, but would be the
- // correct one if memcpy used memory_order_relaxed atomic accesses.
- // In practice it seems unlikely that the generated code would
- // would be any different, so this should be OK.
+uint32_t SystemProperties::ReadMutablePropertyValue(const prop_info* pi, char* value) {
+ // We assume the memcpy below gets serialized by the acquire fence.
+ uint32_t new_serial = load_const_atomic(&pi->serial, memory_order_acquire);
+ uint32_t serial;
+ unsigned int len;
+ for (;;) {
+ serial = new_serial;
+ len = SERIAL_VALUE_LEN(serial);
+ if (__predict_false(SERIAL_DIRTY(serial))) {
+ // See the comment in the prop_area constructor.
+ prop_area* pa = contexts_->GetPropAreaForName(pi->name);
+ memcpy(value, pa->dirty_backup_area(), len + 1);
+ } else {
+ memcpy(value, pi->value, len + 1);
+ }
atomic_thread_fence(memory_order_acquire);
- if (serial == load_const_atomic(&(pi->serial), memory_order_relaxed)) {
- if (name != nullptr) {
- size_t namelen = strlcpy(name, pi->name, PROP_NAME_MAX);
- if (namelen >= PROP_NAME_MAX) {
- async_safe_format_log(ANDROID_LOG_ERROR, "libc",
- "The property name length for \"%s\" is >= %d;"
- " please use __system_property_read_callback"
- " to read this property. (the name is truncated to \"%s\")",
- pi->name, PROP_NAME_MAX - 1, name);
- }
- }
- if (is_read_only(pi->name) && pi->is_long()) {
- async_safe_format_log(
- ANDROID_LOG_ERROR, "libc",
- "The property \"%s\" has a value with length %zu that is too large for"
- " __system_property_get()/__system_property_read(); use"
- " __system_property_read_callback() instead.",
- pi->name, strlen(pi->long_value()));
- }
- return len;
+ new_serial = load_const_atomic(&pi->serial, memory_order_relaxed);
+ if (__predict_true(serial == new_serial)) {
+ break;
+ }
+ // We need another fence here because we want to ensure that the memcpy in the
+ // next iteration of the loop occurs after the load of new_serial above. We could
+ // get this guarantee by making the load_const_atomic of new_serial
+ // memory_order_acquire instead of memory_order_relaxed, but then we'd pay the
+ // penalty of the memory_order_acquire even in the overwhelmingly common case
+ // that the serial number didn't change.
+ atomic_thread_fence(memory_order_acquire);
+ }
+ return serial;
+}
+
+int SystemProperties::Read(const prop_info* pi, char* name, char* value) {
+ uint32_t serial = ReadMutablePropertyValue(pi, value);
+ if (name != nullptr) {
+ size_t namelen = strlcpy(name, pi->name, PROP_NAME_MAX);
+ if (namelen >= PROP_NAME_MAX) {
+ async_safe_format_log(ANDROID_LOG_ERROR, "libc",
+ "The property name length for \"%s\" is >= %d;"
+ " please use __system_property_read_callback"
+ " to read this property. (the name is truncated to \"%s\")",
+ pi->name, PROP_NAME_MAX - 1, name);
}
}
+ if (is_read_only(pi->name) && pi->is_long()) {
+ async_safe_format_log(
+ ANDROID_LOG_ERROR, "libc",
+ "The property \"%s\" has a value with length %zu that is too large for"
+ " __system_property_get()/__system_property_read(); use"
+ " __system_property_read_callback() instead.",
+ pi->name, strlen(pi->long_value()));
+ }
+ return SERIAL_VALUE_LEN(serial);
}
void SystemProperties::ReadCallback(const prop_info* pi,
@@ -183,9 +199,9 @@
const char* value, uint32_t serial),
void* cookie) {
// Read only properties don't need to copy the value to a temporary buffer, since it can never
- // change.
+ // change. We use relaxed memory order on the serial load for the same reason.
if (is_read_only(pi->name)) {
- uint32_t serial = Serial(pi);
+ uint32_t serial = load_const_atomic(&pi->serial, memory_order_relaxed);
if (pi->is_long()) {
callback(cookie, pi->name, pi->long_value(), serial);
} else {
@@ -194,21 +210,9 @@
return;
}
- while (true) {
- uint32_t serial = Serial(pi); // acquire semantics
- size_t len = SERIAL_VALUE_LEN(serial);
- char value_buf[len + 1];
-
- memcpy(value_buf, pi->value, len);
- value_buf[len] = '\0';
-
- // TODO: see todo in Read function
- atomic_thread_fence(memory_order_acquire);
- if (serial == load_const_atomic(&(pi->serial), memory_order_relaxed)) {
- callback(cookie, pi->name, value_buf, serial);
- return;
- }
- }
+ char value_buf[PROP_VALUE_MAX];
+ uint32_t serial = ReadMutablePropertyValue(pi, value_buf);
+ callback(cookie, pi->name, value_buf, serial);
}
int SystemProperties::Get(const char* name, char* value) {
@@ -231,26 +235,37 @@
return -1;
}
- prop_area* pa = contexts_->GetSerialPropArea();
- if (!pa) {
+ prop_area* serial_pa = contexts_->GetSerialPropArea();
+ if (!serial_pa) {
+ return -1;
+ }
+ prop_area* pa = contexts_->GetPropAreaForName(pi->name);
+ if (__predict_false(!pa)) {
+ async_safe_format_log(ANDROID_LOG_ERROR, "libc", "Could not find area for \"%s\"", pi->name);
return -1;
}
uint32_t serial = atomic_load_explicit(&pi->serial, memory_order_relaxed);
+ unsigned int old_len = SERIAL_VALUE_LEN(serial);
+
+ // The contract with readers is that whenever the dirty bit is set, an undamaged copy
+ // of the pre-dirty value is available in the dirty backup area. The fence ensures
+ // that we publish our dirty area update before allowing readers to see a
+ // dirty serial.
+ memcpy(pa->dirty_backup_area(), pi->value, old_len + 1);
+ atomic_thread_fence(memory_order_release);
serial |= 1;
atomic_store_explicit(&pi->serial, serial, memory_order_relaxed);
- // The memcpy call here also races. Again pretend it
- // used memory_order_relaxed atomics, and use the analogous
- // counterintuitive fence.
- atomic_thread_fence(memory_order_release);
strlcpy(pi->value, value, len + 1);
-
- atomic_store_explicit(&pi->serial, (len << 24) | ((serial + 1) & 0xffffff), memory_order_release);
- __futex_wake(&pi->serial, INT32_MAX);
-
- atomic_store_explicit(pa->serial(), atomic_load_explicit(pa->serial(), memory_order_relaxed) + 1,
+ // Now the primary value property area is up-to-date. Let readers know that they should
+ // look at the property value instead of the backup area.
+ atomic_thread_fence(memory_order_release);
+ atomic_store_explicit(&pi->serial, (len << 24) | ((serial + 1) & 0xffffff), memory_order_relaxed);
+ __futex_wake(&pi->serial, INT32_MAX); // Fence by side effect
+ atomic_store_explicit(serial_pa->serial(),
+ atomic_load_explicit(serial_pa->serial(), memory_order_relaxed) + 1,
memory_order_release);
- __futex_wake(pa->serial(), INT32_MAX);
+ __futex_wake(serial_pa->serial(), INT32_MAX);
return 0;
}
@@ -294,16 +309,6 @@
return 0;
}
-// Wait for non-locked serial, and retrieve it with acquire semantics.
-uint32_t SystemProperties::Serial(const prop_info* pi) {
- uint32_t serial = load_const_atomic(&pi->serial, memory_order_acquire);
- while (SERIAL_DIRTY(serial)) {
- __futex_wait(const_cast<_Atomic(uint_least32_t)*>(&pi->serial), serial, nullptr);
- serial = load_const_atomic(&pi->serial, memory_order_acquire);
- }
- return serial;
-}
-
uint32_t SystemProperties::WaitAny(uint32_t old_serial) {
uint32_t new_serial;
Wait(nullptr, old_serial, &new_serial, nullptr);
diff --git a/libc/upstream-openbsd/android/include/openbsd-compat.h b/libc/upstream-openbsd/android/include/openbsd-compat.h
index afd1077..878f71c 100644
--- a/libc/upstream-openbsd/android/include/openbsd-compat.h
+++ b/libc/upstream-openbsd/android/include/openbsd-compat.h
@@ -19,6 +19,8 @@
#define _BSD_SOURCE
#include <sys/cdefs.h>
+#include <unistd.h> // For environ.
+
#include <stddef.h> // For size_t.
#include <sys/random.h> // For getentropy.
diff --git a/libc/upstream-openbsd/lib/libc/crypt/arc4random_uniform.c b/libc/upstream-openbsd/lib/libc/crypt/arc4random_uniform.c
index 23a15e3..a18b5b1 100644
--- a/libc/upstream-openbsd/lib/libc/crypt/arc4random_uniform.c
+++ b/libc/upstream-openbsd/lib/libc/crypt/arc4random_uniform.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: arc4random_uniform.c,v 1.2 2015/09/13 08:31:47 guenther Exp $ */
+/* $OpenBSD: arc4random_uniform.c,v 1.3 2019/01/20 02:59:07 bcook Exp $ */
/*
* Copyright (c) 2008, Damien Miller <djm@openbsd.org>
@@ -16,7 +16,7 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#include <sys/types.h>
+#include <stdint.h>
#include <stdlib.h>
/*
diff --git a/libc/upstream-openbsd/lib/libc/gen/alarm.c b/libc/upstream-openbsd/lib/libc/gen/alarm.c
index 8bca23a..f15dd15 100644
--- a/libc/upstream-openbsd/lib/libc/gen/alarm.c
+++ b/libc/upstream-openbsd/lib/libc/gen/alarm.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: alarm.c,v 1.8 2016/01/28 16:40:54 schwarze Exp $ */
+/* $OpenBSD: alarm.c,v 1.9 2019/06/28 13:32:41 deraadt Exp $ */
/*
* Copyright (c) 1983, 1993
* The Regents of the University of California. All rights reserved.
@@ -40,7 +40,7 @@
timerclear(&itp->it_interval);
itp->it_value.tv_sec = secs;
itp->it_value.tv_usec = 0;
- if (setitimer(ITIMER_REAL, itp, &oitv) < 0)
+ if (setitimer(ITIMER_REAL, itp, &oitv) == -1)
return ((unsigned int) -1);
if (oitv.it_value.tv_usec)
oitv.it_value.tv_sec++;
diff --git a/libc/upstream-openbsd/lib/libc/gen/charclass.h b/libc/upstream-openbsd/lib/libc/gen/charclass.h
index 5edb2c1..073baf6 100644
--- a/libc/upstream-openbsd/lib/libc/gen/charclass.h
+++ b/libc/upstream-openbsd/lib/libc/gen/charclass.h
@@ -1,7 +1,7 @@
/*
- * Public domain, 2008, Todd C. Miller <Todd.Miller@courtesan.com>
+ * Public domain, 2008, Todd C. Miller <millert@openbsd.org>
*
- * $OpenBSD: charclass.h,v 1.1 2008/10/01 23:04:13 millert Exp $
+ * $OpenBSD: charclass.h,v 1.2 2019/01/25 00:19:25 millert Exp $
*/
/*
diff --git a/libc/upstream-openbsd/lib/libc/gen/ftok.c b/libc/upstream-openbsd/lib/libc/gen/ftok.c
index 387b80f..ea1edf1 100644
--- a/libc/upstream-openbsd/lib/libc/gen/ftok.c
+++ b/libc/upstream-openbsd/lib/libc/gen/ftok.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ftok.c,v 1.8 2014/11/15 22:38:47 guenther Exp $ */
+/* $OpenBSD: ftok.c,v 1.9 2019/06/28 13:32:41 deraadt Exp $ */
/*
* Copyright (c) 1994 SigmaSoft, Th. Lockert <tholo@sigmasoft.com>
* All rights reserved.
@@ -34,7 +34,7 @@
{
struct stat st;
- if (stat(path, &st) < 0)
+ if (stat(path, &st) == -1)
return (key_t)-1;
return (key_t)
diff --git a/libc/upstream-openbsd/lib/libc/gen/setprogname.c b/libc/upstream-openbsd/lib/libc/gen/setprogname.c
index ec3189f..bce4cbd 100644
--- a/libc/upstream-openbsd/lib/libc/gen/setprogname.c
+++ b/libc/upstream-openbsd/lib/libc/gen/setprogname.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: setprogname.c,v 1.5 2016/03/13 18:34:20 guenther Exp $ */
+/* $OpenBSD: setprogname.c,v 1.6 2017/09/17 06:38:03 otto Exp $ */
/*
* Copyright (c) 2013 Antoine Jacoutot <ajacoutot@openbsd.org>
*
@@ -21,11 +21,11 @@
void
setprogname(const char *progname)
{
- const char *tmpn;
+ char *tmpn;
tmpn = strrchr(progname, '/');
if (tmpn == NULL)
- __progname = progname;
+ __progname = (char *)progname;
else
__progname = tmpn + 1;
}
diff --git a/libc/upstream-openbsd/lib/libc/locale/wcsxfrm.c b/libc/upstream-openbsd/lib/libc/locale/wcsxfrm.c
index 98db4a9..3d1e580 100644
--- a/libc/upstream-openbsd/lib/libc/locale/wcsxfrm.c
+++ b/libc/upstream-openbsd/lib/libc/locale/wcsxfrm.c
@@ -1,6 +1,5 @@
-/* $OpenBSD: wcsxfrm.c,v 1.2 2012/12/05 23:20:00 deraadt Exp $ */
-/* $OpenBSD: wcsxfrm.c,v 1.2 2012/12/05 23:20:00 deraadt Exp $ */
-/* $NetBSD: multibyte_sb.c,v 1.4 2003/08/07 16:43:04 agc Exp $ */
+/* $OpenBSD: wcsxfrm.c,v 1.3 2017/09/05 03:16:13 schwarze Exp $ */
+/* $NetBSD: multibyte_sb.c,v 1.4 2003/08/07 16:43:04 agc Exp $ */
/*
* Copyright (c) 1991 The Regents of the University of California.
@@ -40,3 +39,4 @@
return wcslen(src);
return wcslcpy(dest, src, n);
}
+DEF_STRONG(wcsxfrm);
diff --git a/libc/upstream-openbsd/lib/libc/stdio/makebuf.c b/libc/upstream-openbsd/lib/libc/stdio/makebuf.c
index 56e5f21..b771a40 100644
--- a/libc/upstream-openbsd/lib/libc/stdio/makebuf.c
+++ b/libc/upstream-openbsd/lib/libc/stdio/makebuf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: makebuf.c,v 1.9 2015/01/13 07:18:21 guenther Exp $ */
+/* $OpenBSD: makebuf.c,v 1.10 2019/06/28 13:32:42 deraadt Exp $ */
/*-
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
@@ -81,7 +81,7 @@
{
struct stat st;
- if (fp->_file < 0 || fstat(fp->_file, &st) < 0) {
+ if (fp->_file < 0 || fstat(fp->_file, &st) == -1) {
*couldbetty = 0;
*bufsize = BUFSIZ;
return (__SNPT);
diff --git a/libc/upstream-openbsd/lib/libc/stdio/mktemp.c b/libc/upstream-openbsd/lib/libc/stdio/mktemp.c
index 4b81d5d..ef9a183 100644
--- a/libc/upstream-openbsd/lib/libc/stdio/mktemp.c
+++ b/libc/upstream-openbsd/lib/libc/stdio/mktemp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mktemp.c,v 1.38 2015/09/13 08:31:47 guenther Exp $ */
+/* $OpenBSD: mktemp.c,v 1.39 2017/11/28 06:55:49 tb Exp $ */
/*
* Copyright (c) 1996-1998, 2008 Theo de Raadt
* Copyright (c) 1997, 2008-2009 Todd C. Miller
@@ -119,7 +119,7 @@
}
__warn_references(mktemp,
- "warning: mktemp() possibly used unsafely; consider using mkstemp()");
+ "mktemp() possibly used unsafely; consider using mkstemp()");
char *
mktemp(char *path)
diff --git a/libc/upstream-openbsd/lib/libc/stdio/tempnam.c b/libc/upstream-openbsd/lib/libc/stdio/tempnam.c
index 854b871..d2c848c 100644
--- a/libc/upstream-openbsd/lib/libc/stdio/tempnam.c
+++ b/libc/upstream-openbsd/lib/libc/stdio/tempnam.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tempnam.c,v 1.19 2015/08/31 02:53:57 guenther Exp $ */
+/* $OpenBSD: tempnam.c,v 1.20 2017/11/28 06:55:49 tb Exp $ */
/*
* Copyright (c) 1988, 1993
* The Regents of the University of California. All rights reserved.
@@ -37,7 +37,7 @@
#include <unistd.h>
__warn_references(tempnam,
- "warning: tempnam() possibly used unsafely; consider using mkstemp()");
+ "tempnam() possibly used unsafely; consider using mkstemp()");
char *
tempnam(const char *dir, const char *pfx)
diff --git a/libc/upstream-openbsd/lib/libc/stdio/tmpnam.c b/libc/upstream-openbsd/lib/libc/stdio/tmpnam.c
index d6dc10e..52cd43d 100644
--- a/libc/upstream-openbsd/lib/libc/stdio/tmpnam.c
+++ b/libc/upstream-openbsd/lib/libc/stdio/tmpnam.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tmpnam.c,v 1.11 2015/08/31 02:53:57 guenther Exp $ */
+/* $OpenBSD: tmpnam.c,v 1.12 2017/11/28 06:55:49 tb Exp $ */
/*-
* Copyright (c) 1990, 1993, 1994
* The Regents of the University of California. All rights reserved.
@@ -37,7 +37,7 @@
#include <unistd.h>
__warn_references(tmpnam,
- "warning: tmpnam() possibly used unsafely; consider using mkstemp()");
+ "tmpnam() possibly used unsafely; consider using mkstemp()");
char *
tmpnam(char *s)
diff --git a/libc/upstream-openbsd/lib/libc/stdio/vswprintf.c b/libc/upstream-openbsd/lib/libc/stdio/vswprintf.c
index 641db4a..91e71cb 100644
--- a/libc/upstream-openbsd/lib/libc/stdio/vswprintf.c
+++ b/libc/upstream-openbsd/lib/libc/stdio/vswprintf.c
@@ -1,8 +1,8 @@
-/* $OpenBSD: vswprintf.c,v 1.6 2015/08/31 02:53:57 guenther Exp $ */
+/* $OpenBSD: vswprintf.c,v 1.7 2019/01/25 00:19:25 millert Exp $ */
/* $NetBSD: vswprintf.c,v 1.1 2005/05/14 23:51:02 christos Exp $ */
/*
- * Copyright (c) 1997 Todd C. Miller <Todd.Miller@courtesan.com>
+ * Copyright (c) 1997 Todd C. Miller <millert@openbsd.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/libc/upstream-openbsd/lib/libc/stdlib/getenv.c b/libc/upstream-openbsd/lib/libc/stdlib/getenv.c
index fd8482e..054497b 100644
--- a/libc/upstream-openbsd/lib/libc/stdlib/getenv.c
+++ b/libc/upstream-openbsd/lib/libc/stdlib/getenv.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: getenv.c,v 1.10 2010/08/23 22:31:50 millert Exp $ */
+/* $OpenBSD: getenv.c,v 1.12 2016/03/13 18:34:21 guenther Exp $ */
/*
* Copyright (c) 1987, 1993
* The Regents of the University of California. All rights reserved.
@@ -31,7 +31,6 @@
#include <stdlib.h>
#include <string.h>
-char *__findenv(const char *name, int len, int *offset);
/*
* __findenv --
@@ -46,7 +45,6 @@
char *
__findenv(const char *name, int len, int *offset)
{
- extern char **environ;
int i;
const char *np;
char **p, *cp;
@@ -79,3 +77,4 @@
;
return (__findenv(name, (int)(np - name), &offset));
}
+DEF_STRONG(getenv);
diff --git a/libc/upstream-openbsd/lib/libc/stdlib/llabs.c b/libc/upstream-openbsd/lib/libc/stdlib/llabs.c
index fc2cd82..f4a260f 100644
--- a/libc/upstream-openbsd/lib/libc/stdlib/llabs.c
+++ b/libc/upstream-openbsd/lib/libc/stdlib/llabs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: llabs.c,v 1.3 2007/01/08 19:39:25 deraadt Exp $ */
+/* $OpenBSD: llabs.c,v 1.4 2016/08/14 23:18:03 guenther Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
@@ -36,3 +36,5 @@
{
return (j < 0 ? -j : j);
}
+
+__weak_alias(qabs, llabs);
diff --git a/libc/upstream-openbsd/lib/libc/string/memrchr.c b/libc/upstream-openbsd/lib/libc/string/memrchr.c
index 26a3399..e123bc1 100644
--- a/libc/upstream-openbsd/lib/libc/string/memrchr.c
+++ b/libc/upstream-openbsd/lib/libc/string/memrchr.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: memrchr.c,v 1.3 2015/08/31 02:53:57 guenther Exp $ */
+/* $OpenBSD: memrchr.c,v 1.4 2019/01/25 00:19:25 millert Exp $ */
/*
- * Copyright (c) 2007 Todd C. Miller <Todd.Miller@courtesan.com>
+ * Copyright (c) 2007 Todd C. Miller <millert@openbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
diff --git a/libc/upstream-openbsd/lib/libc/string/stpcpy.c b/libc/upstream-openbsd/lib/libc/string/stpcpy.c
index d88afac..5a86541 100644
--- a/libc/upstream-openbsd/lib/libc/string/stpcpy.c
+++ b/libc/upstream-openbsd/lib/libc/string/stpcpy.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: stpcpy.c,v 1.2 2014/07/09 17:08:21 naddy Exp $ */
+/* $OpenBSD: stpcpy.c,v 1.3 2017/11/28 06:55:49 tb Exp $ */
/*
* Copyright (c) 1988 Regents of the University of California.
@@ -33,7 +33,7 @@
#if defined(APIWARN)
__warn_references(stpcpy,
- "warning: stpcpy() is dangerous; do not use it");
+ "stpcpy() is dangerous; do not use it");
#endif
char *
diff --git a/libc/upstream-openbsd/lib/libc/string/strcat.c b/libc/upstream-openbsd/lib/libc/string/strcat.c
index 646c9c2..73da22f 100644
--- a/libc/upstream-openbsd/lib/libc/string/strcat.c
+++ b/libc/upstream-openbsd/lib/libc/string/strcat.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: strcat.c,v 1.9 2014/06/10 04:17:37 deraadt Exp $ */
+/* $OpenBSD: strcat.c,v 1.10 2017/11/28 06:55:49 tb Exp $ */
/*
* Copyright (c) 1988 Regents of the University of California.
@@ -33,7 +33,7 @@
#if defined(APIWARN)
__warn_references(strcat,
- "warning: strcat() is almost always misused, please use strlcat()");
+ "strcat() is almost always misused, please use strlcat()");
#endif
char *
diff --git a/libc/upstream-openbsd/lib/libc/string/strcpy.c b/libc/upstream-openbsd/lib/libc/string/strcpy.c
index 5a9001e..290eefe 100644
--- a/libc/upstream-openbsd/lib/libc/string/strcpy.c
+++ b/libc/upstream-openbsd/lib/libc/string/strcpy.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: strcpy.c,v 1.9 2014/06/10 04:17:37 deraadt Exp $ */
+/* $OpenBSD: strcpy.c,v 1.10 2017/11/28 06:55:49 tb Exp $ */
/*
* Copyright (c) 1988 Regents of the University of California.
@@ -33,7 +33,7 @@
#if defined(APIWARN)
__warn_references(strcpy,
- "warning: strcpy() is almost always misused, please use strlcpy()");
+ "strcpy() is almost always misused, please use strlcpy()");
#endif
char *
diff --git a/libc/upstream-openbsd/lib/libc/string/strlcat.c b/libc/upstream-openbsd/lib/libc/string/strlcat.c
index 6bf2a41..aa3db7ab 100644
--- a/libc/upstream-openbsd/lib/libc/string/strlcat.c
+++ b/libc/upstream-openbsd/lib/libc/string/strlcat.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: strlcat.c,v 1.18 2016/10/16 17:37:39 dtucker Exp $ */
+/* $OpenBSD: strlcat.c,v 1.19 2019/01/25 00:19:25 millert Exp $ */
/*
- * Copyright (c) 1998, 2015 Todd C. Miller <Todd.Miller@courtesan.com>
+ * Copyright (c) 1998, 2015 Todd C. Miller <millert@openbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
diff --git a/libc/upstream-openbsd/lib/libc/string/strlcpy.c b/libc/upstream-openbsd/lib/libc/string/strlcpy.c
index 3677689..7e3b9ae 100644
--- a/libc/upstream-openbsd/lib/libc/string/strlcpy.c
+++ b/libc/upstream-openbsd/lib/libc/string/strlcpy.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: strlcpy.c,v 1.15 2016/10/16 17:37:39 dtucker Exp $ */
+/* $OpenBSD: strlcpy.c,v 1.16 2019/01/25 00:19:25 millert Exp $ */
/*
- * Copyright (c) 1998, 2015 Todd C. Miller <Todd.Miller@courtesan.com>
+ * Copyright (c) 1998, 2015 Todd C. Miller <millert@openbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
diff --git a/libc/upstream-openbsd/lib/libc/string/strndup.c b/libc/upstream-openbsd/lib/libc/string/strndup.c
index a6e5bff..499f9a0 100644
--- a/libc/upstream-openbsd/lib/libc/string/strndup.c
+++ b/libc/upstream-openbsd/lib/libc/string/strndup.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: strndup.c,v 1.2 2015/08/31 02:53:57 guenther Exp $ */
+/* $OpenBSD: strndup.c,v 1.3 2019/01/25 00:19:25 millert Exp $ */
/*
- * Copyright (c) 2010 Todd C. Miller <Todd.Miller@courtesan.com>
+ * Copyright (c) 2010 Todd C. Miller <millert@openbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
diff --git a/libc/upstream-openbsd/lib/libc/string/strstr.c b/libc/upstream-openbsd/lib/libc/string/strstr.c
index 95a865b..079d69d 100644
--- a/libc/upstream-openbsd/lib/libc/string/strstr.c
+++ b/libc/upstream-openbsd/lib/libc/string/strstr.c
@@ -1,56 +1,197 @@
-/* $OpenBSD: strstr.c,v 1.5 2005/08/08 08:05:37 espie Exp $ */
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
+/* $OpenBSD: strstr.c,v 1.8 2018/04/30 07:44:56 denis Exp $ */
+
+/*
+ * Copyright (c) 2005-2014 Rich Felker
*
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
*
- * 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. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
*
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <string.h>
+#include <stdlib.h>
+#include <stdint.h>
+
+#ifdef DEBUG
+#include <stdio.h>
+#endif
+
+static char *
+twobyte_strstr(const unsigned char *h, const unsigned char *n)
+{
+ uint16_t nw = n[0]<<8 | n[1], hw = h[0]<<8 | h[1];
+ for (h++; *h && hw != nw; hw = hw<<8 | *++h);
+ return *h ? (char *)h-1 : 0;
+}
+
+static char *
+threebyte_strstr(const unsigned char *h, const unsigned char *n)
+{
+ uint32_t nw = n[0]<<24 | n[1]<<16 | n[2]<<8;
+ uint32_t hw = h[0]<<24 | h[1]<<16 | h[2]<<8;
+ for (h+=2; *h && hw != nw; hw = (hw|*++h)<<8);
+ return *h ? (char *)h-2 : 0;
+}
+
+static char *
+fourbyte_strstr(const unsigned char *h, const unsigned char *n)
+{
+ uint32_t nw = n[0]<<24 | n[1]<<16 | n[2]<<8 | n[3];
+ uint32_t hw = h[0]<<24 | h[1]<<16 | h[2]<<8 | h[3];
+ for (h+=3; *h && hw != nw; hw = hw<<8 | *++h);
+ return *h ? (char *)h-3 : 0;
+}
+
+#define MAX(a,b) ((a)>(b)?(a):(b))
+#define MIN(a,b) ((a)<(b)?(a):(b))
+
+#define BITOP(a,b,op) \
+ ((a)[(size_t)(b)/(8*sizeof *(a))] op (size_t)1<<((size_t)(b)%(8*sizeof *(a))))
/*
- * Find the first occurrence of find in s.
+ * Maxime Crochemore and Dominique Perrin, Two-way string-matching,
+ * Journal of the ACM, 38(3):651-675, July 1991.
*/
-char *
-strstr(const char *s, const char *find)
+static char *
+twoway_strstr(const unsigned char *h, const unsigned char *n)
{
- char c, sc;
- size_t len;
+ const unsigned char *z;
+ size_t l, ip, jp, k, p, ms, p0, mem, mem0;
+ size_t byteset[32 / sizeof(size_t)] = { 0 };
+ size_t shift[256];
- if ((c = *find++) != 0) {
- len = strlen(find);
- do {
- do {
- if ((sc = *s++) == 0)
- return (NULL);
- } while (sc != c);
- } while (strncmp(s, find, len) != 0);
- s--;
+ /* Computing length of needle and fill shift table */
+ for (l=0; n[l] && h[l]; l++)
+ BITOP(byteset, n[l], |=), shift[n[l]] = l+1;
+ if (n[l]) return 0; /* hit the end of h */
+
+ /* Compute maximal suffix */
+ ip = -1; jp = 0; k = p = 1;
+ while (jp+k<l) {
+ if (n[ip+k] == n[jp+k]) {
+ if (k == p) {
+ jp += p;
+ k = 1;
+ } else k++;
+ } else if (n[ip+k] > n[jp+k]) {
+ jp += k;
+ k = 1;
+ p = jp - ip;
+ } else {
+ ip = jp++;
+ k = p = 1;
+ }
}
- return ((char *)s);
+ ms = ip;
+ p0 = p;
+
+ /* And with the opposite comparison */
+ ip = -1; jp = 0; k = p = 1;
+ while (jp+k<l) {
+ if (n[ip+k] == n[jp+k]) {
+ if (k == p) {
+ jp += p;
+ k = 1;
+ } else k++;
+ } else if (n[ip+k] < n[jp+k]) {
+ jp += k;
+ k = 1;
+ p = jp - ip;
+ } else {
+ ip = jp++;
+ k = p = 1;
+ }
+ }
+ if (ip+1 > ms+1) ms = ip;
+ else p = p0;
+
+ /* Periodic needle? */
+ if (memcmp(n, n+p, ms+1)) {
+ mem0 = 0;
+ p = MAX(ms, l-ms-1) + 1;
+ } else mem0 = l-p;
+ mem = 0;
+
+ /* Initialize incremental end-of-haystack pointer */
+ z = h;
+
+ /* Search loop */
+ for (;;) {
+ /* Update incremental end-of-haystack pointer */
+ if (z-h < l) {
+ /* Fast estimate for MIN(l,63) */
+ size_t grow = l | 63;
+ const unsigned char *z2 = memchr(z, 0, grow);
+ if (z2) {
+ z = z2;
+ if (z-h < l) return 0;
+ } else z += grow;
+ }
+
+ /* Check last byte first; advance by shift on mismatch */
+ if (BITOP(byteset, h[l-1], &)) {
+ k = l-shift[h[l-1]];
+#ifdef DEBUG
+ printf("adv by %zu (on %c) at [%s] (%zu;l=%zu)\n", k, h[l-1], h, shift[h[l-1]], l);
+#endif
+ if (k) {
+ if (mem0 && mem && k < p) k = l-p;
+ h += k;
+ mem = 0;
+ continue;
+ }
+ } else {
+ h += l;
+ mem = 0;
+ continue;
+ }
+
+ /* Compare right half */
+ for (k=MAX(ms+1,mem); n[k] && n[k] == h[k]; k++);
+ if (n[k]) {
+ h += k-ms;
+ mem = 0;
+ continue;
+ }
+ /* Compare left half */
+ for (k=ms+1; k>mem && n[k-1] == h[k-1]; k--);
+ if (k <= mem) return (char *)h;
+ h += p;
+ mem = mem0;
+ }
}
+
+char *
+strstr(const char *h, const char *n)
+{
+ /* Return immediately on empty needle */
+ if (!n[0]) return (char *)h;
+
+ /* Use faster algorithms for short needles */
+ h = strchr(h, *n);
+ if (!h || !n[1]) return (char *)h;
+ if (!h[1]) return 0;
+ if (!n[2]) return twobyte_strstr((void *)h, (void *)n);
+ if (!h[2]) return 0;
+ if (!n[3]) return threebyte_strstr((void *)h, (void *)n);
+ if (!h[3]) return 0;
+ if (!n[4]) return fourbyte_strstr((void *)h, (void *)n);
+
+ return twoway_strstr((void *)h, (void *)n);
+}
+DEF_STRONG(strstr);
diff --git a/libc/upstream-openbsd/lib/libc/string/wcslcpy.c b/libc/upstream-openbsd/lib/libc/string/wcslcpy.c
index 36a544a..9c433c8 100644
--- a/libc/upstream-openbsd/lib/libc/string/wcslcpy.c
+++ b/libc/upstream-openbsd/lib/libc/string/wcslcpy.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: wcslcpy.c,v 1.7 2015/09/12 16:23:14 guenther Exp $ */
+/* $OpenBSD: wcslcpy.c,v 1.8 2019/01/25 00:19:25 millert Exp $ */
/*
- * Copyright (c) 1998, 2015 Todd C. Miller <Todd.Miller@courtesan.com>
+ * Copyright (c) 1998, 2015 Todd C. Miller <millert@openbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
diff --git a/libc/upstream-openbsd/lib/libc/time/wcsftime.c b/libc/upstream-openbsd/lib/libc/time/wcsftime.c
index 0678404..6870871 100644
--- a/libc/upstream-openbsd/lib/libc/time/wcsftime.c
+++ b/libc/upstream-openbsd/lib/libc/time/wcsftime.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: wcsftime.c,v 1.6 2015/02/09 14:52:28 tedu Exp $ */
+/* $OpenBSD: wcsftime.c,v 1.7 2019/05/12 12:49:52 schwarze Exp $ */
/*
** Based on the UCB version with the ID appearing below.
** This is ANSIish only when "multibyte character == plain character".
@@ -439,7 +439,7 @@
continue;
case 'Z':
if (t->tm_zone != NULL)
- pt = _sadd(t->TM_ZONE, pt, ptlim);
+ pt = _sadd(t->tm_zone, pt, ptlim);
else
if (t->tm_isdst >= 0)
pt = _sadd(tzname[t->tm_isdst != 0],
diff --git a/libm/libm.map.txt b/libm/libm.map.txt
index 00ea7ee..24ae50b 100644
--- a/libm/libm.map.txt
+++ b/libm/libm.map.txt
@@ -296,56 +296,14 @@
LIBC_DEPRECATED { # arm mips platform-only
global: # arm mips
- ___Unwind_Backtrace; # arm
- ___Unwind_ForcedUnwind; # arm
- ___Unwind_RaiseException; # arm
- ___Unwind_Resume; # arm
- ___Unwind_Resume_or_Rethrow; # arm
__aeabi_d2lz; # arm
__aeabi_d2ulz; # arm
__aeabi_f2lz; # arm
__aeabi_f2ulz; # arm
__aeabi_l2d; # arm
- __aeabi_unwind_cpp_pr0; # arm
- __aeabi_unwind_cpp_pr1; # arm
- __aeabi_unwind_cpp_pr2; # arm
__fixdfdi; # arm mips
__fixsfdi; # arm mips
__fixunsdfdi; # arm mips
__fixunssfdi; # arm mips
__floatdidf; # arm
- __gnu_Unwind_Backtrace; # arm
- __gnu_unwind_execute; # arm
- __gnu_Unwind_ForcedUnwind; # arm
- __gnu_unwind_frame; # arm
- __gnu_Unwind_RaiseException; # arm
- __gnu_Unwind_Restore_VFP; # arm
- __gnu_Unwind_Restore_VFP_D; # arm
- __gnu_Unwind_Restore_VFP_D_16_to_31; # arm
- __gnu_Unwind_Restore_WMMXC; # arm
- __gnu_Unwind_Restore_WMMXD; # arm
- __gnu_Unwind_Resume; # arm
- __gnu_Unwind_Resume_or_Rethrow; # arm
- __gnu_Unwind_Save_VFP; # arm
- __gnu_Unwind_Save_VFP_D; # arm
- __gnu_Unwind_Save_VFP_D_16_to_31; # arm
- __gnu_Unwind_Save_WMMXC; # arm
- __gnu_Unwind_Save_WMMXD; # arm
- __restore_core_regs; # arm
- _Unwind_Backtrace; # arm
- _Unwind_Complete; # arm
- _Unwind_DeleteException; # arm
- _Unwind_ForcedUnwind; # arm
- _Unwind_GetCFA; # arm
- _Unwind_GetDataRelBase; # arm
- _Unwind_GetLanguageSpecificData; # arm
- _Unwind_GetRegionStart; # arm
- _Unwind_GetTextRelBase; # arm
- _Unwind_RaiseException; # arm
- _Unwind_Resume; # arm
- _Unwind_Resume_or_Rethrow; # arm
- _Unwind_VRS_Get; # arm
- _Unwind_VRS_Pop; # arm
- _Unwind_VRS_Set; # arm
- restore_core_regs; # arm
} LIBC_O; # arm mips
diff --git a/linker/Android.bp b/linker/Android.bp
index 1800bdb..3b25d12 100644
--- a/linker/Android.bp
+++ b/linker/Android.bp
@@ -335,11 +335,7 @@
symlinks: ["linker_asan"],
multilib: {
- lib32: {
- cflags: ["-DLIB_PATH=\"lib\""],
- },
lib64: {
- cflags: ["-DLIB_PATH=\"lib64\""],
suffix: "64",
},
},
diff --git a/linker/linker.cpp b/linker/linker.cpp
index 1393eb5..fb22a1d 100644
--- a/linker/linker.cpp
+++ b/linker/linker.cpp
@@ -95,7 +95,7 @@
static const char* const kLdConfigFilePath = "/system/etc/ld.config.txt";
static const char* const kLdConfigVndkLiteFilePath = "/system/etc/ld.config.vndk_lite.txt";
-static const char* const kLdGeneratedConfigFilePath = "/dev/linkerconfig/ld.config.txt";
+static const char* const kLdGeneratedConfigFilePath = "/linkerconfig/ld.config.txt";
#if defined(__LP64__)
static const char* const kSystemLibDir = "/system/lib64";
@@ -1503,7 +1503,16 @@
// Open the file.
int fd = open_library(ns, zip_archive_cache, name, needed_by, &file_offset, &realpath);
if (fd == -1) {
- DL_OPEN_ERR("library \"%s\" not found", name);
+ if (task->is_dt_needed()) {
+ if (needed_by->is_main_executable()) {
+ DL_OPEN_ERR("library \"%s\" not found: needed by main executable", name);
+ } else {
+ DL_OPEN_ERR("library \"%s\" not found: needed by %s in namespace %s", name,
+ needed_by->get_realpath(), task->get_start_from()->get_name());
+ }
+ } else {
+ DL_OPEN_ERR("library \"%s\" not found", name);
+ }
return false;
}
@@ -4045,19 +4054,6 @@
return kLdConfigVndkLiteFilePath;
}
- // Use generated linker config if flag is set
- // TODO(b/138920271) Do not check property once it is confirmed as stable
- // TODO(b/139638519) This file should also cover legacy or vndk-lite config
- if (android::base::GetProperty("ro.vndk.version", "") != "" &&
- android::base::GetBoolProperty("sys.linker.use_generated_config", true)) {
- if (file_exists(kLdGeneratedConfigFilePath)) {
- return kLdGeneratedConfigFilePath;
- } else {
- DL_WARN("Warning: failed to find generated linker configuration from \"%s\"",
- kLdGeneratedConfigFilePath);
- }
- }
-
std::string ld_config_file_vndk = kLdConfigFilePath;
size_t insert_pos = ld_config_file_vndk.find_last_of('.');
if (insert_pos == std::string::npos) {
@@ -4091,6 +4087,18 @@
return path;
}
+ // Use generated linker config if flag is set
+ // TODO(b/138920271) Do not check property once it is confirmed as stable
+ if (android::base::GetBoolProperty("sys.linker.use_generated_config", true)) {
+ if (file_exists(kLdGeneratedConfigFilePath)) {
+ return kLdGeneratedConfigFilePath;
+ } else {
+ // TODO(b/146386369) : Adjust log level and add more condition to log only when necessary
+ INFO("Warning: failed to find generated linker configuration from \"%s\"",
+ kLdGeneratedConfigFilePath);
+ }
+ }
+
path = get_ld_config_file_vndk_path();
if (file_exists(path.c_str())) {
return path;
diff --git a/linker/linker.h b/linker/linker.h
index 89390b3..789640c 100644
--- a/linker/linker.h
+++ b/linker/linker.h
@@ -36,7 +36,7 @@
#include <sys/stat.h>
#include <unistd.h>
-#include "private/bionic_page.h"
+#include "platform/bionic/page.h"
#include "linked_list.h"
#include "linker_common_types.h"
#include "linker_logger.h"
diff --git a/linker/linker_cfi.cpp b/linker/linker_cfi.cpp
index 782ebc6..435bb1a 100644
--- a/linker/linker_cfi.cpp
+++ b/linker/linker_cfi.cpp
@@ -30,7 +30,7 @@
#include "linker_debug.h"
#include "linker_globals.h"
-#include "private/bionic_page.h"
+#include "platform/bionic/page.h"
#include <sys/mman.h>
#include <sys/prctl.h>
diff --git a/linker/linker_config.cpp b/linker/linker_config.cpp
index 85ea8d1..ada25a5 100644
--- a/linker/linker_config.cpp
+++ b/linker/linker_config.cpp
@@ -353,11 +353,6 @@
static constexpr const char* kDefaultConfigName = "default";
static constexpr const char* kPropertyAdditionalNamespaces = "additional.namespaces";
-#if defined(__LP64__)
-static constexpr const char* kLibParamValue = "lib64";
-#else
-static constexpr const char* kLibParamValue = "lib";
-#endif
class Properties {
public:
@@ -401,7 +396,7 @@
split_path(paths_str.c_str(), ":", &paths);
std::vector<std::pair<std::string, std::string>> params;
- params.push_back({ "LIB", kLibParamValue });
+ params.push_back({ "LIB", kLibPath });
if (target_sdk_version_ != 0) {
char buf[16];
async_safe_format_buffer(buf, sizeof(buf), "%d", target_sdk_version_);
diff --git a/linker/linker_config.h b/linker/linker_config.h
index 75d9378..6733148 100644
--- a/linker/linker_config.h
+++ b/linker/linker_config.h
@@ -40,6 +40,12 @@
#include <android-base/macros.h>
+#if defined(__LP64__)
+static constexpr const char* kLibPath = "lib64";
+#else
+static constexpr const char* kLibPath = "lib";
+#endif
+
class NamespaceLinkConfig {
public:
NamespaceLinkConfig() = default;
diff --git a/linker/linker_soinfo.cpp b/linker/linker_soinfo.cpp
index 14293d9..c71945a 100644
--- a/linker/linker_soinfo.cpp
+++ b/linker/linker_soinfo.cpp
@@ -36,6 +36,7 @@
#include <async_safe/log.h>
+#include "linker_config.h"
#include "linker_debug.h"
#include "linker_globals.h"
#include "linker_logger.h"
@@ -85,11 +86,7 @@
// FIXME: add $PLATFORM.
std::vector<std::pair<std::string, std::string>> params = {
{"ORIGIN", origin},
-#if defined(LIB_PATH)
- {"LIB", LIB_PATH},
-#else
-#error "LIB_PATH not defined"
-#endif
+ {"LIB", kLibPath},
};
for (auto&& s : runpaths) {
format_string(&s, params);
diff --git a/tests/Android.bp b/tests/Android.bp
index 1755053..ee4f02e 100644
--- a/tests/Android.bp
+++ b/tests/Android.bp
@@ -312,26 +312,20 @@
},
}
-// If building this fails, then we have both FORTIFY and ASAN enabled, which
-// isn't desirable. (Ideally, we'd emit FORTIFY diagnostics even with ASAN
-// enabled, but that's not a reality today.) This is meant to be otherwise
-// unused.
-cc_test_library {
- name: "fortify_disabled_for_asan",
+// Ensures that FORTIFY checks aren't run when ASAN is on.
+cc_test {
+ name: "bionic-fortify-runtime-asan-test",
defaults: [
"bionic_clang_fortify_tests_w_flags",
],
cflags: [
"-Werror",
"-D_FORTIFY_SOURCE=2",
- // "sanitize: address" doesn't work on platforms where libasan isn't
- // enabled. Since the intent is just to build this, we can get away with
- // passing this flag on its own.
- "-fsanitize=address",
],
- // Ignore that we don't have ASAN symbols linked in.
- allow_undefined_symbols: true,
- srcs: ["clang_fortify_tests.cpp"],
+ sanitize: {
+ address: true,
+ },
+ srcs: ["clang_fortify_asan.cpp"],
}
// Ensure we don't use FORTIFY'ed functions with the static analyzer/clang-tidy:
diff --git a/tests/clang_fortify_asan.cpp b/tests/clang_fortify_asan.cpp
new file mode 100644
index 0000000..51656eb
--- /dev/null
+++ b/tests/clang_fortify_asan.cpp
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * This test ensures that ensures that FORTIFY's run-time bits aren't enabled with ASAN on. Most
+ * ways of getting FORTIFY to break turn into UB unless you get creative. Rather than remaking the
+ * entire FORTIFY test-suite with this added constraint, we pick a function with well-defined
+ * behavior when a FORTIFY check would fail (umask), and hope that the success of that is indicative
+ * of the rest working.
+ */
+
+#ifndef __clang__
+#error "Non-clang isn't supported"
+#endif
+
+#ifndef _FORTIFY_SOURCE
+#error "_FORTIFY_SOURCE must be defined"
+#endif
+
+#include <sys/cdefs.h>
+
+#if defined(__BIONIC__) && __has_feature(address_sanitizer)
+#include <sys/stat.h>
+#include <gtest/gtest.h>
+
+TEST(ClangFortifyASAN, NoRuntimeChecksAreEnabled) {
+ volatile mode_t unknown = 01000;
+ mode_t previous = umask(unknown);
+
+ // Not necessary, but polite.
+ umask(previous);
+}
+#endif
diff --git a/tests/dl_test.cpp b/tests/dl_test.cpp
index 9e46394..05bba05 100644
--- a/tests/dl_test.cpp
+++ b/tests/dl_test.cpp
@@ -25,6 +25,7 @@
#include <limits.h>
#include <stdio.h>
#include <stdint.h>
+#include <sys/stat.h>
#include <string>
#include <iostream>
@@ -85,20 +86,50 @@
#else
static constexpr const char* kPathToLinker = "/system/bin/linker";
#endif
+
+#if defined (__aarch64__)
+ static constexpr const char* kAlternatePathToLinker = "/system/bin/arm64/linker64";
+#elif defined (__arm__)
+ static constexpr const char* kAlternatePathToLinker = "/system/bin/arm/linker";
+#elif defined (__x86_64__)
+ static constexpr const char* kAlternatePathToLinker = "/system/bin/x86_64/linker64";
+#elif defined (__i386__)
+ static constexpr const char* kAlternatePathToLinker = "/system/bin/x86/linker";
+#elif defined (__mips__)
+#if defined(__LP64__)
+ static constexpr const char* kAlternatePathToLinker = "/system/bin/mips64/linker64";
+#else
+ static constexpr const char* kAlternatePathToLinker = "/system/bin/mips/linker";
#endif
+#else
+#error "Unknown architecture"
+#endif
+
+const char* PathToLinker() {
+ // On the systems with emulated architecture linker would be of different
+ // architecture. Try to use alternate paths first.
+ struct stat buffer;
+ if (stat(kAlternatePathToLinker, &buffer) == 0) {
+ return kAlternatePathToLinker;
+ }
+ return kPathToLinker;
+}
+#endif // defined(__BIONIC__)
TEST(dl, exec_linker) {
#if defined(__BIONIC__)
- std::string usage_prefix = std::string("Usage: ") + kPathToLinker;
+ const char* path_to_linker = PathToLinker();
+ std::string usage_prefix = std::string("Usage: ") + path_to_linker;
ExecTestHelper eth;
- eth.SetArgs({ kPathToLinker, nullptr });
- eth.Run([&]() { execve(kPathToLinker, eth.GetArgs(), eth.GetEnv()); }, 0, nullptr);
+ eth.SetArgs({ path_to_linker, nullptr });
+ eth.Run([&]() { execve(path_to_linker, eth.GetArgs(), eth.GetEnv()); }, 0, nullptr);
ASSERT_EQ(0u, eth.GetOutput().find(usage_prefix)) << "Test output:\n" << eth.GetOutput();
#endif
}
TEST(dl, exec_linker_load_file) {
#if defined(__BIONIC__)
+ const char* path_to_linker = PathToLinker();
std::string helper = GetTestlibRoot() +
"/exec_linker_helper/exec_linker_helper";
std::string expected_output =
@@ -107,13 +138,14 @@
"__progname=" + helper + "\n" +
"helper_func called\n";
ExecTestHelper eth;
- eth.SetArgs({ kPathToLinker, helper.c_str(), nullptr });
- eth.Run([&]() { execve(kPathToLinker, eth.GetArgs(), eth.GetEnv()); }, 0, expected_output.c_str());
+ eth.SetArgs({ path_to_linker, helper.c_str(), nullptr });
+ eth.Run([&]() { execve(path_to_linker, eth.GetArgs(), eth.GetEnv()); }, 0, expected_output.c_str());
#endif
}
TEST(dl, exec_linker_load_from_zip) {
#if defined(__BIONIC__)
+ const char* path_to_linker = PathToLinker();
std::string helper = GetTestlibRoot() +
"/libdlext_test_zip/libdlext_test_zip_zipaligned.zip!/libdir/exec_linker_helper";
std::string expected_output =
@@ -122,17 +154,18 @@
"__progname=" + helper + "\n" +
"helper_func called\n";
ExecTestHelper eth;
- eth.SetArgs({ kPathToLinker, helper.c_str(), nullptr });
- eth.Run([&]() { execve(kPathToLinker, eth.GetArgs(), eth.GetEnv()); }, 0, expected_output.c_str());
+ eth.SetArgs({ path_to_linker, helper.c_str(), nullptr });
+ eth.Run([&]() { execve(path_to_linker, eth.GetArgs(), eth.GetEnv()); }, 0, expected_output.c_str());
#endif
}
TEST(dl, exec_linker_load_self) {
#if defined(__BIONIC__)
+ const char* path_to_linker = PathToLinker();
std::string error_message = "error: linker cannot load itself\n";
ExecTestHelper eth;
- eth.SetArgs({ kPathToLinker, kPathToLinker, nullptr });
- eth.Run([&]() { execve(kPathToLinker, eth.GetArgs(), eth.GetEnv()); }, EXIT_FAILURE, error_message.c_str());
+ eth.SetArgs({ path_to_linker, path_to_linker, nullptr });
+ eth.Run([&]() { execve(path_to_linker, eth.GetArgs(), eth.GetEnv()); }, EXIT_FAILURE, error_message.c_str());
#endif
}
@@ -204,7 +237,10 @@
// The two libs are in ns2/ subdir.
TEST(dl, exec_without_ld_config_file) {
#if defined(__BIONIC__)
- std::string error_message = "CANNOT LINK EXECUTABLE \"" + GetTestlibRoot() + "/ld_config_test_helper/ld_config_test_helper\": library \"ld_config_test_helper_lib1.so\" not found\n";
+ std::string error_message =
+ "CANNOT LINK EXECUTABLE \"" + GetTestlibRoot() +
+ "/ld_config_test_helper/ld_config_test_helper\": library \"ld_config_test_helper_lib1.so\" "
+ "not found: needed by main executable\n";
std::string helper = GetTestlibRoot() +
"/ld_config_test_helper/ld_config_test_helper";
chmod(helper.c_str(), 0755);
@@ -244,8 +280,7 @@
#if defined(__BIONIC__)
SKIP_WITH_HWASAN << "libclang_rt.hwasan is not found with custom ld config";
if (!is_debuggable_build()) {
- // LD_CONFIG_FILE is not supported on user build
- return;
+ GTEST_SKIP() << "LD_CONFIG_FILE is not supported on user build";
}
std::string helper = GetTestlibRoot() +
"/ld_config_test_helper/ld_config_test_helper";
@@ -267,8 +302,7 @@
#if defined(__BIONIC__)
SKIP_WITH_HWASAN << "libclang_rt.hwasan is not found with custom ld config";
if (!is_debuggable_build()) {
- // LD_CONFIG_FILE is not supported on user build
- return;
+ GTEST_SKIP() << "LD_CONFIG_FILE is not supported on user build";
}
std::string helper = GetTestlibRoot() +
"/ld_config_test_helper/ld_config_test_helper";
@@ -292,14 +326,15 @@
if (getuid() == 0) {
// when executed from the shell (e.g. not as part of CTS), skip the test.
// This test is only for CTS.
- return;
+ GTEST_SKIP() << "test is not supported with root uid";
}
if (is_debuggable_build()) {
- // Skip the test for non production devices
- return;
+ GTEST_SKIP() << "test is not supported on debuggable build";
}
- std::string error_message = "CANNOT LINK EXECUTABLE \"" + GetTestlibRoot() + "/ld_config_test_helper/ld_config_test_helper\": library \"ld_config_test_helper_lib1.so\" not found\n";
+ std::string error_message = std::string("CANNOT LINK EXECUTABLE ") +
+ "\"" + GetTestlibRoot() + "/ld_config_test_helper/ld_config_test_helper\": " +
+ "library \"ld_config_test_helper_lib1.so\" not found: needed by main executable\n";
std::string helper = GetTestlibRoot() +
"/ld_config_test_helper/ld_config_test_helper";
TemporaryFile config_file;
diff --git a/tests/dlext_test.cpp b/tests/dlext_test.cpp
index e98d66f..0b4cacb 100644
--- a/tests/dlext_test.cpp
+++ b/tests/dlext_test.cpp
@@ -28,6 +28,7 @@
#include <android/dlext.h>
#include <android-base/file.h>
#include <android-base/strings.h>
+#include <android-base/test_utils.h>
#include <sys/mman.h>
#include <sys/types.h>
@@ -1374,7 +1375,10 @@
void* handle2 = android_dlopen_ext(root_lib, RTLD_NOW, &extinfo);
ASSERT_TRUE(handle2 == nullptr);
- ASSERT_STREQ("dlopen failed: library \"libnstest_private_external.so\" not found", dlerror());
+ const char* error = dlerror();
+ ASSERT_MATCH(error,
+ R"(dlopen failed: library "libnstest_private_external.so" not found: needed by )"
+ R"(\S+libnstest_root_not_isolated.so in namespace private_isolated1)");
// Check dlopen by absolute path
handle2 = android_dlopen_ext(lib_private_external_path.c_str(), RTLD_NOW, &extinfo);
@@ -1502,7 +1506,9 @@
void* handle2 = android_dlopen_ext(root_lib, RTLD_NOW, &extinfo);
ASSERT_TRUE(handle2 == nullptr);
- ASSERT_STREQ("dlopen failed: library \"libnstest_private_external.so\" not found", dlerror());
+ ASSERT_MATCH(dlerror(),
+ R"(dlopen failed: library "libnstest_private_external.so" not found: needed by )"
+ R"(\S+libnstest_root_not_isolated.so in namespace private_isolated_shared)");
// Check dlopen by absolute path
handle2 = android_dlopen_ext(lib_private_external_path.c_str(), RTLD_NOW, &extinfo);
@@ -1762,7 +1768,10 @@
handle1 = android_dlopen_ext(root_lib, RTLD_NOW, &extinfo);
ASSERT_TRUE(handle1 == nullptr);
- ASSERT_STREQ("dlopen failed: library \"libnstest_public.so\" not found", dlerror());
+ ASSERT_MATCH(
+ dlerror(),
+ R"(dlopen failed: library "libnstest_public.so" not found: needed by \S+libnstest_root.so)"
+ R"( in namespace isolated2)");
}
TEST(dlext, ns_inaccessible_error_message) {
@@ -2005,10 +2014,15 @@
// For some natively bridged environments this code might be missing
// the executable flag. This is because the guest code is not supposed
// to be executed directly and making it non-executable is more secure.
- // If this is the case we assume that the first segment is the one that
- // has this flag.
- ASSERT_TRUE((maps_to_copy[0].perms & PROT_WRITE) == 0);
- maps_to_copy[0].perms |= PROT_EXEC;
+ // In this case we assume the segment with the function is executable.
+ for (auto& rec : maps_to_copy) {
+ if (ns_get_dlopened_string_addr >= rec.addr_start &&
+ ns_get_dlopened_string_addr < rec.addr_end) {
+ ASSERT_TRUE((rec.perms & PROT_WRITE) == 0);
+ rec.perms |= PROT_EXEC;
+ break;
+ }
+ }
}
// copy
diff --git a/tests/signal_test.cpp b/tests/signal_test.cpp
index 6db7751..eec56dc 100644
--- a/tests/signal_test.cpp
+++ b/tests/signal_test.cpp
@@ -24,9 +24,12 @@
#include <thread>
#include <android-base/macros.h>
+#include <android-base/threads.h>
+
#include <gtest/gtest.h>
#include "SignalUtils.h"
+#include "utils.h"
using namespace std::chrono_literals;
@@ -174,10 +177,10 @@
sigemptyset64(&wait_set);
sigaddset64(&wait_set, SIGRTMIN);
- pid_t pid = getpid();
- std::thread thread([&pid]() {
- usleep(5000);
- kill(pid, SIGRTMIN);
+ pid_t tid = gettid();
+ std::thread thread([&tid]() {
+ sleep(1);
+ tgkill(getpid(), tid, SIGRTMIN);
});
int received_signal;
diff --git a/tests/string_test.cpp b/tests/string_test.cpp
index 335d33b..0ed0598 100644
--- a/tests/string_test.cpp
+++ b/tests/string_test.cpp
@@ -1548,11 +1548,31 @@
}
TEST(STRING_TEST, strstr_smoke) {
- const char* haystack = "big daddy/giant haystacks";
- ASSERT_EQ(haystack, strstr(haystack, ""));
+ const char* haystack = "big daddy/giant haystacks!";
+
+ // The current strstr() implementation has special cases for needles of
+ // lengths 0, 1, 2, 3, and 4, plus a long needle case. We test matches at the
+ // beginning, middle, and end of the haystack.
+
+ ASSERT_EQ(haystack + 0, strstr(haystack, ""));
+
ASSERT_EQ(haystack + 0, strstr(haystack, "b"));
- ASSERT_EQ(haystack + 1, strstr(haystack, "i"));
- ASSERT_EQ(haystack + 4, strstr(haystack, "da"));
+ ASSERT_EQ(haystack + 0, strstr(haystack, "bi"));
+ ASSERT_EQ(haystack + 0, strstr(haystack, "big"));
+ ASSERT_EQ(haystack + 0, strstr(haystack, "big "));
+ ASSERT_EQ(haystack + 0, strstr(haystack, "big d"));
+
+ ASSERT_EQ(haystack + 2, strstr(haystack, "g"));
+ ASSERT_EQ(haystack + 10, strstr(haystack, "gi"));
+ ASSERT_EQ(haystack + 10, strstr(haystack, "gia"));
+ ASSERT_EQ(haystack + 10, strstr(haystack, "gian"));
+ ASSERT_EQ(haystack + 10, strstr(haystack, "giant"));
+
+ ASSERT_EQ(haystack + 25, strstr(haystack, "!"));
+ ASSERT_EQ(haystack + 24, strstr(haystack, "s!"));
+ ASSERT_EQ(haystack + 23, strstr(haystack, "ks!"));
+ ASSERT_EQ(haystack + 22, strstr(haystack, "cks!"));
+ ASSERT_EQ(haystack + 21, strstr(haystack, "acks!"));
}
TEST(STRING_TEST, strcasestr_smoke) {
diff --git a/tests/sys_ptrace_test.cpp b/tests/sys_ptrace_test.cpp
index 15e9a24..f17f80c 100644
--- a/tests/sys_ptrace_test.cpp
+++ b/tests/sys_ptrace_test.cpp
@@ -92,8 +92,14 @@
feature == HwFeature::Watchpoint ? NT_ARM_HW_WATCH : NT_ARM_HW_BREAK, &iov);
if (result == -1) {
ASSERT_EQ(EINVAL, errno);
+ GTEST_SKIP() << "Hardware support missing";
+ } else if ((dreg_state.dbg_info & 0xff) == 0) {
+ if (feature == HwFeature::Watchpoint) {
+ GTEST_SKIP() << "Kernel reports zero hardware watchpoints";
+ } else {
+ GTEST_SKIP() << "Kernel reports zero hardware breakpoints";
+ }
}
- if ((dreg_state.dbg_info & 0xff) == 0) GTEST_SKIP() << "hardware support missing";
#else
// We assume watchpoints and breakpoints are always supported on x86.
UNUSED(child);
diff --git a/tests/system_properties_test.cpp b/tests/system_properties_test.cpp
index 245e42f..6d696c7 100644
--- a/tests/system_properties_test.cpp
+++ b/tests/system_properties_test.cpp
@@ -340,9 +340,9 @@
ASSERT_EQ(0, system_properties.Add("property", 8, "value1", 6));
const prop_info* pi = system_properties.Find("property");
ASSERT_TRUE(pi != nullptr);
- unsigned serial = system_properties.Serial(pi);
+ unsigned serial = __system_property_serial(pi);
ASSERT_EQ(0, system_properties.Update(const_cast<prop_info*>(pi), "value2", 6));
- ASSERT_NE(serial, system_properties.Serial(pi));
+ ASSERT_NE(serial, __system_property_serial(pi));
#else // __BIONIC__
GTEST_SKIP() << "bionic-only test";
#endif // __BIONIC__
@@ -389,7 +389,7 @@
prop_info* pi = const_cast<prop_info*>(system_properties.Find("property"));
ASSERT_TRUE(pi != nullptr);
- unsigned serial = system_properties.Serial(pi);
+ unsigned serial = __system_property_serial(pi);
std::thread thread([&system_properties]() {
prop_info* pi = const_cast<prop_info*>(system_properties.Find("property"));
diff --git a/tests/unistd_test.cpp b/tests/unistd_test.cpp
index 99d92e6..f3b08c3 100644
--- a/tests/unistd_test.cpp
+++ b/tests/unistd_test.cpp
@@ -27,6 +27,7 @@
#include <stdint.h>
#include <sys/capability.h>
#include <sys/param.h>
+#include <sys/resource.h>
#include <sys/syscall.h>
#include <sys/types.h>
#include <sys/utsname.h>
@@ -1065,11 +1066,38 @@
}
TEST(UNISTD_TEST, sysconf_SC_ARG_MAX) {
- // https://lkml.org/lkml/2017/11/15/813.
-#if !defined(ARG_MAX)
-#define ARG_MAX 131072
-#endif
- ASSERT_EQ(ARG_MAX, sysconf(_SC_ARG_MAX));
+ // Since Linux 2.6.23, ARG_MAX isn't a constant and depends on RLIMIT_STACK.
+ // See prepare_arg_pages() in the kernel for the gory details:
+ // https://elixir.bootlin.com/linux/v5.3.11/source/fs/exec.c#L451
+
+ // Get our current limit, and set things up so we restore the limit.
+ rlimit rl;
+ ASSERT_EQ(0, getrlimit(RLIMIT_STACK, &rl));
+ uint64_t original_rlim_cur = rl.rlim_cur;
+ if (rl.rlim_cur == RLIM_INFINITY) {
+ rl.rlim_cur = 8 * 1024 * 1024; // Bionic reports unlimited stacks as 8MiB.
+ }
+ auto guard = android::base::make_scope_guard([&rl, original_rlim_cur]() {
+ rl.rlim_cur = original_rlim_cur;
+ ASSERT_EQ(0, setrlimit(RLIMIT_STACK, &rl));
+ });
+
+ // _SC_ARG_MAX should be 1/4 the stack size.
+ EXPECT_EQ(static_cast<long>(rl.rlim_cur / 4), sysconf(_SC_ARG_MAX));
+
+ // If you have a really small stack, the kernel still guarantees "32 pages" (see fs/exec.c).
+ rl.rlim_cur = 1024;
+ rl.rlim_max = RLIM_INFINITY;
+ ASSERT_EQ(0, setrlimit(RLIMIT_STACK, &rl));
+
+ EXPECT_EQ(static_cast<long>(32 * sysconf(_SC_PAGE_SIZE)), sysconf(_SC_ARG_MAX));
+
+ // With a 128-page stack limit, we know exactly what _SC_ARG_MAX should be...
+ rl.rlim_cur = 128 * sysconf(_SC_PAGE_SIZE);
+ rl.rlim_max = RLIM_INFINITY;
+ ASSERT_EQ(0, setrlimit(RLIMIT_STACK, &rl));
+
+ EXPECT_EQ(static_cast<long>((128 * sysconf(_SC_PAGE_SIZE)) / 4), sysconf(_SC_ARG_MAX));
}
TEST(UNISTD_TEST, sysconf_unknown) {
diff --git a/tools/versioner/src/Driver.cpp b/tools/versioner/src/Driver.cpp
index bad63ad..927a0f5 100644
--- a/tools/versioner/src/Driver.cpp
+++ b/tools/versioner/src/Driver.cpp
@@ -242,8 +242,7 @@
auto diags = constructDiags();
std::vector<const char*> cc1_flags = getCC1Command(type, filename);
auto invocation = std::make_unique<CompilerInvocation>();
- if (!CompilerInvocation::CreateFromArgs(*invocation.get(), &cc1_flags.front(),
- &cc1_flags.front() + cc1_flags.size(), *diags)) {
+ if (!CompilerInvocation::CreateFromArgs(*invocation.get(), cc1_flags, *diags)) {
errx(1, "failed to create CompilerInvocation");
}