Merge "Sync strptime.c with upstream."
diff --git a/OWNERS b/OWNERS
index 670f88d..3818b1d 100644
--- a/OWNERS
+++ b/OWNERS
@@ -1,6 +1,7 @@
 enh@google.com
 
 cferris@google.com
+chiahungduan@google.com
 danalbert@google.com
 rprichard@google.com
 yabinc@google.com
diff --git a/android-changes-for-ndk-developers.md b/android-changes-for-ndk-developers.md
index 13c8911..c5a6ac3 100644
--- a/android-changes-for-ndk-developers.md
+++ b/android-changes-for-ndk-developers.md
@@ -475,3 +475,7 @@
 There are no plans to remove support for ELF files using the older
 OS private use constants for RELR, nor for ELF files using packed
 relocations.
+
+You can read more about relative relocations
+and their long and complicated history at
+https://maskray.me/blog/2021-10-31-relative-relocations-and-relr.
diff --git a/benchmarks/Android.bp b/benchmarks/Android.bp
index 5dfc38f..17d2d68 100644
--- a/benchmarks/Android.bp
+++ b/benchmarks/Android.bp
@@ -156,3 +156,23 @@
     ],
     data: ["test_suites/*"],
 }
+
+cc_binary {
+    name: "malloc-rss-benchmark",
+    srcs: [
+        "malloc_rss_benchmark.cpp",
+    ],
+
+    shared_libs: [
+        "libbase",
+    ],
+
+    target: {
+        android: {
+            static_libs: [
+                "libmeminfo",
+                "libprocinfo",
+            ],
+        },
+    },
+}
diff --git a/benchmarks/NOTICE b/benchmarks/NOTICE
index f720e23..e46a624 100644
--- a/benchmarks/NOTICE
+++ b/benchmarks/NOTICE
@@ -178,3 +178,31 @@
 
 -------------------------------------------------------------------
 
+Copyright (C) 2022 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.
+
+-------------------------------------------------------------------
+
diff --git a/benchmarks/malloc_rss_benchmark.cpp b/benchmarks/malloc_rss_benchmark.cpp
new file mode 100644
index 0000000..58f61d9
--- /dev/null
+++ b/benchmarks/malloc_rss_benchmark.cpp
@@ -0,0 +1,165 @@
+/*
+ * Copyright (C) 2022 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 <string.h>
+#include <unistd.h>
+
+#include <algorithm>
+#include <chrono>
+#include <iostream>
+#include <memory>
+#include <random>
+#include <thread>
+#include <vector>
+
+#include <android-base/strings.h>
+#if defined(__BIONIC__)
+#include <malloc.h>
+#include <meminfo/procmeminfo.h>
+#include <procinfo/process_map.h>
+#endif
+
+constexpr size_t kMaxThreads = 8;
+// The max number of bytes that can be allocated by a thread. Note that each
+// allocator may have its own limitation on each size allocation. For example,
+// Scudo has a 256 MB limit for each size-class in the primary allocator. The
+// amount of memory allocated should not exceed the limit in each allocator.
+constexpr size_t kMaxBytes = 1 << 24;
+constexpr size_t kMaxLen = kMaxBytes;
+void* MemPool[kMaxThreads][kMaxLen];
+
+void dirtyMem(void* ptr, size_t bytes) {
+  memset(ptr, 1U, bytes);
+}
+
+void ThreadTask(int id, size_t allocSize) {
+  // In the following, we will first allocate blocks with kMaxBytes of memory
+  // and release all of them in random order. In the end, we will do another
+  // round of allocations until it reaches 1/10 kMaxBytes.
+
+  // Total number of blocks
+  const size_t maxCounts = kMaxBytes / allocSize;
+  // The number of blocks in the end
+  const size_t finalCounts = maxCounts / 10;
+
+  for (size_t i = 0; i < maxCounts; ++i) {
+    MemPool[id][i] = malloc(allocSize);
+    if (MemPool[id][i] == 0) {
+      std::cout << "Allocation failure."
+                   "Please consider reducing the number of threads"
+                << std::endl;
+      exit(1);
+    }
+    dirtyMem(MemPool[id][i], allocSize);
+  }
+
+  // Each allocator may apply different strategies to manage the free blocks and
+  // each strategy may have different impacts on future memory usage. For
+  // example, managing free blocks in simple FIFO list may have its memory usage
+  // highly correlated with the blocks releasing pattern. Therefore, release the
+  // blocks in random order to observe the impact of free blocks handling.
+  unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
+  std::shuffle(MemPool[id], MemPool[id] + maxCounts, std::default_random_engine(seed));
+  for (size_t i = 0; i < maxCounts; ++i) {
+    free(MemPool[id][i]);
+    MemPool[id][i] = nullptr;
+  }
+
+  for (size_t i = 0; i < finalCounts; ++i) {
+    MemPool[id][i] = malloc(allocSize);
+    dirtyMem(MemPool[id][i], allocSize);
+  }
+}
+
+void StressSizeClass(size_t numThreads, size_t allocSize) {
+  // We would like to see the minimum memory usage under aggressive page
+  // releasing.
+  mallopt(M_DECAY_TIME, 0);
+
+  std::thread* threads[kMaxThreads];
+  for (size_t i = 0; i < numThreads; ++i) threads[i] = new std::thread(ThreadTask, i, allocSize);
+
+  for (size_t i = 0; i < numThreads; ++i) {
+    threads[i]->join();
+    delete threads[i];
+  }
+
+  // Do an explicit purge to ensure we will be more likely to get the actual
+  // in-use memory.
+  mallopt(M_PURGE, 0);
+
+  android::meminfo::ProcMemInfo proc_mem(getpid());
+  const std::vector<android::meminfo::Vma>& maps = proc_mem.MapsWithoutUsageStats();
+  uint64_t rss_bytes = 0;
+  uint64_t vss_bytes = 0;
+
+  for (auto& vma : maps) {
+    if (vma.name == "[anon:libc_malloc]" || android::base::StartsWith(vma.name, "[anon:scudo:") ||
+        android::base::StartsWith(vma.name, "[anon:GWP-ASan")) {
+      android::meminfo::Vma update_vma(vma);
+      if (!proc_mem.FillInVmaStats(update_vma)) {
+        std::cout << "Failed to parse VMA" << std::endl;
+        exit(1);
+      }
+      rss_bytes += update_vma.usage.rss;
+      vss_bytes += update_vma.usage.vss;
+    }
+  }
+
+  std::cout << "RSS: " << rss_bytes / (1024.0 * 1024.0) << " MB" << std::endl;
+  std::cout << "VSS: " << vss_bytes / (1024.0 * 1024.0) << " MB" << std::endl;
+
+  for (size_t i = 0; i < numThreads; ++i) {
+    for (size_t j = 0; j < kMaxLen; ++j) free(MemPool[i][j]);
+  }
+}
+
+int main(int argc, char* argv[]) {
+  if (argc != 3) {
+    std::cerr << "usage: " << argv[0] << " $NUM_THREADS $ALLOC_SIZE" << std::endl;
+    return 1;
+  }
+
+  size_t numThreads = atoi(argv[1]);
+  size_t allocSize = atoi(argv[2]);
+
+  if (numThreads == 0 || allocSize == 0) {
+    std::cerr << "Please provide valid $NUM_THREADS and $ALLOC_SIZE" << std::endl;
+    return 1;
+  }
+
+  if (numThreads > kMaxThreads) {
+    std::cerr << "The max number of threads is " << kMaxThreads << std::endl;
+    return 1;
+  }
+
+  StressSizeClass(numThreads, allocSize);
+
+  return 0;
+}
diff --git a/libc/Android.bp b/libc/Android.bp
index 5732490..fb4825d 100644
--- a/libc/Android.bp
+++ b/libc/Android.bp
@@ -248,6 +248,7 @@
 cc_library_static {
 
     defaults: ["libc_defaults"],
+    tidy_disabled_srcs: ["upstream-*/**/*.c"],
     srcs: [
         "tzcode/**/*.c",
         "tzcode/bionic.cpp",
@@ -294,6 +295,7 @@
 cc_library_static {
 
     defaults: ["libc_defaults"],
+    tidy_disabled_srcs: ["upstream-*/**/*.c"],
     srcs: [
         "dns/**/*.c*",
 
@@ -329,6 +331,7 @@
 
 cc_library_static {
     defaults: ["libc_defaults"],
+    tidy_disabled_srcs: ["upstream-*/**/*.c"],
     srcs: [
         "upstream-freebsd/lib/libc/gen/ldexp.c",
         "upstream-freebsd/lib/libc/stdlib/getopt_long.c",
@@ -395,6 +398,7 @@
 
 cc_library_static {
     defaults: ["libc_defaults"],
+    tidy_disabled_srcs: ["upstream-*/**/*.c"],
     srcs: [
         "upstream-freebsd/lib/libc/gen/glob.c",
     ],
@@ -422,6 +426,7 @@
 cc_library_static {
 
     defaults: ["libc_defaults"],
+    tidy_disabled_srcs: ["upstream-*/**/*.c"],
     srcs: [
         "upstream-netbsd/common/lib/libc/stdlib/random.c",
         "upstream-netbsd/lib/libc/gen/nice.c",
@@ -479,6 +484,7 @@
 cc_library_static {
     name: "libc_openbsd_ndk",
     defaults: ["libc_defaults"],
+    tidy_disabled_srcs: ["upstream-*/**/*.c"],
     srcs: [
         "upstream-openbsd/lib/libc/gen/alarm.c",
         "upstream-openbsd/lib/libc/gen/ctype_.c",
@@ -597,6 +603,7 @@
 cc_library_static {
     name: "libc_openbsd_large_stack",
     defaults: ["libc_defaults"],
+    tidy_disabled_srcs: ["upstream-*/**/*.c"],
     srcs: [
         "stdio/vfprintf.cpp",
         "stdio/vfwprintf.cpp",
@@ -626,6 +633,7 @@
 // automatically included.
 cc_library_static {
     defaults: ["libc_defaults"],
+    tidy_disabled_srcs: ["upstream-*/**/*.c"],
     srcs: [
         // These two depend on getentropy, which isn't in libc_ndk.a.
         "upstream-openbsd/lib/libc/crypt/arc4random.c",
@@ -725,6 +733,7 @@
 
 cc_library_static {
     defaults: ["libc_defaults"],
+    tidy_disabled_srcs: ["upstream-*/**/*.c"],
     srcs: [
         "upstream-openbsd/android/gdtoa_support.cpp",
         "upstream-openbsd/lib/libc/gdtoa/dmisc.c",
@@ -2264,6 +2273,48 @@
 }
 
 // ========================================================
+// libc dependencies for baremetal Rust projects.
+// ========================================================
+
+// This library contains the following unresolved symbols:
+//     __errno
+//     abort
+//     async_safe_fatal_va_list
+cc_library_static {
+    name: "librust_baremetal",
+    header_libs: ["libc_headers"],
+    include_dirs: [
+        "bionic/libc/async_safe/include",
+        "bionic/libc/platform",
+    ],
+    cflags: [
+        "-Wall",
+        "-Werror",
+    ],
+    srcs: [
+        "bionic/fortify.cpp",
+        "bionic/strtol.cpp",
+    ],
+    arch: {
+        arm64: {
+            cflags: ["-DHAVE_ASSEMBLER___MEMCPY_CHK"],
+            srcs: [
+                "arch-arm64/string/__memcpy_chk.S",
+            ],
+        },
+    },
+    whole_static_libs: [
+        "libarm-optimized-routines-mem",
+    ],
+    system_shared_libs: [],
+    nocrt: true,
+    stl: "none",
+    visibility: [
+        "//packages/modules/Virtualization/vmbase",
+    ],
+}
+
+// ========================================================
 // NDK headers.
 // ========================================================
 
@@ -2785,6 +2836,7 @@
 
 cc_library_host_static {
     name: "libfts",
+    tidy_disabled_srcs: ["upstream-*/**/*.c"],
     srcs: [
         "bionic/fts.c",
         "upstream-openbsd/lib/libc/stdlib/recallocarray.c",
@@ -2827,6 +2879,7 @@
 cc_library_host_static {
     name: "libb64",
     visibility: ["//external/musl"],
+    tidy_disabled_srcs: ["upstream-*/**/*.c"],
     srcs: ["upstream-openbsd/lib/libc/net/base64.c"],
     export_include_dirs: ["b64/include"],
     local_include_dirs: [
diff --git a/libc/bionic/malloc_common_dynamic.cpp b/libc/bionic/malloc_common_dynamic.cpp
index 97e8d15..802a94f 100644
--- a/libc/bionic/malloc_common_dynamic.cpp
+++ b/libc/bionic/malloc_common_dynamic.cpp
@@ -371,6 +371,7 @@
 extern "C" const char* __scudo_get_stack_depot_addr();
 extern "C" const char* __scudo_get_region_info_addr();
 extern "C" const char* __scudo_get_ring_buffer_addr();
+extern "C" size_t __scudo_get_ring_buffer_size();
 
 // Initializes memory allocation framework once per process.
 static void MallocInitImpl(libc_globals* globals) {
@@ -383,6 +384,7 @@
   __libc_shared_globals()->scudo_stack_depot = __scudo_get_stack_depot_addr();
   __libc_shared_globals()->scudo_region_info = __scudo_get_region_info_addr();
   __libc_shared_globals()->scudo_ring_buffer = __scudo_get_ring_buffer_addr();
+  __libc_shared_globals()->scudo_ring_buffer_size = __scudo_get_ring_buffer_size();
 #endif
 
   // Prefer malloc debug since it existed first and is a more complete
diff --git a/libc/bionic/sysconf.cpp b/libc/bionic/sysconf.cpp
index dd6b129..1c06c9e 100644
--- a/libc/bionic/sysconf.cpp
+++ b/libc/bionic/sysconf.cpp
@@ -88,7 +88,7 @@
     case _SC_PAGESIZE:
     case _SC_PAGE_SIZE:
       // _SC_PAGESIZE and _SC_PAGE_SIZE are distinct, but return the same value.
-      return static_cast<long>(getauxval(AT_PAGESZ));
+      return getpagesize();
 
     case _SC_PHYS_PAGES:        return get_phys_pages();
 
diff --git a/libc/include/execinfo.h b/libc/include/execinfo.h
index 347ae92..88f4ae7 100644
--- a/libc/include/execinfo.h
+++ b/libc/include/execinfo.h
@@ -47,7 +47,7 @@
  *
  * Available since API level 33.
  */
-int backtrace(void** buffer, int size) __INTRODUCED_IN(33);
+int backtrace(void* _Nonnull * _Nonnull buffer, int size) __INTRODUCED_IN(33);
 
 /**
  * [backtrace_symbols(3)](https://man7.org/linux/man-pages/man3/backtrace_symbols.3.html)
@@ -59,7 +59,7 @@
  *
  * Available since API level 33.
  */
-char** backtrace_symbols(void* const* buffer, int size) __INTRODUCED_IN(33);
+char* _Nullable * _Nullable backtrace_symbols(void* _Nonnull const* _Nonnull buffer, int size) __INTRODUCED_IN(33);
 
 /**
  * [backtrace_symbols_fd(3)](https://man7.org/linux/man-pages/man3/backtrace_symbols_fd.3.html)
@@ -69,6 +69,6 @@
  *
  * Available since API level 33.
  */
-void backtrace_symbols_fd(void* const* buffer, int size, int fd) __INTRODUCED_IN(33);
+void backtrace_symbols_fd(void* _Nonnull const* _Nonnull buffer, int size, int fd) __INTRODUCED_IN(33);
 
 __END_DECLS
diff --git a/libc/include/inttypes.h b/libc/include/inttypes.h
index 7a409d8..f8b7f7d 100644
--- a/libc/include/inttypes.h
+++ b/libc/include/inttypes.h
@@ -257,10 +257,10 @@
 __BEGIN_DECLS
 intmax_t imaxabs(intmax_t __i) __attribute_const__ __INTRODUCED_IN(19);
 imaxdiv_t imaxdiv(intmax_t __numerator, intmax_t __denominator) __attribute_const__ __INTRODUCED_IN(19);
-intmax_t strtoimax(const char* __s, char** __end_ptr, int __base);
-uintmax_t strtoumax(const char* __s, char** __end_ptr, int __base);
-intmax_t wcstoimax(const wchar_t* __s, wchar_t** __end_ptr, int __base) __INTRODUCED_IN(21);
-uintmax_t wcstoumax(const wchar_t* __s, wchar_t** __end_ptr, int __base) __INTRODUCED_IN(21);
+intmax_t strtoimax(const char* _Nonnull __s, char* _Nullable * _Nullable __end_ptr, int __base);
+uintmax_t strtoumax(const char* _Nonnull __s, char* _Nullable * _Nullable __end_ptr, int __base);
+intmax_t wcstoimax(const wchar_t* _Nonnull __s, wchar_t* _Nullable * _Nullable __end_ptr, int __base) __INTRODUCED_IN(21);
+uintmax_t wcstoumax(const wchar_t* _Nonnull __s, wchar_t* _Nullable * _Nullable __end_ptr, int __base) __INTRODUCED_IN(21);
 __END_DECLS
 
 #endif
diff --git a/libc/include/langinfo.h b/libc/include/langinfo.h
index d9d8c15..2b43892 100644
--- a/libc/include/langinfo.h
+++ b/libc/include/langinfo.h
@@ -92,8 +92,8 @@
 #define NOEXPR 54
 #define CRNCYSTR 55
 
-char* nl_langinfo(nl_item __item) __INTRODUCED_IN(26);
-char* nl_langinfo_l(nl_item __item, locale_t __l) __INTRODUCED_IN(26);
+char* _Nonnull nl_langinfo(nl_item __item) __INTRODUCED_IN(26);
+char* _Nonnull nl_langinfo_l(nl_item __item, locale_t _Nonnull __l) __INTRODUCED_IN(26);
 
 __END_DECLS
 
diff --git a/libc/include/libgen.h b/libc/include/libgen.h
index b910790..474f066 100644
--- a/libc/include/libgen.h
+++ b/libc/include/libgen.h
@@ -50,7 +50,7 @@
  * Note that Android's cv-qualifiers differ from POSIX; Android's implementation doesn't
  * modify its input and uses thread-local storage for the result if necessary.
  */
-char* __posix_basename(const char* __path) __RENAME(basename);
+char* _Nullable __posix_basename(const char* _Nullable __path) __RENAME(basename);
 
 /**
  * This macro ensures that callers get the POSIX basename() if they include this header,
@@ -65,13 +65,13 @@
  * Note that Android's cv-qualifiers differ from POSIX; Android's implementation doesn't
  * modify its input and uses thread-local storage for the result if necessary.
  */
-char* dirname(const char* __path);
+char* _Nullable dirname(const char* _Nullable __path);
 
 #if !defined(__LP64__)
 /** Deprecated. Use dirname() instead. */
-int dirname_r(const char* __path, char* __buf, size_t __n);
+int dirname_r(const char* _Nullable __path, char* _Nullable __buf, size_t __n);
 /** Deprecated. Use basename() instead. */
-int basename_r(const char* __path, char* __buf, size_t __n);
+int basename_r(const char* _Nullable __path, char* _Nullable __buf, size_t __n);
 #endif
 
 __END_DECLS
diff --git a/libc/include/malloc.h b/libc/include/malloc.h
index 40786fa..02bda60 100644
--- a/libc/include/malloc.h
+++ b/libc/include/malloc.h
@@ -40,7 +40,7 @@
  * Returns a pointer to the allocated memory on success and returns a null
  * pointer and sets `errno` on failure.
  */
-void* malloc(size_t __byte_count) __mallocfunc __BIONIC_ALLOC_SIZE(1) __wur;
+void* _Nullable malloc(size_t __byte_count) __mallocfunc __BIONIC_ALLOC_SIZE(1) __wur;
 
 /**
  * [calloc(3)](http://man7.org/linux/man-pages/man3/calloc.3.html) allocates
@@ -49,7 +49,7 @@
  * Returns a pointer to the allocated memory on success and returns a null
  * pointer and sets `errno` on failure.
  */
-void* calloc(size_t __item_count, size_t __item_size) __mallocfunc __BIONIC_ALLOC_SIZE(1,2) __wur;
+void* _Nullable calloc(size_t __item_count, size_t __item_size) __mallocfunc __BIONIC_ALLOC_SIZE(1,2) __wur;
 
 /**
  * [realloc(3)](http://man7.org/linux/man-pages/man3/realloc.3.html) resizes
@@ -58,7 +58,7 @@
  * Returns a pointer (which may be different from `__ptr`) to the resized
  * memory on success and returns a null pointer and sets `errno` on failure.
  */
-void* realloc(void* __ptr, size_t __byte_count) __BIONIC_ALLOC_SIZE(2) __wur;
+void* _Nullable realloc(void* _Nullable __ptr, size_t __byte_count) __BIONIC_ALLOC_SIZE(2) __wur;
 
 /**
  * [reallocarray(3)](http://man7.org/linux/man-pages/man3/realloc.3.html) resizes
@@ -70,13 +70,13 @@
  * Returns a pointer (which may be different from `__ptr`) to the resized
  * memory on success and returns a null pointer and sets `errno` on failure.
  */
-void* reallocarray(void* __ptr, size_t __item_count, size_t __item_size) __BIONIC_ALLOC_SIZE(2, 3) __wur __INTRODUCED_IN(29);
+void* _Nullable reallocarray(void* _Nullable __ptr, size_t __item_count, size_t __item_size) __BIONIC_ALLOC_SIZE(2, 3) __wur __INTRODUCED_IN(29);
 
 /**
  * [free(3)](http://man7.org/linux/man-pages/man3/free.3.html) deallocates
  * memory on the heap.
  */
-void free(void* __ptr);
+void free(void* _Nullable __ptr);
 
 /**
  * [memalign(3)](http://man7.org/linux/man-pages/man3/memalign.3.html) allocates
@@ -87,7 +87,7 @@
  *
  * See also posix_memalign().
  */
-void* memalign(size_t __alignment, size_t __byte_count) __mallocfunc __BIONIC_ALLOC_SIZE(2) __wur;
+void* _Nullable memalign(size_t __alignment, size_t __byte_count) __mallocfunc __BIONIC_ALLOC_SIZE(2) __wur;
 
 /**
  * [malloc_usable_size(3)](http://man7.org/linux/man-pages/man3/malloc_usable_size.3.html)
@@ -95,7 +95,7 @@
  *
  * Available since API level 17.
  */
-size_t malloc_usable_size(const void* __ptr) __INTRODUCED_IN(17);
+size_t malloc_usable_size(const void* _Nullable __ptr) __INTRODUCED_IN(17);
 
 #define __MALLINFO_BODY \
   /** Total number of non-mmapped bytes currently allocated from OS. */ \
@@ -168,7 +168,7 @@
  *
  * Available since API level 23.
  */
-int malloc_info(int __must_be_zero, FILE* __fp) __INTRODUCED_IN(23);
+int malloc_info(int __must_be_zero, FILE* _Nonnull __fp) __INTRODUCED_IN(23);
 
 /**
  * mallopt() option to set the decay time. Valid values are 0 and 1.
@@ -329,7 +329,7 @@
  *
  * See also: [extra documentation](https://android.googlesource.com/platform/bionic/+/master/libc/malloc_hooks/README.md)
  */
-extern void* (*volatile __malloc_hook)(size_t __byte_count, const void* __caller) __INTRODUCED_IN(28);
+extern void* _Nonnull (*volatile _Nonnull __malloc_hook)(size_t __byte_count, const void* _Nonnull __caller) __INTRODUCED_IN(28);
 
 /**
  * [__realloc_hook(3)](http://man7.org/linux/man-pages/man3/__realloc_hook.3.html)
@@ -340,7 +340,7 @@
  *
  * See also: [extra documentation](https://android.googlesource.com/platform/bionic/+/master/libc/malloc_hooks/README.md)
  */
-extern void* (*volatile __realloc_hook)(void* __ptr, size_t __byte_count, const void* __caller) __INTRODUCED_IN(28);
+extern void* _Nonnull (*volatile _Nonnull __realloc_hook)(void* _Nullable __ptr, size_t __byte_count, const void* _Nonnull __caller) __INTRODUCED_IN(28);
 
 /**
  * [__free_hook(3)](http://man7.org/linux/man-pages/man3/__free_hook.3.html)
@@ -351,7 +351,7 @@
  *
  * See also: [extra documentation](https://android.googlesource.com/platform/bionic/+/master/libc/malloc_hooks/README.md)
  */
-extern void (*volatile __free_hook)(void* __ptr, const void* __caller) __INTRODUCED_IN(28);
+extern void (*volatile _Nonnull __free_hook)(void* _Nullable __ptr, const void* _Nonnull __caller) __INTRODUCED_IN(28);
 
 /**
  * [__memalign_hook(3)](http://man7.org/linux/man-pages/man3/__memalign_hook.3.html)
@@ -362,6 +362,6 @@
  *
  * See also: [extra documentation](https://android.googlesource.com/platform/bionic/+/master/libc/malloc_hooks/README.md)
  */
-extern void* (*volatile __memalign_hook)(size_t __alignment, size_t __byte_count, const void* __caller) __INTRODUCED_IN(28);
+extern void* _Nonnull (*volatile _Nonnull __memalign_hook)(size_t __alignment, size_t __byte_count, const void* _Nonnull __caller) __INTRODUCED_IN(28);
 
 __END_DECLS
diff --git a/libc/include/syslog.h b/libc/include/syslog.h
index 45de253..d89d769 100644
--- a/libc/include/syslog.h
+++ b/libc/include/syslog.h
@@ -133,9 +133,10 @@
 
 /**
  * [openlog(3)](http://man7.org/linux/man-pages/man3/openlog.3.html) sets
- * the log tag to `__prefix`. On Android, the other two arguments are ignored.
+ * the log tag to `__prefix`, which can be NULL to return to the default of
+ * getprogname(). On Android, the other two arguments are ignored.
  */
-void openlog(const char* __prefix, int __option, int __facility);
+void openlog(const char* _Nullable __prefix, int __option, int __facility);
 
 /**
  * [setlogmask(3)](http://man7.org/linux/man-pages/man3/setlogmask.3.html)
@@ -149,13 +150,13 @@
  * the printf()-like message and logs it with the given priority, unless
  * suppressed by setlogmask(). On Android, the output goes to logcat.
  */
-void syslog(int __priority, const char* __fmt, ...) __printflike(2, 3);
+void syslog(int __priority, const char* _Nonnull __fmt, ...) __printflike(2, 3);
 
 /**
  * [vsyslog(3)](http://man7.org/linux/man-pages/man3/vsyslog.3.html) formats
  * the vprintf()-like message and logs it with the given priority, unless
  * suppressed by setlogmask(). On Android, the output goes to logcat.
  */
-void vsyslog(int __priority, const char* __fmt, va_list __args) __printflike(2, 0);
+void vsyslog(int __priority, const char* _Nonnull __fmt, va_list __args) __printflike(2, 0);
 
 __END_DECLS
diff --git a/libc/include/termios.h b/libc/include/termios.h
index e3f388c..92ac24b 100644
--- a/libc/include/termios.h
+++ b/libc/include/termios.h
@@ -49,19 +49,19 @@
  * [cfgetispeed(3)](http://man7.org/linux/man-pages/man3/cfgetispeed.3.html)
  * returns the terminal input baud rate.
  */
-speed_t cfgetispeed(const struct termios* __t) __INTRODUCED_IN(21);
+speed_t cfgetispeed(const struct termios* _Nonnull __t) __INTRODUCED_IN(21);
 
 /**
  * [cfgetospeed(3)](http://man7.org/linux/man-pages/man3/cfgetospeed.3.html)
  * returns the terminal output baud rate.
  */
-speed_t cfgetospeed(const struct termios* __t) __INTRODUCED_IN(21);
+speed_t cfgetospeed(const struct termios* _Nonnull __t) __INTRODUCED_IN(21);
 
 /**
  * [cfmakeraw(3)](http://man7.org/linux/man-pages/man3/cfmakeraw.3.html)
  * configures the terminal for "raw" mode.
  */
-void cfmakeraw(struct termios* __t) __INTRODUCED_IN(21);
+void cfmakeraw(struct termios* _Nonnull __t) __INTRODUCED_IN(21);
 
 /**
  * [cfsetspeed(3)](http://man7.org/linux/man-pages/man3/cfsetspeed.3.html)
@@ -69,7 +69,7 @@
  *
  * Returns 0 on success and returns -1 and sets `errno` on failure.
  */
-int cfsetspeed(struct termios* __t, speed_t __speed) __INTRODUCED_IN(21);
+int cfsetspeed(struct termios* _Nonnull __t, speed_t __speed) __INTRODUCED_IN(21);
 
 /**
  * [cfsetispeed(3)](http://man7.org/linux/man-pages/man3/cfsetispeed.3.html)
@@ -77,7 +77,7 @@
  *
  * Returns 0 on success and returns -1 and sets `errno` on failure.
  */
-int cfsetispeed(struct termios* __t, speed_t __speed) __INTRODUCED_IN(21);
+int cfsetispeed(struct termios* _Nonnull _t, speed_t __speed) __INTRODUCED_IN(21);
 
 /**
  * [cfsetospeed(3)](http://man7.org/linux/man-pages/man3/cfsetospeed.3.html)
@@ -85,7 +85,7 @@
  *
  * Returns 0 on success and returns -1 and sets `errno` on failure.
  */
-int cfsetospeed(struct termios* __t, speed_t __speed) __INTRODUCED_IN(21);
+int cfsetospeed(struct termios* _Nonnull __t, speed_t __speed) __INTRODUCED_IN(21);
 
 /**
  * [tcdrain(3)](http://man7.org/linux/man-pages/man3/tcdrain.3.html)
@@ -120,7 +120,7 @@
  *
  * Returns 0 on success and returns -1 and sets `errno` on failure.
  */
-int tcgetattr(int __fd, struct termios* __t) __INTRODUCED_IN(21);
+int tcgetattr(int __fd, struct termios* _Nonnull __t) __INTRODUCED_IN(21);
 
 /**
  * [tcgetsid(3)](http://man7.org/linux/man-pages/man3/tcgetsid.3.html)
@@ -145,7 +145,7 @@
  *
  * Returns 0 on success and returns -1 and sets `errno` on failure.
  */
-int tcsetattr(int __fd, int __optional_actions, const struct termios* __t) __INTRODUCED_IN(21);
+int tcsetattr(int __fd, int __optional_actions, const struct termios* _Nonnull __t) __INTRODUCED_IN(21);
 
 #endif
 
diff --git a/libc/include/time.h b/libc/include/time.h
index 0db14ff..4b005c6 100644
--- a/libc/include/time.h
+++ b/libc/include/time.h
@@ -37,7 +37,7 @@
 
 #define CLOCKS_PER_SEC 1000000
 
-extern char* tzname[];
+extern char* _Nonnull tzname[];
 extern int daylight;
 extern long int timezone;
 
@@ -54,62 +54,64 @@
   int tm_yday;
   int tm_isdst;
   long int tm_gmtoff;
-  const char* tm_zone;
+  const char* _Nullable tm_zone;
 };
 
 #define TM_ZONE tm_zone
 
-time_t time(time_t* __t);
-int nanosleep(const struct timespec* __request, struct timespec* __remainder);
+time_t time(time_t* _Nullable __t);
+int nanosleep(const struct timespec* _Nonnull __request, struct timespec* _Nullable __remainder);
 
-char* asctime(const struct tm* __tm);
-char* asctime_r(const struct tm* __tm, char* __buf);
+char* _Nullable asctime(const struct tm* _Nonnull __tm);
+char* _Nullable asctime_r(const struct tm* _Nonnull __tm, char* _Nonnull __buf);
 
 double difftime(time_t __lhs, time_t __rhs);
-time_t mktime(struct tm* __tm);
+time_t mktime(struct tm* _Nonnull __tm);
 
-struct tm* localtime(const time_t* __t);
-struct tm* localtime_r(const time_t* __t, struct tm* __tm);
+struct tm* _Nullable localtime(const time_t* _Nonnull __t);
+struct tm* _Nullable localtime_r(const time_t* _Nonnull __t, struct tm* _Nonnull __tm);
 
-struct tm* gmtime(const time_t* __t);
-struct tm* gmtime_r(const time_t* __t, struct tm* __tm);
+struct tm* _Nullable gmtime(const time_t* _Nonnull __t);
+struct tm* _Nullable gmtime_r(const time_t* _Nonnull __t, struct tm* _Nonnull __tm);
 
-char* strptime(const char* __s, const char* __fmt, struct tm* __tm) __strftimelike(2);
-char* strptime_l(const char* __s, const char* __fmt, struct tm* __tm, locale_t __l) __strftimelike(2) __INTRODUCED_IN(28);
+char* _Nullable strptime(const char* _Nonnull __s, const char* _Nonnull __fmt, struct tm* _Nonnull __tm) __strftimelike(2);
+char* _Nullable strptime_l(const char* _Nonnull __s, const char* _Nonnull __fmt, struct tm* _Nonnull __tm, locale_t _Nonnull __l) __strftimelike(2) __INTRODUCED_IN(28);
 
-size_t strftime(char* __buf, size_t __n, const char* __fmt, const struct tm* __tm) __strftimelike(3);
+size_t strftime(char* _Nonnull __buf, size_t __n, const char* _Nonnull __fmt, const struct tm* _Nullable __tm) __strftimelike(3);
 #if __ANDROID_API__ >= 21
-size_t strftime_l(char* __buf, size_t __n, const char* __fmt, const struct tm* __tm, locale_t __l) __strftimelike(3) __INTRODUCED_IN(21);
+size_t strftime_l(char* _Nonnull __buf, size_t __n, const char* _Nonnull __fmt, const struct tm* _Nullable __tm, locale_t _Nonnull __l) __strftimelike(3) __INTRODUCED_IN(21);
 #else
 // Implemented as static inline before 21.
 #endif
 
-char* ctime(const time_t* __t);
-char* ctime_r(const time_t* __t, char* __buf);
+
+char* _Nullable ctime(const time_t* _Nonnull __t);
+char* _Nullable ctime_r(const time_t* _Nonnull __t, char* _Nonnull __buf);
 
 void tzset(void);
 
 clock_t clock(void);
 
-int clock_getcpuclockid(pid_t __pid, clockid_t* __clock) __INTRODUCED_IN(23);
+int clock_getcpuclockid(pid_t __pid, clockid_t* _Nonnull __clock) __INTRODUCED_IN(23);
 
-int clock_getres(clockid_t __clock, struct timespec* __resolution);
-int clock_gettime(clockid_t __clock, struct timespec* __ts);
-int clock_nanosleep(clockid_t __clock, int __flags, const struct timespec* __request, struct timespec* __remainder);
-int clock_settime(clockid_t __clock, const struct timespec* __ts);
 
-int timer_create(clockid_t __clock, struct sigevent* __event, timer_t* __timer_ptr);
-int timer_delete(timer_t __timer);
-int timer_settime(timer_t __timer, int __flags, const struct itimerspec* __new_value, struct itimerspec* __old_value);
-int timer_gettime(timer_t __timer, struct itimerspec* __ts);
-int timer_getoverrun(timer_t __timer);
+int clock_getres(clockid_t __clock, struct timespec* _Nullable __resolution);
+int clock_gettime(clockid_t __clock, struct timespec* _Nonnull __ts);
+int clock_nanosleep(clockid_t __clock, int __flags, const struct timespec* _Nonnull __request, struct timespec* _Nullable __remainder);
+int clock_settime(clockid_t __clock, const struct timespec* _Nonnull __ts);
+
+int timer_create(clockid_t __clock, struct sigevent* _Nullable __event, timer_t _Nonnull * _Nonnull __timer_ptr);
+int timer_delete(timer_t _Nonnull __timer);
+int timer_settime(timer_t _Nonnull __timer, int __flags, const struct itimerspec* _Nonnull __new_value, struct itimerspec* _Nullable __old_value);
+int timer_gettime(timer_t _Nonnull _timer, struct itimerspec* _Nonnull __ts);
+int timer_getoverrun(timer_t _Nonnull __timer);
 
 /* Non-standard extensions that are in the BSDs and glibc. */
-time_t timelocal(struct tm* __tm);
-time_t timegm(struct tm* __tm);
+time_t timelocal(struct tm* _Nonnull __tm);
+time_t timegm(struct tm* _Nonnull __tm);
 
 #define TIME_UTC 1
-int timespec_get(struct timespec* __ts, int __base) __INTRODUCED_IN(29);
+int timespec_get(struct timespec* _Nonnull __ts, int __base) __INTRODUCED_IN(29);
 
 __END_DECLS
 
diff --git a/libc/include/time64.h b/libc/include/time64.h
index 905669d..7d70030 100644
--- a/libc/include/time64.h
+++ b/libc/include/time64.h
@@ -47,17 +47,17 @@
 
 typedef int64_t time64_t;
 
-char* asctime64(const struct tm*);
-char* asctime64_r(const struct tm*, char*);
-char* ctime64(const time64_t*);
-char* ctime64_r(const time64_t*, char*);
-struct tm* gmtime64(const time64_t*);
-struct tm* gmtime64_r(const time64_t*, struct tm*);
-struct tm* localtime64(const time64_t*);
-struct tm* localtime64_r(const time64_t*, struct tm*);
-time64_t mktime64(const struct tm*);
-time64_t timegm64(const struct tm*);
-time64_t timelocal64(const struct tm*);
+char* _Nullable asctime64(const struct tm* _Nonnull);
+char* _Nullable asctime64_r(const struct tm* _Nonnull, char* _Nonnull);
+char* _Nullable ctime64(const time64_t* _Nonnull);
+char* _Nullable ctime64_r(const time64_t* _Nonnull, char* _Nonnull);
+struct tm* _Nullable gmtime64(const time64_t* _Nonnull);
+struct tm* _Nullable gmtime64_r(const time64_t* _Nonnull, struct tm* _Nonnull);
+struct tm* _Nullable localtime64(const time64_t* _Nonnull);
+struct tm* _Nullable localtime64_r(const time64_t* _Nonnull, struct tm* _Nonnull);
+time64_t mktime64(const struct tm* _Nonnull);
+time64_t timegm64(const struct tm* _Nonnull);
+time64_t timelocal64(const struct tm* _Nonnull);
 
 __END_DECLS
 
diff --git a/libc/kernel/tools/defaults.py b/libc/kernel/tools/defaults.py
index abb8f82..d0fe157 100644
--- a/libc/kernel/tools/defaults.py
+++ b/libc/kernel/tools/defaults.py
@@ -94,6 +94,9 @@
     "__kernel_old_timeval": "timeval",
     # Do the same for __kernel_old_itimerval as for timeval.
     "__kernel_old_itimerval": "itimerval",
+    # Replace __packed with __attribute__((__packed__)) to avoid depending
+    # on sys/cdefs.h
+    "__packed": "__attribute__((__packed__))",
     }
 
 
diff --git a/libc/kernel/uapi/asm-arm64/asm/hwcap.h b/libc/kernel/uapi/asm-arm64/asm/hwcap.h
index 442600d..af32056 100644
--- a/libc/kernel/uapi/asm-arm64/asm/hwcap.h
+++ b/libc/kernel/uapi/asm-arm64/asm/hwcap.h
@@ -83,4 +83,5 @@
 #define HWCAP2_SME_FA64 (1 << 30)
 #define HWCAP2_WFXT (1UL << 31)
 #define HWCAP2_EBF16 (1UL << 32)
+#define HWCAP2_SVE_EBF16 (1UL << 33)
 #endif
diff --git a/libc/kernel/uapi/asm-arm64/asm/perf_regs.h b/libc/kernel/uapi/asm-arm64/asm/perf_regs.h
index 71d496f..e18fd05 100644
--- a/libc/kernel/uapi/asm-arm64/asm/perf_regs.h
+++ b/libc/kernel/uapi/asm-arm64/asm/perf_regs.h
@@ -53,5 +53,8 @@
   PERF_REG_ARM64_SP,
   PERF_REG_ARM64_PC,
   PERF_REG_ARM64_MAX,
+  PERF_REG_ARM64_VG = 46,
+  PERF_REG_ARM64_EXTENDED_MAX
 };
+#define PERF_REG_EXTENDED_MASK (1ULL << PERF_REG_ARM64_VG)
 #endif
diff --git a/libc/kernel/uapi/asm-generic/hugetlb_encode.h b/libc/kernel/uapi/asm-generic/hugetlb_encode.h
index 73d8180..059991c 100644
--- a/libc/kernel/uapi/asm-generic/hugetlb_encode.h
+++ b/libc/kernel/uapi/asm-generic/hugetlb_encode.h
@@ -20,17 +20,17 @@
 #define _ASM_GENERIC_HUGETLB_ENCODE_H_
 #define HUGETLB_FLAG_ENCODE_SHIFT 26
 #define HUGETLB_FLAG_ENCODE_MASK 0x3f
-#define HUGETLB_FLAG_ENCODE_16KB (14 << HUGETLB_FLAG_ENCODE_SHIFT)
-#define HUGETLB_FLAG_ENCODE_64KB (16 << HUGETLB_FLAG_ENCODE_SHIFT)
-#define HUGETLB_FLAG_ENCODE_512KB (19 << HUGETLB_FLAG_ENCODE_SHIFT)
-#define HUGETLB_FLAG_ENCODE_1MB (20 << HUGETLB_FLAG_ENCODE_SHIFT)
-#define HUGETLB_FLAG_ENCODE_2MB (21 << HUGETLB_FLAG_ENCODE_SHIFT)
-#define HUGETLB_FLAG_ENCODE_8MB (23 << HUGETLB_FLAG_ENCODE_SHIFT)
-#define HUGETLB_FLAG_ENCODE_16MB (24 << HUGETLB_FLAG_ENCODE_SHIFT)
-#define HUGETLB_FLAG_ENCODE_32MB (25 << HUGETLB_FLAG_ENCODE_SHIFT)
-#define HUGETLB_FLAG_ENCODE_256MB (28 << HUGETLB_FLAG_ENCODE_SHIFT)
-#define HUGETLB_FLAG_ENCODE_512MB (29 << HUGETLB_FLAG_ENCODE_SHIFT)
-#define HUGETLB_FLAG_ENCODE_1GB (30 << HUGETLB_FLAG_ENCODE_SHIFT)
-#define HUGETLB_FLAG_ENCODE_2GB (31 << HUGETLB_FLAG_ENCODE_SHIFT)
-#define HUGETLB_FLAG_ENCODE_16GB (34 << HUGETLB_FLAG_ENCODE_SHIFT)
+#define HUGETLB_FLAG_ENCODE_16KB (14U << HUGETLB_FLAG_ENCODE_SHIFT)
+#define HUGETLB_FLAG_ENCODE_64KB (16U << HUGETLB_FLAG_ENCODE_SHIFT)
+#define HUGETLB_FLAG_ENCODE_512KB (19U << HUGETLB_FLAG_ENCODE_SHIFT)
+#define HUGETLB_FLAG_ENCODE_1MB (20U << HUGETLB_FLAG_ENCODE_SHIFT)
+#define HUGETLB_FLAG_ENCODE_2MB (21U << HUGETLB_FLAG_ENCODE_SHIFT)
+#define HUGETLB_FLAG_ENCODE_8MB (23U << HUGETLB_FLAG_ENCODE_SHIFT)
+#define HUGETLB_FLAG_ENCODE_16MB (24U << HUGETLB_FLAG_ENCODE_SHIFT)
+#define HUGETLB_FLAG_ENCODE_32MB (25U << HUGETLB_FLAG_ENCODE_SHIFT)
+#define HUGETLB_FLAG_ENCODE_256MB (28U << HUGETLB_FLAG_ENCODE_SHIFT)
+#define HUGETLB_FLAG_ENCODE_512MB (29U << HUGETLB_FLAG_ENCODE_SHIFT)
+#define HUGETLB_FLAG_ENCODE_1GB (30U << HUGETLB_FLAG_ENCODE_SHIFT)
+#define HUGETLB_FLAG_ENCODE_2GB (31U << HUGETLB_FLAG_ENCODE_SHIFT)
+#define HUGETLB_FLAG_ENCODE_16GB (34U << HUGETLB_FLAG_ENCODE_SHIFT)
 #endif
diff --git a/libc/kernel/uapi/asm-generic/mman-common.h b/libc/kernel/uapi/asm-generic/mman-common.h
index e96f4cc..966d05b 100644
--- a/libc/kernel/uapi/asm-generic/mman-common.h
+++ b/libc/kernel/uapi/asm-generic/mman-common.h
@@ -63,6 +63,7 @@
 #define MADV_POPULATE_READ 22
 #define MADV_POPULATE_WRITE 23
 #define MADV_DONTNEED_LOCKED 24
+#define MADV_COLLAPSE 25
 #define MAP_FILE 0
 #define PKEY_DISABLE_ACCESS 0x1
 #define PKEY_DISABLE_WRITE 0x2
diff --git a/libc/kernel/uapi/asm-riscv/asm/auxvec.h b/libc/kernel/uapi/asm-riscv/asm/auxvec.h
index b0e22af..c70be17 100644
--- a/libc/kernel/uapi/asm-riscv/asm/auxvec.h
+++ b/libc/kernel/uapi/asm-riscv/asm/auxvec.h
@@ -25,5 +25,7 @@
 #define AT_L1D_CACHEGEOMETRY 43
 #define AT_L2_CACHESIZE 44
 #define AT_L2_CACHEGEOMETRY 45
-#define AT_VECTOR_SIZE_ARCH 7
+#define AT_L3_CACHESIZE 46
+#define AT_L3_CACHEGEOMETRY 47
+#define AT_VECTOR_SIZE_ARCH 9
 #endif
diff --git a/libc/kernel/uapi/asm-riscv/asm/kvm.h b/libc/kernel/uapi/asm-riscv/asm/kvm.h
index 8a317b6..5dc165b 100644
--- a/libc/kernel/uapi/asm-riscv/asm/kvm.h
+++ b/libc/kernel/uapi/asm-riscv/asm/kvm.h
@@ -39,6 +39,7 @@
 };
 struct kvm_riscv_config {
   unsigned long isa;
+  unsigned long zicbom_block_size;
 };
 struct kvm_riscv_core {
   struct user_regs_struct regs;
@@ -74,6 +75,9 @@
   KVM_RISCV_ISA_EXT_M,
   KVM_RISCV_ISA_EXT_SVPBMT,
   KVM_RISCV_ISA_EXT_SSTC,
+  KVM_RISCV_ISA_EXT_SVINVAL,
+  KVM_RISCV_ISA_EXT_ZIHINTPAUSE,
+  KVM_RISCV_ISA_EXT_ZICBOM,
   KVM_RISCV_ISA_EXT_MAX,
 };
 #define KVM_RISCV_TIMER_STATE_OFF 0
diff --git a/libc/kernel/uapi/drm/amdgpu_drm.h b/libc/kernel/uapi/drm/amdgpu_drm.h
index f03a086..658eb31 100644
--- a/libc/kernel/uapi/drm/amdgpu_drm.h
+++ b/libc/kernel/uapi/drm/amdgpu_drm.h
@@ -453,6 +453,11 @@
 #define AMDGPU_INFO_FW_DMCUB 0x14
 #define AMDGPU_INFO_FW_TOC 0x15
 #define AMDGPU_INFO_FW_CAP 0x16
+#define AMDGPU_INFO_FW_GFX_RLCP 0x17
+#define AMDGPU_INFO_FW_GFX_RLCV 0x18
+#define AMDGPU_INFO_FW_MES_KIQ 0x19
+#define AMDGPU_INFO_FW_MES 0x1a
+#define AMDGPU_INFO_FW_IMU 0x1b
 #define AMDGPU_INFO_NUM_BYTES_MOVED 0x0f
 #define AMDGPU_INFO_VRAM_USAGE 0x10
 #define AMDGPU_INFO_GTT_USAGE 0x11
diff --git a/libc/kernel/uapi/drm/drm_fourcc.h b/libc/kernel/uapi/drm/drm_fourcc.h
index a59a6fb..8188b8f 100644
--- a/libc/kernel/uapi/drm/drm_fourcc.h
+++ b/libc/kernel/uapi/drm/drm_fourcc.h
@@ -25,7 +25,17 @@
 #define fourcc_code(a,b,c,d) ((__u32) (a) | ((__u32) (b) << 8) | ((__u32) (c) << 16) | ((__u32) (d) << 24))
 #define DRM_FORMAT_BIG_ENDIAN (1U << 31)
 #define DRM_FORMAT_INVALID 0
+#define DRM_FORMAT_C1 fourcc_code('C', '1', ' ', ' ')
+#define DRM_FORMAT_C2 fourcc_code('C', '2', ' ', ' ')
+#define DRM_FORMAT_C4 fourcc_code('C', '4', ' ', ' ')
 #define DRM_FORMAT_C8 fourcc_code('C', '8', ' ', ' ')
+#define DRM_FORMAT_D1 fourcc_code('D', '1', ' ', ' ')
+#define DRM_FORMAT_D2 fourcc_code('D', '2', ' ', ' ')
+#define DRM_FORMAT_D4 fourcc_code('D', '4', ' ', ' ')
+#define DRM_FORMAT_D8 fourcc_code('D', '8', ' ', ' ')
+#define DRM_FORMAT_R1 fourcc_code('R', '1', ' ', ' ')
+#define DRM_FORMAT_R2 fourcc_code('R', '2', ' ', ' ')
+#define DRM_FORMAT_R4 fourcc_code('R', '4', ' ', ' ')
 #define DRM_FORMAT_R8 fourcc_code('R', '8', ' ', ' ')
 #define DRM_FORMAT_R10 fourcc_code('R', '1', '0', ' ')
 #define DRM_FORMAT_R12 fourcc_code('R', '1', '2', ' ')
@@ -86,7 +96,9 @@
 #define DRM_FORMAT_UYVY fourcc_code('U', 'Y', 'V', 'Y')
 #define DRM_FORMAT_VYUY fourcc_code('V', 'Y', 'U', 'Y')
 #define DRM_FORMAT_AYUV fourcc_code('A', 'Y', 'U', 'V')
+#define DRM_FORMAT_AVUY8888 fourcc_code('A', 'V', 'U', 'Y')
 #define DRM_FORMAT_XYUV8888 fourcc_code('X', 'Y', 'U', 'V')
+#define DRM_FORMAT_XVUY8888 fourcc_code('X', 'V', 'U', 'Y')
 #define DRM_FORMAT_VUY888 fourcc_code('V', 'U', '2', '4')
 #define DRM_FORMAT_VUY101010 fourcc_code('V', 'U', '3', '0')
 #define DRM_FORMAT_Y210 fourcc_code('Y', '2', '1', '0')
diff --git a/libc/kernel/uapi/drm/i915_drm.h b/libc/kernel/uapi/drm/i915_drm.h
index 3188908..198b969 100644
--- a/libc/kernel/uapi/drm/i915_drm.h
+++ b/libc/kernel/uapi/drm/i915_drm.h
@@ -788,7 +788,7 @@
   __u64 flags;
   __u64 mbz64[3];
   struct i915_engine_class_instance engines[];
-} __packed;
+} __attribute__((__packed__));
 #define I915_DEFINE_CONTEXT_ENGINES_PARALLEL_SUBMIT(name__,N__) struct { struct i915_user_extension base; __u16 engine_index; __u16 width; __u16 num_siblings; __u16 mbz16; __u64 flags; __u64 mbz64[3]; struct i915_engine_class_instance engines[N__]; \
 } __attribute__((packed)) name__
 struct i915_context_param_engines {
diff --git a/libc/kernel/uapi/drm/panfrost_drm.h b/libc/kernel/uapi/drm/panfrost_drm.h
index 1f4473d..04a85df 100644
--- a/libc/kernel/uapi/drm/panfrost_drm.h
+++ b/libc/kernel/uapi/drm/panfrost_drm.h
@@ -136,6 +136,38 @@
   __u32 madv;
   __u32 retained;
 };
+#define PANFROSTDUMP_MAJOR 1
+#define PANFROSTDUMP_MINOR 0
+#define PANFROSTDUMP_MAGIC 0x464E4150
+#define PANFROSTDUMP_BUF_REG 0
+#define PANFROSTDUMP_BUF_BOMAP (PANFROSTDUMP_BUF_REG + 1)
+#define PANFROSTDUMP_BUF_BO (PANFROSTDUMP_BUF_BOMAP + 1)
+#define PANFROSTDUMP_BUF_TRAILER (PANFROSTDUMP_BUF_BO + 1)
+struct panfrost_dump_object_header {
+  __u32 magic;
+  __u32 type;
+  __u32 file_size;
+  __u32 file_offset;
+  union {
+    struct {
+      __u64 jc;
+      __u32 gpu_id;
+      __u32 major;
+      __u32 minor;
+      __u64 nbos;
+    } reghdr;
+    struct {
+      __u32 valid;
+      __u64 iova;
+      __u32 data[2];
+    } bomap;
+    __u32 sizer[496];
+  };
+};
+struct panfrost_dump_registers {
+  __u32 reg;
+  __u32 value;
+};
 #ifdef __cplusplus
 }
 #endif
diff --git a/libc/kernel/uapi/linux/android/binder.h b/libc/kernel/uapi/linux/android/binder.h
index e3b3289..52f4c6b 100644
--- a/libc/kernel/uapi/linux/android/binder.h
+++ b/libc/kernel/uapi/linux/android/binder.h
@@ -189,7 +189,7 @@
 struct binder_handle_cookie {
   __u32 handle;
   binder_uintptr_t cookie;
-} __packed;
+} __attribute__((__packed__));
 struct binder_pri_desc {
   __s32 priority;
   __u32 desc;
diff --git a/libc/kernel/uapi/linux/ashmem.h b/libc/kernel/uapi/linux/ashmem.h
index 174667f..88f0e81 100644
--- a/libc/kernel/uapi/linux/ashmem.h
+++ b/libc/kernel/uapi/linux/ashmem.h
@@ -41,4 +41,5 @@
 #define ASHMEM_UNPIN _IOW(__ASHMEMIOC, 8, struct ashmem_pin)
 #define ASHMEM_GET_PIN_STATUS _IO(__ASHMEMIOC, 9)
 #define ASHMEM_PURGE_ALL_CACHES _IO(__ASHMEMIOC, 10)
+#define ASHMEM_GET_FILE_ID _IOR(__ASHMEMIOC, 11, unsigned long)
 #endif
diff --git a/libc/kernel/uapi/linux/audit.h b/libc/kernel/uapi/linux/audit.h
index 2c37e2a..f7c969b 100644
--- a/libc/kernel/uapi/linux/audit.h
+++ b/libc/kernel/uapi/linux/audit.h
@@ -140,7 +140,7 @@
 #define AUDIT_MAX_KEY_LEN 256
 #define AUDIT_BITMASK_SIZE 64
 #define AUDIT_WORD(nr) ((__u32) ((nr) / 32))
-#define AUDIT_BIT(nr) (1 << ((nr) - AUDIT_WORD(nr) * 32))
+#define AUDIT_BIT(nr) (1U << ((nr) - AUDIT_WORD(nr) * 32))
 #define AUDIT_SYSCALL_CLASSES 16
 #define AUDIT_CLASS_DIR_WRITE 0
 #define AUDIT_CLASS_DIR_WRITE_32 1
diff --git a/libc/kernel/uapi/linux/bpf.h b/libc/kernel/uapi/linux/bpf.h
index 641ac55..807884a 100644
--- a/libc/kernel/uapi/linux/bpf.h
+++ b/libc/kernel/uapi/linux/bpf.h
@@ -74,10 +74,27 @@
   __u64 cgroup_inode_id;
   __u32 attach_type;
 };
+enum bpf_cgroup_iter_order {
+  BPF_CGROUP_ITER_ORDER_UNSPEC = 0,
+  BPF_CGROUP_ITER_SELF_ONLY,
+  BPF_CGROUP_ITER_DESCENDANTS_PRE,
+  BPF_CGROUP_ITER_DESCENDANTS_POST,
+  BPF_CGROUP_ITER_ANCESTORS_UP,
+};
 union bpf_iter_link_info {
   struct {
     __u32 map_fd;
   } map;
+  struct {
+    enum bpf_cgroup_iter_order order;
+    __u32 cgroup_fd;
+    __u64 cgroup_id;
+  } cgroup;
+  struct {
+    __u32 tid;
+    __u32 pid;
+    __u32 pid_fd;
+  } task;
 };
 enum bpf_cmd {
   BPF_MAP_CREATE,
@@ -150,6 +167,7 @@
   BPF_MAP_TYPE_INODE_STORAGE,
   BPF_MAP_TYPE_TASK_STORAGE,
   BPF_MAP_TYPE_BLOOM_FILTER,
+  BPF_MAP_TYPE_USER_RINGBUF,
 };
 enum bpf_prog_type {
   BPF_PROG_TYPE_UNSPEC,
@@ -500,7 +518,7 @@
     __u32 flags;
   } prog_bind_map;
 } __attribute__((aligned(8)));
-#define __BPF_FUNC_MAPPER(FN) FN(unspec), FN(map_lookup_elem), FN(map_update_elem), FN(map_delete_elem), FN(probe_read), FN(ktime_get_ns), FN(trace_printk), FN(get_prandom_u32), FN(get_smp_processor_id), FN(skb_store_bytes), FN(l3_csum_replace), FN(l4_csum_replace), FN(tail_call), FN(clone_redirect), FN(get_current_pid_tgid), FN(get_current_uid_gid), FN(get_current_comm), FN(get_cgroup_classid), FN(skb_vlan_push), FN(skb_vlan_pop), FN(skb_get_tunnel_key), FN(skb_set_tunnel_key), FN(perf_event_read), FN(redirect), FN(get_route_realm), FN(perf_event_output), FN(skb_load_bytes), FN(get_stackid), FN(csum_diff), FN(skb_get_tunnel_opt), FN(skb_set_tunnel_opt), FN(skb_change_proto), FN(skb_change_type), FN(skb_under_cgroup), FN(get_hash_recalc), FN(get_current_task), FN(probe_write_user), FN(current_task_under_cgroup), FN(skb_change_tail), FN(skb_pull_data), FN(csum_update), FN(set_hash_invalid), FN(get_numa_node_id), FN(skb_change_head), FN(xdp_adjust_head), FN(probe_read_str), FN(get_socket_cookie), FN(get_socket_uid), FN(set_hash), FN(setsockopt), FN(skb_adjust_room), FN(redirect_map), FN(sk_redirect_map), FN(sock_map_update), FN(xdp_adjust_meta), FN(perf_event_read_value), FN(perf_prog_read_value), FN(getsockopt), FN(override_return), FN(sock_ops_cb_flags_set), FN(msg_redirect_map), FN(msg_apply_bytes), FN(msg_cork_bytes), FN(msg_pull_data), FN(bind), FN(xdp_adjust_tail), FN(skb_get_xfrm_state), FN(get_stack), FN(skb_load_bytes_relative), FN(fib_lookup), FN(sock_hash_update), FN(msg_redirect_hash), FN(sk_redirect_hash), FN(lwt_push_encap), FN(lwt_seg6_store_bytes), FN(lwt_seg6_adjust_srh), FN(lwt_seg6_action), FN(rc_repeat), FN(rc_keydown), FN(skb_cgroup_id), FN(get_current_cgroup_id), FN(get_local_storage), FN(sk_select_reuseport), FN(skb_ancestor_cgroup_id), FN(sk_lookup_tcp), FN(sk_lookup_udp), FN(sk_release), FN(map_push_elem), FN(map_pop_elem), FN(map_peek_elem), FN(msg_push_data), FN(msg_pop_data), FN(rc_pointer_rel), FN(spin_lock), FN(spin_unlock), FN(sk_fullsock), FN(tcp_sock), FN(skb_ecn_set_ce), FN(get_listener_sock), FN(skc_lookup_tcp), FN(tcp_check_syncookie), FN(sysctl_get_name), FN(sysctl_get_current_value), FN(sysctl_get_new_value), FN(sysctl_set_new_value), FN(strtol), FN(strtoul), FN(sk_storage_get), FN(sk_storage_delete), FN(send_signal), FN(tcp_gen_syncookie), FN(skb_output), FN(probe_read_user), FN(probe_read_kernel), FN(probe_read_user_str), FN(probe_read_kernel_str), FN(tcp_send_ack), FN(send_signal_thread), FN(jiffies64), FN(read_branch_records), FN(get_ns_current_pid_tgid), FN(xdp_output), FN(get_netns_cookie), FN(get_current_ancestor_cgroup_id), FN(sk_assign), FN(ktime_get_boot_ns), FN(seq_printf), FN(seq_write), FN(sk_cgroup_id), FN(sk_ancestor_cgroup_id), FN(ringbuf_output), FN(ringbuf_reserve), FN(ringbuf_submit), FN(ringbuf_discard), FN(ringbuf_query), FN(csum_level), FN(skc_to_tcp6_sock), FN(skc_to_tcp_sock), FN(skc_to_tcp_timewait_sock), FN(skc_to_tcp_request_sock), FN(skc_to_udp6_sock), FN(get_task_stack), FN(load_hdr_opt), FN(store_hdr_opt), FN(reserve_hdr_opt), FN(inode_storage_get), FN(inode_storage_delete), FN(d_path), FN(copy_from_user), FN(snprintf_btf), FN(seq_printf_btf), FN(skb_cgroup_classid), FN(redirect_neigh), FN(per_cpu_ptr), FN(this_cpu_ptr), FN(redirect_peer), FN(task_storage_get), FN(task_storage_delete), FN(get_current_task_btf), FN(bprm_opts_set), FN(ktime_get_coarse_ns), FN(ima_inode_hash), FN(sock_from_file), FN(check_mtu), FN(for_each_map_elem), FN(snprintf), FN(sys_bpf), FN(btf_find_by_name_kind), FN(sys_close), FN(timer_init), FN(timer_set_callback), FN(timer_start), FN(timer_cancel), FN(get_func_ip), FN(get_attach_cookie), FN(task_pt_regs), FN(get_branch_snapshot), FN(trace_vprintk), FN(skc_to_unix_sock), FN(kallsyms_lookup_name), FN(find_vma), FN(loop), FN(strncmp), FN(get_func_arg), FN(get_func_ret), FN(get_func_arg_cnt), FN(get_retval), FN(set_retval), FN(xdp_get_buff_len), FN(xdp_load_bytes), FN(xdp_store_bytes), FN(copy_from_user_task), FN(skb_set_tstamp), FN(ima_file_hash), FN(kptr_xchg), FN(map_lookup_percpu_elem), FN(skc_to_mptcp_sock), FN(dynptr_from_mem), FN(ringbuf_reserve_dynptr), FN(ringbuf_submit_dynptr), FN(ringbuf_discard_dynptr), FN(dynptr_read), FN(dynptr_write), FN(dynptr_data), FN(tcp_raw_gen_syncookie_ipv4), FN(tcp_raw_gen_syncookie_ipv6), FN(tcp_raw_check_syncookie_ipv4), FN(tcp_raw_check_syncookie_ipv6),
+#define __BPF_FUNC_MAPPER(FN) FN(unspec), FN(map_lookup_elem), FN(map_update_elem), FN(map_delete_elem), FN(probe_read), FN(ktime_get_ns), FN(trace_printk), FN(get_prandom_u32), FN(get_smp_processor_id), FN(skb_store_bytes), FN(l3_csum_replace), FN(l4_csum_replace), FN(tail_call), FN(clone_redirect), FN(get_current_pid_tgid), FN(get_current_uid_gid), FN(get_current_comm), FN(get_cgroup_classid), FN(skb_vlan_push), FN(skb_vlan_pop), FN(skb_get_tunnel_key), FN(skb_set_tunnel_key), FN(perf_event_read), FN(redirect), FN(get_route_realm), FN(perf_event_output), FN(skb_load_bytes), FN(get_stackid), FN(csum_diff), FN(skb_get_tunnel_opt), FN(skb_set_tunnel_opt), FN(skb_change_proto), FN(skb_change_type), FN(skb_under_cgroup), FN(get_hash_recalc), FN(get_current_task), FN(probe_write_user), FN(current_task_under_cgroup), FN(skb_change_tail), FN(skb_pull_data), FN(csum_update), FN(set_hash_invalid), FN(get_numa_node_id), FN(skb_change_head), FN(xdp_adjust_head), FN(probe_read_str), FN(get_socket_cookie), FN(get_socket_uid), FN(set_hash), FN(setsockopt), FN(skb_adjust_room), FN(redirect_map), FN(sk_redirect_map), FN(sock_map_update), FN(xdp_adjust_meta), FN(perf_event_read_value), FN(perf_prog_read_value), FN(getsockopt), FN(override_return), FN(sock_ops_cb_flags_set), FN(msg_redirect_map), FN(msg_apply_bytes), FN(msg_cork_bytes), FN(msg_pull_data), FN(bind), FN(xdp_adjust_tail), FN(skb_get_xfrm_state), FN(get_stack), FN(skb_load_bytes_relative), FN(fib_lookup), FN(sock_hash_update), FN(msg_redirect_hash), FN(sk_redirect_hash), FN(lwt_push_encap), FN(lwt_seg6_store_bytes), FN(lwt_seg6_adjust_srh), FN(lwt_seg6_action), FN(rc_repeat), FN(rc_keydown), FN(skb_cgroup_id), FN(get_current_cgroup_id), FN(get_local_storage), FN(sk_select_reuseport), FN(skb_ancestor_cgroup_id), FN(sk_lookup_tcp), FN(sk_lookup_udp), FN(sk_release), FN(map_push_elem), FN(map_pop_elem), FN(map_peek_elem), FN(msg_push_data), FN(msg_pop_data), FN(rc_pointer_rel), FN(spin_lock), FN(spin_unlock), FN(sk_fullsock), FN(tcp_sock), FN(skb_ecn_set_ce), FN(get_listener_sock), FN(skc_lookup_tcp), FN(tcp_check_syncookie), FN(sysctl_get_name), FN(sysctl_get_current_value), FN(sysctl_get_new_value), FN(sysctl_set_new_value), FN(strtol), FN(strtoul), FN(sk_storage_get), FN(sk_storage_delete), FN(send_signal), FN(tcp_gen_syncookie), FN(skb_output), FN(probe_read_user), FN(probe_read_kernel), FN(probe_read_user_str), FN(probe_read_kernel_str), FN(tcp_send_ack), FN(send_signal_thread), FN(jiffies64), FN(read_branch_records), FN(get_ns_current_pid_tgid), FN(xdp_output), FN(get_netns_cookie), FN(get_current_ancestor_cgroup_id), FN(sk_assign), FN(ktime_get_boot_ns), FN(seq_printf), FN(seq_write), FN(sk_cgroup_id), FN(sk_ancestor_cgroup_id), FN(ringbuf_output), FN(ringbuf_reserve), FN(ringbuf_submit), FN(ringbuf_discard), FN(ringbuf_query), FN(csum_level), FN(skc_to_tcp6_sock), FN(skc_to_tcp_sock), FN(skc_to_tcp_timewait_sock), FN(skc_to_tcp_request_sock), FN(skc_to_udp6_sock), FN(get_task_stack), FN(load_hdr_opt), FN(store_hdr_opt), FN(reserve_hdr_opt), FN(inode_storage_get), FN(inode_storage_delete), FN(d_path), FN(copy_from_user), FN(snprintf_btf), FN(seq_printf_btf), FN(skb_cgroup_classid), FN(redirect_neigh), FN(per_cpu_ptr), FN(this_cpu_ptr), FN(redirect_peer), FN(task_storage_get), FN(task_storage_delete), FN(get_current_task_btf), FN(bprm_opts_set), FN(ktime_get_coarse_ns), FN(ima_inode_hash), FN(sock_from_file), FN(check_mtu), FN(for_each_map_elem), FN(snprintf), FN(sys_bpf), FN(btf_find_by_name_kind), FN(sys_close), FN(timer_init), FN(timer_set_callback), FN(timer_start), FN(timer_cancel), FN(get_func_ip), FN(get_attach_cookie), FN(task_pt_regs), FN(get_branch_snapshot), FN(trace_vprintk), FN(skc_to_unix_sock), FN(kallsyms_lookup_name), FN(find_vma), FN(loop), FN(strncmp), FN(get_func_arg), FN(get_func_ret), FN(get_func_arg_cnt), FN(get_retval), FN(set_retval), FN(xdp_get_buff_len), FN(xdp_load_bytes), FN(xdp_store_bytes), FN(copy_from_user_task), FN(skb_set_tstamp), FN(ima_file_hash), FN(kptr_xchg), FN(map_lookup_percpu_elem), FN(skc_to_mptcp_sock), FN(dynptr_from_mem), FN(ringbuf_reserve_dynptr), FN(ringbuf_submit_dynptr), FN(ringbuf_discard_dynptr), FN(dynptr_read), FN(dynptr_write), FN(dynptr_data), FN(tcp_raw_gen_syncookie_ipv4), FN(tcp_raw_gen_syncookie_ipv6), FN(tcp_raw_check_syncookie_ipv4), FN(tcp_raw_check_syncookie_ipv6), FN(ktime_get_tai_ns), FN(user_ringbuf_drain),
 #define __BPF_ENUM_FN(x) BPF_FUNC_ ##x
 enum bpf_func_id {
   __BPF_FUNC_MAPPER(__BPF_ENUM_FN) __BPF_FUNC_MAX_ID,
@@ -537,6 +555,9 @@
   BPF_F_SEQ_NUMBER = (1ULL << 3),
 };
 enum {
+  BPF_F_TUNINFO_FLAGS = (1ULL << 4),
+};
+enum {
   BPF_F_INDEX_MASK = 0xffffffffULL,
   BPF_F_CURRENT_CPU = BPF_F_INDEX_MASK,
   BPF_F_CTXLEN_MASK = (0xfffffULL << 32),
@@ -664,7 +685,10 @@
   };
   __u8 tunnel_tos;
   __u8 tunnel_ttl;
-  __u16 tunnel_ext;
+  union {
+    __u16 tunnel_ext;
+    __be16 tunnel_flags;
+  };
   __u32 tunnel_label;
   union {
     __u32 local_ipv4;
@@ -686,6 +710,7 @@
   BPF_DROP = 2,
   BPF_REDIRECT = 7,
   BPF_LWT_REROUTE = 128,
+  BPF_FLOW_DISSECTOR_CONTINUE = 129,
 };
 struct bpf_sock {
   __u32 bound_dev_if;
@@ -903,6 +928,16 @@
           __u32 map_id;
         } map;
       };
+      union {
+        struct {
+          __u64 cgroup_id;
+          __u32 order;
+        } cgroup;
+        struct {
+          __u32 tid;
+          __u32 pid;
+        } task;
+      };
     } iter;
     struct {
       __u32 netns_ino;
diff --git a/libc/kernel/uapi/linux/btrfs.h b/libc/kernel/uapi/linux/btrfs.h
index d73527e..506238f 100644
--- a/libc/kernel/uapi/linux/btrfs.h
+++ b/libc/kernel/uapi/linux/btrfs.h
@@ -176,6 +176,7 @@
 #define BTRFS_FEATURE_COMPAT_RO_FREE_SPACE_TREE (1ULL << 0)
 #define BTRFS_FEATURE_COMPAT_RO_FREE_SPACE_TREE_VALID (1ULL << 1)
 #define BTRFS_FEATURE_COMPAT_RO_VERITY (1ULL << 2)
+#define BTRFS_FEATURE_COMPAT_RO_BLOCK_GROUP_TREE (1ULL << 3)
 #define BTRFS_FEATURE_INCOMPAT_MIXED_BACKREF (1ULL << 0)
 #define BTRFS_FEATURE_INCOMPAT_DEFAULT_SUBVOL (1ULL << 1)
 #define BTRFS_FEATURE_INCOMPAT_MIXED_GROUPS (1ULL << 2)
diff --git a/libc/kernel/uapi/linux/btrfs_tree.h b/libc/kernel/uapi/linux/btrfs_tree.h
index 3becce8..6cd46dd 100644
--- a/libc/kernel/uapi/linux/btrfs_tree.h
+++ b/libc/kernel/uapi/linux/btrfs_tree.h
@@ -394,6 +394,7 @@
 #define BTRFS_QGROUP_STATUS_FLAG_ON (1ULL << 0)
 #define BTRFS_QGROUP_STATUS_FLAG_RESCAN (1ULL << 1)
 #define BTRFS_QGROUP_STATUS_FLAG_INCONSISTENT (1ULL << 2)
+#define BTRFS_QGROUP_STATUS_FLAGS_MASK (BTRFS_QGROUP_STATUS_FLAG_ON | BTRFS_QGROUP_STATUS_FLAG_RESCAN | BTRFS_QGROUP_STATUS_FLAG_INCONSISTENT)
 #define BTRFS_QGROUP_STATUS_VERSION 1
 struct btrfs_qgroup_status_item {
   __le64 version;
diff --git a/libc/kernel/uapi/linux/can.h b/libc/kernel/uapi/linux/can.h
index 30eeca2..1365dba 100644
--- a/libc/kernel/uapi/linux/can.h
+++ b/libc/kernel/uapi/linux/can.h
@@ -20,21 +20,29 @@
 #define _UAPI_CAN_H
 #include <linux/types.h>
 #include <linux/socket.h>
+#include <linux/stddef.h>
 #define CAN_EFF_FLAG 0x80000000U
 #define CAN_RTR_FLAG 0x40000000U
 #define CAN_ERR_FLAG 0x20000000U
 #define CAN_SFF_MASK 0x000007FFU
 #define CAN_EFF_MASK 0x1FFFFFFFU
 #define CAN_ERR_MASK 0x1FFFFFFFU
+#define CANXL_PRIO_MASK CAN_SFF_MASK
 typedef __u32 canid_t;
 #define CAN_SFF_ID_BITS 11
 #define CAN_EFF_ID_BITS 29
+#define CANXL_PRIO_BITS CAN_SFF_ID_BITS
 typedef __u32 can_err_mask_t;
 #define CAN_MAX_DLC 8
 #define CAN_MAX_RAW_DLC 15
 #define CAN_MAX_DLEN 8
 #define CANFD_MAX_DLC 15
 #define CANFD_MAX_DLEN 64
+#define CANXL_MIN_DLC 0
+#define CANXL_MAX_DLC 2047
+#define CANXL_MAX_DLC_MASK 0x07FF
+#define CANXL_MIN_DLEN 1
+#define CANXL_MAX_DLEN 2048
 struct can_frame {
   canid_t can_id;
   union {
@@ -57,8 +65,22 @@
   __u8 __res1;
   __u8 data[CANFD_MAX_DLEN] __attribute__((aligned(8)));
 };
+#define CANXL_XLF 0x80
+#define CANXL_SEC 0x01
+struct canxl_frame {
+  canid_t prio;
+  __u8 flags;
+  __u8 sdt;
+  __u16 len;
+  __u32 af;
+  __u8 data[CANXL_MAX_DLEN];
+};
 #define CAN_MTU (sizeof(struct can_frame))
 #define CANFD_MTU (sizeof(struct canfd_frame))
+#define CANXL_MTU (sizeof(struct canxl_frame))
+#define CANXL_HDR_SIZE (offsetof(struct canxl_frame, data))
+#define CANXL_MIN_MTU (CANXL_HDR_SIZE + 64)
+#define CANXL_MAX_MTU CANXL_MTU
 #define CAN_RAW 1
 #define CAN_BCM 2
 #define CAN_TP16 3
diff --git a/libc/kernel/uapi/linux/can/raw.h b/libc/kernel/uapi/linux/can/raw.h
index a3bddb7..f8de179 100644
--- a/libc/kernel/uapi/linux/can/raw.h
+++ b/libc/kernel/uapi/linux/can/raw.h
@@ -30,5 +30,6 @@
   CAN_RAW_RECV_OWN_MSGS,
   CAN_RAW_FD_FRAMES,
   CAN_RAW_JOIN_FILTERS,
+  CAN_RAW_XL_FRAMES,
 };
 #endif
diff --git a/libc/kernel/uapi/linux/capability.h b/libc/kernel/uapi/linux/capability.h
index 958e6ab..c1b5dbf 100644
--- a/libc/kernel/uapi/linux/capability.h
+++ b/libc/kernel/uapi/linux/capability.h
@@ -111,5 +111,5 @@
 #define CAP_LAST_CAP CAP_CHECKPOINT_RESTORE
 #define cap_valid(x) ((x) >= 0 && (x) <= CAP_LAST_CAP)
 #define CAP_TO_INDEX(x) ((x) >> 5)
-#define CAP_TO_MASK(x) (1 << ((x) & 31))
+#define CAP_TO_MASK(x) (1U << ((x) & 31))
 #endif
diff --git a/libc/kernel/uapi/linux/cec.h b/libc/kernel/uapi/linux/cec.h
index b90dc49..3953fe3 100644
--- a/libc/kernel/uapi/linux/cec.h
+++ b/libc/kernel/uapi/linux/cec.h
@@ -340,6 +340,7 @@
 #define CEC_OP_FEAT_DEV_HAS_SET_AUDIO_RATE 0x08
 #define CEC_OP_FEAT_DEV_SINK_HAS_ARC_TX 0x04
 #define CEC_OP_FEAT_DEV_SOURCE_HAS_ARC_RX 0x02
+#define CEC_OP_FEAT_DEV_HAS_SET_AUDIO_VOLUME_LEVEL 0x01
 #define CEC_MSG_GIVE_FEATURES 0xa5
 #define CEC_MSG_DECK_CONTROL 0x42
 #define CEC_OP_DECK_CTL_MODE_SKIP_FWD 1
@@ -554,6 +555,7 @@
 #define CEC_MSG_SYSTEM_AUDIO_MODE_STATUS 0x7e
 #define CEC_OP_AUD_FMT_ID_CEA861 0
 #define CEC_OP_AUD_FMT_ID_CEA861_CXT 1
+#define CEC_MSG_SET_AUDIO_VOLUME_LEVEL 0x73
 #define CEC_MSG_SET_AUDIO_RATE 0x9a
 #define CEC_OP_AUD_RATE_OFF 0
 #define CEC_OP_AUD_RATE_WIDE_STD 1
diff --git a/libc/kernel/uapi/linux/counter.h b/libc/kernel/uapi/linux/counter.h
index 4b86b28..f986365 100644
--- a/libc/kernel/uapi/linux/counter.h
+++ b/libc/kernel/uapi/linux/counter.h
@@ -46,6 +46,7 @@
   COUNTER_EVENT_THRESHOLD,
   COUNTER_EVENT_INDEX,
   COUNTER_EVENT_CHANGE_OF_STATE,
+  COUNTER_EVENT_CAPTURE,
 };
 struct counter_watch {
   struct counter_component component;
@@ -91,4 +92,8 @@
   COUNTER_SYNAPSE_ACTION_FALLING_EDGE,
   COUNTER_SYNAPSE_ACTION_BOTH_EDGES,
 };
+enum counter_signal_polarity {
+  COUNTER_SIGNAL_POLARITY_POSITIVE,
+  COUNTER_SIGNAL_POLARITY_NEGATIVE,
+};
 #endif
diff --git a/libc/kernel/uapi/linux/dlm.h b/libc/kernel/uapi/linux/dlm.h
index c75918f..499baad 100644
--- a/libc/kernel/uapi/linux/dlm.h
+++ b/libc/kernel/uapi/linux/dlm.h
@@ -31,6 +31,5 @@
   char * sb_lvbptr;
 };
 #define DLM_LSFL_TIMEWARN 0x00000002
-#define DLM_LSFL_FS 0x00000004
 #define DLM_LSFL_NEWEXCL 0x00000008
 #endif
diff --git a/libc/kernel/uapi/linux/dn.h b/libc/kernel/uapi/linux/dn.h
deleted file mode 100644
index 621f60f..0000000
--- a/libc/kernel/uapi/linux/dn.h
+++ /dev/null
@@ -1,114 +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 _LINUX_DN_H
-#define _LINUX_DN_H
-#include <linux/ioctl.h>
-#include <linux/types.h>
-#include <linux/if_ether.h>
-#define DNPROTO_NSP 2
-#define DNPROTO_ROU 3
-#define DNPROTO_NML 4
-#define DNPROTO_EVL 5
-#define DNPROTO_EVR 6
-#define DNPROTO_NSPT 7
-#define DN_ADDL 2
-#define DN_MAXADDL 2
-#define DN_MAXOPTL 16
-#define DN_MAXOBJL 16
-#define DN_MAXACCL 40
-#define DN_MAXALIASL 128
-#define DN_MAXNODEL 256
-#define DNBUFSIZE 65023
-#define SO_CONDATA 1
-#define SO_CONACCESS 2
-#define SO_PROXYUSR 3
-#define SO_LINKINFO 7
-#define DSO_CONDATA 1
-#define DSO_DISDATA 10
-#define DSO_CONACCESS 2
-#define DSO_ACCEPTMODE 4
-#define DSO_CONACCEPT 5
-#define DSO_CONREJECT 6
-#define DSO_LINKINFO 7
-#define DSO_STREAM 8
-#define DSO_SEQPACKET 9
-#define DSO_MAXWINDOW 11
-#define DSO_NODELAY 12
-#define DSO_CORK 13
-#define DSO_SERVICES 14
-#define DSO_INFO 15
-#define DSO_MAX 15
-#define LL_INACTIVE 0
-#define LL_CONNECTING 1
-#define LL_RUNNING 2
-#define LL_DISCONNECTING 3
-#define ACC_IMMED 0
-#define ACC_DEFER 1
-#define SDF_WILD 1
-#define SDF_PROXY 2
-#define SDF_UICPROXY 4
-struct dn_naddr {
-  __le16 a_len;
-  __u8 a_addr[DN_MAXADDL];
-};
-struct sockaddr_dn {
-  __u16 sdn_family;
-  __u8 sdn_flags;
-  __u8 sdn_objnum;
-  __le16 sdn_objnamel;
-  __u8 sdn_objname[DN_MAXOBJL];
-  struct dn_naddr sdn_add;
-};
-#define sdn_nodeaddrl sdn_add.a_len
-#define sdn_nodeaddr sdn_add.a_addr
-struct optdata_dn {
-  __le16 opt_status;
-#define opt_sts opt_status
-  __le16 opt_optl;
-  __u8 opt_data[16];
-};
-struct accessdata_dn {
-  __u8 acc_accl;
-  __u8 acc_acc[DN_MAXACCL];
-  __u8 acc_passl;
-  __u8 acc_pass[DN_MAXACCL];
-  __u8 acc_userl;
-  __u8 acc_user[DN_MAXACCL];
-};
-struct linkinfo_dn {
-  __u16 idn_segsize;
-  __u8 idn_linkstate;
-};
-union etheraddress {
-  __u8 dne_addr[ETH_ALEN];
-  struct {
-    __u8 dne_hiord[4];
-    __u8 dne_nodeaddr[2];
-  } dne_remote;
-};
-struct dn_addr {
-  __le16 dna_family;
-  union etheraddress dna_netaddr;
-};
-#define DECNET_IOCTL_BASE 0x89
-#define SIOCSNETADDR _IOW(DECNET_IOCTL_BASE, 0xe0, struct dn_naddr)
-#define SIOCGNETADDR _IOR(DECNET_IOCTL_BASE, 0xe1, struct dn_naddr)
-#define OSIOCSNETADDR _IOW(DECNET_IOCTL_BASE, 0xe0, int)
-#define OSIOCGNETADDR _IOR(DECNET_IOCTL_BASE, 0xe1, int)
-#endif
diff --git a/libc/kernel/uapi/linux/dns_resolver.h b/libc/kernel/uapi/linux/dns_resolver.h
index 21cb5c0..e7113d0 100644
--- a/libc/kernel/uapi/linux/dns_resolver.h
+++ b/libc/kernel/uapi/linux/dns_resolver.h
@@ -55,13 +55,13 @@
   __u8 zero;
   __u8 content;
   __u8 version;
-} __packed;
+} __attribute__((__packed__));
 struct dns_server_list_v1_header {
   struct dns_payload_header hdr;
   __u8 source;
   __u8 status;
   __u8 nr_servers;
-} __packed;
+} __attribute__((__packed__));
 struct dns_server_list_v1_server {
   __u16 name_len;
   __u16 priority;
@@ -71,8 +71,8 @@
   __u8 status;
   __u8 protocol;
   __u8 nr_addrs;
-} __packed;
+} __attribute__((__packed__));
 struct dns_server_list_v1_address {
   __u8 address_type;
-} __packed;
+} __attribute__((__packed__));
 #endif
diff --git a/libc/kernel/uapi/linux/dw100.h b/libc/kernel/uapi/linux/dw100.h
new file mode 100644
index 0000000..13d8487
--- /dev/null
+++ b/libc/kernel/uapi/linux/dw100.h
@@ -0,0 +1,23 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ ***   This header was automatically generated from a Linux kernel header
+ ***   of the same name, to make information necessary for userspace to
+ ***   call into the kernel available to libc.  It contains only constants,
+ ***   structures, and macros generated from the original header, and thus,
+ ***   contains no copyrightable information.
+ ***
+ ***   To edit the content of this header, modify the corresponding
+ ***   source file (e.g. under external/kernel-headers/original/) then
+ ***   run bionic/libc/kernel/tools/update_all.py
+ ***
+ ***   Any manual change here will be lost the next time this script will
+ ***   be run. You've been warned!
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef __UAPI_DW100_H__
+#define __UAPI_DW100_H__
+#include <linux/v4l2-controls.h>
+#define V4L2_CID_DW100_DEWARPING_16x16_VERTEX_MAP (V4L2_CID_USER_DW100_BASE + 1)
+#endif
diff --git a/libc/kernel/uapi/linux/ethtool.h b/libc/kernel/uapi/linux/ethtool.h
index 22dc9f2..8bdd622 100644
--- a/libc/kernel/uapi/linux/ethtool.h
+++ b/libc/kernel/uapi/linux/ethtool.h
@@ -277,6 +277,20 @@
   ETHTOOL_MODULE_POWER_MODE_LOW = 1,
   ETHTOOL_MODULE_POWER_MODE_HIGH,
 };
+enum ethtool_podl_pse_admin_state {
+  ETHTOOL_PODL_PSE_ADMIN_STATE_UNKNOWN = 1,
+  ETHTOOL_PODL_PSE_ADMIN_STATE_DISABLED,
+  ETHTOOL_PODL_PSE_ADMIN_STATE_ENABLED,
+};
+enum ethtool_podl_pse_pw_d_status {
+  ETHTOOL_PODL_PSE_PW_D_STATUS_UNKNOWN = 1,
+  ETHTOOL_PODL_PSE_PW_D_STATUS_DISABLED,
+  ETHTOOL_PODL_PSE_PW_D_STATUS_SEARCHING,
+  ETHTOOL_PODL_PSE_PW_D_STATUS_DELIVERING,
+  ETHTOOL_PODL_PSE_PW_D_STATUS_SLEEP,
+  ETHTOOL_PODL_PSE_PW_D_STATUS_IDLE,
+  ETHTOOL_PODL_PSE_PW_D_STATUS_ERROR,
+};
 struct ethtool_gstrings {
   __u32 cmd;
   __u32 string_set;
@@ -800,6 +814,10 @@
 #define MASTER_SLAVE_STATE_MASTER 2
 #define MASTER_SLAVE_STATE_SLAVE 3
 #define MASTER_SLAVE_STATE_ERR 4
+#define RATE_MATCH_NONE 0
+#define RATE_MATCH_PAUSE 1
+#define RATE_MATCH_CRS 2
+#define RATE_MATCH_OPEN_LOOP 3
 #define PORT_TP 0x00
 #define PORT_AUI 0x01
 #define PORT_MII 0x02
@@ -901,7 +919,7 @@
   __u8 transceiver;
   __u8 master_slave_cfg;
   __u8 master_slave_state;
-  __u8 reserved1[1];
+  __u8 rate_matching;
   __u32 reserved[7];
   __u32 link_mode_masks[];
 };
diff --git a/libc/kernel/uapi/linux/ethtool_netlink.h b/libc/kernel/uapi/linux/ethtool_netlink.h
index 85ce51b..08c6936 100644
--- a/libc/kernel/uapi/linux/ethtool_netlink.h
+++ b/libc/kernel/uapi/linux/ethtool_netlink.h
@@ -56,6 +56,8 @@
   ETHTOOL_MSG_PHC_VCLOCKS_GET,
   ETHTOOL_MSG_MODULE_GET,
   ETHTOOL_MSG_MODULE_SET,
+  ETHTOOL_MSG_PSE_GET,
+  ETHTOOL_MSG_PSE_SET,
   __ETHTOOL_MSG_USER_CNT,
   ETHTOOL_MSG_USER_MAX = __ETHTOOL_MSG_USER_CNT - 1
 };
@@ -97,6 +99,7 @@
   ETHTOOL_MSG_PHC_VCLOCKS_GET_REPLY,
   ETHTOOL_MSG_MODULE_GET_REPLY,
   ETHTOOL_MSG_MODULE_NTF,
+  ETHTOOL_MSG_PSE_GET_REPLY,
   __ETHTOOL_MSG_KERNEL_CNT,
   ETHTOOL_MSG_KERNEL_MAX = __ETHTOOL_MSG_KERNEL_CNT - 1
 };
