Commit 337e166e23 for qemu.org

commit 337e166e23ce10168926620b1ed886f0f093a324
Author: Warner Losh <imp@bsdimp.com>
Date:   Wed May 27 23:22:19 2026 -0600

    bsd-user: Implement exterrctl(2)

    Reviewed-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
    Signed-off-by: Warner Losh <imp@bsdimp.com>

diff --git a/bsd-user/freebsd/os-misc.h b/bsd-user/freebsd/os-misc.h
index be549c4bd9..fa40261da3 100644
--- a/bsd-user/freebsd/os-misc.h
+++ b/bsd-user/freebsd/os-misc.h
@@ -9,6 +9,9 @@
 #define OS_MISC_H

 #include <sys/cpuset.h>
+#ifdef TARGET_FREEBSD_NR_exterrctl
+#include <sys/exterrvar.h>
+#endif
 #include <sys/random.h>
 #include <sched.h>
 #include <kenv.h>
@@ -538,4 +541,17 @@ static inline abi_long do_freebsd_kenv(abi_long action, abi_ulong name,
     return ret;
 }

+#ifdef TARGET_FREEBSD_NR_exterrctl
+static inline abi_long do_freebsd_exterrctl(abi_long op, abi_long flags, abi_long ptr)
+{
+    void *hostptr = 0;
+
+    if (op == EXTERRCTL_ENABLE) {
+        hostptr = g2h_untagged(ptr);
+    }
+
+    return get_errno(exterrctl(op, flags, hostptr));
+}
+#endif
+
 #endif /* OS_MISC_H */
diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c
index 7e400c89bc..e87924fbb5 100644
--- a/bsd-user/freebsd/os-syscall.c
+++ b/bsd-user/freebsd/os-syscall.c
@@ -1592,6 +1592,12 @@ static abi_long freebsd_syscall(CPUArchState *env, int num, abi_long arg1,
         ret = do_freebsd_kenv(arg1, arg2, arg3, arg4);
         break;

+#ifdef TARGET_FREEBSD_NR_exterrctl
+    case TARGET_FREEBSD_NR_exterrctl:
+        ret = do_freebsd_exterrctl(arg1, arg2, arg3);
+        break;
+#endif
+
     /* XXX */
     case TARGET_FREEBSD_NR_cap_rights_limit:
     case TARGET_FREEBSD_NR_cap_ioctls_limit: