Merge "Stop fp unwinding if the pc is 0." into main
diff --git a/benchmarks/Android.bp b/benchmarks/Android.bp
index ffb5921..75e607c 100644
--- a/benchmarks/Android.bp
+++ b/benchmarks/Android.bp
@@ -72,6 +72,7 @@
 
     target: {
         android: {
+            header_libs: ["bionic_libc_platform_headers"],
             static_libs: [
                 "libmeminfo",
                 "libprocinfo",
diff --git a/benchmarks/ScopedDecayTimeRestorer.h b/benchmarks/ScopedDecayTimeRestorer.h
new file mode 100644
index 0000000..5835b43
--- /dev/null
+++ b/benchmarks/ScopedDecayTimeRestorer.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#pragma once
+
+#include <malloc.h>
+
+#if defined(__BIONIC__)
+
+#include "platform/bionic/malloc.h"
+
+class ScopedDecayTimeRestorer {
+ public:
+  ScopedDecayTimeRestorer() {
+    bool value;
+    if (android_mallopt(M_GET_DECAY_TIME_ENABLED, &value, sizeof(value))) {
+      saved_value_ = value ? 1 : 0;
+    }
+  }
+
+  virtual ~ScopedDecayTimeRestorer() { mallopt(M_DECAY_TIME, saved_value_); }
+
+ private:
+  int saved_value_ = 0;
+};
+
+#endif
diff --git a/benchmarks/malloc_benchmark.cpp b/benchmarks/malloc_benchmark.cpp
index 258343f..8f467d2 100644
--- a/benchmarks/malloc_benchmark.cpp
+++ b/benchmarks/malloc_benchmark.cpp
@@ -36,11 +36,14 @@
 #include <vector>
 
 #include <benchmark/benchmark.h>
+#include "ScopedDecayTimeRestorer.h"
 #include "util.h"
 
 #if defined(__BIONIC__)
 
 static void RunMalloptPurge(benchmark::State& state, int purge_value) {
+  ScopedDecayTimeRestorer restorer;
+
   static size_t sizes[] = {8, 16, 32, 64, 128, 1024, 4096, 16384, 65536, 131072, 1048576};
   static int pagesize = getpagesize();
   mallopt(M_DECAY_TIME, 1);
@@ -69,7 +72,6 @@
 
     mallopt(purge_value, 0);
   }
-  mallopt(M_DECAY_TIME, 0);
 }
 
 static void RunThreadsThroughput(benchmark::State& state, size_t size, size_t num_threads) {
diff --git a/benchmarks/malloc_sql_benchmark.cpp b/benchmarks/malloc_sql_benchmark.cpp
index 383325c..d5b17f6 100644
--- a/benchmarks/malloc_sql_benchmark.cpp
+++ b/benchmarks/malloc_sql_benchmark.cpp
@@ -31,6 +31,7 @@
 #include <unistd.h>
 
 #include <benchmark/benchmark.h>
+#include "ScopedDecayTimeRestorer.h"
 #include "util.h"
 
 #if defined(__BIONIC__)
@@ -104,6 +105,8 @@
 #include "malloc_sql.h"
 
 static void BM_malloc_sql_trace_default(benchmark::State& state) {
+  ScopedDecayTimeRestorer restorer;
+
   // The default is expected to be a zero decay time.
   mallopt(M_DECAY_TIME, 0);
 
@@ -115,14 +118,14 @@
 BIONIC_BENCHMARK(BM_malloc_sql_trace_default);
 
 static void BM_malloc_sql_trace_decay1(benchmark::State& state) {
+  ScopedDecayTimeRestorer restorer;
+
   mallopt(M_DECAY_TIME, 1);
 
   for (auto _ : state) {
     BenchmarkMalloc(g_sql_entries, sizeof(g_sql_entries) / sizeof(MallocEntry),
                     kMaxSqlAllocSlots);
   }
-
-  mallopt(M_DECAY_TIME, 0);
 }
 BIONIC_BENCHMARK(BM_malloc_sql_trace_decay1);
 
diff --git a/benchmarks/stdlib_benchmark.cpp b/benchmarks/stdlib_benchmark.cpp
index 14b380a..9be72e7 100644
--- a/benchmarks/stdlib_benchmark.cpp
+++ b/benchmarks/stdlib_benchmark.cpp
@@ -22,6 +22,7 @@
 #include <unistd.h>
 
 #include <benchmark/benchmark.h>
+#include "ScopedDecayTimeRestorer.h"
 #include "util.h"
 
 static void MallocFree(benchmark::State& state) {
@@ -40,6 +41,8 @@
 
 static void BM_stdlib_malloc_free_default(benchmark::State& state) {
 #if defined(__BIONIC__)
+  ScopedDecayTimeRestorer restorer;
+
   // The default is expected to be a zero decay time.
   mallopt(M_DECAY_TIME, 0);
 #endif
@@ -50,11 +53,11 @@
 
 #if defined(__BIONIC__)
 static void BM_stdlib_malloc_free_decay1(benchmark::State& state) {
+  ScopedDecayTimeRestorer restorer;
+
   mallopt(M_DECAY_TIME, 1);
 
   MallocFree(state);
-
-  mallopt(M_DECAY_TIME, 0);
 }
 BIONIC_BENCHMARK_WITH_ARG(BM_stdlib_malloc_free_decay1, "AT_COMMON_SIZES");
 #endif
@@ -75,6 +78,8 @@
 
 static void BM_stdlib_calloc_free_default(benchmark::State& state) {
 #if defined(__BIONIC__)
+  ScopedDecayTimeRestorer restorer;
+
   // The default is expected to be a zero decay time.
   mallopt(M_DECAY_TIME, 0);
 #endif
@@ -113,8 +118,9 @@
 }
 
 void BM_stdlib_malloc_forty_default(benchmark::State& state) {
-
 #if defined(__BIONIC__)
+  ScopedDecayTimeRestorer restorer;
+
   // The default is expected to be a zero decay time.
   mallopt(M_DECAY_TIME, 0);
 #endif
@@ -125,17 +131,19 @@
 
 #if defined(__BIONIC__)
 void BM_stdlib_malloc_forty_decay1(benchmark::State& state) {
+  ScopedDecayTimeRestorer restorer;
+
   mallopt(M_DECAY_TIME, 1);
 
   MallocMultiple(state, state.range(0), 40);
-
-  mallopt(M_DECAY_TIME, 0);
 }
 BIONIC_BENCHMARK_WITH_ARG(BM_stdlib_malloc_forty_decay1, "AT_COMMON_SIZES");
 #endif
 
 void BM_stdlib_malloc_multiple_8192_allocs_default(benchmark::State& state) {
 #if defined(__BIONIC__)
+  ScopedDecayTimeRestorer restorer;
+
   // The default is expected to be a zero decay time.
   mallopt(M_DECAY_TIME, 0);
 #endif
@@ -146,11 +154,11 @@
 
 #if defined(__BIONIC__)
 void BM_stdlib_malloc_multiple_8192_allocs_decay1(benchmark::State& state) {
+  ScopedDecayTimeRestorer restorer;
+
   mallopt(M_DECAY_TIME, 1);
 
   MallocMultiple(state, 8192, state.range(0));
-
-  mallopt(M_DECAY_TIME, 0);
 }
 BIONIC_BENCHMARK_WITH_ARG(BM_stdlib_malloc_multiple_8192_allocs_decay1, "AT_SMALL_SIZES");
 #endif
diff --git a/libc/Android.bp b/libc/Android.bp
index 390cc0c..174ecd9 100644
--- a/libc/Android.bp
+++ b/libc/Android.bp
@@ -910,11 +910,14 @@
                 "arch-riscv64/bionic/syscall.S",
                 "arch-riscv64/bionic/vfork.S",
 
+                // TODO(b/306514350): Remove this and replace with the optimized
+                // version once the bug is resolved.
+                "upstream-freebsd/lib/libc/string/memcmp.c",
+
                 "bionic/strchrnul.cpp",
                 "bionic/strrchr.cpp",
 
                 "arch-riscv64/string/memchr.S",
-                "arch-riscv64/string/memcmp.S",
                 "arch-riscv64/string/memcpy.S",
                 "arch-riscv64/string/memmove.S",
                 "arch-riscv64/string/memset.S",
diff --git a/libc/arch-riscv64/string/memcmp.S b/libc/arch-riscv64/string/memcmp.S
deleted file mode 100644
index 9c1ecdc..0000000
--- a/libc/arch-riscv64/string/memcmp.S
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Copyright (C) 2023 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.
- */
-/*
- * Copyright (c) 2023 SiFive, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. The name of the company may not be used to endorse or promote
- *    products derived from this software without specific prior written
- *    permission.
- *
- * THIS SOFTWARE IS PROVIDED BY SIFIVE INC ``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 SIFIVE INC 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 <private/bionic_asm.h>
-
-#define iResult a0
-
-#define pSrc1 a0
-#define pSrc2 a1
-#define iNum a2
-
-#define iVL a3
-#define iTemp a4
-#define iTemp1 a5
-#define iTemp2 a6
-
-#define ELEM_LMUL_SETTING m8
-#define vData1 v0
-#define vData2 v8
-#define vMask v16
-
-ENTRY(memcmp)
-
-L(loop):
-    vsetvli iVL, iNum, e8, ELEM_LMUL_SETTING, ta, ma
-
-    vle8.v vData1, (pSrc1)
-    vle8.v vData2, (pSrc2)
-
-    vmsne.vv vMask, vData1, vData2
-    sub iNum, iNum, iVL
-    vfirst.m iTemp, vMask
-
-    /* skip the loop if we find the different
-       value between pSrc1 and pSrc2.  */
-    bgez iTemp, L(found)
-
-    add pSrc1, pSrc1, iVL
-    add pSrc2, pSrc2, iVL
-
-    bnez iNum, L(loop)
-
-    li iResult, 0
-    ret
-
-L(found):
-    add pSrc1, pSrc1, iTemp
-    add pSrc2, pSrc2, iTemp
-    lbu iTemp1, 0(pSrc1)
-    lbu iTemp2, 0(pSrc2)
-    sub iResult, iTemp1, iTemp2
-    ret
-
-END(memcmp)
diff --git a/libc/bionic/malloc_common.cpp b/libc/bionic/malloc_common.cpp
index e159fdc..3c4884b 100644
--- a/libc/bionic/malloc_common.cpp
+++ b/libc/bionic/malloc_common.cpp
@@ -110,12 +110,27 @@
   if (param == M_BIONIC_ZERO_INIT) {
     return SetHeapZeroInitialize(value);
   }
+
   // The rest we pass on...
+  int retval;
   auto dispatch_table = GetDispatchTable();
   if (__predict_false(dispatch_table != nullptr)) {
-    return dispatch_table->mallopt(param, value);
+    retval = dispatch_table->mallopt(param, value);
+  } else {
+    retval = Malloc(mallopt)(param, value);
   }
-  return Malloc(mallopt)(param, value);
+
+  // Track the M_DECAY_TIME mallopt calls.
+  if (param == M_DECAY_TIME && retval == 1) {
+    __libc_globals.mutate([value](libc_globals* globals) {
+      if (value == 0) {
+        atomic_store(&globals->decay_time_enabled, false);
+      } else {
+        atomic_store(&globals->decay_time_enabled, true);
+      }
+    });
+  }
+  return retval;
 }
 
 extern "C" void* malloc(size_t bytes) {
@@ -341,6 +356,14 @@
     *reinterpret_cast<bool*>(arg) = atomic_load(&__libc_globals->memtag_stack);
     return true;
   }
+  if (opcode == M_GET_DECAY_TIME_ENABLED) {
+    if (arg == nullptr || arg_size != sizeof(bool)) {
+      errno = EINVAL;
+      return false;
+    }
+    *reinterpret_cast<bool*>(arg) = atomic_load(&__libc_globals->decay_time_enabled);
+    return true;
+  }
   errno = ENOTSUP;
   return false;
 }
diff --git a/libc/bionic/malloc_common_dynamic.cpp b/libc/bionic/malloc_common_dynamic.cpp
index 802a94f..792a114 100644
--- a/libc/bionic/malloc_common_dynamic.cpp
+++ b/libc/bionic/malloc_common_dynamic.cpp
@@ -543,6 +543,14 @@
     *reinterpret_cast<bool*>(arg) = atomic_load(&__libc_globals->memtag_stack);
     return true;
   }
+  if (opcode == M_GET_DECAY_TIME_ENABLED) {
+    if (arg == nullptr || arg_size != sizeof(bool)) {
+      errno = EINVAL;
+      return false;
+    }
+    *reinterpret_cast<bool*>(arg) = atomic_load(&__libc_globals->decay_time_enabled);
+    return true;
+  }
   // Try heapprofd's mallopt, as it handles options not covered here.
   return HeapprofdMallopt(opcode, arg, arg_size);
 }
diff --git a/libc/bionic/system_property_api.cpp b/libc/bionic/system_property_api.cpp
index a641f12..8fdea59 100644
--- a/libc/bionic/system_property_api.cpp
+++ b/libc/bionic/system_property_api.cpp
@@ -29,6 +29,7 @@
 #define _REALLY_INCLUDE_SYS__SYSTEM_PROPERTIES_H_
 #include <sys/_system_properties.h>
 
+#include <async_safe/CHECK.h>
 #include <system_properties/prop_area.h>
 #include <system_properties/system_properties.h>
 
@@ -45,7 +46,7 @@
 
 __BIONIC_WEAK_FOR_NATIVE_BRIDGE
 int __system_properties_init() {
-  return system_properties.Init(PROP_FILENAME) ? 0 : -1;
+  return system_properties.Init(PROP_DIRNAME) ? 0 : -1;
 }
 
 __BIONIC_WEAK_FOR_NATIVE_BRIDGE
@@ -55,8 +56,8 @@
 
 __BIONIC_WEAK_FOR_NATIVE_BRIDGE
 int __system_property_area_init() {
-  bool fsetxattr_failed = false;
-  return system_properties.AreaInit(PROP_FILENAME, &fsetxattr_failed) && !fsetxattr_failed ? 0 : -1;
+  bool fsetxattr_fail = false;
+  return system_properties.AreaInit(PROP_DIRNAME, &fsetxattr_fail) && !fsetxattr_fail ? 0 : -1;
 }
 
 __BIONIC_WEAK_FOR_NATIVE_BRIDGE
@@ -129,3 +130,9 @@
 int __system_property_foreach(void (*propfn)(const prop_info* pi, void* cookie), void* cookie) {
   return system_properties.Foreach(propfn, cookie);
 }
+
+__BIONIC_WEAK_FOR_NATIVE_BRIDGE
+int __system_properties_zygote_reload(void) {
+  CHECK(getpid() == gettid());
+  return system_properties.Reload(false) ? 0 : -1;
+}
diff --git a/libc/include/bits/glibc-syscalls.h b/libc/include/bits/glibc-syscalls.h
index 50817af..ccccf46 100644
--- a/libc/include/bits/glibc-syscalls.h
+++ b/libc/include/bits/glibc-syscalls.h
@@ -222,6 +222,9 @@
 #if defined(__NR_fchmodat)
   #define SYS_fchmodat __NR_fchmodat
 #endif
+#if defined(__NR_fchmodat2)
+  #define SYS_fchmodat2 __NR_fchmodat2
+#endif
 #if defined(__NR_fchown)
   #define SYS_fchown __NR_fchown
 #endif
@@ -573,6 +576,9 @@
 #if defined(__NR_madvise)
   #define SYS_madvise __NR_madvise
 #endif
+#if defined(__NR_map_shadow_stack)
+  #define SYS_map_shadow_stack __NR_map_shadow_stack
+#endif
 #if defined(__NR_mbind)
   #define SYS_mbind __NR_mbind
 #endif
diff --git a/libc/include/dlfcn.h b/libc/include/dlfcn.h
index a8066a9..0425031 100644
--- a/libc/include/dlfcn.h
+++ b/libc/include/dlfcn.h
@@ -46,8 +46,31 @@
 } Dl_info;
 
 void* _Nullable dlopen(const char* _Nullable __filename, int __flag);
+
+/**
+ * [dlclose(3)](http://man7.org/linux/man-pages/man3/dlclose.3.html)
+ * decrements the reference count for the given shared library (and
+ * any libraries brought in by that library's DT_NEEDED entries).
+ *
+ * If a library's reference count hits zero, it may be unloaded.
+ * Code that relies on this is not portable, and may not work on
+ * future versions of Android.
+ *
+ * dlclose() is dangerous because function pointers may or may not
+ * be rendered invalid, global data may or may not be rendered invalid,
+ * and memory may or may not leak. Code with global constructors is
+ * especially problematic. Instead of dlclose, prefer to leave the
+ * library open or, if cleanup is necessary, dlopen() the library in
+ * a child process which can later be killed by the parent or call
+ * exit() itself.
+ *
+ * Returns 0 on success, and returns -1 on failure, in which case
+ * dlerror() can be used to retrieve the specific error.
+ */
 int dlclose(void* _Nonnull __handle);
+
 char* _Nullable dlerror(void);
+
 /* (RTLD_DEFAULT is null for LP64, but -1 for LP32) */
 void* _Nullable dlsym(void* __BIONIC_COMPLICATED_NULLNESS __handle, const char* _Nullable __symbol);
 /* (RTLD_DEFAULT is null for LP64, but -1 for LP32) */
diff --git a/libc/include/sys/_system_properties.h b/libc/include/sys/_system_properties.h
index 943d4c6..30dea89 100644
--- a/libc/include/sys/_system_properties.h
+++ b/libc/include/sys/_system_properties.h
@@ -41,7 +41,7 @@
 __BEGIN_DECLS
 
 #define PROP_SERVICE_NAME "property_service"
-#define PROP_FILENAME "/dev/__properties__"
+#define PROP_DIRNAME "/dev/__properties__"
 
 #define PROP_MSG_SETPROP 1
 #define PROP_MSG_SETPROP2 0x00020001
@@ -129,6 +129,18 @@
  */
 int __system_properties_init(void);
 
+/*
+ * Reloads the system properties from disk.
+ * Not intended for use by any apps except the Zygote. Should only be called from the main thread.
+ *
+ * NOTE: Any pointers received from methods such as __system_property_find should be assumed to be
+ * invalid after this method is called.
+ *
+ * Returns 0 on success, -1 if the system properties failed to re-initialize (same conditions as
+ * __system properties_init)
+ */
+int __system_properties_zygote_reload(void); __INTRODUCED_IN(__ANDROID_API_V__)
+
 /* Deprecated: use __system_property_wait instead. */
 uint32_t __system_property_wait_any(uint32_t __old_serial);
 
diff --git a/libc/include/time.h b/libc/include/time.h
index 31c2050..45c5c34 100644
--- a/libc/include/time.h
+++ b/libc/include/time.h
@@ -115,7 +115,7 @@
  * was interrupted by a signal, `errno` will be `EINTR` and `remainder` will be
  * the amount of time remaining.
  */
-int nanosleep(const struct timespec* _Nonnull __request, struct timespec* _Nullable __remainder);
+int nanosleep(const struct timespec* _Nonnull __duration, struct timespec* _Nullable __remainder);
 
 /**
  * [asctime(3)](http://man7.org/linux/man-pages/man3/asctime.3p.html) formats
@@ -371,7 +371,7 @@
  * If the sleep was interrupted by a signal, the return value will be `EINTR`
  * and `remainder` will be the amount of time remaining.
  */
-int clock_nanosleep(clockid_t __clock, int __flags, const struct timespec* _Nonnull __request, struct timespec* _Nullable __remainder);
+int clock_nanosleep(clockid_t __clock, int __flags, const struct timespec* _Nonnull __duration, struct timespec* _Nullable __remainder);
 
 /**
  * [clock_settime(2)](http://man7.org/linux/man-pages/man2/clock_settime.2.html)
diff --git a/libc/kernel/uapi/asm-arm/asm/unistd-eabi.h b/libc/kernel/uapi/asm-arm/asm/unistd-eabi.h
index b9ea9bc..3490f5d 100644
--- a/libc/kernel/uapi/asm-arm/asm/unistd-eabi.h
+++ b/libc/kernel/uapi/asm-arm/asm/unistd-eabi.h
@@ -422,4 +422,5 @@
 #define __NR_futex_waitv (__NR_SYSCALL_BASE + 449)
 #define __NR_set_mempolicy_home_node (__NR_SYSCALL_BASE + 450)
 #define __NR_cachestat (__NR_SYSCALL_BASE + 451)
+#define __NR_fchmodat2 (__NR_SYSCALL_BASE + 452)
 #endif
diff --git a/libc/kernel/uapi/asm-arm/asm/unistd-oabi.h b/libc/kernel/uapi/asm-arm/asm/unistd-oabi.h
index f7eb7ca..334ef0c 100644
--- a/libc/kernel/uapi/asm-arm/asm/unistd-oabi.h
+++ b/libc/kernel/uapi/asm-arm/asm/unistd-oabi.h
@@ -434,4 +434,5 @@
 #define __NR_futex_waitv (__NR_SYSCALL_BASE + 449)
 #define __NR_set_mempolicy_home_node (__NR_SYSCALL_BASE + 450)
 #define __NR_cachestat (__NR_SYSCALL_BASE + 451)
+#define __NR_fchmodat2 (__NR_SYSCALL_BASE + 452)
 #endif
diff --git a/libc/kernel/uapi/asm-arm64/asm/hwcap.h b/libc/kernel/uapi/asm-arm64/asm/hwcap.h
index 7852454..cd03a32 100644
--- a/libc/kernel/uapi/asm-arm64/asm/hwcap.h
+++ b/libc/kernel/uapi/asm-arm64/asm/hwcap.h
@@ -94,4 +94,5 @@
 #define HWCAP2_SME_B16B16 (1UL << 41)
 #define HWCAP2_SME_F16F16 (1UL << 42)
 #define HWCAP2_MOPS (1UL << 43)
+#define HWCAP2_HBC (1UL << 44)
 #endif
diff --git a/libc/kernel/uapi/asm-generic/siginfo.h b/libc/kernel/uapi/asm-generic/siginfo.h
index 90393ba..a6eef5a 100644
--- a/libc/kernel/uapi/asm-generic/siginfo.h
+++ b/libc/kernel/uapi/asm-generic/siginfo.h
@@ -185,7 +185,8 @@
 #define SEGV_ADIPERR 7
 #define SEGV_MTEAERR 8
 #define SEGV_MTESERR 9
-#define NSIGSEGV 9
+#define SEGV_CPERR 10
+#define NSIGSEGV 10
 #define BUS_ADRALN 1
 #define BUS_ADRERR 2
 #define BUS_OBJERR 3
diff --git a/libc/kernel/uapi/asm-generic/unistd.h b/libc/kernel/uapi/asm-generic/unistd.h
index 24b3222..add612f 100644
--- a/libc/kernel/uapi/asm-generic/unistd.h
+++ b/libc/kernel/uapi/asm-generic/unistd.h
@@ -414,8 +414,9 @@
 #define __NR_futex_waitv 449
 #define __NR_set_mempolicy_home_node 450
 #define __NR_cachestat 451
+#define __NR_fchmodat2 452
 #undef __NR_syscalls
-#define __NR_syscalls 452
+#define __NR_syscalls 453
 #if __BITS_PER_LONG == 64 && !defined(__SYSCALL_COMPAT)
 #define __NR_fcntl __NR3264_fcntl
 #define __NR_statfs __NR3264_statfs
diff --git a/libc/kernel/uapi/asm-riscv/asm/kvm.h b/libc/kernel/uapi/asm-riscv/asm/kvm.h
index c595872..c68cb7b 100644
--- a/libc/kernel/uapi/asm-riscv/asm/kvm.h
+++ b/libc/kernel/uapi/asm-riscv/asm/kvm.h
@@ -46,6 +46,7 @@
   unsigned long marchid;
   unsigned long mimpid;
   unsigned long zicboz_block_size;
+  unsigned long satp_mode;
 };
 struct kvm_riscv_core {
   struct user_regs_struct regs;
@@ -98,6 +99,12 @@
   KVM_RISCV_ISA_EXT_SSAIA,
   KVM_RISCV_ISA_EXT_V,
   KVM_RISCV_ISA_EXT_SVNAPOT,
+  KVM_RISCV_ISA_EXT_ZBA,
+  KVM_RISCV_ISA_EXT_ZBS,
+  KVM_RISCV_ISA_EXT_ZICNTR,
+  KVM_RISCV_ISA_EXT_ZICSR,
+  KVM_RISCV_ISA_EXT_ZIFENCEI,
+  KVM_RISCV_ISA_EXT_ZIHPM,
   KVM_RISCV_ISA_EXT_MAX,
 };
 enum KVM_RISCV_SBI_EXT_ID {
@@ -135,6 +142,12 @@
 #define KVM_REG_RISCV_FP_D (0x06 << KVM_REG_RISCV_TYPE_SHIFT)
 #define KVM_REG_RISCV_FP_D_REG(name) (offsetof(struct __riscv_d_ext_state, name) / sizeof(__u64))
 #define KVM_REG_RISCV_ISA_EXT (0x07 << KVM_REG_RISCV_TYPE_SHIFT)
+#define KVM_REG_RISCV_ISA_SINGLE (0x0 << KVM_REG_RISCV_SUBTYPE_SHIFT)
+#define KVM_REG_RISCV_ISA_MULTI_EN (0x1 << KVM_REG_RISCV_SUBTYPE_SHIFT)
+#define KVM_REG_RISCV_ISA_MULTI_DIS (0x2 << KVM_REG_RISCV_SUBTYPE_SHIFT)
+#define KVM_REG_RISCV_ISA_MULTI_REG(__ext_id) ((__ext_id) / __BITS_PER_LONG)
+#define KVM_REG_RISCV_ISA_MULTI_MASK(__ext_id) (1UL << ((__ext_id) % __BITS_PER_LONG))
+#define KVM_REG_RISCV_ISA_MULTI_REG_LAST KVM_REG_RISCV_ISA_MULTI_REG(KVM_RISCV_ISA_EXT_MAX - 1)
 #define KVM_REG_RISCV_SBI_EXT (0x08 << KVM_REG_RISCV_TYPE_SHIFT)
 #define KVM_REG_RISCV_SBI_SINGLE (0x0 << KVM_REG_RISCV_SUBTYPE_SHIFT)
 #define KVM_REG_RISCV_SBI_MULTI_EN (0x1 << KVM_REG_RISCV_SUBTYPE_SHIFT)
diff --git a/libc/kernel/uapi/asm-riscv/asm/ptrace.h b/libc/kernel/uapi/asm-riscv/asm/ptrace.h
index f491908..dc7f198 100644
--- a/libc/kernel/uapi/asm-riscv/asm/ptrace.h
+++ b/libc/kernel/uapi/asm-riscv/asm/ptrace.h
@@ -20,6 +20,9 @@
 #define _UAPI_ASM_RISCV_PTRACE_H
 #ifndef __ASSEMBLY__
 #include <linux/types.h>
+#define PTRACE_GETFDPIC 33
+#define PTRACE_GETFDPIC_EXEC 0
+#define PTRACE_GETFDPIC_INTERP 1
 struct user_regs_struct {
   unsigned long pc;
   unsigned long ra;
@@ -89,6 +92,14 @@
   unsigned long vlenb;
   void * datap;
 };
+struct __riscv_v_regset_state {
+  unsigned long vstart;
+  unsigned long vl;
+  unsigned long vtype;
+  unsigned long vcsr;
+  unsigned long vlenb;
+  char vreg[];
+};
 #define RISCV_MAX_VLENB (8192)
 #endif
 #endif
diff --git a/libc/kernel/uapi/asm-x86/asm/mman.h b/libc/kernel/uapi/asm-x86/asm/mman.h
index 1061a6f..693ab82 100644
--- a/libc/kernel/uapi/asm-x86/asm/mman.h
+++ b/libc/kernel/uapi/asm-x86/asm/mman.h
@@ -19,5 +19,7 @@
 #ifndef _ASM_X86_MMAN_H
 #define _ASM_X86_MMAN_H
 #define MAP_32BIT 0x40
+#define MAP_ABOVE4G 0x80
+#define SHADOW_STACK_SET_TOKEN (1ULL << 0)
 #include <asm-generic/mman.h>
 #endif
diff --git a/libc/kernel/uapi/asm-x86/asm/prctl.h b/libc/kernel/uapi/asm-x86/asm/prctl.h
index e2fe9df..51b0035 100644
--- a/libc/kernel/uapi/asm-x86/asm/prctl.h
+++ b/libc/kernel/uapi/asm-x86/asm/prctl.h
@@ -38,4 +38,11 @@
 #define ARCH_ENABLE_TAGGED_ADDR 0x4002
 #define ARCH_GET_MAX_TAG_BITS 0x4003
 #define ARCH_FORCE_TAGGED_SVA 0x4004
+#define ARCH_SHSTK_ENABLE 0x5001
+#define ARCH_SHSTK_DISABLE 0x5002
+#define ARCH_SHSTK_LOCK 0x5003
+#define ARCH_SHSTK_UNLOCK 0x5004
+#define ARCH_SHSTK_STATUS 0x5005
+#define ARCH_SHSTK_SHSTK (1ULL << 0)
+#define ARCH_SHSTK_WRSS (1ULL << 1)
 #endif
diff --git a/libc/kernel/uapi/asm-x86/asm/unistd_32.h b/libc/kernel/uapi/asm-x86/asm/unistd_32.h
index f9d8dbd..19155f2 100644
--- a/libc/kernel/uapi/asm-x86/asm/unistd_32.h
+++ b/libc/kernel/uapi/asm-x86/asm/unistd_32.h
@@ -459,4 +459,5 @@
 #define __NR_futex_waitv 449
 #define __NR_set_mempolicy_home_node 450
 #define __NR_cachestat 451
+#define __NR_fchmodat2 452
 #endif
diff --git a/libc/kernel/uapi/asm-x86/asm/unistd_64.h b/libc/kernel/uapi/asm-x86/asm/unistd_64.h
index 34a9ecc..7cb6d0d 100644
--- a/libc/kernel/uapi/asm-x86/asm/unistd_64.h
+++ b/libc/kernel/uapi/asm-x86/asm/unistd_64.h
@@ -381,4 +381,6 @@
 #define __NR_futex_waitv 449
 #define __NR_set_mempolicy_home_node 450
 #define __NR_cachestat 451
+#define __NR_fchmodat2 452
+#define __NR_map_shadow_stack 453
 #endif
diff --git a/libc/kernel/uapi/asm-x86/asm/unistd_x32.h b/libc/kernel/uapi/asm-x86/asm/unistd_x32.h
index de6c857..386e66c 100644
--- a/libc/kernel/uapi/asm-x86/asm/unistd_x32.h
+++ b/libc/kernel/uapi/asm-x86/asm/unistd_x32.h
@@ -334,6 +334,7 @@
 #define __NR_futex_waitv (__X32_SYSCALL_BIT + 449)
 #define __NR_set_mempolicy_home_node (__X32_SYSCALL_BIT + 450)
 #define __NR_cachestat (__X32_SYSCALL_BIT + 451)
+#define __NR_fchmodat2 (__X32_SYSCALL_BIT + 452)
 #define __NR_rt_sigaction (__X32_SYSCALL_BIT + 512)
 #define __NR_rt_sigreturn (__X32_SYSCALL_BIT + 513)
 #define __NR_ioctl (__X32_SYSCALL_BIT + 514)
diff --git a/libc/kernel/uapi/drm/amdgpu_drm.h b/libc/kernel/uapi/drm/amdgpu_drm.h
index d4ae7d4..19d96bc 100644
--- a/libc/kernel/uapi/drm/amdgpu_drm.h
+++ b/libc/kernel/uapi/drm/amdgpu_drm.h
@@ -60,7 +60,8 @@
 #define AMDGPU_GEM_DOMAIN_GDS 0x8
 #define AMDGPU_GEM_DOMAIN_GWS 0x10
 #define AMDGPU_GEM_DOMAIN_OA 0x20
-#define AMDGPU_GEM_DOMAIN_MASK (AMDGPU_GEM_DOMAIN_CPU | AMDGPU_GEM_DOMAIN_GTT | AMDGPU_GEM_DOMAIN_VRAM | AMDGPU_GEM_DOMAIN_GDS | AMDGPU_GEM_DOMAIN_GWS | AMDGPU_GEM_DOMAIN_OA)
+#define AMDGPU_GEM_DOMAIN_DOORBELL 0x40
+#define AMDGPU_GEM_DOMAIN_MASK (AMDGPU_GEM_DOMAIN_CPU | AMDGPU_GEM_DOMAIN_GTT | AMDGPU_GEM_DOMAIN_VRAM | AMDGPU_GEM_DOMAIN_GDS | AMDGPU_GEM_DOMAIN_GWS | AMDGPU_GEM_DOMAIN_OA | AMDGPU_GEM_DOMAIN_DOORBELL)
 #define AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED (1 << 0)
 #define AMDGPU_GEM_CREATE_NO_CPU_ACCESS (1 << 1)
 #define AMDGPU_GEM_CREATE_CPU_GTT_USWC (1 << 2)
diff --git a/libc/kernel/uapi/drm/drm.h b/libc/kernel/uapi/drm/drm.h
index 1954452..8eedf28 100644
--- a/libc/kernel/uapi/drm/drm.h
+++ b/libc/kernel/uapi/drm/drm.h
@@ -430,6 +430,13 @@
   __u32 first_signaled;
   __u32 pad;
 };
+struct drm_syncobj_eventfd {
+  __u32 handle;
+  __u32 flags;
+  __u64 point;
+  __s32 fd;
+  __u32 pad;
+};
 struct drm_syncobj_array {
   __u64 handles;
   __u32 count_handles;
@@ -574,6 +581,7 @@
 #define DRM_IOCTL_SYNCOBJ_TRANSFER DRM_IOWR(0xCC, struct drm_syncobj_transfer)
 #define DRM_IOCTL_SYNCOBJ_TIMELINE_SIGNAL DRM_IOWR(0xCD, struct drm_syncobj_timeline_array)
 #define DRM_IOCTL_MODE_GETFB2 DRM_IOWR(0xCE, struct drm_mode_fb_cmd2)
+#define DRM_IOCTL_SYNCOBJ_EVENTFD DRM_IOWR(0xCF, struct drm_syncobj_eventfd)
 #define DRM_COMMAND_BASE 0x40
 #define DRM_COMMAND_END 0xA0
 struct drm_event {
diff --git a/libc/kernel/uapi/drm/i915_drm.h b/libc/kernel/uapi/drm/i915_drm.h
index ae79ab3..c2b1c18 100644
--- a/libc/kernel/uapi/drm/i915_drm.h
+++ b/libc/kernel/uapi/drm/i915_drm.h
@@ -59,10 +59,10 @@
 #define I915_PMU_SAMPLE_MASK (0xf)
 #define I915_PMU_SAMPLE_INSTANCE_BITS (8)
 #define I915_PMU_CLASS_SHIFT (I915_PMU_SAMPLE_BITS + I915_PMU_SAMPLE_INSTANCE_BITS)
-#define __I915_PMU_ENGINE(class,instance,sample) ((class) << I915_PMU_CLASS_SHIFT | (instance) << I915_PMU_SAMPLE_BITS | (sample))
-#define I915_PMU_ENGINE_BUSY(class,instance) __I915_PMU_ENGINE(class, instance, I915_SAMPLE_BUSY)
-#define I915_PMU_ENGINE_WAIT(class,instance) __I915_PMU_ENGINE(class, instance, I915_SAMPLE_WAIT)
-#define I915_PMU_ENGINE_SEMA(class,instance) __I915_PMU_ENGINE(class, instance, I915_SAMPLE_SEMA)
+#define __I915_PMU_ENGINE(__linux_class,instance,sample) ((__linux_class) << I915_PMU_CLASS_SHIFT | (instance) << I915_PMU_SAMPLE_BITS | (sample))
+#define I915_PMU_ENGINE_BUSY(__linux_class,instance) __I915_PMU_ENGINE(__linux_class, instance, I915_SAMPLE_BUSY)
+#define I915_PMU_ENGINE_WAIT(__linux_class,instance) __I915_PMU_ENGINE(__linux_class, instance, I915_SAMPLE_WAIT)
+#define I915_PMU_ENGINE_SEMA(__linux_class,instance) __I915_PMU_ENGINE(__linux_class, instance, I915_SAMPLE_SEMA)
 #define __I915_PMU_GT_SHIFT (60)
 #define ___I915_PMU_OTHER(gt,x) (((__u64) __I915_PMU_ENGINE(0xff, 0xff, 0xf) + 1 + (x)) | ((__u64) (gt) << __I915_PMU_GT_SHIFT))
 #define __I915_PMU_OTHER(x) ___I915_PMU_OTHER(0, x)
diff --git a/libc/kernel/uapi/drm/ivpu_accel.h b/libc/kernel/uapi/drm/ivpu_accel.h
index e148a5b..5d9edbd 100644
--- a/libc/kernel/uapi/drm/ivpu_accel.h
+++ b/libc/kernel/uapi/drm/ivpu_accel.h
@@ -49,23 +49,28 @@
 #define DRM_IVPU_PARAM_UNIQUE_INFERENCE_ID 10
 #define DRM_IVPU_PARAM_TILE_CONFIG 11
 #define DRM_IVPU_PARAM_SKU 12
+#define DRM_IVPU_PARAM_CAPABILITIES 13
 #define DRM_IVPU_PLATFORM_TYPE_SILICON 0
 #define DRM_IVPU_CONTEXT_PRIORITY_IDLE 0
 #define DRM_IVPU_CONTEXT_PRIORITY_NORMAL 1
 #define DRM_IVPU_CONTEXT_PRIORITY_FOCUS 2
 #define DRM_IVPU_CONTEXT_PRIORITY_REALTIME 3
+#define DRM_IVPU_CAP_METRIC_STREAMER 1
+#define DRM_IVPU_CAP_DMA_MEMORY_RANGE 2
 struct drm_ivpu_param {
   __u32 param;
   __u32 index;
   __u64 value;
 };
-#define DRM_IVPU_BO_HIGH_MEM 0x00000001
+#define DRM_IVPU_BO_SHAVE_MEM 0x00000001
+#define DRM_IVPU_BO_HIGH_MEM DRM_IVPU_BO_SHAVE_MEM
 #define DRM_IVPU_BO_MAPPABLE 0x00000002
+#define DRM_IVPU_BO_DMA_MEM 0x00000004
 #define DRM_IVPU_BO_CACHED 0x00000000
 #define DRM_IVPU_BO_UNCACHED 0x00010000
 #define DRM_IVPU_BO_WC 0x00020000
 #define DRM_IVPU_BO_CACHE_MASK 0x00030000
-#define DRM_IVPU_BO_FLAGS (DRM_IVPU_BO_HIGH_MEM | DRM_IVPU_BO_MAPPABLE | DRM_IVPU_BO_CACHE_MASK)
+#define DRM_IVPU_BO_FLAGS (DRM_IVPU_BO_HIGH_MEM | DRM_IVPU_BO_MAPPABLE | DRM_IVPU_BO_DMA_MEM | DRM_IVPU_BO_CACHE_MASK)
 struct drm_ivpu_bo_create {
   __u64 size;
   __u32 flags;
diff --git a/libc/kernel/uapi/drm/nouveau_drm.h b/libc/kernel/uapi/drm/nouveau_drm.h
index 150f729..2c38494 100644
--- a/libc/kernel/uapi/drm/nouveau_drm.h
+++ b/libc/kernel/uapi/drm/nouveau_drm.h
@@ -23,11 +23,43 @@
 #ifdef __cplusplus
 extern "C" {
 #endif
+#define NOUVEAU_GETPARAM_PCI_VENDOR 3
+#define NOUVEAU_GETPARAM_PCI_DEVICE 4
+#define NOUVEAU_GETPARAM_BUS_TYPE 5
+#define NOUVEAU_GETPARAM_FB_SIZE 8
+#define NOUVEAU_GETPARAM_AGP_SIZE 9
+#define NOUVEAU_GETPARAM_CHIPSET_ID 11
+#define NOUVEAU_GETPARAM_VM_VRAM_BASE 12
+#define NOUVEAU_GETPARAM_GRAPH_UNITS 13
+#define NOUVEAU_GETPARAM_PTIMER_TIME 14
+#define NOUVEAU_GETPARAM_HAS_BO_USAGE 15
+#define NOUVEAU_GETPARAM_HAS_PAGEFLIP 16
+#define NOUVEAU_GETPARAM_EXEC_PUSH_MAX 17
+struct drm_nouveau_getparam {
+  __u64 param;
+  __u64 value;
+};
+struct drm_nouveau_channel_alloc {
+  __u32 fb_ctxdma_handle;
+  __u32 tt_ctxdma_handle;
+  __s32 channel;
+  __u32 pushbuf_domains;
+  __u32 notifier_handle;
+  struct {
+    __u32 handle;
+    __u32 grclass;
+  } subchan[8];
+  __u32 nr_subchan;
+};
+struct drm_nouveau_channel_free {
+  __s32 channel;
+};
 #define NOUVEAU_GEM_DOMAIN_CPU (1 << 0)
 #define NOUVEAU_GEM_DOMAIN_VRAM (1 << 1)
 #define NOUVEAU_GEM_DOMAIN_GART (1 << 2)
 #define NOUVEAU_GEM_DOMAIN_MAPPABLE (1 << 3)
 #define NOUVEAU_GEM_DOMAIN_COHERENT (1 << 4)
+#define NOUVEAU_GEM_DOMAIN_NO_SHARE (1 << 5)
 #define NOUVEAU_GEM_TILE_COMP 0x00030000
 #define NOUVEAU_GEM_TILE_LAYOUT_MASK 0x0000ff00
 #define NOUVEAU_GEM_TILE_16BPP 0x00000001
@@ -81,6 +113,7 @@
   __u32 pad;
   __u64 offset;
   __u64 length;
+#define NOUVEAU_GEM_PUSHBUF_NO_PREFETCH (1 << 23)
 };
 struct drm_nouveau_gem_pushbuf {
   __u32 channel;
@@ -105,6 +138,55 @@
 struct drm_nouveau_gem_cpu_fini {
   __u32 handle;
 };
+struct drm_nouveau_sync {
+  __u32 flags;
+#define DRM_NOUVEAU_SYNC_SYNCOBJ 0x0
+#define DRM_NOUVEAU_SYNC_TIMELINE_SYNCOBJ 0x1
+#define DRM_NOUVEAU_SYNC_TYPE_MASK 0xf
+  __u32 handle;
+  __u64 timeline_value;
+};
+struct drm_nouveau_vm_init {
+  __u64 kernel_managed_addr;
+  __u64 kernel_managed_size;
+};
+struct drm_nouveau_vm_bind_op {
+  __u32 op;
+#define DRM_NOUVEAU_VM_BIND_OP_MAP 0x0
+#define DRM_NOUVEAU_VM_BIND_OP_UNMAP 0x1
+  __u32 flags;
+#define DRM_NOUVEAU_VM_BIND_SPARSE (1 << 8)
+  __u32 handle;
+  __u32 pad;
+  __u64 addr;
+  __u64 bo_offset;
+  __u64 range;
+};
+struct drm_nouveau_vm_bind {
+  __u32 op_count;
+  __u32 flags;
+#define DRM_NOUVEAU_VM_BIND_RUN_ASYNC 0x1
+  __u32 wait_count;
+  __u32 sig_count;
+  __u64 wait_ptr;
+  __u64 sig_ptr;
+  __u64 op_ptr;
+};
+struct drm_nouveau_exec_push {
+  __u64 va;
+  __u32 va_len;
+  __u32 flags;
+#define DRM_NOUVEAU_EXEC_PUSH_NO_PREFETCH 0x1
+};
+struct drm_nouveau_exec {
+  __u32 channel;
+  __u32 push_count;
+  __u32 wait_count;
+  __u32 sig_count;
+  __u64 wait_ptr;
+  __u64 sig_ptr;
+  __u64 push_ptr;
+};
 #define DRM_NOUVEAU_GETPARAM 0x00
 #define DRM_NOUVEAU_SETPARAM 0x01
 #define DRM_NOUVEAU_CHANNEL_ALLOC 0x02
@@ -115,6 +197,9 @@
 #define DRM_NOUVEAU_NVIF 0x07
 #define DRM_NOUVEAU_SVM_INIT 0x08
 #define DRM_NOUVEAU_SVM_BIND 0x09
+#define DRM_NOUVEAU_VM_INIT 0x10
+#define DRM_NOUVEAU_VM_BIND 0x11
+#define DRM_NOUVEAU_EXEC 0x12
 #define DRM_NOUVEAU_GEM_NEW 0x40
 #define DRM_NOUVEAU_GEM_PUSHBUF 0x41
 #define DRM_NOUVEAU_GEM_CPU_PREP 0x42
@@ -147,6 +232,9 @@
 #define NOUVEAU_SVM_BIND_VALID_MASK ((1ULL << NOUVEAU_SVM_BIND_VALID_BITS) - 1)
 #define NOUVEAU_SVM_BIND_COMMAND__MIGRATE 0
 #define NOUVEAU_SVM_BIND_TARGET__GPU_VRAM (1UL << 31)
+#define DRM_IOCTL_NOUVEAU_GETPARAM DRM_IOWR(DRM_COMMAND_BASE + DRM_NOUVEAU_GETPARAM, struct drm_nouveau_getparam)
+#define DRM_IOCTL_NOUVEAU_CHANNEL_ALLOC DRM_IOWR(DRM_COMMAND_BASE + DRM_NOUVEAU_CHANNEL_ALLOC, struct drm_nouveau_channel_alloc)
+#define DRM_IOCTL_NOUVEAU_CHANNEL_FREE DRM_IOW(DRM_COMMAND_BASE + DRM_NOUVEAU_CHANNEL_FREE, struct drm_nouveau_channel_free)
 #define DRM_IOCTL_NOUVEAU_SVM_INIT DRM_IOWR(DRM_COMMAND_BASE + DRM_NOUVEAU_SVM_INIT, struct drm_nouveau_svm_init)
 #define DRM_IOCTL_NOUVEAU_SVM_BIND DRM_IOWR(DRM_COMMAND_BASE + DRM_NOUVEAU_SVM_BIND, struct drm_nouveau_svm_bind)
 #define DRM_IOCTL_NOUVEAU_GEM_NEW DRM_IOWR(DRM_COMMAND_BASE + DRM_NOUVEAU_GEM_NEW, struct drm_nouveau_gem_new)
@@ -154,6 +242,9 @@
 #define DRM_IOCTL_NOUVEAU_GEM_CPU_PREP DRM_IOW(DRM_COMMAND_BASE + DRM_NOUVEAU_GEM_CPU_PREP, struct drm_nouveau_gem_cpu_prep)
 #define DRM_IOCTL_NOUVEAU_GEM_CPU_FINI DRM_IOW(DRM_COMMAND_BASE + DRM_NOUVEAU_GEM_CPU_FINI, struct drm_nouveau_gem_cpu_fini)
 #define DRM_IOCTL_NOUVEAU_GEM_INFO DRM_IOWR(DRM_COMMAND_BASE + DRM_NOUVEAU_GEM_INFO, struct drm_nouveau_gem_info)
+#define DRM_IOCTL_NOUVEAU_VM_INIT DRM_IOWR(DRM_COMMAND_BASE + DRM_NOUVEAU_VM_INIT, struct drm_nouveau_vm_init)
+#define DRM_IOCTL_NOUVEAU_VM_BIND DRM_IOWR(DRM_COMMAND_BASE + DRM_NOUVEAU_VM_BIND, struct drm_nouveau_vm_bind)
+#define DRM_IOCTL_NOUVEAU_EXEC DRM_IOWR(DRM_COMMAND_BASE + DRM_NOUVEAU_EXEC, struct drm_nouveau_exec)
 #ifdef __cplusplus
 }
 #endif
diff --git a/libc/kernel/uapi/drm/virtgpu_drm.h b/libc/kernel/uapi/drm/virtgpu_drm.h
index 342282d..cf73121 100644
--- a/libc/kernel/uapi/drm/virtgpu_drm.h
+++ b/libc/kernel/uapi/drm/virtgpu_drm.h
@@ -42,6 +42,13 @@
   __u32 handle;
   __u32 pad;
 };
+#define VIRTGPU_EXECBUF_SYNCOBJ_RESET 0x01
+#define VIRTGPU_EXECBUF_SYNCOBJ_FLAGS (VIRTGPU_EXECBUF_SYNCOBJ_RESET | 0)
+struct drm_virtgpu_execbuffer_syncobj {
+  __u32 handle;
+  __u32 flags;
+  __u64 point;
+};
 struct drm_virtgpu_execbuffer {
   __u32 flags;
   __u32 size;
@@ -50,7 +57,11 @@
   __u32 num_bo_handles;
   __s32 fence_fd;
   __u32 ring_idx;
-  __u32 pad;
+  __u32 syncobj_stride;
+  __u32 num_in_syncobjs;
+  __u32 num_out_syncobjs;
+  __u64 in_syncobjs;
+  __u64 out_syncobjs;
 };
 #define VIRTGPU_PARAM_3D_FEATURES 1
 #define VIRTGPU_PARAM_CAPSET_QUERY_FIX 2
diff --git a/libc/kernel/uapi/linux/bpf.h b/libc/kernel/uapi/linux/bpf.h
index 48ec710..835be41 100644
--- a/libc/kernel/uapi/linux/bpf.h
+++ b/libc/kernel/uapi/linux/bpf.h
@@ -23,6 +23,7 @@
 #define BPF_JMP32 0x06
 #define BPF_ALU64 0x07
 #define BPF_DW 0x18
+#define BPF_MEMSX 0x80
 #define BPF_ATOMIC 0xc0
 #define BPF_XADD 0xc0
 #define BPF_MOV 0xb0
@@ -253,6 +254,9 @@
   BPF_LSM_CGROUP,
   BPF_STRUCT_OPS,
   BPF_NETFILTER,
+  BPF_TCX_INGRESS,
+  BPF_TCX_EGRESS,
+  BPF_TRACE_UPROBE_MULTI,
   __MAX_BPF_ATTACH_TYPE
 };
 #define MAX_BPF_ATTACH_TYPE __MAX_BPF_ATTACH_TYPE
@@ -268,11 +272,26 @@
   BPF_LINK_TYPE_KPROBE_MULTI = 8,
   BPF_LINK_TYPE_STRUCT_OPS = 9,
   BPF_LINK_TYPE_NETFILTER = 10,
+  BPF_LINK_TYPE_TCX = 11,
+  BPF_LINK_TYPE_UPROBE_MULTI = 12,
   MAX_BPF_LINK_TYPE,
 };
+enum bpf_perf_event_type {
+  BPF_PERF_EVENT_UNSPEC = 0,
+  BPF_PERF_EVENT_UPROBE = 1,
+  BPF_PERF_EVENT_URETPROBE = 2,
+  BPF_PERF_EVENT_KPROBE = 3,
+  BPF_PERF_EVENT_KRETPROBE = 4,
+  BPF_PERF_EVENT_TRACEPOINT = 5,
+  BPF_PERF_EVENT_EVENT = 6,
+};
 #define BPF_F_ALLOW_OVERRIDE (1U << 0)
 #define BPF_F_ALLOW_MULTI (1U << 1)
 #define BPF_F_REPLACE (1U << 2)
+#define BPF_F_BEFORE (1U << 3)
+#define BPF_F_AFTER (1U << 4)
+#define BPF_F_ID (1U << 5)
+#define BPF_F_LINK BPF_F_LINK
 #define BPF_F_STRICT_ALIGNMENT (1U << 0)
 #define BPF_F_ANY_ALIGNMENT (1U << 1)
 #define BPF_F_TEST_RND_HI32 (1U << 2)
@@ -280,7 +299,13 @@
 #define BPF_F_SLEEPABLE (1U << 4)
 #define BPF_F_XDP_HAS_FRAGS (1U << 5)
 #define BPF_F_XDP_DEV_BOUND_ONLY (1U << 6)
-#define BPF_F_KPROBE_MULTI_RETURN (1U << 0)
+enum {
+  BPF_F_KPROBE_MULTI_RETURN = (1U << 0)
+};
+enum {
+  BPF_F_UPROBE_MULTI_RETURN = (1U << 0)
+};
+#define BPF_F_NETFILTER_IP_DEFRAG (1U << 0)
 #define BPF_PSEUDO_MAP_FD 1
 #define BPF_PSEUDO_MAP_IDX 5
 #define BPF_PSEUDO_MAP_VALUE 2
@@ -407,11 +432,19 @@
     __s32 path_fd;
   };
   struct {
-    __u32 target_fd;
+    union {
+      __u32 target_fd;
+      __u32 target_ifindex;
+    };
     __u32 attach_bpf_fd;
     __u32 attach_type;
     __u32 attach_flags;
     __u32 replace_bpf_fd;
+    union {
+      __u32 relative_fd;
+      __u32 relative_id;
+    };
+    __u64 expected_revision;
   };
   struct {
     __u32 prog_fd;
@@ -447,13 +480,23 @@
     __aligned_u64 info;
   } info;
   struct {
-    __u32 target_fd;
+    union {
+      __u32 target_fd;
+      __u32 target_ifindex;
+    };
     __u32 attach_type;
     __u32 query_flags;
     __u32 attach_flags;
     __aligned_u64 prog_ids;
-    __u32 prog_cnt;
+    union {
+      __u32 prog_cnt;
+      __u32 count;
+    };
+    __u32 : 32;
     __aligned_u64 prog_attach_flags;
+    __aligned_u64 link_ids;
+    __aligned_u64 link_attach_flags;
+    __u64 revision;
   } query;
   struct {
     __u64 name;
@@ -515,6 +558,22 @@
         __s32 priority;
         __u32 flags;
       } netfilter;
+      struct {
+        union {
+          __u32 relative_fd;
+          __u32 relative_id;
+        };
+        __u64 expected_revision;
+      } tcx;
+      struct {
+        __aligned_u64 path;
+        __aligned_u64 offsets;
+        __aligned_u64 ref_ctr_offsets;
+        __aligned_u64 cookies;
+        __u32 cnt;
+        __u32 flags;
+        __u32 pid;
+      } uprobe_multi;
     };
   } link_create;
   struct {
@@ -805,6 +864,12 @@
     } ipv6;
   };
 };
+enum tcx_action_base {
+  TCX_NEXT = - 1,
+  TCX_PASS = 0,
+  TCX_DROP = 2,
+  TCX_REDIRECT = 7,
+};
 struct bpf_xdp_sock {
   __u32 queue_id;
 };
@@ -987,6 +1052,40 @@
       __s32 priority;
       __u32 flags;
     } netfilter;
+    struct {
+      __aligned_u64 addrs;
+      __u32 count;
+      __u32 flags;
+    } kprobe_multi;
+    struct {
+      __u32 type;
+      __u32 : 32;
+      union {
+        struct {
+          __aligned_u64 file_name;
+          __u32 name_len;
+          __u32 offset;
+        } uprobe;
+        struct {
+          __aligned_u64 func_name;
+          __u32 name_len;
+          __u32 offset;
+          __u64 addr;
+        } kprobe;
+        struct {
+          __aligned_u64 tp_name;
+          __u32 name_len;
+        } tracepoint;
+        struct {
+          __u64 config;
+          __u32 type;
+        } event;
+      };
+    } perf_event;
+    struct {
+      __u32 ifindex;
+      __u32 attach_type;
+    } tcx;
   };
 } __attribute__((aligned(8)));
 struct bpf_sock_addr {
@@ -1261,6 +1360,7 @@
 struct bpf_list_node {
   __u64 : 64;
   __u64 : 64;
+  __u64 : 64;
 } __attribute__((aligned(8)));
 struct bpf_rb_root {
   __u64 : 64;
@@ -1270,6 +1370,7 @@
   __u64 : 64;
   __u64 : 64;
   __u64 : 64;
+  __u64 : 64;
 } __attribute__((aligned(8)));
 struct bpf_refcount {
   __u32 : 32;
diff --git a/libc/kernel/uapi/linux/btrfs_tree.h b/libc/kernel/uapi/linux/btrfs_tree.h
index 02422c0..5a42297 100644
--- a/libc/kernel/uapi/linux/btrfs_tree.h
+++ b/libc/kernel/uapi/linux/btrfs_tree.h
@@ -74,7 +74,6 @@
 #define BTRFS_METADATA_ITEM_KEY 169
 #define BTRFS_TREE_BLOCK_REF_KEY 176
 #define BTRFS_EXTENT_DATA_REF_KEY 178
-#define BTRFS_EXTENT_REF_V0_KEY 180
 #define BTRFS_SHARED_BLOCK_REF_KEY 182
 #define BTRFS_SHARED_DATA_REF_KEY 184
 #define BTRFS_BLOCK_GROUP_ITEM_KEY 192
diff --git a/libc/kernel/uapi/linux/cn_proc.h b/libc/kernel/uapi/linux/cn_proc.h
index 411b725..5b7ffd9 100644
--- a/libc/kernel/uapi/linux/cn_proc.h
+++ b/libc/kernel/uapi/linux/cn_proc.h
@@ -23,19 +23,26 @@
   PROC_CN_MCAST_LISTEN = 1,
   PROC_CN_MCAST_IGNORE = 2
 };
+#define PROC_EVENT_ALL (PROC_EVENT_FORK | PROC_EVENT_EXEC | PROC_EVENT_UID | PROC_EVENT_GID | PROC_EVENT_SID | PROC_EVENT_PTRACE | PROC_EVENT_COMM | PROC_EVENT_NONZERO_EXIT | PROC_EVENT_COREDUMP | PROC_EVENT_EXIT)
+enum proc_cn_event {
+  PROC_EVENT_NONE = 0x00000000,
+  PROC_EVENT_FORK = 0x00000001,
+  PROC_EVENT_EXEC = 0x00000002,
+  PROC_EVENT_UID = 0x00000004,
+  PROC_EVENT_GID = 0x00000040,
+  PROC_EVENT_SID = 0x00000080,
+  PROC_EVENT_PTRACE = 0x00000100,
+  PROC_EVENT_COMM = 0x00000200,
+  PROC_EVENT_NONZERO_EXIT = 0x20000000,
+  PROC_EVENT_COREDUMP = 0x40000000,
+  PROC_EVENT_EXIT = 0x80000000
+};
+struct proc_input {
+  enum proc_cn_mcast_op mcast_op;
+  enum proc_cn_event event_type;
+};
 struct proc_event {
-  enum what {
-    PROC_EVENT_NONE = 0x00000000,
-    PROC_EVENT_FORK = 0x00000001,
-    PROC_EVENT_EXEC = 0x00000002,
-    PROC_EVENT_UID = 0x00000004,
-    PROC_EVENT_GID = 0x00000040,
-    PROC_EVENT_SID = 0x00000080,
-    PROC_EVENT_PTRACE = 0x00000100,
-    PROC_EVENT_COMM = 0x00000200,
-    PROC_EVENT_COREDUMP = 0x40000000,
-    PROC_EVENT_EXIT = 0x80000000
-  } what;
+  enum proc_cn_event what;
   __u32 cpu;
   __u64 __attribute__((aligned(8))) timestamp_ns;
   union {
diff --git a/libc/kernel/uapi/linux/devlink.h b/libc/kernel/uapi/linux/devlink.h
index b7705c3..d2fd979 100644
--- a/libc/kernel/uapi/linux/devlink.h
+++ b/libc/kernel/uapi/linux/devlink.h
@@ -462,10 +462,14 @@
 enum devlink_port_fn_attr_cap {
   DEVLINK_PORT_FN_ATTR_CAP_ROCE_BIT,
   DEVLINK_PORT_FN_ATTR_CAP_MIGRATABLE_BIT,
+  DEVLINK_PORT_FN_ATTR_CAP_IPSEC_CRYPTO_BIT,
+  DEVLINK_PORT_FN_ATTR_CAP_IPSEC_PACKET_BIT,
   __DEVLINK_PORT_FN_ATTR_CAPS_MAX,
 };
 #define DEVLINK_PORT_FN_CAP_ROCE _BITUL(DEVLINK_PORT_FN_ATTR_CAP_ROCE_BIT)
 #define DEVLINK_PORT_FN_CAP_MIGRATABLE _BITUL(DEVLINK_PORT_FN_ATTR_CAP_MIGRATABLE_BIT)
+#define DEVLINK_PORT_FN_CAP_IPSEC_CRYPTO _BITUL(DEVLINK_PORT_FN_ATTR_CAP_IPSEC_CRYPTO_BIT)
+#define DEVLINK_PORT_FN_CAP_IPSEC_PACKET _BITUL(DEVLINK_PORT_FN_ATTR_CAP_IPSEC_PACKET_BIT)
 enum devlink_port_function_attr {
   DEVLINK_PORT_FUNCTION_ATTR_UNSPEC,
   DEVLINK_PORT_FUNCTION_ATTR_HW_ADDR,
diff --git a/libc/kernel/uapi/linux/dlm_plock.h b/libc/kernel/uapi/linux/dlm_plock.h
index 332397b..80eff88 100644
--- a/libc/kernel/uapi/linux/dlm_plock.h
+++ b/libc/kernel/uapi/linux/dlm_plock.h
@@ -27,6 +27,7 @@
   DLM_PLOCK_OP_LOCK = 1,
   DLM_PLOCK_OP_UNLOCK,
   DLM_PLOCK_OP_GET,
+  DLM_PLOCK_OP_CANCEL,
 };
 #define DLM_PLOCK_FL_CLOSE 1
 struct dlm_plock_info {
diff --git a/libc/kernel/uapi/linux/elf-fdpic.h b/libc/kernel/uapi/linux/elf-fdpic.h
index 4e81292..352089c 100644
--- a/libc/kernel/uapi/linux/elf-fdpic.h
+++ b/libc/kernel/uapi/linux/elf-fdpic.h
@@ -31,4 +31,15 @@
   struct elf32_fdpic_loadseg segs[];
 };
 #define ELF32_FDPIC_LOADMAP_VERSION 0x0000
+struct elf64_fdpic_loadseg {
+  Elf64_Addr addr;
+  Elf64_Addr p_vaddr;
+  Elf64_Word p_memsz;
+};
+struct elf64_fdpic_loadmap {
+  Elf64_Half version;
+  Elf64_Half nsegs;
+  struct elf64_fdpic_loadseg segs[];
+};
+#define ELF64_FDPIC_LOADMAP_VERSION 0x0000
 #endif
diff --git a/libc/kernel/uapi/linux/elf.h b/libc/kernel/uapi/linux/elf.h
index 7eb29df..dc7cfbf 100644
--- a/libc/kernel/uapi/linux/elf.h
+++ b/libc/kernel/uapi/linux/elf.h
@@ -340,6 +340,7 @@
 #define NT_386_TLS 0x200
 #define NT_386_IOPERM 0x201
 #define NT_X86_XSTATE 0x202
+#define NT_X86_SHSTK 0x204
 #define NT_S390_HIGH_GPRS 0x300
 #define NT_S390_TIMER 0x301
 #define NT_S390_TODCMP 0x302
@@ -374,6 +375,8 @@
 #define NT_MIPS_DSP 0x800
 #define NT_MIPS_FP_MODE 0x801
 #define NT_MIPS_MSA 0x802
+#define NT_RISCV_CSR 0x900
+#define NT_RISCV_VECTOR 0x901
 #define NT_LOONGARCH_CPUCFG 0xa00
 #define NT_LOONGARCH_CSR 0xa01
 #define NT_LOONGARCH_LSX 0xa02
diff --git a/libc/kernel/uapi/linux/fsi.h b/libc/kernel/uapi/linux/fsi.h
index b080c21..c6849c1 100644
--- a/libc/kernel/uapi/linux/fsi.h
+++ b/libc/kernel/uapi/linux/fsi.h
@@ -48,5 +48,6 @@
 #define FSI_SCOM_READ _IOWR('s', 0x01, struct scom_access)
 #define FSI_SCOM_WRITE _IOWR('s', 0x02, struct scom_access)
 #define FSI_SCOM_RESET _IOW('s', 0x03, __u32)
+#define FSI_SBEFIFO_CMD_TIMEOUT_SECONDS _IOW('s', 0x01, __u32)
 #define FSI_SBEFIFO_READ_TIMEOUT_SECONDS _IOW('s', 0x00, __u32)
 #endif
diff --git a/libc/kernel/uapi/linux/fuse.h b/libc/kernel/uapi/linux/fuse.h
index ce4424e..029fb14 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 38
+#define FUSE_KERNEL_MINOR_VERSION 39
 #define FUSE_ROOT_ID 1
 struct fuse_attr {
   uint64_t ino;
@@ -40,6 +40,34 @@
   uint32_t blksize;
   uint32_t flags;
 };
+struct fuse_sx_time {
+  int64_t tv_sec;
+  uint32_t tv_nsec;
+  int32_t __reserved;
+};
+struct fuse_statx {
+  uint32_t mask;
+  uint32_t blksize;
+  uint64_t attributes;
+  uint32_t nlink;
+  uint32_t uid;
+  uint32_t gid;
+  uint16_t mode;
+  uint16_t __spare0[1];
+  uint64_t ino;
+  uint64_t size;
+  uint64_t blocks;
+  uint64_t attributes_mask;
+  struct fuse_sx_time atime;
+  struct fuse_sx_time btime;
+  struct fuse_sx_time ctime;
+  struct fuse_sx_time mtime;
+  uint32_t rdev_major;
+  uint32_t rdev_minor;
+  uint32_t dev_major;
+  uint32_t dev_minor;
+  uint64_t __spare2[14];
+};
 struct fuse_kstatfs {
   uint64_t blocks;
   uint64_t bfree;
@@ -113,6 +141,7 @@
 #define FUSE_HAS_INODE_DAX (1ULL << 33)
 #define FUSE_CREATE_SUPP_GROUP (1ULL << 34)
 #define FUSE_HAS_EXPIRE_ONLY (1ULL << 35)
+#define FUSE_DIRECT_IO_RELAX (1ULL << 36)
 #if FUSE_KERNEL_VERSION > 7 || FUSE_KERNEL_VERSION == 7 && FUSE_KERNEL_MINOR_VERSION >= 36
 #define FUSE_PASSTHROUGH (1ULL << 63)
 #else
@@ -196,6 +225,7 @@
   FUSE_REMOVEMAPPING = 49,
   FUSE_SYNCFS = 50,
   FUSE_TMPFILE = 51,
+  FUSE_STATX = 52,
   FUSE_CANONICAL_PATH = 2016,
   CUSE_INIT = 4096,
   CUSE_INIT_BSWAP_RESERVED = 1048576,
@@ -244,6 +274,20 @@
   uint32_t dummy;
   struct fuse_attr attr;
 };
+struct fuse_statx_in {
+  uint32_t getattr_flags;
+  uint32_t reserved;
+  uint64_t fh;
+  uint32_t sx_flags;
+  uint32_t sx_mask;
+};
+struct fuse_statx_out {
+  uint64_t attr_valid;
+  uint32_t attr_valid_nsec;
+  uint32_t flags;
+  uint64_t spare[2];
+  struct fuse_statx stat;
+};
 #define FUSE_COMPAT_MKNOD_IN_SIZE 8
 struct fuse_mknod_in {
   uint32_t mode;
diff --git a/libc/kernel/uapi/linux/gsmmux.h b/libc/kernel/uapi/linux/gsmmux.h
index 8ff29fd..d9392b6 100644
--- a/libc/kernel/uapi/linux/gsmmux.h
+++ b/libc/kernel/uapi/linux/gsmmux.h
@@ -18,9 +18,11 @@
  ****************************************************************************/
 #ifndef _LINUX_GSMMUX_H
 #define _LINUX_GSMMUX_H
+#include <linux/const.h>
 #include <linux/if.h>
 #include <linux/ioctl.h>
 #include <linux/types.h>
+#define GSM_FL_RESTART _BITUL(0)
 struct gsm_config {
   unsigned int adaption;
   unsigned int encapsulation;
@@ -50,7 +52,8 @@
 struct gsm_config_ext {
   __u32 keep_alive;
   __u32 wait_config;
-  __u32 reserved[6];
+  __u32 flags;
+  __u32 reserved[5];
 };
 #define GSMIOC_GETCONF_EXT _IOR('G', 5, struct gsm_config_ext)
 #define GSMIOC_SETCONF_EXT _IOW('G', 6, struct gsm_config_ext)
@@ -61,7 +64,8 @@
   __u32 priority;
   __u32 i;
   __u32 k;
-  __u32 reserved[8];
+  __u32 flags;
+  __u32 reserved[7];
 };
 #define GSMIOC_GETCONF_DLCI _IOWR('G', 7, struct gsm_dlci_config)
 #define GSMIOC_SETCONF_DLCI _IOW('G', 8, struct gsm_dlci_config)
diff --git a/libc/kernel/uapi/linux/gtp.h b/libc/kernel/uapi/linux/gtp.h
index 20bc3d6..ff55116 100644
--- a/libc/kernel/uapi/linux/gtp.h
+++ b/libc/kernel/uapi/linux/gtp.h
@@ -45,5 +45,5 @@
   GTPA_PAD,
   __GTPA_MAX,
 };
-#define GTPA_MAX (__GTPA_MAX + 1)
+#define GTPA_MAX (__GTPA_MAX - 1)
 #endif
diff --git a/libc/kernel/uapi/linux/if_link.h b/libc/kernel/uapi/linux/if_link.h
index e0b504e..6db5334 100644
--- a/libc/kernel/uapi/linux/if_link.h
+++ b/libc/kernel/uapi/linux/if_link.h
@@ -312,6 +312,7 @@
   IFLA_BRPORT_MCAST_N_GROUPS,
   IFLA_BRPORT_MCAST_MAX_GROUPS,
   IFLA_BRPORT_NEIGH_VLAN_SUPPRESS,
+  IFLA_BRPORT_BACKUP_NHID,
   __IFLA_BRPORT_MAX
 };
 #define IFLA_BRPORT_MAX (__IFLA_BRPORT_MAX - 1)
diff --git a/libc/kernel/uapi/linux/if_packet.h b/libc/kernel/uapi/linux/if_packet.h
index cb0c804..1fe897a 100644
--- a/libc/kernel/uapi/linux/if_packet.h
+++ b/libc/kernel/uapi/linux/if_packet.h
@@ -32,10 +32,7 @@
   unsigned short sll_hatype;
   unsigned char sll_pkttype;
   unsigned char sll_halen;
-  union {
-    unsigned char sll_addr[8];
-    __DECLARE_FLEX_ARRAY(unsigned char, sll_addr_flex);
-  };
+  unsigned char sll_addr[8];
 };
 #define PACKET_HOST 0
 #define PACKET_BROADCAST 1