@@ -193,6 +196,7 @@
   ETHTOOL_A_LINKMODES_MASTER_SLAVE_CFG,
   ETHTOOL_A_LINKMODES_MASTER_SLAVE_STATE,
   ETHTOOL_A_LINKMODES_LANES,
+  ETHTOOL_A_LINKMODES_RATE_MATCHING,
   __ETHTOOL_A_LINKMODES_CNT,
   ETHTOOL_A_LINKMODES_MAX = __ETHTOOL_A_LINKMODES_CNT - 1
 };
@@ -609,6 +613,15 @@
   __ETHTOOL_A_MODULE_CNT,
   ETHTOOL_A_MODULE_MAX = (__ETHTOOL_A_MODULE_CNT - 1)
 };
+enum {
+  ETHTOOL_A_PSE_UNSPEC,
+  ETHTOOL_A_PSE_HEADER,
+  ETHTOOL_A_PODL_PSE_ADMIN_STATE,
+  ETHTOOL_A_PODL_PSE_ADMIN_CONTROL,
+  ETHTOOL_A_PODL_PSE_PW_D_STATUS,
+  __ETHTOOL_A_PSE_CNT,
+  ETHTOOL_A_PSE_MAX = (__ETHTOOL_A_PSE_CNT - 1)
+};
 #define ETHTOOL_GENL_NAME "ethtool"
 #define ETHTOOL_GENL_VERSION 1
 #define ETHTOOL_MCGRP_MONITOR_NAME "monitor"
diff --git a/libc/kernel/uapi/linux/fuse.h b/libc/kernel/uapi/linux/fuse.h
index 144e960..ae667eb 100644
--- a/libc/kernel/uapi/linux/fuse.h
+++ b/libc/kernel/uapi/linux/fuse.h
@@ -20,7 +20,7 @@
 #define _LINUX_FUSE_H
 #include <stdint.h>
 #define FUSE_KERNEL_VERSION 7
-#define FUSE_KERNEL_MINOR_VERSION 36
+#define FUSE_KERNEL_MINOR_VERSION 37
 #define FUSE_ROOT_ID 1
 struct fuse_attr {
   uint64_t ino;
@@ -187,6 +187,7 @@
   FUSE_SETUPMAPPING = 48,
   FUSE_REMOVEMAPPING = 49,
   FUSE_SYNCFS = 50,
+  FUSE_TMPFILE = 51,
   FUSE_CANONICAL_PATH = 2016,
   CUSE_INIT = 4096,
   CUSE_INIT_BSWAP_RESERVED = 1048576,
diff --git a/libc/kernel/uapi/linux/hid.h b/libc/kernel/uapi/linux/hid.h
index ce93cd7..37ab462 100644
--- a/libc/kernel/uapi/linux/hid.h
+++ b/libc/kernel/uapi/linux/hid.h
@@ -22,12 +22,20 @@
 #define USB_INTERFACE_SUBCLASS_BOOT 1
 #define USB_INTERFACE_PROTOCOL_KEYBOARD 1
 #define USB_INTERFACE_PROTOCOL_MOUSE 2
-#define HID_REQ_GET_REPORT 0x01
-#define HID_REQ_GET_IDLE 0x02
-#define HID_REQ_GET_PROTOCOL 0x03
-#define HID_REQ_SET_REPORT 0x09
-#define HID_REQ_SET_IDLE 0x0A
-#define HID_REQ_SET_PROTOCOL 0x0B
+enum hid_report_type {
+  HID_INPUT_REPORT = 0,
+  HID_OUTPUT_REPORT = 1,
+  HID_FEATURE_REPORT = 2,
+  HID_REPORT_TYPES,
+};
+enum hid_class_request {
+  HID_REQ_GET_REPORT = 0x01,
+  HID_REQ_GET_IDLE = 0x02,
+  HID_REQ_GET_PROTOCOL = 0x03,
+  HID_REQ_SET_REPORT = 0x09,
+  HID_REQ_SET_IDLE = 0x0A,
+  HID_REQ_SET_PROTOCOL = 0x0B,
+};
 #define HID_DT_HID (USB_TYPE_CLASS | 0x01)
 #define HID_DT_REPORT (USB_TYPE_CLASS | 0x02)
 #define HID_DT_PHYSICAL (USB_TYPE_CLASS | 0x03)
diff --git a/libc/kernel/uapi/linux/idxd.h b/libc/kernel/uapi/linux/idxd.h
index c6d6985..a456352 100644
--- a/libc/kernel/uapi/linux/idxd.h
+++ b/libc/kernel/uapi/linux/idxd.h
@@ -38,6 +38,7 @@
   IDXD_SCMD_WQ_NO_SIZE = 0x800e0000,
   IDXD_SCMD_WQ_NO_PRIV = 0x800f0000,
   IDXD_SCMD_WQ_IRQ_ERR = 0x80100000,
+  IDXD_SCMD_WQ_USER_NO_IOMMU = 0x80110000,
 };
 #define IDXD_SCMD_SOFTERR_MASK 0x80000000
 #define IDXD_SCMD_SOFTERR_SHIFT 16
diff --git a/libc/kernel/uapi/linux/if_ether.h b/libc/kernel/uapi/linux/if_ether.h
index d35509e..6043921 100644
--- a/libc/kernel/uapi/linux/if_ether.h
+++ b/libc/kernel/uapi/linux/if_ether.h
@@ -112,6 +112,7 @@
 #define ETH_P_LOCALTALK 0x0009
 #define ETH_P_CAN 0x000C
 #define ETH_P_CANFD 0x000D