diff --git a/libc/kernel/uapi/linux/if_xdp.h b/libc/kernel/uapi/linux/if_xdp.h
index d2b6bfd..fb9c686 100644
--- a/libc/kernel/uapi/linux/if_xdp.h
+++ b/libc/kernel/uapi/linux/if_xdp.h
@@ -23,6 +23,7 @@
 #define XDP_COPY (1 << 1)
 #define XDP_ZEROCOPY (1 << 2)
 #define XDP_USE_NEED_WAKEUP (1 << 3)
+#define XDP_USE_SG (1 << 4)
 #define XDP_UMEM_UNALIGNED_CHUNK_FLAG (1 << 0)
 struct sockaddr_xdp {
   __u16 sxdp_family;
@@ -82,4 +83,5 @@
   __u32 len;
   __u32 options;
 };
+#define XDP_PKT_CONTD (1 << 0)
 #endif
diff --git a/libc/kernel/uapi/linux/io_uring.h b/libc/kernel/uapi/linux/io_uring.h
index 32c6c7b..30cb7a3 100644
--- a/libc/kernel/uapi/linux/io_uring.h
+++ b/libc/kernel/uapi/linux/io_uring.h
@@ -120,6 +120,7 @@
 #define IORING_SETUP_DEFER_TASKRUN (1U << 13)
 #define IORING_SETUP_NO_MMAP (1U << 14)
 #define IORING_SETUP_REGISTERED_FD_ONLY (1U << 15)
+#define IORING_SETUP_NO_SQARRAY (1U << 16)
 enum io_uring_op {
   IORING_OP_NOP,
   IORING_OP_READV,
@@ -193,6 +194,8 @@
 #define IORING_ASYNC_CANCEL_FD (1U << 1)
 #define IORING_ASYNC_CANCEL_ANY (1U << 2)
 #define IORING_ASYNC_CANCEL_FD_FIXED (1U << 3)
+#define IORING_ASYNC_CANCEL_USERDATA (1U << 4)
+#define IORING_ASYNC_CANCEL_OP (1U << 5)
 #define IORING_RECVSEND_POLL_FIRST (1U << 0)
 #define IORING_RECV_MULTISHOT (1U << 1)
 #define IORING_RECVSEND_FIXED_BUF (1U << 2)
@@ -411,7 +414,9 @@
   __s32 fd;
   __u32 flags;
   struct __kernel_timespec timeout;
-  __u64 pad[4];
+  __u8 opcode;
+  __u8 pad[7];
+  __u64 pad2[3];
 };
 struct io_uring_file_index_range {
   __u32 off;
@@ -424,6 +429,10 @@
   __u32 payloadlen;
   __u32 flags;
 };
+enum {
+  SOCKET_URING_OP_SIOCINQ = 0,
+  SOCKET_URING_OP_SIOCOUTQ,
+};
 #ifdef __cplusplus
 }
 #endif