+#define ETH_P_CANXL 0x000E
 #define ETH_P_PPPTALK 0x0010
 #define ETH_P_TR_802_2 0x0011
 #define ETH_P_MOBITEX 0x0015
diff --git a/libc/kernel/uapi/linux/if_link.h b/libc/kernel/uapi/linux/if_link.h
index 52f8ca3..ebf403a 100644
--- a/libc/kernel/uapi/linux/if_link.h
+++ b/libc/kernel/uapi/linux/if_link.h
@@ -165,6 +165,7 @@
   IFLA_GRO_MAX_SIZE,
   IFLA_TSO_MAX_SIZE,
   IFLA_TSO_MAX_SEGS,
+  IFLA_ALLMULTI,
   __IFLA_MAX
 };
 #define IFLA_MAX (__IFLA_MAX - 1)
@@ -411,6 +412,7 @@
   IFLA_XFRM_UNSPEC,
   IFLA_XFRM_LINK,
   IFLA_XFRM_IF_ID,
+  IFLA_XFRM_COLLECT_METADATA,
   __IFLA_XFRM_MAX
 };
 #define IFLA_XFRM_MAX (__IFLA_XFRM_MAX - 1)
@@ -937,4 +939,10 @@
   __IFLA_MCTP_MAX,
 };
 #define IFLA_MCTP_MAX (__IFLA_MCTP_MAX - 1)
+enum {
+  IFLA_DSA_UNSPEC,
+  IFLA_DSA_MASTER,
+  __IFLA_DSA_MAX,
+};
+#define IFLA_DSA_MAX (__IFLA_DSA_MAX - 1)
 #endif
diff --git a/libc/kernel/uapi/linux/if_macsec.h b/libc/kernel/uapi/linux/if_macsec.h
index e60d767..7b51f80 100644
--- a/libc/kernel/uapi/linux/if_macsec.h
+++ b/libc/kernel/uapi/linux/if_macsec.h
@@ -23,6 +23,7 @@
 #define MACSEC_GENL_VERSION 1
 #define MACSEC_MAX_KEY_LEN 128
 #define MACSEC_KEYID_LEN 16
+#define MACSEC_SALT_LEN 12
 #define MACSEC_CIPHER_ID_GCM_AES_128 0x0080C20001000001ULL
 #define MACSEC_CIPHER_ID_GCM_AES_256 0x0080C20001000002ULL
 #define MACSEC_CIPHER_ID_GCM_AES_XPN_128 0x0080C20001000003ULL
diff --git a/libc/kernel/uapi/linux/if_pppox.h b/libc/kernel/uapi/linux/if_pppox.h
index b6c076b..2acafdf 100644
--- a/libc/kernel/uapi/linux/if_pppox.h
+++ b/libc/kernel/uapi/linux/if_pppox.h
@@ -51,27 +51,27 @@
     struct pppoe_addr pppoe;
     struct pptp_addr pptp;
   } sa_addr;
-} __packed;
+} __attribute__((__packed__));
 struct sockaddr_pppol2tp {
   __kernel_sa_family_t sa_family;
   unsigned int sa_protocol;
   struct pppol2tp_addr pppol2tp;
-} __packed;
+} __attribute__((__packed__));
 struct sockaddr_pppol2tpin6 {
   __kernel_sa_family_t sa_family;
   unsigned int sa_protocol;
   struct pppol2tpin6_addr pppol2tp;
-} __packed;
+} __attribute__((__packed__));
 struct sockaddr_pppol2tpv3 {
   __kernel_sa_family_t sa_family;
   unsigned int sa_protocol;
   struct pppol2tpv3_addr pppol2tp;
-} __packed;
+} __attribute__((__packed__));
 struct sockaddr_pppol2tpv3in6 {
   __kernel_sa_family_t sa_family;
   unsigned int sa_protocol;
   struct pppol2tpv3in6_addr pppol2tp;
-} __packed;
+} __attribute__((__packed__));
 #define PPPOEIOCSFWD _IOW(0xB1, 0, size_t)
 #define PPPOEIOCDFWD _IO(0xB1, 1)
 #define PADI_CODE 0x09
@@ -108,6 +108,6 @@
   __be16 sid;
   __be16 length;
   struct pppoe_tag tag[];
-} __packed;
+} __attribute__((__packed__));
 #define PPPOE_SES_HLEN 8
 #endif
diff --git a/libc/kernel/uapi/linux/iio/types.h b/libc/kernel/uapi/linux/iio/types.h
index aa66d50..af7bdda 100644
--- a/libc/kernel/uapi/linux/iio/types.h
+++ b/libc/kernel/uapi/linux/iio/types.h
@@ -101,6 +101,12 @@
   IIO_MOD_ETHANOL,
   IIO_MOD_H2,
   IIO_MOD_O2,
+  IIO_MOD_LINEAR_X,
+  IIO_MOD_LINEAR_Y,
+  IIO_MOD_LINEAR_Z,
+  IIO_MOD_PITCH,
+  IIO_MOD_YAW,
+  IIO_MOD_ROLL,
 };
 enum iio_event_type {
   IIO_EV_TYPE_THRESH,
@@ -110,11 +116,14 @@
   IIO_EV_TYPE_MAG_ADAPTIVE,
   IIO_EV_TYPE_CHANGE,
   IIO_EV_TYPE_MAG_REFERENCED,
+  IIO_EV_TYPE_GESTURE,
 };
 enum iio_event_direction {
   IIO_EV_DIR_EITHER,
   IIO_EV_DIR_RISING,
   IIO_EV_DIR_FALLING,
   IIO_EV_DIR_NONE,
+  IIO_EV_DIR_SINGLETAP,
+  IIO_EV_DIR_DOUBLETAP,
 };
 #endif
diff --git a/libc/kernel/uapi/linux/in.h b/libc/kernel/uapi/linux/in.h
index d4060e7..53d3074 100644
--- a/libc/kernel/uapi/linux/in.h
+++ b/libc/kernel/uapi/linux/in.h
@@ -22,6 +22,7 @@
 #include <bits/ip_mreq_source.h>
 #include <bits/in_addr.h>
 #include <linux/types.h>
+#include <linux/stddef.h>
 #include <linux/libc-compat.h>
 #include <linux/socket.h>
 #if __UAPI_DEF_IN_IPPROTO
@@ -68,6 +69,8 @@
 #define IPPROTO_PIM IPPROTO_PIM
   IPPROTO_COMP = 108,
 #define IPPROTO_COMP IPPROTO_COMP
+  IPPROTO_L2TP = 115,
+#define IPPROTO_L2TP IPPROTO_L2TP
   IPPROTO_SCTP = 132,
 #define IPPROTO_SCTP IPPROTO_SCTP
   IPPROTO_UDPLITE = 136,
diff --git a/libc/kernel/uapi/linux/input-event-codes.h b/libc/kernel/uapi/linux/input-event-codes.h
index 4b251df..40827b5 100644
--- a/libc/kernel/uapi/linux/input-event-codes.h
+++ b/libc/kernel/uapi/linux/input-event-codes.h
@@ -720,6 +720,7 @@
 #define ABS_TILT_Y 0x1b
 #define ABS_TOOL_WIDTH 0x1c
 #define ABS_VOLUME 0x20
+#define ABS_PROFILE 0x21
 #define ABS_MISC 0x28
 #define ABS_RESERVED 0x2e
 #define ABS_MT_SLOT 0x2f
diff --git a/libc/kernel/uapi/linux/io_uring.h b/libc/kernel/uapi/linux/io_uring.h
index 4d52cf0..82dee97 100644
--- a/libc/kernel/uapi/linux/io_uring.h
+++ b/libc/kernel/uapi/linux/io_uring.h
@@ -61,6 +61,7 @@
     __u32 hardlink_flags;
     __u32 xattr_flags;
     __u32 msg_ring_flags;
+    __u32 uring_cmd_flags;
   };
   __u64 user_data;
   union {
@@ -114,6 +115,7 @@
 #define IORING_SETUP_SQE128 (1U << 10)
 #define IORING_SETUP_CQE32 (1U << 11)
 #define IORING_SETUP_SINGLE_ISSUER (1U << 12)
+#define IORING_SETUP_DEFER_TASKRUN (1U << 13)
 enum io_uring_op {
   IORING_OP_NOP,
   IORING_OP_READV,
@@ -163,8 +165,10 @@
   IORING_OP_SOCKET,
   IORING_OP_URING_CMD,
   IORING_OP_SEND_ZC,
+  IORING_OP_SENDMSG_ZC,
   IORING_OP_LAST,
 };
+#define IORING_URING_CMD_FIXED (1U << 0)
 #define IORING_FSYNC_DATASYNC (1U << 0)
 #define IORING_TIMEOUT_ABS (1U << 0)
 #define IORING_TIMEOUT_UPDATE (1U << 1)
diff --git a/libc/kernel/uapi/linux/ip.h b/libc/kernel/uapi/linux/ip.h
index b6aef50..766a808 100644
--- a/libc/kernel/uapi/linux/ip.h
+++ b/libc/kernel/uapi/linux/ip.h
@@ -86,8 +86,9 @@
   __u8 ttl;
   __u8 protocol;
   __sum16 check;
-  __be32 saddr;
+  __struct_group(, addrs,, __be32 saddr;
   __be32 daddr;
+ );
 };
 struct ip_auth_hdr {
   __u8 nexthdr;
diff --git a/libc/kernel/uapi/linux/ipv6.h b/libc/kernel/uapi/linux/ipv6.h
index 757cbda..2e57ed1 100644
--- a/libc/kernel/uapi/linux/ipv6.h
+++ b/libc/kernel/uapi/linux/ipv6.h
@@ -87,8 +87,9 @@
   __be16 payload_len;
   __u8 nexthdr;
   __u8 hop_limit;
-  struct in6_addr saddr;
+  __struct_group(, addrs,, struct in6_addr saddr;
   struct in6_addr daddr;
+ );
 };
 enum {
   DEVCONF_FORWARDING = 0,
diff --git a/libc/kernel/uapi/linux/kvm.h b/libc/kernel/uapi/linux/kvm.h
index affb6a5..768f57e 100644
--- a/libc/kernel/uapi/linux/kvm.h
+++ b/libc/kernel/uapi/linux/kvm.h
@@ -928,6 +928,7 @@
 #define KVM_CAP_VM_DISABLE_NX_HUGE_PAGES 220
 #define KVM_CAP_S390_ZPCI_OP 221
 #define KVM_CAP_S390_CPU_TOPOLOGY 222
+#define KVM_CAP_DIRTY_LOG_RING_ACQ_REL 223
 #ifdef KVM_CAP_IRQ_ROUTING
 struct kvm_irq_routing_irqchip {
   __u32 irqchip;
diff --git a/libc/kernel/uapi/linux/l2tp.h b/libc/kernel/uapi/linux/l2tp.h
index a054819..dee634e 100644
--- a/libc/kernel/uapi/linux/l2tp.h
+++ b/libc/kernel/uapi/linux/l2tp.h
@@ -22,7 +22,6 @@
 #include <linux/socket.h>
 #include <linux/in.h>
 #include <linux/in6.h>
-#define IPPROTO_L2TP 115
 #define __SOCK_SIZE__ 16
 struct sockaddr_l2tpip {
   __kernel_sa_family_t l2tp_family;
diff --git a/libc/kernel/uapi/linux/lwtunnel.h b/libc/kernel/uapi/linux/lwtunnel.h
index e6fb536..94011dd 100644
--- a/libc/kernel/uapi/linux/lwtunnel.h
+++ b/libc/kernel/uapi/linux/lwtunnel.h
@@ -30,6 +30,7 @@
   LWTUNNEL_ENCAP_SEG6_LOCAL,
   LWTUNNEL_ENCAP_RPL,
   LWTUNNEL_ENCAP_IOAM6,
+  LWTUNNEL_ENCAP_XFRM,
   __LWTUNNEL_ENCAP_MAX,
 };
 #define LWTUNNEL_ENCAP_MAX (__LWTUNNEL_ENCAP_MAX - 1)
@@ -107,4 +108,11 @@
 };
 #define LWT_BPF_MAX (__LWT_BPF_MAX - 1)
 #define LWT_BPF_MAX_HEADROOM 256
+enum {
+  LWT_XFRM_UNSPEC,
+  LWT_XFRM_IF_ID,
+  LWT_XFRM_LINK,
+  __LWT_XFRM_MAX,
+};
+#define LWT_XFRM_MAX (__LWT_XFRM_MAX - 1)
 #endif
diff --git a/libc/kernel/uapi/linux/ndctl.h b/libc/kernel/uapi/linux/ndctl.h
index f6b9f7f..7e0d560 100644
--- a/libc/kernel/uapi/linux/ndctl.h
+++ b/libc/kernel/uapi/linux/ndctl.h
@@ -22,33 +22,33 @@
 struct nd_cmd_dimm_flags {
   __u32 status;
   __u32 flags;
-} __packed;
+} __attribute__((__packed__));
 struct nd_cmd_get_config_size {
   __u32 status;
   __u32 config_size;
   __u32 max_xfer;
-} __packed;
+} __attribute__((__packed__));
 struct nd_cmd_get_config_data_hdr {
   __u32 in_offset;
   __u32 in_length;
   __u32 status;
   __u8 out_buf[];
-} __packed;
+} __attribute__((__packed__));
 struct nd_cmd_set_config_hdr {
   __u32 in_offset;
   __u32 in_length;
   __u8 in_buf[];
-} __packed;
+} __attribute__((__packed__));
 struct nd_cmd_vendor_hdr {
   __u32 opcode;
   __u32 in_length;
   __u8 in_buf[];
-} __packed;
+} __attribute__((__packed__));
 struct nd_cmd_vendor_tail {
   __u32 status;
   __u32 out_length;
   __u8 out_buf[];
-} __packed;
+} __attribute__((__packed__));
 struct nd_cmd_ars_cap {
   __u64 address;
   __u64 length;
@@ -57,7 +57,7 @@
   __u32 clear_err_unit;
   __u16 flags;
   __u16 reserved;
-} __packed;
+} __attribute__((__packed__));
 struct nd_cmd_ars_start {
   __u64 address;
   __u64 length;
@@ -66,7 +66,7 @@
   __u8 reserved[5];
   __u32 status;
   __u32 scrub_time;
-} __packed;
+} __attribute__((__packed__));
 struct nd_cmd_ars_status {
   __u32 status;
   __u32 out_length;
@@ -82,15 +82,15 @@
     __u32 reserved;
     __u64 err_address;
     __u64 length;
-  } __packed records[];
-} __packed;
+  } __attribute__((__packed__)) records[];
+} __attribute__((__packed__));
 struct nd_cmd_clear_error {
   __u64 address;
   __u64 length;
   __u32 status;
   __u8 reserved[4];
   __u64 cleared;
-} __packed;
+} __attribute__((__packed__));
 enum {
   ND_CMD_IMPLEMENTED = 0,
   ND_CMD_ARS_CAP = 1,
diff --git a/libc/kernel/uapi/linux/netfilter_decnet.h b/libc/kernel/uapi/linux/netfilter_decnet.h
deleted file mode 100644
index c9c16ca..0000000
--- a/libc/kernel/uapi/linux/netfilter_decnet.h
+++ /dev/null
@@ -1,57 +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 __LINUX_DECNET_NETFILTER_H
-#define __LINUX_DECNET_NETFILTER_H
-#include <linux/netfilter.h>
-#include <limits.h>
-#define NF_DN_NUMHOOKS 7
-#define NF_DN_PRE_ROUTING 0
-#define NF_DN_LOCAL_IN 1
-#define NF_DN_FORWARD 2
-#define NF_DN_LOCAL_OUT 3
-#define NF_DN_POST_ROUTING 4
-#define NF_DN_HELLO 5
-#define NF_DN_ROUTE 6
-enum nf_dn_hook_priorities {
-  NF_DN_PRI_FIRST = INT_MIN,
-  NF_DN_PRI_CONNTRACK = - 200,
-  NF_DN_PRI_MANGLE = - 150,
-  NF_DN_PRI_NAT_DST = - 100,
-  NF_DN_PRI_FILTER = 0,
-  NF_DN_PRI_NAT_SRC = 100,
-  NF_DN_PRI_DNRTMSG = 200,
-  NF_DN_PRI_LAST = INT_MAX,
-};
-struct nf_dn_rtmsg {
-  int nfdn_ifindex;
-};
-#define NFDN_RTMSG(r) ((unsigned char *) (r) + NLMSG_ALIGN(sizeof(struct nf_dn_rtmsg)))
-#define DNRMG_L1_GROUP 0x01
-#define DNRMG_L2_GROUP 0x02
-enum {
-  DNRNG_NLGRP_NONE,
-#define DNRNG_NLGRP_NONE DNRNG_NLGRP_NONE
-  DNRNG_NLGRP_L1,
-#define DNRNG_NLGRP_L1 DNRNG_NLGRP_L1
-  DNRNG_NLGRP_L2,
-#define DNRNG_NLGRP_L2 DNRNG_NLGRP_L2
-  __DNRNG_NLGRP_MAX
-};
-#define DNRNG_NLGRP_MAX (__DNRNG_NLGRP_MAX - 1)
-#endif
diff --git a/libc/kernel/uapi/linux/netlink.h b/libc/kernel/uapi/linux/netlink.h
index bc3e749..17d5291 100644
--- a/libc/kernel/uapi/linux/netlink.h
+++ b/libc/kernel/uapi/linux/netlink.h
@@ -100,6 +100,8 @@
   NLMSGERR_ATTR_OFFS,
   NLMSGERR_ATTR_COOKIE,
   NLMSGERR_ATTR_POLICY,
+  NLMSGERR_ATTR_MISS_TYPE,
+  NLMSGERR_ATTR_MISS_NEST,
   __NLMSGERR_ATTR_MAX,
   NLMSGERR_ATTR_MAX = __NLMSGERR_ATTR_MAX - 1
 };
diff --git a/libc/kernel/uapi/linux/nl80211.h b/libc/kernel/uapi/linux/nl80211.h
index c3aefa3..faff80a 100644
--- a/libc/kernel/uapi/linux/nl80211.h
+++ b/libc/kernel/uapi/linux/nl80211.h
@@ -1118,6 +1118,7 @@
   NL80211_BSS_CHAIN_SIGNAL,
   NL80211_BSS_FREQUENCY_OFFSET,
   NL80211_BSS_MLO_LINK_ID,
+  NL80211_BSS_MLD_ADDR,
   __NL80211_BSS_AFTER_LAST,
   NL80211_BSS_MAX = __NL80211_BSS_AFTER_LAST - 1
 };
@@ -1530,6 +1531,7 @@
   NL80211_EXT_FEATURE_BSS_COLOR,
   NL80211_EXT_FEATURE_FILS_CRYPTO_OFFLOAD,
   NL80211_EXT_FEATURE_RADAR_BACKGROUND,
+  NL80211_EXT_FEATURE_POWERED_ADDR_CHANGE,
   NUM_NL80211_EXT_FEATURES,
   MAX_NL80211_EXT_FEATURES = NUM_NL80211_EXT_FEATURES - 1
 };
diff --git a/libc/kernel/uapi/linux/openvswitch.h b/libc/kernel/uapi/linux/openvswitch.h
index c7d719c..c44e950 100644
--- a/libc/kernel/uapi/linux/openvswitch.h
+++ b/libc/kernel/uapi/linux/openvswitch.h
@@ -44,6 +44,7 @@
   OVS_DP_ATTR_PAD,
   OVS_DP_ATTR_MASKS_CACHE_SIZE,
   OVS_DP_ATTR_PER_CPU_PIDS,
+  OVS_DP_ATTR_IFINDEX,
   __OVS_DP_ATTR_MAX
 };
 #define OVS_DP_ATTR_MAX (__OVS_DP_ATTR_MAX - 1)
diff --git a/libc/kernel/uapi/linux/perf_event.h b/libc/kernel/uapi/linux/perf_event.h
index 165ff45..8f081ed 100644
--- a/libc/kernel/uapi/linux/perf_event.h
+++ b/libc/kernel/uapi/linux/perf_event.h
@@ -108,7 +108,6 @@
   PERF_SAMPLE_CODE_PAGE_SIZE = 1U << 23,
   PERF_SAMPLE_WEIGHT_STRUCT = 1U << 24,
   PERF_SAMPLE_MAX = 1U << 25,
-  __PERF_SAMPLE_CALLCHAIN_EARLY = 1ULL << 63,
 };
 #define PERF_SAMPLE_WEIGHT_TYPE (PERF_SAMPLE_WEIGHT | PERF_SAMPLE_WEIGHT_STRUCT)
 enum perf_branch_sample_type_shift {
@@ -130,6 +129,7 @@
   PERF_SAMPLE_BRANCH_NO_CYCLES_SHIFT = 15,
   PERF_SAMPLE_BRANCH_TYPE_SAVE_SHIFT = 16,
   PERF_SAMPLE_BRANCH_HW_INDEX_SHIFT = 17,
+  PERF_SAMPLE_BRANCH_PRIV_SAVE_SHIFT = 18,
   PERF_SAMPLE_BRANCH_MAX_SHIFT
 };
 enum perf_branch_sample_type {
@@ -151,6 +151,7 @@
   PERF_SAMPLE_BRANCH_NO_CYCLES = 1U << PERF_SAMPLE_BRANCH_NO_CYCLES_SHIFT,
   PERF_SAMPLE_BRANCH_TYPE_SAVE = 1U << PERF_SAMPLE_BRANCH_TYPE_SAVE_SHIFT,
   PERF_SAMPLE_BRANCH_HW_INDEX = 1U << PERF_SAMPLE_BRANCH_HW_INDEX_SHIFT,
+  PERF_SAMPLE_BRANCH_PRIV_SAVE = 1U << PERF_SAMPLE_BRANCH_PRIV_SAVE_SHIFT,
   PERF_SAMPLE_BRANCH_MAX = 1U << PERF_SAMPLE_BRANCH_MAX_SHIFT,
 };
 enum {
@@ -167,8 +168,40 @@
   PERF_BR_COND_RET = 10,
   PERF_BR_ERET = 11,
   PERF_BR_IRQ = 12,
+  PERF_BR_SERROR = 13,
+  PERF_BR_NO_TX = 14,
+  PERF_BR_EXTEND_ABI = 15,
   PERF_BR_MAX,
 };
+enum {
+  PERF_BR_SPEC_NA = 0,
+  PERF_BR_SPEC_WRONG_PATH = 1,
+  PERF_BR_NON_SPEC_CORRECT_PATH = 2,
+  PERF_BR_SPEC_CORRECT_PATH = 3,
+  PERF_BR_SPEC_MAX,
+};
+enum {
+  PERF_BR_NEW_FAULT_ALGN = 0,
+  PERF_BR_NEW_FAULT_DATA = 1,
+  PERF_BR_NEW_FAULT_INST = 2,
+  PERF_BR_NEW_ARCH_1 = 3,
+  PERF_BR_NEW_ARCH_2 = 4,
+  PERF_BR_NEW_ARCH_3 = 5,
+  PERF_BR_NEW_ARCH_4 = 6,
+  PERF_BR_NEW_ARCH_5 = 7,
+  PERF_BR_NEW_MAX,
+};
+enum {
+  PERF_BR_PRIV_UNKNOWN = 0,
+  PERF_BR_PRIV_USER = 1,
+  PERF_BR_PRIV_KERNEL = 2,
+  PERF_BR_PRIV_HV = 3,
+};
+#define PERF_BR_ARM64_FIQ PERF_BR_NEW_ARCH_1
+#define PERF_BR_ARM64_DEBUG_HALT PERF_BR_NEW_ARCH_2
+#define PERF_BR_ARM64_DEBUG_EXIT PERF_BR_NEW_ARCH_3
+#define PERF_BR_ARM64_DEBUG_INST PERF_BR_NEW_ARCH_4
+#define PERF_BR_ARM64_DEBUG_DATA PERF_BR_NEW_ARCH_5
 #define PERF_SAMPLE_BRANCH_PLM_ALL (PERF_SAMPLE_BRANCH_USER | PERF_SAMPLE_BRANCH_KERNEL | PERF_SAMPLE_BRANCH_HV)
 enum perf_sample_regs_abi {
   PERF_SAMPLE_REGS_ABI_NONE = 0,
@@ -435,6 +468,8 @@
 #define PERF_MEM_LVLNUM_L2 0x02
 #define PERF_MEM_LVLNUM_L3 0x03
 #define PERF_MEM_LVLNUM_L4 0x04
+#define PERF_MEM_LVLNUM_CXL 0x09
+#define PERF_MEM_LVLNUM_IO 0x0a
 #define PERF_MEM_LVLNUM_ANY_CACHE 0x0b
 #define PERF_MEM_LVLNUM_LFB 0x0c
 #define PERF_MEM_LVLNUM_RAM 0x0d
@@ -448,6 +483,7 @@
 #define PERF_MEM_SNOOP_HITM 0x10
 #define PERF_MEM_SNOOP_SHIFT 19
 #define PERF_MEM_SNOOPX_FWD 0x01
+#define PERF_MEM_SNOOPX_PEER 0x02
 #define PERF_MEM_SNOOPX_SHIFT 38
 #define PERF_MEM_LOCK_NA 0x01
 #define PERF_MEM_LOCK_LOCKED 0x02
@@ -473,7 +509,7 @@
 struct perf_branch_entry {
   __u64 from;
   __u64 to;
-  __u64 mispred : 1, predicted : 1, in_tx : 1, abort : 1, cycles : 16, type : 4, reserved : 40;
+  __u64 mispred : 1, predicted : 1, in_tx : 1, abort : 1, cycles : 16, type : 4, spec : 2, new_type : 4, priv : 3, reserved : 31;
 };
 union perf_sample_weight {
   __u64 full;
diff --git a/libc/kernel/uapi/linux/pkt_cls.h b/libc/kernel/uapi/linux/pkt_cls.h
index 580e83e..876cb73 100644
--- a/libc/kernel/uapi/linux/pkt_cls.h
+++ b/libc/kernel/uapi/linux/pkt_cls.h
@@ -462,6 +462,7 @@
   TCA_FLOWER_KEY_NUM_OF_VLANS,
   TCA_FLOWER_KEY_PPPOE_SID,
   TCA_FLOWER_KEY_PPP_PROTO,
+  TCA_FLOWER_KEY_L2TPV3_SID,
   __TCA_FLOWER_MAX,
 };
 #define TCA_FLOWER_MAX (__TCA_FLOWER_MAX - 1)
diff --git a/libc/kernel/uapi/linux/pkt_sched.h b/libc/kernel/uapi/linux/pkt_sched.h
index e298b74..c31b8bb 100644
--- a/libc/kernel/uapi/linux/pkt_sched.h
+++ b/libc/kernel/uapi/linux/pkt_sched.h
@@ -924,6 +924,13 @@
 #define TCA_TAPRIO_ATTR_FLAG_TXTIME_ASSIST _BITUL(0)
 #define TCA_TAPRIO_ATTR_FLAG_FULL_OFFLOAD _BITUL(1)
 enum {
+  TCA_TAPRIO_TC_ENTRY_UNSPEC,
+  TCA_TAPRIO_TC_ENTRY_INDEX,
+  TCA_TAPRIO_TC_ENTRY_MAX_SDU,
+  __TCA_TAPRIO_TC_ENTRY_CNT,
+  TCA_TAPRIO_TC_ENTRY_MAX = (__TCA_TAPRIO_TC_ENTRY_CNT - 1)
+};
+enum {
   TCA_TAPRIO_ATTR_UNSPEC,
   TCA_TAPRIO_ATTR_PRIOMAP,
   TCA_TAPRIO_ATTR_SCHED_ENTRY_LIST,
@@ -936,6 +943,7 @@
   TCA_TAPRIO_ATTR_SCHED_CYCLE_TIME_EXTENSION,
   TCA_TAPRIO_ATTR_FLAGS,
   TCA_TAPRIO_ATTR_TXTIME_DELAY,
+  TCA_TAPRIO_ATTR_TC_ENTRY,
   __TCA_TAPRIO_ATTR_MAX,
 };
 #define TCA_TAPRIO_ATTR_MAX (__TCA_TAPRIO_ATTR_MAX - 1)
diff --git a/libc/kernel/uapi/linux/psci.h b/libc/kernel/uapi/linux/psci.h
index 31e7465..4dead17 100644
--- a/libc/kernel/uapi/linux/psci.h
+++ b/libc/kernel/uapi/linux/psci.h
@@ -39,11 +39,23 @@
 #define PSCI_0_2_FN64_MIGRATE PSCI_0_2_FN64(5)
 #define PSCI_0_2_FN64_MIGRATE_INFO_UP_CPU PSCI_0_2_FN64(7)
 #define PSCI_1_0_FN_PSCI_FEATURES PSCI_0_2_FN(10)
+#define PSCI_1_0_FN_CPU_FREEZE PSCI_0_2_FN(11)
+#define PSCI_1_0_FN_CPU_DEFAULT_SUSPEND PSCI_0_2_FN(12)
+#define PSCI_1_0_FN_NODE_HW_STATE PSCI_0_2_FN(13)
 #define PSCI_1_0_FN_SYSTEM_SUSPEND PSCI_0_2_FN(14)
 #define PSCI_1_0_FN_SET_SUSPEND_MODE PSCI_0_2_FN(15)
+#define PSCI_1_0_FN_STAT_RESIDENCY PSCI_0_2_FN(16)
+#define PSCI_1_0_FN_STAT_COUNT PSCI_0_2_FN(17)
 #define PSCI_1_1_FN_SYSTEM_RESET2 PSCI_0_2_FN(18)
+#define PSCI_1_1_FN_MEM_PROTECT PSCI_0_2_FN(19)
+#define PSCI_1_1_FN_MEM_PROTECT_CHECK_RANGE PSCI_0_2_FN(19)
+#define PSCI_1_0_FN64_CPU_DEFAULT_SUSPEND PSCI_0_2_FN64(12)
+#define PSCI_1_0_FN64_NODE_HW_STATE PSCI_0_2_FN64(13)
 #define PSCI_1_0_FN64_SYSTEM_SUSPEND PSCI_0_2_FN64(14)
+#define PSCI_1_0_FN64_STAT_RESIDENCY PSCI_0_2_FN64(16)
+#define PSCI_1_0_FN64_STAT_COUNT PSCI_0_2_FN64(17)
 #define PSCI_1_1_FN64_SYSTEM_RESET2 PSCI_0_2_FN64(18)
+#define PSCI_1_1_FN64_MEM_PROTECT_CHECK_RANGE PSCI_0_2_FN64(19)
 #define PSCI_0_2_POWER_STATE_ID_MASK 0xffff
 #define PSCI_0_2_POWER_STATE_ID_SHIFT 0
 #define PSCI_0_2_POWER_STATE_TYPE_SHIFT 16
diff --git a/libc/kernel/uapi/linux/psp-sev.h b/libc/kernel/uapi/linux/psp-sev.h
index 6c4f73d..8c9ec80 100644
--- a/libc/kernel/uapi/linux/psp-sev.h
+++ b/libc/kernel/uapi/linux/psp-sev.h
@@ -66,37 +66,37 @@
   __u32 flags;
   __u8 build;
   __u32 guest_count;
-} __packed;
+} __attribute__((__packed__));
 #define SEV_STATUS_FLAGS_CONFIG_ES 0x0100
 struct sev_user_data_pek_csr {
   __u64 address;
   __u32 length;
-} __packed;
+} __attribute__((__packed__));
 struct sev_user_data_pek_cert_import {
   __u64 pek_cert_address;
   __u32 pek_cert_len;
   __u64 oca_cert_address;
   __u32 oca_cert_len;
-} __packed;
+} __attribute__((__packed__));
 struct sev_user_data_pdh_cert_export {
   __u64 pdh_cert_address;
   __u32 pdh_cert_len;
   __u64 cert_chain_address;
   __u32 cert_chain_len;
-} __packed;
+} __attribute__((__packed__));
 struct sev_user_data_get_id {
   __u8 socket1[64];
   __u8 socket2[64];
-} __packed;
+} __attribute__((__packed__));
 struct sev_user_data_get_id2 {
   __u64 address;
   __u32 length;
-} __packed;
+} __attribute__((__packed__));
 struct sev_issue_cmd {
   __u32 cmd;
   __u64 data;
   __u32 error;
-} __packed;
+} __attribute__((__packed__));
 #define SEV_IOC_TYPE 'S'
 #define SEV_ISSUE_CMD _IOWR(SEV_IOC_TYPE, 0x0, struct sev_issue_cmd)
 #endif