diff --git a/libc/kernel/uapi/linux/iommufd.h b/libc/kernel/uapi/linux/iommufd.h
index b7f5815..a9e6b52 100644
--- a/libc/kernel/uapi/linux/iommufd.h
+++ b/libc/kernel/uapi/linux/iommufd.h
@@ -32,6 +32,8 @@
   IOMMUFD_CMD_IOAS_UNMAP,
   IOMMUFD_CMD_OPTION,
   IOMMUFD_CMD_VFIO_IOAS,
+  IOMMUFD_CMD_HWPT_ALLOC,
+  IOMMUFD_CMD_GET_HW_INFO,
 };
 struct iommu_destroy {
   __u32 size;
@@ -126,4 +128,33 @@
   __u16 __reserved;
 };
 #define IOMMU_VFIO_IOAS _IO(IOMMUFD_TYPE, IOMMUFD_CMD_VFIO_IOAS)
+struct iommu_hwpt_alloc {
+  __u32 size;
+  __u32 flags;
+  __u32 dev_id;
+  __u32 pt_id;
+  __u32 out_hwpt_id;
+  __u32 __reserved;
+};
+#define IOMMU_HWPT_ALLOC _IO(IOMMUFD_TYPE, IOMMUFD_CMD_HWPT_ALLOC)
+struct iommu_hw_info_vtd {
+  __u32 flags;
+  __u32 __reserved;
+  __aligned_u64 cap_reg;
+  __aligned_u64 ecap_reg;
+};
+enum iommu_hw_info_type {
+  IOMMU_HW_INFO_TYPE_NONE,
+  IOMMU_HW_INFO_TYPE_INTEL_VTD,
+};
+struct iommu_hw_info {
+  __u32 size;
+  __u32 flags;
+  __u32 dev_id;
+  __u32 data_len;
+  __aligned_u64 data_uptr;
+  __u32 out_data_type;
+  __u32 __reserved;
+};
+#define IOMMU_GET_HW_INFO _IO(IOMMUFD_TYPE, IOMMUFD_CMD_GET_HW_INFO)
 #endif
diff --git a/libc/kernel/uapi/linux/ioprio.h b/libc/kernel/uapi/linux/ioprio.h
index 9ae9dae..a766d53 100644
--- a/libc/kernel/uapi/linux/ioprio.h
+++ b/libc/kernel/uapi/linux/ioprio.h
@@ -61,10 +61,10 @@
   IOPRIO_HINT_DEV_DURATION_LIMIT_7 = 7,
 };
 #define IOPRIO_BAD_VALUE(val,max) ((val) < 0 || (val) >= (max))
-static __always_inline __u16 ioprio_value(int __linux_class, int level, int hint) {
-  if(IOPRIO_BAD_VALUE(__linux_class, IOPRIO_NR_CLASSES) || IOPRIO_BAD_VALUE(level, IOPRIO_NR_LEVELS) || IOPRIO_BAD_VALUE(hint, IOPRIO_NR_HINTS)) return IOPRIO_CLASS_INVALID << IOPRIO_CLASS_SHIFT;
-  return(__linux_class << IOPRIO_CLASS_SHIFT) | (hint << IOPRIO_HINT_SHIFT) | level;
+static __always_inline __u16 ioprio_value(int prioclass, int priolevel, int priohint) {
+  if(IOPRIO_BAD_VALUE(prioclass, IOPRIO_NR_CLASSES) || IOPRIO_BAD_VALUE(priolevel, IOPRIO_NR_LEVELS) || IOPRIO_BAD_VALUE(priohint, IOPRIO_NR_HINTS)) return IOPRIO_CLASS_INVALID << IOPRIO_CLASS_SHIFT;
+  return(prioclass << IOPRIO_CLASS_SHIFT) | (priohint << IOPRIO_HINT_SHIFT) | priolevel;
 }
-#define IOPRIO_PRIO_VALUE(__linux_class,level) ioprio_value(__linux_class, level, IOPRIO_HINT_NONE)
-#define IOPRIO_PRIO_VALUE_HINT(__linux_class,level,hint) ioprio_value(__linux_class, level, hint)
+#define IOPRIO_PRIO_VALUE(prioclass,priolevel) ioprio_value(prioclass, priolevel, IOPRIO_HINT_NONE)
+#define IOPRIO_PRIO_VALUE_HINT(prioclass,priolevel,priohint) ioprio_value(prioclass, priolevel, priohint)
 #endif
diff --git a/libc/kernel/uapi/linux/ipv6.h b/libc/kernel/uapi/linux/ipv6.h
index d8fe3cd..da09ced 100644
--- a/libc/kernel/uapi/linux/ipv6.h
+++ b/libc/kernel/uapi/linux/ipv6.h
@@ -151,6 +151,7 @@
   DEVCONF_IOAM6_ID_WIDE,
   DEVCONF_NDISC_EVICT_NOCARRIER,
   DEVCONF_ACCEPT_UNTRACKED_NA,
+  DEVCONF_ACCEPT_RA_MIN_LFT,
   DEVCONF_MAX
 };
 #endif
diff --git a/libc/kernel/uapi/linux/kexec.h b/libc/kernel/uapi/linux/kexec.h
index 438c07b..f63d154 100644
--- a/libc/kernel/uapi/linux/kexec.h
+++ b/libc/kernel/uapi/linux/kexec.h
@@ -21,6 +21,7 @@
 #include <linux/types.h>
 #define KEXEC_ON_CRASH 0x00000001
 #define KEXEC_PRESERVE_CONTEXT 0x00000002
+#define KEXEC_UPDATE_ELFCOREHDR 0x00000004
 #define KEXEC_ARCH_MASK 0xffff0000
 #define KEXEC_FILE_UNLOAD 0x00000001
 #define KEXEC_FILE_ON_CRASH 0x00000002