diff --git a/libc/kernel/uapi/linux/qrtr.h b/libc/kernel/uapi/linux/qrtr.h
index c0a4c72..ee56aca 100644
--- a/libc/kernel/uapi/linux/qrtr.h
+++ b/libc/kernel/uapi/linux/qrtr.h
@@ -54,5 +54,5 @@
       __le32 port;
     } client;
   };
-} __packed;
+} __attribute__((__packed__));
 #endif
diff --git a/libc/kernel/uapi/linux/rkisp1-config.h b/libc/kernel/uapi/linux/rkisp1-config.h
index cea14cd..7175c23 100644
--- a/libc/kernel/uapi/linux/rkisp1-config.h
+++ b/libc/kernel/uapi/linux/rkisp1-config.h
@@ -67,6 +67,37 @@
 #define RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE_V12 81
 #define RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE_V12
 #define RKISP1_CIF_ISP_DPCC_METHODS_MAX 3
+#define RKISP1_CIF_ISP_DPCC_MODE_STAGE1_ENABLE (1U << 2)
+#define RKISP1_CIF_ISP_DPCC_OUTPUT_MODE_STAGE1_INCL_G_CENTER (1U << 0)
+#define RKISP1_CIF_ISP_DPCC_OUTPUT_MODE_STAGE1_INCL_RB_CENTER (1U << 1)
+#define RKISP1_CIF_ISP_DPCC_OUTPUT_MODE_STAGE1_G_3X3 (1U << 2)
+#define RKISP1_CIF_ISP_DPCC_OUTPUT_MODE_STAGE1_RB_3X3 (1U << 3)
+#define RKISP1_CIF_ISP_DPCC_SET_USE_STAGE1_USE_SET(n) ((n) << 0)
+#define RKISP1_CIF_ISP_DPCC_SET_USE_STAGE1_USE_FIX_SET (1U << 3)
+#define RKISP1_CIF_ISP_DPCC_METHODS_SET_PG_GREEN_ENABLE (1U << 0)
+#define RKISP1_CIF_ISP_DPCC_METHODS_SET_LC_GREEN_ENABLE (1U << 1)
+#define RKISP1_CIF_ISP_DPCC_METHODS_SET_RO_GREEN_ENABLE (1U << 2)
+#define RKISP1_CIF_ISP_DPCC_METHODS_SET_RND_GREEN_ENABLE (1U << 3)
+#define RKISP1_CIF_ISP_DPCC_METHODS_SET_RG_GREEN_ENABLE (1U << 4)
+#define RKISP1_CIF_ISP_DPCC_METHODS_SET_PG_RED_BLUE_ENABLE (1U << 8)
+#define RKISP1_CIF_ISP_DPCC_METHODS_SET_LC_RED_BLUE_ENABLE (1U << 9)
+#define RKISP1_CIF_ISP_DPCC_METHODS_SET_RO_RED_BLUE_ENABLE (1U << 10)
+#define RKISP1_CIF_ISP_DPCC_METHODS_SET_RND_RED_BLUE_ENABLE (1U << 11)
+#define RKISP1_CIF_ISP_DPCC_METHODS_SET_RG_RED_BLUE_ENABLE (1U << 12)
+#define RKISP1_CIF_ISP_DPCC_LINE_THRESH_G(v) ((v) << 0)
+#define RKISP1_CIF_ISP_DPCC_LINE_THRESH_RB(v) ((v) << 8)
+#define RKISP1_CIF_ISP_DPCC_LINE_MAD_FAC_G(v) ((v) << 0)
+#define RKISP1_CIF_ISP_DPCC_LINE_MAD_FAC_RB(v) ((v) << 8)
+#define RKISP1_CIF_ISP_DPCC_PG_FAC_G(v) ((v) << 0)
+#define RKISP1_CIF_ISP_DPCC_PG_FAC_RB(v) ((v) << 8)
+#define RKISP1_CIF_ISP_DPCC_RND_THRESH_G(v) ((v) << 0)
+#define RKISP1_CIF_ISP_DPCC_RND_THRESH_RB(v) ((v) << 8)
+#define RKISP1_CIF_ISP_DPCC_RG_FAC_G(v) ((v) << 0)
+#define RKISP1_CIF_ISP_DPCC_RG_FAC_RB(v) ((v) << 8)
+#define RKISP1_CIF_ISP_DPCC_RO_LIMITS_n_G(n,v) ((v) << ((n) * 4))
+#define RKISP1_CIF_ISP_DPCC_RO_LIMITS_n_RB(n,v) ((v) << ((n) * 4 + 2))
+#define RKISP1_CIF_ISP_DPCC_RND_OFFS_n_G(n,v) ((v) << ((n) * 4))
+#define RKISP1_CIF_ISP_DPCC_RND_OFFS_n_RB(n,v) ((v) << ((n) * 4 + 2))
 #define RKISP1_CIF_ISP_DPF_MAX_NLF_COEFFS 17
 #define RKISP1_CIF_ISP_DPF_MAX_SPATIAL_COEFFS 6
 #define RKISP1_CIF_ISP_STAT_AWB (1U << 0)
diff --git a/libc/kernel/uapi/linux/sed-opal.h b/libc/kernel/uapi/linux/sed-opal.h
index a20197a..f7ac9bd 100644
--- a/libc/kernel/uapi/linux/sed-opal.h
+++ b/libc/kernel/uapi/linux/sed-opal.h
@@ -112,6 +112,16 @@
   __u64 flags;
   __u64 priv;
 };
+#define OPAL_FL_SUPPORTED 0x00000001
+#define OPAL_FL_LOCKING_SUPPORTED 0x00000002
+#define OPAL_FL_LOCKING_ENABLED 0x00000004
+#define OPAL_FL_LOCKED 0x00000008
+#define OPAL_FL_MBR_ENABLED 0x00000010
+#define OPAL_FL_MBR_DONE 0x00000020
+struct opal_status {
+  __u32 flags;
+  __u32 reserved;
+};
 #define IOC_OPAL_SAVE _IOW('p', 220, struct opal_lock_unlock)
 #define IOC_OPAL_LOCK_UNLOCK _IOW('p', 221, struct opal_lock_unlock)
 #define IOC_OPAL_TAKE_OWNERSHIP _IOW('p', 222, struct opal_key)
@@ -128,4 +138,5 @@
 #define IOC_OPAL_MBR_DONE _IOW('p', 233, struct opal_mbr_done)
 #define IOC_OPAL_WRITE_SHADOW_MBR _IOW('p', 234, struct opal_shadow_mbr)
 #define IOC_OPAL_GENERIC_TABLE_RW _IOW('p', 235, struct opal_read_write_table)
+#define IOC_OPAL_GET_STATUS _IOR('p', 236, struct opal_status)
 #endif
diff --git a/libc/kernel/uapi/linux/seg6_local.h b/libc/kernel/uapi/linux/seg6_local.h
index 61a8d97..4d062e8 100644
--- a/libc/kernel/uapi/linux/seg6_local.h
+++ b/libc/kernel/uapi/linux/seg6_local.h
@@ -31,6 +31,7 @@
   SEG6_LOCAL_BPF,
   SEG6_LOCAL_VRFTABLE,
   SEG6_LOCAL_COUNTERS,
+  SEG6_LOCAL_FLAVORS,
   __SEG6_LOCAL_MAX,
 };
 #define SEG6_LOCAL_MAX (__SEG6_LOCAL_MAX - 1)
@@ -71,4 +72,21 @@
   __SEG6_LOCAL_CNT_MAX,
 };
 #define SEG6_LOCAL_CNT_MAX (__SEG6_LOCAL_CNT_MAX - 1)
+enum {
+  SEG6_LOCAL_FLV_UNSPEC,
+  SEG6_LOCAL_FLV_OPERATION,
+  SEG6_LOCAL_FLV_LCBLOCK_BITS,
+  SEG6_LOCAL_FLV_LCNODE_FN_BITS,
+  __SEG6_LOCAL_FLV_MAX,
+};
+#define SEG6_LOCAL_FLV_MAX (__SEG6_LOCAL_FLV_MAX - 1)
+enum {
+  SEG6_LOCAL_FLV_OP_UNSPEC,
+  SEG6_LOCAL_FLV_OP_PSP,
+  SEG6_LOCAL_FLV_OP_USP,
+  SEG6_LOCAL_FLV_OP_USD,
+  SEG6_LOCAL_FLV_OP_NEXT_CSID,
+  __SEG6_LOCAL_FLV_OP_MAX
+};
+#define SEG6_LOCAL_FLV_OP_MAX (__SEG6_LOCAL_FLV_OP_MAX - 1)
 #endif
diff --git a/libc/kernel/uapi/linux/stat.h b/libc/kernel/uapi/linux/stat.h
index a15b9b5..89304ce 100644
--- a/libc/kernel/uapi/linux/stat.h
+++ b/libc/kernel/uapi/linux/stat.h
@@ -78,7 +78,8 @@
   __u32 stx_dev_major;
   __u32 stx_dev_minor;
   __u64 stx_mnt_id;
-  __u64 __spare2;
+  __u32 stx_dio_mem_align;
+  __u32 stx_dio_offset_align;
   __u64 __spare3[12];
 };
 #define STATX_TYPE 0x00000001U
@@ -95,6 +96,7 @@
 #define STATX_BASIC_STATS 0x000007ffU
 #define STATX_BTIME 0x00000800U
 #define STATX_MNT_ID 0x00001000U
+#define STATX_DIOALIGN 0x00002000U
 #define STATX__RESERVED 0x80000000U
 #define STATX_ALL 0x00000fffU
 #define STATX_ATTR_COMPRESSED 0x00000004
diff --git a/libc/kernel/uapi/linux/target_core_user.h b/libc/kernel/uapi/linux/target_core_user.h
index daecb7d..83e155e 100644
--- a/libc/kernel/uapi/linux/target_core_user.h
+++ b/libc/kernel/uapi/linux/target_core_user.h
@@ -34,7 +34,7 @@
   __u32 cmdr_size;
   __u32 cmd_head;
   __u32 cmd_tail __attribute__((__aligned__(ALIGN_SIZE)));
-} __packed;
+} __attribute__((__packed__));
 enum tcmu_opcode {
   TCMU_OP_PAD = 0,
   TCMU_OP_CMD,
@@ -48,7 +48,7 @@
 #define TCMU_UFLAG_READ_LEN 0x2
 #define TCMU_UFLAG_KEEP_BUF 0x4
   __u8 uflags;
-} __packed;
+} __attribute__((__packed__));
 #define TCMU_OP_MASK 0x7
 #define TCMU_SENSE_BUFFERSIZE 96
 struct tcmu_cmd_entry {
@@ -71,7 +71,7 @@
       char sense_buffer[TCMU_SENSE_BUFFERSIZE];
     } rsp;
   };
-} __packed;
+} __attribute__((__packed__));
 struct tcmu_tmr_entry {
   struct tcmu_cmd_entry_hdr hdr;
 #define TCMU_TMR_UNKNOWN 0
@@ -90,7 +90,7 @@
   __u64 __pad3;
   __u64 __pad4;
   __u16 cmd_ids[];
-} __packed;
+} __attribute__((__packed__));
 #define TCMU_OP_ALIGN_SIZE sizeof(__u64)
 enum tcmu_genl_cmd {
   TCMU_CMD_UNSPEC,
diff --git a/libc/kernel/uapi/linux/tls.h b/libc/kernel/uapi/linux/tls.h
index d327d66..fcab74b 100644
--- a/libc/kernel/uapi/linux/tls.h
+++ b/libc/kernel/uapi/linux/tls.h
@@ -68,6 +68,18 @@
 #define TLS_CIPHER_SM4_CCM_SALT_SIZE 4
 #define TLS_CIPHER_SM4_CCM_TAG_SIZE 16
 #define TLS_CIPHER_SM4_CCM_REC_SEQ_SIZE 8
+#define TLS_CIPHER_ARIA_GCM_128 57
+#define TLS_CIPHER_ARIA_GCM_128_IV_SIZE 8
+#define TLS_CIPHER_ARIA_GCM_128_KEY_SIZE 16
+#define TLS_CIPHER_ARIA_GCM_128_SALT_SIZE 4
+#define TLS_CIPHER_ARIA_GCM_128_TAG_SIZE 16
+#define TLS_CIPHER_ARIA_GCM_128_REC_SEQ_SIZE 8
+#define TLS_CIPHER_ARIA_GCM_256 58
+#define TLS_CIPHER_ARIA_GCM_256_IV_SIZE 8
+#define TLS_CIPHER_ARIA_GCM_256_KEY_SIZE 32
+#define TLS_CIPHER_ARIA_GCM_256_SALT_SIZE 4
+#define TLS_CIPHER_ARIA_GCM_256_TAG_SIZE 16
+#define TLS_CIPHER_ARIA_GCM_256_REC_SEQ_SIZE 8
 #define TLS_SET_RECORD_TYPE 1
 #define TLS_GET_RECORD_TYPE 2
 struct tls_crypto_info {
@@ -116,6 +128,20 @@
   unsigned char salt[TLS_CIPHER_SM4_CCM_SALT_SIZE];
   unsigned char rec_seq[TLS_CIPHER_SM4_CCM_REC_SEQ_SIZE];
 };
+struct tls12_crypto_info_aria_gcm_128 {
+  struct tls_crypto_info info;
+  unsigned char iv[TLS_CIPHER_ARIA_GCM_128_IV_SIZE];
+  unsigned char key[TLS_CIPHER_ARIA_GCM_128_KEY_SIZE];
+  unsigned char salt[TLS_CIPHER_ARIA_GCM_128_SALT_SIZE];
+  unsigned char rec_seq[TLS_CIPHER_ARIA_GCM_128_REC_SEQ_SIZE];
+};
+struct tls12_crypto_info_aria_gcm_256 {
+  struct tls_crypto_info info;
+  unsigned char iv[TLS_CIPHER_ARIA_GCM_256_IV_SIZE];
+  unsigned char key[TLS_CIPHER_ARIA_GCM_256_KEY_SIZE];
+  unsigned char salt[TLS_CIPHER_ARIA_GCM_256_SALT_SIZE];
+  unsigned char rec_seq[TLS_CIPHER_ARIA_GCM_256_REC_SEQ_SIZE];
+};
 enum {
   TLS_INFO_UNSPEC,
   TLS_INFO_VERSION,
diff --git a/libc/kernel/uapi/linux/ublk_cmd.h b/libc/kernel/uapi/linux/ublk_cmd.h
index caf7f93..8c9cbeb 100644
--- a/libc/kernel/uapi/linux/ublk_cmd.h
+++ b/libc/kernel/uapi/linux/ublk_cmd.h
@@ -27,6 +27,8 @@
 #define UBLK_CMD_STOP_DEV 0x07
 #define UBLK_CMD_SET_PARAMS 0x08
 #define UBLK_CMD_GET_PARAMS 0x09
+#define UBLK_CMD_START_USER_RECOVERY 0x10
+#define UBLK_CMD_END_USER_RECOVERY 0x11
 #define UBLK_IO_FETCH_REQ 0x20
 #define UBLK_IO_COMMIT_AND_FETCH_REQ 0x21
 #define UBLK_IO_NEED_GET_DATA 0x22
@@ -39,8 +41,11 @@
 #define UBLK_F_SUPPORT_ZERO_COPY (1ULL << 0)
 #define UBLK_F_URING_CMD_COMP_IN_TASK (1ULL << 1)
 #define UBLK_F_NEED_GET_DATA (1UL << 2)
+#define UBLK_F_USER_RECOVERY (1UL << 3)
+#define UBLK_F_USER_RECOVERY_REISSUE (1UL << 4)
 #define UBLK_S_DEV_DEAD 0
 #define UBLK_S_DEV_LIVE 1
+#define UBLK_S_DEV_QUIESCED 2
 struct ublksrv_ctrl_cmd {
   __u32 dev_id;
   __u16 queue_id;
diff --git a/libc/kernel/uapi/linux/usbip.h b/libc/kernel/uapi/linux/usbip.h
index ae18347..b0c1067 100644
--- a/libc/kernel/uapi/linux/usbip.h
+++ b/libc/kernel/uapi/linux/usbip.h
@@ -27,4 +27,21 @@
   VDEV_ST_USED,
   VDEV_ST_ERROR
 };
+#define USBIP_URB_SHORT_NOT_OK 0x0001
+#define USBIP_URB_ISO_ASAP 0x0002
+#define USBIP_URB_NO_TRANSFER_DMA_MAP 0x0004
+#define USBIP_URB_ZERO_PACKET 0x0040
+#define USBIP_URB_NO_INTERRUPT 0x0080
+#define USBIP_URB_FREE_BUFFER 0x0100
+#define USBIP_URB_DIR_IN 0x0200
+#define USBIP_URB_DIR_OUT 0
+#define USBIP_URB_DIR_MASK USBIP_URB_DIR_IN
+#define USBIP_URB_DMA_MAP_SINGLE 0x00010000
+#define USBIP_URB_DMA_MAP_PAGE 0x00020000
+#define USBIP_URB_DMA_MAP_SG 0x00040000
+#define USBIP_URB_MAP_LOCAL 0x00080000
+#define USBIP_URB_SETUP_MAP_SINGLE 0x00100000
+#define USBIP_URB_SETUP_MAP_LOCAL 0x00200000
+#define USBIP_URB_DMA_SG_COMBINED 0x00400000
+#define USBIP_URB_ALIGNED_TEMP_BUFFER 0x00800000
 #endif
diff --git a/libc/kernel/uapi/linux/userfaultfd.h b/libc/kernel/uapi/linux/userfaultfd.h
index 46d7472..09e0d80 100644
--- a/libc/kernel/uapi/linux/userfaultfd.h
+++ b/libc/kernel/uapi/linux/userfaultfd.h
@@ -19,6 +19,8 @@
 #ifndef _LINUX_USERFAULTFD_H
 #define _LINUX_USERFAULTFD_H
 #include <linux/types.h>
+#define USERFAULTFD_IOC 0xAA
+#define USERFAULTFD_IOC_NEW _IO(USERFAULTFD_IOC, 0x00)
 #define UFFD_API ((__u64) 0xAA)
 #define UFFD_API_REGISTER_MODES (UFFDIO_REGISTER_MODE_MISSING | UFFDIO_REGISTER_MODE_WP | UFFDIO_REGISTER_MODE_MINOR)
 #define UFFD_API_FEATURES (UFFD_FEATURE_PAGEFAULT_FLAG_WP | UFFD_FEATURE_EVENT_FORK | UFFD_FEATURE_EVENT_REMAP | UFFD_FEATURE_EVENT_REMOVE | UFFD_FEATURE_EVENT_UNMAP | UFFD_FEATURE_MISSING_HUGETLBFS | UFFD_FEATURE_MISSING_SHMEM | UFFD_FEATURE_SIGBUS | UFFD_FEATURE_THREAD_ID | UFFD_FEATURE_MINOR_HUGETLBFS | UFFD_FEATURE_MINOR_SHMEM | UFFD_FEATURE_EXACT_ADDRESS | UFFD_FEATURE_WP_HUGETLBFS_SHMEM)
@@ -73,7 +75,7 @@
       __u64 reserved3;
     } reserved;
   } arg;
-} __packed;
+} __attribute__((__packed__));
 #define UFFD_EVENT_PAGEFAULT 0x12
 #define UFFD_EVENT_FORK 0x13
 #define UFFD_EVENT_REMAP 0x14
diff --git a/libc/kernel/uapi/linux/uvcvideo.h b/libc/kernel/uapi/linux/uvcvideo.h
index 719147a..46528a9 100644
--- a/libc/kernel/uapi/linux/uvcvideo.h
+++ b/libc/kernel/uapi/linux/uvcvideo.h
@@ -68,5 +68,5 @@
   __u8 length;
   __u8 flags;
   __u8 buf[];
-} __packed;
+} __attribute__((__packed__));
 #endif
diff --git a/libc/kernel/uapi/linux/v4l2-controls.h b/libc/kernel/uapi/linux/v4l2-controls.h
index 9de38d1..276ecaa 100644
--- a/libc/kernel/uapi/linux/v4l2-controls.h
+++ b/libc/kernel/uapi/linux/v4l2-controls.h
@@ -120,6 +120,7 @@
 #define V4L2_CID_USER_CCS_BASE (V4L2_CID_USER_BASE + 0x10f0)
 #define V4L2_CID_USER_ALLEGRO_BASE (V4L2_CID_USER_BASE + 0x1170)
 #define V4L2_CID_USER_ISL7998X_BASE (V4L2_CID_USER_BASE + 0x1180)
+#define V4L2_CID_USER_DW100_BASE (V4L2_CID_USER_BASE + 0x1190)
 #define V4L2_CID_CODEC_BASE (V4L2_CTRL_CLASS_CODEC | 0x900)
 #define V4L2_CID_CODEC_CLASS (V4L2_CTRL_CLASS_CODEC | 1)
 #define V4L2_CID_MPEG_STREAM_TYPE (V4L2_CID_CODEC_BASE + 0)
diff --git a/libc/kernel/uapi/linux/vbox_vmmdev_types.h b/libc/kernel/uapi/linux/vbox_vmmdev_types.h
index 009f9a6..777a2bb 100644
--- a/libc/kernel/uapi/linux/vbox_vmmdev_types.h
+++ b/libc/kernel/uapi/linux/vbox_vmmdev_types.h
@@ -157,7 +157,7 @@
       __u32 offset;
     } page_list;
   } u;
-} __packed;
+} __attribute__((__packed__));
 struct vmmdev_hgcm_function_parameter64 {
   enum vmmdev_hgcm_function_parameter_type type;
   union {
@@ -169,13 +169,13 @@
         __u64 phys_addr;
         __u64 linear_addr;
       } u;
-    } __packed pointer;
+    } __attribute__((__packed__)) pointer;
     struct {
       __u32 size;
       __u32 offset;
     } page_list;
-  } __packed u;
-} __packed;
+  } __attribute__((__packed__)) u;
+} __attribute__((__packed__));
 #if __BITS_PER_LONG == 64
 #define vmmdev_hgcm_function_parameter vmmdev_hgcm_function_parameter64
 #else
diff --git a/libc/kernel/uapi/linux/vdpa.h b/libc/kernel/uapi/linux/vdpa.h
index 8b3be00..ed61cdd 100644
--- a/libc/kernel/uapi/linux/vdpa.h
+++ b/libc/kernel/uapi/linux/vdpa.h
@@ -52,6 +52,8 @@
   VDPA_ATTR_DEV_QUEUE_INDEX,
   VDPA_ATTR_DEV_VENDOR_ATTR_NAME,
   VDPA_ATTR_DEV_VENDOR_ATTR_VALUE,
+  VDPA_ATTR_DEV_FEATURES,
+  VDPA_ATTR_VDPA_DEV_SUPPORTED_FEATURES,
   VDPA_ATTR_MAX,
 };
 #endif
diff --git a/libc/kernel/uapi/linux/version.h b/libc/kernel/uapi/linux/version.h
index c194345..ab95caf 100644
--- a/libc/kernel/uapi/linux/version.h
+++ b/libc/kernel/uapi/linux/version.h
@@ -16,8 +16,8 @@
  ***
  ****************************************************************************
  ****************************************************************************/
-#define LINUX_VERSION_CODE 393216
+#define LINUX_VERSION_CODE 393472
 #define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + ((c) > 255 ? 255 : (c)))
 #define LINUX_VERSION_MAJOR 6
-#define LINUX_VERSION_PATCHLEVEL 0
+#define LINUX_VERSION_PATCHLEVEL 1
 #define LINUX_VERSION_SUBLEVEL 0
diff --git a/libc/kernel/uapi/linux/vfio.h b/libc/kernel/uapi/linux/vfio.h
index 8075408..dffa136 100644
--- a/libc/kernel/uapi/linux/vfio.h
+++ b/libc/kernel/uapi/linux/vfio.h
@@ -304,6 +304,32 @@
   VFIO_DEVICE_STATE_RESUMING = 4,
   VFIO_DEVICE_STATE_RUNNING_P2P = 5,
 };
+#define VFIO_DEVICE_FEATURE_LOW_POWER_ENTRY 3
+struct vfio_device_low_power_entry_with_wakeup {
+  __s32 wakeup_eventfd;
+  __u32 reserved;
+};
+#define VFIO_DEVICE_FEATURE_LOW_POWER_ENTRY_WITH_WAKEUP 4
+#define VFIO_DEVICE_FEATURE_LOW_POWER_EXIT 5
+struct vfio_device_feature_dma_logging_control {
+  __aligned_u64 page_size;
+  __u32 num_ranges;
+  __u32 __reserved;
+  __aligned_u64 ranges;
+};
+struct vfio_device_feature_dma_logging_range {
+  __aligned_u64 iova;
+  __aligned_u64 length;
+};
+#define VFIO_DEVICE_FEATURE_DMA_LOGGING_START 6
+#define VFIO_DEVICE_FEATURE_DMA_LOGGING_STOP 7
+struct vfio_device_feature_dma_logging_report {
+  __aligned_u64 iova;
+  __aligned_u64 length;
+  __aligned_u64 page_size;
+  __aligned_u64 bitmap;
+};
+#define VFIO_DEVICE_FEATURE_DMA_LOGGING_REPORT 8
 struct vfio_iommu_type1_info {
   __u32 argsz;
   __u32 flags;
diff --git a/libc/kernel/uapi/linux/vfio_ccw.h b/libc/kernel/uapi/linux/vfio_ccw.h
index a6defc5..7bf08f5 100644
--- a/libc/kernel/uapi/linux/vfio_ccw.h
+++ b/libc/kernel/uapi/linux/vfio_ccw.h
@@ -27,19 +27,19 @@
 #define IRB_AREA_SIZE 96
   __u8 irb_area[IRB_AREA_SIZE];
   __u32 ret_code;
-} __packed;
+} __attribute__((__packed__));
 #define VFIO_CCW_ASYNC_CMD_HSCH (1 << 0)
 #define VFIO_CCW_ASYNC_CMD_CSCH (1 << 1)
 struct ccw_cmd_region {
   __u32 command;
   __u32 ret_code;
-} __packed;
+} __attribute__((__packed__));
 struct ccw_schib_region {
 #define SCHIB_AREA_SIZE 52
   __u8 schib_area[SCHIB_AREA_SIZE];
-} __packed;
+} __attribute__((__packed__));
 struct ccw_crw_region {
   __u32 crw;
   __u32 pad;
-} __packed;
+} __attribute__((__packed__));
 #endif
diff --git a/libc/kernel/uapi/linux/videodev2.h b/libc/kernel/uapi/linux/videodev2.h
index 9fc33a4..3d8dd72 100644
--- a/libc/kernel/uapi/linux/videodev2.h
+++ b/libc/kernel/uapi/linux/videodev2.h
@@ -185,7 +185,6 @@
 #define V4L2_CAP_SDR_OUTPUT 0x00400000
 #define V4L2_CAP_META_CAPTURE 0x00800000
 #define V4L2_CAP_READWRITE 0x01000000
-#define V4L2_CAP_ASYNCIO 0x02000000
 #define V4L2_CAP_STREAMING 0x04000000
 #define V4L2_CAP_META_OUTPUT 0x08000000
 #define V4L2_CAP_TOUCH 0x10000000
@@ -792,7 +791,7 @@
 #define V4L2_DV_FL_CAN_DETECT_REDUCED_FPS (1 << 9)
 #define V4L2_DV_BT_BLANKING_WIDTH(bt) ((bt)->hfrontporch + (bt)->hsync + (bt)->hbackporch)
 #define V4L2_DV_BT_FRAME_WIDTH(bt) ((bt)->width + V4L2_DV_BT_BLANKING_WIDTH(bt))
-#define V4L2_DV_BT_BLANKING_HEIGHT(bt) ((bt)->vfrontporch + (bt)->vsync + (bt)->vbackporch + (bt)->il_vfrontporch + (bt)->il_vsync + (bt)->il_vbackporch)
+#define V4L2_DV_BT_BLANKING_HEIGHT(bt) ((bt)->vfrontporch + (bt)->vsync + (bt)->vbackporch + ((bt)->interlaced ? ((bt)->il_vfrontporch + (bt)->il_vsync + (bt)->il_vbackporch) : 0))
 #define V4L2_DV_BT_FRAME_HEIGHT(bt) ((bt)->height + V4L2_DV_BT_BLANKING_HEIGHT(bt))
 struct v4l2_dv_timings {
   __u32 type;
@@ -1324,6 +1323,7 @@
 #define V4L2_EVENT_CTRL_CH_VALUE (1 << 0)
 #define V4L2_EVENT_CTRL_CH_FLAGS (1 << 1)
 #define V4L2_EVENT_CTRL_CH_RANGE (1 << 2)
+#define V4L2_EVENT_CTRL_CH_DIMENSIONS (1 << 3)
 struct v4l2_event_ctrl {
   __u32 changes;
   __u32 type;
@@ -1495,4 +1495,5 @@
 #define BASE_VIDIOC_PRIVATE 192
 #define V4L2_PIX_FMT_HM12 V4L2_PIX_FMT_NV12_16L16
 #define V4L2_PIX_FMT_SUNXI_TILED_NV12 V4L2_PIX_FMT_NV12_32L32
+#define V4L2_CAP_ASYNCIO 0x02000000
 #endif
diff --git a/libc/kernel/uapi/linux/virtio_blk.h b/libc/kernel/uapi/linux/virtio_blk.h
index f2f0381..0dd08c5 100644
--- a/libc/kernel/uapi/linux/virtio_blk.h
+++ b/libc/kernel/uapi/linux/virtio_blk.h
@@ -31,6 +31,7 @@
 #define VIRTIO_BLK_F_MQ 12
 #define VIRTIO_BLK_F_DISCARD 13
 #define VIRTIO_BLK_F_WRITE_ZEROES 14
+#define VIRTIO_BLK_F_SECURE_ERASE 16
 #ifndef VIRTIO_BLK_NO_LEGACY
 #define VIRTIO_BLK_F_BARRIER 0
 #define VIRTIO_BLK_F_SCSI 7
@@ -63,6 +64,9 @@
   __virtio32 max_write_zeroes_seg;
   __u8 write_zeroes_may_unmap;
   __u8 unused1[3];
+  __virtio32 max_secure_erase_sectors;
+  __virtio32 max_secure_erase_seg;
+  __virtio32 secure_erase_sector_alignment;
 } __attribute__((packed));
 #define VIRTIO_BLK_T_IN 0
 #define VIRTIO_BLK_T_OUT 1
@@ -73,6 +77,7 @@
 #define VIRTIO_BLK_T_GET_ID 8
 #define VIRTIO_BLK_T_DISCARD 11
 #define VIRTIO_BLK_T_WRITE_ZEROES 13
+#define VIRTIO_BLK_T_SECURE_ERASE 14
 #ifndef VIRTIO_BLK_NO_LEGACY
 #define VIRTIO_BLK_T_BARRIER 0x80000000
 #endif
diff --git a/libc/kernel/uapi/linux/wmi.h b/libc/kernel/uapi/linux/wmi.h
index 26f54d9..7b72056 100644
--- a/libc/kernel/uapi/linux/wmi.h
+++ b/libc/kernel/uapi/linux/wmi.h
@@ -30,17 +30,17 @@
   __u16 cmd_select;
   volatile __u32 input[4];
   volatile __u32 output[4];
-} __packed;
+} __attribute__((__packed__));
 struct dell_wmi_extensions {
   __u32 argattrib;
   __u32 blength;
   __u8 data[];
-} __packed;
+} __attribute__((__packed__));
 struct dell_wmi_smbios_buffer {
   __u64 length;
   struct calling_interface_buffer std;
   struct dell_wmi_extensions ext;
-} __packed;
+} __attribute__((__packed__));
 #define CLASS_TOKEN_READ 0
 #define CLASS_TOKEN_WRITE 1
 #define SELECT_TOKEN_STD 0
diff --git a/libc/kernel/uapi/linux/zorro.h b/libc/kernel/uapi/linux/zorro.h
index f8e47a1..86320aa 100644
--- a/libc/kernel/uapi/linux/zorro.h
+++ b/libc/kernel/uapi/linux/zorro.h
@@ -42,7 +42,7 @@
   __u8 ln_Type;
   __s8 ln_Pri;
   __be32 ln_Name;
-} __packed;
+} __attribute__((__packed__));
 struct ExpansionRom {
   __u8 er_Type;
   __u8 er_Product;
@@ -55,7 +55,7 @@
   __u8 er_Reserved0d;
   __u8 er_Reserved0e;
   __u8 er_Reserved0f;
-} __packed;
+} __attribute__((__packed__));
 #define ERT_TYPEMASK 0xc0
 #define ERT_ZORROII 0xc0
 #define ERT_ZORROIII 0x80
@@ -73,6 +73,6 @@
   __be32 cd_Driver;
   __be32 cd_NextCD;
   __be32 cd_Unused[4];
-} __packed;
+} __attribute__((__packed__));
 #define ZORRO_NUM_AUTO 16
 #endif
diff --git a/libc/kernel/uapi/misc/habanalabs.h b/libc/kernel/uapi/misc/habanalabs.h
index 6703676..b6140bc 100644
--- a/libc/kernel/uapi/misc/habanalabs.h
+++ b/libc/kernel/uapi/misc/habanalabs.h
@@ -617,6 +617,13 @@
   HL_SERVER_GAUDI_TYPE2 = 4,
   HL_SERVER_GAUDI2_HLS2 = 5
 };
+#define HL_NOTIFIER_EVENT_TPC_ASSERT (1ULL << 0)
+#define HL_NOTIFIER_EVENT_UNDEFINED_OPCODE (1ULL << 1)
+#define HL_NOTIFIER_EVENT_DEVICE_RESET (1ULL << 2)
+#define HL_NOTIFIER_EVENT_CS_TIMEOUT (1ULL << 3)
+#define HL_NOTIFIER_EVENT_DEVICE_UNAVAILABLE (1ULL << 4)
+#define HL_NOTIFIER_EVENT_USER_ENGINE_ERR (1ULL << 5)
+#define HL_NOTIFIER_EVENT_GENERAL_HW_ERR (1ULL << 6)
 #define HL_INFO_HW_IP_INFO 0
 #define HL_INFO_HW_EVENTS 1
 #define HL_INFO_DRAM_USAGE 2
@@ -641,12 +648,15 @@
 #define HL_INFO_CS_TIMEOUT_EVENT 24
 #define HL_INFO_RAZWI_EVENT 25
 #define HL_INFO_DEV_MEM_ALLOC_PAGE_SIZES 26
+#define HL_INFO_SECURED_ATTESTATION 27
 #define HL_INFO_REGISTER_EVENTFD 28
 #define HL_INFO_UNREGISTER_EVENTFD 29
 #define HL_INFO_GET_EVENTS 30
 #define HL_INFO_UNDEFINED_OPCODE_EVENT 31
+#define HL_INFO_ENGINE_STATUS 32
 #define HL_INFO_VERSION_MAX_LEN 128
 #define HL_INFO_CARD_NAME_MAX_LEN 16
+#define HL_ENGINES_DATA_MAX_SIZE SZ_1M
 struct hl_info_hw_ip_info {
   __u64 sram_base_address;
   __u64 dram_base_address;
@@ -665,7 +675,7 @@
   __u32 psoc_pci_pll_div_factor;
   __u8 tpc_enabled_mask;
   __u8 dram_enabled;
-  __u8 reserved;
+  __u8 security_enabled;
   __u8 mme_master_slave_mode;
   __u8 cpucp_version[HL_INFO_VERSION_MAX_LEN];
   __u8 card_name[HL_INFO_CARD_NAME_MAX_LEN];
@@ -794,6 +804,26 @@
 struct hl_info_dev_memalloc_page_sizes {
   __u64 page_order_bitmask;
 };
+#define SEC_PCR_DATA_BUF_SZ 256
+#define SEC_PCR_QUOTE_BUF_SZ 510
+#define SEC_SIGNATURE_BUF_SZ 255
+#define SEC_PUB_DATA_BUF_SZ 510
+#define SEC_CERTIFICATE_BUF_SZ 2046
+struct hl_info_sec_attest {
+  __u32 nonce;
+  __u16 pcr_quote_len;
+  __u16 pub_data_len;
+  __u16 certificate_len;
+  __u8 pcr_num_reg;
+  __u8 pcr_reg_len;
+  __u8 quote_sig_len;
+  __u8 pcr_data[SEC_PCR_DATA_BUF_SZ];
+  __u8 pcr_quote[SEC_PCR_QUOTE_BUF_SZ];
+  __u8 quote_sig[SEC_SIGNATURE_BUF_SZ];
+  __u8 public_data[SEC_PUB_DATA_BUF_SZ];
+  __u8 certificate[SEC_CERTIFICATE_BUF_SZ];
+  __u8 pad0[2];
+};
 enum gaudi_dcores {
   HL_GAUDI_WS_DCORE,
   HL_GAUDI_WN_DCORE,
@@ -810,6 +840,8 @@
     __u32 period_ms;
     __u32 pll_index;
     __u32 eventfd;
+    __u32 user_buffer_actual_size;
+    __u32 sec_attest_nonce;
   };
   __u32 pad;
 };
@@ -872,11 +904,23 @@
 #define HL_CS_FLAGS_ENCAP_SIGNALS 0x800
 #define HL_CS_FLAGS_RESERVE_SIGNALS_ONLY 0x1000
 #define HL_CS_FLAGS_UNRESERVE_SIGNALS_ONLY 0x2000
+#define HL_CS_FLAGS_ENGINE_CORE_COMMAND 0x4000
 #define HL_CS_STATUS_SUCCESS 0
 #define HL_MAX_JOBS_PER_CS 512
+#define HL_ENGINE_CORE_HALT (1 << 0)
+#define HL_ENGINE_CORE_RUN (1 << 1)
 struct hl_cs_in {
-  __u64 chunks_restore;
-  __u64 chunks_execute;
+  union {
+    struct {
+      __u64 chunks_restore;
+      __u64 chunks_execute;
+    };
+    struct {
+      __u64 engine_cores;
+      __u32 num_engine_cores;
+      __u32 core_command;
+    };
+  };
   union {
     __u64 seq;
     __u32 encaps_sig_handle_id;
@@ -1081,11 +1125,6 @@
   __u32 enable;
   __u32 ctx_id;
 };
-#define HL_NOTIFIER_EVENT_TPC_ASSERT (1ULL << 0)
-#define HL_NOTIFIER_EVENT_UNDEFINED_OPCODE (1ULL << 1)
-#define HL_NOTIFIER_EVENT_DEVICE_RESET (1ULL << 2)
-#define HL_NOTIFIER_EVENT_CS_TIMEOUT (1ULL << 3)
-#define HL_NOTIFIER_EVENT_DEVICE_UNAVAILABLE (1ULL << 4)
 #define HL_IOCTL_INFO _IOWR('H', 0x01, struct hl_info_args)
 #define HL_IOCTL_CB _IOWR('H', 0x02, union hl_cb_args)
 #define HL_IOCTL_CS _IOWR('H', 0x03, union hl_cs_args)
diff --git a/libc/kernel/uapi/misc/uacce/hisi_qm.h b/libc/kernel/uapi/misc/uacce/hisi_qm.h
index 87757a9..d2509d0 100644
--- a/libc/kernel/uapi/misc/uacce/hisi_qm.h
+++ b/libc/kernel/uapi/misc/uacce/hisi_qm.h
@@ -23,8 +23,15 @@
   __u16 id;
   __u16 qc_type;
 };
+struct hisi_qp_info {
+  __u32 sqe_size;
+  __u16 sq_depth;
+  __u16 cq_depth;
+  __u64 reserved;
+};
 #define HISI_QM_API_VER_BASE "hisi_qm_v1"
 #define HISI_QM_API_VER2_BASE "hisi_qm_v2"
 #define HISI_QM_API_VER3_BASE "hisi_qm_v3"
 #define UACCE_CMD_QM_SET_QP_CTX _IOWR('H', 10, struct hisi_qp_ctx)
+#define UACCE_CMD_QM_SET_QP_INFO _IOWR('H', 11, struct hisi_qp_info)
 #endif
diff --git a/libc/kernel/uapi/mtd/mtd-abi.h b/libc/kernel/uapi/mtd/mtd-abi.h
index 50ae565..6e26cae 100644
--- a/libc/kernel/uapi/mtd/mtd-abi.h
+++ b/libc/kernel/uapi/mtd/mtd-abi.h
@@ -52,6 +52,21 @@
   __u8 mode;
   __u8 padding[7];
 };
+struct mtd_read_req_ecc_stats {
+  __u32 uncorrectable_errors;
+  __u32 corrected_bitflips;
+  __u32 max_bitflips;
+};
+struct mtd_read_req {
+  __u64 start;
+  __u64 len;
+  __u64 ooblen;
+  __u64 usr_data;
+  __u64 usr_oob;
+  __u8 mode;
+  __u8 padding[7];
+  struct mtd_read_req_ecc_stats ecc_stats;
+};
 #define MTD_ABSENT 0
 #define MTD_RAM 1
 #define MTD_ROM 2
@@ -122,6 +137,7 @@
 #define MEMISLOCKED _IOR('M', 23, struct erase_info_user)
 #define MEMWRITE _IOWR('M', 24, struct mtd_write_req)
 #define OTPERASE _IOW('M', 25, struct otp_info)
+#define MEMREAD _IOWR('M', 26, struct mtd_read_req)
 struct nand_oobinfo {
   __u32 useecc;
   __u32 eccbytes;
diff --git a/libc/kernel/uapi/mtd/ubi-user.h b/libc/kernel/uapi/mtd/ubi-user.h
index 866fbd2..db203d5 100644
--- a/libc/kernel/uapi/mtd/ubi-user.h
+++ b/libc/kernel/uapi/mtd/ubi-user.h
@@ -56,7 +56,8 @@
   __s32 mtd_num;
   __s32 vid_hdr_offset;
   __s16 max_beb_per1024;
-  __s8 padding[10];
+  __s8 disable_fm;
+  __s8 padding[9];
 };
 enum {
   UBI_VOL_SKIP_CRC_CHECK_FLG = 0x1,
@@ -71,11 +72,11 @@
   __s16 name_len;
   __s8 padding2[4];
   char name[UBI_MAX_VOLUME_NAME + 1];
-} __packed;
+} __attribute__((__packed__));
 struct ubi_rsvol_req {
   __s64 bytes;
   __s32 vol_id;
-} __packed;
+} __attribute__((__packed__));
 struct ubi_rnvol_req {
   __s32 count;
   __s8 padding1[12];
@@ -85,24 +86,24 @@
     __s8 padding2[2];
     char name[UBI_MAX_VOLUME_NAME + 1];
   } ents[UBI_MAX_RNVOL];
-} __packed;
+} __attribute__((__packed__));
 struct ubi_leb_change_req {
   __s32 lnum;
   __s32 bytes;
   __s8 dtype;
   __s8 padding[7];
-} __packed;
+} __attribute__((__packed__));
 struct ubi_map_req {
   __s32 lnum;
   __s8 dtype;
   __s8 padding[3];
-} __packed;
+} __attribute__((__packed__));
 struct ubi_set_vol_prop_req {
   __u8 property;
   __u8 padding[7];
   __u64 value;
-} __packed;
+} __attribute__((__packed__));
 struct ubi_blkcreate_req {
   __s8 padding[128];
-} __packed;
+} __attribute__((__packed__));
 #endif
diff --git a/libc/kernel/uapi/rdma/efa-abi.h b/libc/kernel/uapi/rdma/efa-abi.h
index 4b6842b..bfb3f18 100644
--- a/libc/kernel/uapi/rdma/efa-abi.h
+++ b/libc/kernel/uapi/rdma/efa-abi.h
@@ -49,6 +49,7 @@
 };
 enum {
   EFA_CREATE_CQ_WITH_COMPLETION_CHANNEL = 1 << 0,
+  EFA_CREATE_CQ_WITH_SGID = 1 << 1,
 };
 struct efa_ibv_create_cq {
   __u32 comp_mask;
@@ -102,6 +103,7 @@
   EFA_QUERY_DEVICE_CAPS_RDMA_READ = 1 << 0,
   EFA_QUERY_DEVICE_CAPS_RNR_RETRY = 1 << 1,
   EFA_QUERY_DEVICE_CAPS_CQ_NOTIFICATIONS = 1 << 2,
+  EFA_QUERY_DEVICE_CAPS_CQ_WITH_SGID = 1 << 3,
 };
 struct efa_ibv_ex_query_device_resp {
   __u32 comp_mask;
diff --git a/libc/kernel/uapi/rdma/mlx5-abi.h b/libc/kernel/uapi/rdma/mlx5-abi.h
index aadb20e..f41c887 100644
--- a/libc/kernel/uapi/rdma/mlx5-abi.h
+++ b/libc/kernel/uapi/rdma/mlx5-abi.h
@@ -70,6 +70,7 @@
   MLX5_IB_ALLOC_UCONTEXT_RESP_MASK_ECE = 1UL << 2,
   MLX5_IB_ALLOC_UCONTEXT_RESP_MASK_SQD2RTS = 1UL << 3,
   MLX5_IB_ALLOC_UCONTEXT_RESP_MASK_REAL_TIME_TS = 1UL << 4,
+  MLX5_IB_ALLOC_UCONTEXT_RESP_MASK_MKEY_UPDATE_TAG = 1UL << 5,
 };
 enum mlx5_user_cmds_supp_uhw {
   MLX5_USER_CMDS_SUPP_UHW_QUERY_DEVICE = 1 << 0,
diff --git a/libc/kernel/uapi/rdma/mlx5_user_ioctl_cmds.h b/libc/kernel/uapi/rdma/mlx5_user_ioctl_cmds.h
index dc3eb1f..c060482 100644
--- a/libc/kernel/uapi/rdma/mlx5_user_ioctl_cmds.h
+++ b/libc/kernel/uapi/rdma/mlx5_user_ioctl_cmds.h
@@ -135,6 +135,7 @@
   MLX5_IB_ATTR_DEVX_UMEM_REG_ACCESS,
   MLX5_IB_ATTR_DEVX_UMEM_REG_OUT_ID,
   MLX5_IB_ATTR_DEVX_UMEM_REG_PGSZ_BITMAP,
+  MLX5_IB_ATTR_DEVX_UMEM_REG_DMABUF_FD,
 };
 enum mlx5_ib_devx_umem_dereg_attrs {
   MLX5_IB_ATTR_DEVX_UMEM_DEREG_HANDLE = (1U << UVERBS_ID_NS_SHIFT),
diff --git a/libc/kernel/uapi/rdma/rdma_user_rxe.h b/libc/kernel/uapi/rdma/rdma_user_rxe.h
index cdb00c7..2476699 100644
--- a/libc/kernel/uapi/rdma/rdma_user_rxe.h
+++ b/libc/kernel/uapi/rdma/rdma_user_rxe.h
@@ -52,7 +52,7 @@
 };
 struct rxe_send_wr {
   __aligned_u64 wr_id;
-  __u32 num_sge;
+  __u32 reserved;
   __u32 opcode;
   __u32 send_flags;
   union {
@@ -128,7 +128,7 @@
 };
 struct rxe_recv_wqe {
   __aligned_u64 wr_id;
-  __u32 num_sge;
+  __u32 reserved;
   __u32 padding;
   struct rxe_dma_info dma;
 };
diff --git a/libc/kernel/uapi/scsi/scsi_netlink_fc.h b/libc/kernel/uapi/scsi/scsi_netlink_fc.h
index ff92877..6eeb866 100644
--- a/libc/kernel/uapi/scsi/scsi_netlink_fc.h
+++ b/libc/kernel/uapi/scsi/scsi_netlink_fc.h
@@ -30,6 +30,9 @@
   __u16 event_datalen;
   __u32 event_num;
   __u32 event_code;
-  __u32 event_data;
+  union {
+    __u32 event_data;
+    __DECLARE_FLEX_ARRAY(__u8, event_data_flex);
+  };
 } __attribute__((aligned(sizeof(__u64))));
 #endif
diff --git a/libc/kernel/uapi/sound/asoc.h b/libc/kernel/uapi/sound/asoc.h
index eeb12b0..1940e5d 100644
--- a/libc/kernel/uapi/sound/asoc.h
+++ b/libc/kernel/uapi/sound/asoc.h
@@ -356,7 +356,7 @@
   __le32 pcm_elems;
   __le32 dai_link_elems;
   struct snd_soc_tplg_private priv;
-} __packed;
+} __attribute__((__packed__));
 struct snd_soc_tplg_stream_caps_v4 {
   __le32 size;
   char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
@@ -372,7 +372,7 @@
   __le32 period_size_max;
   __le32 buffer_size_min;
   __le32 buffer_size_max;
-} __packed;
+} __attribute__((__packed__));
 struct snd_soc_tplg_pcm_v4 {
   __le32 size;
   char pcm_name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
@@ -385,11 +385,11 @@
   struct snd_soc_tplg_stream stream[SND_SOC_TPLG_STREAM_CONFIG_MAX];
   __le32 num_streams;
   struct snd_soc_tplg_stream_caps_v4 caps[2];
-} __packed;
+} __attribute__((__packed__));
 struct snd_soc_tplg_link_config_v4 {
   __le32 size;
   __le32 id;
   struct snd_soc_tplg_stream stream[SND_SOC_TPLG_STREAM_CONFIG_MAX];
   __le32 num_streams;
-} __packed;
+} __attribute__((__packed__));
 #endif
diff --git a/libc/kernel/uapi/sound/asound.h b/libc/kernel/uapi/sound/asound.h
index 7f496d9..6e325e9 100644
--- a/libc/kernel/uapi/sound/asound.h
+++ b/libc/kernel/uapi/sound/asound.h
@@ -605,7 +605,7 @@
   __u32 tv_nsec;
   __u64 tv_sec;
   __u8 data[SNDRV_RAWMIDI_FRAMING_DATA_LENGTH];
-} __packed;
+} __attribute__((__packed__));
 struct snd_rawmidi_params {
   int stream;
   size_t buffer_size;
diff --git a/libc/kernel/uapi/sound/skl-tplg-interface.h b/libc/kernel/uapi/sound/skl-tplg-interface.h
index 387d168..6dd9655 100644
--- a/libc/kernel/uapi/sound/skl-tplg-interface.h
+++ b/libc/kernel/uapi/sound/skl-tplg-interface.h
@@ -111,7 +111,7 @@
   __u32 param_id;
   __u32 max;
   char params[];
-} __packed;
+} __attribute__((__packed__));
 enum skl_tkn_dir {
   SKL_DIR_IN,
   SKL_DIR_OUT
@@ -123,7 +123,7 @@
 struct skl_dfw_v4_module_pin {
   __u16 module_id;
   __u16 instance_id;
-} __packed;
+} __attribute__((__packed__));
 struct skl_dfw_v4_module_fmt {
   __u32 channels;
   __u32 freq;
@@ -133,21 +133,21 @@
   __u32 interleaving_style;
   __u32 sample_type;
   __u32 ch_map;
-} __packed;
+} __attribute__((__packed__));
 struct skl_dfw_v4_module_caps {
   __u32 set_params : 2;
   __u32 rsvd : 30;
   __u32 param_id;
   __u32 caps_size;
   __u32 caps[HDA_SST_CFG_MAX];
-} __packed;
+} __attribute__((__packed__));
 struct skl_dfw_v4_pipe {
   __u8 pipe_id;
   __u8 pipe_priority;
   __u16 conn_type : 4;
   __u16 rsvd : 4;
   __u16 memory_pages : 8;
-} __packed;
+} __attribute__((__packed__));
 struct skl_dfw_v4_module {
   char uuid[SKL_UUID_STR_SZ];
   __u16 module_id;
@@ -181,5 +181,5 @@
   struct skl_dfw_v4_module_pin in_pin[MAX_IN_QUEUE];
   struct skl_dfw_v4_module_pin out_pin[MAX_OUT_QUEUE];
   struct skl_dfw_v4_module_caps caps;
-} __packed;
+} __attribute__((__packed__));
 #endif
diff --git a/libc/kernel/uapi/sound/sof/fw.h b/libc/kernel/uapi/sound/sof/fw.h
index c36c2b9..97b7de3 100644
--- a/libc/kernel/uapi/sound/sof/fw.h
+++ b/libc/kernel/uapi/sound/sof/fw.h
@@ -46,7 +46,7 @@
   enum snd_sof_fw_blk_type type;
   __u32 size;
   __u32 offset;
-} __packed;
+} __attribute__((__packed__));
 enum snd_sof_fw_mod_type {
   SOF_FW_BASE = 0,
   SOF_FW_MODULE = 1,
@@ -55,11 +55,11 @@
   enum snd_sof_fw_mod_type type;
   __u32 size;
   __u32 num_blocks;
-} __packed;
+} __attribute__((__packed__));
 struct snd_sof_fw_header {
   unsigned char sig[SND_SOF_FW_SIG_SIZE];
   __u32 file_size;
   __u32 num_modules;
   __u32 abi;
-} __packed;
+} __attribute__((__packed__));
 #endif
diff --git a/libc/kernel/uapi/sound/sof/header.h b/libc/kernel/uapi/sound/sof/header.h
index a1a13db..7514550 100644
--- a/libc/kernel/uapi/sound/sof/header.h
+++ b/libc/kernel/uapi/sound/sof/header.h
@@ -26,7 +26,7 @@
   __u32 abi;
   __u32 reserved[4];
   __u32 data[];
-} __packed;
+} __attribute__((__packed__));
 #define SOF_MANIFEST_DATA_TYPE_NHLT 1
 struct sof_manifest_tlv {
   __le32 type;
diff --git a/libc/libc.map.txt b/libc/libc.map.txt
index 5695dc6..4a4e607 100644
--- a/libc/libc.map.txt
+++ b/libc/libc.map.txt
@@ -1518,34 +1518,34 @@
     tss_set;
 
     # Unwinder implementation
-    __aeabi_unwind_cpp_pr0; # apex llndk arm
-    __aeabi_unwind_cpp_pr1; # apex llndk arm
-    __aeabi_unwind_cpp_pr2; # apex llndk arm
-    __deregister_frame; # apex llndk arm64 x86 x86_64
-    __gnu_unwind_frame; # apex llndk arm
-    __register_frame; # apex llndk arm64 x86 x86_64
-    _Unwind_Backtrace; # apex llndk
-    _Unwind_Complete; # apex llndk arm
-    _Unwind_DeleteException; # apex llndk
-    _Unwind_Find_FDE; # apex llndk
-    _Unwind_FindEnclosingFunction; # apex llndk
-    _Unwind_ForcedUnwind; # apex llndk arm64 x86 x86_64
-    _Unwind_GetCFA; # apex llndk
-    _Unwind_GetDataRelBase; # apex llndk
-    _Unwind_GetGR; # apex llndk
-    _Unwind_GetIP; # apex llndk
-    _Unwind_GetIPInfo; # apex llndk
-    _Unwind_GetLanguageSpecificData; # apex llndk
-    _Unwind_GetRegionStart; # apex llndk
-    _Unwind_GetTextRelBase; # apex llndk
-    _Unwind_RaiseException; # apex llndk
-    _Unwind_Resume; # apex llndk
-    _Unwind_Resume_or_Rethrow; # apex llndk
-    _Unwind_SetGR; # apex llndk
-    _Unwind_SetIP; # apex llndk
-    _Unwind_VRS_Get; # apex llndk arm
-    _Unwind_VRS_Pop; # apex llndk arm
-    _Unwind_VRS_Set; # apex llndk arm
+    __aeabi_unwind_cpp_pr0; # arm
+    __aeabi_unwind_cpp_pr1; # arm
+    __aeabi_unwind_cpp_pr2; # arm
+    __deregister_frame; # arm64 x86 x86_64
+    __gnu_unwind_frame; # arm
+    __register_frame; # arm64 x86 x86_64
+    _Unwind_Backtrace;
+    _Unwind_Complete; # arm
+    _Unwind_DeleteException;
+    _Unwind_Find_FDE;
+    _Unwind_FindEnclosingFunction;
+    _Unwind_ForcedUnwind; # arm64 x86 x86_64
+    _Unwind_GetCFA;
+    _Unwind_GetDataRelBase;
+    _Unwind_GetGR;
+    _Unwind_GetIP;
+    _Unwind_GetIPInfo;
+    _Unwind_GetLanguageSpecificData;
+    _Unwind_GetRegionStart;
+    _Unwind_GetTextRelBase;
+    _Unwind_RaiseException;
+    _Unwind_Resume;
+    _Unwind_Resume_or_Rethrow;
+    _Unwind_SetGR;
+    _Unwind_SetIP;
+    _Unwind_VRS_Get; # arm
+    _Unwind_VRS_Pop; # arm
+    _Unwind_VRS_Set; # arm
 } LIBC_Q;
 
 LIBC_S { # introduced=S
diff --git a/libc/malloc_debug/Android.bp b/libc/malloc_debug/Android.bp
index e7a157e..373d497 100644
--- a/libc/malloc_debug/Android.bp
+++ b/libc/malloc_debug/Android.bp
@@ -176,6 +176,11 @@
         "bionic_libc_platform_headers",
     ],
 
+    // The clang-analyzer-unix.Malloc and other warnings in these
+    // unit tests are either false positive or in
+    // negative tests that can be ignored.
+    tidy: false,
+
     srcs: [
         "tests/malloc_debug_system_tests.cpp",
     ],
diff --git a/libc/malloc_debug/Config.cpp b/libc/malloc_debug/Config.cpp
index 6a81277..be577bc 100644
--- a/libc/malloc_debug/Config.cpp
+++ b/libc/malloc_debug/Config.cpp
@@ -87,35 +87,65 @@
         {BACKTRACE_SPECIFIC_SIZES, &Config::SetBacktraceSize},
     },
     {
+        "bt_sz",
+        {BACKTRACE_SPECIFIC_SIZES, &Config::SetBacktraceSize},
+    },
+    {
         "backtrace_min_size",
         {BACKTRACE_SPECIFIC_SIZES, &Config::SetBacktraceMinSize},
     },
     {
+        "bt_min_sz",
+        {BACKTRACE_SPECIFIC_SIZES, &Config::SetBacktraceMinSize},
+    },
+    {
         "backtrace_max_size",
         {BACKTRACE_SPECIFIC_SIZES, &Config::SetBacktraceMaxSize},
     },
-
+    {
+        "bt_max_sz",
+        {BACKTRACE_SPECIFIC_SIZES, &Config::SetBacktraceMaxSize},
+    },
     {
         "backtrace",
         {BACKTRACE | TRACK_ALLOCS, &Config::SetBacktrace},
     },
     {
+        "bt",
+        {BACKTRACE | TRACK_ALLOCS, &Config::SetBacktrace},
+    },
+    {
         "backtrace_enable_on_signal",
         {BACKTRACE | TRACK_ALLOCS, &Config::SetBacktraceEnableOnSignal},
     },
-
+    {
+        "bt_en_on_sig",
+        {BACKTRACE | TRACK_ALLOCS, &Config::SetBacktraceEnableOnSignal},
+    },
     {
         "backtrace_dump_on_exit",
         {0, &Config::SetBacktraceDumpOnExit},
     },
     {
+        "bt_dmp_on_ex",
+        {0, &Config::SetBacktraceDumpOnExit},
+    },
+    {
         "backtrace_dump_prefix",
         {0, &Config::SetBacktraceDumpPrefix},
     },
     {
+        "bt_dmp_pre",
+        {0, &Config::SetBacktraceDumpPrefix},
+    },
+    {
         "backtrace_full",
         {BACKTRACE_FULL, &Config::VerifyValueEmpty},
     },