diff --git a/libc/kernel/uapi/linux/kvm.h b/libc/kernel/uapi/linux/kvm.h
index ebed0e8..3c0ac60 100644
--- a/libc/kernel/uapi/linux/kvm.h
+++ b/libc/kernel/uapi/linux/kvm.h
@@ -1108,9 +1108,12 @@
   __u64 attr;
   __u64 addr;
 };
-#define KVM_DEV_VFIO_GROUP 1
-#define KVM_DEV_VFIO_GROUP_ADD 1
-#define KVM_DEV_VFIO_GROUP_DEL 2
+#define KVM_DEV_VFIO_FILE 1
+#define KVM_DEV_VFIO_FILE_ADD 1
+#define KVM_DEV_VFIO_FILE_DEL 2
+#define KVM_DEV_VFIO_GROUP KVM_DEV_VFIO_FILE
+#define KVM_DEV_VFIO_GROUP_ADD KVM_DEV_VFIO_FILE_ADD
+#define KVM_DEV_VFIO_GROUP_DEL KVM_DEV_VFIO_FILE_DEL
 #define KVM_DEV_VFIO_GROUP_SET_SPAPR_TCE 3
 enum kvm_device_type {
   KVM_DEV_TYPE_FSL_MPIC_20 = 1,
diff --git a/libc/kernel/uapi/linux/mdio.h b/libc/kernel/uapi/linux/mdio.h
index 2305f64..711aaf1 100644
--- a/libc/kernel/uapi/linux/mdio.h
+++ b/libc/kernel/uapi/linux/mdio.h
@@ -81,6 +81,8 @@
 #define MDIO_AN_10BT1_AN_CTRL 526
 #define MDIO_AN_10BT1_AN_STAT 527
 #define MDIO_PMA_PMD_BT1_CTRL 2100
+#define MDIO_PCS_1000BT1_CTRL 2304
+#define MDIO_PCS_1000BT1_STAT 2305
 #define MDIO_PMA_LASI_RXCTRL 0x9000
 #define MDIO_PMA_LASI_TXCTRL 0x9001
 #define MDIO_PMA_LASI_CTRL 0x9002
@@ -273,6 +275,8 @@
 #define MDIO_PMA_10T1L_STAT_LB_ABLE 0x2000
 #define MDIO_PCS_10T1L_CTRL_LB 0x4000
 #define MDIO_PCS_10T1L_CTRL_RESET 0x8000
+#define MDIO_PMA_PMD_BT1_B100_ABLE 0x0001
+#define MDIO_PMA_PMD_BT1_B1000_ABLE 0x0002
 #define MDIO_PMA_PMD_BT1_B10L_ABLE 0x0004
 #define MDIO_AN_T1_ADV_L_PAUSE_CAP ADVERTISE_PAUSE_CAP
 #define MDIO_AN_T1_ADV_L_PAUSE_ASYM ADVERTISE_PAUSE_ASYM
@@ -296,7 +300,14 @@
 #define MDIO_AN_T1_LP_H_10L_TX_HI 0x2000
 #define MDIO_AN_10BT1_AN_CTRL_ADV_EEE_T1L 0x4000
 #define MDIO_AN_10BT1_AN_STAT_LPA_EEE_T1L 0x4000
+#define MDIO_PMA_PMD_BT1_CTRL_STRAP 0x000F
+#define MDIO_PMA_PMD_BT1_CTRL_STRAP_B1000 0x0001
 #define MDIO_PMA_PMD_BT1_CTRL_CFG_MST 0x4000
+#define MDIO_PCS_1000BT1_CTRL_LOW_POWER 0x0800
+#define MDIO_PCS_1000BT1_CTRL_DISABLE_TX 0x4000
+#define MDIO_PCS_1000BT1_CTRL_RESET 0x8000
+#define MDIO_PCS_1000BT1_STAT_LINK 0x0004
+#define MDIO_PCS_1000BT1_STAT_FAULT 0x0080
 #define MDIO_AN_EEE_ADV_100TX 0x0002
 #define MDIO_AN_EEE_ADV_1000T 0x0004
 #define MDIO_EEE_100TX MDIO_AN_EEE_ADV_100TX
diff --git a/libc/kernel/uapi/linux/mount.h b/libc/kernel/uapi/linux/mount.h
index 28f233a..e48555c 100644
--- a/libc/kernel/uapi/linux/mount.h
+++ b/libc/kernel/uapi/linux/mount.h
@@ -79,6 +79,7 @@
   FSCONFIG_SET_FD = 5,
   FSCONFIG_CMD_CREATE = 6,
   FSCONFIG_CMD_RECONFIGURE = 7,
+  FSCONFIG_CMD_CREATE_EXCL = 8,
 };
 #define FSMOUNT_CLOEXEC 0x00000001
 #define MOUNT_ATTR_RDONLY 0x00000001
diff --git a/libc/kernel/uapi/linux/netdev.h b/libc/kernel/uapi/linux/netdev.h
index 53a237b..c55440c 100644
--- a/libc/kernel/uapi/linux/netdev.h
+++ b/libc/kernel/uapi/linux/netdev.h
@@ -34,6 +34,7 @@
   NETDEV_A_DEV_IFINDEX = 1,
   NETDEV_A_DEV_PAD,
   NETDEV_A_DEV_XDP_FEATURES,
+  NETDEV_A_DEV_XDP_ZC_MAX_SEGS,
   __NETDEV_A_DEV_MAX,
   NETDEV_A_DEV_MAX = (__NETDEV_A_DEV_MAX - 1)
 };
diff --git a/libc/kernel/uapi/linux/netfilter_bridge/ebtables.h b/libc/kernel/uapi/linux/netfilter_bridge/ebtables.h
index d87d65e..aab08f9 100644
--- a/libc/kernel/uapi/linux/netfilter_bridge/ebtables.h
+++ b/libc/kernel/uapi/linux/netfilter_bridge/ebtables.h
@@ -63,7 +63,7 @@
   unsigned int counter_offset;
   int policy;
   unsigned int nentries;
-  char data[0] __attribute__((aligned(__alignof__(struct ebt_replace))));
+  char data[] __attribute__((aligned(__alignof__(struct ebt_replace))));
 };
 #define EBT_ENTRY_OR_ENTRIES 0x01
 #define EBT_NOPROTO 0x02
@@ -88,7 +88,7 @@
     struct xt_match * match;
   } u;
   unsigned int match_size;
-  unsigned char data[0] __attribute__((aligned(__alignof__(struct ebt_replace))));
+  unsigned char data[] __attribute__((aligned(__alignof__(struct ebt_replace))));
 };
 struct ebt_entry_watcher {
   union {
@@ -99,7 +99,7 @@
     struct xt_target * watcher;
   } u;
   unsigned int watcher_size;
-  unsigned char data[0] __attribute__((aligned(__alignof__(struct ebt_replace))));
+  unsigned char data[] __attribute__((aligned(__alignof__(struct ebt_replace))));
 };
 struct ebt_entry_target {
   union {
@@ -129,10 +129,11 @@
   unsigned char sourcemsk[ETH_ALEN];
   unsigned char destmac[ETH_ALEN];
   unsigned char destmsk[ETH_ALEN];
-  unsigned int watchers_offset;
+  __struct_group(, offsets,, unsigned int watchers_offset;
   unsigned int target_offset;
   unsigned int next_offset;
-  unsigned char elems[0] __attribute__((aligned(__alignof__(struct ebt_replace))));
+ );
+  unsigned char elems[] __attribute__((aligned(__alignof__(struct ebt_replace))));
 };
 #define EBT_BASE_CTL 128
 #define EBT_SO_SET_ENTRIES (EBT_BASE_CTL)
diff --git a/libc/kernel/uapi/linux/openvswitch.h b/libc/kernel/uapi/linux/openvswitch.h
index 1e2a412..1049c3d 100644
--- a/libc/kernel/uapi/linux/openvswitch.h
+++ b/libc/kernel/uapi/linux/openvswitch.h
@@ -466,6 +466,7 @@
   OVS_ACTION_ATTR_CHECK_PKT_LEN,
   OVS_ACTION_ATTR_ADD_MPLS,
   OVS_ACTION_ATTR_DEC_TTL,
+  OVS_ACTION_ATTR_DROP,
   __OVS_ACTION_ATTR_MAX,
 };
 #define OVS_ACTION_ATTR_MAX (__OVS_ACTION_ATTR_MAX - 1)
diff --git a/libc/kernel/uapi/linux/perf_event.h b/libc/kernel/uapi/linux/perf_event.h
index 9223bd7..5398e26 100644
--- a/libc/kernel/uapi/linux/perf_event.h
+++ b/libc/kernel/uapi/linux/perf_event.h
@@ -470,6 +470,7 @@
 #define PERF_MEM_LVLNUM_L2 0x02
 #define PERF_MEM_LVLNUM_L3 0x03
 #define PERF_MEM_LVLNUM_L4 0x04
+#define PERF_MEM_LVLNUM_UNC 0x08
 #define PERF_MEM_LVLNUM_CXL 0x09
 #define PERF_MEM_LVLNUM_IO 0x0a
 #define PERF_MEM_LVLNUM_ANY_CACHE 0x0b
diff --git a/libc/kernel/uapi/linux/pkt_cls.h b/libc/kernel/uapi/linux/pkt_cls.h
index 0afec0d..ec19c08 100644
--- a/libc/kernel/uapi/linux/pkt_cls.h
+++ b/libc/kernel/uapi/linux/pkt_cls.h
@@ -465,6 +465,8 @@
   TCA_FLOWER_KEY_L2TPV3_SID,
   TCA_FLOWER_L2_MISS,
   TCA_FLOWER_KEY_CFM,
+  TCA_FLOWER_KEY_SPI,
+  TCA_FLOWER_KEY_SPI_MASK,
   __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 6a4b6e1..e15168a 100644
--- a/libc/kernel/uapi/linux/pkt_sched.h
+++ b/libc/kernel/uapi/linux/pkt_sched.h
@@ -443,6 +443,7 @@
   TCA_NETEM_JITTER64,
   TCA_NETEM_SLOT,
   TCA_NETEM_SLOT_DIST,
+  TCA_NETEM_PRNG_SEED,
   __TCA_NETEM_MAX,
 };
 #define TCA_NETEM_MAX (__TCA_NETEM_MAX - 1)
diff --git a/libc/kernel/uapi/linux/psp-dbc.h b/libc/kernel/uapi/linux/psp-dbc.h
new file mode 100644
index 0000000..4b5e3f4
--- /dev/null
+++ b/libc/kernel/uapi/linux/psp-dbc.h
@@ -0,0 +1,57 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ ***   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 __PSP_DBC_USER_H__
+#define __PSP_DBC_USER_H__
+#include <linux/types.h>
+#define DBC_NONCE_SIZE 16
+#define DBC_SIG_SIZE 32
+#define DBC_UID_SIZE 16
+struct dbc_user_nonce {
+  __u32 auth_needed;
+  __u8 nonce[DBC_NONCE_SIZE];
+  __u8 signature[DBC_SIG_SIZE];
+} __attribute__((__packed__));
+struct dbc_user_setuid {
+  __u8 uid[DBC_UID_SIZE];
+  __u8 signature[DBC_SIG_SIZE];
+} __attribute__((__packed__));
+struct dbc_user_param {
+  __u32 msg_index;
+  __u32 param;
+  __u8 signature[DBC_SIG_SIZE];
+} __attribute__((__packed__));
+#define DBC_IOC_TYPE 'D'
+#define DBCIOCNONCE _IOWR(DBC_IOC_TYPE, 0x1, struct dbc_user_nonce)
+#define DBCIOCUID _IOW(DBC_IOC_TYPE, 0x2, struct dbc_user_setuid)
+#define DBCIOCPARAM _IOWR(DBC_IOC_TYPE, 0x3, struct dbc_user_param)
+enum dbc_cmd_msg {
+  PARAM_GET_FMAX_CAP = 0x3,
+  PARAM_SET_FMAX_CAP = 0x4,
+  PARAM_GET_PWR_CAP = 0x5,
+  PARAM_SET_PWR_CAP = 0x6,
+  PARAM_GET_GFX_MODE = 0x7,
+  PARAM_SET_GFX_MODE = 0x8,
+  PARAM_GET_CURR_TEMP = 0x9,
+  PARAM_GET_FMAX_MAX = 0xA,
+  PARAM_GET_FMAX_MIN = 0xB,
+  PARAM_GET_SOC_PWR_MAX = 0xC,
+  PARAM_GET_SOC_PWR_MIN = 0xD,
+  PARAM_GET_SOC_PWR_CUR = 0xE,
+};
+#endif
diff --git a/libc/kernel/uapi/linux/quota.h b/libc/kernel/uapi/linux/quota.h
index 280b396..9f94cb9 100644
--- a/libc/kernel/uapi/linux/quota.h
+++ b/libc/kernel/uapi/linux/quota.h
@@ -42,6 +42,7 @@
 #define QFMT_VFS_V0 2
 #define QFMT_OCFS2 3
 #define QFMT_VFS_V1 4
+#define QFMT_SHMEM 5
 #define QIF_DQBLKSIZE_BITS 10
 #define QIF_DQBLKSIZE (1 << QIF_DQBLKSIZE_BITS)
 enum {
diff --git a/libc/kernel/uapi/linux/rpmsg.h b/libc/kernel/uapi/linux/rpmsg.h
index 9ceccdd..5f6cbd4 100644
--- a/libc/kernel/uapi/linux/rpmsg.h
+++ b/libc/kernel/uapi/linux/rpmsg.h
@@ -30,4 +30,6 @@
 #define RPMSG_DESTROY_EPT_IOCTL _IO(0xb5, 0x2)
 #define RPMSG_CREATE_DEV_IOCTL _IOW(0xb5, 0x3, struct rpmsg_endpoint_info)
 #define RPMSG_RELEASE_DEV_IOCTL _IOW(0xb5, 0x4, struct rpmsg_endpoint_info)
+#define RPMSG_GET_OUTGOING_FLOWCONTROL _IOR(0xb5, 0x5, int)
+#define RPMSG_SET_INCOMING_FLOWCONTROL _IOR(0xb5, 0x6, int)
 #endif
diff --git a/libc/kernel/uapi/linux/seccomp.h b/libc/kernel/uapi/linux/seccomp.h
index cc506ae..293bced 100644
--- a/libc/kernel/uapi/linux/seccomp.h
+++ b/libc/kernel/uapi/linux/seccomp.h
@@ -69,6 +69,7 @@
   __s32 error;
   __u32 flags;
 };
+#define SECCOMP_USER_NOTIF_FD_SYNC_WAKE_UP (1UL << 0)
 #define SECCOMP_ADDFD_FLAG_SETFD (1UL << 0)
 #define SECCOMP_ADDFD_FLAG_SEND (1UL << 1)
 struct seccomp_notif_addfd {
@@ -87,4 +88,5 @@
 #define SECCOMP_IOCTL_NOTIF_SEND SECCOMP_IOWR(1, struct seccomp_notif_resp)
 #define SECCOMP_IOCTL_NOTIF_ID_VALID SECCOMP_IOW(2, __u64)
 #define SECCOMP_IOCTL_NOTIF_ADDFD SECCOMP_IOW(3, struct seccomp_notif_addfd)
+#define SECCOMP_IOCTL_NOTIF_SET_FLAGS SECCOMP_IOW(4, __u64)
 #endif
diff --git a/libc/kernel/uapi/linux/sed-opal.h b/libc/kernel/uapi/linux/sed-opal.h
index fa1d7ed..5ec2ec6 100644
--- a/libc/kernel/uapi/linux/sed-opal.h
+++ b/libc/kernel/uapi/linux/sed-opal.h
@@ -49,12 +49,20 @@
 enum opal_lock_flags {
   OPAL_SAVE_FOR_LOCK = 0x01,
 };
+enum opal_key_type {
+  OPAL_INCLUDED = 0,
+  OPAL_KEYRING,
+};
 struct opal_key {
   __u8 lr;
   __u8 key_len;
-  __u8 __align[6];
+  __u8 key_type;
+  __u8 __align[5];
   __u8 key[OPAL_KEY_MAX];
 };
+enum opal_revert_lsp_opts {
+  OPAL_PRESERVE = 0x01,
+};
 struct opal_lr_act {
   struct opal_key key;
   __u32 sum;
@@ -143,6 +151,15 @@
   __u64 lowest_aligned_lba;
   __u8 __align[3];
 };
+struct opal_discovery {
+  __u64 data;
+  __u64 size;
+};
+struct opal_revert_lsp {
+  struct opal_key key;
+  __u32 options;
+  __u32 __pad;
+};
 #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)
@@ -162,4 +179,6 @@
 #define IOC_OPAL_GET_STATUS _IOR('p', 236, struct opal_status)
 #define IOC_OPAL_GET_LR_STATUS _IOW('p', 237, struct opal_lr_status)
 #define IOC_OPAL_GET_GEOMETRY _IOR('p', 238, struct opal_geometry)
+#define IOC_OPAL_DISCOVERY _IOW('p', 239, struct opal_discovery)
+#define IOC_OPAL_REVERT_LSP _IOW('p', 240, struct opal_revert_lsp)
 #endif
diff --git a/libc/kernel/uapi/linux/serial_core.h b/libc/kernel/uapi/linux/serial_core.h
index ecd395c..734b508 100644
--- a/libc/kernel/uapi/linux/serial_core.h
+++ b/libc/kernel/uapi/linux/serial_core.h
@@ -59,32 +59,21 @@
 #define PORT_SCI 52
 #define PORT_SCIF 53
 #define PORT_IRDA 54
-#define PORT_S3C2410 55
 #define PORT_IP22ZILOG 56
-#define PORT_LH7A40X 57
 #define PORT_CPM 58
 #define PORT_MPC52xx 59
 #define PORT_ICOM 60
-#define PORT_S3C2440 61
 #define PORT_IMX 62
-#define PORT_MPSC 63
 #define PORT_TXX9 64
-#define PORT_S3C2400 67
-#define PORT_M32R_SIO 68
 #define PORT_JSM 69
 #define PORT_SUNHV 72
-#define PORT_S3C2412 73
 #define PORT_UARTLITE 74
-#define PORT_BFIN 75
+#define PORT_BCM7271 76
 #define PORT_SB1250_DUART 77
 #define PORT_MCF 78
-#define PORT_BFIN_SPORT 79
-#define PORT_MN10300 80
-#define PORT_MN10300_CTS 81
 #define PORT_SC26XX 82
 #define PORT_SCIFA 83
 #define PORT_S3C6400 84
-#define PORT_NWPSERIAL 85
 #define PORT_MAX3100 86
 #define PORT_TIMBUART 87
 #define PORT_MSM 88
@@ -105,13 +94,11 @@
 #define PORT_LPUART 103
 #define PORT_HSCIF 104
 #define PORT_ASC 105
-#define PORT_TILEGX 106
 #define PORT_MEN_Z135 107
 #define PORT_SC16IS7XX 108
 #define PORT_MESON 109
 #define PORT_DIGICOLOR 110
 #define PORT_SPRD 111
-#define PORT_CRIS 112
 #define PORT_STM32 113
 #define PORT_MVEBU 114
 #define PORT_PIC32 115
diff --git a/libc/kernel/uapi/linux/smc.h b/libc/kernel/uapi/linux/smc.h
index 200c9b6..679dea0 100644
--- a/libc/kernel/uapi/linux/smc.h
+++ b/libc/kernel/uapi/linux/smc.h
@@ -97,6 +97,8 @@
 enum {
   SMC_NLA_LGR_R_V2_UNSPEC,
   SMC_NLA_LGR_R_V2_DIRECT,
+  SMC_NLA_LGR_R_V2_MAX_CONNS,
+  SMC_NLA_LGR_R_V2_MAX_LINKS,
   __SMC_NLA_LGR_R_V2_MAX,
   SMC_NLA_LGR_R_V2_MAX = __SMC_NLA_LGR_R_V2_MAX - 1
 };
diff --git a/libc/kernel/uapi/linux/stddef.h b/libc/kernel/uapi/linux/stddef.h
index 6bc6925..98968a2 100644
--- a/libc/kernel/uapi/linux/stddef.h
+++ b/libc/kernel/uapi/linux/stddef.h
@@ -23,5 +23,12 @@
 #define __always_inline inline
 #endif
 #define __struct_group(TAG,NAME,ATTRS,MEMBERS...) union { struct { MEMBERS } ATTRS; struct TAG { MEMBERS } ATTRS NAME; }
+#ifdef __cplusplus
+#define __DECLARE_FLEX_ARRAY(T,member) T member[0]
+#else
 #define __DECLARE_FLEX_ARRAY(TYPE,NAME) struct { struct { } __empty_ ##NAME; TYPE NAME[]; }
 #endif
+#ifndef __counted_by
+#define __counted_by(m)
+#endif
+#endif
diff --git a/libc/kernel/uapi/linux/ublk_cmd.h b/libc/kernel/uapi/linux/ublk_cmd.h
index 975015f..8c8fe53 100644
--- a/libc/kernel/uapi/linux/ublk_cmd.h
+++ b/libc/kernel/uapi/linux/ublk_cmd.h
@@ -75,6 +75,7 @@
 #define UBLK_F_UNPRIVILEGED_DEV (1UL << 5)
 #define UBLK_F_CMD_IOCTL_ENCODE (1UL << 6)
 #define UBLK_F_USER_COPY (1UL << 7)
+#define UBLK_F_ZONED (1ULL << 8)
 #define UBLK_S_DEV_DEAD 0
 #define UBLK_S_DEV_LIVE 1
 #define UBLK_S_DEV_QUIESCED 2
@@ -110,6 +111,13 @@
 #define UBLK_IO_OP_DISCARD 3
 #define UBLK_IO_OP_WRITE_SAME 4
 #define UBLK_IO_OP_WRITE_ZEROES 5
+#define UBLK_IO_OP_ZONE_OPEN 10
+#define UBLK_IO_OP_ZONE_CLOSE 11
+#define UBLK_IO_OP_ZONE_FINISH 12
+#define UBLK_IO_OP_ZONE_APPEND 13
+#define UBLK_IO_OP_ZONE_RESET_ALL 14
+#define UBLK_IO_OP_ZONE_RESET 15
+#define UBLK_IO_OP_REPORT_ZONES 18
 #define UBLK_IO_F_FAILFAST_DEV (1U << 8)
 #define UBLK_IO_F_FAILFAST_TRANSPORT (1U << 9)
 #define UBLK_IO_F_FAILFAST_DRIVER (1U << 10)
@@ -119,7 +127,10 @@
 #define UBLK_IO_F_SWAP (1U << 16)
 struct ublksrv_io_desc {
   __u32 op_flags;
-  __u32 nr_sectors;
+  union {
+    __u32 nr_sectors;
+    __u32 nr_zones;
+  };
   __u64 start_sector;
   __u64 addr;
 };
@@ -127,7 +138,10 @@
   __u16 q_id;
   __u16 tag;
   __s32 result;
-  __u64 addr;
+  union {
+    __u64 addr;
+    __u64 zone_append_lba;
+  };
 };
 struct ublk_param_basic {
 #define UBLK_ATTR_READ_ONLY (1 << 0)
@@ -158,14 +172,22 @@
   __u32 disk_major;
   __u32 disk_minor;
 };
+struct ublk_param_zoned {
+  __u32 max_open_zones;
+  __u32 max_active_zones;
+  __u32 max_zone_append_sectors;
+  __u8 reserved[20];
+};
 struct ublk_params {
   __u32 len;
 #define UBLK_PARAM_TYPE_BASIC (1 << 0)
 #define UBLK_PARAM_TYPE_DISCARD (1 << 1)
 #define UBLK_PARAM_TYPE_DEVT (1 << 2)
+#define UBLK_PARAM_TYPE_ZONED (1 << 3)
   __u32 types;
   struct ublk_param_basic basic;
   struct ublk_param_discard discard;
   struct ublk_param_devt devt;
+  struct ublk_param_zoned zoned;
 };
 #endif
diff --git a/libc/kernel/uapi/linux/userfaultfd.h b/libc/kernel/uapi/linux/userfaultfd.h
index 816198f..6037746 100644
--- a/libc/kernel/uapi/linux/userfaultfd.h
+++ b/libc/kernel/uapi/linux/userfaultfd.h
@@ -23,10 +23,10 @@
 #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 | UFFD_FEATURE_WP_UNPOPULATED)
+#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 | UFFD_FEATURE_WP_UNPOPULATED | UFFD_FEATURE_POISON)
 #define UFFD_API_IOCTLS ((__u64) 1 << _UFFDIO_REGISTER | (__u64) 1 << _UFFDIO_UNREGISTER | (__u64) 1 << _UFFDIO_API)
-#define UFFD_API_RANGE_IOCTLS ((__u64) 1 << _UFFDIO_WAKE | (__u64) 1 << _UFFDIO_COPY | (__u64) 1 << _UFFDIO_ZEROPAGE | (__u64) 1 << _UFFDIO_WRITEPROTECT | (__u64) 1 << _UFFDIO_CONTINUE)
-#define UFFD_API_RANGE_IOCTLS_BASIC ((__u64) 1 << _UFFDIO_WAKE | (__u64) 1 << _UFFDIO_COPY | (__u64) 1 << _UFFDIO_CONTINUE | (__u64) 1 << _UFFDIO_WRITEPROTECT)
+#define UFFD_API_RANGE_IOCTLS ((__u64) 1 << _UFFDIO_WAKE | (__u64) 1 << _UFFDIO_COPY | (__u64) 1 << _UFFDIO_ZEROPAGE | (__u64) 1 << _UFFDIO_WRITEPROTECT | (__u64) 1 << _UFFDIO_CONTINUE | (__u64) 1 << _UFFDIO_POISON)
+#define UFFD_API_RANGE_IOCTLS_BASIC ((__u64) 1 << _UFFDIO_WAKE | (__u64) 1 << _UFFDIO_COPY | (__u64) 1 << _UFFDIO_WRITEPROTECT | (__u64) 1 << _UFFDIO_CONTINUE | (__u64) 1 << _UFFDIO_POISON)
 #define _UFFDIO_REGISTER (0x00)
 #define _UFFDIO_UNREGISTER (0x01)
 #define _UFFDIO_WAKE (0x02)
@@ -34,6 +34,7 @@
 #define _UFFDIO_ZEROPAGE (0x04)
 #define _UFFDIO_WRITEPROTECT (0x06)
 #define _UFFDIO_CONTINUE (0x07)
+#define _UFFDIO_POISON (0x08)
 #define _UFFDIO_API (0x3F)
 #define UFFDIO 0xAA
 #define UFFDIO_API _IOWR(UFFDIO, _UFFDIO_API, struct uffdio_api)
@@ -44,6 +45,7 @@
 #define UFFDIO_ZEROPAGE _IOWR(UFFDIO, _UFFDIO_ZEROPAGE, struct uffdio_zeropage)
 #define UFFDIO_WRITEPROTECT _IOWR(UFFDIO, _UFFDIO_WRITEPROTECT, struct uffdio_writeprotect)
 #define UFFDIO_CONTINUE _IOWR(UFFDIO, _UFFDIO_CONTINUE, struct uffdio_continue)
+#define UFFDIO_POISON _IOWR(UFFDIO, _UFFDIO_POISON, struct uffdio_poison)
 struct uffd_msg {
   __u8 event;
   __u8 reserved1;
@@ -100,6 +102,7 @@
 #define UFFD_FEATURE_EXACT_ADDRESS (1 << 11)
 #define UFFD_FEATURE_WP_HUGETLBFS_SHMEM (1 << 12)
 #define UFFD_FEATURE_WP_UNPOPULATED (1 << 13)
+#define UFFD_FEATURE_POISON (1 << 14)
   __u64 features;
   __u64 ioctls;
 };
@@ -143,5 +146,11 @@
   __u64 mode;
   __s64 mapped;
 };
+struct uffdio_poison {
+  struct uffdio_range range;
+#define UFFDIO_POISON_MODE_DONTWAKE ((__u64) 1 << 0)
+  __u64 mode;
+  __s64 updated;
+};
 #define UFFD_USER_MODE_ONLY 1
 #endif
diff --git a/libc/kernel/uapi/linux/version.h b/libc/kernel/uapi/linux/version.h
index 52d0113..e338e57 100644
--- a/libc/kernel/uapi/linux/version.h
+++ b/libc/kernel/uapi/linux/version.h
@@ -16,8 +16,8 @@
  ***
  ****************************************************************************
  ****************************************************************************/
-#define LINUX_VERSION_CODE 394496
+#define LINUX_VERSION_CODE 394752
 #define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + ((c) > 255 ? 255 : (c)))
 #define LINUX_VERSION_MAJOR 6
-#define LINUX_VERSION_PATCHLEVEL 5
+#define LINUX_VERSION_PATCHLEVEL 6
 #define LINUX_VERSION_SUBLEVEL 0
diff --git a/libc/kernel/uapi/linux/vfio.h b/libc/kernel/uapi/linux/vfio.h
index b404238..7916990 100644
--- a/libc/kernel/uapi/linux/vfio.h
+++ b/libc/kernel/uapi/linux/vfio.h
@@ -66,6 +66,7 @@
   __u32 num_regions;
   __u32 num_irqs;
   __u32 cap_offset;
+  __u32 pad;
 };
 #define VFIO_DEVICE_GET_INFO _IO(VFIO_TYPE, VFIO_BASE + 7)
 #define VFIO_DEVICE_API_PCI_STRING "vfio-pci"
@@ -232,7 +233,12 @@
   VFIO_AP_NUM_IRQS
 };
 struct vfio_pci_dependent_device {
-  __u32 group_id;
+  union {
+    __u32 group_id;
+    __u32 devid;
+#define VFIO_PCI_DEVID_OWNED 0
+#define VFIO_PCI_DEVID_NOT_OWNED - 1
+  };
   __u16 segment;
   __u8 bus;
   __u8 devfn;
@@ -240,6 +246,8 @@
 struct vfio_pci_hot_reset_info {
   __u32 argsz;
   __u32 flags;
+#define VFIO_PCI_HOT_RESET_FLAG_DEV_ID (1 << 0)
+#define VFIO_PCI_HOT_RESET_FLAG_DEV_ID_OWNED (1 << 1)
   __u32 count;
   struct vfio_pci_dependent_device devices[];
 };
@@ -298,6 +306,24 @@
   __u8 data[];
 };
 #define VFIO_DEVICE_FEATURE _IO(VFIO_TYPE, VFIO_BASE + 17)
+struct vfio_device_bind_iommufd {
+  __u32 argsz;
+  __u32 flags;
+  __s32 iommufd;
+  __u32 out_devid;
+};
+#define VFIO_DEVICE_BIND_IOMMUFD _IO(VFIO_TYPE, VFIO_BASE + 18)
+struct vfio_device_attach_iommufd_pt {
+  __u32 argsz;
+  __u32 flags;
+  __u32 pt_id;
+};
+#define VFIO_DEVICE_ATTACH_IOMMUFD_PT _IO(VFIO_TYPE, VFIO_BASE + 19)
+struct vfio_device_detach_iommufd_pt {
+  __u32 argsz;
+  __u32 flags;
+};
+#define VFIO_DEVICE_DETACH_IOMMUFD_PT _IO(VFIO_TYPE, VFIO_BASE + 20)
 #define VFIO_DEVICE_FEATURE_PCI_VF_TOKEN (0)
 struct vfio_device_feature_migration {
   __aligned_u64 flags;
@@ -365,6 +391,7 @@
 #define VFIO_IOMMU_INFO_CAPS (1 << 1)
   __u64 iova_pgsizes;
   __u32 cap_offset;
+  __u32 pad;
 };
 #define VFIO_IOMMU_TYPE1_INFO_CAP_IOVA_RANGE 1
 struct vfio_iova_range {
diff --git a/libc/kernel/uapi/linux/vhost_types.h b/libc/kernel/uapi/linux/vhost_types.h
index 1cd6965..926c7b9 100644
--- a/libc/kernel/uapi/linux/vhost_types.h
+++ b/libc/kernel/uapi/linux/vhost_types.h
@@ -114,4 +114,5 @@
 #define VHOST_BACKEND_F_IOTLB_ASID 0x3
 #define VHOST_BACKEND_F_SUSPEND 0x4
 #define VHOST_BACKEND_F_RESUME 0x5
+#define VHOST_BACKEND_F_ENABLE_AFTER_DRIVER_OK 0x6
 #endif
diff --git a/libc/kernel/uapi/linux/videodev2.h b/libc/kernel/uapi/linux/videodev2.h
index 2cd1beb..8c209af 100644
--- a/libc/kernel/uapi/linux/videodev2.h
+++ b/libc/kernel/uapi/linux/videodev2.h
@@ -422,6 +422,8 @@
 #define V4L2_PIX_FMT_Z16 v4l2_fourcc('Z', '1', '6', ' ')
 #define V4L2_PIX_FMT_MT21C v4l2_fourcc('M', 'T', '2', '1')
 #define V4L2_PIX_FMT_MM21 v4l2_fourcc('M', 'M', '2', '1')
+#define V4L2_PIX_FMT_MT2110T v4l2_fourcc('M', 'T', '2', 'T')
+#define V4L2_PIX_FMT_MT2110R v4l2_fourcc('M', 'T', '2', 'R')
 #define V4L2_PIX_FMT_INZI v4l2_fourcc('I', 'N', 'Z', 'I')
 #define V4L2_PIX_FMT_CNF4 v4l2_fourcc('C', 'N', 'F', '4')
 #define V4L2_PIX_FMT_HI240 v4l2_fourcc('H', 'I', '2', '4')
diff --git a/libc/kernel/uapi/linux/virtio_net.h b/libc/kernel/uapi/linux/virtio_net.h
index d2554a0..b3b600d 100644
--- a/libc/kernel/uapi/linux/virtio_net.h
+++ b/libc/kernel/uapi/linux/virtio_net.h
@@ -45,6 +45,7 @@
 #define VIRTIO_NET_F_GUEST_ANNOUNCE 21
 #define VIRTIO_NET_F_MQ 22
 #define VIRTIO_NET_F_CTRL_MAC_ADDR 23
+#define VIRTIO_NET_F_VQ_NOTF_COAL 52
 #define VIRTIO_NET_F_NOTF_COAL 53
 #define VIRTIO_NET_F_GUEST_USO4 54
 #define VIRTIO_NET_F_GUEST_USO6 55
@@ -141,7 +142,7 @@
 };
 #endif
 struct virtio_net_ctrl_hdr {
-  __u8 class;
+  __u8 __linux_class;
   __u8 cmd;
 } __attribute__((packed));
 typedef __u8 virtio_net_ctrl_ack;
@@ -203,4 +204,15 @@
   __le32 rx_usecs;
 };
 #define VIRTIO_NET_CTRL_NOTF_COAL_RX_SET 1
+#define VIRTIO_NET_CTRL_NOTF_COAL_VQ_SET 2
+#define VIRTIO_NET_CTRL_NOTF_COAL_VQ_GET 3
+struct virtio_net_ctrl_coal {
+  __le32 max_packets;
+  __le32 max_usecs;
+};
+struct virtio_net_ctrl_coal_vq {
+  __le16 vqn;
+  __le16 reserved;
+  struct virtio_net_ctrl_coal coal;
+};
 #endif
diff --git a/libc/kernel/uapi/rdma/bnxt_re-abi.h b/libc/kernel/uapi/rdma/bnxt_re-abi.h
index 68cb06a..8324923 100644
--- a/libc/kernel/uapi/rdma/bnxt_re-abi.h
+++ b/libc/kernel/uapi/rdma/bnxt_re-abi.h
@@ -28,6 +28,7 @@
   BNXT_RE_UCNTX_CMASK_HAVE_CCTX = 0x1ULL,
   BNXT_RE_UCNTX_CMASK_HAVE_MODE = 0x02ULL,
   BNXT_RE_UCNTX_CMASK_WC_DPI_ENABLED = 0x04ULL,
+  BNXT_RE_UCNTX_CMASK_DBR_PACING_ENABLED = 0x08ULL,
 };
 enum bnxt_re_wqe_mode {
   BNXT_QPLIB_WQE_MODE_STATIC = 0x00,
@@ -89,9 +90,12 @@
 };
 enum bnxt_re_objects {
   BNXT_RE_OBJECT_ALLOC_PAGE = (1U << UVERBS_ID_NS_SHIFT),
+  BNXT_RE_OBJECT_NOTIFY_DRV,
 };
 enum bnxt_re_alloc_page_type {
   BNXT_RE_ALLOC_WC_PAGE = 0,
+  BNXT_RE_ALLOC_DBR_BAR_PAGE,
+  BNXT_RE_ALLOC_DBR_PAGE,
 };
 enum bnxt_re_var_alloc_page_attrs {
   BNXT_RE_ALLOC_PAGE_HANDLE = (1U << UVERBS_ID_NS_SHIFT),
@@ -107,4 +111,7 @@
   BNXT_RE_METHOD_ALLOC_PAGE = (1U << UVERBS_ID_NS_SHIFT),
   BNXT_RE_METHOD_DESTROY_PAGE,
 };
+enum bnxt_re_notify_drv_methods {
+  BNXT_RE_METHOD_NOTIFY_DRV = (1U << UVERBS_ID_NS_SHIFT),
+};
 #endif
diff --git a/libc/kernel/uapi/rdma/irdma-abi.h b/libc/kernel/uapi/rdma/irdma-abi.h
index b6840cf..b2eb258 100644
--- a/libc/kernel/uapi/rdma/irdma-abi.h
+++ b/libc/kernel/uapi/rdma/irdma-abi.h
@@ -25,10 +25,15 @@
   IRDMA_MEMREG_TYPE_QP = 1,
   IRDMA_MEMREG_TYPE_CQ = 2,
 };
+enum {
+  IRDMA_ALLOC_UCTX_USE_RAW_ATTR = 1 << 0,
+  IRDMA_ALLOC_UCTX_MIN_HW_WQ_SIZE = 1 << 1,
+};
 struct irdma_alloc_ucontext_req {
   __u32 rsvd32;
   __u8 userspace_ver;
   __u8 rsvd8[3];
+  __aligned_u64 comp_mask;
 };
 struct irdma_alloc_ucontext_resp {
   __u32 max_pds;
@@ -48,6 +53,9 @@
   __u16 max_hw_sq_chunk;
   __u8 hw_rev;
   __u8 rsvd2;
+  __aligned_u64 comp_mask;
+  __u16 min_hw_wq_size;
+  __u8 rsvd3[6];
 };
 struct irdma_alloc_pd_resp {
   __u32 pd_id;
diff --git a/libc/kernel/uapi/scsi/scsi_bsg_ufs.h b/libc/kernel/uapi/scsi/scsi_bsg_ufs.h
index b820c07..96ee194 100644
--- a/libc/kernel/uapi/scsi/scsi_bsg_ufs.h
+++ b/libc/kernel/uapi/scsi/scsi_bsg_ufs.h
@@ -18,6 +18,7 @@
  ****************************************************************************/
 #ifndef SCSI_BSG_UFS_H
 #define SCSI_BSG_UFS_H
+#include <asm/byteorder.h>
 #include <linux/types.h>
 #define UFS_CDB_SIZE 16
 #define UIC_CMD_SIZE (sizeof(__u32) * 4)
@@ -37,9 +38,37 @@
   UFS_RPMB_PURGE_STATUS_READ = 0x09,
 };
 struct utp_upiu_header {
-  __be32 dword_0;
-  __be32 dword_1;
-  __be32 dword_2;
+  union {
+    struct {
+      __be32 dword_0;
+      __be32 dword_1;
+      __be32 dword_2;
+    };
+    struct {
+      __u8 transaction_code;
+      __u8 flags;
+      __u8 lun;
+      __u8 task_tag;
+#ifdef __BIG_ENDIAN
+      __u8 iid : 4;
+      __u8 command_set_type : 4;
+#elif defined(__LITTLE_ENDIAN)
+      __u8 command_set_type : 4;
+      __u8 iid : 4;
+#else
+#error 
+#endif
+      union {
+        __u8 tm_function;
+        __u8 query_function;
+      } __attribute__((packed));
+      __u8 response;
+      __u8 status;
+      __u8 ehs_length;
+      __u8 device_information;
+      __be16 data_segment_length;
+    };
+  };
 };
 struct utp_upiu_query {
   __u8 opcode;
diff --git a/libc/kernel/uapi/sound/sof/tokens.h b/libc/kernel/uapi/sound/sof/tokens.h
index 48ef360..fcc7228 100644
--- a/libc/kernel/uapi/sound/sof/tokens.h
+++ b/libc/kernel/uapi/sound/sof/tokens.h
@@ -66,6 +66,7 @@
 #define SOF_TKN_COMP_OUTPUT_PIN_BINDING_WNAME 414
 #define SOF_TKN_COMP_NUM_INPUT_AUDIO_FORMATS 415
 #define SOF_TKN_COMP_NUM_OUTPUT_AUDIO_FORMATS 416
+#define SOF_TKN_COMP_NO_WNAME_IN_KCONTROL_NAME 417
 #define SOF_TKN_INTEL_SSP_CLKS_CONTROL 500
 #define SOF_TKN_INTEL_SSP_MCLK_ID 501
 #define SOF_TKN_INTEL_SSP_SAMPLE_BITS 502
diff --git a/libc/kernel/uapi/xen/privcmd.h b/libc/kernel/uapi/xen/privcmd.h
index 21d9f84..c4de85e 100644
--- a/libc/kernel/uapi/xen/privcmd.h
+++ b/libc/kernel/uapi/xen/privcmd.h
@@ -67,6 +67,15 @@
   __u64 num;
   __u64 addr;
 };