+    {
+        "bt_full",
+        {BACKTRACE_FULL, &Config::VerifyValueEmpty},
+    },
 
     {
         "fill",
diff --git a/libc/malloc_debug/PointerData.cpp b/libc/malloc_debug/PointerData.cpp
index 5ab2232..e3a35a6 100644
--- a/libc/malloc_debug/PointerData.cpp
+++ b/libc/malloc_debug/PointerData.cpp
@@ -26,6 +26,7 @@
  * SUCH DAMAGE.
  */
 
+#include <cxxabi.h>
 #include <errno.h>
 #include <inttypes.h>
 #include <signal.h>
@@ -54,8 +55,6 @@
 #include "malloc_debug.h"
 #include "UnwindBacktrace.h"
 
-extern "C" char* __cxa_demangle(const char*, char*, size_t*, int*);
-
 std::atomic_uint8_t PointerData::backtrace_enabled_;
 std::atomic_bool PointerData::backtrace_dump_;
 
@@ -617,8 +616,8 @@
         if (frame.function_name.empty()) {
           dprintf(fd, " \"\" 0}");
         } else {
-          char* demangled_name = __cxa_demangle(frame.function_name.c_str(), nullptr, nullptr,
-                                                nullptr);
+          char* demangled_name =
+              abi::__cxa_demangle(frame.function_name.c_str(), nullptr, nullptr, nullptr);
           const char* name;
           if (demangled_name != nullptr) {
             name = demangled_name;
diff --git a/libc/malloc_debug/README.md b/libc/malloc_debug/README.md
index 3667624..fddc4a3 100644
--- a/libc/malloc_debug/README.md
+++ b/libc/malloc_debug/README.md
@@ -200,6 +200,20 @@
 that is extra thorough and can unwind through Java frames. This will run
 slower than the normal backtracing function.
 
+### bt, bt\_dmp\_on\_ex, bt\_dmp\_pre, bt\_en\_on\_sig, bt\_full, bt\_max\_sz, bt\_min\_sz, bt\_sz
+As of U, add shorter aliases for backtrace related options to avoid property length restrictions.
+
+| Alias           | Option                        |
+|:----------------|:------------------------------|
+| bt              | backtrace                     |
+| bt\_dmp\_on\_ex | backtrace\_dump\_on\_exit     |
+| bt\_dmp\_pre    | backtrace\_dump\_prefix       |
+| bt\_en\_on\_sig | backtrace\_enable\_on\_signal |
+| bt\_full        | backtrace\_full               |
+| bt\_max\_sz     | backtrace\_max\_size          |
+| bt\_min\_sz     | backtrace\_min\_size          |
+| bt\_sz          | backtrace\_size               |
+
 ### check\_unreachable\_on\_signal
 As of Android U, this option will trigger a check for unreachable memory
 in a process. Specifically, if the signal SIGRTMAX - 16 (which is 48 on
diff --git a/libc/malloc_debug/RecordData.cpp b/libc/malloc_debug/RecordData.cpp
index a829a09..8a77170 100644
--- a/libc/malloc_debug/RecordData.cpp
+++ b/libc/malloc_debug/RecordData.cpp
@@ -28,6 +28,7 @@
 
 #include <errno.h>
 #include <fcntl.h>
+#include <inttypes.h>
 #include <pthread.h>
 #include <stdatomic.h>
 #include <stdint.h>
@@ -52,40 +53,51 @@
   return dprintf(fd, "%d: thread_done 0x0\n", tid_) > 0;
 }
 
-AllocEntry::AllocEntry(void* pointer) : pointer_(pointer) {}
+AllocEntry::AllocEntry(void* pointer, uint64_t start_ns, uint64_t end_ns)
+    : pointer_(pointer), start_ns_(start_ns), end_ns_(end_ns) {}
 
-MallocEntry::MallocEntry(void* pointer, size_t size) : AllocEntry(pointer), size_(size) {}
+MallocEntry::MallocEntry(void* pointer, size_t size, uint64_t start_ns, uint64_t end_ns)
+    : AllocEntry(pointer, start_ns, end_ns), size_(size) {}
 
 bool MallocEntry::Write(int fd) const {
-  return dprintf(fd, "%d: malloc %p %zu\n", tid_, pointer_, size_) > 0;
+  return dprintf(fd, "%d: malloc %p %zu %" PRIu64 " %" PRIu64 "\n", tid_, pointer_, size_,
+                 start_ns_, end_ns_) > 0;
 }
 
-FreeEntry::FreeEntry(void* pointer) : AllocEntry(pointer) {}
+FreeEntry::FreeEntry(void* pointer, uint64_t start_ns, uint64_t end_ns)
+    : AllocEntry(pointer, start_ns, end_ns) {}
 
 bool FreeEntry::Write(int fd) const {
-  return dprintf(fd, "%d: free %p\n", tid_, pointer_) > 0;
+  return dprintf(fd, "%d: free %p %" PRIu64 " %" PRIu64 "\n", tid_, pointer_, start_ns_, end_ns_) >
+         0;
 }
 
-CallocEntry::CallocEntry(void* pointer, size_t nmemb, size_t size)
-    : MallocEntry(pointer, size), nmemb_(nmemb) {}
+CallocEntry::CallocEntry(void* pointer, size_t nmemb, size_t size, uint64_t start_ns,
+                         uint64_t end_ns)
+    : MallocEntry(pointer, size, start_ns, end_ns), nmemb_(nmemb) {}
 
 bool CallocEntry::Write(int fd) const {
-  return dprintf(fd, "%d: calloc %p %zu %zu\n", tid_, pointer_, nmemb_, size_) > 0;
+  return dprintf(fd, "%d: calloc %p %zu %zu %" PRIu64 " %" PRIu64 "\n", tid_, pointer_, nmemb_,
+                 size_, start_ns_, end_ns_) > 0;
 }
 
-ReallocEntry::ReallocEntry(void* pointer, size_t size, void* old_pointer)
-    : MallocEntry(pointer, size), old_pointer_(old_pointer) {}
+ReallocEntry::ReallocEntry(void* pointer, size_t size, void* old_pointer, uint64_t start_ns,
+                           uint64_t end_ns)
+    : MallocEntry(pointer, size, start_ns, end_ns), old_pointer_(old_pointer) {}
 
 bool ReallocEntry::Write(int fd) const {
-  return dprintf(fd, "%d: realloc %p %p %zu\n", tid_, pointer_, old_pointer_, size_) > 0;
+  return dprintf(fd, "%d: realloc %p %p %zu %" PRIu64 " %" PRIu64 "\n", tid_, pointer_,
+                 old_pointer_, size_, start_ns_, end_ns_) > 0;
 }
 
 // aligned_alloc, posix_memalign, memalign, pvalloc, valloc all recorded with this class.
-MemalignEntry::MemalignEntry(void* pointer, size_t size, size_t alignment)
-    : MallocEntry(pointer, size), alignment_(alignment) {}
+MemalignEntry::MemalignEntry(void* pointer, size_t size, size_t alignment, uint64_t start_ns,
+                             uint64_t end_ns)
+    : MallocEntry(pointer, size, start_ns, end_ns), alignment_(alignment) {}
 
 bool MemalignEntry::Write(int fd) const {
-  return dprintf(fd, "%d: memalign %p %zu %zu\n", tid_, pointer_, alignment_, size_) > 0;
+  return dprintf(fd, "%d: memalign %p %zu %zu %" PRIu64 " %" PRIu64 "\n", tid_, pointer_,
+                 alignment_, size_, start_ns_, end_ns_) > 0;
 }
 
 struct ThreadData {
diff --git a/libc/malloc_debug/RecordData.h b/libc/malloc_debug/RecordData.h
index 43dba6a..a02c956 100644
--- a/libc/malloc_debug/RecordData.h
+++ b/libc/malloc_debug/RecordData.h
@@ -68,19 +68,23 @@
 
 class AllocEntry : public RecordEntry {
  public:
-  explicit AllocEntry(void* pointer);
+  explicit AllocEntry(void* pointer, uint64_t st, uint64_t et);
   virtual ~AllocEntry() = default;
 
  protected:
   void* pointer_;
 
+  // The start/end time of this operation.
+  uint64_t start_ns_;
+  uint64_t end_ns_;
+
  private:
   BIONIC_DISALLOW_COPY_AND_ASSIGN(AllocEntry);
 };
 
 class MallocEntry : public AllocEntry {
  public:
-  MallocEntry(void* pointer, size_t size);
+  MallocEntry(void* pointer, size_t size, uint64_t st, uint64_t et);
   virtual ~MallocEntry() = default;
 
   bool Write(int fd) const override;
@@ -94,7 +98,7 @@
 
 class FreeEntry : public AllocEntry {
  public:
-  explicit FreeEntry(void* pointer);
+  explicit FreeEntry(void* pointer, uint64_t st, uint64_t et);
   virtual ~FreeEntry() = default;
 
   bool Write(int fd) const override;
@@ -105,7 +109,7 @@
 
 class CallocEntry : public MallocEntry {
  public:
-  CallocEntry(void* pointer, size_t size, size_t nmemb);
+  CallocEntry(void* pointer, size_t nmemb, size_t size, uint64_t st, uint64_t et);
   virtual ~CallocEntry() = default;
 
   bool Write(int fd) const override;
@@ -119,7 +123,7 @@
 
 class ReallocEntry : public MallocEntry {
  public:
-  ReallocEntry(void* pointer, size_t size, void* old_pointer);
+  ReallocEntry(void* pointer, size_t size, void* old_pointer, uint64_t st, uint64_t et);
   virtual ~ReallocEntry() = default;
 
   bool Write(int fd) const override;
@@ -134,7 +138,7 @@
 // aligned_alloc, posix_memalign, memalign, pvalloc, valloc all recorded with this class.
 class MemalignEntry : public MallocEntry {
  public:
-  MemalignEntry(void* pointer, size_t size, size_t alignment);
+  MemalignEntry(void* pointer, size_t size, size_t alignment, uint64_t st, uint64_t et);
   virtual ~MemalignEntry() = default;
 
   bool Write(int fd) const override;
diff --git a/libc/malloc_debug/UnwindBacktrace.cpp b/libc/malloc_debug/UnwindBacktrace.cpp
index c892a39..8a6ff7b 100644
--- a/libc/malloc_debug/UnwindBacktrace.cpp
+++ b/libc/malloc_debug/UnwindBacktrace.cpp
@@ -26,6 +26,7 @@
  * SUCH DAMAGE.
  */
 
+#include <cxxabi.h>
 #include <inttypes.h>
 #include <pthread.h>
 #include <stdint.h>
@@ -48,8 +49,6 @@
 #define PAD_PTR "08" PRIx64
 #endif
 
-extern "C" char* __cxa_demangle(const char*, char*, size_t*, int*);
-
 bool Unwind(std::vector<uintptr_t>* frames, std::vector<unwindstack::FrameData>* frame_info,
             size_t max_frames) {
   [[clang::no_destroy]] static unwindstack::AndroidLocalUnwinder unwinder(
@@ -89,7 +88,8 @@
 
     if (!info->function_name.empty()) {
       line += " (";
-      char* demangled_name = __cxa_demangle(info->function_name.c_str(), nullptr, nullptr, nullptr);
+      char* demangled_name =
+          abi::__cxa_demangle(info->function_name.c_str(), nullptr, nullptr, nullptr);
       if (demangled_name != nullptr) {
         line += demangled_name;
         free(demangled_name);
diff --git a/libc/malloc_debug/backtrace.cpp b/libc/malloc_debug/backtrace.cpp
index 0649571..ecb3a80 100644
--- a/libc/malloc_debug/backtrace.cpp
+++ b/libc/malloc_debug/backtrace.cpp
@@ -26,6 +26,7 @@
  * SUCH DAMAGE.
  */
 
+#include <cxxabi.h>
 #include <dlfcn.h>
 #include <errno.h>
 #include <inttypes.h>
@@ -48,8 +49,6 @@
 
 typedef struct _Unwind_Context __unwind_context;
 
-extern "C" char* __cxa_demangle(const char*, char*, size_t*, int*);
-
 static MapData g_map_data;
 static const MapEntry* g_current_code_map = nullptr;
 
@@ -145,7 +144,7 @@
 
     char buf[1024];
     if (symbol != nullptr) {
-      char* demangled_name = __cxa_demangle(symbol, nullptr, nullptr, nullptr);
+      char* demangled_name = abi::__cxa_demangle(symbol, nullptr, nullptr, nullptr);
       const char* name;
       if (demangled_name != nullptr) {
         name = demangled_name;
diff --git a/libc/malloc_debug/malloc_debug.cpp b/libc/malloc_debug/malloc_debug.cpp
index 617858a..4bc5649 100644
--- a/libc/malloc_debug/malloc_debug.cpp
+++ b/libc/malloc_debug/malloc_debug.cpp
@@ -68,6 +68,100 @@
 bool* g_zygote_child;
 
 const MallocDispatch* g_dispatch;
+
+static __always_inline uint64_t Nanotime() {
+  struct timespec t = {};
+  clock_gettime(CLOCK_MONOTONIC, &t);
+  return static_cast<uint64_t>(t.tv_sec) * 1000000000LL + t.tv_nsec;
+}
+
+namespace {
+// A TimedResult contains the result of from malloc end_ns al. functions and the
+// start/end timestamps.
+struct TimedResult {
+  uint64_t start_ns = 0;
+  uint64_t end_ns = 0;
+  union {
+    size_t s;
+    int i;
+    void* p;
+  } v;
+
+  uint64_t GetStartTimeNS() const { return start_ns; }
+  uint64_t GetEndTimeNS() const { return end_ns; }
+  void SetStartTimeNS(uint64_t t) { start_ns = t; }
+  void SetEndTimeNS(uint64_t t) { end_ns = t; }
+
+  template <typename T>
+  void setValue(T);
+  template <>
+  void setValue(size_t s) {
+    v.s = s;
+  }
+  template <>
+  void setValue(int i) {
+    v.i = i;
+  }
+  template <>
+  void setValue(void* p) {
+    v.p = p;
+  }
+
+  template <typename T>
+  T getValue() const;
+  template <>
+  size_t getValue<size_t>() const {
+    return v.s;
+  }
+  template <>
+  int getValue<int>() const {
+    return v.i;
+  }
+  template <>
+  void* getValue<void*>() const {
+    return v.p;
+  }
+};
+
+class ScopedTimer {
+ public:
+  ScopedTimer(TimedResult& res) : res_(res) { res_.start_ns = Nanotime(); }
+
+  ~ScopedTimer() { res_.end_ns = Nanotime(); }
+
+ private:
+  TimedResult& res_;
+};
+
+}  // namespace
+
+template <typename MallocFn, typename... Args>
+static TimedResult TimerCall(MallocFn fn, Args... args) {
+  TimedResult ret;
+  decltype((g_dispatch->*fn)(args...)) r;
+  if (g_debug->config().options() & RECORD_ALLOCS) {
+    ScopedTimer t(ret);
+    r = (g_dispatch->*fn)(args...);
+  } else {
+    r = (g_dispatch->*fn)(args...);
+  }
+  ret.setValue<decltype(r)>(r);
+  return ret;
+}
+
+template <typename MallocFn, typename... Args>
+static TimedResult TimerCallVoid(MallocFn fn, Args... args) {
+  TimedResult ret;
+  {
+    ScopedTimer t(ret);
+    (g_dispatch->*fn)(args...);
+  }
+  return ret;
+}
+
+#define TCALL(FUNC, ...) TimerCall(&MallocDispatch::FUNC, __VA_ARGS__);
+#define TCALLVOID(FUNC, ...) TimerCallVoid(&MallocDispatch::FUNC, __VA_ARGS__);
+
 // ------------------------------------------------------------------------
 
 // ------------------------------------------------------------------------
@@ -419,7 +513,7 @@
   return InternalMallocUsableSize(pointer);
 }
 
-static void* InternalMalloc(size_t size) {
+static TimedResult InternalMalloc(size_t size) {
   if ((g_debug->config().options() & BACKTRACE) && g_debug->pointer->ShouldDumpAndReset()) {
     debug_dump_heap(android::base::StringPrintf(
                         "%s.%d.txt", g_debug->config().backtrace_dump_prefix().c_str(), getpid())
@@ -430,30 +524,35 @@
     size = 1;
   }
 
+  TimedResult result;
+
   size_t real_size = size + g_debug->extra_bytes();
   if (real_size < size) {
     // Overflow.
     errno = ENOMEM;
-    return nullptr;
+    result.setValue<void*>(nullptr);
+    return result;
   }
 
   if (size > PointerInfoType::MaxSize()) {
     errno = ENOMEM;
-    return nullptr;
+    result.setValue<void*>(nullptr);
+    return result;
   }
 
-  void* pointer;
   if (g_debug->HeaderEnabled()) {
-    Header* header =
-        reinterpret_cast<Header*>(g_dispatch->memalign(MINIMUM_ALIGNMENT_BYTES, real_size));
+    result = TCALL(memalign, MINIMUM_ALIGNMENT_BYTES, real_size);
+    Header* header = reinterpret_cast<Header*>(result.getValue<void*>());
     if (header == nullptr) {
-      return nullptr;
+      return result;
     }
-    pointer = InitHeader(header, header, size);
+    result.setValue<void*>(InitHeader(header, header, size));
   } else {
-    pointer = g_dispatch->malloc(real_size);
+    result = TCALL(malloc, real_size);
   }
 
+  void* pointer = result.getValue<void*>();
+
   if (pointer != nullptr) {
     if (g_debug->TrackPointers()) {
       PointerData::Add(pointer, size);
@@ -466,7 +565,8 @@
       memset(pointer, g_debug->config().fill_alloc_value(), bytes);
     }
   }
-  return pointer;
+
+  return result;
 }
 
 void* debug_malloc(size_t size) {
@@ -479,16 +579,17 @@
   ScopedDisableDebugCalls disable;
   ScopedBacktraceSignalBlocker blocked;
 
-  void* pointer = InternalMalloc(size);
+  TimedResult result = InternalMalloc(size);
 
   if (g_debug->config().options() & RECORD_ALLOCS) {
-    g_debug->record->AddEntry(new MallocEntry(pointer, size));
+    g_debug->record->AddEntry(new MallocEntry(result.getValue<void*>(), size,
+                                              result.GetStartTimeNS(), result.GetEndTimeNS()));
   }
 
-  return pointer;
+  return result.getValue<void*>();
 }
 
-static void InternalFree(void* pointer) {
+static TimedResult InternalFree(void* pointer) {
   if ((g_debug->config().options() & BACKTRACE) && g_debug->pointer->ShouldDumpAndReset()) {
     debug_dump_heap(android::base::StringPrintf(
                         "%s.%d.txt", g_debug->config().backtrace_dump_prefix().c_str(), getpid())
@@ -530,6 +631,7 @@
     PointerData::Remove(pointer);
   }
 
+  TimedResult result;
   if (g_debug->config().options() & FREE_TRACK) {
     // Do not add the allocation until we are done modifying the pointer
     // itself. This avoids a race if a lot of threads are all doing
@@ -537,15 +639,15 @@
     // pointer from another thread, while still trying to free it in
     // this function.
     pointer = PointerData::AddFreed(pointer, bytes);
-    if (pointer != nullptr) {
-      if (g_debug->HeaderEnabled()) {
-        pointer = g_debug->GetHeader(pointer)->orig_pointer;
-      }
-      g_dispatch->free(pointer);
+    if (pointer != nullptr && g_debug->HeaderEnabled()) {
+      pointer = g_debug->GetHeader(pointer)->orig_pointer;
     }
+    result = TCALLVOID(free, pointer);
   } else {
-    g_dispatch->free(free_pointer);
+    result = TCALLVOID(free, free_pointer);
   }
+
+  return result;
 }
 
 void debug_free(void* pointer) {
@@ -558,15 +660,16 @@
   ScopedDisableDebugCalls disable;
   ScopedBacktraceSignalBlocker blocked;
 
-  if (g_debug->config().options() & RECORD_ALLOCS) {
-    g_debug->record->AddEntry(new FreeEntry(pointer));
-  }
-
   if (!VerifyPointer(pointer, "free")) {
     return;
   }
 
-  InternalFree(pointer);
+  TimedResult result = InternalFree(pointer);
+
+  if (g_debug->config().options() & RECORD_ALLOCS) {
+    g_debug->record->AddEntry(
+        new FreeEntry(pointer, result.GetStartTimeNS(), result.GetEndTimeNS()));
+  }
 }
 
 void* debug_memalign(size_t alignment, size_t bytes) {
@@ -588,6 +691,7 @@
     return nullptr;
   }
 
+  TimedResult result;
   void* pointer;
   if (g_debug->HeaderEnabled()) {
     // Make the alignment a power of two.
@@ -610,7 +714,8 @@
       return nullptr;
     }
 
-    pointer = g_dispatch->malloc(real_size);
+    result = TCALL(malloc, real_size);
+    pointer = result.getValue<void*>();
     if (pointer == nullptr) {
       return nullptr;
     }
@@ -620,6 +725,7 @@
     value += (-value % alignment);
 
     Header* header = g_debug->GetHeader(reinterpret_cast<void*>(value));
+    // Don't need to update `result` here because we only need the timestamps.
     pointer = InitHeader(header, pointer, bytes);
   } else {
     size_t real_size = bytes + g_debug->extra_bytes();
@@ -628,7 +734,8 @@
       errno = ENOMEM;
       return nullptr;
     }
-    pointer = g_dispatch->memalign(alignment, real_size);
+    result = TCALL(memalign, alignment, real_size);
+    pointer = result.getValue<void*>();
   }
 
   if (pointer != nullptr) {
@@ -644,7 +751,8 @@
     }
 
     if (g_debug->config().options() & RECORD_ALLOCS) {
-      g_debug->record->AddEntry(new MemalignEntry(pointer, bytes, alignment));
+      g_debug->record->AddEntry(new MemalignEntry(pointer, bytes, alignment,
+                                                  result.GetStartTimeNS(), result.GetEndTimeNS()));
     }
   }
 
@@ -662,10 +770,12 @@
   ScopedBacktraceSignalBlocker blocked;
 
   if (pointer == nullptr) {
-    pointer = InternalMalloc(bytes);
+    TimedResult result = InternalMalloc(bytes);
     if (g_debug->config().options() & RECORD_ALLOCS) {
-      g_debug->record->AddEntry(new ReallocEntry(pointer, bytes, nullptr));
+      g_debug->record->AddEntry(new ReallocEntry(result.getValue<void*>(), bytes, nullptr,
+                                                 result.GetStartTimeNS(), result.GetEndTimeNS()));
     }
+    pointer = result.getValue<void*>();
     return pointer;
   }
 
@@ -674,11 +784,13 @@
   }
 
   if (bytes == 0) {
+    TimedResult result = InternalFree(pointer);
+
     if (g_debug->config().options() & RECORD_ALLOCS) {
-      g_debug->record->AddEntry(new ReallocEntry(nullptr, bytes, pointer));
+      g_debug->record->AddEntry(new ReallocEntry(nullptr, bytes, pointer, result.GetStartTimeNS(),
+                                                 result.GetEndTimeNS()));
     }
 
-    InternalFree(pointer);
     return nullptr;
   }
 
@@ -697,6 +809,7 @@
     return nullptr;
   }
 
+  TimedResult result;
   void* new_pointer;
   size_t prev_size;
   if (g_debug->HeaderEnabled()) {
@@ -730,7 +843,8 @@
     }
 
     // Allocate the new size.
-    new_pointer = InternalMalloc(bytes);
+    result = InternalMalloc(bytes);
+    new_pointer = result.getValue<void*>();
     if (new_pointer == nullptr) {
       errno = ENOMEM;
       return nullptr;
@@ -738,14 +852,18 @@
 
     prev_size = header->usable_size;
     memcpy(new_pointer, pointer, prev_size);
-    InternalFree(pointer);
+    TimedResult free_time = InternalFree(pointer);
+    // `realloc` is split into two steps, update the end time to the finish time
+    // of the second operation.
+    result.SetEndTimeNS(free_time.GetEndTimeNS());
   } else {
     if (g_debug->TrackPointers()) {
       PointerData::Remove(pointer);
     }
 
     prev_size = g_dispatch->malloc_usable_size(pointer);
-    new_pointer = g_dispatch->realloc(pointer, real_size);
+    result = TCALL(realloc, pointer, real_size);
+    new_pointer = result.getValue<void*>();
     if (new_pointer == nullptr) {
       return nullptr;
     }
@@ -767,7 +885,8 @@
   }
 
   if (g_debug->config().options() & RECORD_ALLOCS) {
-    g_debug->record->AddEntry(new ReallocEntry(new_pointer, bytes, pointer));
+    g_debug->record->AddEntry(new ReallocEntry(new_pointer, bytes, pointer, result.GetStartTimeNS(),
+                                               result.GetEndTimeNS()));
   }
 
   return new_pointer;
@@ -807,21 +926,24 @@
   }
 
   void* pointer;
+  TimedResult result;
   if (g_debug->HeaderEnabled()) {
     // Need to guarantee the alignment of the header.
-    Header* header =
-        reinterpret_cast<Header*>(g_dispatch->memalign(MINIMUM_ALIGNMENT_BYTES, real_size));
+    result = TCALL(memalign, MINIMUM_ALIGNMENT_BYTES, real_size);
+    Header* header = reinterpret_cast<Header*>(result.getValue<void*>());
     if (header == nullptr) {
       return nullptr;
     }
     memset(header, 0, g_dispatch->malloc_usable_size(header));
     pointer = InitHeader(header, header, size);
   } else {
-    pointer = g_dispatch->calloc(1, real_size);
+    result = TCALL(calloc, 1, real_size);
+    pointer = result.getValue<void*>();
   }
 
   if (g_debug->config().options() & RECORD_ALLOCS) {
-    g_debug->record->AddEntry(new CallocEntry(pointer, bytes, nmemb));
+    g_debug->record->AddEntry(
+        new CallocEntry(pointer, nmemb, bytes, result.GetStartTimeNS(), result.GetEndTimeNS()));
   }
 
   if (pointer != nullptr && g_debug->TrackPointers()) {
diff --git a/libc/malloc_debug/tests/malloc_debug_config_tests.cpp b/libc/malloc_debug/tests/malloc_debug_config_tests.cpp
index 0a0eaef..bc7af6d 100644
--- a/libc/malloc_debug/tests/malloc_debug_config_tests.cpp
+++ b/libc/malloc_debug/tests/malloc_debug_config_tests.cpp
@@ -215,6 +215,13 @@
   ASSERT_FALSE(config->backtrace_enable_on_signal());
   ASSERT_FALSE(config->backtrace_dump_on_exit());
 
+  ASSERT_TRUE(InitConfig("bt=23")) << getFakeLogPrint();
+  ASSERT_EQ(BACKTRACE | TRACK_ALLOCS, config->options());
+  ASSERT_EQ(23U, config->backtrace_frames());
+  ASSERT_TRUE(config->backtrace_enabled());
+  ASSERT_FALSE(config->backtrace_enable_on_signal());
+  ASSERT_FALSE(config->backtrace_dump_on_exit());
+
   ASSERT_TRUE(InitConfig("backtrace")) << getFakeLogPrint();
   ASSERT_EQ(BACKTRACE | TRACK_ALLOCS, config->options());
   ASSERT_EQ(16U, config->backtrace_frames());
@@ -222,6 +229,13 @@
   ASSERT_FALSE(config->backtrace_enable_on_signal());
   ASSERT_FALSE(config->backtrace_dump_on_exit());
 
+  ASSERT_TRUE(InitConfig("bt")) << getFakeLogPrint();
+  ASSERT_EQ(BACKTRACE | TRACK_ALLOCS, config->options());
+  ASSERT_EQ(16U, config->backtrace_frames());
+  ASSERT_TRUE(config->backtrace_enabled());
+  ASSERT_FALSE(config->backtrace_enable_on_signal());
+  ASSERT_FALSE(config->backtrace_dump_on_exit());
+
   ASSERT_STREQ("", getFakeLogBuf().c_str());
   ASSERT_STREQ("", getFakeLogPrint().c_str());
 }
@@ -234,6 +248,13 @@
   ASSERT_TRUE(config->backtrace_enable_on_signal());
   ASSERT_FALSE(config->backtrace_dump_on_exit());
 
+  ASSERT_TRUE(InitConfig("bt_en_on_sig=64")) << getFakeLogPrint();
+  ASSERT_EQ(BACKTRACE | TRACK_ALLOCS, config->options());
+  ASSERT_EQ(64U, config->backtrace_frames());
+  ASSERT_FALSE(config->backtrace_enabled());
+  ASSERT_TRUE(config->backtrace_enable_on_signal());
+  ASSERT_FALSE(config->backtrace_dump_on_exit());
+
   ASSERT_TRUE(InitConfig("backtrace_enable_on_signal")) << getFakeLogPrint();
   ASSERT_EQ(BACKTRACE | TRACK_ALLOCS, config->options());
   ASSERT_EQ(16U, config->backtrace_frames());
@@ -241,6 +262,13 @@
   ASSERT_TRUE(config->backtrace_enable_on_signal());
   ASSERT_FALSE(config->backtrace_dump_on_exit());
 
+  ASSERT_TRUE(InitConfig("bt_en_on_sig")) << getFakeLogPrint();
+  ASSERT_EQ(BACKTRACE | TRACK_ALLOCS, config->options());
+  ASSERT_EQ(16U, config->backtrace_frames());
+  ASSERT_FALSE(config->backtrace_enabled());
+  ASSERT_TRUE(config->backtrace_enable_on_signal());
+  ASSERT_FALSE(config->backtrace_dump_on_exit());
+
   ASSERT_STREQ("", getFakeLogBuf().c_str());
   ASSERT_STREQ("", getFakeLogPrint().c_str());
 }
@@ -288,6 +316,10 @@
   ASSERT_EQ(0U, config->options());
   ASSERT_TRUE(config->backtrace_dump_on_exit());
 
+  ASSERT_TRUE(InitConfig("bt_dmp_on_ex")) << getFakeLogPrint();
+  ASSERT_EQ(0U, config->options());
+  ASSERT_TRUE(config->backtrace_dump_on_exit());
+
   ASSERT_STREQ("", getFakeLogBuf().c_str());
   ASSERT_STREQ("", getFakeLogPrint().c_str());
 }
@@ -307,10 +339,18 @@
   ASSERT_EQ(0U, config->options());
   ASSERT_EQ("/data/local/tmp/backtrace_heap", config->backtrace_dump_prefix());
 
+  ASSERT_TRUE(InitConfig("bt_dmp_pre")) << getFakeLogPrint();
+  ASSERT_EQ(0U, config->options());
+  ASSERT_EQ("/data/local/tmp/backtrace_heap", config->backtrace_dump_prefix());
+
   ASSERT_TRUE(InitConfig("backtrace_dump_prefix=/fake/location")) << getFakeLogPrint();
   ASSERT_EQ(0U, config->options());
   ASSERT_EQ("/fake/location", config->backtrace_dump_prefix());
 
+  ASSERT_TRUE(InitConfig("bt_dmp_pre=/fake/location")) << getFakeLogPrint();
+  ASSERT_EQ(0U, config->options());
+  ASSERT_EQ("/fake/location", config->backtrace_dump_prefix());
+
   ASSERT_STREQ("", getFakeLogBuf().c_str());
   ASSERT_STREQ("", getFakeLogPrint().c_str());
 }
@@ -319,6 +359,9 @@
   ASSERT_TRUE(InitConfig("backtrace_full")) << getFakeLogPrint();
   ASSERT_EQ(BACKTRACE_FULL, config->options());
 
+  ASSERT_TRUE(InitConfig("bt_full")) << getFakeLogPrint();
+  ASSERT_EQ(BACKTRACE_FULL, config->options());
+
   ASSERT_STREQ("", getFakeLogBuf().c_str());
   ASSERT_STREQ("", getFakeLogPrint().c_str());
 }
@@ -786,6 +829,11 @@
   ASSERT_EQ(37U, config->backtrace_min_size_bytes());
   ASSERT_EQ(37U, config->backtrace_max_size_bytes());
 
+  ASSERT_TRUE(InitConfig("bt_sz=39")) << getFakeLogPrint();
+  ASSERT_EQ(BACKTRACE_SPECIFIC_SIZES, config->options());
+  ASSERT_EQ(39U, config->backtrace_min_size_bytes());
+  ASSERT_EQ(39U, config->backtrace_max_size_bytes());
+
   ASSERT_FALSE(InitConfig("backtrace_size")) << getFakeLogPrint();
   ASSERT_FALSE(InitConfig("backtrace_size=0")) << getFakeLogPrint();
   ASSERT_FALSE(InitConfig("backtrace_size=-1")) << getFakeLogPrint();
@@ -808,6 +856,11 @@
   ASSERT_EQ(9U, config->backtrace_min_size_bytes());
   ASSERT_EQ(SIZE_MAX, config->backtrace_max_size_bytes());
 
+  ASSERT_TRUE(InitConfig("bt_min_sz=11")) << getFakeLogPrint();
+  ASSERT_EQ(BACKTRACE_SPECIFIC_SIZES, config->options());
+  ASSERT_EQ(11U, config->backtrace_min_size_bytes());
+  ASSERT_EQ(SIZE_MAX, config->backtrace_max_size_bytes());
+
   ASSERT_FALSE(InitConfig("backtrace_min_size")) << getFakeLogPrint();
   ASSERT_FALSE(InitConfig("backtrace_min_size=0")) << getFakeLogPrint();
   ASSERT_FALSE(InitConfig("backtrace_min_size=-1")) << getFakeLogPrint();
@@ -830,6 +883,11 @@
   ASSERT_EQ(0U, config->backtrace_min_size_bytes());
   ASSERT_EQ(13U, config->backtrace_max_size_bytes());
 
+  ASSERT_TRUE(InitConfig("bt_max_sz=15")) << getFakeLogPrint();
+  ASSERT_EQ(BACKTRACE_SPECIFIC_SIZES, config->options());
+  ASSERT_EQ(0U, config->backtrace_min_size_bytes());
+  ASSERT_EQ(15U, config->backtrace_max_size_bytes());
+
   ASSERT_FALSE(InitConfig("backtrace_max_size")) << getFakeLogPrint();
   ASSERT_FALSE(InitConfig("backtrace_max_size=0")) << getFakeLogPrint();
   ASSERT_FALSE(InitConfig("backtrace_max_size=-1")) << getFakeLogPrint();
diff --git a/libc/malloc_debug/tests/malloc_debug_unit_tests.cpp b/libc/malloc_debug/tests/malloc_debug_unit_tests.cpp
index c6378f5..bf3ed14 100644
--- a/libc/malloc_debug/tests/malloc_debug_unit_tests.cpp
+++ b/libc/malloc_debug/tests/malloc_debug_unit_tests.cpp
@@ -184,6 +184,23 @@
   return diff;
 }
 
+static void VerifyRecords(std::vector<std::string>& expected, std::string& actual) {
+  size_t offset = 0;
+  for (std::string& str : expected) {
+    ASSERT_STREQ(str.c_str(), actual.substr(offset, str.size()).c_str());
+    if (str.find("thread_done") != std::string::npos) {
+      offset = actual.find_first_of("\n", offset) + 1;
+      continue;
+    }
+    offset += str.size() + 1;
+    uint64_t st = strtoull(&actual[offset], nullptr, 10);
+    offset = actual.find_first_of(" ", offset) + 1;
+    uint64_t et = strtoull(&actual[offset], nullptr, 10);
+    ASSERT_GT(et, st);
+    offset = actual.find_first_of("\n", offset) + 1;
+  }
+}
+
 void VerifyAllocCalls(bool all_options) {
   size_t alloc_size = 1024;
 
@@ -2171,61 +2188,61 @@
 #endif
 
 void VerifyRecordAllocs(const std::string& record_filename) {
-  std::string expected;
+  std::vector<std::string> expected;
 
   void* pointer = debug_malloc(10);
   ASSERT_TRUE(pointer != nullptr);
-  expected += android::base::StringPrintf("%d: malloc %p 10\n", getpid(), pointer);
+  expected.push_back(android::base::StringPrintf("%d: malloc %p 10", getpid(), pointer));
   debug_free(pointer);
-  expected += android::base::StringPrintf("%d: free %p\n", getpid(), pointer);
+  expected.push_back(android::base::StringPrintf("%d: free %p", getpid(), pointer));
 
-  pointer = debug_calloc(1, 20);
+  pointer = debug_calloc(20, 1);
   ASSERT_TRUE(pointer != nullptr);
-  expected += android::base::StringPrintf("%d: calloc %p 20 1\n", getpid(), pointer);
+  expected.push_back(android::base::StringPrintf("%d: calloc %p 20 1", getpid(), pointer));
   debug_free(pointer);
-  expected += android::base::StringPrintf("%d: free %p\n", getpid(), pointer);
+  expected.push_back(android::base::StringPrintf("%d: free %p", getpid(), pointer));
 
   pointer = debug_realloc(nullptr, 30);
   ASSERT_TRUE(pointer != nullptr);
-  expected += android::base::StringPrintf("%d: realloc %p 0x0 30\n", getpid(), pointer);
+  expected.push_back(android::base::StringPrintf("%d: realloc %p 0x0 30", getpid(), pointer));
   void* old_pointer = pointer;
   pointer = debug_realloc(pointer, 2048);
   ASSERT_TRUE(pointer != nullptr);
-  expected += android::base::StringPrintf("%d: realloc %p %p 2048\n", getpid(),
-                                          pointer, old_pointer);
+  expected.push_back(
+      android::base::StringPrintf("%d: realloc %p %p 2048", getpid(), pointer, old_pointer));
   debug_realloc(pointer, 0);
-  expected += android::base::StringPrintf("%d: realloc 0x0 %p 0\n", getpid(), pointer);
+  expected.push_back(android::base::StringPrintf("%d: realloc 0x0 %p 0", getpid(), pointer));
 
   pointer = debug_memalign(16, 40);
   ASSERT_TRUE(pointer != nullptr);
-  expected += android::base::StringPrintf("%d: memalign %p 16 40\n", getpid(), pointer);
+  expected.push_back(android::base::StringPrintf("%d: memalign %p 16 40", getpid(), pointer));
   debug_free(pointer);
-  expected += android::base::StringPrintf("%d: free %p\n", getpid(), pointer);
+  expected.push_back(android::base::StringPrintf("%d: free %p", getpid(), pointer));
 
   pointer = debug_aligned_alloc(32, 64);
   ASSERT_TRUE(pointer != nullptr);
-  expected += android::base::StringPrintf("%d: memalign %p 32 64\n", getpid(), pointer);
+  expected.push_back(android::base::StringPrintf("%d: memalign %p 32 64", getpid(), pointer));
   debug_free(pointer);
-  expected += android::base::StringPrintf("%d: free %p\n", getpid(), pointer);
+  expected.push_back(android::base::StringPrintf("%d: free %p", getpid(), pointer));
 
   ASSERT_EQ(0, debug_posix_memalign(&pointer, 32, 50));
   ASSERT_TRUE(pointer != nullptr);
-  expected += android::base::StringPrintf("%d: memalign %p 32 50\n", getpid(), pointer);
+  expected.push_back(android::base::StringPrintf("%d: memalign %p 32 50", getpid(), pointer));
   debug_free(pointer);
-  expected += android::base::StringPrintf("%d: free %p\n", getpid(), pointer);
+  expected.push_back(android::base::StringPrintf("%d: free %p", getpid(), pointer));
 
 #if defined(HAVE_DEPRECATED_MALLOC_FUNCS)
   pointer = debug_pvalloc(60);
   ASSERT_TRUE(pointer != nullptr);
-  expected += android::base::StringPrintf("%d: memalign %p 4096 4096\n", getpid(), pointer);
+  expected.push_back(android::base::StringPrintf("%d: memalign %p 4096 4096", getpid(), pointer));
   debug_free(pointer);
-  expected += android::base::StringPrintf("%d: free %p\n", getpid(), pointer);
+  expected.push_back(android::base::StringPrintf("%d: free %p", getpid(), pointer));
 
   pointer = debug_valloc(70);
   ASSERT_TRUE(pointer != nullptr);
-  expected += android::base::StringPrintf("%d: memalign %p 4096 70\n", getpid(), pointer);
+  expected.push_back(android::base::StringPrintf("%d: memalign %p 4096 70", getpid(), pointer));
   debug_free(pointer);
-  expected += android::base::StringPrintf("%d: free %p\n", getpid(), pointer);
+  expected.push_back(android::base::StringPrintf("%d: free %p", getpid(), pointer));
 #endif
 
   // Dump all of the data accumulated so far.
@@ -2235,7 +2252,7 @@
   std::string actual;
   ASSERT_TRUE(android::base::ReadFileToString(record_filename, &actual));
 
-  ASSERT_STREQ(expected.c_str(), actual.c_str());
+  VerifyRecords(expected, actual);
 
   ASSERT_STREQ("", getFakeLogBuf().c_str());
   ASSERT_STREQ("", getFakeLogPrint().c_str());
@@ -2256,23 +2273,23 @@
 TEST_F(MallocDebugTest, record_allocs_max) {
   InitRecordAllocs("record_allocs=5");
 
-  std::string expected;
+  std::vector<std::string> expected;
 
   void* pointer = debug_malloc(10);
   ASSERT_TRUE(pointer != nullptr);
-  expected += android::base::StringPrintf("%d: malloc %p 10\n", getpid(), pointer);
+  expected.push_back(android::base::StringPrintf("%d: malloc %p 10", getpid(), pointer));
   debug_free(pointer);
-  expected += android::base::StringPrintf("%d: free %p\n", getpid(), pointer);
+  expected.push_back(android::base::StringPrintf("%d: free %p", getpid(), pointer));
 
   pointer = debug_malloc(20);
   ASSERT_TRUE(pointer != nullptr);
-  expected += android::base::StringPrintf("%d: malloc %p 20\n", getpid(), pointer);
+  expected.push_back(android::base::StringPrintf("%d: malloc %p 20", getpid(), pointer));
   debug_free(pointer);
-  expected += android::base::StringPrintf("%d: free %p\n", getpid(), pointer);
+  expected.push_back(android::base::StringPrintf("%d: free %p", getpid(), pointer));
 
   pointer = debug_malloc(1024);
   ASSERT_TRUE(pointer != nullptr);
-  expected += android::base::StringPrintf("%d: malloc %p 1024\n", getpid(), pointer);
+  expected.push_back(android::base::StringPrintf("%d: malloc %p 1024", getpid(), pointer));
   debug_free(pointer);
 
   // Dump all of the data accumulated so far.
@@ -2282,7 +2299,7 @@
   std::string actual;
   ASSERT_TRUE(android::base::ReadFileToString(record_filename, &actual));
 
-  ASSERT_STREQ(expected.c_str(), actual.c_str());
+  VerifyRecords(expected, actual);
 
   ASSERT_STREQ("", getFakeLogBuf().c_str());
   ASSERT_STREQ(
@@ -2303,9 +2320,10 @@
   });
   thread.join();
 
-  std::string expected = android::base::StringPrintf("%d: malloc %p 100\n", tid, pointer);
-  expected += android::base::StringPrintf("%d: free %p\n", tid, pointer);
-  expected += android::base::StringPrintf("%d: thread_done 0x0\n", tid);
+  std::vector<std::string> expected;
+  expected.push_back(android::base::StringPrintf("%d: malloc %p 100", tid, pointer));
+  expected.push_back(android::base::StringPrintf("%d: free %p", tid, pointer));
+  expected.push_back(android::base::StringPrintf("%d: thread_done 0x0", tid));
 
   // Dump all of the data accumulated so far.
   ASSERT_TRUE(kill(getpid(), SIGRTMAX - 18) == 0);
@@ -2314,7 +2332,7 @@
   std::string actual;
   ASSERT_TRUE(android::base::ReadFileToString(record_filename, &actual));
 
-  ASSERT_STREQ(expected.c_str(), actual.c_str());
+  VerifyRecords(expected, actual);
 
   ASSERT_STREQ("", getFakeLogBuf().c_str());
   ASSERT_STREQ("", getFakeLogPrint().c_str());
@@ -2329,13 +2347,13 @@
 
   ASSERT_EQ(0, symlink("/data/local/tmp/does_not_exist", record_filename.c_str()));
 
-  std::string expected;
+  std::vector<std::string> expected;
 
   void* pointer = debug_malloc(10);
   ASSERT_TRUE(pointer != nullptr);
-  expected += android::base::StringPrintf("%d: malloc %p 10\n", getpid(), pointer);
+  expected.push_back(android::base::StringPrintf("%d: malloc %p 10", getpid(), pointer));
   debug_free(pointer);
-  expected += android::base::StringPrintf("%d: free %p\n", getpid(), pointer);
+  expected.push_back(android::base::StringPrintf("%d: free %p", getpid(), pointer));
 
   // Dump all of the data accumulated so far.
   ASSERT_TRUE(kill(getpid(), SIGRTMAX - 18) == 0);
@@ -2351,7 +2369,8 @@
   ASSERT_TRUE(kill(getpid(), SIGRTMAX - 18) == 0);
 
   ASSERT_TRUE(android::base::ReadFileToString(record_filename, &actual));
-  ASSERT_STREQ(expected.c_str(), actual.c_str());
+
+  VerifyRecords(expected, actual);
 
   ASSERT_STREQ("", getFakeLogBuf().c_str());
   std::string expected_log = android::base::StringPrintf(
@@ -2375,13 +2394,13 @@
 TEST_F(MallocDebugTest, record_allocs_write_entries_does_not_allocate) {
   InitRecordAllocs("record_allocs=5");
 
-  std::string expected;
+  std::vector<std::string> expected;
 
   void* pointer = debug_malloc(10);
   ASSERT_TRUE(pointer != nullptr);
-  expected += android::base::StringPrintf("%d: malloc %p 10\n", getpid(), pointer);
+  expected.push_back(android::base::StringPrintf("%d: malloc %p 10", getpid(), pointer));
   debug_free(pointer);
-  expected += android::base::StringPrintf("%d: free %p\n", getpid(), pointer);
+  expected.push_back(android::base::StringPrintf("%d: free %p", getpid(), pointer));
 
   malloc_disable();
   kill(getpid(), SIGRTMAX - 18);
@@ -2389,7 +2408,8 @@
 
   std::string actual;
   ASSERT_TRUE(android::base::ReadFileToString(record_filename, &actual));
-  ASSERT_STREQ(expected.c_str(), actual.c_str());
+
+  VerifyRecords(expected, actual);
 
   ASSERT_STREQ("", getFakeLogBuf().c_str());
   ASSERT_STREQ("", getFakeLogPrint().c_str());
diff --git a/libc/malloc_hooks/Android.bp b/libc/malloc_hooks/Android.bp
index 01394da..6b4e606 100644
--- a/libc/malloc_hooks/Android.bp
+++ b/libc/malloc_hooks/Android.bp
@@ -59,6 +59,11 @@
     name: "malloc_hooks_system_tests",
     isolated: true,
 
+    // The clang-analyzer-unix.Malloc and other warnings in these
+    // unit tests are either false positive or in
+    // negative tests that can be ignored.
+    tidy: false,
+
     srcs: [
         "tests/malloc_hooks_tests.cpp",
     ],
diff --git a/libc/private/bionic_globals.h b/libc/private/bionic_globals.h
index c7e951d..520e50f 100644
--- a/libc/private/bionic_globals.h
+++ b/libc/private/bionic_globals.h
@@ -111,6 +111,7 @@
   const char* scudo_stack_depot = nullptr;
   const char* scudo_region_info = nullptr;
   const char* scudo_ring_buffer = nullptr;
+  size_t scudo_ring_buffer_size = 0;
 
   HeapTaggingLevel initial_heap_tagging_level = M_HEAP_TAGGING_LEVEL_NONE;
   bool initial_memtag_stack = false;
diff --git a/libfdtrack/fdtrack.cpp b/libfdtrack/fdtrack.cpp
index 2d114f2..b064401 100644
--- a/libfdtrack/fdtrack.cpp
+++ b/libfdtrack/fdtrack.cpp
@@ -71,7 +71,11 @@
 static constexpr size_t kStackDepth = 32;
 
 // Skip any initial frames from libfdtrack.so.
-static std::vector<std::string> kSkipFdtrackLib [[clang::no_destroy]] = {"libfdtrack.so"};
+// Also ignore frames from ART (http://b/236197847) because we'd rather spend
+// our precious few frames on the actual Java calling code rather than the
+// implementation of JNI!
+static std::vector<std::string> kSkipFdtrackLib
+    [[clang::no_destroy]] = {"libfdtrack.so", "libart.so"};
 
 static bool installed = false;
 static std::array<FdEntry, kFdTableSize> stack_traces [[clang::no_destroy]];
diff --git a/libm/Android.bp b/libm/Android.bp
index 2748871..3e271fa 100644
--- a/libm/Android.bp
+++ b/libm/Android.bp
@@ -29,6 +29,7 @@
 
     whole_static_libs: ["libarm-optimized-routines-math"],
 
+    tidy_disabled_srcs: ["upstream-*/**/*.c"],
     srcs: [
         "upstream-freebsd/lib/msun/bsdsrc/b_tgamma.c",
         "upstream-freebsd/lib/msun/src/catrig.c",
diff --git a/linker/linker_debuggerd_android.cpp b/linker/linker_debuggerd_android.cpp
index cba6345..3d64628 100644
--- a/linker/linker_debuggerd_android.cpp
+++ b/linker/linker_debuggerd_android.cpp
@@ -43,6 +43,7 @@
       .scudo_stack_depot = __libc_shared_globals()->scudo_stack_depot,
       .scudo_region_info = __libc_shared_globals()->scudo_region_info,
       .scudo_ring_buffer = __libc_shared_globals()->scudo_ring_buffer,
+      .scudo_ring_buffer_size = __libc_shared_globals()->scudo_ring_buffer_size,
   };
 }
 #endif
diff --git a/linker/linker_phdr.cpp b/linker/linker_phdr.cpp
index 19f0cab..73cfced 100644
--- a/linker/linker_phdr.cpp
+++ b/linker/linker_phdr.cpp
@@ -175,7 +175,8 @@
   if (did_load_) {
     return true;
   }
-  if (ReserveAddressSpace(address_space) && LoadSegments() && FindPhdr() &&
+  bool reserveSuccess = ReserveAddressSpace(address_space);
+  if (reserveSuccess && LoadSegments() && FindPhdr() &&
       FindGnuPropertySection()) {
     did_load_ = true;
 #if defined(__aarch64__)
@@ -186,6 +187,13 @@
     }
 #endif
   }
+  if (reserveSuccess && !did_load_) {
+    if (load_start_ != nullptr && load_size_ != 0) {
+      if (!mapped_by_caller_) {
+        munmap(load_start_, load_size_);
+      }
+    }
+  }
 
   return did_load_;
 }
diff --git a/tests/Android.bp b/tests/Android.bp
index 9c6aec5..8c6057f 100644
--- a/tests/Android.bp
+++ b/tests/Android.bp
@@ -367,6 +367,9 @@
 cc_test_library {
     name: "libBionicStandardTests",
     defaults: ["bionic_tests_defaults"],
+    tidy_disabled_srcs: [
+        "malloc_test.cpp", // timed out with clang-tidy, and too many warnings
+    ],
     srcs: [
         "__aeabi_read_tp_test.cpp",
         "__cxa_atexit_test.cpp",
diff --git a/tests/__cxa_atexit_test.cpp b/tests/__cxa_atexit_test.cpp
index 6a122d1..9f73261 100644
--- a/tests/__cxa_atexit_test.cpp
+++ b/tests/__cxa_atexit_test.cpp
@@ -26,19 +26,30 @@
  * SUCH DAMAGE.
  */
 
-#include <cxxabi.h>
 #include <gtest/gtest.h>
 
+extern "C" {
+int __cxa_atexit(void (*func)(void*), void* arg, void* dso);
+
+// TODO(b/175635923). __cxa_finalize's return type should actually be "void",
+// but it is declared "int" here instead to be compatible with the declaration
+// in an old version of cxxabi.h, which is included indirectly. The declarations
+// of __cxa_atexit and __cxa_finalize are removed from newer versions of
+// cxxabi.h, so once libc++ is updated, this return type should be changed to
+// "void".
+int __cxa_finalize(void* dso);
+}
+
 TEST(__cxa_atexit, simple) {
   int counter = 0;
 
-  __cxxabiv1::__cxa_atexit([](void* arg) { ++*static_cast<int*>(arg); }, &counter, &counter);
+  __cxa_atexit([](void* arg) { ++*static_cast<int*>(arg); }, &counter, &counter);
 
-  __cxxabiv1::__cxa_finalize(&counter);
+  __cxa_finalize(&counter);
   ASSERT_EQ(counter, 1);
 
   // The handler won't be called twice.
-  __cxxabiv1::__cxa_finalize(&counter);
+  __cxa_finalize(&counter);
   ASSERT_EQ(counter, 1);
 }
 
@@ -54,16 +65,16 @@
   };
 
   for (int i = 0; i < 500; ++i) {
-    __cxxabiv1::__cxa_atexit(append_to_actual, new int{i}, &handles[i % 2]);
+    __cxa_atexit(append_to_actual, new int{i}, &handles[i % 2]);
   }
 
-  __cxxabiv1::__cxa_finalize(&handles[0]);
+  __cxa_finalize(&handles[0]);
 
   for (int i = 500; i < 750; ++i) {
-    __cxxabiv1::__cxa_atexit(append_to_actual, new int{i}, &handles[1]);
+    __cxa_atexit(append_to_actual, new int{i}, &handles[1]);
   }
 
-  __cxxabiv1::__cxa_finalize(&handles[1]);
+  __cxa_finalize(&handles[1]);
 
   std::vector<int> expected;
   for (int i = 498; i >= 0; i -= 2) expected.push_back(i);
diff --git a/tests/__cxa_demangle_test.cpp b/tests/__cxa_demangle_test.cpp
index 4628a61..d400619 100644
--- a/tests/__cxa_demangle_test.cpp
+++ b/tests/__cxa_demangle_test.cpp
@@ -29,11 +29,9 @@
 #include <cxxabi.h>
 #include <gtest/gtest.h>
 
-extern "C" char* __cxa_demangle(const char*, char*, size_t*, int*);
-
 TEST(__cxa_demangle, cxa_demangle_fuzz_152588929) {
 #if defined(__aarch64__)
-  char* p = __cxa_demangle("1\006ILeeeEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE", 0, 0, 0);
+  char* p = abi::__cxa_demangle("1\006ILeeeEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE", 0, 0, 0);
   ASSERT_STREQ("\x6<-0x1.cecececececececececececececep+11983", p);
   free(p);
 #endif
@@ -41,7 +39,7 @@
 
 TEST(__cxa_demangle, DISABLED_cxa_demangle_fuzz_167977068) {
 #if defined(__aarch64__)
-  char* p = __cxa_demangle("DTLeeeeeeeeeeeeeeeeeeeeeeeeeEEEEeeEEEE", 0, 0, 0);
+  char* p = abi::__cxa_demangle("DTLeeeeeeeeeeeeeeeeeeeeeeeeeEEEEeeEEEE", 0, 0, 0);
   ASSERT_EQ(nullptr, p) << p;
   free(p);
 #endif
diff --git a/tests/headers/posix/Android.bp b/tests/headers/posix/Android.bp
index 4a20d45..0809cdb 100644
--- a/tests/headers/posix/Android.bp
+++ b/tests/headers/posix/Android.bp
@@ -33,8 +33,5 @@
         darwin: {
             enabled: false,
         },
-        musl: {
-            enabled: false,
-        },
     },
 }
diff --git a/tests/headers/posix/fcntl_h.c b/tests/headers/posix/fcntl_h.c
index a55fe89..418add0 100644
--- a/tests/headers/posix/fcntl_h.c
+++ b/tests/headers/posix/fcntl_h.c
@@ -84,7 +84,11 @@
 
   // POSIX: "The <fcntl.h> header shall define the symbolic constants for
   // file modes for use as values of mode_t as described in <sys/stat.h>."
+  // Musl only defines the file mode bits (S_IFUSR, etc.) and not the file
+  // type bits (S_IFMT, etc.).
+#if !defined(ANDROID_HOST_MUSL)
 #include "sys_stat_h_mode_constants.h"
+#endif
 
   MACRO(AT_FDCWD);
 #if !defined(__BIONIC__) // See comment in "faccessat.cpp".
diff --git a/tests/headers/posix/limits_h.c b/tests/headers/posix/limits_h.c
index 143f717..7e92d81 100644
--- a/tests/headers/posix/limits_h.c
+++ b/tests/headers/posix/limits_h.c
@@ -32,15 +32,17 @@
 
 static void limits_h() {
   // These are only defined if they're constants.
-#if !defined(__BIONIC__) && !defined(__GLIBC__)
+#if !defined(__BIONIC__) && !defined(__GLIBC__) && !defined(ANDROID_HOST_MUSL)
   MACRO(AIO_LISTIO_MAX);
   MACRO(AIO_MAX);
 #endif
-#if !defined(__BIONIC__)
+#if !defined(__BIONIC__) && !defined(ANDROID_HOST_MUSL)
   MACRO(AIO_PRIO_DELTA_MAX);
 #endif
 #if !defined(__BIONIC__) && !defined(__GLIBC__)
   MACRO(ARG_MAX);
+#endif
+#if !defined(__BIONIC__) && !defined(__GLIBC__) && !defined(ANDROID_HOST_MUSL)
   MACRO(ATEXIT_MAX);
   MACRO(CHILD_MAX);
 #endif
@@ -50,14 +52,16 @@
   MACRO(HOST_NAME_MAX);
   MACRO(IOV_MAX);
   MACRO(LOGIN_NAME_MAX);
-#if !defined(__BIONIC__) && !defined(__GLIBC__)
+#if !defined(__BIONIC__) && !defined(__GLIBC__) && !defined(ANDROID_HOST_MUSL)
   MACRO(MQ_OPEN_MAX);
 #endif
 #if !defined(__BIONIC__)
   MACRO(MQ_PRIO_MAX);
 #endif
-#if !defined(__BIONIC__) && !defined(__GLIBC__)
+#if !defined(__BIONIC__) && !defined(__GLIBC__) && !defined(ANDROID_HOST_MUSL)
   MACRO(OPEN_MAX);
+#endif
+#if !defined(__BIONIC__) && !defined(__GLIBC__)
   MACRO(PAGESIZE);
   MACRO(PAGE_SIZE);
 #endif
@@ -66,19 +70,25 @@
 #if !defined(__BIONIC__)
   MACRO(PTHREAD_STACK_MIN);
 #endif
-#if !defined(__BIONIC__) && !defined(__GLIBC__)
+#if !defined(__BIONIC__) && !defined(__GLIBC__) && !defined(ANDROID_HOST_MUSL)
   MACRO(PTHREAD_THREADS_MAX);
 #endif
+#if !defined(ANDROID_HOST_MUSL)
   MACRO(RTSIG_MAX);
+#endif
 #if !defined(__BIONIC__) && !defined(__GLIBC__)
   MACRO(SEM_NSEMS_MAX);
 #endif
   MACRO(SEM_VALUE_MAX);
-#if !defined(__BIONIC__) && !defined(__GLIBC__)
+#if !defined(__BIONIC__) && !defined(__GLIBC__) && !defined(ANDROID_HOST_MUSL)
   MACRO(SIGQUEUE_MAX);
   MACRO(SS_REPL_MAX);
   MACRO(STREAM_MAX);
+#endif
+#if !defined(__BIONIC__) && !defined(__GLIBC__)
   MACRO(SYMLOOP_MAX);
+#endif
+#if !defined(__BIONIC__) && !defined(__GLIBC__) && !defined(ANDROID_HOST_MUSL)
   MACRO(TIMER_MAX);
 #endif
 #if !defined(__BIONIC__)
@@ -90,10 +100,14 @@
 
 #if !defined(__BIONIC__) && !defined(__GLIBC__)
   MACRO(FILESIZEBITS);
+#endif
+#if !defined(__BIONIC__) && !defined(__GLIBC__) && !defined(ANDROID_HOST_MUSL)
   MACRO(LINK_MAX);
 #endif
+#if !defined(ANDROID_HOST_MUSL)
   MACRO(MAX_CANON);
   MACRO(MAX_INPUT);
+#endif
   MACRO(NAME_MAX);
   MACRO(PATH_MAX);
   MACRO(PIPE_BUF);
@@ -104,7 +118,7 @@
   MACRO(POSIX_REC_MIN_XFER_SIZE);
   MACRO(POSIX_REC_XFER_ALIGN);
 #endif
-#if !defined(__BIONIC__) && !defined(__GLIBC__)
+#if !defined(__BIONIC__) && !defined(__GLIBC__) && !defined(ANDROID_HOST_MUSL)
   MACRO(SYMLINK_MAX);
 #endif
 
diff --git a/tests/headers/posix/unistd_h.c b/tests/headers/posix/unistd_h.c
index b713f53..0b2cee5 100644
--- a/tests/headers/posix/unistd_h.c
+++ b/tests/headers/posix/unistd_h.c
@@ -51,8 +51,10 @@
   MACRO(_POSIX_MESSAGE_PASSING);
   MACRO(_POSIX_MONOTONIC_CLOCK);
   MACRO(_POSIX_NO_TRUNC);
+#if !defined(ANDROID_HOST_MUSL)
   MACRO(_POSIX_PRIORITIZED_IO);
   MACRO(_POSIX_PRIORITY_SCHEDULING);
+#endif
   MACRO(_POSIX_RAW_SOCKETS);
   MACRO(_POSIX_READER_WRITER_LOCKS);
   MACRO(_POSIX_REALTIME_SIGNALS);
@@ -63,35 +65,51 @@
   MACRO(_POSIX_SHELL);
   MACRO(_POSIX_SPAWN);
   MACRO(_POSIX_SPIN_LOCKS);
+#if !defined(ANDROID_HOST_MUSL)
   MACRO(_POSIX_SPORADIC_SERVER);
   MACRO(_POSIX_SYNCHRONIZED_IO);
+#endif
   MACRO(_POSIX_THREAD_ATTR_STACKADDR);
   MACRO(_POSIX_THREAD_ATTR_STACKSIZE);
   MACRO(_POSIX_THREAD_CPUTIME);
+#if !defined(ANDROID_HOST_MUSL)
   MACRO(_POSIX_THREAD_PRIO_INHERIT);
   MACRO(_POSIX_THREAD_PRIO_PROTECT);
+#endif
   MACRO(_POSIX_THREAD_PRIORITY_SCHEDULING);
   MACRO(_POSIX_THREAD_PROCESS_SHARED);
+#if !defined(ANDROID_HOST_MUSL)
   MACRO(_POSIX_THREAD_ROBUST_PRIO_INHERIT);
   MACRO(_POSIX_THREAD_ROBUST_PRIO_PROTECT);
+#endif
   MACRO(_POSIX_THREAD_SAFE_FUNCTIONS);
+#if !defined(ANDROID_HOST_MUSL)
   MACRO(_POSIX_THREAD_SPORADIC_SERVER);
+#endif
   MACRO(_POSIX_THREADS);
   MACRO(_POSIX_TIMEOUTS);
   MACRO(_POSIX_TIMERS);
+#if !defined(ANDROID_HOST_MUSL)
   MACRO(_POSIX_TYPED_MEMORY_OBJECTS);
+#endif
   MACRO(_POSIX2_C_BIND);
+#if !defined(ANDROID_HOST_MUSL)
   MACRO(_POSIX2_CHAR_TERM);
   MACRO(_POSIX2_LOCALEDEF);
   MACRO(_POSIX2_SW_DEV);
+#endif
 #if 0 // No libc I can find actually has this.
   MACRO(_POSIX2_UPE);
 #endif
+#if !defined(ANDROID_HOST_MUSL)
   MACRO(_XOPEN_CRYPT);
+#endif
   MACRO(_XOPEN_ENH_I18N);
+#if !defined(ANDROID_HOST_MUSL)
   MACRO(_XOPEN_REALTIME);
   MACRO(_XOPEN_REALTIME_THREADS);
   MACRO(_XOPEN_SHM);
+#endif
   MACRO(_XOPEN_UNIX);
 #if defined(_XOPEN_UUCP)
 #if _XOPEN_UUCP != -1 && _XOPEN_UUCP != 0 && _XOPEN_UUCP != 200809L
diff --git a/tests/malloc_test.cpp b/tests/malloc_test.cpp
index 3cc5bbd..e90a824 100644
--- a/tests/malloc_test.cpp
+++ b/tests/malloc_test.cpp
@@ -661,13 +661,13 @@
 }
 
 TEST(malloc, mallopt_smoke) {
-#if !defined(ANDROID_HOST_MUSL)
+#if defined(__BIONIC__)
   errno = 0;
   ASSERT_EQ(0, mallopt(-1000, 1));
   // mallopt doesn't set errno.
   ASSERT_EQ(0, errno);
 #else
-  GTEST_SKIP() << "musl doesn't have mallopt";
+  GTEST_SKIP() << "bionic-only test";
 #endif
 }
 
diff --git a/tests/time_test.cpp b/tests/time_test.cpp
index 40e5c6d..f0ad937 100644
--- a/tests/time_test.cpp
+++ b/tests/time_test.cpp
@@ -998,6 +998,10 @@
   ASSERT_EQ(-1, ts.tv_sec);
 }
 
+TEST(time, clock_getres_null_resolution) {
+  ASSERT_EQ(0, clock_getres(CLOCK_REALTIME, nullptr));
+}
+
 TEST(time, clock) {
   // clock(3) is hard to test, but a 1s sleep should cost less than 10ms on average.
   static const clock_t N = 5;