+#define PRIVCMD_IRQFD_FLAG_DEASSIGN (1 << 0)
+struct privcmd_irqfd {
+  void  * dm_op;
+  __u32 size;
+  __u32 fd;
+  __u32 flags;
+  domid_t dom;
+  __u8 pad[2];
+};
 #define IOCTL_PRIVCMD_HYPERCALL _IOC(_IOC_NONE, 'P', 0, sizeof(struct privcmd_hypercall))
 #define IOCTL_PRIVCMD_MMAP _IOC(_IOC_NONE, 'P', 2, sizeof(struct privcmd_mmap))
 #define IOCTL_PRIVCMD_MMAPBATCH _IOC(_IOC_NONE, 'P', 3, sizeof(struct privcmd_mmapbatch))
@@ -74,4 +83,5 @@
 #define IOCTL_PRIVCMD_DM_OP _IOC(_IOC_NONE, 'P', 5, sizeof(struct privcmd_dm_op))
 #define IOCTL_PRIVCMD_RESTRICT _IOC(_IOC_NONE, 'P', 6, sizeof(domid_t))
 #define IOCTL_PRIVCMD_MMAP_RESOURCE _IOC(_IOC_NONE, 'P', 7, sizeof(struct privcmd_mmap_resource))
+#define IOCTL_PRIVCMD_IRQFD _IOC(_IOC_NONE, 'P', 8, sizeof(struct privcmd_irqfd))
 #endif
diff --git a/libc/libc.map.txt b/libc/libc.map.txt
index 824682b..156e9ee 100644
--- a/libc/libc.map.txt
+++ b/libc/libc.map.txt
@@ -1600,6 +1600,7 @@
     tzalloc;
     tzfree;
     wcsrtombs_l;
+    __system_properties_zygote_reload; # apex
 } LIBC_U;
 
 LIBC_PRIVATE {
diff --git a/libc/platform/bionic/malloc.h b/libc/platform/bionic/malloc.h
index 0a6546e..a06b8ee 100644
--- a/libc/platform/bionic/malloc.h
+++ b/libc/platform/bionic/malloc.h
@@ -104,6 +104,13 @@
   // Query whether memtag stack is enabled for this process.
   M_MEMTAG_STACK_IS_ON = 11,
 #define M_MEMTAG_STACK_IS_ON M_MEMTAG_STACK_IS_ON
+  // Query whether the current process has the decay time enabled so that
+  // the memory from allocations are not immediately released to the OS.
+  // Result is assigned to the arg pointer's destination.
+  //   arg = bool*
+  //   arg_size = sizeof(bool)
+  M_GET_DECAY_TIME_ENABLED = 12,
+#define M_GET_DECAY_TIME_ENABLED M_GET_DECAY_TIME_ENABLED
 };
 
 #pragma clang diagnostic push
diff --git a/libc/private/bionic_globals.h b/libc/private/bionic_globals.h
index d9c4234..15b570d 100644
--- a/libc/private/bionic_globals.h
+++ b/libc/private/bionic_globals.h
@@ -49,6 +49,7 @@
   long setjmp_cookie;
   uintptr_t heap_pointer_tag;
   _Atomic(bool) memtag_stack;
+  _Atomic(bool) decay_time_enabled;
 
   // In order to allow a complete switch between dispatch tables without
   // the need for copying each function by function in the structure,
diff --git a/libc/system_properties/contexts_serialized.cpp b/libc/system_properties/contexts_serialized.cpp
index f05aaa0..73c9136 100644
--- a/libc/system_properties/contexts_serialized.cpp
+++ b/libc/system_properties/contexts_serialized.cpp
@@ -38,6 +38,7 @@
 #include <new>
 
 #include <async_safe/log.h>
+#include <private/android_filesystem_config.h>
 
 #include "system_properties/system_properties.h"
 
@@ -59,25 +60,28 @@
   context_nodes_mmap_size_ = context_nodes_mmap_size;
 
   for (size_t i = 0; i < num_context_nodes; ++i) {
-    new (&context_nodes_[i]) ContextNode(property_info_area_file_->context(i), filename_);
+    new (&context_nodes_[i]) ContextNode(property_info_area_file_->context(i), dirname_);
   }
 
   return true;
 }
 
 bool ContextsSerialized::MapSerialPropertyArea(bool access_rw, bool* fsetxattr_failed) {
-  PropertiesFilename filename(filename_, "properties_serial");
   if (access_rw) {
     serial_prop_area_ = prop_area::map_prop_area_rw(
-        filename.c_str(), "u:object_r:properties_serial:s0", fsetxattr_failed);
+        serial_filename_.c_str(), "u:object_r:properties_serial:s0", fsetxattr_failed);
   } else {
-    serial_prop_area_ = prop_area::map_prop_area(filename.c_str());
+    serial_prop_area_ = prop_area::map_prop_area(serial_filename_.c_str());
   }
   return serial_prop_area_;
 }
 
-bool ContextsSerialized::InitializeProperties() {
-  if (!property_info_area_file_.LoadDefaultPath()) {
+// Note: load_default_path is only used for testing, as it will cause properties to be loaded from
+// one file (specified by PropertyInfoAreaFile.LoadDefaultPath), but be written to "filename".
+bool ContextsSerialized::InitializeProperties(bool load_default_path) {
+  if (load_default_path && !property_info_area_file_.LoadDefaultPath()) {
+    return false;
+  } else if (!load_default_path && !property_info_area_file_.LoadPath(tree_filename_.c_str())) {
     return false;
   }
 
@@ -89,14 +93,20 @@
   return true;
 }
 
-bool ContextsSerialized::Initialize(bool writable, const char* filename, bool* fsetxattr_failed) {
-  filename_ = filename;
-  if (!InitializeProperties()) {
+// Note: load_default_path is only used for testing, as it will cause properties to be loaded from
+// one file (specified by PropertyInfoAreaFile.LoadDefaultPath), but be written to "filename".
+bool ContextsSerialized::Initialize(bool writable, const char* dirname, bool* fsetxattr_failed,
+                                    bool load_default_path) {
+  dirname_ = dirname;
+  tree_filename_ = PropertiesFilename(dirname, "property_info");
+  serial_filename_ = PropertiesFilename(dirname, "properties_serial");
+
+  if (!InitializeProperties(load_default_path)) {
     return false;
   }
 
   if (writable) {
-    mkdir(filename_, S_IRWXU | S_IXGRP | S_IXOTH);
+    mkdir(dirname_, S_IRWXU | S_IXGRP | S_IXOTH);
     bool open_failed = false;
     if (fsetxattr_failed) {
       *fsetxattr_failed = false;
diff --git a/libc/system_properties/contexts_split.cpp b/libc/system_properties/contexts_split.cpp
index 3579f55..78bdc64 100644
--- a/libc/system_properties/contexts_split.cpp
+++ b/libc/system_properties/contexts_split.cpp
@@ -281,7 +281,7 @@
   return true;
 }
 
-bool ContextsSplit::Initialize(bool writable, const char* filename, bool* fsetxattr_failed) {
+bool ContextsSplit::Initialize(bool writable, const char* filename, bool* fsetxattr_failed, bool) {
   filename_ = filename;
   if (!InitializeProperties()) {
     return false;
diff --git a/libc/system_properties/include/system_properties/contexts.h b/libc/system_properties/include/system_properties/contexts.h
index 670f808..df8c5a2 100644
--- a/libc/system_properties/include/system_properties/contexts.h
+++ b/libc/system_properties/include/system_properties/contexts.h
@@ -36,7 +36,8 @@
   virtual ~Contexts() {
   }
 
-  virtual bool Initialize(bool writable, const char* filename, bool* fsetxattr_failed) = 0;
+  virtual bool Initialize(bool writable, const char* filename, bool* fsetxattr_failed,
+                          bool load_default_path = false) = 0;
   virtual prop_area* GetPropAreaForName(const char* name) = 0;
   virtual prop_area* GetSerialPropArea() = 0;
   virtual void ForEach(void (*propfn)(const prop_info* pi, void* cookie), void* cookie) = 0;
diff --git a/libc/system_properties/include/system_properties/contexts_pre_split.h b/libc/system_properties/include/system_properties/contexts_pre_split.h
index 6e695e9..a6cd039 100644
--- a/libc/system_properties/include/system_properties/contexts_pre_split.h
+++ b/libc/system_properties/include/system_properties/contexts_pre_split.h
@@ -38,7 +38,7 @@
   }
 
   // We'll never initialize this legacy option as writable, so don't even check the arg.
-  virtual bool Initialize(bool, const char* filename, bool*) override {
+  virtual bool Initialize(bool, const char* filename, bool*, bool) override {
     pre_split_prop_area_ = prop_area::map_prop_area(filename);
     return pre_split_prop_area_ != nullptr;
   }
diff --git a/libc/system_properties/include/system_properties/contexts_serialized.h b/libc/system_properties/include/system_properties/contexts_serialized.h
index 93d6ac1..8bb0b11 100644
--- a/libc/system_properties/include/system_properties/contexts_serialized.h
+++ b/libc/system_properties/include/system_properties/contexts_serialized.h
@@ -32,13 +32,15 @@
 
 #include "context_node.h"
 #include "contexts.h"
+#include "properties_filename.h"
 
 class ContextsSerialized : public Contexts {
  public:
   virtual ~ContextsSerialized() override {
   }
 
-  virtual bool Initialize(bool writable, const char* filename, bool* fsetxattr_failed) override;
+  virtual bool Initialize(bool writable, const char* dirname, bool* fsetxattr_failed,
+                          bool load_default_path) override;
   virtual prop_area* GetPropAreaForName(const char* name) override;
   virtual prop_area* GetSerialPropArea() override {
     return serial_prop_area_;
@@ -49,10 +51,12 @@
 
  private:
   bool InitializeContextNodes();
-  bool InitializeProperties();
+  bool InitializeProperties(bool load_default_path);
   bool MapSerialPropertyArea(bool access_rw, bool* fsetxattr_failed);
 
-  const char* filename_;
+  const char* dirname_;
+  PropertiesFilename tree_filename_;
+  PropertiesFilename serial_filename_;
   android::properties::PropertyInfoAreaFile property_info_area_file_;
   ContextNode* context_nodes_ = nullptr;
   size_t num_context_nodes_ = 0;
diff --git a/libc/system_properties/include/system_properties/contexts_split.h b/libc/system_properties/include/system_properties/contexts_split.h
index 1d954cc..321cfd2 100644
--- a/libc/system_properties/include/system_properties/contexts_split.h
+++ b/libc/system_properties/include/system_properties/contexts_split.h
@@ -38,7 +38,8 @@
   virtual ~ContextsSplit() override {
   }
 
-  virtual bool Initialize(bool writable, const char* filename, bool* fsetxattr_failed) override;
+  virtual bool Initialize(bool writable, const char* filename, bool* fsetxattr_failed,
+                          bool) override;
   virtual prop_area* GetPropAreaForName(const char* name) override;
   virtual prop_area* GetSerialPropArea() override {
     return serial_prop_area_;
diff --git a/libc/system_properties/include/system_properties/properties_filename.h b/libc/system_properties/include/system_properties/properties_filename.h
new file mode 100644
index 0000000..d686f20
--- /dev/null
+++ b/libc/system_properties/include/system_properties/properties_filename.h
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2023 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.
+ */
+
+#pragma once
+
+#include <stdint.h>
+
+class PropertiesFilename {
+ public:
+  PropertiesFilename() = default;
+  PropertiesFilename(const char* dir, const char* file) {
+    if (snprintf(filename_, sizeof(filename_), "%s/%s", dir, file) >=
+        static_cast<int>(sizeof(filename_))) {
+      abort();
+    }
+  }
+  void operator=(const char* value) {
+    if (strlen(value) >= sizeof(filename_)) abort();
+    strcpy(filename_, value);
+  }
+  const char* c_str() { return filename_; }
+
+ private:
+  // Typically something like "/dev/__properties__/properties_serial".
+  char filename_[128];
+};
diff --git a/libc/system_properties/include/system_properties/system_properties.h b/libc/system_properties/include/system_properties/system_properties.h
index 4d84b39..ea4f339 100644
--- a/libc/system_properties/include/system_properties/system_properties.h
+++ b/libc/system_properties/include/system_properties/system_properties.h
@@ -28,7 +28,6 @@
 
 #pragma once
 
-#include <stdint.h>
 #include <sys/param.h>
 #include <sys/system_properties.h>
 
@@ -37,26 +36,6 @@
 #include "contexts_serialized.h"
 #include "contexts_split.h"
 
-class PropertiesFilename {
- public:
-  PropertiesFilename() = default;
-  PropertiesFilename(const char* dir, const char* file) {
-    if (snprintf(filename_, sizeof(filename_), "%s/%s", dir, file) >=
-        static_cast<int>(sizeof(filename_))) {
-      abort();
-    }
-  }
-  void operator=(const char* value) {
-    if (strlen(value) >= sizeof(filename_)) abort();
-    strcpy(filename_, value);
-  }
-  const char* c_str() { return filename_; }
-
- private:
-  // Typically something like "/dev/__properties__/properties_serial".
-  char filename_[128];
-};
-
 class SystemProperties {
  public:
   friend struct LocalPropertyTestState;
@@ -73,7 +52,9 @@
   BIONIC_DISALLOW_COPY_AND_ASSIGN(SystemProperties);
 
   bool Init(const char* filename);
+  bool Reload(bool load_default_path);
   bool AreaInit(const char* filename, bool* fsetxattr_failed);
+  bool AreaInit(const char* filename, bool* fsetxattr_failed, bool load_default_path);
   uint32_t AreaSerial();
   const prop_info* Find(const char* name);
   int Read(const prop_info* pi, char* name, char* value);
@@ -101,8 +82,14 @@
   static constexpr size_t kMaxContextsSize =
       MAX(sizeof(ContextsSerialized), MAX(sizeof(ContextsSplit), sizeof(ContextsPreSplit)));
   alignas(kMaxContextsAlign) char contexts_data_[kMaxContextsSize];
+  alignas(kMaxContextsAlign) char appcompat_override_contexts_data_[kMaxContextsSize];
   Contexts* contexts_;
+  // See http://b/291816546#comment#3 for more explanation of appcompat_override
+  Contexts* appcompat_override_contexts_;
+
+  bool InitContexts(bool load_default_path);
 
   bool initialized_;
   PropertiesFilename properties_filename_;
+  PropertiesFilename appcompat_filename_;
 };
diff --git a/libc/system_properties/system_properties.cpp b/libc/system_properties/system_properties.cpp
index 049236f..9dd5e35 100644
--- a/libc/system_properties/system_properties.cpp
+++ b/libc/system_properties/system_properties.cpp
@@ -29,6 +29,7 @@
 #include "system_properties/system_properties.h"
 
 #include <errno.h>
+#include <private/android_filesystem_config.h>
 #include <stdatomic.h>
 #include <stdlib.h>
 #include <string.h>
@@ -38,6 +39,7 @@
 
 #include <new>
 
+#include <async_safe/CHECK.h>
 #include <async_safe/log.h>
 
 #include "private/ErrnoRestorer.h"
@@ -49,6 +51,7 @@
 
 #define SERIAL_DIRTY(serial) ((serial)&1)
 #define SERIAL_VALUE_LEN(serial) ((serial) >> 24)
+#define APPCOMPAT_PREFIX "ro.appcompat_override."
 
 static bool is_dir(const char* pathname) {
   struct stat info;
@@ -69,10 +72,21 @@
 
   properties_filename_ = filename;
 
+  if (!InitContexts(false)) {
+    return false;
+  }
+
+  initialized_ = true;
+  return true;
+}
+
+bool SystemProperties::InitContexts(bool load_default_path) {
   if (is_dir(properties_filename_.c_str())) {
-    if (access("/dev/__properties__/property_info", R_OK) == 0) {
-      contexts_ = new (contexts_data_) ContextsSerialized();
-      if (!contexts_->Initialize(false, properties_filename_.c_str(), nullptr)) {
+    if (access(PROP_TREE_FILE, R_OK) == 0) {
+      auto serial_contexts = new (contexts_data_) ContextsSerialized();
+      contexts_ = serial_contexts;
+      if (!serial_contexts->Initialize(false, properties_filename_.c_str(), nullptr,
+                                       load_default_path)) {
         return false;
       }
     } else {
@@ -87,20 +101,46 @@
       return false;
     }
   }
-  initialized_ = true;
   return true;
 }
 
 bool SystemProperties::AreaInit(const char* filename, bool* fsetxattr_failed) {
+  return AreaInit(filename, fsetxattr_failed, false);
+}
+
+// Note: load_default_path is only used for testing, as it will cause properties to be loaded from
+// one file (specified by PropertyInfoAreaFile.LoadDefaultPath), but be written to "filename".
+bool SystemProperties::AreaInit(const char* filename, bool* fsetxattr_failed,
+                                bool load_default_path) {
   properties_filename_ = filename;
-  contexts_ = new (contexts_data_) ContextsSerialized();
-  if (!contexts_->Initialize(true, properties_filename_.c_str(), fsetxattr_failed)) {
+  auto serial_contexts = new (contexts_data_) ContextsSerialized();
+  contexts_ = serial_contexts;
+  if (!serial_contexts->Initialize(true, properties_filename_.c_str(), fsetxattr_failed,
+                                   load_default_path)) {
     return false;
   }
+
+  auto* appcompat_contexts = new (appcompat_override_contexts_data_) ContextsSerialized();
+  appcompat_filename_ = PropertiesFilename(properties_filename_.c_str(), "appcompat_override");
+  if (!appcompat_contexts->Initialize(true, appcompat_filename_.c_str(), fsetxattr_failed,
+                                      load_default_path)) {
+    appcompat_override_contexts_ = nullptr;
+    return false;
+  }
+  appcompat_override_contexts_ = appcompat_contexts;
+
   initialized_ = true;
   return true;
 }
 
+bool SystemProperties::Reload(bool load_default_path) {
+  if (!initialized_) {
+    return true;
+  }
+
+  return InitContexts(load_default_path);
+}
+
 uint32_t SystemProperties::AreaSerial() {
   if (!initialized_) {
     return -1;
@@ -129,6 +169,10 @@
   return pa->find(name);
 }
 
+static bool is_appcompat_override(const char* name) {
+  return strncmp(name, APPCOMPAT_PREFIX, strlen(APPCOMPAT_PREFIX)) == 0;
+}
+
 static bool is_read_only(const char* name) {
   return strncmp(name, "ro.", 3) == 0;
 }
@@ -227,16 +271,24 @@
   if (!initialized_) {
     return -1;
   }
+  bool have_override = appcompat_override_contexts_ != nullptr;
 
   prop_area* serial_pa = contexts_->GetSerialPropArea();
+  prop_area* override_serial_pa =
+      have_override ? appcompat_override_contexts_->GetSerialPropArea() : nullptr;
   if (!serial_pa) {
     return -1;
   }
   prop_area* pa = contexts_->GetPropAreaForName(pi->name);
+  prop_area* override_pa =
+      have_override ? appcompat_override_contexts_->GetPropAreaForName(pi->name) : nullptr;
   if (__predict_false(!pa)) {
     async_safe_format_log(ANDROID_LOG_ERROR, "libc", "Could not find area for \"%s\"", pi->name);
     return -1;
   }
+  CHECK(!have_override || (override_pa && override_serial_pa));
+
+  auto* override_pi = const_cast<prop_info*>(have_override ? override_pa->find(pi->name) : nullptr);
 
   uint32_t serial = atomic_load_explicit(&pi->serial, memory_order_relaxed);
   unsigned int old_len = SERIAL_VALUE_LEN(serial);
@@ -246,18 +298,34 @@
   // that we publish our dirty area update before allowing readers to see a
   // dirty serial.
   memcpy(pa->dirty_backup_area(), pi->value, old_len + 1);
+  if (have_override) {
+    memcpy(override_pa->dirty_backup_area(), override_pi->value, old_len + 1);
+  }
   atomic_thread_fence(memory_order_release);
   serial |= 1;
   atomic_store_explicit(&pi->serial, serial, memory_order_relaxed);
   strlcpy(pi->value, value, len + 1);
+  if (have_override) {
+    atomic_store_explicit(&override_pi->serial, serial, memory_order_relaxed);
+    strlcpy(override_pi->value, value, len + 1);
+  }
   // Now the primary value property area is up-to-date. Let readers know that they should
   // look at the property value instead of the backup area.
   atomic_thread_fence(memory_order_release);
-  atomic_store_explicit(&pi->serial, (len << 24) | ((serial + 1) & 0xffffff), memory_order_relaxed);
+  int new_serial = (len << 24) | ((serial + 1) & 0xffffff);
+  atomic_store_explicit(&pi->serial, new_serial, memory_order_relaxed);
+  if (have_override) {
+    atomic_store_explicit(&override_pi->serial, new_serial, memory_order_relaxed);
+  }
   __futex_wake(&pi->serial, INT32_MAX);  // Fence by side effect
   atomic_store_explicit(serial_pa->serial(),
                         atomic_load_explicit(serial_pa->serial(), memory_order_relaxed) + 1,
                         memory_order_release);
+  if (have_override) {
+    atomic_store_explicit(override_serial_pa->serial(),
+                          atomic_load_explicit(serial_pa->serial(), memory_order_relaxed) + 1,
+                          memory_order_release);
+  }
   __futex_wake(serial_pa->serial(), INT32_MAX);
 
   return 0;
@@ -293,6 +361,34 @@
     return -1;
   }
 
+  if (appcompat_override_contexts_ != nullptr) {
+    bool is_override = is_appcompat_override(name);
+    const char* override_name = name;
+    if (is_override) override_name += strlen(APPCOMPAT_PREFIX);
+    prop_area* other_pa = appcompat_override_contexts_->GetPropAreaForName(override_name);
+    prop_area* other_serial_pa = appcompat_override_contexts_->GetSerialPropArea();
+    CHECK(other_pa && other_serial_pa);
+    // We may write a property twice to overrides, once for the ro.*, and again for the
+    // ro.appcompat_override.ro.* property. If we've already written, then we should essentially
+    // perform an Update, not an Add.
+    auto other_pi = const_cast<prop_info*>(other_pa->find(override_name));
+    if (!other_pi) {
+      if (other_pa->add(override_name, strlen(override_name), value, valuelen)) {
+        atomic_store_explicit(
+            other_serial_pa->serial(),
+            atomic_load_explicit(other_serial_pa->serial(), memory_order_relaxed) + 1,
+            memory_order_release);
+      }
+    } else if (is_override) {
+      // We already wrote the ro.*, but appcompat_override.ro.* should override that. We don't
+      // need to do the usual dirty bit setting, as this only happens during the init process,
+      // before any readers are started. Check that only init or root can write appcompat props.
+      CHECK(getpid() == 1 || getuid() == 0);
+      atomic_thread_fence(memory_order_release);
+      strlcpy(other_pi->value, value, valuelen + 1);
+    }
+  }
+
   // There is only a single mutator, but we want to make sure that
   // updates are visible to a reader waiting for the update.
   atomic_store_explicit(serial_pa->serial(),
diff --git a/libc/upstream-freebsd/lib/libc/string/memcmp.c b/libc/upstream-freebsd/lib/libc/string/memcmp.c
new file mode 100644
index 0000000..183b09c
--- /dev/null
+++ b/libc/upstream-freebsd/lib/libc/string/memcmp.c
@@ -0,0 +1,59 @@
+/*-
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)memcmp.c	8.1 (Berkeley) 6/4/93";
+#endif /* LIBC_SCCS and not lint */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <string.h>
+
+/*
+ * Compare memory regions.
+ */
+int
+memcmp(const void *s1, const void *s2, size_t n)
+{
+	if (n != 0) {
+		const unsigned char *p1 = s1, *p2 = s2;
+
+		do {
+			if (*p1++ != *p2++)
+				return (*--p1 - *--p2);
+		} while (--n != 0);
+	}
+	return (0);
+}
+
diff --git a/tests/malloc_test.cpp b/tests/malloc_test.cpp
index 2411753..14a426f 100644
--- a/tests/malloc_test.cpp
+++ b/tests/malloc_test.cpp
@@ -1734,3 +1734,36 @@
     }
   }
 }
+
+TEST(android_mallopt, get_decay_time_enabled_errors) {
+#if defined(__BIONIC__)
+  errno = 0;
+  EXPECT_FALSE(android_mallopt(M_GET_DECAY_TIME_ENABLED, nullptr, sizeof(bool)));
+  EXPECT_ERRNO(EINVAL);
+
+  errno = 0;
+  int value;
+  EXPECT_FALSE(android_mallopt(M_GET_DECAY_TIME_ENABLED, &value, sizeof(value)));
+  EXPECT_ERRNO(EINVAL);
+#else
+  GTEST_SKIP() << "bionic-only test";
+#endif
+}
+
+TEST(android_mallopt, get_decay_time_enabled) {
+#if defined(__BIONIC__)
+  SKIP_WITH_HWASAN << "hwasan does not implement mallopt";
+
+  EXPECT_EQ(1, mallopt(M_DECAY_TIME, 0));
+
+  bool value;
+  EXPECT_TRUE(android_mallopt(M_GET_DECAY_TIME_ENABLED, &value, sizeof(value)));
+  EXPECT_FALSE(value);
+
+  EXPECT_EQ(1, mallopt(M_DECAY_TIME, 1));
+  EXPECT_TRUE(android_mallopt(M_GET_DECAY_TIME_ENABLED, &value, sizeof(value)));
+  EXPECT_TRUE(value);
+#else
+  GTEST_SKIP() << "bionic-only test";
+#endif
+}
diff --git a/tests/sys_msg_test.cpp b/tests/sys_msg_test.cpp
index da45087..b2d855d 100644
--- a/tests/sys_msg_test.cpp
+++ b/tests/sys_msg_test.cpp
@@ -56,16 +56,17 @@
     long type;
     char data[32];
   } msg = { 1, "hello world" };
-  ASSERT_EQ(0, msgsnd(id, &msg, sizeof(msg), 0));
+  ASSERT_EQ(0, msgsnd(id, &msg, sizeof(msg.data), 0));
 
   // Queue should be non-empty.
   ASSERT_EQ(0, msgctl(id, IPC_STAT, &ds));
   ASSERT_EQ(1U, ds.msg_qnum);
-  ASSERT_EQ(sizeof(msg), ds.msg_cbytes);
+  ASSERT_EQ(sizeof(msg.data), ds.msg_cbytes);
 
   // Read the message.
   memset(&msg, 0, sizeof(msg));
-  ASSERT_EQ(static_cast<ssize_t>(sizeof(msg)), msgrcv(id, &msg, sizeof(msg), 0, 0));
+  ASSERT_EQ(static_cast<ssize_t>(sizeof(msg.data)),
+            msgrcv(id, &msg, sizeof(msg.data), 0, 0));
   ASSERT_EQ(1, msg.type);
   ASSERT_STREQ("hello world", msg.data);
 
@@ -98,7 +99,11 @@
 }
 
 TEST(sys_msg, msgsnd_failure) {
+  struct {
+    long type;
+    char data[1];
+  } msg = { 1, "" };
   errno = 0;
-  ASSERT_EQ(-1, msgsnd(-1, "", 0, 0));
+  ASSERT_EQ(-1, msgsnd(-1, &msg, sizeof(msg.data), 0));
   ASSERT_TRUE(errno == EINVAL || errno == ENOSYS);
 }
diff --git a/tests/system_properties_test.cpp b/tests/system_properties_test.cpp
index b1dfe0b..0b7f5ae 100644
--- a/tests/system_properties_test.cpp
+++ b/tests/system_properties_test.cpp
@@ -25,31 +25,53 @@
 
 #include <android-base/file.h>
 #include <android-base/silent_death_test.h>
+#include <android-base/stringprintf.h>
+
+#include "utils.h"
 
 using namespace std::literals;
 
 #if defined(__BIONIC__)
 
 #define _REALLY_INCLUDE_SYS__SYSTEM_PROPERTIES_H_
+#include <stdlib.h>
 #include <sys/_system_properties.h>
+#include <sys/mount.h>
 
 #include <system_properties/system_properties.h>
 
 class SystemPropertiesTest : public SystemProperties {
  public:
   SystemPropertiesTest() : SystemProperties(false) {
-    valid_ = AreaInit(dir_.path, nullptr);
+    appcompat_path = android::base::StringPrintf("%s/appcompat_override", dir_.path);
+    mount_path = android::base::StringPrintf("%s/__properties__", dir_.path);
+    mkdir(appcompat_path.c_str(), S_IRWXU | S_IXGRP | S_IXOTH);
+    valid_ = AreaInit(dir_.path, nullptr, true);
   }
   ~SystemPropertiesTest() {
     if (valid_) {
       contexts_->FreeAndUnmap();
     }
+    umount2(dir_.path, MNT_DETACH);
+    umount2(real_sysprop_dir.c_str(), MNT_DETACH);
   }
 
   bool valid() const {
     return valid_;
   }
 
+  const char* get_path() const { return dir_.path; }
+
+  const char* get_appcompat_path() const { return appcompat_path.c_str(); }
+
+  const char* get_mount_path() const { return mount_path.c_str(); }
+
+  const char* get_real_sysprop_dir() const { return real_sysprop_dir.c_str(); }
+
+  std::string appcompat_path;
+  std::string mount_path;
+  std::string real_sysprop_dir = "/dev/__properties__";
+
  private:
   TemporaryDir dir_;
   bool valid_;
@@ -125,6 +147,58 @@
 #endif // __BIONIC__
 }
 
+TEST(properties, __system_property_add_appcompat) {
+#if defined(__BIONIC__)
+    if (getuid() != 0) GTEST_SKIP() << "test requires root";
+    SystemPropertiesTest system_properties;
+    ASSERT_TRUE(system_properties.valid());
+
+    char name[] = "ro.property";
+    char override_name[] = "ro.appcompat_override.ro.property";
+    char name_not_written[] = "ro.property_other";
+    char override_with_no_real[] = "ro.appcompat_override.ro.property_other";
+    ASSERT_EQ(0, system_properties.Add(name, strlen(name), "value1", 6));
+    ASSERT_EQ(0, system_properties.Add(override_name, strlen(override_name), "value2", 6));
+    ASSERT_EQ(0, system_properties.Add(override_with_no_real, strlen(override_with_no_real),
+                                       "value3", 6));
+
+    char propvalue[PROP_VALUE_MAX];
+    ASSERT_EQ(6, system_properties.Get(name, propvalue));
+    ASSERT_STREQ(propvalue, "value1");
+
+    ASSERT_EQ(6, system_properties.Get(override_name, propvalue));
+    ASSERT_STREQ(propvalue, "value2");
+
+    ASSERT_EQ(0, system_properties.Get(name_not_written, propvalue));
+    ASSERT_STREQ(propvalue, "");
+
+    ASSERT_EQ(6, system_properties.Get(override_with_no_real, propvalue));
+    ASSERT_STREQ(propvalue, "value3");
+
+    int ret = mount(system_properties.get_appcompat_path(), system_properties.get_path(), nullptr,
+                    MS_BIND | MS_REC, nullptr);
+    if (ret != 0) {
+      ASSERT_ERRNO(0);
+    }
+    system_properties.Reload(true);
+
+    ASSERT_EQ(6, system_properties.Get(name, propvalue));
+    ASSERT_STREQ(propvalue, "value2");
+
+    ASSERT_EQ(0, system_properties.Get(override_name, propvalue));
+    ASSERT_STREQ(propvalue, "");
+
+    ASSERT_EQ(6, system_properties.Get(name_not_written, propvalue));
+    ASSERT_STREQ(propvalue, "value3");
+
+    ASSERT_EQ(0, system_properties.Get(override_with_no_real, propvalue));
+    ASSERT_STREQ(propvalue, "");
+
+#else   // __BIONIC__
+    GTEST_SKIP() << "bionic-only test";
+#endif  // __BIONIC__
+}
+
 TEST(properties, __system_property_update) {
 #if defined(__BIONIC__)
     SystemPropertiesTest system_properties;
@@ -432,7 +506,7 @@
 
   // This test only makes sense if we're talking to the real system property service.
   struct stat sb;
-  ASSERT_FALSE(stat(PROP_FILENAME, &sb) == -1 && errno == ENOENT);
+  ASSERT_FALSE(stat(PROP_DIRNAME, &sb) == -1 && errno == ENOENT);
 
   ASSERT_EXIT(__system_property_add("property", 8, "value", 5), KilledByFault(), "");
 #else // __BIONIC__
@@ -526,3 +600,93 @@
   GTEST_SKIP() << "bionic-only test";
 #endif  // __BIONIC__
 }
+
+// Note that this test affects global state of the system
+// this tests tries to mitigate this by using utime+pid
+// prefix for the property name. It is still results in
+// pollution of property service since properties cannot
+// be removed.
+//
+// Note that there is also possibility to run into "out-of-memory"
+// if this test if it is executed often enough without reboot.
+TEST(properties, __system_property_reload_no_op) {
+#if defined(__BIONIC__)
+  std::string property_name =
+      android::base::StringPrintf("debug.test.%d.%" PRId64 ".property", getpid(), NanoTime());
+  ASSERT_EQ(0, __system_property_find(property_name.c_str()));
+  ASSERT_EQ(0, __system_property_set(property_name.c_str(), "test value"));
+  ASSERT_EQ(0, __system_properties_zygote_reload());
+  const prop_info* readptr = __system_property_find(property_name.c_str());
+  std::string expected_name = property_name;
+  __system_property_read_callback(
+      readptr,
+      [](void*, const char*, const char* value, unsigned) { ASSERT_STREQ("test value", value); },
+      &expected_name);
+#else   // __BIONIC__
+  GTEST_SKIP() << "bionic-only test";
+#endif  // __BIONIC__
+}
+
+TEST(properties, __system_property_reload_invalid) {
+#if defined(__BIONIC__)
+  if (getuid() != 0) GTEST_SKIP() << "test requires root";
+  SystemPropertiesTest system_properties;
+
+  // Create an invalid property_info file, so the system will attempt to initialize a
+  // ContextSerialized
+  std::string property_info_file =
+      android::base::StringPrintf("%s/property_info", system_properties.get_path());
+  fclose(fopen(property_info_file.c_str(), "w"));
+  int ret = mount(system_properties.get_path(), system_properties.get_real_sysprop_dir(), nullptr,
+                  MS_BIND | MS_REC, nullptr);
+  if (ret != 0) {
+    ASSERT_ERRNO(0);
+  }
+
+  ASSERT_EQ(-1, __system_properties_zygote_reload());
+#else   // __BIONIC__
+  GTEST_SKIP() << "bionic-only test";
+#endif  // __BIONIC__
+}
+
+// Note that this test affects global state of the system
+// this tests tries to mitigate this by using utime+pid
+// prefix for the property name. It is still results in
+// pollution of property service since properties cannot
+// be removed.
+//
+// Note that there is also possibility to run into "out-of-memory"
+// if this test if it is executed often enough without reboot.
+TEST(properties, __system_property_reload_valid) {
+#if defined(__BIONIC__)
+  if (getuid() != 0) GTEST_SKIP() << "test requires root";
+  SystemPropertiesTest system_properties;
+
+  // Copy the system properties files into the temp directory
+  std::string shell_cmd = android::base::StringPrintf(
+      "cp -r %s %s", system_properties.get_real_sysprop_dir(), system_properties.get_path());
+  system(shell_cmd.c_str());
+
+  // Write a system property to the current set of system properties
+  std::string property_name =
+      android::base::StringPrintf("debug.test.%d.%" PRId64 ".property", getpid(), NanoTime());
+  ASSERT_EQ(0, __system_property_find(property_name.c_str()));
+  ASSERT_EQ(0, __system_property_set(property_name.c_str(), "test value"));
+
+  // Mount the temp directory (which doesn't have the property we just wrote) in place of the
+  // real one
+  int ret = mount(system_properties.get_mount_path(), system_properties.get_real_sysprop_dir(),
+                  nullptr, MS_BIND | MS_REC, nullptr);
+  if (ret != 0) {
+    ASSERT_ERRNO(0);
+  }
+
+  // reload system properties in the new dir, and verify the property we wrote after we copied the
+  // files isn't there
+  ASSERT_EQ(0, __system_properties_zygote_reload());
+  ASSERT_EQ(0, __system_property_find(property_name.c_str()));
+
+#else   // __BIONIC__
+  GTEST_SKIP() << "bionic-only test";
+#endif  // __BIONIC__
+}
diff --git a/tests/system_properties_test2.cpp b/tests/system_properties_test2.cpp
index 0953bde..0795ccd 100644
--- a/tests/system_properties_test2.cpp
+++ b/tests/system_properties_test2.cpp
@@ -28,10 +28,6 @@
 
 #if defined(__BIONIC__)
 #include <sys/system_properties.h>
-int64_t NanoTime() {
-  auto t = std::chrono::time_point_cast<std::chrono::nanoseconds>(std::chrono::steady_clock::now());
-  return t.time_since_epoch().count();
-}
 #endif
 
 // Note that this test affects global state of the system
diff --git a/tests/utils.cpp b/tests/utils.cpp
index 0c7c552..e123b42 100644
--- a/tests/utils.cpp
+++ b/tests/utils.cpp
@@ -89,6 +89,11 @@
   }
 }
 
+int64_t NanoTime() {
+  auto t = std::chrono::time_point_cast<std::chrono::nanoseconds>(std::chrono::steady_clock::now());
+  return t.time_since_epoch().count();
+}
+
 bool operator==(const Errno& lhs, const Errno& rhs) {
   return lhs.errno_ == rhs.errno_;
 }
diff --git a/tests/utils.h b/tests/utils.h
index f6b7174..dcb08f5 100644
--- a/tests/utils.h
+++ b/tests/utils.h
@@ -316,6 +316,8 @@
 
 bool IsLowRamDevice();
 
+int64_t NanoTime();
+
 class Errno {
  public:
   Errno(int e) : errno_(e) {}